@walkeros/server-source-gcp 4.7.0-next-1790245733116 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _walkeros_core_dev from '@walkeros/core/dev';
2
2
  import { z } from '@walkeros/core/dev';
3
3
  import { Source, Flow, Trigger } from '@walkeros/core';
4
- import { PubSub } from '@google-cloud/pubsub';
4
+ import { ClientConfig, SubscriptionOptions, Message } from '@google-cloud/pubsub';
5
5
 
6
6
  /**
7
7
  * HTTP methods enum
@@ -71,12 +71,12 @@ type Settings$2 = z.infer<typeof SettingsSchema$2>;
71
71
 
72
72
  declare const settings$2: _walkeros_core_dev.JSONSchema;
73
73
 
74
- type index$5_CorsOptions = CorsOptions;
75
- declare const index$5_CorsOptionsSchema: typeof CorsOptionsSchema;
76
- declare const index$5_CorsOrigin: typeof CorsOrigin;
77
- declare const index$5_HttpMethod: typeof HttpMethod;
78
- declare namespace index$5 {
79
- export { type index$5_CorsOptions as CorsOptions, index$5_CorsOptionsSchema as CorsOptionsSchema, index$5_CorsOrigin as CorsOrigin, index$5_HttpMethod as HttpMethod, type Settings$2 as Settings, SettingsSchema$2 as SettingsSchema, settings$2 as settings };
74
+ type index$2_CorsOptions = CorsOptions;
75
+ declare const index$2_CorsOptionsSchema: typeof CorsOptionsSchema;
76
+ declare const index$2_CorsOrigin: typeof CorsOrigin;
77
+ declare const index$2_HttpMethod: typeof HttpMethod;
78
+ declare namespace index$2 {
79
+ export { type index$2_CorsOptions as CorsOptions, index$2_CorsOptionsSchema as CorsOptionsSchema, index$2_CorsOrigin as CorsOrigin, index$2_HttpMethod as HttpMethod, type Settings$2 as Settings, SettingsSchema$2 as SettingsSchema, settings$2 as settings };
80
80
  }
81
81
 
82
82
  declare module '@walkeros/core' {
@@ -151,88 +151,10 @@ interface Result$2 {
151
151
  */
152
152
  declare const createTrigger$2: Trigger.CreateFn<Content$2, Result$2>;
153
153
 
