@walkeros/server-source-gcp 4.8.1 → 4.8.3-next-1793115089237

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # @walkeros/server-source-gcp
2
2
 
3
+ ## 4.8.3-next-1793115089237
4
+
5
+ ### Patch Changes
6
+
7
+ - 5313635: The Pub/Sub `decoder` descriptions say what `text` and `raw` forward
8
+ and that those events need a before transformer that sets the event name,
9
+ otherwise the collector rejects them. The setup `ackDeadlineSeconds`
10
+ description states that an unset value leaves Pub/Sub's own default of 10
11
+ seconds. The push `projectId` description no longer claims the value appears
12
+ in error messages.
13
+ - Updated dependencies [5313635]
14
+ - Updated dependencies [5313635]
15
+ - Updated dependencies [34fd225]
16
+ - Updated dependencies [34fd225]
17
+ - Updated dependencies [5313635]
18
+ - Updated dependencies [5313635]
19
+ - Updated dependencies [5313635]
20
+ - Updated dependencies [5313635]
21
+ - Updated dependencies [5313635]
22
+ - Updated dependencies [34fd225]
23
+ - Updated dependencies [5313635]
24
+ - @walkeros/collector@4.8.3-next-1793115089237
25
+ - @walkeros/core@4.8.3-next-1793115089237
26
+
27
+ ## 4.8.2
28
+
29
+ ### Patch Changes
30
+
31
+ - 2374f54: A push that failed for a reason a resend cannot fix (a missing
32
+ setting, a 4xx, a destination that is not ready) is acknowledged: SQS deletes
33
+ the message, Pub/Sub acks it, HTTP sources answer 200. Only retryable failures
34
+ nack or answer 500, or 207 for a batch, with the fixed text
35
+ `Event was not processed`.
36
+ - 2374f54: A nack for a retryable failure logs at DEBUG, because the collector's
37
+ ERROR line reports the cause once per minute instead of one line per message.
38
+ Transient Pub/Sub stream errors and SQS receive errors that the SDK or loop
39
+ retries log at WARN instead of ERROR.
40
+ - Updated dependencies [2374f54]
41
+ - Updated dependencies [2374f54]
42
+ - Updated dependencies [7e5fc27]
43
+ - Updated dependencies [2374f54]
44
+ - Updated dependencies [2374f54]
45
+ - Updated dependencies [2374f54]
46
+ - Updated dependencies [2374f54]
47
+ - Updated dependencies [7e5fc27]
48
+ - Updated dependencies [2374f54]
49
+ - Updated dependencies [964590a]
50
+ - Updated dependencies [2374f54]
51
+ - Updated dependencies [7e5fc27]
52
+ - Updated dependencies [2374f54]
53
+ - Updated dependencies [964590a]
54
+ - Updated dependencies [4100ede]
55
+ - Updated dependencies [2374f54]
56
+ - Updated dependencies [2374f54]
57
+ - Updated dependencies [15eb7b2]
58
+ - Updated dependencies [33a2779]
59
+ - Updated dependencies [33a2779]
60
+ - @walkeros/collector@4.8.2
61
+ - @walkeros/core@4.8.2
62
+
3
63
  ## 4.8.1
4
64
 
5
65
  ### Patch Changes
@@ -343,9 +403,6 @@
343
403
  and `event.context` remain required.
344
404
  - Each source self-registers via TypeScript module augmentation of `SourceMap`
345
405
  in `@walkeros/core`.
346
- - App-side coordination (`/workspaces/developer/app`) is a follow-up plan, not
347
- part of this release. Telemetry from v4 CLI/MCP will not validate against
348
- the existing app schema until that follow-up ships.
349
406
  - `Mapping.Rule.skip` is renamed to `Mapping.Rule.silent`. Customer flow.json
350
407
  configs using `skip: true` in mapping rules must rename to `silent: true`.
351
408
  Hard cut: no legacy alias, the field is gone.
package/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  # @walkeros/server-source-gcp
8
8
 
9
- Google Cloud Functions source for walkerOS. A lightweight runtime adapter with
10
- plug-and-play assignment to a Cloud Functions handler, batch processing, and
9
+ Google Cloud Functions source for walkerOS: a runtime adapter whose `push` you
10
+ assign directly as a Cloud Functions handler, with batch processing and
11
11
  configurable CORS. The package also ships Pub/Sub sources for ingesting from
12
12
  Pub/Sub topics.
13
13
 
@@ -30,13 +30,22 @@ npm install @walkeros/server-source-gcp @google-cloud/functions-framework
30
30
  "default": {
31
31
  "config": { "platform": "server" },
32
32
  "sources": {
33
- "gcp": { "package": "@walkeros/server-source-gcp", "config": {} }
33
+ "gcp": {
34
+ "package": "@walkeros/server-source-gcp",
35
+ "import": "sourceCloudFunction",
36
+ "config": {}
37
+ }
34
38
  }
35
39
  }
36
40
  }
37
41
  }
