@walkeros/server-source-aws 4.1.2 → 4.1.3-next-1780071196115
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 +8 -0
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +3 -3
- package/package.json +3 -3
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:()=>i,HttpMethod:()=>a,SettingsSchema:()=>u,settings:()=>d,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 a=r.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),i=r.union([r.string(),r.array(r.string()),r.literal("*")]),c=r.object({origin:i.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:r.array(a).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")}),d=o(u);import{zodToSchema as l}from"@walkeros/core/dev";import{z as p}from"@walkeros/core/dev";var f=p.object({queueName:p.string().min(1).describe("SQS queue short name (like walkeros-events). Required for both setup and runtime poll."),region:p.string().describe("AWS region (like eu-central-1). Default: eu-central-1.").optional(),queueUrl:p.string().url().describe("Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.").optional(),client:p.any().describe("Pre-configured AWS SQSClient instance. Bypasses construction when supplied.").optional(),config:p.any().describe("AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).").optional(),decoder:p.enum(["json","text","raw"]).describe("Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.").optional(),maxMessages:p.number().int().min(1).max(10).describe("SQS receive batch size. Cap 10. Default: 10.").optional(),waitTimeSeconds:p.number().int().min(0).max(20).describe("Long-poll duration in seconds. Cap 20. Default: 20.").optional(),visibilityTimeout:p.number().int().nonnegative().describe("Per-receive visibility timeout override. Default: queue-configured value.").optional(),shutdownTimeoutMs:p.number().int().positive().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.").optional(),onPushError:p.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=l(f),w=l(m),v={};t(v,{createTrigger:()=>Pt,env:()=>b,step:()=>O,trigger:()=>$t});var b={};t(b,{push:()=>q});var k=()=>()=>Promise.resolve({ok:!0}),S=()=>{},I={error:S,warn:S,info:S,debug:S,throw:e=>{throw"string"==typeof e?new Error(e):e},json:S,scope:()=>I},q={get push(){return k()},get command(){return k()},get elb(){return k()},logger:I},O={};t(O,{apiGatewayV1Post:()=>A,lambdaGet:()=>C,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"}}]]},A={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"}}]]},C={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 D}from"@walkeros/core";import{assign as T,createLogger as j}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 N,emitStep as B,getId as z,getGrantedConsent as G,getNextSteps as F,isDefined as L,isFunction as K,isObject as Q,processEventMapping as J,stepId as U,tryCatchAsync as W,useHooks as V}from"@walkeros/core";import{emitStep as Y}from"@walkeros/core";import{isArray as X,FatalError as Z}from"@walkeros/core";import{tryCatch as ee,tryCatchAsync as te}from"@walkeros/core";import{createIngest as ne,FatalError as oe,getMappingValue as se,tryCatchAsync as re,getNextSteps as ae,compileCache as ie,checkCache as ce,storeCache as ue,applyUpdate as de,buildCacheContext as le}from"@walkeros/core";import{createIngest as pe,emitStep as fe,FatalError as ge,isObject as he,stepId as me,tryCatchAsync as ye,useHooks as we,getNextSteps as ve,compileCache as be,checkCache as ke,storeCache as Se,buildCacheContext as Ie,validateStepEntry as qe,processEventMapping as Oe}from"@walkeros/core";import{assign as xe,getSpanId as Ae,isFunction as Ce,isString as De}from"@walkeros/core";import{isObject as Te}from"@walkeros/core";import{createIngest as je,emitStep as Ee,FatalError as Me,getGrantedConsent as Pe,processEventMapping as $e,tryCatchAsync as _e,useHooks as Re}from"@walkeros/core";import{FatalError as He,useHooks as Ne,tryCatchAsync as Be}from"@walkeros/core";import{emitStep as ze,useHooks as Ge}from"@walkeros/core";import{compileMatcher as Fe,emitStep as Le}from"@walkeros/core";var Ke={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",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function Qe(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 Je(e,t){return e.storeId&&t.stores[e.storeId]?t.stores[e.storeId]:t.stores.__cache}function Ue(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 We(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 Ve(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 Ye(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:pe(n),config:t.config,env:tt(t.config.env)};s.debug("init");const a=await we(t.init,"TransformerInit",e.hooks,e.logger)(r);if(!1===a)return!1;t.config={...a||t.config,env:a?.env||t.config.env,init:!0},s.debug("init done")}return!0}async function Xe(e,t,n,o,s,r){const a=t.type||"unknown",i=e.logger.scope(`transformer:${a}`),c={collector:e,logger:i,id:n,ingest:s,config:t.config,env:{...tt(t.config.env),...r?{respond:r}:{}}};i.debug("push",{event:o.name});const u="string"==typeof o.id?o.id:"",d=Date.now(),l=Qe(e,{stepId:me("transformer",n),stepType:"transformer",phase:"in",eventId:u,now:d});fe(e,l);try{const s=await we(t.push,"TransformerPush",e.hooks,e.logger)(o,c),r=Date.now(),a=Qe(e,{stepId:me("transformer",n),stepType:"transformer",phase:"out",eventId:u,now:r});return a.durationMs=r-d,a.outEvent=s,fe(e,a),i.debug("push done"),s}catch(t){const o=Date.now(),s=Qe(e,{stepId:me("transformer",n),stepType:"transformer",phase:"error",eventId:u,now:o});throw s.durationMs=o-d,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},fe(e,s),t}}function Ze(e,t){return e?{...e,_meta:{...e._meta,path:[...e._meta.path]}}:pe(t)}async function et(e,t,n,o,s,r,a){s||(s=pe(n[0]??"chain")),a&&s._meta&&(s._meta.chainPath=a);let i=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 ye(Ye,t=>{if(t instanceof ge)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(a&&void 0!==r.config?.chainMocks?.[a]){const t=r.config.chainMocks[a];e.logger.scope(`transformer:${r.type||"unknown"}`).debug("chainMock",{chain:a}),i=t;continue}if(void 0!==r.config?.mock){e.logger.scope(`transformer:${r.type||"unknown"}`).debug("mock"),i=r.config.mock;continue}if(r.config?.disabled)continue;const u=r.config?.cache,d=u?be(u):void 0,l=d?Je(d,e):void 0;let p;if(d&&l){const e=Ie(s,i),t=await ke(d,l,e);if("HIT"===t?.status&&t.value){if(i=t.value,d.stop)return{event:i,respond:c,stopped:!0};continue}"MISS"===t?.status&&(p={key:t.key,ttl:t.rule.ttl})}const f=r.config.before;if(f){const n=ve(f,Ie(s,i));if(1===n.length){const o=Ve(n[0],Ue(t));if(o.length>0){const n=await et(e,t,o,i,s,c,a);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),i=Array.isArray(n.event)?n.event[0]:n.event}}else n.length>1&&await Promise.all(n.map(n=>ye(et,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Ve(n,Ue(t)),i,Ze(s,n),void 0,a)))}const g=await ye(Xe,t=>(e.logger.scope(`transformer:${r.type||"unknown"}`).error("Push failed",{error:t}),!1))(e,r,o,i,s,c);if(!1===g)return{event:null,respond:c};if(Array.isArray(g)){const r=n.slice(n.indexOf(o)+1),u=await Promise.all(g.map(async n=>{const o=n.event||i,u=Ze(s,"unknown");if(n.next){const s=ve(n.next,Ie(u,o));if(0===s.length)return{event:o,respond:c};if(1===s.length){const n=Ve(s[0],Ue(t));return n.length>0?et(e,t,n,o,u,c,a):{event:o,respond:c}}return(await Promise.all(s.map(n=>ye(et,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Ve(n,Ue(t)),o,Ze(u,n),void 0,a)))).map(e=>({event:e.event,respond:void 0}))}return r.length>0?et(e,t,r,o,u,c,a):{event:o,respond:c}}));let d=c;const l=[];for(const e of u.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const t=e;if(t.respond&&(d=t.respond),null===t.event)continue;Array.isArray(t.event)?l.push(...t.event):l.push(t.event)}else l.push(e);return 0===l.length?{event:null,respond:d}:1===l.length?{event:l[0],respond:d}:{event:l,respond:d}}if(g&&"object"==typeof g){const{event:n,respond:o,next:r}=g;if(o&&(c=o),void 0!==r){const o=ve(r,Ie(s,i));if(0===o.length){n&&(i=n);continue}if(1===o.length){const u=Ve(o[0],Ue(t));return u.length>0?et(e,t,u,n||i,s,c,a):(e.logger.warn(`Branch target not found: ${JSON.stringify(r)}`),{event:null,respond:c})}return await Promise.all(o.map(o=>ye(et,t=>(e.logger.scope("transformer:many").error(`many branch ${o} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Ve(o,Ue(t)),n||i,Ze(s,o),void 0,a))),{event:null,respond:void 0}}n&&(i=n)}p&&l&&Se(l,p.key,i,p.ttl);const h=r.config.next,m="string"==typeof h||Array.isArray(h)&&h.every(e=>"string"==typeof e),y=void 0!==h&&!m;if((!g||"object"==typeof g&&!g.next)&&y){const n=ve(r.config.next,Ie(s,i));if(1===n.length){const o=Ve(n[0],Ue(t));return o.length>0?et(e,t,o,i,s,c,a):{event:i,respond:c}}return n.length>1?(await Promise.all(n.map(n=>ye(et,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Ve(n,Ue(t)),i,Ze(s,n),void 0,a))),{event:null,respond:void 0}):{event:i,respond:c}}}return{event:i,respond:c}}function tt(e){return e&&he(e)?e:{}}function nt(e){return"string"==typeof e||!(!Array.isArray(e)||!e.every(e=>"string"==typeof e))}async function ot(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)await re(t.on,t=>{if(t instanceof oe)throw t;e.status.failed++,e.logger.scope("source").error("source on flush failed",{sourceId:s,type:n,error:t})})(n,r)}function st(e){return Boolean(e.config.init)&&!e.config.require?.length}async function rt(e,t,n){const{code:o,config:s={},env:r={},primary:a,next:i,before:c,cache:u}=n,d=u,l=d?ie({...d,stop:d.stop??!0}):void 0,p=nt(i)?Ve(i,Ue(e.transformers)):void 0,f=nt(c)?Ve(c,Ue(e.transformers)):void 0,g=r.push,h=g??e.push,m=Boolean(g),y=async(n,o,r)=>{let a;const u=f??(void 0!==c?(()=>{const t=ae(c,le(r.ingest));return 0===t.length?[]:Ve(1===t.length?t[0]:t,Ue(e.transformers))})():[]);let d=[n];if(u.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const o=await et(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),d=Array.isArray(o.event)?o.event:[o.event]}if(l){const t=Je(l,e);if(t){const n=le(r.ingest),o=await ce(l,t,n);if(o){if("HIT"===o.status&&void 0!==o.value&&l.stop){let t=o.value;return o.rule.update&&(t=await de(t,o.rule.update,{...n,cache:{status:"HIT"}},e)),r.respond?.(t),{ok:!0}}if("MISS"===o.status&&l.stop&&r.respond){const s=r.respond,i=o.rule.update,c={...n,cache:{status:"MISS"}},u=o.key,d=o.rule.ttl,l=n=>{ue(t,u,n,d),i?a=(async()=>{const t=await de(n,i,c,e);s(t)})():s(n)};r.respond=l}"MISS"!==o.status||l.stop||ue(t,o.key,!0,o.rule.ttl)}}}const g=p?{kind:"single",preChain:p}:void 0!==i?(()=>{const t=ae(i,le(r.ingest));return 0===t.length?{kind:"single",preChain:[]}:1===t.length?{kind:"single",preChain:Ve(t[0],Ue(e.transformers))}:{kind:"many",branches:t.map(t=>Ve(t,Ue(e.transformers)))}})():{kind:"single",preChain:[]};let y={ok:!0};for(const n of d)"many"===g.kind?(await Promise.all(g.branches.map((a,i)=>re(async()=>m?h(n):h(n,{...o,id:t,ingest:Ze(r.ingest,`${t}.${i}`),respond:void 0,mapping:s,preChain:a}),t=>(e.logger.scope("source:many").error(`many branch ${i} failed`,{error:t}),{ok:!0}))())),y={ok:!0}):y=m?await h(n):await h(n,{...o,id:t,ingest:r.ingest,respond:r.respond,mapping:s,preChain:g.preChain});return a&&await a,y},w=async n=>{const o=ne(t);if(!s.ingest||void 0===n)return o;const r=await se(n,s.ingest,{collector:e});return{...o,...r,_meta:o._meta}},v=e.logger.scope("source").scope(t),b={command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:v,...r,push:async(e,n={})=>{const o={ingest:ne(t),respond:void 0};return y(e,n,o)}},k={collector:e,logger:v,id:t,config:s,env:b,withScope:async(e,t,n)=>{const o={ingest:await w(e),respond:t};return n({...b,push:(e,t={})=>y(e,t,o),ingest:o.ingest,respond:o.respond})}},S=await re(o,n=>{if(n instanceof oe)throw n;e.status.failed++,e.logger.scope("source").error("source factory failed",{sourceId:t,error:n})})(k);if(!S)return;const I=S.type||"unknown",q=e.logger.scope(I).scope(t);return b.logger=q,a&&(S.config={...S.config,primary:a}),S}function at(e,t,n,o){if(n instanceof Z)throw n;e.logger.scope("on").error("on callback failed",{kind:t,...o,error:n})}function it(e,t){return{collector:e,logger:e.logger.scope("on").scope(String(t))}}function ct(e,t,n,o,s){if(!t.on)return;const r=t.type||"unknown",a=e.logger.scope(r).scope("on").scope(o),i={collector:e,logger:a,id:n,config:t.config,data:s,env:Ot(t.env,t.config.env)};ee(t.on,t=>at(e,"destination",t,{destId:n,type:o}))(o,i)}function ut(e,t,n,o){let s;switch(t){case Ke.Consent:s=o||e.consent;break;case Ke.Session:s=e.session;break;case Ke.User:s=o||e.user;break;case Ke.Custom:s=o||e.custom;break;case Ke.Globals:s=o||e.globals;break;case Ke.Config:s=o||e.config;break;case Ke.Ready:case Ke.Run:default:s=void 0}if(n.length)switch(t){case Ke.Consent:!function(e,t,n){const o=n||e.consent,s=it(e,Ke.Consent);t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{ee(t[n],t=>at(e,"consent",t,{key:n}))(o,s)})})}(e,n,o);break;case Ke.Ready:!function(e,t){if(!e.allowed)return;const n=it(e,Ke.Ready);t.forEach(t=>{ee(t,t=>at(e,"ready",t))(void 0,n)})}(e,n);break;case Ke.Run:!function(e,t){if(!e.allowed)return;const n=it(e,Ke.Run);t.forEach(t=>{ee(t,t=>at(e,"run",t))(void 0,n)})}(e,n);break;case Ke.Session:!function(e,t){if(!e.session)return;const n=it(e,Ke.Session);t.forEach(t=>{ee(t,t=>at(e,"session",t))(e.session,n)})}(e,n);break;default:{const o=it(e,t);n.forEach(n=>{"function"==typeof n&&ee(n,n=>at(e,"generic",n,{type:t}))(s,o)});break}}}function dt(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 lt=new WeakMap;function pt(e,t,n,o){lt.get(e)||(lt.set(e,!0),t.warn(n,o))}function ft(e){lt.delete(e)}var gt=Object.freeze({batched:!0});function ht(e){return e===gt}function mt(e){return void 0===e?{}:"number"==typeof e?{wait:e}:{wait:e.wait,size:e.size,age:e.age}}function yt(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 wt(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 vt(e,t,n){if(!e)return[];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return Ve(e,t);if("string"==typeof e)return Ve(e,t);const o=F(e,M(n));return 0===o.length?[]:1===o.length?Ve(o[0],t):Ve(o,t)}async function bt(e,t,n={},o){const{allowed:s,consent:r,globals:a,user:i}=e;if(!s)return It({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=dt(e.queue,t,{max:n});if(o.dropped>0){const t=wt(e.status,U("collector"),"queue",o.dropped);pt(e.queue,e.logger,"collector.queue overflow; oldest events dropped",{buffer:"queue",cap:n,droppedCount:t})}else e.queue.length<n&&ft(e.queue);e.status.in++}o||(o=e.destinations);const c=e.transformers?Ue(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 d=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 kt(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 l=[],p=u.filter(t=>{const n=G(s.config.consent,r,t.consent);if(n)return t.consent=n,l.push(t),!1;const a=Qe(e,{stepId:U("destination",o),stepType:"destination",phase:"skip",eventId:"string"==typeof t.id?t.id:"",now:Date.now()});return a.skipReason="consent",r&&(a.consent={...r}),s.config.consent&&(a.meta={required:{...s.config.consent}}),B(e,a),!0});if(p.length>0){const t=s.queuePush,n=s.config.id||o,r={max:s.config.queueMax??1e3};let a=0;for(const e of p)a+=dt(t,e,r).dropped;if(a>0){yt(e,n);const o=wt(e.status,U("destination",n),"queue",a);pt(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&&ft(t)}if(!l.length)return{id:o,destination:s,queue:u};let f,g,h=!1;try{h=await kt(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=vt(s.config.before,c,d),y=s.config.next,w=s.config?.cache,v=w?$(w):void 0,b=v?Je(v,e):void 0;let k=0,S=0;return await Promise.all(l.map(async t=>{let r;if(t.globals=E(a,t.globals),t.user=E(i,t.user),v?.stop&&b){const e=M(d,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,l=n.respond;if(m.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const s=await et(e,e.transformers,m,t,d,n.respond,`destination.${o}.before`);if(null===s.event)return t;s.respond&&(l=s.respond),u=Array.isArray(s.event)?s.event[0]:s.event}if(v&&!v.stop&&b){const e=M(d,u),n=await _(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}const p=Date.now();let h=!1;const w=await W(St,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,a=s.config.id||o,i={max:s.config.dlqMax??100},c=dt(r,[u,t],i);if(c.dropped>0){yt(e,a);const t=wt(e.status,U("destination",a),"dlq",c.dropped);pt(r,e.logger.scope(s.type||"unknown"),"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:a,cap:i.max,droppedCount:t})}else r.length<i.max&&ft(r)})(e,s,o,u,d,l);if(k+=Date.now()-p,r&&b&&void 0===s.config.mock&&R(b,r.key,w??!0,r.ttl),void 0===w||ht(w)||(g=w),ht(w)&&S++,!h&&y){void 0!==w&&(d._response=w);const t=vt(y,c,d);if(t.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const n=await et(e,e.transformers,t,u,d,l,`destination.${o}.next`);n.respond&&(l=n.respond)}}return t})),{id:o,destination:s,error:f,response:g,totalDuration:k,batchedCount:S,allowedCount:l.length}})),d={},l={},p={};for(const t of u){if(t.skipped)continue;const n=t.destination,o={type:n.type||"unknown",data:t.response};yt(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)l[t.id]=o;else{const n=t.batchedCount??0,a=t.allowedCount??0;(Math.max(0,a-n)>0||0===a)&&(d[t.id]=o,s.count++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.out++)}}return It({event:t,...Object.keys(d).length&&{done:d},...Object.keys(l).length&&{queued:l},...Object.keys(p).length&&{failed:p}})}async function kt(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:Ot(t.env,t.config.env)};s.debug("init");const a=Date.now();let i;B(e,Qe(e,{stepId:U("destination",n),stepType:"destination",phase:"init",eventId:"",now:a}));try{i=await V(t.init,"DestinationInit",e.hooks,e.logger)(r)}catch(t){const o=Date.now(),s=Qe(e,{stepId:U("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)},B(e,s),t}if(!1===i)return i;if(t.config={...i||t.config,init:!0},t.queueOn?.length){const o=t.queueOn;t.queueOn=[];for(const{type:s,data:r}of o)ct(e,t,n,s,r)}s.debug("init done")}return!0}async function St(e,t,n,o,s,r){const{config:a}=t,i=await J(o,a,e);if(i.ignore)return!1;const c=t.type||"unknown",u=e.logger.scope(c),d={collector:e,logger:u,id:n,config:a,data:i.data,rule:i.mapping,ingest:s,env:{...Ot(t.env,a.env),...r?{respond:r}:{}}};if(void 0!==a.mock)return u.debug("mock",{event:i.event.name}),a.mock;const l=i.mapping,p=i.mappingKey||"* *";if(l?.batch&&t.pushBatch&&void 0===a.mock){if(t.batches=t.batches||{},!t.batches[p]){const o={key:p,entries:[],events:[],data:[]},s=mt(l.batch),r=mt(a.batch),i=s.wait??r.wait??3e4,c=s.size??r.size??1e3,d=s.age??r.age??3e4,f=Ot(t.env,a.env),g=N(async()=>{const o=t.batches[p].batched;if(0===o.entries.length)return;const s={key:o.key,entries:o.entries,events:o.events,data:o.data};o.entries=[],o.events=[],o.data=[];const r=s.entries[0],i={collector:e,logger:u,id:n,config:a,data:void 0,rule:r.rule,ingest:r.ingest,env:{...f,...r.respond?{respond:r.respond}:{}}};u.debug("push batch",{events:s.entries.length});const c=t.config.id||n,d=yt(e,c),l=Date.now(),g=Qe(e,{stepId:U("destination",n),stepType:"destination",phase:"flush",eventId:"",now:l});g.batch={size:s.entries.length,index:0},B(e,g);let h=!0;await W(V(t.pushBatch,"DestinationPushBatch",e.hooks,e.logger),o=>{h=!1;const r=Date.now(),a=Qe(e,{stepId:U("destination",n),stepType:"destination",phase:"error",eventId:"",now:r});a.durationMs=r-l,a.error=o instanceof Error?{name:o.name,message:o.message}:{message:String(o)},a.batch={size:s.entries.length,index:0},B(e,a);const i=t.dlq=t.dlq||[],p={max:t.config.dlqMax??100};let f=0;for(const e of s.entries)f+=dt(i,[e.event,o],p).dropped;if(f>0){const t=wt(e.status,U("destination",c),"dlq",f);pt(i,u,"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:c,cap:p.max,droppedCount:t})}else i.length<p.max&&ft(i);d.failed+=s.entries.length,d.dlqSize=i.length,e.status.failed+=s.entries.length,u.error("Push batch failed",{error:o instanceof Error?o.message:String(o),entries:s.entries.length})})(s,i),u.debug("push batch done"),d.inFlightBatch=Math.max(0,(d.inFlightBatch??0)-s.entries.length),h&&(d.count+=s.entries.length,d.lastAt=Date.now(),e.status.out+=s.entries.length)},{wait:i,size:c,age:d});t.batches[p]={batched:o,batchFn:()=>{g()},flush:async()=>{await g.flush()}}}const o=t.batches[p];o.batched.entries.push({event:i.event,ingest:s,respond:r,rule:l,data:i.data}),o.batched.events.push(i.event),L(i.data)&&o.batched.data.push(i.data);const c=t.config.id||n,d=yt(e,c);return d.inFlightBatch=(d.inFlightBatch??0)+1,o.batchFn(),gt}{u.debug("push",{event:i.event.name});const o="string"==typeof i.event.id?i.event.id:"",s=Date.now(),r=Qe(e,{stepId:U("destination",n),stepType:"destination",phase:"in",eventId:o,now:s});i.mappingKey&&(r.mappingKey=i.mappingKey),i.event.consent&&(r.consent={...i.event.consent}),B(e,r);try{const r=await V(t.push,"DestinationPush",e.hooks,e.logger)(i.event,d),a=Date.now(),c=Qe(e,{stepId:U("destination",n),stepType:"destination",phase:"out",eventId:o,now:a});return c.durationMs=a-s,c.outEvent=r,i.mappingKey&&(c.mappingKey=i.mappingKey),B(e,c),u.debug("push done"),r}catch(t){const r=Date.now(),a=Qe(e,{stepId:U("destination",n),stepType:"destination",phase:"error",eventId:o,now:r});throw a.durationMs=r-s,a.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},i.mappingKey&&(a.mappingKey=i.mappingKey),B(e,a),t}}}function It(e){return{ok:!e?.failed,...e}}function qt(e){const{code:t,config:n={},env:o={},cache:s}=e,{config:r}=We(e,"before"),{config:a}=We({...e,config:r},"next"),i={...t.config,...n,...a};s&&(i.cache=s);const c=Ot(t.env,o);return{...t,config:i,env:c}}function Ot(e,t){return e||t?t?e&&Q(e)&&Q(t)?{...e,...t}:t:e:{}}async function xt(e,t,n){const o=Object.entries(e).map(async([e,o])=>{const s=o.destroy;if(!s)return;const r=o.type||"unknown",a=n.scope(r),i={id:e,config:o.config,env:o.env??{},logger:a};try{await Promise.race([s(i),new Promise((n,o)=>setTimeout(()=>o(new Error(`${t} '${e}' destroy timed out`)),5e3))])}catch(n){a.error(`${t} '${e}' destroy failed: ${n}`)}});await Promise.allSettled(o)}async function At(e,t,n){let o,s,r=!1;switch(t){case Ke.Config:Te(n)&&(xe(e.config,n,{shallow:!1}),s=n,r=!0);break;case Ke.Consent:if(Te(n)){const{update:t}=function(e,t){const n={};return Object.entries(t).forEach(([e,t])=>{n[e]=!!t}),e.consent=D(e.consent,n),{update:n}}(e,n);s=t,r=!0}break;case Ke.Custom:Te(n)&&(e.custom=xe(e.custom,n),s=n,r=!0);break;case Ke.Destination:Te(n)&&"code"in n&&Te(n.code)&&(o=await async function(e,t){const{code:n,config:o={},env:s={},before:r,next:a,cache:i}=t;if(!K(n.push))return It({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const c=o||{init:!1};let u=r?{...c,before:r}:{...c};a&&(u={...u,next:a}),i&&(u={...u,cache:i});const d={...n,config:u,env:Ot(n.env,s)};let l=d.config.id;if(!l)do{l=z(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[l]);return e.destinations[l]=d,!1!==d.config.queue&&(d.queuePush=[...e.queue]),bt(e,void 0,{},{[l]:d})}(e,n));break;case Ke.Globals:Te(n)&&(e.globals=xe(e.globals,n),s=n,r=!0);break;case Ke.Hook:if(Te(n)&&De(n.name)&&Ce(n.fn)){const{name:t,fn:o}=n;e.hooks[t]=o,s=n,r=!0}break;case Ke.On:if(Te(n)&&De(n.type)){const{type:t,rules:o}=n;await async function(e,t,n){const o=e.on,s=o[t]||[],r=X(n)?n:[n];r.forEach(e=>{s.push(e)}),o[t]=s,ut(e,t,r)}(e,t,o)}break;case Ke.Ready:r=!0;break;case Ke.Run:o=await async function(e,t){return e.allowed=!0,e.timing=Date.now(),t&&(t.consent&&(e.consent=xe(e.consent,t.consent)),t.user&&(e.user=xe(e.user,t.user)),t.globals&&(e.globals=xe(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=xe(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await bt(e)}(e,n),r=!0;break;case Ke.Session:r=!0;break;case Ke.Shutdown:await async function(e){const t=e.logger;await xt(e.sources,"source",t),await xt(e.destinations,"destination",t),await xt(e.transformers,"transformer",t),await xt(e.stores,"store",t)}(e);break;case Ke.User:Te(n)&&(xe(e.user,n,{shallow:!1}),s=n,r=!0)}return r&&(await async function(e,t,n,o){let s,r=n||[];switch(n||(r=e.on[t]||[]),t){case Ke.Consent:s=o||e.consent;break;case Ke.Session:s=e.session;break;case Ke.User:s=o||e.user;break;case Ke.Custom:s=o||e.custom;break;case Ke.Globals:s=o||e.globals;break;case Ke.Config:s=o||e.config;break;case Ke.Ready:case Ke.Run:default:s=void 0}let a=!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&&(st(o)?!1===await te(o.on,o=>at(e,"source",o,{sourceId:n,type:t}))(t,s)&&(a=!0):(o.queueOn=o.queueOn||[],o.queueOn.push({type:t,data:s})))}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:s});ct(e,o,n,t,s)}});for(const[t,n]of Object.entries(e.sources))st(n)&&n.queueOn?.length&&await ot(e,n,t);return Object.keys(e.pending.destinations).length>0&&await async function(e,t){for(const[n,o]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[n]||e.destinations[n])continue;const s=o.config?.require;if(!s)continue;const r=s.indexOf(t);if(-1===r)continue;if(s.splice(r,1),s.length>0)continue;delete e.pending.destinations[n];const a=qt(o);!1!==a.config.queue&&(a.queuePush=[...e.queue]),e.destinations[n]=a}}(e,t),ut(e,t,r,o),!a}(e,t,void 0,s),o=await bt(e)),o||It({ok:!0})}function Ct(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:a={},context:i={},globals:c=e.globals,custom:u={},user:d=e.user,nested:l=[],consent:p=e.consent,id:f=Ae(),trigger:g="",entity:h=n,action:m=o,timing:y=0,source:w={type:"collector",schema:"4"}}=t;return{name:r,data:a,context:i,globals:c,custom:u,user:d,nested:l,consent:p,id:f,trigger:g,entity:h,action:m,timestamp:s,timing:y,source:w}}function Dt(e={}){const t=e.maxEntries??1e4,n=e.lowWaterMark??.8,o=e.sweepIntervalMs??6e4,s=Math.floor(t*n),r=new Map,a={hits:0,misses:0,populates:0,writes:0,deletes:0,evictions_entries:0,evictions_ttl:0};let i;return o>0&&(i=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++);a.evictions_ttl+=t},o),i&&"function"==typeof i.unref&&i.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),a.evictions_ttl++,void a.misses++):(r.delete(e),r.set(e,t),a.hits++,t.value);a.misses++},set(e,n,o){const i=!r.has(e);i||r.delete(e),r.set(e,{value:n,expires:void 0!==o?Date.now()+o:void 0}),a.writes++,i&&a.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++}a.evictions_entries+=n}()},delete(e){r.delete(e)&&a.deletes++},get counters(){return{...a}},destroy(){void 0!==i&&(clearInterval(i),i=void 0),r.clear()}}}function Tt(e,t){const{cacheConfig:n,cacheStore:o,namespace:s,logger:r,storeId:a,collector:i}=t,c=(e,t)=>{if(!i)return;const n=Qe(i,{stepId:`store.${a}`,stepType:"store",phase:"in",eventId:"",now:Date.now()});n.meta={op:"cache",cached:"hit"===t,status:t,key:e},Le(i,n)},u={hits:0,misses:0,populates:0,writes:0,deletes:0,inflight_dedups:0},d=n.rules.map(e=>({match:e.match?Fe(e.match):()=>!0,ttl:e.ttl})),l=e=>`${s}:${e}`;function p(e,t){const n=void 0===t?{key:e}:{key:e,value:t};return d.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=l(t),s=await o.get(n);if(void 0!==s)return u.hits++,c(t,"hit"),s;const r=f.get(n);if(r)return u.inflight_dedups++,c(t,"hit"),r;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{await o.set(n,s,1e3*r.ttl),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{await o.set(l(t),n,1e3*r.ttl)}catch(e){g("set",t,e)}},async delete(t){u.deletes++,await e.delete(t);try{await o.delete(l(t))}catch(e){g("delete",t,e)}}};function g(e,t,n){const o=`store-cache(${a}): cache ${e} failed for "${t}"; backing succeeded, continuing`;r?r.warn(o,{error:n}):console.warn(o,n)}}function jt(e,t,n){const o=`store.${n}`,s=Ge(t.get,"StoreGet",e.hooks,e.logger),r=Ge(t.set,"StoreSet",e.hooks,e.logger),a=Ge(t.delete,"StoreDelete",e.hooks,e.logger);t.get=async t=>{const n=Date.now(),r=Qe(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});r.meta={op:"get",key:t},ze(e,r);try{const r=await s(t),a=Date.now(),i=Qe(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:a});return i.durationMs=a-n,i.meta={op:"get",key:t},ze(e,i),r}catch(s){const r=Date.now(),a=Qe(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw a.durationMs=r-n,a.meta={op:"get",key:t},a.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},ze(e,a),s}},t.set=async(t,n,s)=>{const a=Date.now(),i=Qe(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:a});i.meta={op:"set",key:t},ze(e,i);try{await r(t,n,s);const i=Date.now(),c=Qe(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:i});c.durationMs=i-a,c.meta={op:"set",key:t},ze(e,c)}catch(n){const s=Date.now(),r=Qe(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:s});throw r.durationMs=s-a,r.meta={op:"set",key:t},r.error=n instanceof Error?{name:n.name,message:n.message}:{message:String(n)},ze(e,r),n}},t.delete=async t=>{const n=Date.now(),s=Qe(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});s.meta={op:"delete",key:t},ze(e,s);try{await a(t);const s=Date.now(),r=Qe(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:s});r.durationMs=s-n,r.meta={op:"delete",key:t},ze(e,r)}catch(s){const r=Date.now(),a=Qe(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw a.durationMs=r-n,a.meta={op:"delete",key:t},a.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},ze(e,a),s}}}async function Et(e){const t=T({globalsStatic:{},sessionStatic:{},run:!0,queueMax:1e3},e,{merge:!1,extend:!1}),n={level:e.logger?.level,handler:e.logger?.handler},o=j(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,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:{}},push:void 0,command:void 0};var a,i;r.push=function(e,t){const n=Re(async(n,o={})=>await _e(async()=>{const s=Date.now(),{id:r,ingest:a,respond:i,mapping:c,preChain:u,include:d,exclude:l}=o;let p=i,f=n;const g=d||l?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,d,l):void 0,h=a??je(r||"unknown");if(c){const t=await $e(f,c,e);if(t.ignore)return It({ok:!0});if(c.consent&&!Pe(c.consent,e.consent,t.event.consent))return It({ok:!0});f=t.event}if(u?.length&&e.transformers&&Object.keys(e.transformers).length>0){const n=await et(e,e.transformers,u,f,h,p,r?`source.${r}.next`:void 0);if(null===n.event)return It({ok:!0});if(n.stopped)return n.respond&&(p=n.respond),It({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=Ct(e,o);return bt(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]??It({ok:!0})}f=n.event}const m=t(f),y=Ct(e,m),w=await bt(e,y,{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 w},t=>{if(t instanceof Me)throw t;return e.status.failed++,e.logger.error("push failed",{event:n,ingest:o.ingest,error:t}),It({ok:!1})})(),"Push",e.hooks,e.logger);return async(t,o)=>{const s="string"==typeof t.id?t.id:"",r=Date.now();Ee(e,Qe(e,{stepId:"collector.push",stepType:"collector",phase:"in",eventId:s,now:r}));try{const a=await n(t,o),i=Date.now(),c=Qe(e,{stepId:"collector.push",stepType:"collector",phase:"out",eventId:s,now:i});return c.durationMs=i-r,c.outEvent=a,Ee(e,c),a}catch(t){const n=Date.now(),o=Qe(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)},Ee(e,o),t}}}(r,e=>({timing:Math.round((Date.now()-r.timing)/10)/100,source:{type:"collector",schema:"4",version:"4.1.2"},...e})),r.command=(i=At,Ne(async(e,t,n)=>await Be(async()=>await i(a,e,t,n),n=>{if(n instanceof He)throw n;return a.status.failed++,a.logger.error("command failed",{command:e,data:t,error:n}),It({ok:!1})})(),"Command",(a=r).hooks,a.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:a={}}=s,i=e.logger.scope("store").scope(o),c={collector:e,logger:i,id:o,config:r,env:a},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 a=t[r];if("BLACK"===a)return;if("GRAY"===a){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 i=e[r].cache?.store;if(void 0!==i){if(!(i in e))throw new Error(`Store "${r}" cache.store references "${i}", which is not declared in flow.stores`);s(i)}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,a;void 0!==s.store?(r=n[s.store],a=s.store):(n.__cache||(n.__cache=Dt()),r=n.__cache,a="__cache");const i=s.namespace??t;e.logger.scope("store-cache").scope(t).info(`store "${t}" caches with namespace "${i}:" via ${a}`),n[t]=Tt(n[t],{storeId:t,cacheConfig:s,cacheStore:r,namespace:i,logger:e.logger.scope("store-cache").scope(t),collector:e})}for(const[t,o]of Object.entries(n))"__cache"!==t&&jt(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=Dt()),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,a=qe(s,"Transformer");if(!a.ok){e.logger.warn(`Transformer ${o} invalid (${a.code}): ${a.reason}. Skipping.`);continue}const{config:i}=We(s,"before"),{config:c}=We({...s,config:i},"next"),u=Object.keys(r).length>0?{...c,env:r}:c,{cache:d}=s,l=d?{...u,cache:d}:u,p=e.logger.scope("transformer").scope(o),f={collector:e,logger:p,id:o,ingest:pe(o),config:l,env:r},g=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 Oe(n,t,e.collector);return!o.ignore&&{event:o.event}}}}return{type:"pass",config:e.config,push:e=>({event:e})}}),h=await g(f);void 0!==s.before&&void 0===h.config?.before&&(h.config={...h.config??{},before:s.before}),void 0!==s.next&&void 0===h.config?.next&&(h.config={...h.config??{},next:s.next}),n[o]=h}return n}(r,e.transformers||{}),r}async function Mt(e){e=e||{};const t=await Et(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 a;if("string"==typeof e)a={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(a.data=t);else{if(!e||"object"!=typeof e)return It({ok:!1});a=e,t&&"object"==typeof t&&!Array.isArray(t)&&(a.data={...a.data||{},...t})}return n&&"object"==typeof n&&(a.context=n),s&&Array.isArray(s)&&(a.nested=s),r&&"object"==typeof r&&(a.custom=r),o.push(a)}});var o;t.sources.elb=n,await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const t=await rt(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 re(n.init.bind(n),n=>{if(n instanceof oe)throw n;o=!0,e.status.failed++,e.logger.scope("source").error("source init failed",{sourceId:t,error:n})})(),o||(n.config.init=!0,st(n)&&await ot(e,n,t))}return n}(t,e.sources||{});const{consent:s,user:r,globals:a,custom:i}=e;s&&await t.command("consent",s),r&&await t.command("user",r),a&&Object.assign(t.globals,a),i&&Object.assign(t.custom,i),t.config.run&&await t.command("run");let c=n.push;const u=Object.values(t.sources).filter(e=>"elb"!==e.type),d=u.find(e=>e.config.primary);return d?c=d.push:u.length>0&&(c=u[0].push),{collector:t,elb:c}}var Pt=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Mt(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,a=await r(n,s);let i;try{i=JSON.parse(a.body||"{}")}catch{i=a.body}const c={};if(a.headers)for(const[e,t]of Object.entries(a.headers))void 0!==t&&(c[e]=String(t));return{statusCode:a.statusCode,body:i,headers:c}}}};function $t(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 _t={};t(_t,{createTrigger:()=>Wt,env:()=>Rt,step:()=>Ft});var Rt={};t(Rt,{push:()=>zt,simulation:()=>Gt});var Ht=()=>{},Nt={error:Ht,warn:Ht,info:Ht,debug:Ht,throw:e=>{throw"string"==typeof e?new Error(e):e},json:Ht,scope:()=>Nt},Bt=()=>()=>Promise.resolve({ok:!0}),zt={get push(){return Bt()},get command(){return Bt()},get elb(){return Bt()},logger:Nt},Gt=["AWS.SQSClient"],Ft={};t(Ft,{decoderText:()=>Qt,malformedJson:()=>Jt,orderComplete:()=>Kt,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"]]},Kt={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"]]},Qt={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"]]},Jt={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 Ut(e){if("object"!=typeof e||null===e)return!1;const t=e;return"sqs"===t.type&&"function"==typeof t.push}var Wt=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Mt(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources??{}))if(Ut(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),a=[];return r&&"object"==typeof r&&(r.acked&&a.push(["message.ack",n.MessageId]),r.nacked&&a.push(["message.nack",n.MessageId])),a}}};export{v as examples,n as schemas,_t 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:()=>i,HttpMethod:()=>a,SettingsSchema:()=>u,settings:()=>d,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 a=r.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),i=r.union([r.string(),r.array(r.string()),r.literal("*")]),c=r.object({origin:i.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:r.array(a).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")}),d=o(u);import{zodToSchema as l}from"@walkeros/core/dev";import{z as p}from"@walkeros/core/dev";var f=p.object({queueName:p.string().min(1).describe("SQS queue short name (like walkeros-events). Required for both setup and runtime poll."),region:p.string().describe("AWS region (like eu-central-1). Default: eu-central-1.").optional(),queueUrl:p.string().url().describe("Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.").optional(),client:p.any().describe("Pre-configured AWS SQSClient instance. Bypasses construction when supplied.").optional(),config:p.any().describe("AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).").optional(),decoder:p.enum(["json","text","raw"]).describe("Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.").optional(),maxMessages:p.number().int().min(1).max(10).describe("SQS receive batch size. Cap 10. Default: 10.").optional(),waitTimeSeconds:p.number().int().min(0).max(20).describe("Long-poll duration in seconds. Cap 20. Default: 20.").optional(),visibilityTimeout:p.number().int().nonnegative().describe("Per-receive visibility timeout override. Default: queue-configured value.").optional(),shutdownTimeoutMs:p.number().int().positive().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.").optional(),onPushError:p.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=l(f),w=l(m),v={};t(v,{createTrigger:()=>zt,env:()=>b,step:()=>O,trigger:()=>Gt});var b={};t(b,{push:()=>q});var k=()=>()=>Promise.resolve({ok:!0}),S=()=>{},I={error:S,warn:S,info:S,debug:S,throw:e=>{throw"string"==typeof e?new Error(e):e},json:S,scope:()=>I},q={get push(){return k()},get command(){return k()},get elb(){return k()},logger:I},O={};t(O,{apiGatewayV1Post:()=>A,lambdaGet:()=>C,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"}}]]},A={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"}}]]},C={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 D}from"@walkeros/core";import{assign as T,createLogger as j}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 N,emitStep as B,getId as z,getGrantedConsent as G,getNextSteps as F,isDefined as L,isFunction as K,isObject as Q,processEventMapping as J,stepId as U,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 ae,tryCatchAsync as ie,getNextSteps as ce,compileCache as ue,checkCache as de,storeCache as le,applyUpdate as pe,buildCacheContext as fe,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 Ie,compileCache as qe,checkCache as Oe,storeCache as xe,buildCacheContext as Ae,validateStepEntry as Ce,processEventMapping as De,compileState as Te,applyState as je}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 Ne,getGrantedConsent as Be,processEventMapping as ze,tryCatchAsync as Ge,useHooks as Fe}from"@walkeros/core";import{FatalError as Le,useHooks as Ke,tryCatchAsync as Qe}from"@walkeros/core";import{emitStep as Je,useHooks as Ue}from"@walkeros/core";import{compileMatcher as We,emitStep as Ve}from"@walkeros/core";var Ye={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",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function Xe(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 Ze(e,t){return e.storeId&&t.stores[e.storeId]?t.stores[e.storeId]:t.stores.__cache}function et(e,t){return e?t.stores[e]:t.stores.__cache}function tt(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 nt(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 ot(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 st(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:ct(t.config.env)};s.debug("init");const a=await Se(t.init,"TransformerInit",e.hooks,e.logger)(r);if(!1===a)return!1;t.config={...a||t.config,env:a?.env||t.config.env,init:!0},s.debug("init done")}return!0}async function rt(e,t,n,o,s,r){const a=t.type||"unknown",i=e.logger.scope(`transformer:${a}`),c={collector:e,logger:i,id:n,ingest:s,config:t.config,env:{...ct(t.config.env),...r?{respond:r}:{}}};i.debug("push",{event:o.name});const u="string"==typeof o.id?o.id:"",d=Date.now(),l=Xe(e,{stepId:be("transformer",n),stepType:"transformer",phase:"in",eventId:u,now:d});ye(e,l);try{const s=await Se(t.push,"TransformerPush",e.hooks,e.logger)(o,c),r=Date.now(),a=Xe(e,{stepId:be("transformer",n),stepType:"transformer",phase:"out",eventId:u,now:r});return a.durationMs=r-d,a.outEvent=s,ye(e,a),i.debug("push done"),s}catch(t){const o=Date.now(),s=Xe(e,{stepId:be("transformer",n),stepType:"transformer",phase:"error",eventId:u,now:o});throw s.durationMs=o-d,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},ye(e,s),t}}function at(e,t){return e?{...e,_meta:{...e._meta,path:[...e._meta.path]}}:me(t)}async function it(e,t,n,o,s,r,a){s||(s=me(n[0]??"chain")),a&&s._meta&&(s._meta.chainPath=a);let i=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(st,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(a&&void 0!==r.config?.chainMocks?.[a]){const t=r.config.chainMocks[a];e.logger.scope(`transformer:${r.type||"unknown"}`).debug("chainMock",{chain:a}),i=t;continue}if(void 0!==r.config?.mock){e.logger.scope(`transformer:${r.type||"unknown"}`).debug("mock"),i=r.config.mock;continue}if(r.config?.disabled)continue;const u=r.config?.cache,d=u?qe(u):void 0,l=d?Ze(d,e):void 0,p=r.config?.state?Te(r.config.state):void 0,f=p?.filter(e=>"get"===e.mode),g=p?.filter(e=>"set"===e.mode);let h;if(d&&l){const e=Ae(s,i),t=await Oe(d,l,e);if("HIT"===t?.status&&t.value){if(i=t.value,d.stop)return{event:i,respond:c,stopped:!0};continue}"MISS"===t?.status&&(h={key:t.key,ttl:t.rule.ttl})}const m=r.config.before;if(m){const n=Ie(m,Ae(s,i));if(1===n.length){const o=ot(n[0],tt(t));if(o.length>0){const n=await it(e,t,o,i,s,c,a);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),i=Array.isArray(n.event)?n.event[0]:n.event}}else n.length>1&&await Promise.all(n.map(n=>ke(it,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,ot(n,tt(t)),i,at(s,n),void 0,a)))}f&&f.length>0&&(i=await je(f,t=>et(t,e),i,e));const y=await ke(rt,t=>(e.logger.scope(`transformer:${r.type||"unknown"}`).error("Push failed",{error:t}),!1))(e,r,o,i,s,c);if(!1===y)return{event:null,respond:c};if(Array.isArray(y)){const r=n.slice(n.indexOf(o)+1),u=await Promise.all(y.map(async n=>{const o=n.event||i,u=at(s,"unknown");if(n.next){const s=Ie(n.next,Ae(u,o));if(0===s.length)return{event:o,respond:c};if(1===s.length){const n=ot(s[0],tt(t));return n.length>0?it(e,t,n,o,u,c,a):{event:o,respond:c}}return(await Promise.all(s.map(n=>ke(it,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,ot(n,tt(t)),o,at(u,n),void 0,a)))).map(e=>({event:e.event,respond:void 0}))}return r.length>0?it(e,t,r,o,u,c,a):{event:o,respond:c}}));let d=c;const l=[];for(const e of u.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const t=e;if(t.respond&&(d=t.respond),null===t.event)continue;Array.isArray(t.event)?l.push(...t.event):l.push(t.event)}else l.push(e);return 0===l.length?{event:null,respond:d}:1===l.length?{event:l[0],respond:d}:{event:l,respond:d}}if(y&&"object"==typeof y){const{event:n,respond:o,next:r}=y;if(o&&(c=o),void 0!==r){const o=Ie(r,Ae(s,i));if(0===o.length){n&&(i=n);continue}if(1===o.length){const u=ot(o[0],tt(t));return u.length>0?it(e,t,u,n||i,s,c,a):(e.logger.warn(`Branch target not found: ${JSON.stringify(r)}`),{event:null,respond:c})}return await Promise.all(o.map(o=>ke(it,t=>(e.logger.scope("transformer:many").error(`many branch ${o} failed`,{error:t}),{event:null,respond:void 0}))(e,t,ot(o,tt(t)),n||i,at(s,o),void 0,a))),{event:null,respond:void 0}}n&&(i=n)}g&&g.length>0&&(i=await je(g,t=>et(t,e),i,e)),h&&l&&xe(l,h.key,i,h.ttl);const w=r.config.next,v="string"==typeof w||Array.isArray(w)&&w.every(e=>"string"==typeof e),b=void 0!==w&&!v;if((!y||"object"==typeof y&&!y.next)&&b){const n=Ie(r.config.next,Ae(s,i));if(1===n.length){const o=ot(n[0],tt(t));return o.length>0?it(e,t,o,i,s,c,a):{event:i,respond:c}}return n.length>1?(await Promise.all(n.map(n=>ke(it,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,ot(n,tt(t)),i,at(s,n),void 0,a))),{event:null,respond:void 0}):{event:i,respond:c}}}return{event:i,respond:c}}function ct(e){return e&&ve(e)?e:{}}function ut(e){return"string"==typeof e||!(!Array.isArray(e)||!e.every(e=>"string"==typeof e))}async function dt(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)await ie(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)}function lt(e){return Boolean(e.config.init)&&!e.config.require?.length}async function pt(e,t,n){const{code:o,config:s={},env:r={},primary:a,next:i,before:c,cache:u}=n,d=s.state??n.state,l=d?ge(d):void 0,p=u,f=p?ue({...p,stop:p.stop??!0}):void 0,g=ut(i)?ot(i,tt(e.transformers)):void 0,h=ut(c)?ot(c,tt(e.transformers)):void 0,m=r.push,y=m??e.push,w=Boolean(m),v=async(n,o,r)=>{let a;const u=h??(void 0!==c?(()=>{const t=ce(c,fe(r.ingest));return 0===t.length?[]:ot(1===t.length?t[0]:t,tt(e.transformers))})():[]);let d=[n];if(u.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const o=await it(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),d=Array.isArray(o.event)?o.event:[o.event]}if(f){const t=Ze(f,e);if(t){const n=fe(r.ingest),o=await de(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 pe(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,i=o.rule.update,c={...n,cache:{status:"MISS"}},u=o.key,d=o.rule.ttl,l=n=>{le(t,u,n,d),i?a=(async()=>{const t=await pe(n,i,c,e);s(t)})():s(n)};r.respond=l}"MISS"!==o.status||f.stop||le(t,o.key,!0,o.rule.ttl)}}}const p=g?{kind:"single",preChain:g}:void 0!==i?(()=>{const t=ce(i,fe(r.ingest));return 0===t.length?{kind:"single",preChain:[]}:1===t.length?{kind:"single",preChain:ot(t[0],tt(e.transformers))}:{kind:"many",branches:t.map(t=>ot(t,tt(e.transformers)))}})():{kind:"single",preChain:[]};l&&l.length>0&&(d=await Promise.all(d.map(t=>he(l,t=>et(t,e),t,e))));let m={ok:!0};for(const n of d)"many"===p.kind?(await Promise.all(p.branches.map((a,i)=>ie(async()=>w?y(n):y(n,{...o,id:t,ingest:at(r.ingest,`${t}.${i}`),respond:void 0,mapping:s,preChain:a}),t=>(e.logger.scope("source:many").error(`many branch ${i} 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 a&&await a,m},b=async n=>{const o=se(t);if(!s.ingest||void 0===n)return o;const r=await ae(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)}},I={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})}},q=await ie(o,n=>{if(n instanceof re)throw n;e.status.failed++,e.logger.scope("source").error("source factory failed",{sourceId:t,error:n})})(I);if(!q)return;const O=q.type||"unknown",x=e.logger.scope(O).scope(t);return S.logger=x,a&&(q.config={...q.config,primary:a}),q}function ft(e,t,n,o){if(n instanceof te)throw n;e.logger.scope("on").error("on callback failed",{kind:t,...o,error:n})}function gt(e,t){return{collector:e,logger:e.logger.scope("on").scope(String(t))}}function ht(e,t,n,o,s){if(!t.on)return;const r=t.type||"unknown",a=e.logger.scope(r).scope("on").scope(o),i={collector:e,logger:a,id:n,config:t.config,data:s,env:Et(t.env,t.config.env)};ne(t.on,t=>ft(e,"destination",t,{destId:n,type:o}))(o,i)}function mt(e,t,n,o){let s;switch(t){case Ye.Consent:s=o||e.consent;break;case Ye.Session:s=e.session;break;case Ye.User:s=o||e.user;break;case Ye.Custom:s=o||e.custom;break;case Ye.Globals:s=o||e.globals;break;case Ye.Config:s=o||e.config;break;case Ye.Ready:case Ye.Run:default:s=void 0}if(n.length)switch(t){case Ye.Consent:!function(e,t,n){const o=n||e.consent,s=gt(e,Ye.Consent);t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{ne(t[n],t=>ft(e,"consent",t,{key:n}))(o,s)})})}(e,n,o);break;case Ye.Ready:!function(e,t){if(!e.allowed)return;const n=gt(e,Ye.Ready);t.forEach(t=>{ne(t,t=>ft(e,"ready",t))(void 0,n)})}(e,n);break;case Ye.Run:!function(e,t){if(!e.allowed)return;const n=gt(e,Ye.Run);t.forEach(t=>{ne(t,t=>ft(e,"run",t))(void 0,n)})}(e,n);break;case Ye.Session:!function(e,t){if(!e.session)return;const n=gt(e,Ye.Session);t.forEach(t=>{ne(t,t=>ft(e,"session",t))(e.session,n)})}(e,n);break;default:{const o=gt(e,t);n.forEach(n=>{"function"==typeof n&&ne(n,n=>ft(e,"generic",n,{type:t}))(s,o)});break}}}function yt(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 wt=new WeakMap;function vt(e,t,n,o){wt.get(e)||(wt.set(e,!0),t.warn(n,o))}function bt(e){wt.delete(e)}var kt=Object.freeze({batched:!0});function St(e){return e===kt}function It(e){return void 0===e?{}:"number"==typeof e?{wait:e}:{wait:e.wait,size:e.size,age:e.age}}function qt(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 Ot(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 xt(e,t,n){if(!e)return[];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return ot(e,t);if("string"==typeof e)return ot(e,t);const o=F(e,M(n));return 0===o.length?[]:1===o.length?ot(o[0],t):ot(o,t)}async function At(e,t,n={},o){const{allowed:s,consent:r,globals:a,user:i}=e;if(!s)return Tt({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=yt(e.queue,t,{max:n});if(o.dropped>0){const t=Ot(e.status,U("collector"),"queue",o.dropped);vt(e.queue,e.logger,"collector.queue overflow; oldest events dropped",{buffer:"queue",cap:n,droppedCount:t})}else e.queue.length<n&&bt(e.queue);e.status.in++}o||(o=e.destinations);const c=e.transformers?tt(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 d=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 Ct(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 l=[],p=u.filter(t=>{const n=G(s.config.consent,r,t.consent);if(n)return t.consent=n,l.push(t),!1;const a=Xe(e,{stepId:U("destination",o),stepType:"destination",phase:"skip",eventId:"string"==typeof t.id?t.id:"",now:Date.now()});return a.skipReason="consent",r&&(a.consent={...r}),s.config.consent&&(a.meta={required:{...s.config.consent}}),B(e,a),!0});if(p.length>0){const t=s.queuePush,n=s.config.id||o,r={max:s.config.queueMax??1e3};let a=0;for(const e of p)a+=yt(t,e,r).dropped;if(a>0){qt(e,n);const o=Ot(e.status,U("destination",n),"queue",a);vt(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&&bt(t)}if(!l.length)return{id:o,destination:s,queue:u};let f,g,h=!1;try{h=await Ct(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=xt(s.config.before,c,d),y=s.config.next,w=s.config?.cache,v=w?$(w):void 0,b=v?Ze(v,e):void 0,k=s.config?.state?Y(s.config.state):void 0,S=k?.filter(e=>"get"===e.mode),I=k?.filter(e=>"set"===e.mode);let q=0,O=0;return await Promise.all(l.map(async t=>{let r;if(t.globals=E(a,t.globals),t.user=E(i,t.user),v?.stop&&b){const e=M(d,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,l=n.respond;if(m.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const s=await it(e,e.transformers,m,t,d,n.respond,`destination.${o}.before`);if(null===s.event)return t;s.respond&&(l=s.respond),u=Array.isArray(s.event)?s.event[0]:s.event}if(v&&!v.stop&&b){const e=M(d,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=>et(t,e),u,e));const p=Date.now();let h=!1;const w=await W(Dt,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,a=s.config.id||o,i={max:s.config.dlqMax??100},c=yt(r,[u,t],i);if(c.dropped>0){qt(e,a);const t=Ot(e.status,U("destination",a),"dlq",c.dropped);vt(r,e.logger.scope(s.type||"unknown"),"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:a,cap:i.max,droppedCount:t})}else r.length<i.max&&bt(r)})(e,s,o,u,d,l);if(q+=Date.now()-p,r&&b&&void 0===s.config.mock&&R(b,r.key,w??!0,r.ttl),!h&&I&&I.length>0&&u&&(u=await X(I,t=>et(t,e),u,e)),void 0===w||St(w)||(g=w),St(w)&&O++,!h&&y){void 0!==w&&(d._response=w);const t=xt(y,c,d);if(t.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const n=await it(e,e.transformers,t,u,d,l,`destination.${o}.next`);n.respond&&(l=n.respond)}}return t})),{id:o,destination:s,error:f,response:g,totalDuration:q,batchedCount:O,allowedCount:l.length}})),d={},l={},p={};for(const t of u){if(t.skipped)continue;const n=t.destination,o={type:n.type||"unknown",data:t.response};qt(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)l[t.id]=o;else{const n=t.batchedCount??0,a=t.allowedCount??0;(Math.max(0,a-n)>0||0===a)&&(d[t.id]=o,s.count++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.out++)}}return Tt({event:t,...Object.keys(d).length&&{done:d},...Object.keys(l).length&&{queued:l},...Object.keys(p).length&&{failed:p}})}async function Ct(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:Et(t.env,t.config.env)};s.debug("init");const a=Date.now();let i;B(e,Xe(e,{stepId:U("destination",n),stepType:"destination",phase:"init",eventId:"",now:a}));try{i=await V(t.init,"DestinationInit",e.hooks,e.logger)(r)}catch(t){const o=Date.now(),s=Xe(e,{stepId:U("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)},B(e,s),t}if(!1===i)return i;if(t.config={...i||t.config,init:!0},t.queueOn?.length){const o=t.queueOn;t.queueOn=[];for(const{type:s,data:r}of o)ht(e,t,n,s,r)}s.debug("init done")}return!0}async function Dt(e,t,n,o,s,r){const{config:a}=t,i=await J(o,a,e);if(i.ignore)return!1;const c=t.type||"unknown",u=e.logger.scope(c),d={collector:e,logger:u,id:n,config:a,data:i.data,rule:i.mapping,ingest:s,env:{...Et(t.env,a.env),...r?{respond:r}:{}}};if(void 0!==a.mock)return u.debug("mock",{event:i.event.name}),a.mock;const l=i.mapping,p=i.mappingKey||"* *";if(l?.batch&&t.pushBatch&&void 0===a.mock){if(t.batches=t.batches||{},!t.batches[p]){const o={key:p,entries:[],events:[],data:[]},s=It(l.batch),r=It(a.batch),i=s.wait??r.wait??3e4,c=s.size??r.size??1e3,d=s.age??r.age??3e4,f=Et(t.env,a.env),g=N(async()=>{const o=t.batches[p].batched;if(0===o.entries.length)return;const s={key:o.key,entries:o.entries,events:o.events,data:o.data};o.entries=[],o.events=[],o.data=[];const r=s.entries[0],i={collector:e,logger:u,id:n,config:a,data:void 0,rule:r.rule,ingest:r.ingest,env:{...f,...r.respond?{respond:r.respond}:{}}};u.debug("push batch",{events:s.entries.length});const c=t.config.id||n,d=qt(e,c),l=Date.now(),g=Xe(e,{stepId:U("destination",n),stepType:"destination",phase:"flush",eventId:"",now:l});g.batch={size:s.entries.length,index:0},B(e,g);let h=!0;await W(V(t.pushBatch,"DestinationPushBatch",e.hooks,e.logger),o=>{h=!1;const r=Date.now(),a=Xe(e,{stepId:U("destination",n),stepType:"destination",phase:"error",eventId:"",now:r});a.durationMs=r-l,a.error=o instanceof Error?{name:o.name,message:o.message}:{message:String(o)},a.batch={size:s.entries.length,index:0},B(e,a);const i=t.dlq=t.dlq||[],p={max:t.config.dlqMax??100};let f=0;for(const e of s.entries)f+=yt(i,[e.event,o],p).dropped;if(f>0){const t=Ot(e.status,U("destination",c),"dlq",f);vt(i,u,"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:c,cap:p.max,droppedCount:t})}else i.length<p.max&&bt(i);d.failed+=s.entries.length,d.dlqSize=i.length,e.status.failed+=s.entries.length,u.error("Push batch failed",{error:o instanceof Error?o.message:String(o),entries:s.entries.length})})(s,i),u.debug("push batch done"),d.inFlightBatch=Math.max(0,(d.inFlightBatch??0)-s.entries.length),h&&(d.count+=s.entries.length,d.lastAt=Date.now(),e.status.out+=s.entries.length)},{wait:i,size:c,age:d});t.batches[p]={batched:o,batchFn:()=>{g()},flush:async()=>{await g.flush()}}}const o=t.batches[p];o.batched.entries.push({event:i.event,ingest:s,respond:r,rule:l,data:i.data}),o.batched.events.push(i.event),L(i.data)&&o.batched.data.push(i.data);const c=t.config.id||n,d=qt(e,c);return d.inFlightBatch=(d.inFlightBatch??0)+1,o.batchFn(),kt}{u.debug("push",{event:i.event.name});const o="string"==typeof i.event.id?i.event.id:"",s=Date.now(),r=Xe(e,{stepId:U("destination",n),stepType:"destination",phase:"in",eventId:o,now:s});i.mappingKey&&(r.mappingKey=i.mappingKey),i.event.consent&&(r.consent={...i.event.consent}),B(e,r);try{const r=await V(t.push,"DestinationPush",e.hooks,e.logger)(i.event,d),a=Date.now(),c=Xe(e,{stepId:U("destination",n),stepType:"destination",phase:"out",eventId:o,now:a});return c.durationMs=a-s,c.outEvent=r,i.mappingKey&&(c.mappingKey=i.mappingKey),B(e,c),u.debug("push done"),r}catch(t){const r=Date.now(),a=Xe(e,{stepId:U("destination",n),stepType:"destination",phase:"error",eventId:o,now:r});throw a.durationMs=r-s,a.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},i.mappingKey&&(a.mappingKey=i.mappingKey),B(e,a),t}}}function Tt(e){return{ok:!e?.failed,...e}}function jt(e){const{code:t,config:n={},env:o={},cache:s,state:r}=e,{config:a}=nt(e,"before"),{config:i}=nt({...e,config:a},"next"),c={...t.config,...n,...i};s&&(c.cache=s),void 0!==r&&void 0===c.state&&(c.state=r);const u=Et(t.env,o);return{...t,config:c,env:u}}function Et(e,t){return e||t?t?e&&Q(e)&&Q(t)?{...e,...t}:t:e:{}}async function Mt(e,t,n){const o=Object.entries(e).map(async([e,o])=>{const s=o.destroy;if(!s)return;const r=o.type||"unknown",a=n.scope(r),i={id:e,config:o.config,env:o.env??{},logger:a};try{await Promise.race([s(i),new Promise((n,o)=>setTimeout(()=>o(new Error(`${t} '${e}' destroy timed out`)),5e3))])}catch(n){a.error(`${t} '${e}' destroy failed: ${n}`)}});await Promise.allSettled(o)}async function Pt(e,t,n){let o,s,r=!1;switch(t){case Ye.Config:_e(n)&&(Ee(e.config,n,{shallow:!1}),s=n,r=!0);break;case Ye.Consent:if(_e(n)){const{update:t}=function(e,t){const n={};return Object.entries(t).forEach(([e,t])=>{n[e]=!!t}),e.consent=D(e.consent,n),{update:n}}(e,n);s=t,r=!0}break;case Ye.Custom:_e(n)&&(e.custom=Ee(e.custom,n),s=n,r=!0);break;case Ye.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:a,cache:i,state:c}=t;if(!K(n.push))return Tt({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const u=o||{init:!1};let d=r?{...u,before:r}:{...u};a&&(d={...d,next:a}),i&&(d={...d,cache:i}),void 0!==c&&void 0===d.state&&(d={...d,state:c});const l={...n,config:d,env:Et(n.env,s)};let p=l.config.id;if(!p)do{p=z(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[p]);return e.destinations[p]=l,!1!==l.config.queue&&(l.queuePush=[...e.queue]),At(e,void 0,{},{[p]:l})}(e,n));break;case Ye.Globals:_e(n)&&(e.globals=Ee(e.globals,n),s=n,r=!0);break;case Ye.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 Ye.On:if(_e(n)&&$e(n.type)){const{type:t,rules:o}=n;await async function(e,t,n){const o=e.on,s=o[t]||[],r=ee(n)?n:[n];r.forEach(e=>{s.push(e)}),o[t]=s,mt(e,t,r)}(e,t,o)}break;case Ye.Ready:r=!0;break;case Ye.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)),t.user&&(e.user=Ee(e.user,t.user)),t.globals&&(e.globals=Ee(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=Ee(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await At(e)}(e,n),r=!0;break;case Ye.Session:r=!0;break;case Ye.Shutdown:await async function(e){const t=e.logger;await Mt(e.sources,"source",t),await Mt(e.destinations,"destination",t),await Mt(e.transformers,"transformer",t),await Mt(e.stores,"store",t)}(e);break;case Ye.User:_e(n)&&(Ee(e.user,n,{shallow:!1}),s=n,r=!0)}return r&&(await async function(e,t,n,o){let s,r=n||[];switch(n||(r=e.on[t]||[]),t){case Ye.Consent:s=o||e.consent;break;case Ye.Session:s=e.session;break;case Ye.User:s=o||e.user;break;case Ye.Custom:s=o||e.custom;break;case Ye.Globals:s=o||e.globals;break;case Ye.Config:s=o||e.config;break;case Ye.Ready:case Ye.Run:default:s=void 0}let a=!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&&(lt(o)?!1===await oe(o.on,o=>ft(e,"source",o,{sourceId:n,type:t}))(t,s)&&(a=!0):(o.queueOn=o.queueOn||[],o.queueOn.push({type:t,data:s})))}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:s});ht(e,o,n,t,s)}});for(const[t,n]of Object.entries(e.sources))lt(n)&&n.queueOn?.length&&await dt(e,n,t);return Object.keys(e.pending.destinations).length>0&&await async function(e,t){for(const[n,o]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[n]||e.destinations[n])continue;const s=o.config?.require;if(!s)continue;const r=s.indexOf(t);if(-1===r)continue;if(s.splice(r,1),s.length>0)continue;delete e.pending.destinations[n];const a=jt(o);!1!==a.config.queue&&(a.queuePush=[...e.queue]),e.destinations[n]=a}}(e,t),mt(e,t,r,o),!a}(e,t,void 0,s),o=await At(e)),o||Tt({ok:!0})}function $t(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:a={},context:i={},globals:c=e.globals,custom:u={},user:d=e.user,nested:l=[],consent:p=e.consent,id:f=Me(),trigger:g="",entity:h=n,action:m=o,timing:y=0,source:w={type:"collector",schema:"4"}}=t;return{name:r,data:a,context:i,globals:c,custom:u,user:d,nested:l,consent:p,id:f,trigger:g,entity:h,action:m,timestamp:s,timing:y,source:w}}function _t(e={}){const t=e.maxEntries??1e4,n=e.lowWaterMark??.8,o=e.sweepIntervalMs??6e4,s=Math.floor(t*n),r=new Map,a={hits:0,misses:0,populates:0,writes:0,deletes:0,evictions_entries:0,evictions_ttl:0};let i;return o>0&&(i=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++);a.evictions_ttl+=t},o),i&&"function"==typeof i.unref&&i.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),a.evictions_ttl++,void a.misses++):(r.delete(e),r.set(e,t),a.hits++,t.value);a.misses++},set(e,n,o){const i=!r.has(e);i||r.delete(e),r.set(e,{value:n,expires:void 0!==o?Date.now()+o:void 0}),a.writes++,i&&a.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++}a.evictions_entries+=n}()},delete(e){r.delete(e)&&a.deletes++},get counters(){return{...a}},destroy(){void 0!==i&&(clearInterval(i),i=void 0),r.clear()}}}function Rt(e,t){const{cacheConfig:n,cacheStore:o,namespace:s,logger:r,storeId:a,collector:i}=t,c=(e,t)=>{if(!i)return;const n=Xe(i,{stepId:`store.${a}`,stepType:"store",phase:"in",eventId:"",now:Date.now()});n.meta={op:"cache",cached:"hit"===t,status:t,key:e},Ve(i,n)},u={hits:0,misses:0,populates:0,writes:0,deletes:0,inflight_dedups:0},d=n.rules.map(e=>({match:e.match?We(e.match):()=>!0,ttl:e.ttl})),l=e=>`${s}:${e}`;function p(e,t){const n=void 0===t?{key:e}:{key:e,value:t};return d.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=l(t),s=await o.get(n);if(void 0!==s)return u.hits++,c(t,"hit"),s;const r=f.get(n);if(r)return u.inflight_dedups++,c(t,"hit"),r;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{await o.set(n,s,1e3*r.ttl),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{await o.set(l(t),n,1e3*r.ttl)}catch(e){g("set",t,e)}},async delete(t){u.deletes++,await e.delete(t);try{await o.delete(l(t))}catch(e){g("delete",t,e)}}};function g(e,t,n){const o=`store-cache(${a}): cache ${e} failed for "${t}"; backing succeeded, continuing`;r?r.warn(o,{error:n}):console.warn(o,n)}}function Ht(e,t,n){const o=`store.${n}`,s=Ue(t.get,"StoreGet",e.hooks,e.logger),r=Ue(t.set,"StoreSet",e.hooks,e.logger),a=Ue(t.delete,"StoreDelete",e.hooks,e.logger);t.get=async t=>{const n=Date.now(),r=Xe(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});r.meta={op:"get",key:t},Je(e,r);try{const r=await s(t),a=Date.now(),i=Xe(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:a});return i.durationMs=a-n,i.meta={op:"get",key:t},Je(e,i),r}catch(s){const r=Date.now(),a=Xe(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw a.durationMs=r-n,a.meta={op:"get",key:t},a.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},Je(e,a),s}},t.set=async(t,n,s)=>{const a=Date.now(),i=Xe(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:a});i.meta={op:"set",key:t},Je(e,i);try{await r(t,n,s);const i=Date.now(),c=Xe(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:i});c.durationMs=i-a,c.meta={op:"set",key:t},Je(e,c)}catch(n){const s=Date.now(),r=Xe(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:s});throw r.durationMs=s-a,r.meta={op:"set",key:t},r.error=n instanceof Error?{name:n.name,message:n.message}:{message:String(n)},Je(e,r),n}},t.delete=async t=>{const n=Date.now(),s=Xe(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});s.meta={op:"delete",key:t},Je(e,s);try{await a(t);const s=Date.now(),r=Xe(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:s});r.durationMs=s-n,r.meta={op:"delete",key:t},Je(e,r)}catch(s){const r=Date.now(),a=Xe(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw a.durationMs=r-n,a.meta={op:"delete",key:t},a.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},Je(e,a),s}}}async function Nt(e){const t=T({globalsStatic:{},sessionStatic:{},run:!0,queueMax:1e3},e,{merge:!1,extend:!1}),n={level:e.logger?.level,handler:e.logger?.handler},o=j(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,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:{}},push:void 0,command:void 0};var a,i;r.push=function(e,t){const n=Fe(async(n,o={})=>await Ge(async()=>{const s=Date.now(),{id:r,ingest:a,respond:i,mapping:c,preChain:u,include:d,exclude:l}=o;let p=i,f=n;const g=d||l?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,d,l):void 0,h=a??Re(r||"unknown");if(c){const t=await ze(f,c,e);if(t.ignore)return Tt({ok:!0});if(c.consent&&!Be(c.consent,e.consent,t.event.consent))return Tt({ok:!0});f=t.event}if(u?.length&&e.transformers&&Object.keys(e.transformers).length>0){const n=await it(e,e.transformers,u,f,h,p,r?`source.${r}.next`:void 0);if(null===n.event)return Tt({ok:!0});if(n.stopped)return n.respond&&(p=n.respond),Tt({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=$t(e,o);return At(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]??Tt({ok:!0})}f=n.event}const m=t(f),y=$t(e,m),w=await At(e,y,{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 w},t=>{if(t instanceof Ne)throw t;return e.status.failed++,e.logger.error("push failed",{event:n,ingest:o.ingest,error:t}),Tt({ok:!1})})(),"Push",e.hooks,e.logger);return async(t,o)=>{const s="string"==typeof t.id?t.id:"",r=Date.now();He(e,Xe(e,{stepId:"collector.push",stepType:"collector",phase:"in",eventId:s,now:r}));try{const a=await n(t,o),i=Date.now(),c=Xe(e,{stepId:"collector.push",stepType:"collector",phase:"out",eventId:s,now:i});return c.durationMs=i-r,c.outEvent=a,He(e,c),a}catch(t){const n=Date.now(),o=Xe(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}}}(r,e=>({timing:Math.round((Date.now()-r.timing)/10)/100,source:{type:"collector",schema:"4",version:"4.1.3-next-1780071196115"},...e})),r.command=(i=Pt,Ke(async(e,t,n)=>await Qe(async()=>await i(a,e,t,n),n=>{if(n instanceof Le)throw n;return a.status.failed++,a.logger.error("command failed",{command:e,data:t,error:n}),Tt({ok:!1})})(),"Command",(a=r).hooks,a.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:a={}}=s,i=e.logger.scope("store").scope(o),c={collector:e,logger:i,id:o,config:r,env:a},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 a=t[r];if("BLACK"===a)return;if("GRAY"===a){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 i=e[r].cache?.store;if(void 0!==i){if(!(i in e))throw new Error(`Store "${r}" cache.store references "${i}", which is not declared in flow.stores`);s(i)}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,a;void 0!==s.store?(r=n[s.store],a=s.store):(n.__cache||(n.__cache=_t()),r=n.__cache,a="__cache");const i=s.namespace??t;e.logger.scope("store-cache").scope(t).info(`store "${t}" caches with namespace "${i}:" via ${a}`),n[t]=Rt(n[t],{storeId:t,cacheConfig:s,cacheStore:r,namespace:i,logger:e.logger.scope("store-cache").scope(t),collector:e})}for(const[t,o]of Object.entries(n))"__cache"!==t&&Ht(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=_t()),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]=jt(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,a=Ce(s,"Transformer");if(!a.ok){e.logger.warn(`Transformer ${o} invalid (${a.code}): ${a.reason}. Skipping.`);continue}const{config:i}=nt(s,"before"),{config:c}=nt({...s,config:i},"next"),u=Object.keys(r).length>0?{...c,env:r}:c,{cache:d}=s,l=d?{...u,cache:d}:u,{state:p}=s,f=void 0!==p&&void 0===l.state?{...l,state:p}:l,g=e.logger.scope("transformer").scope(o),h={collector:e,logger:g,id:o,ingest:me(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 De(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}),n[o]=y}return n}(r,e.transformers||{}),r}async function Bt(e){e=e||{};const t=await Nt(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 a;if("string"==typeof e)a={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(a.data=t);else{if(!e||"object"!=typeof e)return Tt({ok:!1});a=e,t&&"object"==typeof t&&!Array.isArray(t)&&(a.data={...a.data||{},...t})}return n&&"object"==typeof n&&(a.context=n),s&&Array.isArray(s)&&(a.nested=s),r&&"object"==typeof r&&(a.custom=r),o.push(a)}});var o;t.sources.elb=n,await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const t=await pt(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 ie(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,lt(n)&&await dt(e,n,t))}return n}(t,e.sources||{});const{consent:s,user:r,globals:a,custom:i}=e;s&&await t.command("consent",s),r&&await t.command("user",r),a&&Object.assign(t.globals,a),i&&Object.assign(t.custom,i),t.config.run&&await t.command("run");let c=n.push;const u=Object.values(t.sources).filter(e=>"elb"!==e.type),d=u.find(e=>e.config.primary);return d?c=d.push:u.length>0&&(c=u[0].push),{collector:t,elb:c}}var zt=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Bt(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,a=await r(n,s);let i;try{i=JSON.parse(a.body||"{}")}catch{i=a.body}const c={};if(a.headers)for(const[e,t]of Object.entries(a.headers))void 0!==t&&(c[e]=String(t));return{statusCode:a.statusCode,body:i,headers:c}}}};function Gt(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 Ft={};t(Ft,{createTrigger:()=>nn,env:()=>Lt,step:()=>Vt});var Lt={};t(Lt,{push:()=>Ut,simulation:()=>Wt});var Kt=()=>{},Qt={error:Kt,warn:Kt,info:Kt,debug:Kt,throw:e=>{throw"string"==typeof e?new Error(e):e},json:Kt,scope:()=>Qt},Jt=()=>()=>Promise.resolve({ok:!0}),Ut={get push(){return Jt()},get command(){return Jt()},get elb(){return Jt()},logger:Qt},Wt=["AWS.SQSClient"],Vt={};t(Vt,{decoderText:()=>Zt,malformedJson:()=>en,orderComplete:()=>Xt,pageView:()=>Yt});var Yt={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"]]},Xt={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"]]},Zt={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"]]},en={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 tn(e){if("object"!=typeof e||null===e)return!1;const t=e;return"sqs"===t.type&&"function"==typeof t.push}var nn=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Bt(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources??{}))if(tn(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),a=[];return r&&"object"==typeof r&&(r.acked&&a.push(["message.ack",n.MessageId]),r.nacked&&a.push(["message.nack",n.MessageId])),a}}};export{v as examples,n as schemas,Ft 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,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,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACrC,MAAMA,GACH,MAAM,CAACA,GAAE,QAAQ,GAAG,iBAAiB,CAAC,EACtC;AAAA,IACC;AAAA,EACF,EACC,QAAQ,IAAI;AAAA,E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AAI,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
|
+
{"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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M,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"]}
|