@walkeros/cli 4.1.0 → 4.1.1-next-1779485810490

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/index.js CHANGED
@@ -3906,7 +3906,14 @@ function startDrainPump(pending, options = {}) {
3906
3906
  }
3907
3907
 
3908
3908
  // src/commands/push/flow-context.ts
3909
- async function withFlowContext(options, fn) {
3909
+ function defaultPushError(error, startTime) {
3910
+ return {
3911
+ success: false,
3912
+ duration: Date.now() - startTime,
3913
+ error: getErrorMessage(error)
3914
+ };
3915
+ }
3916
+ async function withFlowContext(options, fn, onError) {
3910
3917
  const {
3911
3918
  esmPath,
3912
3919
  platform,
@@ -3998,11 +4005,7 @@ async function withFlowContext(options, fn) {
3998
4005
  }
3999
4006
  return await fn(flowModule);
4000
4007
  } catch (error) {
4001
- return {
4002
- success: false,
4003
- duration: Date.now() - startTime,
4004
- error: getErrorMessage(error)
4005
- };
4008
+ return (onError ?? defaultPushError)(error, startTime);
4006
4009
  } finally {
4007
4010
  if (timerControl) timerControl.restore();
4008
4011
  if (savedFetch !== void 0) {
@@ -4064,6 +4067,28 @@ function cleanupNetworkPolyfills(savedFetch) {
4064
4067
  global.fetch = savedFetch;
4065
4068
  }
4066
4069
 
4070
+ // src/commands/push/simulation-result.ts
4071
+ init_utils2();
4072
+ function hasEvent(entry) {
4073
+ return entry.event != null;
4074
+ }
4075
+ function toError(error) {
4076
+ return error instanceof Error ? error : new Error(getErrorMessage(error));
4077
+ }
4078
+ function buildSimulationResult(args) {
4079
+ const { step, name, startTime, captured, usage, error } = args;
4080
+ const events = (captured ?? []).filter(hasEvent).map((entry) => entry.event);
4081
+ const calls = usage ? Object.values(usage).flat().map((call) => ({ fn: call.fn, args: call.args, ts: call.ts })) : [];
4082
+ return {
4083
+ step,
4084
+ name,
4085
+ events,
4086
+ calls,
4087
+ duration: Date.now() - startTime,
4088
+ ...error !== void 0 ? { error: toError(error) } : {}
4089
+ };
4090
+ }
4091
+
4067
4092
  // src/commands/push/prepare.ts
4068
4093
  init_cli_logger();
4069
4094
  init_tmp();
@@ -4167,6 +4192,13 @@ function dispatchSimulate(flags) {
4167
4192
  // src/commands/push/run.ts
4168
4193
  init_core();
4169
4194
  init_config();
4195
+ function simulationToPushResult(result) {
4196
+ return {
4197
+ success: !result.error,
4198
+ duration: result.duration,
4199
+ ...result.error ? { error: result.error.message } : {}
4200
+ };
4201
+ }
4170
4202
  async function runPushCommand(options) {
4171
4203
  const startTime = Date.now();
4172
4204
  try {
@@ -4197,26 +4229,30 @@ async function runPushCommand(options) {
4197
4229
  });
4198
4230
  break;
4199
4231
  case "source":
4200
- result = await simulateSource(config, resolvedEvent, {
4201
- sourceId: plan.ids[0],
4202
- flow: options.flow,
4203
- silent: options.silent,
4204
- verbose: options.verbose,
4205
- snapshot: options.snapshot
4206
- });
4207
- break;
4208
- case "transformer":
4209
- result = await simulateTransformer(
4210
- config,
4211
- resolvedEvent,
4212
- {
4213
- transformerId: plan.ids[0],
4232
+ result = simulationToPushResult(
4233
+ await simulateSource(config, resolvedEvent, {
4234
+ sourceId: plan.ids[0],
4214
4235
  flow: options.flow,
4215
- mock: options.mock,
4216
4236
  silent: options.silent,
4217
4237
  verbose: options.verbose,
4218
4238
  snapshot: options.snapshot
4219
- }
4239
+ })
4240
+ );
4241
+ break;
4242
+ case "transformer":
4243
+ result = simulationToPushResult(
4244
+ await simulateTransformer(
4245
+ config,
4246
+ resolvedEvent,
4247
+ {
4248
+ transformerId: plan.ids[0],
4249
+ flow: options.flow,
4250
+ mock: options.mock,
4251
+ silent: options.silent,
4252
+ verbose: options.verbose,
4253
+ snapshot: options.snapshot
4254
+ }
4255
+ )
4220
4256
  );
4221
4257
  break;
4222
4258
  case "destination":
@@ -4239,7 +4275,6 @@ async function runPushCommand(options) {
4239
4275
  }
4240
4276
  async function runDestinationSimulationLoop(config, event, destinationIds, options) {
4241
4277
  const startTime = Date.now();
4242
- const perDestination = {};
4243
4278
  for (const destinationId of destinationIds) {
4244
4279
  const r = await simulateDestination(config, event, {
4245
4280
  destinationId,
@@ -4249,20 +4284,17 @@ async function runDestinationSimulationLoop(config, event, destinationIds, optio
4249
4284
  verbose: options.verbose,
4250
4285
  snapshot: options.snapshot
4251
4286
  });
4252
- perDestination[destinationId] = r;
4253
- if (!r.success) {
4287
+ if (r.error) {
4254
4288
  return {
4255
4289
  success: false,
4256
4290
  duration: Date.now() - startTime,
4257
- error: `simulate destination.${destinationId}: ${r.error ?? "unknown error"}`,
4258
- perDestination
4291
+ error: `simulate destination.${destinationId}: ${r.error.message}`
4259
4292
  };
4260
4293
  }
4261
4294
  }
4262
4295
  return {
4263
4296
  success: true,
4264
- duration: Date.now() - startTime,
4265
- perDestination
4297
+ duration: Date.now() - startTime
4266
4298
  };
4267
4299
  }
4268
4300
 
@@ -4626,20 +4658,27 @@ async function simulateSource(configOrPath, input, options) {
4626
4658
  if (instance.flow?.collector?.command) {
4627
4659
  await instance.flow.collector.command("shutdown");
4628
4660
  }
4629
- return {
4630
- success: true,
4631
- ...captured.length > 0 ? { captured } : {},
4632
- ...networkCalls.length > 0 ? { networkCalls } : {},
4633
- duration: Date.now() - startTime
4634
- };
4635
- }
4661
+ return buildSimulationResult({
4662
+ step: "source",
4663
+ name: options.sourceId,
4664
+ startTime,
4665
+ captured
4666
+ });
4667
+ },
4668
+ (error) => buildSimulationResult({
4669
+ step: "source",
4670
+ name: options.sourceId,
4671
+ startTime,
4672
+ error
4673
+ })
4636
4674
  );
4637
4675
  } catch (error) {
4638
- return {
4639
- success: false,
4640
- duration: Date.now() - startTime,
4641
- error: getErrorMessage(error)
4642
- };
4676
+ return buildSimulationResult({
4677
+ step: "source",
4678
+ name: options.sourceId,
4679
+ startTime,
4680
+ error
4681
+ });
4643
4682
  } finally {
4644
4683
  await prepared.cleanup();
4645
4684
  }
@@ -4648,11 +4687,12 @@ async function simulateTransformer(configOrPath, event, options) {
4648
4687
  const startTime = Date.now();
4649
4688
  const parsed = schemas3.PartialEventSchema.safeParse(event);
4650
4689
  if (!parsed.success) {
4651
- return {
4652
- success: false,
4653
- duration: 0,
4690
+ return buildSimulationResult({
4691
+ step: "transformer",
4692
+ name: options.transformerId,
4693
+ startTime,
4654
4694
  error: parsed.error.message
4655
- };
4695
+ });
4656
4696
  }
4657
4697
  let config;
4658
4698
  if (typeof configOrPath === "string") {
@@ -4728,7 +4768,6 @@ async function simulateTransformer(configOrPath, event, options) {
4728
4768
  const inputEvent = event;
4729
4769
  const ingest = createIngest(options.transformerId);
4730
4770
  const captured = [];
4731
- captured.push({ event: { ...inputEvent }, timestamp: Date.now() });
4732
4771
  logger.info(`Simulating transformer: ${options.transformerId}`);
4733
4772
  let processedEvent = inputEvent;
4734
4773
  const before = transformer.config.before;
@@ -4752,11 +4791,12 @@ async function simulateTransformer(configOrPath, event, options) {
4752
4791
  if (beforeResult === null) {
4753
4792
  captured.push({ event: null, timestamp: Date.now() });
4754
4793
  await collector.command("shutdown");
4755
- return {
4756
- success: true,
4757
- captured,
4758
- duration: Date.now() - startTime
4759
- };
4794
+ return buildSimulationResult({
4795
+ step: "transformer",
4796
+ name: options.transformerId,
4797
+ startTime,
4798
+ captured
4799
+ });
4760
4800
  }
4761
4801
  processedEvent = Array.isArray(beforeResult) ? beforeResult[0] : beforeResult;
4762
4802
  }
@@ -4783,20 +4823,27 @@ async function simulateTransformer(configOrPath, event, options) {
4783
4823
  captured.push({ event: processedEvent, timestamp: Date.now() });
4784
4824
  }
4785
4825
  await collector.command("shutdown");
4786
- return {
4787
- success: true,
4788
- captured,
4789
- ...networkCalls.length > 0 ? { networkCalls } : {},
4790
- duration: Date.now() - startTime
4791
- };
4792
- }
4826
+ return buildSimulationResult({
4827
+ step: "transformer",
4828
+ name: options.transformerId,
4829
+ startTime,
4830
+ captured
4831
+ });
4832
+ },
4833
+ (error) => buildSimulationResult({
4834
+ step: "transformer",
4835
+ name: options.transformerId,
4836
+ startTime,
4837
+ error
4838
+ })
4793
4839
  );
4794
4840
  } catch (error) {
4795
- return {
4796
- success: false,
4797
- duration: Date.now() - startTime,
4798
- error: getErrorMessage(error)
4799
- };
4841
+ return buildSimulationResult({
4842
+ step: "transformer",
4843
+ name: options.transformerId,
4844
+ startTime,
4845
+ error
4846
+ });
4800
4847
  } finally {
4801
4848
  await prepared.cleanup();
4802
4849
  }
@@ -4805,11 +4852,12 @@ async function simulateDestination(configOrPath, event, options) {
4805
4852
  const startTime = Date.now();
4806
4853
  const parsed = schemas3.PartialEventSchema.safeParse(event);
4807
4854
  if (!parsed.success) {
4808
- return {
4809
- success: false,
4810
- duration: 0,
4855
+ return buildSimulationResult({
4856
+ step: "destination",
4857
+ name: options.destinationId,
4858
+ startTime,
4811
4859
  error: parsed.error.message
4812
- };
4860
+ });
4813
4861
  }
4814
4862
  let config;
4815
4863
  if (typeof configOrPath === "string") {
@@ -4892,25 +4940,31 @@ async function simulateDestination(configOrPath, event, options) {
4892
4940
  );
4893
4941
  }
4894
4942
  logger.info(`Simulating destination: ${options.destinationId}`);
4895
- const elbResult = await collector.push(event, {
4943
+ await collector.push(event, {
4896
4944
  include: [options.destinationId]
4897
4945
  });
4898
4946
  await collector.command("shutdown");
4899
- return {
4900
- success: true,
4901
- elbResult,
4902
- ...trackedCalls.length > 0 ? { usage: { [options.destinationId]: trackedCalls } } : {},
4903
- ...networkCalls.length > 0 ? { networkCalls } : {},
4904
- duration: Date.now() - startTime
4905
- };
4906
- }
4947
+ return buildSimulationResult({
4948
+ step: "destination",
4949
+ name: options.destinationId,
4950
+ startTime,
4951
+ usage: trackedCalls.length ? { [options.destinationId]: trackedCalls } : void 0
4952
+ });
4953
+ },
4954
+ (error) => buildSimulationResult({
4955
+ step: "destination",
4956
+ name: options.destinationId,
4957
+ startTime,
4958
+ error
4959
+ })
4907
4960
  );
4908
4961
  } catch (error) {
4909
- return {
4910
- success: false,
4911
- duration: Date.now() - startTime,
4912
- error: getErrorMessage(error)
4913
- };
4962
+ return buildSimulationResult({
4963
+ step: "destination",
4964
+ name: options.destinationId,
4965
+ startTime,
4966
+ error
4967
+ });
4914
4968
  } finally {
4915
4969
  await prepared.cleanup();
4916
4970
  }
@@ -5871,7 +5925,7 @@ import chalk2 from "chalk";
5871
5925
  // src/commands/validate/validators/contract.ts
5872
5926
  var SECTION_KEYS = ["globals", "context", "custom", "user", "consent"];
5873
5927
  var KNOWN_KEYS = /* @__PURE__ */ new Set([
5874
- "extends",
5928
+ "extend",
5875
5929
  "description",
5876
5930
  "events",
5877
5931
  ...SECTION_KEYS
@@ -5901,18 +5955,18 @@ function validateContract(input) {
5901
5955
  continue;
5902
5956
  }
5903
5957
  const obj = entry;
5904
- if (obj.extends !== void 0) {
5905
- if (typeof obj.extends !== "string") {
5958
+ if (obj.extend !== void 0) {
5959
+ if (typeof obj.extend !== "string") {
5906
5960
  errors.push({
5907
- path: `${name}.extends`,
5908
- message: "extends must be a string",
5961
+ path: `${name}.extend`,
5962
+ message: "extend must be a string",
5909
5963
  code: "INVALID_EXTENDS"
5910
5964
  });
5911
- } else if (!contractNames.includes(obj.extends)) {
5965
+ } else if (!contractNames.includes(obj.extend)) {
5912
5966
  errors.push({
5913
- path: `${name}.extends`,
5914
- message: `extends references non-existent contract "${obj.extends}"`,
5915
- value: obj.extends,
5967
+ path: `${name}.extend`,
5968
+ message: `extend references non-existent contract "${obj.extend}"`,
5969
+ value: obj.extend,
5916
5970
  code: "INVALID_EXTENDS"
5917
5971
  });
5918
5972
  }
@@ -5951,15 +6005,15 @@ function validateContract(input) {
5951
6005
  while (current) {
5952
6006
  if (visited.has(current)) {
5953
6007
  errors.push({
5954
- path: `${name}.extends`,
5955
- message: `Circular extends chain: ${[...visited, current].join(" \u2192 ")}`,
6008
+ path: `${name}.extend`,
6009
+ message: `Circular extend chain: ${[...visited, current].join(" \u2192 ")}`,
5956
6010
  code: "CIRCULAR_EXTENDS"
5957
6011
  });
5958
6012
  break;
5959
6013
  }
5960
6014
  visited.add(current);
5961
6015
  const entry = contracts[current];
5962
- current = entry?.extends || "";
6016
+ current = entry?.extend || "";
5963
6017
  }
5964
6018
  }
5965
6019
  return {
@@ -6528,7 +6582,7 @@ function validateMapping(input) {
6528
6582
  // src/commands/validate/validators/entry.ts
6529
6583
  import Ajv from "ajv";
6530
6584
  import { fetchPackageSchema } from "@walkeros/core";
6531
- var CLIENT_HEADER = "walkeros-cli/4.1.0";
6585
+ var CLIENT_HEADER = "walkeros-cli/4.1.1-next-1779485810490";
6532
6586
  var SECTIONS = ["destinations", "sources", "transformers"];
6533
6587
  function resolveEntry(path20, flowConfig) {
6534
6588
  const flows = flowConfig.flows;
@@ -7181,9 +7235,11 @@ async function whoamiCommand(options) {
7181
7235
  // src/commands/projects/index.ts
7182
7236
  init_auth();
7183
7237
  init_output();
7184
- async function listProjects() {
7238
+ async function listProjects(options = {}) {
7185
7239
  const client = createApiClient();
7186
- const { data, error } = await client.GET("/api/projects");
7240
+ const { data, error } = await client.GET("/api/projects", {
7241
+ params: { query: { cursor: options.cursor, limit: options.limit } }
7242
+ });
7187
7243
  if (error) throw new Error(error.error?.message || "Failed to list projects");
7188
7244
  return data;
7189
7245
  }
@@ -7279,7 +7335,9 @@ async function listFlows(options = {}) {
7279
7335
  query: {
7280
7336
  sort: options.sort,
7281
7337
  order: options.order,
7282
- include_deleted: options.includeDeleted ? "true" : void 0
7338
+ include_deleted: options.includeDeleted ? "true" : void 0,
7339
+ cursor: options.cursor,
7340
+ limit: options.limit
7283
7341
  }
7284
7342
  }
7285
7343
  });
@@ -7685,6 +7743,8 @@ async function listDeployments(options = {}) {
7685
7743
  if (options.type) params.set("type", options.type);
7686
7744
  if (options.status) params.set("status", options.status);
7687
7745
  if (options.flowId) params.set("flowId", options.flowId);
7746
+ if (options.cursor) params.set("cursor", options.cursor);
7747
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
7688
7748
  const qs = params.toString();
7689
7749
  const response = await apiFetch(
7690
7750
  `/api/projects/${id}/deployments${qs ? `?${qs}` : ""}`