wrangler 4.128.0 → 4.129.1

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.
@@ -26460,7 +26460,7 @@ var DEFAULT_COMPAT_DATE;
26460
26460
  var init_default_compat_date = __esm({
26461
26461
  "../workers-utils/src/default-compat-date.ts"() {
26462
26462
  init_import_meta_url();
26463
- DEFAULT_COMPAT_DATE = "2026-08-31";
26463
+ DEFAULT_COMPAT_DATE = "2026-09-07";
26464
26464
  }
26465
26465
  });
26466
26466
 
@@ -43446,8 +43446,8 @@ var require_snapshot_utils = __commonJS({
43446
43446
  };
43447
43447
  }
43448
43448
  __name(createHeaderFilters, "createHeaderFilters");
43449
- var crypto8 = runtimeFeatures.has("crypto") ? __require("crypto") : null;
43450
- var hashId = crypto8?.hash ? (value) => crypto8.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
43449
+ var crypto7 = runtimeFeatures.has("crypto") ? __require("crypto") : null;
43450
+ var hashId = crypto7?.hash ? (value) => crypto7.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
43451
43451
  function isUndiciHeaders(headers) {
43452
43452
  return Array.isArray(headers) && (headers.length & 1) === 0;
43453
43453
  }
@@ -50139,10 +50139,10 @@ var require_subresource_integrity = __commonJS({
50139
50139
  var assert70 = __require("assert");
50140
50140
  var { runtimeFeatures } = require_runtime_features();
50141
50141
  var validSRIHashAlgorithmTokenSet = /* @__PURE__ */ new Map([["sha256", 0], ["sha384", 1], ["sha512", 2]]);
50142
- var crypto8;
50142
+ var crypto7;
50143
50143
  if (runtimeFeatures.has("crypto")) {
50144
- crypto8 = __require("crypto");
50145
- const cryptoHashes = crypto8.getHashes();
50144
+ crypto7 = __require("crypto");
50145
+ const cryptoHashes = crypto7.getHashes();
50146
50146
  if (cryptoHashes.length === 0) {
50147
50147
  validSRIHashAlgorithmTokenSet.clear();
50148
50148
  }
@@ -50234,7 +50234,7 @@ var require_subresource_integrity = __commonJS({
50234
50234
  }
50235
50235
  __name(parseMetadata, "parseMetadata");
50236
50236
  var applyAlgorithmToBytes = /* @__PURE__ */ __name((algorithm, bytes) => {
50237
- return crypto8.hash(algorithm, bytes, "base64");
50237
+ return crypto7.hash(algorithm, bytes, "base64");
50238
50238
  }, "applyAlgorithmToBytes");
50239
50239
  function caseSensitiveMatch(actualValue, expectedValue) {
50240
50240
  let actualValueLength = actualValue.length;
@@ -53272,7 +53272,7 @@ var require_connection = __commonJS({
53272
53272
  var { WebsocketFrameSend } = require_frame();
53273
53273
  var assert70 = __require("assert");
53274
53274
  var { runtimeFeatures } = require_runtime_features();
53275
- var crypto8 = runtimeFeatures.has("crypto") ? __require("crypto") : null;
53275
+ var crypto7 = runtimeFeatures.has("crypto") ? __require("crypto") : null;
53276
53276
  var warningEmitted2 = false;
53277
53277
  function establishWebSocketConnection(url5, protocols, client, handler, options) {
53278
53278
  const requestURL = url5;
@@ -53292,7 +53292,7 @@ var require_connection = __commonJS({
53292
53292
  const headersList = getHeadersList(new Headers7(options.headers));
53293
53293
  request4.headersList = headersList;
53294
53294
  }
53295
- const keyValue = crypto8.randomBytes(16).toString("base64");
53295
+ const keyValue = crypto7.randomBytes(16).toString("base64");
53296
53296
  request4.headersList.append("sec-websocket-key", keyValue, true);
53297
53297
  request4.headersList.append("sec-websocket-version", "13", true);
53298
53298
  for (const protocol of protocols) {
@@ -53332,7 +53332,7 @@ var require_connection = __commonJS({
53332
53332
  return;
53333
53333
  }
53334
53334
  const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
53335
- const digest = crypto8.hash("sha1", keyValue + uid, "base64");
53335
+ const digest = crypto7.hash("sha1", keyValue + uid, "base64");
53336
53336
  if (secWSAccept !== digest) {
53337
53337
  failWebsocketConnection(handler, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
53338
53338
  return;
@@ -60702,7 +60702,7 @@ var name, version2;
60702
60702
  var init_package = __esm({
60703
60703
  "package.json"() {
60704
60704
  name = "wrangler";
60705
- version2 = "4.128.0";
60705
+ version2 = "4.129.1";
60706
60706
  }
60707
60707
  });
60708
60708
 
@@ -154282,18 +154282,18 @@ async function getSize(modules) {
154282
154282
  }
154283
154283
  function printBundleSize({ size, gzipSize }) {
154284
154284
  const bundleReport = `${(size / ONE_KIB_BYTES).toFixed(2)} KiB / gzip: ${(gzipSize / ONE_KIB_BYTES).toFixed(2)} KiB`;
154285
- const percentage = gzipSize / MAX_GZIP_SIZE_BYTES * 100;
154285
+ const percentage = size / MAX_UNCOMPRESSED_SIZE_BYTES * 100;
154286
154286
  const colorizedReport = percentage > 90 ? source_default.red(bundleReport) : percentage > 70 ? source_default.yellow(bundleReport) : source_default.green(bundleReport);
154287
154287
  logger.log(`Total Upload: ${colorizedReport}`);
154288
154288
  }
154289
- var ONE_KIB_BYTES, MAX_GZIP_SIZE_BYTES;
154289
+ var ONE_KIB_BYTES, MAX_UNCOMPRESSED_SIZE_BYTES;
154290
154290
  var init_bundle_reporter = __esm({
154291
154291
  "../deploy-helpers/src/deploy/helpers/bundle-reporter.ts"() {
154292
154292
  init_import_meta_url();
154293
154293
  init_source();
154294
154294
  init_context();
154295
154295
  ONE_KIB_BYTES = 1024;
154296
- MAX_GZIP_SIZE_BYTES = 3 * ONE_KIB_BYTES * ONE_KIB_BYTES;
154296
+ MAX_UNCOMPRESSED_SIZE_BYTES = 64 * ONE_KIB_BYTES * ONE_KIB_BYTES;
154297
154297
  __name(getSize, "getSize");
154298
154298
  __name(printBundleSize, "printBundleSize");
154299
154299
  }
@@ -155837,7 +155837,7 @@ var require_main = __commonJS({
155837
155837
  var fs37 = __require("fs");
155838
155838
  var path106 = __require("path");
155839
155839
  var os14 = __require("os");
155840
- var crypto8 = __require("crypto");
155840
+ var crypto7 = __require("crypto");
155841
155841
  var packageJson = require_package();
155842
155842
  var version7 = packageJson.version;
155843
155843
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
@@ -156003,7 +156003,7 @@ var require_main = __commonJS({
156003
156003
  const authTag = ciphertext.slice(-16);
156004
156004
  ciphertext = ciphertext.slice(12, -16);
156005
156005
  try {
156006
- const aesgcm = crypto8.createDecipheriv("aes-256-gcm", key, nonce);
156006
+ const aesgcm = crypto7.createDecipheriv("aes-256-gcm", key, nonce);
156007
156007
  aesgcm.setAuthTag(authTag);
156008
156008
  return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
156009
156009
  } catch (error53) {
@@ -156204,6 +156204,55 @@ function addBindingToPatch(patch, resourceType, binding) {
156204
156204
  serialisableBinding
156205
156205
  );
156206
156206
  }
156207
+ function isPermissionDeniedAPIError(error53) {
156208
+ return error53 instanceof APIError && error53.status === 403;
156209
+ }
156210
+ function trackSkippedProvisioning(skippedProvisioning, resourceType, bindingName) {
156211
+ const skippedBindingNames = skippedProvisioning.get(resourceType) ?? /* @__PURE__ */ new Set();
156212
+ skippedBindingNames.add(bindingName);
156213
+ skippedProvisioning.set(resourceType, skippedBindingNames);
156214
+ }
156215
+ function warnSkippedProvisioning(skippedProvisioning) {
156216
+ if (skippedProvisioning.size === 0) {
156217
+ return;
156218
+ }
156219
+ const bindingsByResourceType = Array.from(
156220
+ skippedProvisioning,
156221
+ ([type, names]) => {
156222
+ return `${getSkippedProvisioningResourceName(type)} - ${Array.from(names).join(", ")}`;
156223
+ }
156224
+ ).join("\n");
156225
+ logger.warn(esm_default`
156226
+ Skipping automatic provisioning for the following bindings because Wrangler does not have permission to check whether the resource exists. The deploy will continue, but may fail later if the resource does not exist:
156227
+
156228
+ ${bindingsByResourceType}
156229
+ `);
156230
+ }
156231
+ function getSkippedProvisioningResourceName(resourceType) {
156232
+ switch (resourceType) {
156233
+ case "kv_namespace":
156234
+ return "KV";
156235
+ case "d1":
156236
+ return "D1";
156237
+ case "r2_bucket":
156238
+ return "R2";
156239
+ case "ai_search_namespace":
156240
+ return "AI Search";
156241
+ case "agent_memory":
156242
+ return "Agent Memory";
156243
+ case "queue":
156244
+ return "Queue";
156245
+ case "dispatch_namespace":
156246
+ return "Dispatch Namespace";
156247
+ case "flagship":
156248
+ return "Flagship";
156249
+ }
156250
+ }
156251
+ function inheritIfNoConfiguredResourceIdentifier(handler) {
156252
+ if (!handler.hasConfiguredResourceIdentifier()) {
156253
+ handler.inherit();
156254
+ }
156255
+ }
156207
156256
  function isProvisionableBinding(binding) {
156208
156257
  return binding.type in HANDLERS;
156209
156258
  }
@@ -156280,6 +156329,7 @@ async function collectPendingResources(complianceConfig, accountId, scriptName,
156280
156329
  logger.debug("No settings found");
156281
156330
  }
156282
156331
  const pendingResources = [];
156332
+ const skippedProvisioning = /* @__PURE__ */ new Map();
156283
156333
  for (const [bindingName, binding] of Object.entries(bindings2 ?? {})) {
156284
156334
  if (!isProvisionableBinding(binding)) {
156285
156335
  continue;
@@ -156290,7 +156340,18 @@ async function collectPendingResources(complianceConfig, accountId, scriptName,
156290
156340
  complianceConfig,
156291
156341
  accountId
156292
156342
  );
156293
- if (await handler.shouldProvision(settings)) {
156343
+ let shouldProvision;
156344
+ try {
156345
+ shouldProvision = await handler.shouldProvision(settings);
156346
+ } catch (error53) {
156347
+ if (!isPermissionDeniedAPIError(error53)) {
156348
+ throw error53;
156349
+ }
156350
+ inheritIfNoConfiguredResourceIdentifier(handler);
156351
+ trackSkippedProvisioning(skippedProvisioning, binding.type, bindingName);
156352
+ continue;
156353
+ }
156354
+ if (shouldProvision) {
156294
156355
  pendingResources.push({
156295
156356
  binding: bindingName,
156296
156357
  resourceType: binding.type,
@@ -156298,18 +156359,16 @@ async function collectPendingResources(complianceConfig, accountId, scriptName,
156298
156359
  });
156299
156360
  }
156300
156361
  }
156301
- return pendingResources.sort(
156302
- (a7, b10) => HANDLERS[a7.resourceType].sort - HANDLERS[b10.resourceType].sort
156303
- );
156362
+ return {
156363
+ pendingResources: pendingResources.sort(
156364
+ (a7, b10) => HANDLERS[a7.resourceType].sort - HANDLERS[b10.resourceType].sort
156365
+ ),
156366
+ skippedProvisioning
156367
+ };
156304
156368
  }
156305
156369
  async function provisionBindings(bindings2, accountId, scriptName, autoCreate, config2, options) {
156306
156370
  const configPath = config2.userConfigPath ?? config2.configPath;
156307
- const pendingResources = await collectPendingResources(
156308
- config2,
156309
- accountId,
156310
- scriptName,
156311
- bindings2
156312
- );
156371
+ const { pendingResources, skippedProvisioning } = await collectPendingResources(config2, accountId, scriptName, bindings2);
156313
156372
  if (pendingResources.length > 0) {
156314
156373
  assert36__default.default(
156315
156374
  configPath,
@@ -156334,7 +156393,20 @@ async function provisionBindings(bindings2, accountId, scriptName, autoCreate, c
156334
156393
  logger.log();
156335
156394
  const existingResources = {};
156336
156395
  for (const resource of pendingResources) {
156337
- existingResources[resource.resourceType] ??= await HANDLERS[resource.resourceType].load(config2, accountId);
156396
+ try {
156397
+ existingResources[resource.resourceType] ??= await HANDLERS[resource.resourceType].load(config2, accountId);
156398
+ } catch (error53) {
156399
+ if (!isPermissionDeniedAPIError(error53)) {
156400
+ throw error53;
156401
+ }
156402
+ inheritIfNoConfiguredResourceIdentifier(resource.handler);
156403
+ trackSkippedProvisioning(
156404
+ skippedProvisioning,
156405
+ resource.resourceType,
156406
+ resource.binding
156407
+ );
156408
+ continue;
156409
+ }
156338
156410
  await runProvisioningFlow(
156339
156411
  resource,
156340
156412
  existingResources[resource.resourceType],
@@ -156400,9 +156472,12 @@ async function provisionBindings(bindings2, accountId, scriptName, autoCreate, c
156400
156472
  }
156401
156473
  }
156402
156474
  }
156403
- logger.log(`\u{1F389} All resources provisioned, continuing with deployment...
156475
+ logger.log(`\u{1F389} Resources provisioned, continuing with deployment...
156404
156476
  `);
156405
156477
  }
156478
+ return {
156479
+ warnOnSkippedProvisioning: /* @__PURE__ */ __name(() => warnSkippedProvisioning(skippedProvisioning), "warnOnSkippedProvisioning")
156480
+ };
156406
156481
  }
156407
156482
  function getSettings(complianceConfig, accountId, scriptName) {
156408
156483
  return fetchResult(
@@ -156731,6 +156806,10 @@ var init_provision_bindings = __esm({
156731
156806
  connect(id) {
156732
156807
  this.binding[this.idField] = id;
156733
156808
  }
156809
+ hasConfiguredResourceIdentifier() {
156810
+ const id = this.binding[this.idField];
156811
+ return typeof id === "string" && id.length > 0 || this.name !== void 0;
156812
+ }
156734
156813
  async provision(name2) {
156735
156814
  const id = await this.create(name2);
156736
156815
  this.connect(id);
@@ -157322,6 +157401,11 @@ var init_provision_bindings = __esm({
157322
157401
  };
157323
157402
  __name(getRawConfigBindings, "getRawConfigBindings");
157324
157403
  __name(addBindingToPatch, "addBindingToPatch");
157404
+ __name(isPermissionDeniedAPIError, "isPermissionDeniedAPIError");
157405
+ __name(trackSkippedProvisioning, "trackSkippedProvisioning");
157406
+ __name(warnSkippedProvisioning, "warnSkippedProvisioning");
157407
+ __name(getSkippedProvisioningResourceName, "getSkippedProvisioningResourceName");
157408
+ __name(inheritIfNoConfiguredResourceIdentifier, "inheritIfNoConfiguredResourceIdentifier");
157325
157409
  __name(isProvisionableBinding, "isProvisionableBinding");
157326
157410
  __name(createHandler, "createHandler");
157327
157411
  __name(toConfigBinding, "toConfigBinding");
@@ -161869,10 +161953,11 @@ async function deployWorker(props, config2, buildResult, callbacks) {
161869
161953
  });
161870
161954
  } else {
161871
161955
  assert36__default.default(accountId, "Missing accountId");
161956
+ let provisionBindingsResult;
161872
161957
  if (assetsOptions?.routerConfig.has_user_worker === false) {
161873
161958
  logger.debug("skipping provisioning on assets-only project");
161874
161959
  } else if (props.resourcesProvision) {
161875
- await provisionBindings(
161960
+ provisionBindingsResult = await provisionBindings(
161876
161961
  bindings2 ?? {},
161877
161962
  accountId,
161878
161963
  scriptName,
@@ -162000,6 +162085,7 @@ async function deployWorker(props, config2, buildResult, callbacks) {
162000
162085
  containers: config2.containers,
162001
162086
  unsafeMetadata: config2.unsafe?.metadata
162002
162087
  });
162088
+ provisionBindingsResult?.warnOnSkippedProvisioning();
162003
162089
  versionId = parseNonHyphenedUuid(result.deployment_id);
162004
162090
  if (config2.first_party_worker) {
162005
162091
  if (result.id) {
@@ -162311,10 +162397,11 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
162311
162397
  });
162312
162398
  } else {
162313
162399
  assert36__default.default(accountId, "Missing accountId");
162400
+ let provisionBindingsResult;
162314
162401
  if (assetsOptions?.routerConfig.has_user_worker === false) {
162315
162402
  logger.debug("skipping provisioning on assets-only project");
162316
162403
  } else if (props.resourcesProvision) {
162317
- await provisionBindings(
162404
+ provisionBindingsResult = await provisionBindings(
162318
162405
  bindings2,
162319
162406
  accountId,
162320
162407
  scriptName,
@@ -162351,6 +162438,7 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
162351
162438
  streamingTailConsumers: config2.streaming_tail_consumers,
162352
162439
  unsafeMetadata: config2.unsafe?.metadata
162353
162440
  });
162441
+ provisionBindingsResult?.warnOnSkippedProvisioning();
162354
162442
  versionId = result.id;
162355
162443
  hasPreview = result.metadata.has_preview;
162356
162444
  } catch (err) {
@@ -162969,7 +163057,7 @@ function getPullRequestMetadata() {
162969
163057
  return getDirectPullRequestMetadata() ?? getGitHubPullRequestMetadata() ?? getGitLabPullRequestMetadata();
162970
163058
  }
162971
163059
  function resolveWorkerName(args, config2) {
162972
- const workerName = args.workerName ?? args["worker-name"] ?? config2.name;
163060
+ const workerName = getCIOverrideName() ?? args.workerName ?? args["worker-name"] ?? config2.name;
162973
163061
  if (!workerName) {
162974
163062
  throw new UserError(
162975
163063
  `Required Worker name missing. Please specify the Worker name in your ${configFileName(
@@ -165545,6 +165633,8 @@ var init_cf = __esm({
165545
165633
  "dns_records:edit",
165546
165634
  "dns_records:read",
165547
165635
  "dns_settings:read",
165636
+ "email_routing:write",
165637
+ "email_sending:write",
165548
165638
  "firstpartytags:write",
165549
165639
  "images:read",
165550
165640
  "images:write",
@@ -169861,7 +169951,7 @@ var init_dist11 = __esm({
169861
169951
  init_wrapper();
169862
169952
  init_create_worker_upload_form();
169863
169953
  import_undici12 = __toESM(require_undici(), 1);
169864
- version3 = "0.0.18";
169954
+ version3 = "0.0.20";
169865
169955
  NoDefaultValueProvided2 = class extends UserError {
169866
169956
  static {
169867
169957
  __name(this, "NoDefaultValueProvided");
@@ -200475,6 +200565,18 @@ function switchHost(originalUrl, host, zonePreview) {
200475
200565
  url5.hostname = zonePreview ? host ?? url5.hostname : url5.hostname;
200476
200566
  return url5;
200477
200567
  }
200568
+ function getWorkersDevPreviewHost(exchangeUrl, name2) {
200569
+ if (!exchangeUrl) {
200570
+ return void 0;
200571
+ }
200572
+ try {
200573
+ const exchangeHost = new Url.URL(exchangeUrl).hostname;
200574
+ const firstDot = exchangeHost.indexOf(".");
200575
+ return firstDot === -1 ? void 0 : `${name2}${exchangeHost.slice(firstDot)}`;
200576
+ } catch {
200577
+ return void 0;
200578
+ }
200579
+ }
200478
200580
  async function tryExpandToken2(exchangeUrl, ctx, abortSignal) {
200479
200581
  try {
200480
200582
  const switchedExchangeUrl = switchHost(exchangeUrl, ctx.host, !!ctx.zone);
@@ -200515,7 +200617,7 @@ async function tryExpandToken2(exchangeUrl, ctx, abortSignal) {
200515
200617
  }
200516
200618
  async function createPreviewSession2(complianceConfig, account, ctx, abortSignal, name2) {
200517
200619
  const { accountId, apiToken } = account;
200518
- const initUrl = ctx.zone ? `/zones/${ctx.zone}/workers/edge-preview` : `/accounts/${accountId}/workers/subdomain/edge-preview`;
200620
+ const initUrl = ctx.zone ? `/zones/${ctx.zone}/workers/edge-preview` : `/accounts/${accountId}/workers/scripts/${name2}/subdomain/edge-preview`;
200519
200621
  const { token, exchange_url } = await fetchResult2(
200520
200622
  complianceConfig,
200521
200623
  initUrl,
@@ -200526,7 +200628,7 @@ async function createPreviewSession2(complianceConfig, account, ctx, abortSignal
200526
200628
  );
200527
200629
  const previewSessionToken = exchange_url ? await tryExpandToken2(exchange_url, ctx, withTimeout2(abortSignal)) ?? token : token;
200528
200630
  try {
200529
- let host = ctx.host;
200631
+ let host = ctx.host ?? getWorkersDevPreviewHost(ctx.zone ? void 0 : exchange_url, name2);
200530
200632
  if (!host) {
200531
200633
  const subdomain = await getWorkersDevSubdomain(
200532
200634
  complianceConfig,
@@ -200535,7 +200637,7 @@ async function createPreviewSession2(complianceConfig, account, ctx, abortSignal
200535
200637
  abortSignal: withTimeout2(abortSignal)
200536
200638
  }
200537
200639
  );
200538
- host = `${name2 ?? crypto2__default.default.randomUUID()}.${subdomain}`;
200640
+ host = `${name2}.${subdomain}`;
200539
200641
  }
200540
200642
  return {
200541
200643
  value: previewSessionToken,
@@ -200622,6 +200724,7 @@ var init_create_worker_preview = __esm({
200622
200724
  PREVIEW_API_TIMEOUT_MS2 = 3e4;
200623
200725
  __name(withTimeout2, "withTimeout");
200624
200726
  __name(switchHost, "switchHost");
200727
+ __name(getWorkersDevPreviewHost, "getWorkersDevPreviewHost");
200625
200728
  __name(tryExpandToken2, "tryExpandToken");
200626
200729
  __name(createPreviewSession2, "createPreviewSession");
200627
200730
  __name(createPreviewToken, "createPreviewToken");
@@ -212175,14 +212278,14 @@ var init_console = __esm({
212175
212278
  // ../../node_modules/.pnpm/@sentry+utils@7.87.0/node_modules/@sentry/utils/esm/misc.js
212176
212279
  function uuid43() {
212177
212280
  const gbl = GLOBAL_OBJ;
212178
- const crypto8 = gbl.crypto || gbl.msCrypto;
212281
+ const crypto7 = gbl.crypto || gbl.msCrypto;
212179
212282
  let getRandomByte = /* @__PURE__ */ __name(() => Math.random() * 16, "getRandomByte");
212180
212283
  try {
212181
- if (crypto8 && crypto8.randomUUID) {
212182
- return crypto8.randomUUID().replace(/-/g, "");
212284
+ if (crypto7 && crypto7.randomUUID) {
212285
+ return crypto7.randomUUID().replace(/-/g, "");
212183
212286
  }
212184
- if (crypto8 && crypto8.getRandomValues) {
212185
- getRandomByte = /* @__PURE__ */ __name(() => crypto8.getRandomValues(new Uint8Array(1))[0], "getRandomByte");
212287
+ if (crypto7 && crypto7.getRandomValues) {
212288
+ getRandomByte = /* @__PURE__ */ __name(() => crypto7.getRandomValues(new Uint8Array(1))[0], "getRandomByte");
212186
212289
  }
212187
212290
  } catch (_4) {
212188
212291
  }
@@ -222945,12 +223048,12 @@ This action is irreversible and will permanently delete all data in the database
222945
223048
  var require_md5_file = __commonJS({
222946
223049
  "../../node_modules/.pnpm/md5-file@5.0.0/node_modules/md5-file/index.js"(exports2, module2) {
222947
223050
  init_import_meta_url();
222948
- var crypto8 = __require("crypto");
223051
+ var crypto7 = __require("crypto");
222949
223052
  var fs37 = __require("fs");
222950
223053
  var BUFFER_SIZE = 8192;
222951
223054
  function md5FileSync(path106) {
222952
223055
  const fd = fs37.openSync(path106, "r");
222953
- const hash2 = crypto8.createHash("md5");
223056
+ const hash2 = crypto7.createHash("md5");
222954
223057
  const buffer = Buffer.alloc(BUFFER_SIZE);
222955
223058
  try {
222956
223059
  let bytesRead;
@@ -222966,7 +223069,7 @@ var require_md5_file = __commonJS({
222966
223069
  __name(md5FileSync, "md5FileSync");
222967
223070
  function md5File2(path106) {
222968
223071
  return new Promise((resolve35, reject) => {
222969
- const output = crypto8.createHash("md5");
223072
+ const output = crypto7.createHash("md5");
222970
223073
  const input = fs37.createReadStream(path106);
222971
223074
  input.on("error", (err) => {
222972
223075
  reject(err);
@@ -226340,15 +226443,39 @@ In-flight queries and transactions will be cancelled.
226340
226443
  async function deleteSiteNamespaceIfExisting(complianceConfig, scriptName, accountId) {
226341
226444
  const title = `__${scriptName}-workers_sites_assets`;
226342
226445
  const previewTitle = `__${scriptName}-workers_sites_assets_preview`;
226343
- const allNamespaces = await listKVNamespaces2(complianceConfig, accountId);
226446
+ let allNamespaces;
226447
+ try {
226448
+ allNamespaces = await listKVNamespaces2(complianceConfig, accountId);
226449
+ } catch (error53) {
226450
+ if (isPermissionDeniedAPIError2(error53)) {
226451
+ logger2.warn(
226452
+ `Skipping cleanup of legacy Workers Sites asset namespaces for "${scriptName}" because Wrangler does not have permission to list KV namespaces.`
226453
+ );
226454
+ return;
226455
+ }
226456
+ throw error53;
226457
+ }
226344
226458
  const namespacesToDelete = allNamespaces.filter(
226345
226459
  (ns) => ns.title === title || ns.title === previewTitle
226346
226460
  );
226347
226461
  for (const ns of namespacesToDelete) {
226348
- await deleteKVNamespace(complianceConfig, accountId, ns.id);
226462
+ try {
226463
+ await deleteKVNamespace(complianceConfig, accountId, ns.id);
226464
+ } catch (error53) {
226465
+ if (isPermissionDeniedAPIError2(error53)) {
226466
+ logger2.warn(
226467
+ `Skipping cleanup of legacy Workers Sites asset namespace "${ns.title}" because Wrangler does not have permission to delete KV namespaces.`
226468
+ );
226469
+ continue;
226470
+ }
226471
+ throw error53;
226472
+ }
226349
226473
  logger2.log(`\u{1F300} Deleted asset namespace for Workers Site "${ns.title}"`);
226350
226474
  }
226351
226475
  }
226476
+ function isPermissionDeniedAPIError2(error53) {
226477
+ return error53 instanceof APIError && error53.status === 403;
226478
+ }
226352
226479
  function renderScriptName(details) {
226353
226480
  let service;
226354
226481
  let environment;
@@ -226376,14 +226503,26 @@ function isUsedAsTailConsumer(tailProducers) {
226376
226503
  return tailProducers.length > 0;
226377
226504
  }
226378
226505
  async function checkAndConfirmForceDeleteIfNecessary(complianceConfig, scriptName, accountId) {
226379
- const references = await fetchResult2(
226380
- complianceConfig,
226381
- `/accounts/${accountId}/workers/scripts/${scriptName}/references`
226382
- );
226383
- const tailProducers = await fetchResult2(
226384
- complianceConfig,
226385
- `/accounts/${accountId}/workers/tails/by-consumer/${scriptName}`
226386
- );
226506
+ let references;
226507
+ let tailProducers;
226508
+ try {
226509
+ references = await fetchResult2(
226510
+ complianceConfig,
226511
+ `/accounts/${accountId}/workers/scripts/${scriptName}/references`
226512
+ );
226513
+ tailProducers = await fetchResult2(
226514
+ complianceConfig,
226515
+ `/accounts/${accountId}/workers/tails/by-consumer/${scriptName}`
226516
+ );
226517
+ } catch (error53) {
226518
+ if (isPermissionDeniedAPIError2(error53)) {
226519
+ logger2.warn(
226520
+ `Skipping dependency checks before deleting "${scriptName}" because Wrangler does not have permission to inspect Worker dependencies. The delete will continue, but may fail later if this Worker is still in use.`
226521
+ );
226522
+ return false;
226523
+ }
226524
+ throw error53;
226525
+ }
226387
226526
  const isDependentService = isUsedAsServiceBinding(references) || isUsedByPagesFunction(references) || isUsedAsDurableObjectNamespace(references, scriptName) || isUsedAsDispatchOutbound(references) || isUsedAsTailConsumer(tailProducers);
226388
226527
  if (!isDependentService) {
226389
226528
  return false;
@@ -226530,6 +226669,7 @@ var init_delete6 = __esm({
226530
226669
  }
226531
226670
  });
226532
226671
  __name(deleteSiteNamespaceIfExisting, "deleteSiteNamespaceIfExisting");
226672
+ __name(isPermissionDeniedAPIError2, "isPermissionDeniedAPIError");
226533
226673
  __name(renderScriptName, "renderScriptName");
226534
226674
  __name(isUsedAsServiceBinding, "isUsedAsServiceBinding");
226535
226675
  __name(isUsedByPagesFunction, "isUsedByPagesFunction");
@@ -330390,9 +330530,17 @@ function displayR2CredentialsInstructions(accountId) {
330390
330530
  source_default.dim(' Create token with "Object Read & Write" permissions\n')
330391
330531
  );
330392
330532
  }
330393
- async function promptCompression() {
330533
+ async function promptJsonCompression() {
330534
+ return select2("Compression:", {
330535
+ choices: [...JSON_COMPRESSION_CHOICES],
330536
+ defaultOption: 0,
330537
+ // uncompressed
330538
+ fallbackOption: 0
330539
+ });
330540
+ }
330541
+ async function promptParquetCompression() {
330394
330542
  return select2("Compression:", {
330395
- choices: [...COMPRESSION_CHOICES],
330543
+ choices: [...PARQUET_COMPRESSION_CHOICES],
330396
330544
  defaultOption: 3,
330397
330545
  // zstd
330398
330546
  fallbackOption: 3
@@ -330911,7 +331059,7 @@ async function setupR2Sink(config2, accountId, setupConfig) {
330911
331059
  defaultOption: 0,
330912
331060
  fallbackOption: 0
330913
331061
  });
330914
- const compression = format9 === "parquet" ? await promptCompression() : void 0;
331062
+ const formatConfig = format9 === "json" ? { type: "json", compression: await promptJsonCompression() } : { type: "parquet", compression: await promptParquetCompression() };
330915
331063
  const rollingPolicy = await promptRollingPolicy();
330916
331064
  const useOAuth = await confirm2(
330917
331065
  "Automatically generate credentials needed to write to your R2 bucket?",
@@ -330939,17 +331087,6 @@ async function setupR2Sink(config2, accountId, setupConfig) {
330939
331087
  displayR2CredentialsInstructions(accountId);
330940
331088
  credentials = await promptR2Credentials(accountId, bucket);
330941
331089
  }
330942
- let formatConfig;
330943
- if (format9 === "json") {
330944
- formatConfig = { type: "json" };
330945
- } else {
330946
- formatConfig = {
330947
- type: "parquet",
330948
- ...compression && {
330949
- compression
330950
- }
330951
- };
330952
- }
330953
331090
  setupConfig.sinkConfig = {
330954
331091
  name: setupConfig.sinkName,
330955
331092
  type: "r2",
@@ -330998,7 +331135,7 @@ async function setupDataCatalogSink(config2, accountId, setupConfig) {
330998
331135
  );
330999
331136
  displayCatalogTokenInstructions(accountId);
331000
331137
  const token = await promptCatalogToken(config2, accountId, bucket);
331001
- const compression = await promptCompression();
331138
+ const compression = await promptParquetCompression();
331002
331139
  const rollingPolicy = await promptRollingPolicy({
331003
331140
  minIntervalSeconds: SINK_DEFAULTS.rolling_policy.min_interval_seconds
331004
331141
  });
@@ -331131,7 +331268,7 @@ async function reviewAndCreateStreamSink(config2, setupConfig) {
331131
331268
  `));
331132
331269
  if (setupConfig.sinkConfig.type === "r2") {
331133
331270
  const format9 = setupConfig.sinkConfig.format?.type || "parquet";
331134
- const compression = setupConfig.sinkConfig.format?.type === "parquet" ? setupConfig.sinkConfig.format.compression || "" : "";
331271
+ const compression = setupConfig.sinkConfig.format?.compression || "";
331135
331272
  logger2.log(` Sink ${setupConfig.sinkName}`);
331136
331273
  logger2.log(
331137
331274
  source_default.dim(
@@ -331258,7 +331395,7 @@ async function createPipelineIfNeeded(config2, setupConfig, created, args) {
331258
331395
  }
331259
331396
  }
331260
331397
  }
331261
- var COMPRESSION_CHOICES, pipelinesSetupCommand;
331398
+ var JSON_COMPRESSION_CHOICES, PARQUET_COMPRESSION_CHOICES, pipelinesSetupCommand;
331262
331399
  var init_setup = __esm({
331263
331400
  "src/pipelines/cli/setup.ts"() {
331264
331401
  init_import_meta_url();
@@ -331283,14 +331420,19 @@ var init_setup = __esm({
331283
331420
  __name(ensureCatalogEnabled, "ensureCatalogEnabled");
331284
331421
  __name(displayCatalogTokenInstructions, "displayCatalogTokenInstructions");
331285
331422
  __name(displayR2CredentialsInstructions, "displayR2CredentialsInstructions");
331286
- COMPRESSION_CHOICES = [
331423
+ JSON_COMPRESSION_CHOICES = [
331424
+ { title: "uncompressed", value: "uncompressed" },
331425
+ { title: "gzip", value: "gzip" }
331426
+ ];
331427
+ PARQUET_COMPRESSION_CHOICES = [
331287
331428
  { title: "uncompressed", value: "uncompressed" },
331288
331429
  { title: "snappy", value: "snappy" },
331289
331430
  { title: "gzip", value: "gzip" },
331290
331431
  { title: "zstd", value: "zstd" },
331291
331432
  { title: "lz4", value: "lz4" }
331292
331433
  ];
331293
- __name(promptCompression, "promptCompression");
331434
+ __name(promptJsonCompression, "promptJsonCompression");
331435
+ __name(promptParquetCompression, "promptParquetCompression");
331294
331436
  __name(promptRollingPolicy, "promptRollingPolicy");
331295
331437
  __name(promptCatalogToken, "promptCatalogToken");
331296
331438
  __name(promptR2Credentials, "promptR2Credentials");
@@ -331399,7 +331541,11 @@ ${title}:`);
331399
331541
  const format9 = {
331400
331542
  Type: sink.format.type
331401
331543
  };
331402
- if (sink.format.type === "parquet") {
331544
+ if (sink.format.type === "json") {
331545
+ if (sink.format.compression) {
331546
+ format9.Compression = sink.format.compression;
331547
+ }
331548
+ } else {
331403
331549
  const defaultParquet = SINK_DEFAULTS.format.type === "parquet" ? SINK_DEFAULTS.format : null;
331404
331550
  if (defaultParquet) {
331405
331551
  const compression = sink.format.compression || defaultParquet.compression;
@@ -331439,6 +331585,12 @@ var init_utils19 = __esm({
331439
331585
  });
331440
331586
 
331441
331587
  // src/pipelines/cli/sinks/create.ts
331588
+ function isJsonCompression(compression) {
331589
+ return compression === "uncompressed" || compression === "gzip";
331590
+ }
331591
+ function isParquetCompression(compression) {
331592
+ return compression === "uncompressed" || compression === "snappy" || compression === "gzip" || compression === "zstd" || compression === "lz4";
331593
+ }
331442
331594
  function parseSinkType(type) {
331443
331595
  if (type === "r2" || type === "r2-data-catalog") {
331444
331596
  return type === "r2-data-catalog" ? "r2_data_catalog" : "r2";
@@ -331461,6 +331613,8 @@ var init_create15 = __esm({
331461
331613
  init_pipelines2();
331462
331614
  init_validate5();
331463
331615
  init_utils19();
331616
+ __name(isJsonCompression, "isJsonCompression");
331617
+ __name(isParquetCompression, "isParquetCompression");
331464
331618
  __name(parseSinkType, "parseSinkType");
331465
331619
  pipelinesSinksCreateCommand = createCommand({
331466
331620
  metadata: {
@@ -331493,10 +331647,9 @@ var init_create15 = __esm({
331493
331647
  default: SINK_DEFAULTS.format.type
331494
331648
  },
331495
331649
  compression: {
331496
- describe: "Compression method (parquet only)",
331650
+ describe: "Compression method (JSON supports uncompressed and gzip; Parquet defaults to zstd)",
331497
331651
  type: "string",
331498
- choices: ["uncompressed", "snappy", "gzip", "zstd", "lz4"],
331499
- default: SINK_DEFAULTS.format.compression
331652
+ choices: ["uncompressed", "snappy", "gzip", "zstd", "lz4"]
331500
331653
  },
331501
331654
  "target-row-group-size": {
331502
331655
  describe: "Target row group size for parquet format",
@@ -331585,6 +331738,24 @@ var init_create15 = __esm({
331585
331738
  );
331586
331739
  }
331587
331740
  }
331741
+ if (args.format === "json") {
331742
+ if (args.compression && !isJsonCompression(args.compression)) {
331743
+ throw new CommandLineArgsError(
331744
+ "JSON sinks only support 'uncompressed' or 'gzip' compression",
331745
+ {
331746
+ telemetryMessage: "pipelines sinks create invalid json compression"
331747
+ }
331748
+ );
331749
+ }
331750
+ if (args.targetRowGroupSize) {
331751
+ throw new CommandLineArgsError(
331752
+ "--target-row-group-size is only supported for Parquet sinks",
331753
+ {
331754
+ telemetryMessage: "pipelines sinks create invalid json row group size"
331755
+ }
331756
+ );
331757
+ }
331758
+ }
331588
331759
  }, "validateArgs"),
331589
331760
  async handler(args, { config: config2 }) {
331590
331761
  const accountId = await requireAuth(config2);
@@ -331600,13 +331771,16 @@ var init_create15 = __esm({
331600
331771
  if (args.format || args.compression || args.targetRowGroupSize) {
331601
331772
  let formatConfig;
331602
331773
  if (args.format === "json") {
331603
- formatConfig = { type: "json" };
331774
+ formatConfig = {
331775
+ type: "json",
331776
+ ...isJsonCompression(args.compression) && {
331777
+ compression: args.compression
331778
+ }
331779
+ };
331604
331780
  } else {
331605
331781
  formatConfig = {
331606
331782
  type: "parquet",
331607
- ...args.compression && {
331608
- compression: args.compression
331609
- },
331783
+ compression: isParquetCompression(args.compression) ? args.compression : SINK_DEFAULTS.format.compression,
331610
331784
  ...args.targetRowGroupSize && {
331611
331785
  row_group_bytes: parseInt(args.targetRowGroupSize.replace(/MB$/i, "")) * 1024 * 1024
331612
331786
  }
@@ -346567,7 +346741,7 @@ async function fetchLocalResult(port, path106, init4) {
346567
346741
  }
346568
346742
  return json2.result;
346569
346743
  }
346570
- async function getLocalInstanceIdFromArgs(port, args) {
346744
+ async function getLocalInstanceIdFromArgs(port, args, options = {}) {
346571
346745
  let id = args.id;
346572
346746
  if (id === "latest") {
346573
346747
  const instances = await fetchLocalResult(port, `/workflows/${encodeURIComponent(args.name)}/instances`);
@@ -346580,7 +346754,9 @@ async function getLocalInstanceIdFromArgs(port, args) {
346580
346754
  (a7, b10) => (b10.created_on ?? "").localeCompare(a7.created_on ?? "")
346581
346755
  );
346582
346756
  id = sorted[0].id;
346583
- logger2.info(`Latest instance is "${id}"`);
346757
+ if (!options.quiet) {
346758
+ logger2.info(`Latest instance is "${id}"`);
346759
+ }
346584
346760
  }
346585
346761
  return id;
346586
346762
  }
@@ -346590,7 +346766,7 @@ async function updateLocalInstanceStatus(port, workflowName, instanceId, action,
346590
346766
  ...from ? { from } : {},
346591
346767
  ...action === "terminate" && rollback === true ? { rollback: true } : {}
346592
346768
  };
346593
- await fetchLocalResult(
346769
+ return fetchLocalResult(
346594
346770
  port,
346595
346771
  `/workflows/${encodeURIComponent(workflowName)}/instances/${encodeURIComponent(instanceId)}/status`,
346596
346772
  {
@@ -346626,150 +346802,6 @@ var init_local = __esm({
346626
346802
  }
346627
346803
  });
346628
346804
 
346629
- // src/workflows/commands/delete.ts
346630
- var workflowsDeleteCommand;
346631
- var init_delete26 = __esm({
346632
- "src/workflows/commands/delete.ts"() {
346633
- init_import_meta_url();
346634
- init_cfetch2();
346635
- init_create_command();
346636
- init_logger2();
346637
- init_user3();
346638
- init_local();
346639
- workflowsDeleteCommand = createCommand({
346640
- metadata: {
346641
- description: "Delete workflow - when deleting a workflow, it will also delete it's own instances",
346642
- owner: "Product: Workflows",
346643
- status: "stable"
346644
- },
346645
- args: {
346646
- ...localWorkflowArgs,
346647
- name: {
346648
- describe: "Name of the workflow",
346649
- type: "string",
346650
- demandOption: true
346651
- }
346652
- },
346653
- positionalArgs: ["name"],
346654
- async handler(args, { config: config2 }) {
346655
- if (args.local) {
346656
- await fetchLocalResult(
346657
- args.port,
346658
- `/workflows/${encodeURIComponent(args.name)}`,
346659
- { method: "DELETE" }
346660
- );
346661
- logger2.log(
346662
- `\u2705 Workflow "${args.name}" instances removed successfully from local dev session.`
346663
- );
346664
- } else {
346665
- const accountId = await requireAuth(config2);
346666
- await fetchResult2(
346667
- config2,
346668
- `/accounts/${accountId}/workflows/${args.name}`,
346669
- { method: "DELETE" }
346670
- );
346671
- logger2.log(
346672
- `\u2705 Workflow "${args.name}" removed successfully.
346673
- Note that running instances might take a few minutes to be properly terminated.`
346674
- );
346675
- }
346676
- }
346677
- });
346678
- }
346679
- });
346680
-
346681
- // src/workflows/commands/describe.ts
346682
- var workflowsDescribeCommand;
346683
- var init_describe = __esm({
346684
- "src/workflows/commands/describe.ts"() {
346685
- init_import_meta_url();
346686
- init_dist6();
346687
- init_colors();
346688
- init_cfetch2();
346689
- init_create_command();
346690
- init_user3();
346691
- init_render_labelled_values();
346692
- init_local();
346693
- workflowsDescribeCommand = createCommand({
346694
- metadata: {
346695
- description: "Describe Workflow resource",
346696
- owner: "Product: Workflows",
346697
- status: "stable"
346698
- },
346699
- args: {
346700
- ...localWorkflowArgs,
346701
- name: {
346702
- describe: "Name of the workflow",
346703
- type: "string",
346704
- demandOption: true
346705
- }
346706
- },
346707
- positionalArgs: ["name"],
346708
- async handler(args, { config: config2 }) {
346709
- if (args.local) {
346710
- const workflow = await fetchLocalResult(
346711
- args.port,
346712
- `/workflows/${encodeURIComponent(args.name)}`
346713
- );
346714
- logRaw(
346715
- formatLabelledValues({
346716
- Name: workflow.name,
346717
- "Script Name": workflow.script_name,
346718
- "Class Name": workflow.class_name
346719
- })
346720
- );
346721
- if (workflow.instances) {
346722
- logRaw(white2("Instance Status Counts:"));
346723
- logRaw(
346724
- formatLabelledValues(
346725
- Object.fromEntries(
346726
- Object.entries(workflow.instances).map(([status2, count]) => [
346727
- status2,
346728
- String(count)
346729
- ])
346730
- ),
346731
- { indentationCount: 2 }
346732
- )
346733
- );
346734
- }
346735
- } else {
346736
- const accountId = await requireAuth(config2);
346737
- const workflow = await fetchResult2(
346738
- config2,
346739
- `/accounts/${accountId}/workflows/${args.name}`
346740
- );
346741
- const versions2 = await fetchResult2(
346742
- config2,
346743
- `/accounts/${accountId}/workflows/${args.name}/versions`
346744
- );
346745
- const latestVersion = versions2[0];
346746
- logRaw(
346747
- formatLabelledValues({
346748
- Name: workflow.name,
346749
- Id: workflow.id,
346750
- "Script Name": workflow.script_name,
346751
- "Class Name": workflow.class_name,
346752
- "Created On": workflow.created_on,
346753
- "Modified On": workflow.modified_on
346754
- })
346755
- );
346756
- logRaw(white2("Latest Version:"));
346757
- logRaw(
346758
- formatLabelledValues(
346759
- {
346760
- Id: latestVersion.id,
346761
- "Created On": workflow.created_on,
346762
- "Modified On": workflow.modified_on
346763
- },
346764
- { indentationCount: 2 }
346765
- )
346766
- );
346767
- }
346768
- }
346769
- });
346770
- }
346771
- });
346772
-
346773
346805
  // src/workflows/utils.ts
346774
346806
  function withUtcDesignator(value) {
346775
346807
  const timeIndex = value.indexOf("T");
@@ -346828,7 +346860,7 @@ async function updateInstanceStatus(config2, accountId, workflowName, instanceId
346828
346860
  ...from ? { from } : {},
346829
346861
  ...status2 === "terminate" && rollback === true ? { rollback: true } : {}
346830
346862
  };
346831
- await fetchResult2(
346863
+ return fetchResult2(
346832
346864
  config2,
346833
346865
  `/accounts/${accountId}/workflows/${workflowName}/instances/${instanceId}/status`,
346834
346866
  {
@@ -346840,12 +346872,19 @@ async function updateInstanceStatus(config2, accountId, workflowName, instanceId
346840
346872
  }
346841
346873
  );
346842
346874
  }
346843
- var emojifyInstanceStatus, emojifyInstanceTriggerName, emojifyStepType, validateStatus, ISO_DATE_PREFIX_REG_EXP, UTC_DESIGNATOR_REG_EXP;
346875
+ var jsonWorkflowArgs, emojifyInstanceStatus, emojifyInstanceTriggerName, emojifyStepType, validateStatus, ISO_DATE_PREFIX_REG_EXP, UTC_DESIGNATOR_REG_EXP;
346844
346876
  var init_utils22 = __esm({
346845
346877
  "src/workflows/utils.ts"() {
346846
346878
  init_import_meta_url();
346847
346879
  init_src();
346848
346880
  init_cfetch2();
346881
+ jsonWorkflowArgs = {
346882
+ json: {
346883
+ describe: "Output the raw API response as JSON",
346884
+ type: "boolean",
346885
+ default: false
346886
+ }
346887
+ };
346849
346888
  emojifyInstanceStatus = /* @__PURE__ */ __name((status2) => {
346850
346889
  switch (status2) {
346851
346890
  case "complete":
@@ -346933,6 +346972,183 @@ var init_utils22 = __esm({
346933
346972
  }
346934
346973
  });
346935
346974
 
346975
+ // src/workflows/commands/delete.ts
346976
+ var workflowsDeleteCommand;
346977
+ var init_delete26 = __esm({
346978
+ "src/workflows/commands/delete.ts"() {
346979
+ init_import_meta_url();
346980
+ init_cfetch2();
346981
+ init_create_command();
346982
+ init_logger2();
346983
+ init_user3();
346984
+ init_local();
346985
+ init_utils22();
346986
+ workflowsDeleteCommand = createCommand({
346987
+ metadata: {
346988
+ description: "Delete workflow - when deleting a workflow, it will also delete it's own instances",
346989
+ owner: "Product: Workflows",
346990
+ status: "stable"
346991
+ },
346992
+ args: {
346993
+ ...localWorkflowArgs,
346994
+ ...jsonWorkflowArgs,
346995
+ name: {
346996
+ describe: "Name of the workflow",
346997
+ type: "string",
346998
+ demandOption: true
346999
+ }
347000
+ },
347001
+ positionalArgs: ["name"],
347002
+ behaviour: {
347003
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
347004
+ },
347005
+ async handler(args, { config: config2 }) {
347006
+ let result;
347007
+ if (args.local) {
347008
+ result = await fetchLocalResult(
347009
+ args.port,
347010
+ `/workflows/${encodeURIComponent(args.name)}`,
347011
+ { method: "DELETE" }
347012
+ );
347013
+ if (args.json) {
347014
+ logger2.json(result);
347015
+ return;
347016
+ }
347017
+ logger2.log(
347018
+ `\u2705 Workflow "${args.name}" instances removed successfully from local dev session.`
347019
+ );
347020
+ } else {
347021
+ const accountId = await requireAuth(config2);
347022
+ result = await fetchResult2(
347023
+ config2,
347024
+ `/accounts/${accountId}/workflows/${args.name}`,
347025
+ { method: "DELETE" }
347026
+ );
347027
+ if (args.json) {
347028
+ logger2.json(result);
347029
+ return;
347030
+ }
347031
+ logger2.log(
347032
+ `\u2705 Workflow "${args.name}" removed successfully.
347033
+ Note that running instances might take a few minutes to be properly terminated.`
347034
+ );
347035
+ }
347036
+ }
347037
+ });
347038
+ }
347039
+ });
347040
+
347041
+ // src/workflows/commands/describe.ts
347042
+ var workflowsDescribeCommand;
347043
+ var init_describe = __esm({
347044
+ "src/workflows/commands/describe.ts"() {
347045
+ init_import_meta_url();
347046
+ init_dist6();
347047
+ init_colors();
347048
+ init_cfetch2();
347049
+ init_create_command();
347050
+ init_logger2();
347051
+ init_user3();
347052
+ init_render_labelled_values();
347053
+ init_local();
347054
+ init_utils22();
347055
+ workflowsDescribeCommand = createCommand({
347056
+ metadata: {
347057
+ description: "Describe Workflow resource",
347058
+ owner: "Product: Workflows",
347059
+ status: "stable"
347060
+ },
347061
+ args: {
347062
+ ...localWorkflowArgs,
347063
+ ...jsonWorkflowArgs,
347064
+ name: {
347065
+ describe: "Name of the workflow",
347066
+ type: "string",
347067
+ demandOption: true
347068
+ }
347069
+ },
347070
+ positionalArgs: ["name"],
347071
+ behaviour: {
347072
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
347073
+ },
347074
+ async handler(args, { config: config2 }) {
347075
+ if (args.local) {
347076
+ const workflow = await fetchLocalResult(
347077
+ args.port,
347078
+ `/workflows/${encodeURIComponent(args.name)}`
347079
+ );
347080
+ if (args.json) {
347081
+ logger2.json({
347082
+ name: workflow.name,
347083
+ script_name: workflow.script_name,
347084
+ class_name: workflow.class_name,
347085
+ instances: workflow.instances
347086
+ });
347087
+ return;
347088
+ }
347089
+ logRaw(
347090
+ formatLabelledValues({
347091
+ Name: workflow.name,
347092
+ "Script Name": workflow.script_name,
347093
+ "Class Name": workflow.class_name
347094
+ })
347095
+ );
347096
+ if (workflow.instances) {
347097
+ logRaw(white2("Instance Status Counts:"));
347098
+ logRaw(
347099
+ formatLabelledValues(
347100
+ Object.fromEntries(
347101
+ Object.entries(workflow.instances).map(([status2, count]) => [
347102
+ status2,
347103
+ String(count)
347104
+ ])
347105
+ ),
347106
+ { indentationCount: 2 }
347107
+ )
347108
+ );
347109
+ }
347110
+ } else {
347111
+ const accountId = await requireAuth(config2);
347112
+ const workflow = await fetchResult2(
347113
+ config2,
347114
+ `/accounts/${accountId}/workflows/${args.name}`
347115
+ );
347116
+ const versions2 = await fetchResult2(
347117
+ config2,
347118
+ `/accounts/${accountId}/workflows/${args.name}/versions`
347119
+ );
347120
+ const latestVersion = versions2[0];
347121
+ if (args.json) {
347122
+ logger2.json({ ...workflow, latest_version: latestVersion ?? null });
347123
+ return;
347124
+ }
347125
+ logRaw(
347126
+ formatLabelledValues({
347127
+ Name: workflow.name,
347128
+ Id: workflow.id,
347129
+ "Script Name": workflow.script_name,
347130
+ "Class Name": workflow.class_name,
347131
+ "Created On": workflow.created_on,
347132
+ "Modified On": workflow.modified_on
347133
+ })
347134
+ );
347135
+ logRaw(white2("Latest Version:"));
347136
+ logRaw(
347137
+ formatLabelledValues(
347138
+ {
347139
+ Id: latestVersion.id,
347140
+ "Created On": workflow.created_on,
347141
+ "Modified On": workflow.modified_on
347142
+ },
347143
+ { indentationCount: 2 }
347144
+ )
347145
+ );
347146
+ }
347147
+ }
347148
+ });
347149
+ }
347150
+ });
347151
+
346936
347152
  // src/workflows/commands/instances/delete.ts
346937
347153
  var workflowsInstancesDeleteCommand;
346938
347154
  var init_delete27 = __esm({
@@ -346954,6 +347170,7 @@ var init_delete27 = __esm({
346954
347170
  positionalArgs: ["name", "id"],
346955
347171
  args: {
346956
347172
  ...localWorkflowArgs,
347173
+ ...jsonWorkflowArgs,
346957
347174
  name: {
346958
347175
  describe: "Name of the workflow",
346959
347176
  type: "string",
@@ -346969,6 +347186,9 @@ var init_delete27 = __esm({
346969
347186
  type: "string"
346970
347187
  }
346971
347188
  },
347189
+ behaviour: {
347190
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
347191
+ },
346972
347192
  async handler(args, { config: config2 }) {
346973
347193
  let fileIds = [];
346974
347194
  if (args.filename) {
@@ -346999,10 +347219,11 @@ var init_delete27 = __esm({
346999
347219
  let result;
347000
347220
  if (args.local) {
347001
347221
  if (ids.includes("latest")) {
347002
- const latestId = await getLocalInstanceIdFromArgs(args.port, {
347003
- id: "latest",
347004
- name: args.name
347005
- });
347222
+ const latestId = await getLocalInstanceIdFromArgs(
347223
+ args.port,
347224
+ { id: "latest", name: args.name },
347225
+ { quiet: args.json }
347226
+ );
347006
347227
  ids = ids.map((id) => id === "latest" ? latestId : id);
347007
347228
  }
347008
347229
  result = await fetchLocalResult(
@@ -347034,7 +347255,13 @@ var init_delete27 = __esm({
347034
347255
  }
347035
347256
  );
347036
347257
  }
347037
- if (result.deleted.length > 0) {
347258
+ if (args.json) {
347259
+ logger2.json(result);
347260
+ if (result.errors.length === 0) {
347261
+ return;
347262
+ }
347263
+ }
347264
+ if (!args.json && result.deleted.length > 0) {
347038
347265
  logger2.info(
347039
347266
  `\u{1F5D1}\uFE0F Deleted workflow instances from "${args.name}": ${result.deleted.map(({ id }) => `"${id}"`).join(", ")}`
347040
347267
  );
@@ -349987,6 +350214,7 @@ var init_describe2 = __esm({
349987
350214
  positionalArgs: ["name", "id"],
349988
350215
  args: {
349989
350216
  ...localWorkflowArgs,
350217
+ ...jsonWorkflowArgs,
349990
350218
  name: {
349991
350219
  describe: "Name of the workflow",
349992
350220
  type: "string",
@@ -350009,11 +350237,16 @@ var init_describe2 = __esm({
350009
350237
  default: 5e3
350010
350238
  }
350011
350239
  },
350240
+ behaviour: {
350241
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350242
+ },
350012
350243
  async handler(args, { config: config2 }) {
350013
350244
  let id;
350014
350245
  let instance;
350015
350246
  if (args.local) {
350016
- id = await getLocalInstanceIdFromArgs(args.port, args);
350247
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350248
+ quiet: args.json
350249
+ });
350017
350250
  instance = await fetchLocalResult(
350018
350251
  args.port,
350019
350252
  `/workflows/${encodeURIComponent(args.name)}/instances/${encodeURIComponent(id)}`
@@ -350026,6 +350259,10 @@ var init_describe2 = __esm({
350026
350259
  `/accounts/${accountId}/workflows/${args.name}/instances/${id}`
350027
350260
  );
350028
350261
  }
350262
+ if (args.json) {
350263
+ logger2.json({ id, ...instance });
350264
+ return;
350265
+ }
350029
350266
  renderInstanceDetails(args, id, instance);
350030
350267
  }
350031
350268
  });
@@ -350068,6 +350305,7 @@ var init_list35 = __esm({
350068
350305
  positionalArgs: ["name"],
350069
350306
  args: {
350070
350307
  ...localWorkflowArgs,
350308
+ ...jsonWorkflowArgs,
350071
350309
  name: {
350072
350310
  describe: "Name of the workflow",
350073
350311
  type: "string",
@@ -350102,6 +350340,9 @@ var init_list35 = __esm({
350102
350340
  type: "number"
350103
350341
  }
350104
350342
  },
350343
+ behaviour: {
350344
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350345
+ },
350105
350346
  async handler(args, { config: config2 }) {
350106
350347
  const { dateStart, dateEnd } = validateDateRange(
350107
350348
  args.dateStart,
@@ -350127,6 +350368,13 @@ var init_list35 = __esm({
350127
350368
  const queryString = URLParams.toString();
350128
350369
  const path106 = `/workflows/${encodeURIComponent(args.name)}/instances${queryString ? `?${queryString}` : ""}`;
350129
350370
  const instances = await fetchLocalResult(args.port, path106);
350371
+ const sortedInstances = instances.sort(
350372
+ (a7, b10) => args.reverse ? (a7.created_on ?? "").localeCompare(b10.created_on ?? "") : (b10.created_on ?? "").localeCompare(a7.created_on ?? "")
350373
+ );
350374
+ if (args.json) {
350375
+ logger2.json(sortedInstances);
350376
+ return;
350377
+ }
350130
350378
  if (instances.length === 0 && args.page === 1) {
350131
350379
  logger2.warn(
350132
350380
  hasFilters ? `No instances in workflow "${args.name}" matched the provided filters.` : `There are no instances in workflow "${args.name}". You can trigger it with "wrangler workflows trigger ${args.name} --local"`
@@ -350142,9 +350390,6 @@ var init_list35 = __esm({
350142
350390
  logger2.info(
350143
350391
  `Showing ${instances.length} instance${instances.length > 1 ? "s" : ""} from page ${args.page}:`
350144
350392
  );
350145
- const sortedInstances = instances.sort(
350146
- (a7, b10) => args.reverse ? (a7.created_on ?? "").localeCompare(b10.created_on ?? "") : (b10.created_on ?? "").localeCompare(a7.created_on ?? "")
350147
- );
350148
350393
  const prettierInstances = sortedInstances.map((instance) => ({
350149
350394
  "Instance ID": instance.id,
350150
350395
  Created: instance.created_on ? new Date(instance.created_on).toLocaleString() : "N/A",
@@ -350174,6 +350419,13 @@ var init_list35 = __esm({
350174
350419
  void 0,
350175
350420
  URLParams
350176
350421
  );
350422
+ const sortedInstances = instances.sort(
350423
+ (a7, b10) => args.reverse ? a7.created_on.localeCompare(b10.created_on) : b10.created_on.localeCompare(a7.created_on)
350424
+ );
350425
+ if (args.json) {
350426
+ logger2.json(sortedInstances);
350427
+ return;
350428
+ }
350177
350429
  if (instances.length === 0 && args.page === 1) {
350178
350430
  logger2.warn(
350179
350431
  hasFilters ? `No instances in workflow "${args.name}" matched the provided filters.` : `There are no instances in workflow "${args.name}". You can trigger it with "wrangler workflows trigger ${args.name}"`
@@ -350189,9 +350441,7 @@ var init_list35 = __esm({
350189
350441
  logger2.info(
350190
350442
  `Showing ${instances.length} instance${instances.length > 1 ? "s" : ""} from page ${args.page}:`
350191
350443
  );
350192
- const prettierInstances = instances.sort(
350193
- (a7, b10) => args.reverse ? a7.created_on.localeCompare(b10.created_on) : b10.created_on.localeCompare(a7.created_on)
350194
- ).map((instance) => ({
350444
+ const prettierInstances = sortedInstances.map((instance) => ({
350195
350445
  "Instance ID": instance.id,
350196
350446
  Version: instance.version_id,
350197
350447
  Created: new Date(instance.created_on).toLocaleString(),
@@ -350224,6 +350474,7 @@ var init_pause = __esm({
350224
350474
  positionalArgs: ["name", "id"],
350225
350475
  args: {
350226
350476
  ...localWorkflowArgs,
350477
+ ...jsonWorkflowArgs,
350227
350478
  name: {
350228
350479
  describe: "Name of the workflow",
350229
350480
  type: "string",
@@ -350235,15 +350486,36 @@ var init_pause = __esm({
350235
350486
  demandOption: true
350236
350487
  }
350237
350488
  },
350489
+ behaviour: {
350490
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350491
+ },
350238
350492
  async handler(args, { config: config2 }) {
350239
350493
  let id;
350494
+ let result;
350240
350495
  if (args.local) {
350241
- id = await getLocalInstanceIdFromArgs(args.port, args);
350242
- await updateLocalInstanceStatus(args.port, args.name, id, "pause");
350496
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350497
+ quiet: args.json
350498
+ });
350499
+ result = await updateLocalInstanceStatus(
350500
+ args.port,
350501
+ args.name,
350502
+ id,
350503
+ "pause"
350504
+ );
350243
350505
  } else {
350244
350506
  const accountId = await requireAuth(config2);
350245
350507
  id = await getInstanceIdFromArgs(accountId, args, config2);
350246
- await updateInstanceStatus(config2, accountId, args.name, id, "pause");
350508
+ result = await updateInstanceStatus(
350509
+ config2,
350510
+ accountId,
350511
+ args.name,
350512
+ id,
350513
+ "pause"
350514
+ );
350515
+ }
350516
+ if (args.json) {
350517
+ logger2.json(result);
350518
+ return;
350247
350519
  }
350248
350520
  logger2.info(
350249
350521
  `\u23F8\uFE0F The instance "${id}" from ${args.name} was paused successfully`
@@ -350297,6 +350569,7 @@ var init_restart = __esm({
350297
350569
  positionalArgs: ["name", "id"],
350298
350570
  args: {
350299
350571
  ...localWorkflowArgs,
350572
+ ...jsonWorkflowArgs,
350300
350573
  name: {
350301
350574
  describe: "Name of the workflow",
350302
350575
  type: "string",
@@ -350324,12 +350597,18 @@ var init_restart = __esm({
350324
350597
  demandOption: false
350325
350598
  }
350326
350599
  },
350600
+ behaviour: {
350601
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350602
+ },
350327
350603
  async handler(args, { config: config2 }) {
350328
350604
  let id;
350605
+ let result;
350329
350606
  const from = getRestartFrom(args);
350330
350607
  if (args.local) {
350331
- id = await getLocalInstanceIdFromArgs(args.port, args);
350332
- await updateLocalInstanceStatus(
350608
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350609
+ quiet: args.json
350610
+ });
350611
+ result = await updateLocalInstanceStatus(
350333
350612
  args.port,
350334
350613
  args.name,
350335
350614
  id,
@@ -350339,7 +350618,7 @@ var init_restart = __esm({
350339
350618
  } else {
350340
350619
  const accountId = await requireAuth(config2);
350341
350620
  id = await getInstanceIdFromArgs(accountId, args, config2);
350342
- await updateInstanceStatus(
350621
+ result = await updateInstanceStatus(
350343
350622
  config2,
350344
350623
  accountId,
350345
350624
  args.name,
@@ -350348,6 +350627,10 @@ var init_restart = __esm({
350348
350627
  from
350349
350628
  );
350350
350629
  }
350630
+ if (args.json) {
350631
+ logger2.json(result);
350632
+ return;
350633
+ }
350351
350634
  logger2.info(
350352
350635
  `\u{1F977} The instance "${id}" from ${args.name} was restarted successfully`
350353
350636
  );
@@ -350375,6 +350658,7 @@ var init_resume = __esm({
350375
350658
  positionalArgs: ["name", "id"],
350376
350659
  args: {
350377
350660
  ...localWorkflowArgs,
350661
+ ...jsonWorkflowArgs,
350378
350662
  name: {
350379
350663
  describe: "Name of the workflow",
350380
350664
  type: "string",
@@ -350386,15 +350670,36 @@ var init_resume = __esm({
350386
350670
  demandOption: true
350387
350671
  }
350388
350672
  },
350673
+ behaviour: {
350674
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350675
+ },
350389
350676
  async handler(args, { config: config2 }) {
350390
350677
  let id;
350678
+ let result;
350391
350679
  if (args.local) {
350392
- id = await getLocalInstanceIdFromArgs(args.port, args);
350393
- await updateLocalInstanceStatus(args.port, args.name, id, "resume");
350680
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350681
+ quiet: args.json
350682
+ });
350683
+ result = await updateLocalInstanceStatus(
350684
+ args.port,
350685
+ args.name,
350686
+ id,
350687
+ "resume"
350688
+ );
350394
350689
  } else {
350395
350690
  const accountId = await requireAuth(config2);
350396
350691
  id = await getInstanceIdFromArgs(accountId, args, config2);
350397
- await updateInstanceStatus(config2, accountId, args.name, id, "resume");
350692
+ result = await updateInstanceStatus(
350693
+ config2,
350694
+ accountId,
350695
+ args.name,
350696
+ id,
350697
+ "resume"
350698
+ );
350699
+ }
350700
+ if (args.json) {
350701
+ logger2.json(result);
350702
+ return;
350398
350703
  }
350399
350704
  logger2.info(
350400
350705
  `\u{1F504} The instance "${id}" from ${args.name} was resumed successfully`
@@ -350425,6 +350730,7 @@ var init_send_event2 = __esm({
350425
350730
  positionalArgs: ["name", "id"],
350426
350731
  args: {
350427
350732
  ...localWorkflowArgs,
350733
+ ...jsonWorkflowArgs,
350428
350734
  name: {
350429
350735
  describe: "Name of the workflow",
350430
350736
  type: "string",
@@ -350447,6 +350753,9 @@ var init_send_event2 = __esm({
350447
350753
  default: "{}"
350448
350754
  }
350449
350755
  },
350756
+ behaviour: {
350757
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350758
+ },
350450
350759
  async handler(args, { config: config2 }) {
350451
350760
  let payload;
350452
350761
  try {
@@ -350458,9 +350767,12 @@ var init_send_event2 = __esm({
350458
350767
  );
350459
350768
  }
350460
350769
  let id;
350770
+ let result;
350461
350771
  if (args.local) {
350462
- id = await getLocalInstanceIdFromArgs(args.port, args);
350463
- await fetchLocalResult(
350772
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350773
+ quiet: args.json
350774
+ });
350775
+ result = await fetchLocalResult(
350464
350776
  args.port,
350465
350777
  `/workflows/${encodeURIComponent(args.name)}/instances/${encodeURIComponent(id)}/events/${encodeURIComponent(args.type)}`,
350466
350778
  {
@@ -350472,7 +350784,7 @@ var init_send_event2 = __esm({
350472
350784
  } else {
350473
350785
  const accountId = await requireAuth(config2);
350474
350786
  id = await getInstanceIdFromArgs(accountId, args, config2);
350475
- await fetchResult2(
350787
+ result = await fetchResult2(
350476
350788
  config2,
350477
350789
  `/accounts/${accountId}/workflows/${args.name}/instances/${id}/events/${args.type}`,
350478
350790
  {
@@ -350482,6 +350794,10 @@ var init_send_event2 = __esm({
350482
350794
  }
350483
350795
  );
350484
350796
  }
350797
+ if (args.json) {
350798
+ logger2.json(result);
350799
+ return;
350800
+ }
350485
350801
  const payloadInfo = Object.keys(payload).length > 0 ? ` and payload "${args.payload}"` : "";
350486
350802
  logger2.info(
350487
350803
  `\u{1F4E4} The event with type "${args.type}"${payloadInfo} was sent to the instance "${id}" from ${args.name}`
@@ -350510,6 +350826,7 @@ var init_terminate = __esm({
350510
350826
  positionalArgs: ["name", "id"],
350511
350827
  args: {
350512
350828
  ...localWorkflowArgs,
350829
+ ...jsonWorkflowArgs,
350513
350830
  name: {
350514
350831
  describe: "Name of the workflow",
350515
350832
  type: "string",
@@ -350526,11 +350843,17 @@ var init_terminate = __esm({
350526
350843
  default: false
350527
350844
  }
350528
350845
  },
350846
+ behaviour: {
350847
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350848
+ },
350529
350849
  async handler(args, { config: config2 }) {
350530
350850
  let id;
350851
+ let result;
350531
350852
  if (args.local) {
350532
- id = await getLocalInstanceIdFromArgs(args.port, args);
350533
- await updateLocalInstanceStatus(
350853
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350854
+ quiet: args.json
350855
+ });
350856
+ result = await updateLocalInstanceStatus(
350534
350857
  args.port,
350535
350858
  args.name,
350536
350859
  id,
@@ -350541,7 +350864,7 @@ var init_terminate = __esm({
350541
350864
  } else {
350542
350865
  const accountId = await requireAuth(config2);
350543
350866
  id = await getInstanceIdFromArgs(accountId, args, config2);
350544
- await updateInstanceStatus(
350867
+ result = await updateInstanceStatus(
350545
350868
  config2,
350546
350869
  accountId,
350547
350870
  args.name,
@@ -350551,6 +350874,10 @@ var init_terminate = __esm({
350551
350874
  args.rollback
350552
350875
  );
350553
350876
  }
350877
+ if (args.json) {
350878
+ logger2.json(result);
350879
+ return;
350880
+ }
350554
350881
  logger2.info(
350555
350882
  `\u{1F977} The instance "${id}" from ${args.name} was terminated successfully`
350556
350883
  );
@@ -350569,6 +350896,7 @@ var init_terminate_all = __esm({
350569
350896
  init_create_command();
350570
350897
  init_logger2();
350571
350898
  init_user3();
350899
+ init_utils22();
350572
350900
  workflowsInstancesTerminateAllCommand = createCommand({
350573
350901
  metadata: {
350574
350902
  description: "Terminate all workflow instances",
@@ -350578,6 +350906,7 @@ var init_terminate_all = __esm({
350578
350906
  },
350579
350907
  positionalArgs: ["name"],
350580
350908
  args: {
350909
+ ...jsonWorkflowArgs,
350581
350910
  name: {
350582
350911
  describe: "Name of the workflow",
350583
350912
  type: "string",
@@ -350588,6 +350917,9 @@ var init_terminate_all = __esm({
350588
350917
  type: "string"
350589
350918
  }
350590
350919
  },
350920
+ behaviour: {
350921
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350922
+ },
350591
350923
  validateArgs: /* @__PURE__ */ __name((args) => {
350592
350924
  const validStatusToTerminate = [
350593
350925
  "queued",
@@ -350616,6 +350948,10 @@ var init_terminate_all = __esm({
350616
350948
  },
350617
350949
  maybeURLQueryString
350618
350950
  );
350951
+ if (args.json) {
350952
+ logger2.json(result);
350953
+ return;
350954
+ }
350619
350955
  if (result.status === "ok") {
350620
350956
  logger2.info(
350621
350957
  `\u{1F977} A job to terminate instances from Workflow "${args.name}" ${args.status !== void 0 ? `with status "${args.status}"` : ""} has been started. It might take a few minutes to complete.`
@@ -350640,6 +350976,7 @@ var init_list36 = __esm({
350640
350976
  init_logger2();
350641
350977
  init_user3();
350642
350978
  init_local();
350979
+ init_utils22();
350643
350980
  workflowsListCommand = createCommand({
350644
350981
  metadata: {
350645
350982
  description: "List Workflows associated to account",
@@ -350648,6 +350985,7 @@ var init_list36 = __esm({
350648
350985
  },
350649
350986
  args: {
350650
350987
  ...localWorkflowArgs,
350988
+ ...jsonWorkflowArgs,
350651
350989
  page: {
350652
350990
  describe: 'Show a sepecific page from the listing, can configure page size using "per-page"',
350653
350991
  type: "number",
@@ -350658,12 +350996,19 @@ var init_list36 = __esm({
350658
350996
  type: "number"
350659
350997
  }
350660
350998
  },
350999
+ behaviour: {
351000
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
351001
+ },
350661
351002
  async handler(args, { config: config2 }) {
350662
351003
  if (args.local) {
350663
351004
  const workflows = await fetchLocalResult(
350664
351005
  args.port,
350665
351006
  "/workflows"
350666
351007
  );
351008
+ if (args.json) {
351009
+ logger2.json(workflows);
351010
+ return;
351011
+ }
350667
351012
  if (workflows.length === 0) {
350668
351013
  logger2.warn("There are no Workflows in the local dev session");
350669
351014
  return;
@@ -350690,6 +351035,13 @@ var init_list36 = __esm({
350690
351035
  void 0,
350691
351036
  URLParams
350692
351037
  );
351038
+ const sortedWorkflows = workflows.sort(
351039
+ (a7, b10) => b10.created_on.localeCompare(a7.created_on)
351040
+ );
351041
+ if (args.json) {
351042
+ logger2.json(sortedWorkflows);
351043
+ return;
351044
+ }
350693
351045
  if (workflows.length === 0 && args.page === 1) {
350694
351046
  logger2.warn("There are no deployed Workflows in this account");
350695
351047
  return;
@@ -350703,7 +351055,7 @@ var init_list36 = __esm({
350703
351055
  logger2.info(
350704
351056
  `Showing ${workflows.length} workflow${workflows.length > 1 ? "s" : ""} from page ${args.page}:`
350705
351057
  );
350706
- const prettierWorkflows = workflows.sort((a7, b10) => b10.created_on.localeCompare(a7.created_on)).map((workflow) => ({
351058
+ const prettierWorkflows = sortedWorkflows.map((workflow) => ({
350707
351059
  Name: workflow.name,
350708
351060
  "Script name": workflow.script_name,
350709
351061
  "Class name": workflow.class_name,
@@ -350727,6 +351079,7 @@ var init_trigger = __esm({
350727
351079
  init_create_command();
350728
351080
  init_user3();
350729
351081
  init_local();
351082
+ init_utils22();
350730
351083
  workflowsTriggerCommand = createCommand({
350731
351084
  metadata: {
350732
351085
  description: "Trigger a workflow, creating a new instance. Can optionally take a JSON string to pass a parameter into the workflow instance",
@@ -350735,6 +351088,7 @@ var init_trigger = __esm({
350735
351088
  },
350736
351089
  args: {
350737
351090
  ...localWorkflowArgs,
351091
+ ...jsonWorkflowArgs,
350738
351092
  name: {
350739
351093
  describe: "Name of the workflow",
350740
351094
  type: "string",
@@ -350752,6 +351106,9 @@ var init_trigger = __esm({
350752
351106
  }
350753
351107
  },
350754
351108
  positionalArgs: ["name", "params"],
351109
+ behaviour: {
351110
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
351111
+ },
350755
351112
  async handler(args, { config: config2, logger: logger6 }) {
350756
351113
  if (args.params.length != 0) {
350757
351114
  try {
@@ -350779,6 +351136,10 @@ var init_trigger = __esm({
350779
351136
  }
350780
351137
  );
350781
351138
  instanceId = response.id;
351139
+ if (args.json) {
351140
+ logger6.json(response);
351141
+ return;
351142
+ }
350782
351143
  logger6.info(
350783
351144
  `\u{1F680} Workflow instance "${instanceId}" has been triggered successfully`
350784
351145
  );
@@ -350797,6 +351158,10 @@ var init_trigger = __esm({
350797
351158
  }
350798
351159
  );
350799
351160
  instanceId = response.id;
351161
+ if (args.json) {
351162
+ logger6.json(response);
351163
+ return;
351164
+ }
350800
351165
  logger6.info(
350801
351166
  `\u{1F680} Workflow instance "${instanceId}" has been queued successfully`
350802
351167
  );
@@ -354373,6 +354738,12 @@ var init_DevEnv = __esm({
354373
354738
  logger2.debug(`Error in ${event.source}: ${event.reason}
354374
354739
  `, event.cause);
354375
354740
  logger2.debug("=> Error contextual data:", event.data);
354741
+ } else if (event.source === "ProxyController" && event.reason.startsWith("Error inside ProxyWorker")) {
354742
+ const detail = event.cause.message || event.cause.cause?.message || "unknown error";
354743
+ logger2.error(
354744
+ `${event.reason} (the affected request failed; the dev server continues): ${detail}`
354745
+ );
354746
+ logger2.debug("=> Error contextual data:", event.data);
354376
354747
  } else if (event.source === "ConfigController" && event.cause instanceof ParseError) {
354377
354748
  logger2.error(event.cause);
354378
354749
  this.emit("buildFailed", event);
@@ -361380,6 +361751,19 @@ init_esm2();
361380
361751
 
361381
361752
  // src/cli.ts
361382
361753
  init_api5();
361754
+
361755
+ // src/output-stream-errors.ts
361756
+ init_import_meta_url();
361757
+ function registerOutputStreamErrorHandler(stream2) {
361758
+ stream2.on("error", (error53) => {
361759
+ if (error53.code !== "EPIPE") {
361760
+ throw error53;
361761
+ }
361762
+ });
361763
+ }
361764
+ __name(registerOutputStreamErrorHandler, "registerOutputStreamErrorHandler");
361765
+
361766
+ // src/cli.ts
361383
361767
  init_src7();
361384
361768
  init_print_bindings2();
361385
361769
  init_client15();
@@ -361499,6 +361883,8 @@ init_src();
361499
361883
  init_src();
361500
361884
  init_experimental_commands_api();
361501
361885
  if (typeof vitest === "undefined" && __require.main === module) {
361886
+ registerOutputStreamErrorHandler(process12__default.default.stdout);
361887
+ registerOutputStreamErrorHandler(process12__default.default.stderr);
361502
361888
  main(hideBin(process12__default.default.argv)).catch((e10) => {
361503
361889
  const exitCode = e10 instanceof FatalError && e10.code || 1;
361504
361890
  process12__default.default.exit(exitCode);