154
- declare namespace index$4 {
154
+ declare namespace cloudFunctionExamplesNs {
155
155
  export { createTrigger$2 as createTrigger, env$2 as env, step$2 as step };
156
156
  }
157
157
 
158
- /**
159
- * GCP Pub/Sub pull source settings schema.
160
- *
161
- * Required: projectId, subscription. All other fields optional with sensible
162
- * defaults applied at runtime by `getConfig`.
163
- */
164
- declare const SettingsSchema$1: z.ZodObject<{
165
- client: z.ZodOptional<z.ZodAny>;
166
- projectId: z.ZodString;
167
- subscription: z.ZodString;
168
- topic: z.ZodOptional<z.ZodString>;
169
- credentials: z.ZodOptional<z.ZodAny>;
170
- apiEndpoint: z.ZodOptional<z.ZodString>;
171
- decoder: z.ZodOptional<z.ZodEnum<{
172
- json: "json";
173
- text: "text";
174
- raw: "raw";
175
- }>>;
176
- flowControl: z.ZodOptional<z.ZodObject<{
177
- maxMessages: z.ZodOptional<z.ZodNumber>;
178
- maxBytes: z.ZodOptional<z.ZodNumber>;
179
- }, z.core.$strip>>;
180
- ackDeadline: z.ZodOptional<z.ZodNumber>;
181
- shutdownTimeoutMs: z.ZodOptional<z.ZodNumber>;
182
- onPushError: z.ZodOptional<z.ZodEnum<{
183
- nack: "nack";
184
- ack: "ack";
185
- }>>;
186
- }, z.core.$strip>;
187
- type Settings$1 = z.infer<typeof SettingsSchema$1>;
188
-
189
- /**
190
- * GCP Pub/Sub pull source setup schema.
191
- *
192
- * Provisioning options for `walkeros setup source.<id>`. Idempotent
193
- * subscription creation, plus optional topic and dead-letter topic
194
- * auto-create. Triggered only by the explicit CLI command.
195
- */
196
- declare const SetupSchema: z.ZodObject<{
197
- createTopic: z.ZodOptional<z.ZodBoolean>;
198
- ackDeadlineSeconds: z.ZodOptional<z.ZodNumber>;
199
- messageRetentionDuration: z.ZodOptional<z.ZodObject<{
200
- seconds: z.ZodNumber;
201
- }, z.core.$strip>>;
202
- filter: z.ZodOptional<z.ZodString>;
203
- deadLetterPolicy: z.ZodOptional<z.ZodObject<{
204
- deadLetterTopic: z.ZodString;
205
- maxDeliveryAttempts: z.ZodNumber;
206
- createDeadLetterTopic: z.ZodOptional<z.ZodBoolean>;
207
- }, z.core.$strip>>;
208
- retryPolicy: z.ZodOptional<z.ZodObject<{
209
- minimumBackoff: z.ZodObject<{
210
- seconds: z.ZodNumber;
211
- }, z.core.$strip>;
212
- maximumBackoff: z.ZodObject<{
213
- seconds: z.ZodNumber;
214
- }, z.core.$strip>;
215
- }, z.core.$strip>>;
216
- enableMessageOrdering: z.ZodOptional<z.ZodBoolean>;
217
- labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
218
- expirationPolicy: z.ZodOptional<z.ZodObject<{
219
- ttl: z.ZodOptional<z.ZodNullable<z.ZodObject<{
220
- seconds: z.ZodNumber;
221
- }, z.core.$strip>>>;
222
- }, z.core.$strip>>;
223
- }, z.core.$strip>;
224
- type Setup = z.infer<typeof SetupSchema>;
225
-
226
- declare const settings$1: _walkeros_core_dev.JSONSchema;
227
- declare const setup: _walkeros_core_dev.JSONSchema;
228
-
229
- type index$3_Setup = Setup;
230
- declare const index$3_SetupSchema: typeof SetupSchema;
231
- declare const index$3_setup: typeof setup;
232
- declare namespace index$3 {
233
- export { type Settings$1 as Settings, SettingsSchema$1 as SettingsSchema, type index$3_Setup as Setup, index$3_SetupSchema as SetupSchema, settings$1 as settings, index$3_setup as setup };
234
- }
235
-
236
158
  declare module '@walkeros/core' {
237
159
  interface SourceMap {
238
160
  'pubsub-pull': {
@@ -241,21 +163,42 @@ declare module '@walkeros/core' {
241
163
  };
242
164
  }
243
165
  }
166
+ /** The part of a Pub/Sub subscription the pull source drives. */
167
+ interface PullSubscription {
168
+ on(event: 'message', listener: (message: Message) => void): unknown;
169
+ on(event: 'error', listener: (error: Error) => void): unknown;
170
+ close(): Promise<void>;
171
+ }
172
+ /**
173
+ * The part of a Pub/Sub client the pull source calls at runtime. `PubSub` from
174
+ * `@google-cloud/pubsub` satisfies it, and so does an injected mock (tests,
175
+ * simulate) without a cast. Setup needs a `PubSubAdminClient`.
176
+ */
177
+ interface PubSubPullClient {
178
+ subscription(name: string, options?: SubscriptionOptions): PullSubscription;
179
+ close(): Promise<void>;
180
+ }
244
181
  interface Env$1 extends Source.Env {
245
- PubSub?: typeof PubSub;
182
+ PubSub?: new (options?: ClientConfig) => PubSubPullClient;
246
183
  }
247
184
 
185
+ /** Standard mock environment, with the structural client for simulate. */
186
+ declare const push$1: Env$1;
248
187
  /**
249
- * Standard mock environment for the pull source.
250
- *
251
- * `PubSub` is intentionally absent: the canonical pattern is module-level
252
- * `jest.mock('@google-cloud/pubsub')`, not env-injection.
188
+ * The same environment without the client, for unit tests that substitute the
189
+ * SDK module-wide with `jest.mock`.
190
+ */
191
+ declare const moduleMockEnv: Env$1;
192
+ /**
193
+ * The subscription call binds the source to its subscription; messages then
194
+ * arrive as events, not calls. Construction is not recorded: its options
195
+ * carry credentials.
253
196
  */
254
- declare const push$1: Env$1;
255
197
  declare const simulation$1: string[];
256
198
 
199
+ declare const env$1_moduleMockEnv: typeof moduleMockEnv;
257
200
  declare namespace env$1 {
258
- export { push$1 as push, simulation$1 as simulation };
201
+ export { env$1_moduleMockEnv as moduleMockEnv, push$1 as push, simulation$1 as simulation };
259
202
  }
260
203
 
261
204
  declare const pageView: Flow.StepExample;
@@ -309,38 +252,10 @@ type Result$1 = Array<[string, ...unknown[]]>;
309
252
  */
310
253
  declare const createTrigger$1: Trigger.CreateFn<Content$1, Result$1>;
311
254
 
312
- declare namespace index$2 {
255
+ declare namespace pubsubPullExamplesNs {
313
256
  export { type Content$1 as Content, type Result$1 as Result, createTrigger$1 as createTrigger, env$1 as env, step$1 as step };
314
257
  }
315
258
 
316
- /**
317
- * GCP Pub/Sub push source settings schema.
318
- *
319
- * No required fields. The push source is a request-handler; configuration
320
- * tunables live here, but operators wire `source.push` into their own
321
- * express/lambda runtime.
322
- */
323
- declare const SettingsSchema: z.ZodObject<{
324
- projectId: z.ZodOptional<z.ZodString>;
325
- decoder: z.ZodOptional<z.ZodEnum<{
326
- json: "json";
327
- text: "text";
328
- raw: "raw";
329
- }>>;
330
- verifyOidc: z.ZodOptional<z.ZodBoolean>;
331
- audience: z.ZodOptional<z.ZodString>;
332
- }, z.core.$strip>;
333
- type Settings = z.infer<typeof SettingsSchema>;
334
-
335
- declare const settings: _walkeros_core_dev.JSONSchema;
336
-
337
- type index$1_Settings = Settings;
338
- declare const index$1_SettingsSchema: typeof SettingsSchema;
339
- declare const index$1_settings: typeof settings;
340
- declare namespace index$1 {
341
- export { type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
342
- }
343
-
344
259
  declare module '@walkeros/core' {
345
260
  interface SourceMap {
346
261
  'pubsub-push': {
@@ -409,13 +324,139 @@ type Result = Array<[string, ...unknown[]]>;
409
324
  */
410
325
  declare const createTrigger: Trigger.CreateFn<Content, Result>;
411
326
 
412
- type index_Content = Content;
413
- type index_Result = Result;
414
- declare const index_createTrigger: typeof createTrigger;
415
- declare const index_env: typeof env;
416
- declare const index_step: typeof step;
327
+ type pubsubPushExamplesNs_Content = Content;
328
+ type pubsubPushExamplesNs_Result = Result;
329
+ declare const pubsubPushExamplesNs_createTrigger: typeof createTrigger;
330
+ declare const pubsubPushExamplesNs_env: typeof env;
331
+ declare const pubsubPushExamplesNs_step: typeof step;
332
+ declare namespace pubsubPushExamplesNs {
333
+ export { type pubsubPushExamplesNs_Content as Content, type pubsubPushExamplesNs_Result as Result, pubsubPushExamplesNs_createTrigger as createTrigger, pubsubPushExamplesNs_env as env, pubsubPushExamplesNs_step as step };
334
+ }
335
+
336
+ /**
337
+ * GCP Pub/Sub pull source settings schema.
338
+ *
339
+ * Required: projectId, subscription. All other fields optional with sensible
340
+ * defaults applied at runtime by `getConfig`.
341
+ */
342
+ declare const SettingsSchema$1: z.ZodObject<{
343
+ client: z.ZodOptional<z.ZodAny>;
344
+ projectId: z.ZodString;
345
+ subscription: z.ZodString;
346
+ topic: z.ZodOptional<z.ZodString>;
347
+ credentials: z.ZodOptional<z.ZodAny>;
348
+ apiEndpoint: z.ZodOptional<z.ZodString>;
349
+ decoder: z.ZodOptional<z.ZodEnum<{
350
+ json: "json";
351
+ text: "text";
352
+ raw: "raw";
353
+ }>>;
354
+ flowControl: z.ZodOptional<z.ZodObject<{
355
+ maxMessages: z.ZodOptional<z.ZodNumber>;
356
+ maxBytes: z.ZodOptional<z.ZodNumber>;
357
+ }, z.core.$strip>>;
358
+ ackDeadline: z.ZodOptional<z.ZodNumber>;
359
+ shutdownTimeoutMs: z.ZodOptional<z.ZodNumber>;
360
+ onPushError: z.ZodOptional<z.ZodEnum<{
361
+ nack: "nack";
362
+ ack: "ack";
363
+ }>>;
364
+ }, z.core.$strip>;
365
+ type Settings$1 = z.infer<typeof SettingsSchema$1>;
366
+
367
+ /**
368
+ * GCP Pub/Sub pull source setup schema.
369
+ *
370
+ * Provisioning options for `walkeros setup source.<id>`. Idempotent
371
+ * subscription creation, plus optional topic and dead-letter topic
372
+ * auto-create. Triggered only by the explicit CLI command.
373
+ */
374
+ declare const SetupSchema: z.ZodObject<{
375
+ createTopic: z.ZodOptional<z.ZodBoolean>;
376
+ ackDeadlineSeconds: z.ZodOptional<z.ZodNumber>;
377
+ messageRetentionDuration: z.ZodOptional<z.ZodObject<{
378
+ seconds: z.ZodNumber;
379
+ }, z.core.$strip>>;
380
+ filter: z.ZodOptional<z.ZodString>;
381
+ deadLetterPolicy: z.ZodOptional<z.ZodObject<{
382
+ deadLetterTopic: z.ZodString;
383
+ maxDeliveryAttempts: z.ZodNumber;
384
+ createDeadLetterTopic: z.ZodOptional<z.ZodBoolean>;
385
+ }, z.core.$strip>>;
386
+ retryPolicy: z.ZodOptional<z.ZodObject<{
387
+ minimumBackoff: z.ZodObject<{
388
+ seconds: z.ZodNumber;
389
+ }, z.core.$strip>;
390
+ maximumBackoff: z.ZodObject<{
391
+ seconds: z.ZodNumber;
392
+ }, z.core.$strip>;
393
+ }, z.core.$strip>>;
394
+ enableMessageOrdering: z.ZodOptional<z.ZodBoolean>;
395
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
396
+ expirationPolicy: z.ZodOptional<z.ZodObject<{
397
+ ttl: z.ZodOptional<z.ZodNullable<z.ZodObject<{
398
+ seconds: z.ZodNumber;
399
+ }, z.core.$strip>>>;
400
+ }, z.core.$strip>>;
401
+ }, z.core.$strip>;
402
+ type Setup = z.infer<typeof SetupSchema>;
403
+
404
+ declare const settings$1: _walkeros_core_dev.JSONSchema;
405
+ declare const setup: _walkeros_core_dev.JSONSchema;
406
+
407
+ type index$1_Setup = Setup;
408
+ declare const index$1_SetupSchema: typeof SetupSchema;
409
+ declare const index$1_setup: typeof setup;
410
+ declare namespace index$1 {
411
+ export { type Settings$1 as Settings, SettingsSchema$1 as SettingsSchema, type index$1_Setup as Setup, index$1_SetupSchema as SetupSchema, settings$1 as settings, index$1_setup as setup };
412
+ }
413
+
414
+ /**
415
+ * GCP Pub/Sub push source settings schema.
416
+ *
417
+ * No required fields. The push source is a request-handler; configuration
418
+ * tunables live here, but operators wire `source.push` into their own
419
+ * express/lambda runtime.
420
+ */
421
+ declare const SettingsSchema: z.ZodObject<{
422
+ projectId: z.ZodOptional<z.ZodString>;
423
+ decoder: z.ZodOptional<z.ZodEnum<{
424
+ json: "json";
425
+ text: "text";
426
+ raw: "raw";
427
+ }>>;
428
+ verifyOidc: z.ZodOptional<z.ZodBoolean>;
429
+ audience: z.ZodOptional<z.ZodString>;
430
+ }, z.core.$strip>;
431
+ type Settings = z.infer<typeof SettingsSchema>;
432
+
433
+ declare const settings: _walkeros_core_dev.JSONSchema;
434
+
435
+ type index_Settings = Settings;
436
+ declare const index_SettingsSchema: typeof SettingsSchema;
437
+ declare const index_settings: typeof settings;
417
438
  declare namespace index {
418
- export { type index_Content as Content, type index_Result as Result, index_createTrigger as createTrigger, index_env as env, index_step as step };
439
+ export { type index_Settings as Settings, index_SettingsSchema as SettingsSchema, index_settings as settings };
419
440
  }
420
441
 
421
- export { index$4 as examples, index$2 as pubsubPullExamples, index$3 as pubsubPullSchemas, index as pubsubPushExamples, index$1 as pubsubPushSchemas, index$5 as schemas };
442
+ /** Dev examples per export, keyed by the export names in package.json. */
443
+ declare const exportExamples: {
444
+ sourceCloudFunction: typeof cloudFunctionExamplesNs;
445
+ sourcePubSubPull: typeof pubsubPullExamplesNs;
446
+ sourcePubSubPush: typeof pubsubPushExamplesNs;
447
+ };
448
+ /** Schemas per export, keyed by the export names in package.json. */
449
+ declare const exportSchemas: {
450
+ sourceCloudFunction: {
451
+ settings: _walkeros_core_dev.JSONSchema;
452
+ };
453
+ sourcePubSubPull: {
454
+ settings: _walkeros_core_dev.JSONSchema;
455
+ setup: _walkeros_core_dev.JSONSchema;
456
+ };
457
+ sourcePubSubPush: {
458
+ settings: _walkeros_core_dev.JSONSchema;
459
+ };
460
+ };
461
+
462
+ export { cloudFunctionExamplesNs as examples, exportExamples, exportSchemas, pubsubPullExamplesNs as pubsubPullExamples, index$1 as pubsubPullSchemas, pubsubPushExamplesNs as pubsubPushExamples, index as pubsubPushSchemas, index$2 as schemas };
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:()=>f,pubsubPullExamples:()=>M,pubsubPullSchemas:()=>x,pubsubPushExamples:()=>re,pubsubPushSchemas:()=>Z,schemas:()=>a}),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,{CorsOptionsSchema:()=>b,CorsOrigin:()=>p,HttpMethod:()=>u,SettingsSchema:()=>m,settings:()=>g});var c=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),u=d.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),p=d.z.union([d.z.string(),d.z.array(d.z.string()),d.z.literal("*")]),b=d.z.object({origin:p.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:d.z.array(u).describe("Allowed HTTP methods").optional(),headers:d.z.array(d.z.string()).describe("Allowed request headers").optional(),credentials:d.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:d.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),m=l.z.object({cors:l.z.union([l.z.boolean(),b]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").optional(),maxBatchSize:l.z.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),enablePixelTracking:l.z.boolean().describe("Serve a tracking pixel for GET requests").default(!0),timeout:l.z.number().int().positive().max(54e4).describe("Request timeout in milliseconds (max: 540000 for GCP)").optional()}),g=(0,c.zodToSchema)(m),f={};i(f,{createTrigger:()=>T,env:()=>h,step:()=>z});var h={};i(h,{push:()=>S});var w=()=>()=>Promise.resolve({ok:!0}),y=()=>{},v={error:y,warn:y,info:y,debug:y,throw:e=>{throw"string"==typeof e?new Error(e):e},json:y,scope:()=>v},S={get push(){return w()},get command(){return w()},get elb(){return w()},logger:v},z={};i(z,{cloudFunctionPostForwardsSource:()=>P,orderEvent:()=>k,postEvent:()=>O});var O={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/"}}]]},k={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"}}]]},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"}}}]]},j=require("@walkeros/collector");var T=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await(0,j.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}}}},x={};i(x,{SettingsSchema:()=>A,SetupSchema:()=>q,settings:()=>R,setup:()=>J});var D=require("@walkeros/core/dev"),E=require("@walkeros/core/dev"),A=E.z.object({client:E.z.any().describe("Pre-configured Google Cloud Pub/Sub client (like new PubSub({ projectId })). Bypasses credentials resolution when supplied.").optional(),projectId:E.z.string().min(1).describe("Google Cloud Project ID (like my-gcp-project)."),subscription:E.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:E.z.string().describe("Pub/Sub topic short name. Required when setup.createTopic is true; otherwise informational.").optional(),credentials:E.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:E.z.string().describe("Override Pub/Sub API endpoint. Useful for the local emulator (like localhost:8085).").optional(),decoder:E.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:E.z.object({maxMessages:E.z.number().describe("Maximum in-flight messages. Default: 100.").optional(),maxBytes:E.z.number().describe("Maximum in-flight bytes. Default: 10485760 (10 MB).").optional()}).describe("Subscriber flow control. Tightens the SDK defaults.").optional(),ackDeadline:E.z.number().describe("Subscriber ack deadline in seconds. Default: 60.").optional(),shutdownTimeoutMs:E.z.number().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes the subscriber.").optional(),onPushError:E.z.enum(["nack","ack"]).describe("Behavior when forwarding to the collector throws. nack (default) redelivers the message; ack drops it.").optional()}),C=require("@walkeros/core/dev"),q=C.z.object({createTopic:C.z.boolean().describe("Create the topic if it does not exist. Requires settings.topic. Default: false (require pre-existing topic).").optional(),ackDeadlineSeconds:C.z.number().describe("Subscription ack deadline in seconds. Default: 60.").optional(),messageRetentionDuration:C.z.object({seconds:C.z.number().describe("Retention window in seconds. Default: project default.")}).describe("Subscription-level retention configuration.").optional(),filter:C.z.string().describe("Subscription filter expression. Only messages matching this filter are delivered.").optional(),deadLetterPolicy:C.z.object({deadLetterTopic:C.z.string().describe("Dead-letter topic short name."),maxDeliveryAttempts:C.z.number().describe("Maximum delivery attempts before forwarding to the dead-letter topic."),createDeadLetterTopic:C.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:C.z.object({minimumBackoff:C.z.object({seconds:C.z.number().describe("Minimum backoff in seconds.")}),maximumBackoff:C.z.object({seconds:C.z.number().describe("Maximum backoff in seconds.")})}).describe("Subscription retry policy.").optional(),enableMessageOrdering:C.z.boolean().describe("Enable message ordering on the subscription. Default: false.").optional(),labels:C.z.record(C.z.string(),C.z.string()).describe("Subscription labels for organization and billing.").optional(),expirationPolicy:C.z.object({ttl:C.z.object({seconds:C.z.number().describe("TTL in seconds. null means never expire.")}).nullable().optional()}).describe("Subscription expiration policy.").optional()}),R=(0,D.zodToSchema)(A),J=(0,D.zodToSchema)(q),M={};i(M,{createTrigger:()=>Y,env:()=>N,step:()=>L});var N={};i(N,{push:()=>F,simulation:()=>H});var I=()=>{},B={error:I,warn:I,info:I,debug:I,throw:e=>{throw"string"==typeof e?new Error(e):e},json:I,scope:()=>B},U=()=>()=>Promise.resolve({ok:!0}),F={get push(){return U()},get command(){return U()},get elb(){return U()},logger:B},H=["PubSub"],L={};i(L,{decoderText:()=>K,malformedJson:()=>V,malformedJsonAck:()=>W,orderComplete:()=>_,pageView:()=>G});var G={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"]]},_={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"]]},K={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"]]},V={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"]]},W={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"]]},Q=require("@walkeros/collector");function X(e){if("object"!=typeof e||null===e)return!1;const t=e;return"pubsub-pull"===t.type&&"function"==typeof t.push}var Y=async e=>{let t;return{get flow(){return t},trigger:()=>async o=>{if(!t){const o=await(0,Q.startFlow)(e);t={collector:o.collector,elb:o.elb}}const r=function(e){for(const t of Object.values(e.sources??{}))if(X(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}}},Z={};i(Z,{SettingsSchema:()=>te,settings:()=>oe});var $=require("@walkeros/core/dev"),ee=require("@walkeros/core/dev"),te=ee.z.object({projectId:ee.z.string().describe("Google Cloud Project ID (informational, surfaced in error messages).").optional(),decoder:ee.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:ee.z.boolean().describe("Verify the OIDC bearer token Pub/Sub attaches to push requests. Default: false.").optional(),audience:ee.z.string().describe("OIDC audience (your endpoint URL or a custom audience). Required when verifyOidc is true.").optional()}),oe=(0,$.zodToSchema)(te),re={};i(re,{createTrigger:()=>he,env:()=>se,step:()=>de});var se={};i(se,{push:()=>ce,simulation:()=>le});var ie=()=>{},ne={error:ie,warn:ie,info:ie,debug:ie,throw:e=>{throw"string"==typeof e?new Error(e):e},json:ie,scope:()=>ne},ae=()=>()=>Promise.resolve({ok:!0}),ce={get push(){return ae()},get command(){return ae()},get elb(){return ae()},logger:ne},le=[],de={};i(de,{malformedEnvelope:()=>me,orderEnvelope:()=>be,validEnvelope:()=>pe});function ue(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64")}var pe={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:ue({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"}]]},be={title:"Order envelope",description:"A push envelope carrying an order event is decoded and forwarded to the collector.",in:{message:{messageId:"push-2",data:ue({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"}]]},me={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)."}]]},ge=require("@walkeros/collector");function fe(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 he=async e=>{let t;return{get flow(){return t},trigger:(o,r)=>async o=>{if(!t){const o=await(0,ge.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(fe(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]]}}};//# sourceMappingURL=dev.js.map
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