@walkeros/cli 3.1.1 → 3.2.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.
@@ -135,8 +135,9 @@ export META_PIXEL_ID="123456789"
135
135
  walkeros bundle examples/web-tracking.json --stats
136
136
 
137
137
  # Simulate events
138
- walkeros simulate examples/web-tracking.json \
139
- --event '{"name":"product view","data":{"id":"P123","name":"Laptop","price":999}}'
138
+ walkeros push examples/web-tracking.json \
139
+ --event '{"name":"product view","data":{"id":"P123","name":"Laptop","price":999}}' \
140
+ --simulate destination.demo
140
141
  ```
141
142
 
142
143
  ## Server Examples
@@ -382,7 +383,7 @@ The event name is parsed as: `const [entity, action] = event.split(' ')`
382
383
 
383
384
  ## Next Steps
384
385
 
385
- 1. Try each example with `walkeros bundle` and `walkeros simulate`
386
+ 1. Try each example with `walkeros bundle` and `walkeros push --simulate`
386
387
  2. Modify examples to match your tracking requirements
387
388
  3. Create custom flow files for your use case
388
389
  4. Deploy to production
@@ -540,9 +540,6 @@
540
540
  "@walkeros/destination-demo": {},
541
541
  "@walkeros/transformer-validator": {},
542
542
  "@walkeros/server-transformer-fingerprint": {},
543
- "@walkeros/server-transformer-cache": {
544
- "path": "../../server/transformers/cache"
545
- },
546
543
  "@walkeros/store-memory": {
547
544
  "path": "../../stores/memory"
548
545
  }
@@ -562,6 +559,23 @@
562
559
  "http": {
563
560
  "package": "@walkeros/server-source-express",
564
561
  "primary": true,
562
+ "cache": {
563
+ "store": "cache",
564
+ "rules": [
565
+ {
566
+ "match": {
567
+ "key": "ingest.method",
568
+ "operator": "eq",
569
+ "value": "GET"
570
+ },
571
+ "key": ["ingest.method", "ingest.path"],
572
+ "ttl": 300,
573
+ "update": {
574
+ "headers.X-Cache": { "key": "cache.status" }
575
+ }
576
+ }
577
+ ]
578
+ },
565
579
  "config": {
566
580
  "settings": {
567
581
  "path": "/collect",
@@ -598,26 +612,6 @@
598
612
  }
599
613
  },
600
614
  "transformers": {
601
- "cache": {
602
- "package": "@walkeros/server-transformer-cache",
603
- "next": "filter",
604
- "config": {
605
- "settings": {
606
- "rules": [
607
- {
608
- "match": {
609
- "key": "method",
610
- "operator": "equals",
611
- "value": "GET"
612
- },
613
- "key": ["method", "path"],
614
- "ttl": 300
615
- }
616
- ]
617
- }
618
- },
619
- "env": { "store": "$store:cache" }
620
- },
621
615
  "filter": {
622
616
  "code": {
623
617
  "type": "filter",
@@ -682,7 +676,7 @@
682
676
  "destinations": {
683
677
  "meta": {
684
678
  "package": "@walkeros/server-destination-meta",
685
- "before": "cache",
679
+ "before": "fingerprint",
686
680
  "config": {
687
681
  "settings": {
688
682
  "pixelId": "$var.metaPixelId",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "destinations": {
16
16
  "demo": {
17
- "code": "destinationDemo",
17
+ "package": "@walkeros/destination-demo",
18
18
  "config": {
19
19
  "consent": {
20
20
  "marketing": true
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "destinations": {
16
16
  "demo": {
17
- "code": "destinationDemo",
17
+ "package": "@walkeros/destination-demo",
18
18
  "config": {
19
19
  "settings": {
20
20
  "name": "Simple Demo",
package/dist/index.d.ts CHANGED
@@ -97,6 +97,12 @@ interface BuildOptions extends CLIBuildOptions {
97
97
  * @default "elb"
98
98
  */
99
99
  windowElb?: string;
100
+ /**
101
+ * Skip platform wrapper (Step 2) and output raw ESM.
102
+ * Used by CLI push for direct import of the bundled module.
103
+ * @default false
104
+ */
105
+ skipWrapper?: boolean;
100
106
  /**
101
107
  * Folders to include in the output directory.
102
108
  * These folders are copied alongside the bundle for runtime access.
@@ -218,66 +224,6 @@ declare function bundleRemote(options: {
218
224
  stats: any;
219
225
  }>;
220
226
 
221
- /** Tracked API call from destination simulation */
222
- interface ApiCall {
223
- type: 'call';
224
- path: string;
225
- args: unknown[];
226
- timestamp: number;
227
- }
228
- interface SimulateCommandOptions {
229
- config?: string;
230
- output?: string;
231
- event?: string;
232
- flow?: string;
233
- json?: boolean;
234
- verbose?: boolean;
235
- silent?: boolean;
236
- platform?: 'web' | 'server';
237
- step?: string;
238
- }
239
- interface SimulationResult {
240
- success: boolean;
241
- error?: string;
242
- collector?: unknown;
243
- elbResult?: Elb.PushResult;
244
- logs?: unknown[];
245
- usage?: Record<string, ApiCall[]>;
246
- duration?: number;
247
- /** Events captured by source simulation */
248
- capturedEvents?: WalkerOS.DeepPartialEvent[];
249
- }
250
-
251
- /**
252
- * Simulate Command Schemas
253
- *
254
- * Zod schemas for simulate command parameter validation.
255
- */
256
-
257
- /**
258
- * Platform schema.
259
- *
260
- * @remarks
261
- * Validates platform type for event simulation.
262
- */
263
- declare const PlatformSchema: z.ZodEnum<{
264
- web: "web";
265
- server: "server";
266
- }>;
267
- type Platform$1 = z.infer<typeof PlatformSchema>;
268
- /**
269
- * Simulate options schema.
270
- *
271
- * @remarks
272
- * Options for the programmatic simulate() API.
273
- */
274
- declare const SimulateOptionsSchema: z.ZodObject<{
275
- silent: z.ZodOptional<z.ZodBoolean>;
276
- verbose: z.ZodOptional<z.ZodBoolean>;
277
- json: z.ZodOptional<z.ZodBoolean>;
278
- }, z.core.$strip>;
279
- type SimulateOptions = z.infer<typeof SimulateOptionsSchema>;
280
-
281
227
  /**
282
228
  * Input Detector
283
229
  *
@@ -321,57 +267,15 @@ interface SSEParseResult {
321
267
  }
322
268
  declare function parseSSEEvents(buffer: string): SSEParseResult;
323
269
 
324
- type StepType = 'source' | 'transformer' | 'destination';
325
- interface ExampleLookupResult {
326
- stepType: StepType;
327
- stepName: string;
328
- exampleName: string;
329
- example: {
330
- in?: unknown;
331
- mapping?: unknown;
332
- out?: unknown;
333
- };
270
+ /** Captured network call from polyfilled fetch/sendBeacon during simulation */
271
+ interface NetworkCall {
272
+ type: 'fetch' | 'beacon';
273
+ url: string;
274
+ method?: string;
275
+ body?: string | null;
276
+ headers?: Record<string, string>;
277
+ timestamp: number;
334
278
  }
335
- /**
336
- * Find a named example in a flow config.
337
- *
338
- * Searches sources, transformers, and destinations for a matching example.
339
- * If --step is provided (e.g. "destination.gtag"), looks only in that step.
340
- * If not, searches all steps and errors if ambiguous.
341
- *
342
- * @param config - Raw (unresolved) flow config with examples intact
343
- * @param exampleName - Name of the example to find
344
- * @param stepTarget - Optional step target in "type.name" format
345
- * @returns The found example with its location
346
- */
347
- declare function findExample(config: Flow.Settings, exampleName: string, stepTarget?: string): ExampleLookupResult;
348
-
349
- /**
350
- * Compare simulation output against expected example output.
351
- */
352
- declare function compareOutput(expected: unknown, actual: unknown): {
353
- expected: unknown;
354
- actual: unknown;
355
- match: boolean;
356
- diff?: string;
357
- };
358
-
359
- /**
360
- * CLI command handler for simulate command
361
- */
362
- declare function simulateCommand(options: SimulateCommandOptions): Promise<void>;
363
- /**
364
- * High-level simulate function for programmatic usage.
365
- *
366
- * For destinations/transformers: event is a walkerOS event { name, data }.
367
- * For sources (--step source.*): event is a SourceInput { content, trigger?, env? }.
368
- */
369
- declare function simulate(configOrPath: string | unknown, event: unknown, options?: SimulateOptions & {
370
- flow?: string;
371
- platform?: Platform$1;
372
- step?: string;
373
- }): Promise<SimulationResult>;
374
-
375
279
  /**
376
280
  * Push command options
377
281
  */
@@ -384,6 +288,9 @@ interface PushCommandOptions {
384
288
  verbose?: boolean;
385
289
  silent?: boolean;
386
290
  platform?: 'web' | 'server';
291
+ simulate?: string[];
292
+ mock?: string[];
293
+ snapshot?: string;
387
294
  }
388
295
  /**
389
296
  * Push execution result
@@ -391,6 +298,18 @@ interface PushCommandOptions {
391
298
  interface PushResult {
392
299
  success: boolean;
393
300
  elbResult?: Elb.PushResult;
301
+ captured?: Array<{
302
+ event: unknown;
303
+ timestamp: number;
304
+ }>;
305
+ /** Tracked destination API calls keyed by destination ID */
306
+ usage?: Record<string, Array<{
307
+ fn: string;
308
+ args: unknown[];
309
+ ts: number;
310
+ }>>;
311
+ /** Network calls captured during web simulation (fetch + sendBeacon) */
312
+ networkCalls?: NetworkCall[];
394
313
  duration: number;
395
314
  error?: string;
396
315
  }
@@ -443,7 +362,64 @@ declare function pushCommand(options: PushCommandOptions): Promise<void>;
443
362
  declare function push(configOrPath: string | unknown, event: unknown, options?: PushOptions & {
444
363
  flow?: string;
445
364
  platform?: Platform;
365
+ mock?: string[];
366
+ snapshot?: string;
446
367
  }): Promise<PushResult>;
368
+ interface SimulateSourceOptions {
369
+ sourceId: string;
370
+ flow?: string;
371
+ silent?: boolean;
372
+ verbose?: boolean;
373
+ snapshot?: string;
374
+ }
375
+ /**
376
+ * Self-contained source simulation.
377
+ *
378
+ * Loads the flow config, bundles it, resolves the source package's /dev export
379
+ * to get createTrigger, then invokes the trigger inside a flow context with a
380
+ * prePush hook that captures events before they reach destinations.
381
+ *
382
+ * The `input` parameter is `unknown` — the CLI is agnostic to source-specific
383
+ * content shapes. The source's createTrigger defines what it expects.
384
+ */
385
+ declare function simulateSource(configPath: string, input: unknown, options: SimulateSourceOptions): Promise<PushResult>;
386
+ interface SimulateTransformerOptions {
387
+ transformerId: string;
388
+ flow?: string;
389
+ mock?: string[];
390
+ silent?: boolean;
391
+ verbose?: boolean;
392
+ snapshot?: string;
393
+ }
394
+ /**
395
+ * Self-contained transformer simulation.
396
+ *
397
+ * Takes a DeepPartialEvent, validates it with Zod, loads the flow config,
398
+ * bundles it, starts the flow to get initialized transformers, then runs
399
+ * the event through the target transformer (with optional before chain).
400
+ *
401
+ * Captured array: first entry = input event, subsequent entries = output event(s).
402
+ * If the transformer drops the event (returns false), output event is null.
403
+ */
404
+ declare function simulateTransformer(configPath: string, event: WalkerOS.DeepPartialEvent, options: SimulateTransformerOptions): Promise<PushResult>;
405
+ interface SimulateDestinationOptions {
406
+ destinationId: string;
407
+ flow?: string;
408
+ mock?: string[];
409
+ silent?: boolean;
410
+ verbose?: boolean;
411
+ snapshot?: string;
412
+ }
413
+ /**
414
+ * Self-contained destination simulation.
415
+ *
416
+ * Takes a DeepPartialEvent, validates it with Zod, loads the flow config,
417
+ * bundles it, starts the flow, then pushes via collector.push with an include
418
+ * filter so only the target destination receives the event. This gives full
419
+ * pipeline support — consent checks, event mapping, createEvent enrichment,
420
+ * before chains — without manual wiring.
421
+ */
422
+ declare function simulateDestination(configPath: string, event: WalkerOS.DeepPartialEvent, options: SimulateDestinationOptions): Promise<PushResult>;
447
423
 
448
424
  /**
449
425
  * Run Command Types
@@ -5109,9 +5085,43 @@ declare function readConfig(): WalkerOSConfig | null;
5109
5085
  */
5110
5086
  declare function writeConfig(config: WalkerOSConfig): void;
5111
5087
 
5088
+ /**
5089
+ * Load configuration from a file path, URL, or inline string.
5090
+ *
5091
+ * Supports two modes:
5092
+ * - `json: true` (default) — resolves content and parses as JSON
5093
+ * - `json: false` — resolves content and returns raw string
5094
+ *
5095
+ * Detection priority:
5096
+ * 1. URL (http://, https://) — download content
5097
+ * 2. Existing file path — read file content
5098
+ * 3. Inline string (starting with { or [) — use directly
5099
+ *
5100
+ * @param input - Path to file, HTTP/HTTPS URL, or inline string
5101
+ * @param options - Optional settings
5102
+ * @param options.json - Parse as JSON (default: true)
5103
+ * @returns Parsed object (json: true) or raw string (json: false)
5104
+ * @throws Error if file not found, download fails, or invalid JSON
5105
+ *
5106
+ * @example
5107
+ * ```typescript
5108
+ * // JSON mode (default) — same as loadJsonConfig
5109
+ * const config = await loadConfig('./config.json')
5110
+ * const config = await loadConfig('https://example.com/config.json')
5111
+ * const config = await loadConfig('{"version":3,"flows":{}}')
5112
+ *
5113
+ * // Raw string mode — returns file/URL content as string
5114
+ * const code = await loadConfig('./bundle.js', { json: false })
5115
+ * ```
5116
+ */
5117
+ declare function loadConfig<T = unknown>(input: string, options?: {
5118
+ json?: boolean;
5119
+ }): Promise<T | string>;
5112
5120
  /**
5113
5121
  * Load and parse JSON configuration from a file path, URL, or inline JSON string.
5114
5122
  *
5123
+ * Thin wrapper around `loadConfig` with `json: true` (default).
5124
+ *
5115
5125
  * Detection priority:
5116
5126
  * 1. URL (http://, https://) — download and parse
5117
5127
  * 2. Existing file path — read and parse
@@ -5135,4 +5145,39 @@ declare function writeConfig(config: WalkerOSConfig): void;
5135
5145
  */
5136
5146
  declare function loadJsonConfig<T>(configPath: string): Promise<T>;
5137
5147
 
5138
- export { ApiError, type ApiErrorDetail, type BuildOptions, type BundleStats, type CLIBuildOptions, type DeployOptions, type ExampleLookupResult, type FeedbackOptions, type GlobalOptions, type ListDeploymentsOptions, type ListFlowsOptions, type MinifyOptions, type PushResult, type RunCommandOptions, type RunOptions, type RunResult, type SSEEvent, type SSEParseResult, type SimulationResult, type ValidateResult, type ValidationError, type ValidationType, type ValidationWarning, type WalkerOSConfig, apiFetch, bundle, bundleCommand, bundleRemote, compareOutput, createApiClient, createDeployCommand, createDeployment, createDeploymentCommand, createFlow, createFlowCommand, createProject, createProjectCommand, deleteDeployment, deleteDeploymentCommand, deleteFlow, deleteFlowCommand, deleteProject, deleteProjectCommand, deploy, deployCommand, deployFetch, duplicateFlow, duplicateFlowCommand, feedback, feedbackCommand, findExample, getAuthHeaders, getDeployment, getDeploymentBySlug, getDeploymentBySlugCommand, getDeploymentCommand, getFlow, getFlowCommand, getProject, getProjectCommand, getToken, listDeployments, listDeploymentsCommand, listFlows, listFlowsCommand, listProjects, listProjectsCommand, loadJsonConfig, loginCommand, logoutCommand, mergeAuthHeaders, parseSSEEvents, publicFetch, push, pushCommand, readConfig, requireProjectId, run, runCommand, simulate, simulateCommand, throwApiError, updateFlow, updateFlowCommand, updateProject, updateProjectCommand, validate, validateCommand, whoami, whoamiCommand, writeConfig };
5148
+ type StepType = 'source' | 'transformer' | 'destination';
5149
+ interface ExampleLookupResult {
5150
+ stepType: StepType;
5151
+ stepName: string;
5152
+ exampleName: string;
5153
+ example: {
5154
+ in?: unknown;
5155
+ mapping?: unknown;
5156
+ out?: unknown;
5157
+ };
5158
+ }
5159
+ /**
5160
+ * Find a named example in a flow config.
5161
+ *
5162
+ * Searches sources, transformers, and destinations for a matching example.
5163
+ * If --step is provided (e.g. "destination.gtag"), looks only in that step.
5164
+ * If not, searches all steps and errors if ambiguous.
5165
+ *
5166
+ * @param config - Raw (unresolved) flow config with examples intact
5167
+ * @param exampleName - Name of the example to find
5168
+ * @param stepTarget - Optional step target in "type.name" format
5169
+ * @returns The found example with its location
5170
+ */
5171
+ declare function findExample(config: Flow.Settings, exampleName: string, stepTarget?: string): ExampleLookupResult;
5172
+
5173
+ /**
5174
+ * Compare simulation output against expected example output.
5175
+ */
5176
+ declare function compareOutput(expected: unknown, actual: unknown): {
5177
+ expected: unknown;
5178
+ actual: unknown;
5179
+ match: boolean;
5180
+ diff?: string;
5181
+ };
5182
+
5183
+ export { ApiError, type ApiErrorDetail, type BuildOptions, type BundleStats, type CLIBuildOptions, type DeployOptions, type ExampleLookupResult, type FeedbackOptions, type GlobalOptions, type ListDeploymentsOptions, type ListFlowsOptions, type MinifyOptions, type PushResult, type RunCommandOptions, type RunOptions, type RunResult, type SSEEvent, type SSEParseResult, type SimulateDestinationOptions, type SimulateSourceOptions, type SimulateTransformerOptions, type ValidateResult, type ValidationError, type ValidationType, type ValidationWarning, type WalkerOSConfig, apiFetch, bundle, bundleCommand, bundleRemote, compareOutput, createApiClient, createDeployCommand, createDeployment, createDeploymentCommand, createFlow, createFlowCommand, createProject, createProjectCommand, deleteDeployment, deleteDeploymentCommand, deleteFlow, deleteFlowCommand, deleteProject, deleteProjectCommand, deploy, deployCommand, deployFetch, duplicateFlow, duplicateFlowCommand, feedback, feedbackCommand, findExample, getAuthHeaders, getDeployment, getDeploymentBySlug, getDeploymentBySlugCommand, getDeploymentCommand, getFlow, getFlowCommand, getProject, getProjectCommand, getToken, listDeployments, listDeploymentsCommand, listFlows, listFlowsCommand, listProjects, listProjectsCommand, loadConfig, loadJsonConfig, loginCommand, logoutCommand, mergeAuthHeaders, parseSSEEvents, publicFetch, push, pushCommand, readConfig, requireProjectId, run, runCommand, simulateDestination, simulateSource, simulateTransformer, throwApiError, updateFlow, updateFlowCommand, updateProject, updateProjectCommand, validate, validateCommand, whoami, whoamiCommand, writeConfig };