38
42
  ```
39
43
 
44
+ The package has no default export, so a step names the source with `"import"`
45
+ (`sourceCloudFunction`, `sourcePubSubPull` or `sourcePubSubPush`). This
46
+ quick-start bundle is for deploying to Cloud Functions: the walkerOS runtime
47
+ serves only sources with an HTTP handler, such as the Express source.
48
+
40
49
  ## Documentation
41
50
 
42
51
  Full configuration, mapping, and examples live in the docs:
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,i=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},n={};i(n,{examples:()=>a,exportExamples:()=>Se,exportSchemas:()=>ze,pubsubPullExamples:()=>y,pubsubPullSchemas:()=>ce,pubsubPushExamples:()=>I,pubsubPushSchemas:()=>fe,schemas:()=>$}),module.exports=(e=n,((e,i,n,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of r(i))s.call(e,c)||c===n||t(e,c,{get:()=>i[c],enumerable:!(a=o(i,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};i(a,{createTrigger:()=>w,env:()=>c,step:()=>b});var c={};i(c,{push:()=>p});var l=()=>()=>Promise.resolve({ok:!0}),u=()=>{},d={error:u,warn:u,info:u,debug:u,throw:e=>{throw"string"==typeof e?new Error(e):e},json:u,scope:()=>d},p={get push(){return l()},get command(){return l()},get elb(){return l()},logger:d},b={};i(b,{cloudFunctionPostForwardsSource:()=>f,orderEvent:()=>g,postEvent:()=>m});var m={title:"POST event",description:"A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},g={title:"Order POST",description:"A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"order complete",data:{id:"ORD-700",total:99.99,currency:"EUR"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"order complete",data:{id:"ORD-700",total:99.99,currency:"EUR"}}]]},f={title:"POST with provenance",description:"A POST body carrying a source map is forwarded in full, so release and trace provenance survive the crossing.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}}]]},h=require("@walkeros/collector");var w=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await(0,h.startFlow)(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources||{}))if("cloudfunction"===t.type)return t}(t.collector);if(!r)throw new Error("CloudFunction source not found in collector — ensure it is configured in sources");const s={...o.body};s.name&&!s.event&&(s.event=s.name,delete s.name);const i=o.headers||{"content-type":"application/json"},n={method:o.method,body:s,headers:i,get:e=>i[e.toLowerCase()]};let a,c=200;const l={status:e=>(c=e,l),json:e=>(a=e,l),send:e=>(a=e,l),set:()=>l};return await r.push(n,l),{status:c,body:a}}}},y={};i(y,{createTrigger:()=>N,env:()=>v,step:()=>D});var v={};i(v,{moduleMockEnv:()=>T,push:()=>j,simulation:()=>x});var S=()=>{},z={error:S,warn:S,info:S,debug:S,throw:e=>{throw"string"==typeof e?new Error(e):e},json:S,scope:()=>z},P=()=>()=>Promise.resolve({ok:!0}),O=class{constructor(e,t){this.name=e,this.options=t}name;options;on(e,t){return this}async close(){}};function k(){return{get push(){return P()},get command(){return P()},get elb(){return P()},logger:z}}var j=Object.assign(k(),{PubSub:class{constructor(e){this.options=e}options;subscription(e,t){return new O(e,t)}async close(){}}}),T=k(),x=["call:PubSub.subscription"],D={};i(D,{decoderText:()=>A,malformedJson:()=>q,malformedJsonAck:()=>R,orderComplete:()=>C,pageView:()=>E});var E={title:"Page view",description:"A JSON-encoded page view event arrives on the subscription, decodes successfully, and is acked.",in:{id:"msg-1",dataString:JSON.stringify({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{}},out:[["message.ack","msg-1"]]},C={title:"Order complete",description:"A JSON-encoded order event arrives and is acked after successful collector forwarding.",in:{id:"msg-2",dataString:JSON.stringify({name:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}}),attributes:{entity:"order",action:"complete"}},out:[["message.ack","msg-2"]]},A={title:"Text decoder",description:"With decoder=text on the source settings, the message data is forwarded to the collector as a UTF-8 string and acked.",in:{id:"msg-3",dataString:"plain text payload",attributes:{}},out:[["message.ack","msg-3"]]},q={title:"Malformed JSON nack",description:"A non-JSON body with the default json decoder fails to decode; the message is nacked for redelivery.",in:{id:"msg-4",dataString:"not-json{",attributes:{}},out:[["message.nack","msg-4"]]},R={title:"Malformed JSON ack-and-drop",description:"With onPushError=ack on the source settings, a malformed JSON message is acked-and-dropped instead of redelivered.",in:{id:"msg-5",dataString:"not-json{",attributes:{}},out:[["message.ack","msg-5"]]},M=require("@walkeros/collector");function J(e){if("object"!=typeof e||null===e)return!1;const t=e;return"pubsub-pull"===t.type&&"function"==typeof t.push}var N=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await(0,M.startFlow)(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources??{}))if(J(t))return t}(t.collector);if(!r)throw new Error("pubsub-pull source not registered in collector — ensure it is configured in sources");const s={id:o.id,data:Buffer.from(o.dataString,"utf8"),attributes:o.attributes,orderingKey:o.orderingKey},i=await r.push(s),n=[];return i&&"object"==typeof i&&(i.acked&&n.push(["message.ack",o.id]),i.nacked&&n.push(["message.nack",o.id])),n}}},I={};i(I,{createTrigger:()=>Z,env:()=>F,step:()=>_});var F={};i(F,{push:()=>L,simulation:()=>G});var B=()=>{},U={error:B,warn:B,info:B,debug:B,throw:e=>{throw"string"==typeof e?new Error(e):e},json:B,scope:()=>U},H=()=>()=>Promise.resolve({ok:!0}),L={get push(){return H()},get command(){return H()},get elb(){return H()},logger:U},G=[],_={};i(_,{malformedEnvelope:()=>Q,orderEnvelope:()=>W,validEnvelope:()=>V});function K(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64")}var V={title:"Valid push envelope",description:"A well-formed Pub/Sub push envelope decodes the base64 data, parses JSON, and forwards the event to the collector with a 200 response.",in:{message:{messageId:"push-1",data:K({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{source:"analytics"}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-1"}]]},W={title:"Order envelope",description:"A push envelope carrying an order event is decoded and forwarded to the collector.",in:{message:{messageId:"push-2",data:K({name:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}}),attributes:{}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-2"}]]},Q={title:"Malformed envelope",description:"A POST body lacking message.messageId returns 400 Bad Request without forwarding to the collector.",in:{not_a:"pubsub envelope"},out:[["response",400,{success:!1,error:"Malformed Pub/Sub envelope (missing message.messageId)."}]]},X=require("@walkeros/collector");function Y(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.type&&"pubsub-push"===t.type&&"function"==typeof t.push}var Z=async e=>{let t;return{get flow(){return t},trigger:(o,r)=>async o=>{if(!t){const o=await(0,X.startFlow)(e);t={collector:o.collector,elb:o.elb}}const s=("object"==typeof r&&null!==r?r:{}).headers??{},i=function(e){for(const t of Object.values(e.sources??{}))if(Y(t))return t}(t.collector);if(!i)throw new Error("pubsub-push source not registered");const n={},a=function(e,t){return{method:"POST",body:e,headers:t,get:e=>t[e.toLowerCase()]??t[e]}}(o,s),c=function(e){const t={status:o=>(e.statusCode=o,t),json:o=>(e.body=o,t),send:o=>(e.body=o,t),set:()=>t};return t}(n);await i.push(a,c);return[["response",n.statusCode??0,n.body??null]]}}},$={};i($,{CorsOptionsSchema:()=>ie,CorsOrigin:()=>se,HttpMethod:()=>re,SettingsSchema:()=>ne,settings:()=>ae});var ee=require("@walkeros/core/dev"),te=require("@walkeros/core/dev"),oe=require("@walkeros/core/dev"),re=oe.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),se=oe.z.union([oe.z.string(),oe.z.array(oe.z.string()),oe.z.literal("*")]),ie=oe.z.object({origin:se.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:oe.z.array(re).describe("Allowed HTTP methods").optional(),headers:oe.z.array(oe.z.string()).describe("Allowed request headers").optional(),credentials:oe.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:oe.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),ne=te.z.object({cors:te.z.union([te.z.boolean(),ie]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").optional(),maxBatchSize:te.z.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),enablePixelTracking:te.z.boolean().describe("Serve a tracking pixel for GET requests").default(!0),timeout:te.z.number().int().positive().max(54e4).describe("Request timeout in milliseconds (max: 540000 for GCP)").optional()}),ae=(0,ee.zodToSchema)(ne),ce={};i(ce,{SettingsSchema:()=>de,SetupSchema:()=>be,settings:()=>me,setup:()=>ge});var le=require("@walkeros/core/dev"),ue=require("@walkeros/core/dev"),de=ue.z.object({client:ue.z.any().describe("Pre-configured Google Cloud Pub/Sub client (like new PubSub({ projectId })). Bypasses credentials resolution when supplied.").optional(),projectId:ue.z.string().min(1).describe("Google Cloud Project ID (like my-gcp-project)."),subscription:ue.z.string().min(1).describe("Pub/Sub subscription short name (like events-sub). The full resource name projects/<projectId>/subscriptions/<subscription> is built by the SDK."),topic:ue.z.string().describe("Pub/Sub topic short name. Required when setup.createTopic is true; otherwise informational.").optional(),credentials:ue.z.any().describe("Service account credentials as a JSON string or an object with client_email and private_key. Default: Application Default Credentials (ADC). (deprecated: use config.credentials)").optional(),apiEndpoint:ue.z.string().describe("Override Pub/Sub API endpoint. Useful for the local emulator (like localhost:8085).").optional(),decoder:ue.z.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON, text decodes UTF-8, raw forwards the Buffer.").optional(),flowControl:ue.z.object({maxMessages:ue.z.number().describe("Maximum in-flight messages. Default: 100.").optional(),maxBytes:ue.z.number().describe("Maximum in-flight bytes. Default: 10485760 (10 MB).").optional()}).describe("Subscriber flow control. Tightens the SDK defaults.").optional(),ackDeadline:ue.z.number().describe("Subscriber ack deadline in seconds. Default: 60.").optional(),shutdownTimeoutMs:ue.z.number().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes the subscriber.").optional(),onPushError:ue.z.enum(["nack","ack"]).describe("Behavior when forwarding to the collector throws. nack (default) redelivers the message; ack drops it.").optional()}),pe=require("@walkeros/core/dev"),be=pe.z.object({createTopic:pe.z.boolean().describe("Create the topic if it does not exist. Requires settings.topic. Default: false (require pre-existing topic).").optional(),ackDeadlineSeconds:pe.z.number().describe("Subscription ack deadline in seconds. Default: 60.").optional(),messageRetentionDuration:pe.z.object({seconds:pe.z.number().describe("Retention window in seconds. Default: project default.")}).describe("Subscription-level retention configuration.").optional(),filter:pe.z.string().describe("Subscription filter expression. Only messages matching this filter are delivered.").optional(),deadLetterPolicy:pe.z.object({deadLetterTopic:pe.z.string().describe("Dead-letter topic short name."),maxDeliveryAttempts:pe.z.number().describe("Maximum delivery attempts before forwarding to the dead-letter topic."),createDeadLetterTopic:pe.z.boolean().describe("Auto-create the dead-letter topic if it does not exist. Default: false.").optional()}).describe("Dead-letter policy. Strongly recommended for production.").optional(),retryPolicy:pe.z.object({minimumBackoff:pe.z.object({seconds:pe.z.number().describe("Minimum backoff in seconds.")}),maximumBackoff:pe.z.object({seconds:pe.z.number().describe("Maximum backoff in seconds.")})}).describe("Subscription retry policy.").optional(),enableMessageOrdering:pe.z.boolean().describe("Enable message ordering on the subscription. Default: false.").optional(),labels:pe.z.record(pe.z.string(),pe.z.string()).describe("Subscription labels for organization and billing.").optional(),expirationPolicy:pe.z.object({ttl:pe.z.object({seconds:pe.z.number().describe("TTL in seconds. null means never expire.")}).nullable().optional()}).describe("Subscription expiration policy.").optional()}),me=(0,le.zodToSchema)(de),ge=(0,le.zodToSchema)(be),fe={};i(fe,{SettingsSchema:()=>ye,settings:()=>ve});var he=require("@walkeros/core/dev"),we=require("@walkeros/core/dev"),ye=we.z.object({projectId:we.z.string().describe("Google Cloud Project ID (informational, surfaced in error messages).").optional(),decoder:we.z.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON, text decodes UTF-8, raw forwards the Buffer.").optional(),verifyOidc:we.z.boolean().describe("Verify the OIDC bearer token Pub/Sub attaches to push requests. Default: false.").optional(),audience:we.z.string().describe("OIDC audience (your endpoint URL or a custom audience). Required when verifyOidc is true.").optional()}),ve=(0,he.zodToSchema)(ye),Se={sourceCloudFunction:a,sourcePubSubPull:y,sourcePubSubPush:I},ze={sourceCloudFunction:{settings:ae},sourcePubSubPull:{settings:me,setup:ge},sourcePubSubPush:{settings:ve}};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,n=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},i={};n(i,{examples:()=>a,exportExamples:()=>Se,exportSchemas:()=>ze,pubsubPullExamples:()=>v,pubsubPullSchemas:()=>ce,pubsubPushExamples:()=>I,pubsubPushSchemas:()=>fe,schemas:()=>$}),module.exports=(e=i,((e,n,i,a)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let c of r(n))s.call(e,c)||c===i||t(e,c,{get:()=>n[c],enumerable:!(a=o(n,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};n(a,{createTrigger:()=>w,env:()=>c,step:()=>b});var c={};n(c,{push:()=>p});var l=()=>()=>Promise.resolve({ok:!0}),u=()=>{},d={error:u,warn:u,info:u,debug:u,throw:e=>{throw"string"==typeof e?new Error(e):e},json:u,scope:()=>d},p={get push(){return l()},get command(){return l()},get elb(){return l()},logger:d},b={};n(b,{cloudFunctionPostForwardsSource:()=>f,orderEvent:()=>g,postEvent:()=>m});var m={title:"POST event",description:"A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},g={title:"Order POST",description:"A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"order complete",data:{id:"ORD-700",value:99.99,currency:"EUR"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"order complete",data:{id:"ORD-700",value:99.99,currency:"EUR"}}]]},f={title:"POST with provenance",description:"A POST body carrying a source map is forwarded in full, so release and trace provenance survive the crossing.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}}]]},h=require("@walkeros/collector");var w=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await(0,h.startFlow)(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources||{}))if("cloudfunction"===t.type)return t}(t.collector);if(!r)throw new Error("CloudFunction source not found in collector — ensure it is configured in sources");const s={...o.body};s.name&&!s.event&&(s.event=s.name,delete s.name);const n=o.headers||{"content-type":"application/json"},i={method:o.method,body:s,headers:n,get:e=>n[e.toLowerCase()]};let a,c=200;const l={status:e=>(c=e,l),json:e=>(a=e,l),send:e=>(a=e,l),set:()=>l};return await r.push(i,l),{status:c,body:a}}}},v={};n(v,{createTrigger:()=>N,env:()=>y,step:()=>D});var y={};n(y,{moduleMockEnv:()=>T,push:()=>k,simulation:()=>x});var S=()=>{},z={error:S,warn:S,info:S,debug:S,throw:e=>{throw"string"==typeof e?new Error(e):e},json:S,scope:()=>z},P=()=>()=>Promise.resolve({ok:!0}),O=class{constructor(e,t){this.name=e,this.options=t}name;options;on(e,t){return this}async close(){}};function j(){return{get push(){return P()},get command(){return P()},get elb(){return P()},logger:z}}var k=Object.assign(j(),{PubSub:class{constructor(e){this.options=e}options;subscription(e,t){return new O(e,t)}async close(){}}}),T=j(),x=["call:PubSub.subscription"],D={};n(D,{decoderText:()=>A,malformedJson:()=>q,malformedJsonAck:()=>R,orderComplete:()=>C,pageView:()=>E});var E={title:"Page view",description:"A JSON-encoded page view event arrives on the subscription, decodes successfully, and is acked.",in:{id:"msg-1",dataString:JSON.stringify({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{}},out:[["message.ack","msg-1"]]},C={title:"Order complete",description:"A JSON-encoded order event arrives and is acked after successful collector forwarding.",in:{id:"msg-2",dataString:JSON.stringify({name:"order complete",data:{id:"ORD-500",value:199.99,currency:"EUR"}}),attributes:{entity:"order",action:"complete"}},out:[["message.ack","msg-2"]]},A={title:"Text decoder",description:"With decoder=text on the source settings, the message data is forwarded as data.payload. It has no event name, so without a before transformer that builds the event the collector rejects it and the message is acked.",in:{id:"msg-3",dataString:"plain text payload",attributes:{}},out:[["message.ack","msg-3"]]},q={title:"Malformed JSON nack",description:"A non-JSON body with the default json decoder fails to decode; the message is nacked for redelivery.",in:{id:"msg-4",dataString:"not-json{",attributes:{}},out:[["message.nack","msg-4"]]},R={title:"Malformed JSON ack-and-drop",description:"With onPushError=ack on the source settings, a malformed JSON message is acked-and-dropped instead of redelivered.",in:{id:"msg-5",dataString:"not-json{",attributes:{}},out:[["message.ack","msg-5"]]},M=require("@walkeros/collector");function J(e){if("object"!=typeof e||null===e)return!1;const t=e;return"pubsub-pull"===t.type&&"function"==typeof t.push}var N=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await(0,M.startFlow)(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources??{}))if(J(t))return t}(t.collector);if(!r)throw new Error("pubsub-pull source not registered in collector — ensure it is configured in sources");const s={id:o.id,data:Buffer.from(o.dataString,"utf8"),attributes:o.attributes,orderingKey:o.orderingKey},n=await r.push(s),i=[];return n&&"object"==typeof n&&(n.acked&&i.push(["message.ack",o.id]),n.nacked&&i.push(["message.nack",o.id])),i}}},I={};n(I,{createTrigger:()=>Z,env:()=>F,step:()=>_});var F={};n(F,{push:()=>L,simulation:()=>G});var U=()=>{},B={error:U,warn:U,info:U,debug:U,throw:e=>{throw"string"==typeof e?new Error(e):e},json:U,scope:()=>B},H=()=>()=>Promise.resolve({ok:!0}),L={get push(){return H()},get command(){return H()},get elb(){return H()},logger:B},G=[],_={};n(_,{malformedEnvelope:()=>Q,orderEnvelope:()=>W,validEnvelope:()=>V});function K(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64")}var V={title:"Valid push envelope",description:"A well-formed Pub/Sub push envelope decodes the base64 data, parses JSON, and forwards the event to the collector with a 200 response.",in:{message:{messageId:"push-1",data:K({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{source:"analytics"}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-1"}]]},W={title:"Order envelope",description:"A push envelope carrying an order event is decoded and forwarded to the collector.",in:{message:{messageId:"push-2",data:K({name:"order complete",data:{id:"ORD-500",value:199.99,currency:"EUR"}}),attributes:{}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-2"}]]},Q={title:"Malformed envelope",description:"A POST body lacking message.messageId returns 400 Bad Request without forwarding to the collector.",in:{not_a:"pubsub envelope"},out:[["response",400,{success:!1,error:"Malformed Pub/Sub envelope (missing message.messageId)."}]]},X=require("@walkeros/collector");function Y(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.type&&"pubsub-push"===t.type&&"function"==typeof t.push}var Z=async e=>{let t;return{get flow(){return t},trigger:(o,r)=>async o=>{if(!t){const o=await(0,X.startFlow)(e);t={collector:o.collector,elb:o.elb}}const s=("object"==typeof r&&null!==r?r:{}).headers??{},n=function(e){for(const t of Object.values(e.sources??{}))if(Y(t))return t}(t.collector);if(!n)throw new Error("pubsub-push source not registered");const i={},a=function(e,t){return{method:"POST",body:e,headers:t,get:e=>t[e.toLowerCase()]??t[e]}}(o,s),c=function(e){const t={status:o=>(e.statusCode=o,t),json:o=>(e.body=o,t),send:o=>(e.body=o,t),set:()=>t};return t}(i);await n.push(a,c);return[["response",i.statusCode??0,i.body??null]]}}},$={};n($,{CorsOptionsSchema:()=>ne,CorsOrigin:()=>se,HttpMethod:()=>re,SettingsSchema:()=>ie,settings:()=>ae});var ee=require("@walkeros/core/dev"),te=require("@walkeros/core/dev"),oe=require("@walkeros/core/dev"),re=oe.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),se=oe.z.union([oe.z.string(),oe.z.array(oe.z.string()),oe.z.literal("*")]),ne=oe.z.object({origin:se.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:oe.z.array(re).describe("Allowed HTTP methods").optional(),headers:oe.z.array(oe.z.string()).describe("Allowed request headers").optional(),credentials:oe.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:oe.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),ie=te.z.object({cors:te.z.union([te.z.boolean(),ne]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").optional(),maxBatchSize:te.z.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),enablePixelTracking:te.z.boolean().describe("Serve a tracking pixel for GET requests").default(!0),timeout:te.z.number().int().positive().max(54e4).describe("Request timeout in milliseconds (max: 540000 for GCP)").optional()}),ae=(0,ee.zodToSchema)(ie),ce={};n(ce,{SettingsSchema:()=>de,SetupSchema:()=>be,settings:()=>me,setup:()=>ge});var le=require("@walkeros/core/dev"),ue=require("@walkeros/core/dev"),de=ue.z.object({client:ue.z.any().describe("Pre-configured Google Cloud Pub/Sub client (like new PubSub({ projectId })). Bypasses credentials resolution when supplied.").optional(),projectId:ue.z.string().min(1).describe("Google Cloud Project ID (like my-gcp-project)."),subscription:ue.z.string().min(1).describe("Pub/Sub subscription short name (like events-sub). The full resource name projects/<projectId>/subscriptions/<subscription> is built by the SDK."),topic:ue.z.string().describe("Pub/Sub topic short name. Required when setup.createTopic is true; otherwise informational.").optional(),credentials:ue.z.any().describe("Service account credentials as a JSON string or an object with client_email and private_key. Default: Application Default Credentials (ADC). (deprecated: use config.credentials)").optional(),apiEndpoint:ue.z.string().describe("Override Pub/Sub API endpoint. Useful for the local emulator (like localhost:8085).").optional(),decoder:ue.z.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON; text forwards the UTF-8 string as data.payload; raw forwards the bytes base64 encoded as data.payload. text and raw events need a before transformer that sets the event name.").optional(),flowControl:ue.z.object({maxMessages:ue.z.number().describe("Maximum in-flight messages. Default: 100.").optional(),maxBytes:ue.z.number().describe("Maximum in-flight bytes. Default: 10485760 (10 MB).").optional()}).describe("Subscriber flow control. Tightens the SDK defaults.").optional(),ackDeadline:ue.z.number().describe("Subscriber ack deadline in seconds. Default: 60.").optional(),shutdownTimeoutMs:ue.z.number().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes the subscriber.").optional(),onPushError:ue.z.enum(["nack","ack"]).describe("Behavior when a message is not delivered and a redelivery could still deliver it (a retryable failure), or when decoding or forwarding throws. nack (default) redelivers the message; ack drops it.").optional()}),pe=require("@walkeros/core/dev"),be=pe.z.object({createTopic:pe.z.boolean().describe("Create the topic if it does not exist. Requires settings.topic. Default: false (require pre-existing topic).").optional(),ackDeadlineSeconds:pe.z.number().describe("Subscription ack deadline in seconds. Unset: Pub/Sub's default (10).").optional(),messageRetentionDuration:pe.z.object({seconds:pe.z.number().describe("Retention window in seconds. Default: project default.")}).describe("Subscription-level retention configuration.").optional(),filter:pe.z.string().describe("Subscription filter expression. Only messages matching this filter are delivered.").optional(),deadLetterPolicy:pe.z.object({deadLetterTopic:pe.z.string().describe("Dead-letter topic short name."),maxDeliveryAttempts:pe.z.number().describe("Maximum delivery attempts before forwarding to the dead-letter topic."),createDeadLetterTopic:pe.z.boolean().describe("Auto-create the dead-letter topic if it does not exist. Default: false.").optional()}).describe("Dead-letter policy. Strongly recommended for production.").optional(),retryPolicy:pe.z.object({minimumBackoff:pe.z.object({seconds:pe.z.number().describe("Minimum backoff in seconds.")}),maximumBackoff:pe.z.object({seconds:pe.z.number().describe("Maximum backoff in seconds.")})}).describe("Subscription retry policy.").optional(),enableMessageOrdering:pe.z.boolean().describe("Enable message ordering on the subscription. Default: false.").optional(),labels:pe.z.record(pe.z.string(),pe.z.string()).describe("Subscription labels for organization and billing.").optional(),expirationPolicy:pe.z.object({ttl:pe.z.object({seconds:pe.z.number().describe("TTL in seconds. null means never expire.")}).nullable().optional()}).describe("Subscription expiration policy.").optional()}),me=(0,le.zodToSchema)(de),ge=(0,le.zodToSchema)(be),fe={};n(fe,{SettingsSchema:()=>ve,settings:()=>ye});var he=require("@walkeros/core/dev"),we=require("@walkeros/core/dev"),ve=we.z.object({projectId:we.z.string().describe("Google Cloud Project ID. Optional; the push handler does not read it.").optional(),decoder:we.z.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON, text forwards the UTF-8 string, raw forwards the Buffer. text and raw values carry no event name: without a before transformer that builds the event the collector rejects them and the push answers 400.").optional(),verifyOidc:we.z.boolean().describe("Verify the OIDC bearer token Pub/Sub attaches to push requests. Default: false.").optional(),audience:we.z.string().describe("OIDC audience (your endpoint URL or a custom audience). Required when verifyOidc is true.").optional()}),ye=(0,he.zodToSchema)(ve),Se={sourceCloudFunction:a,sourcePubSubPull:v,sourcePubSubPush:I},ze={sourceCloudFunction:{settings:ae},sourcePubSubPull:{settings:me,setup:ge},sourcePubSubPush:{settings:ye}};//# sourceMappingURL=dev.js.map
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev.ts","../src/cloudfunction/examples/index.ts","../src/cloudfunction/examples/env.ts","../src/cloudfunction/examples/step.ts","../src/cloudfunction/examples/trigger.ts","../src/pubsub/pull/examples/index.ts","../src/pubsub/pull/examples/env.ts","../src/pubsub/pull/examples/step.ts","../src/pubsub/pull/examples/trigger.ts","../src/pubsub/push/examples/index.ts","../src/pubsub/push/examples/env.ts","../src/pubsub/push/examples/step.ts","../src/pubsub/push/examples/trigger.ts","../src/cloudfunction/schemas/index.ts","../src/cloudfunction/schemas/settings.ts","../src/cloudfunction/schemas/primitives.ts","../src/pubsub/pull/schemas/index.ts","../src/pubsub/pull/schemas/settings.ts","../src/pubsub/pull/schemas/setup.ts","../src/pubsub/push/schemas/index.ts","../src/pubsub/push/schemas/settings.ts"],"sourcesContent":["import * as cloudFunctionExamplesNs from './cloudfunction/examples';\nimport * as pubsubPullExamplesNs from './pubsub/pull/examples';\nimport * as pubsubPushExamplesNs from './pubsub/push/examples';\nimport * as cloudFunctionSchemasNs from './cloudfunction/schemas';\nimport * as pubsubPullSchemasNs from './pubsub/pull/schemas';\nimport * as pubsubPushSchemasNs from './pubsub/push/schemas';\n\nexport * as schemas from './cloudfunction/schemas';\nexport * as examples from './cloudfunction/examples';\nexport * as pubsubPullSchemas from './pubsub/pull/schemas';\nexport * as pubsubPullExamples from './pubsub/pull/examples';\nexport * as pubsubPushSchemas from './pubsub/push/schemas';\nexport * as pubsubPushExamples from './pubsub/push/examples';\n\n/** Dev examples per export, keyed by the export names in package.json. */\nexport const exportExamples = {\n sourceCloudFunction: cloudFunctionExamplesNs,\n sourcePubSubPull: pubsubPullExamplesNs,\n sourcePubSubPush: pubsubPushExamplesNs,\n};\n\n/** Schemas per export, keyed by the export names in package.json. */\nexport const exportSchemas = {\n sourceCloudFunction: { settings: cloudFunctionSchemasNs.settings },\n sourcePubSubPull: {\n settings: pubsubPullSchemasNs.settings,\n setup: pubsubPullSchemasNs.setup,\n },\n sourcePubSubPush: { settings: pubsubPushSchemasNs.settings },\n};\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for GCP Cloud Function source\n *\n * These environments provide standardized mock structures for testing\n * HTTP request handling without requiring actual cloud function 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 cloud function source\n *\n * Use this for testing HTTP event ingestion and request/response handling\n * without requiring a real GCP Cloud Function 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 postEvent: Flow.StepExample = {\n title: 'POST event',\n description:\n 'A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.',\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n body: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n headers: { 'content-type': 'application/json' },\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n ],\n ],\n};\n\nexport const orderEvent: Flow.StepExample = {\n title: 'Order POST',\n description:\n 'A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.',\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n body: {\n name: 'order complete',\n data: { id: 'ORD-700', total: 99.99, currency: 'EUR' },\n },\n headers: { 'content-type': 'application/json' },\n },\n out: [\n [\n 'elb',\n {\n name: 'order complete',\n data: { id: 'ORD-700', total: 99.99, currency: 'EUR' },\n },\n ],\n ],\n};\n\nexport const cloudFunctionPostForwardsSource: Flow.StepExample = {\n title: 'POST with provenance',\n description:\n 'A POST body carrying a source map is forwarded in full, so release and trace provenance survive the crossing.',\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n body: {\n name: 'page view',\n data: { title: 'Home' },\n source: { release: { web: 'r1' } },\n },\n headers: { 'content-type': 'application/json' },\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n source: { release: { web: 'r1' } },\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport type { CloudFunctionSource, Request, Response } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n method: string;\n body: Record<string, unknown>;\n headers?: Record<string, string>;\n}\n\nexport interface Result {\n status: number;\n body: unknown;\n}\n\n/**\n * Find the cloudfunction source instance from collector.sources.\n */\nfunction findGcpSource(\n collector: Collector.Instance,\n): CloudFunctionSource | undefined {\n for (const source of Object.values(collector.sources || {})) {\n if ((source as { type?: string }).type === 'cloudfunction')\n return source as unknown as CloudFunctionSource;\n }\n return undefined;\n}\n\n/**\n * GCP CloudFunction source createTrigger.\n *\n * Boots a real collector via startFlow, then synthesizes mock req/res\n * (matching the GCP Functions Framework pattern) and calls source.push(req, res).\n * This is the realistic approach for GCP Cloud Functions - the Functions Framework\n * synthesizes these objects in production too.\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 = findGcpSource(flow.collector);\n if (!source)\n throw new Error(\n 'CloudFunction source not found in collector — ensure it is configured in sources',\n );\n\n // Adapt body: step examples use `name`, source expects `event`\n const body = { ...content.body };\n if (body.name && !body.event) {\n body.event = body.name;\n delete body.name;\n }\n\n const headers = content.headers || {\n 'content-type': 'application/json',\n };\n\n // Synthesize mock req matching GCP Functions Framework pattern\n const req = {\n method: content.method,\n body,\n headers,\n get: (h: string) => headers[h.toLowerCase()],\n } as Request;\n\n // Synthesize mock res that captures status and response body\n let statusCode = 200;\n let responseBody: unknown;\n const res = {\n status: (code: number) => {\n statusCode = code;\n return res;\n },\n json: (data: unknown) => {\n responseBody = data;\n return res;\n },\n send: (data: unknown) => {\n responseBody = data;\n return res;\n },\n set: () => res,\n } as unknown as Response;\n\n // GCP source awaits env.push() — no detached promises\n await source.push(req, res);\n\n return { status: statusCode, body: responseBody };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\nexport { createTrigger };\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\nexport type { Content, Result } from './trigger';\n","import type { Message, SubscriptionOptions } from '@google-cloud/pubsub';\nimport type { Env, PubSubPullClient, PullSubscription } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment for the Pub/Sub pull source.\n *\n * `push` injects a structural Pub/Sub client (`env.PubSub`), so a simulated\n * run never reaches Google Cloud and its subscription call can be recorded.\n * The unit tests keep substituting the SDK module-wide via\n * `jest.mock('@google-cloud/pubsub')`; they use `push` without the client.\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/** A subscription that never receives: messages arrive by synthetic push. */\nclass MockSubscription implements PullSubscription {\n constructor(\n public name: string,\n public options?: SubscriptionOptions,\n ) {}\n\n on(\n _event: 'message' | 'error',\n _listener: ((message: Message) => void) | ((error: Error) => void),\n ): this {\n return this;\n }\n\n async close(): Promise<void> {}\n}\n\nclass MockPubSub implements PubSubPullClient {\n constructor(public options?: object) {}\n\n subscription(name: string, options?: SubscriptionOptions): MockSubscription {\n return new MockSubscription(name, options);\n }\n\n async close(): Promise<void> {}\n}\n\nfunction createEnv(): Env {\n return {\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}\n\n/** Standard mock environment, with the structural client for simulate. */\nexport const push: Env = Object.assign(createEnv(), { PubSub: MockPubSub });\n\n/**\n * The same environment without the client, for unit tests that substitute the\n * SDK module-wide with `jest.mock`.\n */\nexport const moduleMockEnv: Env = createEnv();\n\n/**\n * The subscription call binds the source to its subscription; messages then\n * arrive as events, not calls. Construction is not recorded: its options\n * carry credentials.\n */\nexport const simulation = ['call:PubSub.subscription'];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * Pub/Sub pull step examples.\n *\n * Each example's `in` is a partial MessageLike (id, data Buffer, attributes,\n * publishTime). The trigger synthesizes the missing fields and invokes the\n * registered message handler. `out` is the array of recorded mock calls\n * produced by the handler. Recording shape is `[method, ...args]`.\n *\n * The `__triggerMessage` helper records each message's terminal state under\n * `message.ack` or `message.nack` so step examples can assert on that.\n */\n\nconst eventPayload = {\n name: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n name: 'order complete',\n data: { id: 'ORD-500', total: 199.99, currency: 'EUR' },\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A JSON-encoded page view event arrives on the subscription, decodes successfully, and is acked.',\n in: {\n id: 'msg-1',\n dataString: JSON.stringify(eventPayload),\n attributes: {},\n },\n out: [['message.ack', 'msg-1']],\n};\n\nexport const orderComplete: Flow.StepExample = {\n title: 'Order complete',\n description:\n 'A JSON-encoded order event arrives and is acked after successful collector forwarding.',\n in: {\n id: 'msg-2',\n dataString: JSON.stringify(orderPayload),\n attributes: { entity: 'order', action: 'complete' },\n },\n out: [['message.ack', 'msg-2']],\n};\n\nexport const decoderText: Flow.StepExample = {\n title: 'Text decoder',\n description:\n 'With decoder=text on the source settings, the message data is forwarded to the collector as a UTF-8 string and acked.',\n in: {\n id: 'msg-3',\n dataString: 'plain text payload',\n attributes: {},\n },\n out: [['message.ack', 'msg-3']],\n};\n\nexport const malformedJson: Flow.StepExample = {\n title: 'Malformed JSON nack',\n description:\n 'A non-JSON body with the default json decoder fails to decode; the message is nacked for redelivery.',\n in: {\n id: 'msg-4',\n dataString: 'not-json{',\n attributes: {},\n },\n out: [['message.nack', 'msg-4']],\n};\n\nexport const malformedJsonAck: Flow.StepExample = {\n title: 'Malformed JSON ack-and-drop',\n description:\n 'With onPushError=ack on the source settings, a malformed JSON message is acked-and-dropped instead of redelivered.',\n in: {\n id: 'msg-5',\n dataString: 'not-json{',\n attributes: {},\n },\n out: [['message.ack', 'msg-5']],\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 pull-source trigger.\n *\n * The trigger synthesizes a message from this partial input and dispatches\n * it through the source's `push()` (the same pipeline the SDK subscriber\n * callback uses). `dataString` is the user-friendly way to provide the\n * message body; the trigger encodes it to a Buffer.\n */\nexport interface Content {\n id: string;\n dataString: string;\n attributes?: Record<string, string>;\n orderingKey?: string;\n}\n\n/**\n * Result shape for the pull-source trigger.\n *\n * Returns the recorded ack/nack as `[method, id]` entries, mirroring the\n * destination's `[method, ...args]` recording shape used elsewhere.\n */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface PubSubPullSourceLike {\n type: string;\n push: (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;\n}\n\nfunction isPubSubPullSource(value: unknown): value is PubSubPullSourceLike {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return (\n candidate.type === 'pubsub-pull' && typeof candidate.push === 'function'\n );\n}\n\nfunction findSource(\n collector: Collector.Instance,\n): PubSubPullSourceLike | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isPubSubPullSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * Pub/Sub pull source createTrigger.\n *\n * Boots the collector via startFlow, finds the registered pubsub-pull source,\n * and invokes its `push()` with a synthesized message. The source dispatches\n * the synthetic message through the same handler the SDK subscriber callback\n * uses, exercising the full decode / forward / ack-nack pipeline without\n * touching real Pub/Sub.\n *\n * Matches the convention used by other source triggers (express, lambda,\n * cloudfunction): find the source by type from the collector and call its\n * public `push()` interface.\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 'pubsub-pull source not registered in collector — ensure it is configured in sources',\n );\n\n const synthetic: SyntheticMessage = {\n id: content.id,\n data: Buffer.from(content.dataString, 'utf8'),\n attributes: content.attributes,\n orderingKey: content.orderingKey,\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.id]);\n if (result.nacked) recorded.push(['message.nack', content.id]);\n }\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\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 Pub/Sub push source.\n *\n * Provides a no-op env compatible with `Source.Env` plus an optional\n * verifyOidcToken stub for tests that exercise OIDC verification.\n */\n\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\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() => Promise.resolve({ ok: true })) as Elb.Fn;\n return fn;\n};\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: string[] = [];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * Pub/Sub push step examples.\n *\n * Each example's `in` is a partial Pub/Sub push envelope (with `message.data`\n * pre-encoded as base64). The trigger constructs an HTTP-like Request from\n * `in` and invokes the source handler. `out` is the recorded HTTP response\n * shape (statusCode + JSON body).\n */\n\nconst eventPayload = {\n name: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n name: 'order complete',\n data: { id: 'ORD-500', total: 199.99, currency: 'EUR' },\n};\n\nfunction encodeData(value: unknown): string {\n return Buffer.from(JSON.stringify(value), 'utf8').toString('base64');\n}\n\nexport const validEnvelope: Flow.StepExample = {\n title: 'Valid push envelope',\n description:\n 'A well-formed Pub/Sub push envelope decodes the base64 data, parses JSON, and forwards the event to the collector with a 200 response.',\n in: {\n message: {\n messageId: 'push-1',\n data: encodeData(eventPayload),\n attributes: { source: 'analytics' },\n },\n subscription: 'projects/test/subscriptions/events-sub',\n },\n out: [['response', 200, { success: true, id: 'push-1' }]],\n};\n\nexport const orderEnvelope: Flow.StepExample = {\n title: 'Order envelope',\n description:\n 'A push envelope carrying an order event is decoded and forwarded to the collector.',\n in: {\n message: {\n messageId: 'push-2',\n data: encodeData(orderPayload),\n attributes: {},\n },\n subscription: 'projects/test/subscriptions/events-sub',\n },\n out: [['response', 200, { success: true, id: 'push-2' }]],\n};\n\nexport const malformedEnvelope: Flow.StepExample = {\n title: 'Malformed envelope',\n description:\n 'A POST body lacking message.messageId returns 400 Bad Request without forwarding to the collector.',\n in: {\n not_a: 'pubsub envelope',\n },\n out: [\n [\n 'response',\n 400,\n {\n success: false,\n error: 'Malformed Pub/Sub envelope (missing message.messageId).',\n },\n ],\n ],\n};\n","import type { Collector, Trigger } from '@walkeros/core';\nimport type { Request, Response } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\n/** Content for the push trigger: a Pub/Sub envelope or any POST body. */\nexport type Content = Record<string, unknown>;\n\n/** Result: the recorded HTTP response (`status` + `json` body). */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface RecordedResponse {\n statusCode?: number;\n body?: unknown;\n}\n\nfunction buildResponse(state: RecordedResponse): Response {\n const res: Response = {\n status(code: number) {\n state.statusCode = code;\n return res;\n },\n json(body: unknown) {\n state.body = body;\n return res;\n },\n send(body?: unknown) {\n state.body = body;\n return res;\n },\n set() {\n return res;\n },\n };\n return res;\n}\n\nfunction buildRequest(\n content: Content,\n headers: Record<string, string>,\n): Request {\n return {\n method: 'POST',\n body: content,\n headers,\n get(name: string) {\n const value = headers[name.toLowerCase()] ?? headers[name];\n return value;\n },\n };\n}\n\ninterface TriggerOptions {\n headers?: Record<string, string>;\n}\n\ninterface PushCapableSource {\n type: string;\n push: (req: Request, res: Response) => Promise<void>;\n}\n\nfunction isPushCapableSource(value: unknown): value is PushCapableSource {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return (\n typeof candidate.type === 'string' &&\n candidate.type === 'pubsub-push' &&\n typeof candidate.push === 'function'\n );\n}\n\nfunction findPushSource(\n collector: Collector.Instance,\n): PushCapableSource | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isPushCapableSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * Pub/Sub push source createTrigger.\n *\n * Boots the collector via startFlow, builds a fake Request/Response pair\n * from the trigger Content, and invokes the source's HTTP handler. Returns\n * the recorded response as a Result entry.\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 (_type, options) =>\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 triggerOptions: TriggerOptions =\n typeof options === 'object' && options !== null\n ? (options as TriggerOptions)\n : {};\n const headers = triggerOptions.headers ?? {};\n\n const source = findPushSource(flow.collector);\n if (!source) throw new Error('pubsub-push source not registered');\n\n const state: RecordedResponse = {};\n const req = buildRequest(content, headers);\n const res = buildResponse(state);\n\n await source.push(req, res);\n\n const recorded: Result = [\n ['response', state.statusCode ?? 0, state.body ?? null],\n ];\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\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 * GCP CloudFunction 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 .optional(),\n\n maxBatchSize: z\n .number()\n .int()\n .min(1)\n .describe('Maximum number of events accepted in a single batch request')\n .default(100),\n\n enablePixelTracking: z\n .boolean()\n .describe('Serve a tracking pixel for GET requests')\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(540000) // GCP Cloud Functions max timeout: 9 minutes\n .describe('Request timeout in milliseconds (max: 540000 for GCP)')\n .optional(),\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\nexport const settings = zodToSchema(SettingsSchema);\nexport const setup = zodToSchema(SetupSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * GCP Pub/Sub pull source settings schema.\n *\n * Required: projectId, subscription. All other fields optional with sensible\n * defaults applied at runtime by `getConfig`.\n */\nexport const SettingsSchema = z.object({\n client: z\n .any()\n .describe(\n 'Pre-configured Google Cloud Pub/Sub client (like new PubSub({ projectId })). Bypasses credentials resolution when supplied.',\n )\n .optional(),\n projectId: z\n .string()\n .min(1)\n .describe('Google Cloud Project ID (like my-gcp-project).'),\n subscription: z\n .string()\n .min(1)\n .describe(\n 'Pub/Sub subscription short name (like events-sub). The full resource name projects/<projectId>/subscriptions/<subscription> is built by the SDK.',\n ),\n topic: z\n .string()\n .describe(\n 'Pub/Sub topic short name. Required when setup.createTopic is true; otherwise informational.',\n )\n .optional(),\n credentials: z\n .any()\n .describe(\n 'Service account credentials as a JSON string or an object with client_email and private_key. Default: Application Default Credentials (ADC). (deprecated: use config.credentials)',\n )\n .optional(),\n apiEndpoint: z\n .string()\n .describe(\n 'Override Pub/Sub API endpoint. Useful for the local emulator (like localhost:8085).',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message data field. json (default) parses JSON, text decodes UTF-8, raw forwards the Buffer.',\n )\n .optional(),\n flowControl: z\n .object({\n maxMessages: z\n .number()\n .describe('Maximum in-flight messages. Default: 100.')\n .optional(),\n maxBytes: z\n .number()\n .describe('Maximum in-flight bytes. Default: 10485760 (10 MB).')\n .optional(),\n })\n .describe('Subscriber flow control. Tightens the SDK defaults.')\n .optional(),\n ackDeadline: z\n .number()\n .describe('Subscriber ack deadline in seconds. Default: 60.')\n .optional(),\n shutdownTimeoutMs: z\n .number()\n .describe(\n 'Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes the subscriber.',\n )\n .optional(),\n onPushError: z\n .enum(['nack', 'ack'])\n .describe(\n 'Behavior when forwarding to the collector throws. nack (default) redelivers the message; 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 * GCP Pub/Sub pull source setup schema.\n *\n * Provisioning options for `walkeros setup source.<id>`. Idempotent\n * subscription creation, plus optional topic and dead-letter topic\n * auto-create. Triggered only by the explicit CLI command.\n */\nexport const SetupSchema = z.object({\n createTopic: z\n .boolean()\n .describe(\n 'Create the topic if it does not exist. Requires settings.topic. Default: false (require pre-existing topic).',\n )\n .optional(),\n ackDeadlineSeconds: z\n .number()\n .describe('Subscription ack deadline in seconds. Default: 60.')\n .optional(),\n messageRetentionDuration: z\n .object({\n seconds: z\n .number()\n .describe('Retention window in seconds. Default: project default.'),\n })\n .describe('Subscription-level retention configuration.')\n .optional(),\n filter: z\n .string()\n .describe(\n 'Subscription filter expression. Only messages matching this filter are delivered.',\n )\n .optional(),\n deadLetterPolicy: z\n .object({\n deadLetterTopic: z.string().describe('Dead-letter topic short name.'),\n maxDeliveryAttempts: z\n .number()\n .describe(\n 'Maximum delivery attempts before forwarding to the dead-letter topic.',\n ),\n createDeadLetterTopic: z\n .boolean()\n .describe(\n 'Auto-create the dead-letter topic if it does not exist. Default: false.',\n )\n .optional(),\n })\n .describe('Dead-letter policy. Strongly recommended for production.')\n .optional(),\n retryPolicy: z\n .object({\n minimumBackoff: z.object({\n seconds: z.number().describe('Minimum backoff in seconds.'),\n }),\n maximumBackoff: z.object({\n seconds: z.number().describe('Maximum backoff in seconds.'),\n }),\n })\n .describe('Subscription retry policy.')\n .optional(),\n enableMessageOrdering: z\n .boolean()\n .describe('Enable message ordering on the subscription. Default: false.')\n .optional(),\n labels: z\n .record(z.string(), z.string())\n .describe('Subscription labels for organization and billing.')\n .optional(),\n expirationPolicy: z\n .object({\n ttl: z\n .object({\n seconds: z\n .number()\n .describe('TTL in seconds. null means never expire.'),\n })\n .nullable()\n .optional(),\n })\n .describe('Subscription expiration policy.')\n .optional(),\n});\n\nexport type Setup = z.infer<typeof SetupSchema>;\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * GCP Pub/Sub push source settings schema.\n *\n * No required fields. The push source is a request-handler; configuration\n * tunables live here, but operators wire `source.push` into their own\n * express/lambda runtime.\n */\nexport const SettingsSchema = z.object({\n projectId: z\n .string()\n .describe(\n 'Google Cloud Project ID (informational, surfaced in error messages).',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message data field. json (default) parses JSON, text decodes UTF-8, raw forwards the Buffer.',\n )\n .optional(),\n verifyOidc: z\n .boolean()\n .describe(\n 'Verify the OIDC bearer token Pub/Sub attaches to push requests. Default: false.',\n )\n .optional(),\n audience: z\n .string()\n .describe(\n 'OIDC audience (your endpoint URL or a custom audience). Required when verifyOidc is true.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA,EAAA,yBAAAC;AAAA,EAAA,0BAAAD;AAAA,EAAA,yBAAAC;AAAA,EAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAWA,IAAM,kBAAkB,MAAc;AACpC,QAAM,MAAM,MACV,QAAQ,QAAQ;AAAA,IACd,IAAI;AAAA,EACN,CAAC;AACH,SAAO;AACT;AAGA,IAAM,SAAS,MAAM;AAAC;AACtB,IAAM,aAA8B;AAAA,EAClC,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO,CAAC,YAA4B;AAClC,UAAM,OAAO,YAAY,WAAW,IAAI,MAAM,OAAO,IAAI;AAAA,EAC3D;AAAA,EACA,MAAM;AAAA,EACN,OAAO,MAAM;AACf;AAQO,IAAM,OAAY;AAAA,EACvB,IAAI,OAAO;AACT,WAAO,gBAAgB;AAAA,EACzB;AAAA,EACA,IAAI,UAAU;AACZ,WAAO,gBAAgB;AAAA,EACzB;AAAA,EACA,IAAI,MAAM;AACR,WAAO,gBAAgB;AAAA,EACzB;AAAA,EACA,QAAQ;AACV;;;AClDA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,YAA8B;AAAA,EACzC,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS,EAAE,MAAM,OAAO;AAAA,EACxB,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,MAAM,EAAE,OAAO,QAAQ,KAAK,uBAAuB;AAAA,IACrD;AAAA,IACA,SAAS,EAAE,gBAAgB,mBA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BAAAC;AAAA,EAAA,gBAAAC;AAAA;AAAA,IAAAC,cAA4B;;;ACA5B,IAAAC,cAAkB;AASX,IAAMC,kBAAiB,cAAE,OAAO;AAAA,EACrC,WAAW,cACR,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,cACN,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,EAC5B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,YAAY,cACT,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,UAAU,cACP,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;AD7BM,IAAMC,gBAAW,yBAAYC,eAAc;;;AnBU3C,IAAM,iBAAiB;AAAA,EAC5B,qBAAqB;AAAA,EACrB,kBAAkBC;AAAA,EAClB,kBAAkBA;AACpB;AAGO,IAAM,gBAAgB;AAAA,EAC3B,qBAAqB,EAAE,SAA0C;AAAA,EACjE,kBAAkB;AAAA,IAChB,UAA8BC;AAAA,IAC9B;AAAA,EACF;AAAA,EACA,kBAAkB,EAAE,UAA8BA,UAAS;AAC7D;","names":["examples_exports","schemas_exports","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","noopFn","noopLogger","createMockElbFn","step_exports","import_collector","createTrigger","result","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","simulation","noopFn","noopLogger","createMockElbFn","step_exports","eventPayload","orderPayload","import_collector","createTrigger","import_dev","import_dev","schemas_exports","SettingsSchema","settings","import_dev","import_dev","SettingsSchema","import_dev","settings","SettingsSchema","schemas_exports","SettingsSchema","settings","import_dev","import_dev","SettingsSchema","settings","SettingsSchema","examples_exports","settings"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/cloudfunction/examples/index.ts","../src/cloudfunction/examples/env.ts","../src/cloudfunction/examples/step.ts","../src/cloudfunction/examples/trigger.ts","../src/pubsub/pull/examples/index.ts","../src/pubsub/pull/examples/env.ts","../src/pubsub/pull/examples/step.ts","../src/pubsub/pull/examples/trigger.ts","../src/pubsub/push/examples/index.ts","../src/pubsub/push/examples/env.ts","../src/pubsub/push/examples/step.ts","../src/pubsub/push/examples/trigger.ts","../src/cloudfunction/schemas/index.ts","../src/cloudfunction/schemas/settings.ts","../src/cloudfunction/schemas/primitives.ts","../src/pubsub/pull/schemas/index.ts","../src/pubsub/pull/schemas/settings.ts","../src/pubsub/pull/schemas/setup.ts","../src/pubsub/push/schemas/index.ts","../src/pubsub/push/schemas/settings.ts"],"sourcesContent":["import * as cloudFunctionExamplesNs from './cloudfunction/examples';\nimport * as pubsubPullExamplesNs from './pubsub/pull/examples';\nimport * as pubsubPushExamplesNs from './pubsub/push/examples';\nimport * as cloudFunctionSchemasNs from './cloudfunction/schemas';\nimport * as pubsubPullSchemasNs from './pubsub/pull/schemas';\nimport * as pubsubPushSchemasNs from './pubsub/push/schemas';\n\nexport * as schemas from './cloudfunction/schemas';\nexport * as examples from './cloudfunction/examples';\nexport * as pubsubPullSchemas from './pubsub/pull/schemas';\nexport * as pubsubPullExamples from './pubsub/pull/examples';\nexport * as pubsubPushSchemas from './pubsub/push/schemas';\nexport * as pubsubPushExamples from './pubsub/push/examples';\n\n/** Dev examples per export, keyed by the export names in package.json. */\nexport const exportExamples = {\n sourceCloudFunction: cloudFunctionExamplesNs,\n sourcePubSubPull: pubsubPullExamplesNs,\n sourcePubSubPush: pubsubPushExamplesNs,\n};\n\n/** Schemas per export, keyed by the export names in package.json. */\nexport const exportSchemas = {\n sourceCloudFunction: { settings: cloudFunctionSchemasNs.settings },\n sourcePubSubPull: {\n settings: pubsubPullSchemasNs.settings,\n setup: pubsubPullSchemasNs.setup,\n },\n sourcePubSubPush: { settings: pubsubPushSchemasNs.settings },\n};\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for GCP Cloud Function source\n *\n * These environments provide standardized mock structures for testing\n * HTTP request handling without requiring actual cloud function 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 cloud function source\n *\n * Use this for testing HTTP event ingestion and request/response handling\n * without requiring a real GCP Cloud Function 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 postEvent: Flow.StepExample = {\n title: 'POST event',\n description:\n 'A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.',\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n body: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n headers: { 'content-type': 'application/json' },\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n ],\n ],\n};\n\nexport const orderEvent: Flow.StepExample = {\n title: 'Order POST',\n description:\n 'A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.',\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n body: {\n name: 'order complete',\n data: { id: 'ORD-700', value: 99.99, currency: 'EUR' },\n },\n headers: { 'content-type': 'application/json' },\n },\n out: [\n [\n 'elb',\n {\n name: 'order complete',\n data: { id: 'ORD-700', value: 99.99, currency: 'EUR' },\n },\n ],\n ],\n};\n\nexport const cloudFunctionPostForwardsSource: Flow.StepExample = {\n title: 'POST with provenance',\n description:\n 'A POST body carrying a source map is forwarded in full, so release and trace provenance survive the crossing.',\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n body: {\n name: 'page view',\n data: { title: 'Home' },\n source: { release: { web: 'r1' } },\n },\n headers: { 'content-type': 'application/json' },\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n source: { release: { web: 'r1' } },\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport type { CloudFunctionSource, Request, Response } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n method: string;\n body: Record<string, unknown>;\n headers?: Record<string, string>;\n}\n\nexport interface Result {\n status: number;\n body: unknown;\n}\n\n/**\n * Find the cloudfunction source instance from collector.sources.\n */\nfunction findGcpSource(\n collector: Collector.Instance,\n): CloudFunctionSource | undefined {\n for (const source of Object.values(collector.sources || {})) {\n if ((source as { type?: string }).type === 'cloudfunction')\n return source as unknown as CloudFunctionSource;\n }\n return undefined;\n}\n\n/**\n * GCP CloudFunction source createTrigger.\n *\n * Boots a real collector via startFlow, then synthesizes mock req/res\n * (matching the GCP Functions Framework pattern) and calls source.push(req, res).\n * This is the realistic approach for GCP Cloud Functions - the Functions Framework\n * synthesizes these objects in production too.\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 = findGcpSource(flow.collector);\n if (!source)\n throw new Error(\n 'CloudFunction source not found in collector — ensure it is configured in sources',\n );\n\n // Adapt body: step examples use `name`, source expects `event`\n const body = { ...content.body };\n if (body.name && !body.event) {\n body.event = body.name;\n delete body.name;\n }\n\n const headers = content.headers || {\n 'content-type': 'application/json',\n };\n\n // Synthesize mock req matching GCP Functions Framework pattern\n const req = {\n method: content.method,\n body,\n headers,\n get: (h: string) => headers[h.toLowerCase()],\n } as Request;\n\n // Synthesize mock res that captures status and response body\n let statusCode = 200;\n let responseBody: unknown;\n const res = {\n status: (code: number) => {\n statusCode = code;\n return res;\n },\n json: (data: unknown) => {\n responseBody = data;\n return res;\n },\n send: (data: unknown) => {\n responseBody = data;\n return res;\n },\n set: () => res,\n } as unknown as Response;\n\n // GCP source awaits env.push() — no detached promises\n await source.push(req, res);\n\n return { status: statusCode, body: responseBody };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\nexport { createTrigger };\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\nexport type { Content, Result } from './trigger';\n","import type { Message, SubscriptionOptions } from '@google-cloud/pubsub';\nimport type { Env, PubSubPullClient, PullSubscription } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment for the Pub/Sub pull source.\n *\n * `push` injects a structural Pub/Sub client (`env.PubSub`), so a simulated\n * run never reaches Google Cloud and its subscription call can be recorded.\n * The unit tests keep substituting the SDK module-wide via\n * `jest.mock('@google-cloud/pubsub')`; they use `push` without the client.\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/** A subscription that never receives: messages arrive by synthetic push. */\nclass MockSubscription implements PullSubscription {\n constructor(\n public name: string,\n public options?: SubscriptionOptions,\n ) {}\n\n on(\n _event: 'message' | 'error',\n _listener: ((message: Message) => void) | ((error: Error) => void),\n ): this {\n return this;\n }\n\n async close(): Promise<void> {}\n}\n\nclass MockPubSub implements PubSubPullClient {\n constructor(public options?: object) {}\n\n subscription(name: string, options?: SubscriptionOptions): MockSubscription {\n return new MockSubscription(name, options);\n }\n\n async close(): Promise<void> {}\n}\n\nfunction createEnv(): Env {\n return {\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}\n\n/** Standard mock environment, with the structural client for simulate. */\nexport const push: Env = Object.assign(createEnv(), { PubSub: MockPubSub });\n\n/**\n * The same environment without the client, for unit tests that substitute the\n * SDK module-wide with `jest.mock`.\n */\nexport const moduleMockEnv: Env = createEnv();\n\n/**\n * The subscription call binds the source to its subscription; messages then\n * arrive as events, not calls. Construction is not recorded: its options\n * carry credentials.\n */\nexport const simulation = ['call:PubSub.subscription'];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * Pub/Sub pull step examples.\n *\n * Each example's `in` is a partial MessageLike (id, data Buffer, attributes,\n * publishTime). The trigger synthesizes the missing fields and invokes the\n * registered message handler. `out` is the array of recorded mock calls\n * produced by the handler. Recording shape is `[method, ...args]`.\n *\n * The `__triggerMessage` helper records each message's terminal state under\n * `message.ack` or `message.nack` so step examples can assert on that.\n */\n\nconst eventPayload = {\n name: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n name: 'order complete',\n data: { id: 'ORD-500', value: 199.99, currency: 'EUR' },\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A JSON-encoded page view event arrives on the subscription, decodes successfully, and is acked.',\n in: {\n id: 'msg-1',\n dataString: JSON.stringify(eventPayload),\n attributes: {},\n },\n out: [['message.ack', 'msg-1']],\n};\n\nexport const orderComplete: Flow.StepExample = {\n title: 'Order complete',\n description:\n 'A JSON-encoded order event arrives and is acked after successful collector forwarding.',\n in: {\n id: 'msg-2',\n dataString: JSON.stringify(orderPayload),\n attributes: { entity: 'order', action: 'complete' },\n },\n out: [['message.ack', 'msg-2']],\n};\n\nexport const decoderText: Flow.StepExample = {\n title: 'Text decoder',\n description:\n 'With decoder=text on the source settings, the message data is forwarded as data.payload. It has no event name, so without a before transformer that builds the event the collector rejects it and the message is acked.',\n in: {\n id: 'msg-3',\n dataString: 'plain text payload',\n attributes: {},\n },\n out: [['message.ack', 'msg-3']],\n};\n\nexport const malformedJson: Flow.StepExample = {\n title: 'Malformed JSON nack',\n description:\n 'A non-JSON body with the default json decoder fails to decode; the message is nacked for redelivery.',\n in: {\n id: 'msg-4',\n dataString: 'not-json{',\n attributes: {},\n },\n out: [['message.nack', 'msg-4']],\n};\n\nexport const malformedJsonAck: Flow.StepExample = {\n title: 'Malformed JSON ack-and-drop',\n description:\n 'With onPushError=ack on the source settings, a malformed JSON message is acked-and-dropped instead of redelivered.',\n in: {\n id: 'msg-5',\n dataString: 'not-json{',\n attributes: {},\n },\n out: [['message.ack', 'msg-5']],\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 pull-source trigger.\n *\n * The trigger synthesizes a message from this partial input and dispatches\n * it through the source's `push()` (the same pipeline the SDK subscriber\n * callback uses). `dataString` is the user-friendly way to provide the\n * message body; the trigger encodes it to a Buffer.\n */\nexport interface Content {\n id: string;\n dataString: string;\n attributes?: Record<string, string>;\n orderingKey?: string;\n}\n\n/**\n * Result shape for the pull-source trigger.\n *\n * Returns the recorded ack/nack as `[method, id]` entries, mirroring the\n * destination's `[method, ...args]` recording shape used elsewhere.\n */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface PubSubPullSourceLike {\n type: string;\n push: (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;\n}\n\nfunction isPubSubPullSource(value: unknown): value is PubSubPullSourceLike {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return (\n candidate.type === 'pubsub-pull' && typeof candidate.push === 'function'\n );\n}\n\nfunction findSource(\n collector: Collector.Instance,\n): PubSubPullSourceLike | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isPubSubPullSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * Pub/Sub pull source createTrigger.\n *\n * Boots the collector via startFlow, finds the registered pubsub-pull source,\n * and invokes its `push()` with a synthesized message. The source dispatches\n * the synthetic message through the same handler the SDK subscriber callback\n * uses, exercising the full decode / forward / ack-nack pipeline without\n * touching real Pub/Sub.\n *\n * Matches the convention used by other source triggers (express, lambda,\n * cloudfunction): find the source by type from the collector and call its\n * public `push()` interface.\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 'pubsub-pull source not registered in collector — ensure it is configured in sources',\n );\n\n const synthetic: SyntheticMessage = {\n id: content.id,\n data: Buffer.from(content.dataString, 'utf8'),\n attributes: content.attributes,\n orderingKey: content.orderingKey,\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.id]);\n if (result.nacked) recorded.push(['message.nack', content.id]);\n }\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\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 Pub/Sub push source.\n *\n * Provides a no-op env compatible with `Source.Env` plus an optional\n * verifyOidcToken stub for tests that exercise OIDC verification.\n */\n\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\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() => Promise.resolve({ ok: true })) as Elb.Fn;\n return fn;\n};\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: string[] = [];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * Pub/Sub push step examples.\n *\n * Each example's `in` is a partial Pub/Sub push envelope (with `message.data`\n * pre-encoded as base64). The trigger constructs an HTTP-like Request from\n * `in` and invokes the source handler. `out` is the recorded HTTP response\n * shape (statusCode + JSON body).\n */\n\nconst eventPayload = {\n name: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n name: 'order complete',\n data: { id: 'ORD-500', value: 199.99, currency: 'EUR' },\n};\n\nfunction encodeData(value: unknown): string {\n return Buffer.from(JSON.stringify(value), 'utf8').toString('base64');\n}\n\nexport const validEnvelope: Flow.StepExample = {\n title: 'Valid push envelope',\n description:\n 'A well-formed Pub/Sub push envelope decodes the base64 data, parses JSON, and forwards the event to the collector with a 200 response.',\n in: {\n message: {\n messageId: 'push-1',\n data: encodeData(eventPayload),\n attributes: { source: 'analytics' },\n },\n subscription: 'projects/test/subscriptions/events-sub',\n },\n out: [['response', 200, { success: true, id: 'push-1' }]],\n};\n\nexport const orderEnvelope: Flow.StepExample = {\n title: 'Order envelope',\n description:\n 'A push envelope carrying an order event is decoded and forwarded to the collector.',\n in: {\n message: {\n messageId: 'push-2',\n data: encodeData(orderPayload),\n attributes: {},\n },\n subscription: 'projects/test/subscriptions/events-sub',\n },\n out: [['response', 200, { success: true, id: 'push-2' }]],\n};\n\nexport const malformedEnvelope: Flow.StepExample = {\n title: 'Malformed envelope',\n description:\n 'A POST body lacking message.messageId returns 400 Bad Request without forwarding to the collector.',\n in: {\n not_a: 'pubsub envelope',\n },\n out: [\n [\n 'response',\n 400,\n {\n success: false,\n error: 'Malformed Pub/Sub envelope (missing message.messageId).',\n },\n ],\n ],\n};\n","import type { Collector, Trigger } from '@walkeros/core';\nimport type { Request, Response } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\n/** Content for the push trigger: a Pub/Sub envelope or any POST body. */\nexport type Content = Record<string, unknown>;\n\n/** Result: the recorded HTTP response (`status` + `json` body). */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface RecordedResponse {\n statusCode?: number;\n body?: unknown;\n}\n\nfunction buildResponse(state: RecordedResponse): Response {\n const res: Response = {\n status(code: number) {\n state.statusCode = code;\n return res;\n },\n json(body: unknown) {\n state.body = body;\n return res;\n },\n send(body?: unknown) {\n state.body = body;\n return res;\n },\n set() {\n return res;\n },\n };\n return res;\n}\n\nfunction buildRequest(\n content: Content,\n headers: Record<string, string>,\n): Request {\n return {\n method: 'POST',\n body: content,\n headers,\n get(name: string) {\n const value = headers[name.toLowerCase()] ?? headers[name];\n return value;\n },\n };\n}\n\ninterface TriggerOptions {\n headers?: Record<string, string>;\n}\n\ninterface PushCapableSource {\n type: string;\n push: (req: Request, res: Response) => Promise<void>;\n}\n\nfunction isPushCapableSource(value: unknown): value is PushCapableSource {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return (\n typeof candidate.type === 'string' &&\n candidate.type === 'pubsub-push' &&\n typeof candidate.push === 'function'\n );\n}\n\nfunction findPushSource(\n collector: Collector.Instance,\n): PushCapableSource | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isPushCapableSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * Pub/Sub push source createTrigger.\n *\n * Boots the collector via startFlow, builds a fake Request/Response pair\n * from the trigger Content, and invokes the source's HTTP handler. Returns\n * the recorded response as a Result entry.\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 (_type, options) =>\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 triggerOptions: TriggerOptions =\n typeof options === 'object' && options !== null\n ? (options as TriggerOptions)\n : {};\n const headers = triggerOptions.headers ?? {};\n\n const source = findPushSource(flow.collector);\n if (!source) throw new Error('pubsub-push source not registered');\n\n const state: RecordedResponse = {};\n const req = buildRequest(content, headers);\n const res = buildResponse(state);\n\n await source.push(req, res);\n\n const recorded: Result = [\n ['response', state.statusCode ?? 0, state.body ?? null],\n ];\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\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 * GCP CloudFunction 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 .optional(),\n\n maxBatchSize: z\n .number()\n .int()\n .min(1)\n .describe('Maximum number of events accepted in a single batch request')\n .default(100),\n\n enablePixelTracking: z\n .boolean()\n .describe('Serve a tracking pixel for GET requests')\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(540000) // GCP Cloud Functions max timeout: 9 minutes\n .describe('Request timeout in milliseconds (max: 540000 for GCP)')\n .optional(),\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\nexport const settings = zodToSchema(SettingsSchema);\nexport const setup = zodToSchema(SetupSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * GCP Pub/Sub pull source settings schema.\n *\n * Required: projectId, subscription. All other fields optional with sensible\n * defaults applied at runtime by `getConfig`.\n */\nexport const SettingsSchema = z.object({\n client: z\n .any()\n .describe(\n 'Pre-configured Google Cloud Pub/Sub client (like new PubSub({ projectId })). Bypasses credentials resolution when supplied.',\n )\n .optional(),\n projectId: z\n .string()\n .min(1)\n .describe('Google Cloud Project ID (like my-gcp-project).'),\n subscription: z\n .string()\n .min(1)\n .describe(\n 'Pub/Sub subscription short name (like events-sub). The full resource name projects/<projectId>/subscriptions/<subscription> is built by the SDK.',\n ),\n topic: z\n .string()\n .describe(\n 'Pub/Sub topic short name. Required when setup.createTopic is true; otherwise informational.',\n )\n .optional(),\n credentials: z\n .any()\n .describe(\n 'Service account credentials as a JSON string or an object with client_email and private_key. Default: Application Default Credentials (ADC). (deprecated: use config.credentials)',\n )\n .optional(),\n apiEndpoint: z\n .string()\n .describe(\n 'Override Pub/Sub API endpoint. Useful for the local emulator (like localhost:8085).',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message data field. json (default) parses JSON; text forwards the UTF-8 string as data.payload; raw forwards the bytes base64 encoded as data.payload. text and raw events need a before transformer that sets the event name.',\n )\n .optional(),\n flowControl: z\n .object({\n maxMessages: z\n .number()\n .describe('Maximum in-flight messages. Default: 100.')\n .optional(),\n maxBytes: z\n .number()\n .describe('Maximum in-flight bytes. Default: 10485760 (10 MB).')\n .optional(),\n })\n .describe('Subscriber flow control. Tightens the SDK defaults.')\n .optional(),\n ackDeadline: z\n .number()\n .describe('Subscriber ack deadline in seconds. Default: 60.')\n .optional(),\n shutdownTimeoutMs: z\n .number()\n .describe(\n 'Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes the subscriber.',\n )\n .optional(),\n onPushError: z\n .enum(['nack', 'ack'])\n .describe(\n 'Behavior when a message is not delivered and a redelivery could still deliver it (a retryable failure), or when decoding or forwarding throws. nack (default) redelivers the message; 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 * GCP Pub/Sub pull source setup schema.\n *\n * Provisioning options for `walkeros setup source.<id>`. Idempotent\n * subscription creation, plus optional topic and dead-letter topic\n * auto-create. Triggered only by the explicit CLI command.\n */\nexport const SetupSchema = z.object({\n createTopic: z\n .boolean()\n .describe(\n 'Create the topic if it does not exist. Requires settings.topic. Default: false (require pre-existing topic).',\n )\n .optional(),\n ackDeadlineSeconds: z\n .number()\n .describe(\n \"Subscription ack deadline in seconds. Unset: Pub/Sub's default (10).\",\n )\n .optional(),\n messageRetentionDuration: z\n .object({\n seconds: z\n .number()\n .describe('Retention window in seconds. Default: project default.'),\n })\n .describe('Subscription-level retention configuration.')\n .optional(),\n filter: z\n .string()\n .describe(\n 'Subscription filter expression. Only messages matching this filter are delivered.',\n )\n .optional(),\n deadLetterPolicy: z\n .object({\n deadLetterTopic: z.string().describe('Dead-letter topic short name.'),\n maxDeliveryAttempts: z\n .number()\n .describe(\n 'Maximum delivery attempts before forwarding to the dead-letter topic.',\n ),\n createDeadLetterTopic: z\n .boolean()\n .describe(\n 'Auto-create the dead-letter topic if it does not exist. Default: false.',\n )\n .optional(),\n })\n .describe('Dead-letter policy. Strongly recommended for production.')\n .optional(),\n retryPolicy: z\n .object({\n minimumBackoff: z.object({\n seconds: z.number().describe('Minimum backoff in seconds.'),\n }),\n maximumBackoff: z.object({\n seconds: z.number().describe('Maximum backoff in seconds.'),\n }),\n })\n .describe('Subscription retry policy.')\n .optional(),\n enableMessageOrdering: z\n .boolean()\n .describe('Enable message ordering on the subscription. Default: false.')\n .optional(),\n labels: z\n .record(z.string(), z.string())\n .describe('Subscription labels for organization and billing.')\n .optional(),\n expirationPolicy: z\n .object({\n ttl: z\n .object({\n seconds: z\n .number()\n .describe('TTL in seconds. null means never expire.'),\n })\n .nullable()\n .optional(),\n })\n .describe('Subscription expiration policy.')\n .optional(),\n});\n\nexport type Setup = z.infer<typeof SetupSchema>;\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * GCP Pub/Sub push source settings schema.\n *\n * No required fields. The push source is a request-handler; configuration\n * tunables live here, but operators wire `source.push` into their own\n * express/lambda runtime.\n */\nexport const SettingsSchema = z.object({\n projectId: z\n .string()\n .describe(\n 'Google Cloud Project ID. Optional; the push handler does not read it.',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message data field. json (default) parses JSON, text forwards the UTF-8 string, raw forwards the Buffer. text and raw values carry no event name: without a before transformer that builds the event the collector rejects them and the push answers 400.',\n )\n .optional(),\n verifyOidc: z\n .boolean()\n .describe(\n 'Verify the OIDC bearer token Pub/Sub attaches to push requests. Default: false.',\n )\n .optional(),\n audience: z\n .string()\n .describe(\n 'OIDC audience (your endpoint URL or a custom audience). Required when verifyOidc is true.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA,EAAA,yBAAAC;AAAA,EAAA,0BAAAD;AAAA,EAAA,yBAAAC;AAAA,EAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAWA,IAAM,kBAAkB,MAAc;AACpC,QAAM,MAAM,MACV,QAAQ,QAAQ;AAAA,IACd,IAAI;AAAA,EACN,CAAC;AACH,SAAO;AACT;AAGA,IAAM,SAAS,MAAM;AAAC;AACtB,IAAM,aAA8B;AAAA,EAClC,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO,CAAC,YAA4B;AAClC,UAAM,OAAO,YAAY,WAAW,IAAI,MAAM,OAAO,IAAI;AAAA,EAC3D;AAAA,EACA,MAAM;AAAA,EACN,OAAO,MAAM;AACf;AAQO,IAAM,OAAY;AAAA,EACvB,IAAI,OAAO;AACT,WAAO,gBAAgB;AAAA,EACzB;AAAA,EACA,IAAI,UAAU;AACZ,WAAO,gBAAgB;AAAA,EACzB;AAAA,EACA,IAAI,MAAM;AACR,WAAO,gBAAgB;AAAA,EACzB;AAAA,EACA,QAAQ;AACV;;;AClDA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,YAA8B;AAAA,EACzC,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS,EAAE,MAAM,OAAO;AAAA,EACxB,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,MAAM,EAAE,OAAO,QAAQ,KAAK,uBAAuB;AAAA,IACrD;AAAA,IACA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A;AAAA,SAAAA,kBAAA;AAAA,wBAAAC;AAAA,EAAA,gBAAAC;AAAA;AAAA,IAAAC,cAA4B;;;ACA5B,IAAAC,cAAkB;AASX,IAAMC,kBAAiB,cAAE,OAAO;AAAA,EACrC,WAAW,cACR,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,cACN,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,EAC5B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,YAAY,cACT,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,UAAU,cACP,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;AD7BM,IAAMC,gBAAW,yBAAYC,eAAc;;;AnBU3C,IAAM,iBAAiB;AAAA,EAC5B,qBAAqB;AAAA,EACrB,kBAAkBC;AAAA,EAClB,kBAAkBA;AACpB;AAGO,IAAM,gBAAgB;AAAA,EAC3B,qBAAqB,EAAE,SAA0C;AAAA,EACjE,kBAAkB;AAAA,IAChB,UAA8BC;AAAA,IAC9B;AAAA,EACF;AAAA,EACA,kBAAkB,EAAE,UAA8BA,UAAS;AAC7D;","names":["examples_exports","schemas_exports","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","noopFn","noopLogger","createMockElbFn","step_exports","import_collector","createTrigger","result","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","simulation","noopFn","noopLogger","createMockElbFn","step_exports","eventPayload","orderPayload","import_collector","createTrigger","import_dev","import_dev","schemas_exports","SettingsSchema","settings","import_dev","import_dev","SettingsSchema","import_dev","settings","SettingsSchema","schemas_exports","SettingsSchema","settings","import_dev","import_dev","SettingsSchema","settings","SettingsSchema","examples_exports","settings"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,o)=>{for(var r in o)e(t,r,{get:o[r],enumerable:!0})},o={};t(o,{createTrigger:()=>b,env:()=>r,step:()=>c});var r={};t(r,{push:()=>a});var s=()=>()=>Promise.resolve({ok:!0}),i=()=>{},n={error:i,warn:i,info:i,debug:i,throw:e=>{throw"string"==typeof e?new Error(e):e},json:i,scope:()=>n},a={get push(){return s()},get command(){return s()},get elb(){return s()},logger:n},c={};t(c,{cloudFunctionPostForwardsSource:()=>u,orderEvent:()=>d,postEvent:()=>l});var l={title:"POST event",description:"A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},d={title:"Order POST",description:"A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"order complete",data:{id:"ORD-700",total:99.99,currency:"EUR"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"order complete",data:{id:"ORD-700",total:99.99,currency:"EUR"}}]]},u={title:"POST with provenance",description:"A POST body carrying a source map is forwarded in full, so release and trace provenance survive the crossing.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}}]]};import{startFlow as p}from"@walkeros/collector";var b=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await p(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources||{}))if("cloudfunction"===t.type)return t}(t.collector);if(!r)throw new Error("CloudFunction source not found in collector — ensure it is configured in sources");const s={...o.body};s.name&&!s.event&&(s.event=s.name,delete s.name);const i=o.headers||{"content-type":"application/json"},n={method:o.method,body:s,headers:i,get:e=>i[e.toLowerCase()]};let a,c=200;const l={status:e=>(c=e,l),json:e=>(a=e,l),send:e=>(a=e,l),set:()=>l};return await r.push(n,l),{status:c,body:a}}}},m={};t(m,{createTrigger:()=>R,env:()=>g,step:()=>O});var g={};t(g,{moduleMockEnv:()=>P,push:()=>S,simulation:()=>k});var f=()=>{},h={error:f,warn:f,info:f,debug:f,throw:e=>{throw"string"==typeof e?new Error(e):e},json:f,scope:()=>h},w=()=>()=>Promise.resolve({ok:!0}),v=class{constructor(e,t){this.name=e,this.options=t}name;options;on(e,t){return this}async close(){}};function y(){return{get push(){return w()},get command(){return w()},get elb(){return w()},logger:h}}var S=Object.assign(y(),{PubSub:class{constructor(e){this.options=e}options;subscription(e,t){return new v(e,t)}async close(){}}}),P=y(),k=["call:PubSub.subscription"],O={};t(O,{decoderText:()=>x,malformedJson:()=>D,malformedJsonAck:()=>E,orderComplete:()=>T,pageView:()=>j});var j={title:"Page view",description:"A JSON-encoded page view event arrives on the subscription, decodes successfully, and is acked.",in:{id:"msg-1",dataString:JSON.stringify({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{}},out:[["message.ack","msg-1"]]},T={title:"Order complete",description:"A JSON-encoded order event arrives and is acked after successful collector forwarding.",in:{id:"msg-2",dataString:JSON.stringify({name:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}}),attributes:{entity:"order",action:"complete"}},out:[["message.ack","msg-2"]]},x={title:"Text decoder",description:"With decoder=text on the source settings, the message data is forwarded to the collector as a UTF-8 string and acked.",in:{id:"msg-3",dataString:"plain text payload",attributes:{}},out:[["message.ack","msg-3"]]},D={title:"Malformed JSON nack",description:"A non-JSON body with the default json decoder fails to decode; the message is nacked for redelivery.",in:{id:"msg-4",dataString:"not-json{",attributes:{}},out:[["message.nack","msg-4"]]},E={title:"Malformed JSON ack-and-drop",description:"With onPushError=ack on the source settings, a malformed JSON message is acked-and-dropped instead of redelivered.",in:{id:"msg-5",dataString:"not-json{",attributes:{}},out:[["message.ack","msg-5"]]};import{startFlow as C}from"@walkeros/collector";function A(e){if("object"!=typeof e||null===e)return!1;const t=e;return"pubsub-pull"===t.type&&"function"==typeof t.push}var R=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await C(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources??{}))if(A(t))return t}(t.collector);if(!r)throw new Error("pubsub-pull source not registered in collector — ensure it is configured in sources");const s={id:o.id,data:Buffer.from(o.dataString,"utf8"),attributes:o.attributes,orderingKey:o.orderingKey},i=await r.push(s),n=[];return i&&"object"==typeof i&&(i.acked&&n.push(["message.ack",o.id]),i.nacked&&n.push(["message.nack",o.id])),n}}},J={};t(J,{createTrigger:()=>_,env:()=>M,step:()=>q});var M={};t(M,{push:()=>F,simulation:()=>U});var N=()=>{},I={error:N,warn:N,info:N,debug:N,throw:e=>{throw"string"==typeof e?new Error(e):e},json:N,scope:()=>I},B=()=>()=>Promise.resolve({ok:!0}),F={get push(){return B()},get command(){return B()},get elb(){return B()},logger:I},U=[],q={};t(q,{malformedEnvelope:()=>G,orderEnvelope:()=>z,validEnvelope:()=>L});function H(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64")}var L={title:"Valid push envelope",description:"A well-formed Pub/Sub push envelope decodes the base64 data, parses JSON, and forwards the event to the collector with a 200 response.",in:{message:{messageId:"push-1",data:H({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{source:"analytics"}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-1"}]]},z={title:"Order envelope",description:"A push envelope carrying an order event is decoded and forwarded to the collector.",in:{message:{messageId:"push-2",data:H({name:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}}),attributes:{}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-2"}]]},G={title:"Malformed envelope",description:"A POST body lacking message.messageId returns 400 Bad Request without forwarding to the collector.",in:{not_a:"pubsub envelope"},out:[["response",400,{success:!1,error:"Malformed Pub/Sub envelope (missing message.messageId)."}]]};import{startFlow as K}from"@walkeros/collector";function V(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.type&&"pubsub-push"===t.type&&"function"==typeof t.push}var _=async e=>{let t;return{get flow(){return t},trigger:(o,r)=>async o=>{if(!t){const o=await K(e);t={collector:o.collector,elb:o.elb}}const s=("object"==typeof r&&null!==r?r:{}).headers??{},i=function(e){for(const t of Object.values(e.sources??{}))if(V(t))return t}(t.collector);if(!i)throw new Error("pubsub-push source not registered");const n={},a=function(e,t){return{method:"POST",body:e,headers:t,get:e=>t[e.toLowerCase()]??t[e]}}(o,s),c=function(e){const t={status:o=>(e.statusCode=o,t),json:o=>(e.body=o,t),send:o=>(e.body=o,t),set:()=>t};return t}(n);await i.push(a,c);return[["response",n.statusCode??0,n.body??null]]}}},W={};t(W,{CorsOptionsSchema:()=>ee,CorsOrigin:()=>$,HttpMethod:()=>Z,SettingsSchema:()=>te,settings:()=>oe});import{zodToSchema as Q}from"@walkeros/core/dev";import{z as X}from"@walkeros/core/dev";import{z as Y}from"@walkeros/core/dev";var Z=Y.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),$=Y.union([Y.string(),Y.array(Y.string()),Y.literal("*")]),ee=Y.object({origin:$.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:Y.array(Z).describe("Allowed HTTP methods").optional(),headers:Y.array(Y.string()).describe("Allowed request headers").optional(),credentials:Y.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:Y.number().int().positive().describe("Preflight cache duration in seconds").optional()}),te=X.object({cors:X.union([X.boolean(),ee]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").optional(),maxBatchSize:X.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),enablePixelTracking:X.boolean().describe("Serve a tracking pixel for GET requests").default(!0),timeout:X.number().int().positive().max(54e4).describe("Request timeout in milliseconds (max: 540000 for GCP)").optional()}),oe=Q(te),re={};t(re,{SettingsSchema:()=>ne,SetupSchema:()=>ce,settings:()=>le,setup:()=>de});import{zodToSchema as se}from"@walkeros/core/dev";import{z as ie}from"@walkeros/core/dev";var ne=ie.object({client:ie.any().describe("Pre-configured Google Cloud Pub/Sub client (like new PubSub({ projectId })). Bypasses credentials resolution when supplied.").optional(),projectId:ie.string().min(1).describe("Google Cloud Project ID (like my-gcp-project)."),subscription:ie.string().min(1).describe("Pub/Sub subscription short name (like events-sub). The full resource name projects/<projectId>/subscriptions/<subscription> is built by the SDK."),topic:ie.string().describe("Pub/Sub topic short name. Required when setup.createTopic is true; otherwise informational.").optional(),credentials:ie.any().describe("Service account credentials as a JSON string or an object with client_email and private_key. Default: Application Default Credentials (ADC). (deprecated: use config.credentials)").optional(),apiEndpoint:ie.string().describe("Override Pub/Sub API endpoint. Useful for the local emulator (like localhost:8085).").optional(),decoder:ie.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON, text decodes UTF-8, raw forwards the Buffer.").optional(),flowControl:ie.object({maxMessages:ie.number().describe("Maximum in-flight messages. Default: 100.").optional(),maxBytes:ie.number().describe("Maximum in-flight bytes. Default: 10485760 (10 MB).").optional()}).describe("Subscriber flow control. Tightens the SDK defaults.").optional(),ackDeadline:ie.number().describe("Subscriber ack deadline in seconds. Default: 60.").optional(),shutdownTimeoutMs:ie.number().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes the subscriber.").optional(),onPushError:ie.enum(["nack","ack"]).describe("Behavior when forwarding to the collector throws. nack (default) redelivers the message; ack drops it.").optional()});import{z as ae}from"@walkeros/core/dev";var ce=ae.object({createTopic:ae.boolean().describe("Create the topic if it does not exist. Requires settings.topic. Default: false (require pre-existing topic).").optional(),ackDeadlineSeconds:ae.number().describe("Subscription ack deadline in seconds. Default: 60.").optional(),messageRetentionDuration:ae.object({seconds:ae.number().describe("Retention window in seconds. Default: project default.")}).describe("Subscription-level retention configuration.").optional(),filter:ae.string().describe("Subscription filter expression. Only messages matching this filter are delivered.").optional(),deadLetterPolicy:ae.object({deadLetterTopic:ae.string().describe("Dead-letter topic short name."),maxDeliveryAttempts:ae.number().describe("Maximum delivery attempts before forwarding to the dead-letter topic."),createDeadLetterTopic:ae.boolean().describe("Auto-create the dead-letter topic if it does not exist. Default: false.").optional()}).describe("Dead-letter policy. Strongly recommended for production.").optional(),retryPolicy:ae.object({minimumBackoff:ae.object({seconds:ae.number().describe("Minimum backoff in seconds.")}),maximumBackoff:ae.object({seconds:ae.number().describe("Maximum backoff in seconds.")})}).describe("Subscription retry policy.").optional(),enableMessageOrdering:ae.boolean().describe("Enable message ordering on the subscription. Default: false.").optional(),labels:ae.record(ae.string(),ae.string()).describe("Subscription labels for organization and billing.").optional(),expirationPolicy:ae.object({ttl:ae.object({seconds:ae.number().describe("TTL in seconds. null means never expire.")}).nullable().optional()}).describe("Subscription expiration policy.").optional()}),le=se(ne),de=se(ce),ue={};t(ue,{SettingsSchema:()=>me,settings:()=>ge});import{zodToSchema as pe}from"@walkeros/core/dev";import{z as be}from"@walkeros/core/dev";var me=be.object({projectId:be.string().describe("Google Cloud Project ID (informational, surfaced in error messages).").optional(),decoder:be.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON, text decodes UTF-8, raw forwards the Buffer.").optional(),verifyOidc:be.boolean().describe("Verify the OIDC bearer token Pub/Sub attaches to push requests. Default: false.").optional(),audience:be.string().describe("OIDC audience (your endpoint URL or a custom audience). Required when verifyOidc is true.").optional()}),ge=pe(me),fe={sourceCloudFunction:o,sourcePubSubPull:m,sourcePubSubPush:J},he={sourceCloudFunction:{settings:oe},sourcePubSubPull:{settings:le,setup:de},sourcePubSubPush:{settings:ge}};export{o as examples,fe as exportExamples,he as exportSchemas,m as pubsubPullExamples,re as pubsubPullSchemas,J as pubsubPushExamples,ue as pubsubPushSchemas,W as schemas};//# sourceMappingURL=dev.mjs.map
1
+ import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,o=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},r={};o(r,{createTrigger:()=>m,env:()=>s,step:()=>l});var s={};o(s,{push:()=>c});var i=()=>()=>Promise.resolve({ok:!0}),n=()=>{},a={error:n,warn:n,info:n,debug:n,throw:e=>{throw"string"==typeof e?new Error(e):e},json:n,scope:()=>a},c={get push(){return i()},get command(){return i()},get elb(){return i()},logger:a},l={};o(l,{cloudFunctionPostForwardsSource:()=>p,orderEvent:()=>u,postEvent:()=>d});var d={title:"POST event",description:"A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},u={title:"Order POST",description:"A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.",trigger:{type:"POST"},in:{method:"POST",body:{name:"order complete",data:{id:"ORD-700",value:99.99,currency:"EUR"}},headers:{"content-type":"application/json"}},out:[["elb",{name:"order complete",data:{id:"ORD-700",value:99.99,currency:"EUR"}}]]},p={title:"POST with provenance",description:"A POST body carrying a source map is forwarded in full, so release and trace provenance survive the crossing.",trigger:{type:"POST"},in:{method:"POST",body:{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}},headers:{"content-type":"application/json"}},out:[["elb",{name:"page view",data:{title:"Home"},source:{release:{web:"r1"}}}]]};import{startFlow as b}from"@walkeros/collector";var m=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await b(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources||{}))if("cloudfunction"===t.type)return t}(t.collector);if(!r)throw new Error("CloudFunction source not found in collector — ensure it is configured in sources");const s={...o.body};s.name&&!s.event&&(s.event=s.name,delete s.name);const i=o.headers||{"content-type":"application/json"},n={method:o.method,body:s,headers:i,get:e=>i[e.toLowerCase()]};let a,c=200;const l={status:e=>(c=e,l),json:e=>(a=e,l),send:e=>(a=e,l),set:()=>l};return await r.push(n,l),{status:c,body:a}}}},f={};o(f,{createTrigger:()=>J,env:()=>g,step:()=>j});var g={};o(g,{moduleMockEnv:()=>k,push:()=>P,simulation:()=>O});var h=()=>{},v={error:h,warn:h,info:h,debug:h,throw:e=>{throw"string"==typeof e?new Error(e):e},json:h,scope:()=>v},w=()=>()=>Promise.resolve({ok:!0}),y=class{constructor(e,t){this.name=e,this.options=t}name;options;on(e,t){return this}async close(){}};function S(){return{get push(){return w()},get command(){return w()},get elb(){return w()},logger:v}}var P=Object.assign(S(),{PubSub:class{constructor(e){this.options=e}options;subscription(e,t){return new y(e,t)}async close(){}}}),k=S(),O=["call:PubSub.subscription"],j={};o(j,{decoderText:()=>D,malformedJson:()=>E,malformedJsonAck:()=>C,orderComplete:()=>x,pageView:()=>T});var T={title:"Page view",description:"A JSON-encoded page view event arrives on the subscription, decodes successfully, and is acked.",in:{id:"msg-1",dataString:JSON.stringify({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{}},out:[["message.ack","msg-1"]]},x={title:"Order complete",description:"A JSON-encoded order event arrives and is acked after successful collector forwarding.",in:{id:"msg-2",dataString:JSON.stringify({name:"order complete",data:{id:"ORD-500",value:199.99,currency:"EUR"}}),attributes:{entity:"order",action:"complete"}},out:[["message.ack","msg-2"]]},D={title:"Text decoder",description:"With decoder=text on the source settings, the message data is forwarded as data.payload. It has no event name, so without a before transformer that builds the event the collector rejects it and the message is acked.",in:{id:"msg-3",dataString:"plain text payload",attributes:{}},out:[["message.ack","msg-3"]]},E={title:"Malformed JSON nack",description:"A non-JSON body with the default json decoder fails to decode; the message is nacked for redelivery.",in:{id:"msg-4",dataString:"not-json{",attributes:{}},out:[["message.nack","msg-4"]]},C={title:"Malformed JSON ack-and-drop",description:"With onPushError=ack on the source settings, a malformed JSON message is acked-and-dropped instead of redelivered.",in:{id:"msg-5",dataString:"not-json{",attributes:{}},out:[["message.ack","msg-5"]]};import{startFlow as A}from"@walkeros/collector";function R(e){if("object"!=typeof e||null===e)return!1;const t=e;return"pubsub-pull"===t.type&&"function"==typeof t.push}var J=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await A(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources??{}))if(R(t))return t}(t.collector);if(!r)throw new Error("pubsub-pull source not registered in collector — ensure it is configured in sources");const s={id:o.id,data:Buffer.from(o.dataString,"utf8"),attributes:o.attributes,orderingKey:o.orderingKey},i=await r.push(s),n=[];return i&&"object"==typeof i&&(i.acked&&n.push(["message.ack",o.id]),i.nacked&&n.push(["message.nack",o.id])),n}}},M={};o(M,{createTrigger:()=>W,env:()=>I,step:()=>H});var I={};o(I,{push:()=>F,simulation:()=>q});var N=()=>{},U={error:N,warn:N,info:N,debug:N,throw:e=>{throw"string"==typeof e?new Error(e):e},json:N,scope:()=>U},B=()=>()=>Promise.resolve({ok:!0}),F={get push(){return B()},get command(){return B()},get elb(){return B()},logger:U},q=[],H={};o(H,{malformedEnvelope:()=>K,orderEnvelope:()=>G,validEnvelope:()=>z});function L(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64")}var z={title:"Valid push envelope",description:"A well-formed Pub/Sub push envelope decodes the base64 data, parses JSON, and forwards the event to the collector with a 200 response.",in:{message:{messageId:"push-1",data:L({name:"page view",data:{title:"Documentation",url:"https://example.com/docs"}}),attributes:{source:"analytics"}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-1"}]]},G={title:"Order envelope",description:"A push envelope carrying an order event is decoded and forwarded to the collector.",in:{message:{messageId:"push-2",data:L({name:"order complete",data:{id:"ORD-500",value:199.99,currency:"EUR"}}),attributes:{}},subscription:"projects/test/subscriptions/events-sub"},out:[["response",200,{success:!0,id:"push-2"}]]},K={title:"Malformed envelope",description:"A POST body lacking message.messageId returns 400 Bad Request without forwarding to the collector.",in:{not_a:"pubsub envelope"},out:[["response",400,{success:!1,error:"Malformed Pub/Sub envelope (missing message.messageId)."}]]};import{startFlow as V}from"@walkeros/collector";function _(e){if("object"!=typeof e||null===e)return!1;const t=e;return"string"==typeof t.type&&"pubsub-push"===t.type&&"function"==typeof t.push}var W=async e=>{let t;return{get flow(){return t},trigger:(o,r)=>async o=>{if(!t){const o=await V(e);t={collector:o.collector,elb:o.elb}}const s=("object"==typeof r&&null!==r?r:{}).headers??{},i=function(e){for(const t of Object.values(e.sources??{}))if(_(t))return t}(t.collector);if(!i)throw new Error("pubsub-push source not registered");const n={},a=function(e,t){return{method:"POST",body:e,headers:t,get:e=>t[e.toLowerCase()]??t[e]}}(o,s),c=function(e){const t={status:o=>(e.statusCode=o,t),json:o=>(e.body=o,t),send:o=>(e.body=o,t),set:()=>t};return t}(n);await i.push(a,c);return[["response",n.statusCode??0,n.body??null]]}}},Q={};o(Q,{CorsOptionsSchema:()=>te,CorsOrigin:()=>ee,HttpMethod:()=>$,SettingsSchema:()=>oe,settings:()=>re});import{zodToSchema as X}from"@walkeros/core/dev";import{z as Y}from"@walkeros/core/dev";import{z as Z}from"@walkeros/core/dev";var $=Z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),ee=Z.union([Z.string(),Z.array(Z.string()),Z.literal("*")]),te=Z.object({origin:ee.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:Z.array($).describe("Allowed HTTP methods").optional(),headers:Z.array(Z.string()).describe("Allowed request headers").optional(),credentials:Z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:Z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),oe=Y.object({cors:Y.union([Y.boolean(),te]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").optional(),maxBatchSize:Y.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),enablePixelTracking:Y.boolean().describe("Serve a tracking pixel for GET requests").default(!0),timeout:Y.number().int().positive().max(54e4).describe("Request timeout in milliseconds (max: 540000 for GCP)").optional()}),re=X(oe),se={};o(se,{SettingsSchema:()=>ae,SetupSchema:()=>le,settings:()=>de,setup:()=>ue});import{zodToSchema as ie}from"@walkeros/core/dev";import{z as ne}from"@walkeros/core/dev";var ae=ne.object({client:ne.any().describe("Pre-configured Google Cloud Pub/Sub client (like new PubSub({ projectId })). Bypasses credentials resolution when supplied.").optional(),projectId:ne.string().min(1).describe("Google Cloud Project ID (like my-gcp-project)."),subscription:ne.string().min(1).describe("Pub/Sub subscription short name (like events-sub). The full resource name projects/<projectId>/subscriptions/<subscription> is built by the SDK."),topic:ne.string().describe("Pub/Sub topic short name. Required when setup.createTopic is true; otherwise informational.").optional(),credentials:ne.any().describe("Service account credentials as a JSON string or an object with client_email and private_key. Default: Application Default Credentials (ADC). (deprecated: use config.credentials)").optional(),apiEndpoint:ne.string().describe("Override Pub/Sub API endpoint. Useful for the local emulator (like localhost:8085).").optional(),decoder:ne.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON; text forwards the UTF-8 string as data.payload; raw forwards the bytes base64 encoded as data.payload. text and raw events need a before transformer that sets the event name.").optional(),flowControl:ne.object({maxMessages:ne.number().describe("Maximum in-flight messages. Default: 100.").optional(),maxBytes:ne.number().describe("Maximum in-flight bytes. Default: 10485760 (10 MB).").optional()}).describe("Subscriber flow control. Tightens the SDK defaults.").optional(),ackDeadline:ne.number().describe("Subscriber ack deadline in seconds. Default: 60.").optional(),shutdownTimeoutMs:ne.number().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes the subscriber.").optional(),onPushError:ne.enum(["nack","ack"]).describe("Behavior when a message is not delivered and a redelivery could still deliver it (a retryable failure), or when decoding or forwarding throws. nack (default) redelivers the message; ack drops it.").optional()});import{z as ce}from"@walkeros/core/dev";var le=ce.object({createTopic:ce.boolean().describe("Create the topic if it does not exist. Requires settings.topic. Default: false (require pre-existing topic).").optional(),ackDeadlineSeconds:ce.number().describe("Subscription ack deadline in seconds. Unset: Pub/Sub's default (10).").optional(),messageRetentionDuration:ce.object({seconds:ce.number().describe("Retention window in seconds. Default: project default.")}).describe("Subscription-level retention configuration.").optional(),filter:ce.string().describe("Subscription filter expression. Only messages matching this filter are delivered.").optional(),deadLetterPolicy:ce.object({deadLetterTopic:ce.string().describe("Dead-letter topic short name."),maxDeliveryAttempts:ce.number().describe("Maximum delivery attempts before forwarding to the dead-letter topic."),createDeadLetterTopic:ce.boolean().describe("Auto-create the dead-letter topic if it does not exist. Default: false.").optional()}).describe("Dead-letter policy. Strongly recommended for production.").optional(),retryPolicy:ce.object({minimumBackoff:ce.object({seconds:ce.number().describe("Minimum backoff in seconds.")}),maximumBackoff:ce.object({seconds:ce.number().describe("Maximum backoff in seconds.")})}).describe("Subscription retry policy.").optional(),enableMessageOrdering:ce.boolean().describe("Enable message ordering on the subscription. Default: false.").optional(),labels:ce.record(ce.string(),ce.string()).describe("Subscription labels for organization and billing.").optional(),expirationPolicy:ce.object({ttl:ce.object({seconds:ce.number().describe("TTL in seconds. null means never expire.")}).nullable().optional()}).describe("Subscription expiration policy.").optional()}),de=ie(ae),ue=ie(le),pe={};o(pe,{SettingsSchema:()=>fe,settings:()=>ge});import{zodToSchema as be}from"@walkeros/core/dev";import{z as me}from"@walkeros/core/dev";var fe=me.object({projectId:me.string().describe("Google Cloud Project ID. Optional; the push handler does not read it.").optional(),decoder:me.enum(["json","text","raw"]).describe("Decoder for the message data field. json (default) parses JSON, text forwards the UTF-8 string, raw forwards the Buffer. text and raw values carry no event name: without a before transformer that builds the event the collector rejects them and the push answers 400.").optional(),verifyOidc:me.boolean().describe("Verify the OIDC bearer token Pub/Sub attaches to push requests. Default: false.").optional(),audience:me.string().describe("OIDC audience (your endpoint URL or a custom audience). Required when verifyOidc is true.").optional()}),ge=be(fe),he={sourceCloudFunction:r,sourcePubSubPull:f,sourcePubSubPush:M},ve={sourceCloudFunction:{settings:re},sourcePubSubPull:{settings:de,setup:ue},sourcePubSubPush:{settings:ge}};export{r as examples,he as exportExamples,ve as exportSchemas,f as pubsubPullExamples,se as pubsubPullSchemas,M as pubsubPushExamples,pe as pubsubPushSchemas,Q as schemas};//# sourceMappingURL=dev.mjs.map