wrangler 4.128.0 → 4.129.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.
Files changed (2) hide show
  1. package/package.json +15 -15
  2. package/wrangler-dist/cli.js +620 -253
@@ -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-03";
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.0";
60706
60706
  }
60707
60707
  });
60708
60708
 
@@ -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) {
@@ -165545,6 +165633,10 @@ var init_cf = __esm({
165545
165633
  "dns_records:edit",
165546
165634
  "dns_records:read",
165547
165635
  "dns_settings:read",
165636
+ "email_routing:read",
165637
+ "email_routing:write",
165638
+ "email_sending:read",
165639
+ "email_sending:write",
165548
165640
  "firstpartytags:write",
165549
165641
  "images:read",
165550
165642
  "images:write",
@@ -169861,7 +169953,7 @@ var init_dist11 = __esm({
169861
169953
  init_wrapper();
169862
169954
  init_create_worker_upload_form();
169863
169955
  import_undici12 = __toESM(require_undici(), 1);
169864
- version3 = "0.0.18";
169956
+ version3 = "0.0.19";
169865
169957
  NoDefaultValueProvided2 = class extends UserError {
169866
169958
  static {
169867
169959
  __name(this, "NoDefaultValueProvided");
@@ -200475,6 +200567,18 @@ function switchHost(originalUrl, host, zonePreview) {
200475
200567
  url5.hostname = zonePreview ? host ?? url5.hostname : url5.hostname;
200476
200568
  return url5;
200477
200569
  }
200570
+ function getWorkersDevPreviewHost(exchangeUrl, name2) {
200571
+ if (!exchangeUrl) {
200572
+ return void 0;
200573
+ }
200574
+ try {
200575
+ const exchangeHost = new Url.URL(exchangeUrl).hostname;
200576
+ const firstDot = exchangeHost.indexOf(".");
200577
+ return firstDot === -1 ? void 0 : `${name2}${exchangeHost.slice(firstDot)}`;
200578
+ } catch {
200579
+ return void 0;
200580
+ }
200581
+ }
200478
200582
  async function tryExpandToken2(exchangeUrl, ctx, abortSignal) {
200479
200583
  try {
200480
200584
  const switchedExchangeUrl = switchHost(exchangeUrl, ctx.host, !!ctx.zone);
@@ -200515,7 +200619,7 @@ async function tryExpandToken2(exchangeUrl, ctx, abortSignal) {
200515
200619
  }
200516
200620
  async function createPreviewSession2(complianceConfig, account, ctx, abortSignal, name2) {
200517
200621
  const { accountId, apiToken } = account;
200518
- const initUrl = ctx.zone ? `/zones/${ctx.zone}/workers/edge-preview` : `/accounts/${accountId}/workers/subdomain/edge-preview`;
200622
+ const initUrl = ctx.zone ? `/zones/${ctx.zone}/workers/edge-preview` : `/accounts/${accountId}/workers/scripts/${name2}/subdomain/edge-preview`;
200519
200623
  const { token, exchange_url } = await fetchResult2(
200520
200624
  complianceConfig,
200521
200625
  initUrl,
@@ -200526,7 +200630,7 @@ async function createPreviewSession2(complianceConfig, account, ctx, abortSignal
200526
200630
  );
200527
200631
  const previewSessionToken = exchange_url ? await tryExpandToken2(exchange_url, ctx, withTimeout2(abortSignal)) ?? token : token;
200528
200632
  try {
200529
- let host = ctx.host;
200633
+ let host = ctx.host ?? getWorkersDevPreviewHost(ctx.zone ? void 0 : exchange_url, name2);
200530
200634
  if (!host) {
200531
200635
  const subdomain = await getWorkersDevSubdomain(
200532
200636
  complianceConfig,
@@ -200535,7 +200639,7 @@ async function createPreviewSession2(complianceConfig, account, ctx, abortSignal
200535
200639
  abortSignal: withTimeout2(abortSignal)
200536
200640
  }
200537
200641
  );
200538
- host = `${name2 ?? crypto2__default.default.randomUUID()}.${subdomain}`;
200642
+ host = `${name2}.${subdomain}`;
200539
200643
  }
200540
200644
  return {
200541
200645
  value: previewSessionToken,
@@ -200622,6 +200726,7 @@ var init_create_worker_preview = __esm({
200622
200726
  PREVIEW_API_TIMEOUT_MS2 = 3e4;
200623
200727
  __name(withTimeout2, "withTimeout");
200624
200728
  __name(switchHost, "switchHost");
200729
+ __name(getWorkersDevPreviewHost, "getWorkersDevPreviewHost");
200625
200730
  __name(tryExpandToken2, "tryExpandToken");
200626
200731
  __name(createPreviewSession2, "createPreviewSession");
200627
200732
  __name(createPreviewToken, "createPreviewToken");
@@ -212175,14 +212280,14 @@ var init_console = __esm({
212175
212280
  // ../../node_modules/.pnpm/@sentry+utils@7.87.0/node_modules/@sentry/utils/esm/misc.js
212176
212281
  function uuid43() {
212177
212282
  const gbl = GLOBAL_OBJ;
212178
- const crypto8 = gbl.crypto || gbl.msCrypto;
212283
+ const crypto7 = gbl.crypto || gbl.msCrypto;
212179
212284
  let getRandomByte = /* @__PURE__ */ __name(() => Math.random() * 16, "getRandomByte");
212180
212285
  try {
212181
- if (crypto8 && crypto8.randomUUID) {
212182
- return crypto8.randomUUID().replace(/-/g, "");
212286
+ if (crypto7 && crypto7.randomUUID) {
212287
+ return crypto7.randomUUID().replace(/-/g, "");
212183
212288
  }
212184
- if (crypto8 && crypto8.getRandomValues) {
212185
- getRandomByte = /* @__PURE__ */ __name(() => crypto8.getRandomValues(new Uint8Array(1))[0], "getRandomByte");
212289
+ if (crypto7 && crypto7.getRandomValues) {
212290
+ getRandomByte = /* @__PURE__ */ __name(() => crypto7.getRandomValues(new Uint8Array(1))[0], "getRandomByte");
212186
212291
  }
212187
212292
  } catch (_4) {
212188
212293
  }
@@ -222945,12 +223050,12 @@ This action is irreversible and will permanently delete all data in the database
222945
223050
  var require_md5_file = __commonJS({
222946
223051
  "../../node_modules/.pnpm/md5-file@5.0.0/node_modules/md5-file/index.js"(exports2, module2) {
222947
223052
  init_import_meta_url();
222948
- var crypto8 = __require("crypto");
223053
+ var crypto7 = __require("crypto");
222949
223054
  var fs37 = __require("fs");
222950
223055
  var BUFFER_SIZE = 8192;
222951
223056
  function md5FileSync(path106) {
222952
223057
  const fd = fs37.openSync(path106, "r");
222953
- const hash2 = crypto8.createHash("md5");
223058
+ const hash2 = crypto7.createHash("md5");
222954
223059
  const buffer = Buffer.alloc(BUFFER_SIZE);
222955
223060
  try {
222956
223061
  let bytesRead;
@@ -222966,7 +223071,7 @@ var require_md5_file = __commonJS({
222966
223071
  __name(md5FileSync, "md5FileSync");
222967
223072
  function md5File2(path106) {
222968
223073
  return new Promise((resolve35, reject) => {
222969
- const output = crypto8.createHash("md5");
223074
+ const output = crypto7.createHash("md5");
222970
223075
  const input = fs37.createReadStream(path106);
222971
223076
  input.on("error", (err) => {
222972
223077
  reject(err);
@@ -226340,15 +226445,39 @@ In-flight queries and transactions will be cancelled.
226340
226445
  async function deleteSiteNamespaceIfExisting(complianceConfig, scriptName, accountId) {
226341
226446
  const title = `__${scriptName}-workers_sites_assets`;
226342
226447
  const previewTitle = `__${scriptName}-workers_sites_assets_preview`;
226343
- const allNamespaces = await listKVNamespaces2(complianceConfig, accountId);
226448
+ let allNamespaces;
226449
+ try {
226450
+ allNamespaces = await listKVNamespaces2(complianceConfig, accountId);
226451
+ } catch (error53) {
226452
+ if (isPermissionDeniedAPIError2(error53)) {
226453
+ logger2.warn(
226454
+ `Skipping cleanup of legacy Workers Sites asset namespaces for "${scriptName}" because Wrangler does not have permission to list KV namespaces.`
226455
+ );
226456
+ return;
226457
+ }
226458
+ throw error53;
226459
+ }
226344
226460
  const namespacesToDelete = allNamespaces.filter(
226345
226461
  (ns) => ns.title === title || ns.title === previewTitle
226346
226462
  );
226347
226463
  for (const ns of namespacesToDelete) {
226348
- await deleteKVNamespace(complianceConfig, accountId, ns.id);
226464
+ try {
226465
+ await deleteKVNamespace(complianceConfig, accountId, ns.id);
226466
+ } catch (error53) {
226467
+ if (isPermissionDeniedAPIError2(error53)) {
226468
+ logger2.warn(
226469
+ `Skipping cleanup of legacy Workers Sites asset namespace "${ns.title}" because Wrangler does not have permission to delete KV namespaces.`
226470
+ );
226471
+ continue;
226472
+ }
226473
+ throw error53;
226474
+ }
226349
226475
  logger2.log(`\u{1F300} Deleted asset namespace for Workers Site "${ns.title}"`);
226350
226476
  }
226351
226477
  }
226478
+ function isPermissionDeniedAPIError2(error53) {
226479
+ return error53 instanceof APIError && error53.status === 403;
226480
+ }
226352
226481
  function renderScriptName(details) {
226353
226482
  let service;
226354
226483
  let environment;
@@ -226376,14 +226505,26 @@ function isUsedAsTailConsumer(tailProducers) {
226376
226505
  return tailProducers.length > 0;
226377
226506
  }
226378
226507
  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
- );
226508
+ let references;
226509
+ let tailProducers;
226510
+ try {
226511
+ references = await fetchResult2(
226512
+ complianceConfig,
226513
+ `/accounts/${accountId}/workers/scripts/${scriptName}/references`
226514
+ );
226515
+ tailProducers = await fetchResult2(
226516
+ complianceConfig,
226517
+ `/accounts/${accountId}/workers/tails/by-consumer/${scriptName}`
226518
+ );
226519
+ } catch (error53) {
226520
+ if (isPermissionDeniedAPIError2(error53)) {
226521
+ logger2.warn(
226522
+ `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.`
226523
+ );
226524
+ return false;
226525
+ }
226526
+ throw error53;
226527
+ }
226387
226528
  const isDependentService = isUsedAsServiceBinding(references) || isUsedByPagesFunction(references) || isUsedAsDurableObjectNamespace(references, scriptName) || isUsedAsDispatchOutbound(references) || isUsedAsTailConsumer(tailProducers);
226388
226529
  if (!isDependentService) {
226389
226530
  return false;
@@ -226530,6 +226671,7 @@ var init_delete6 = __esm({
226530
226671
  }
226531
226672
  });
226532
226673
  __name(deleteSiteNamespaceIfExisting, "deleteSiteNamespaceIfExisting");
226674
+ __name(isPermissionDeniedAPIError2, "isPermissionDeniedAPIError");
226533
226675
  __name(renderScriptName, "renderScriptName");
226534
226676
  __name(isUsedAsServiceBinding, "isUsedAsServiceBinding");
226535
226677
  __name(isUsedByPagesFunction, "isUsedByPagesFunction");
@@ -330390,9 +330532,17 @@ function displayR2CredentialsInstructions(accountId) {
330390
330532
  source_default.dim(' Create token with "Object Read & Write" permissions\n')
330391
330533
  );
330392
330534
  }
330393
- async function promptCompression() {
330535
+ async function promptJsonCompression() {
330536
+ return select2("Compression:", {
330537
+ choices: [...JSON_COMPRESSION_CHOICES],
330538
+ defaultOption: 0,
330539
+ // uncompressed
330540
+ fallbackOption: 0
330541
+ });
330542
+ }
330543
+ async function promptParquetCompression() {
330394
330544
  return select2("Compression:", {
330395
- choices: [...COMPRESSION_CHOICES],
330545
+ choices: [...PARQUET_COMPRESSION_CHOICES],
330396
330546
  defaultOption: 3,
330397
330547
  // zstd
330398
330548
  fallbackOption: 3
@@ -330911,7 +331061,7 @@ async function setupR2Sink(config2, accountId, setupConfig) {
330911
331061
  defaultOption: 0,
330912
331062
  fallbackOption: 0
330913
331063
  });
330914
- const compression = format9 === "parquet" ? await promptCompression() : void 0;
331064
+ const formatConfig = format9 === "json" ? { type: "json", compression: await promptJsonCompression() } : { type: "parquet", compression: await promptParquetCompression() };
330915
331065
  const rollingPolicy = await promptRollingPolicy();
330916
331066
  const useOAuth = await confirm2(
330917
331067
  "Automatically generate credentials needed to write to your R2 bucket?",
@@ -330939,17 +331089,6 @@ async function setupR2Sink(config2, accountId, setupConfig) {
330939
331089
  displayR2CredentialsInstructions(accountId);
330940
331090
  credentials = await promptR2Credentials(accountId, bucket);
330941
331091
  }
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
331092
  setupConfig.sinkConfig = {
330954
331093
  name: setupConfig.sinkName,
330955
331094
  type: "r2",
@@ -330998,7 +331137,7 @@ async function setupDataCatalogSink(config2, accountId, setupConfig) {
330998
331137
  );
330999
331138
  displayCatalogTokenInstructions(accountId);
331000
331139
  const token = await promptCatalogToken(config2, accountId, bucket);
331001
- const compression = await promptCompression();
331140
+ const compression = await promptParquetCompression();
331002
331141
  const rollingPolicy = await promptRollingPolicy({
331003
331142
  minIntervalSeconds: SINK_DEFAULTS.rolling_policy.min_interval_seconds
331004
331143
  });
@@ -331131,7 +331270,7 @@ async function reviewAndCreateStreamSink(config2, setupConfig) {
331131
331270
  `));
331132
331271
  if (setupConfig.sinkConfig.type === "r2") {
331133
331272
  const format9 = setupConfig.sinkConfig.format?.type || "parquet";
331134
- const compression = setupConfig.sinkConfig.format?.type === "parquet" ? setupConfig.sinkConfig.format.compression || "" : "";
331273
+ const compression = setupConfig.sinkConfig.format?.compression || "";
331135
331274
  logger2.log(` Sink ${setupConfig.sinkName}`);
331136
331275
  logger2.log(
331137
331276
  source_default.dim(
@@ -331258,7 +331397,7 @@ async function createPipelineIfNeeded(config2, setupConfig, created, args) {
331258
331397
  }
331259
331398
  }
331260
331399
  }
331261
- var COMPRESSION_CHOICES, pipelinesSetupCommand;
331400
+ var JSON_COMPRESSION_CHOICES, PARQUET_COMPRESSION_CHOICES, pipelinesSetupCommand;
331262
331401
  var init_setup = __esm({
331263
331402
  "src/pipelines/cli/setup.ts"() {
331264
331403
  init_import_meta_url();
@@ -331283,14 +331422,19 @@ var init_setup = __esm({
331283
331422
  __name(ensureCatalogEnabled, "ensureCatalogEnabled");
331284
331423
  __name(displayCatalogTokenInstructions, "displayCatalogTokenInstructions");
331285
331424
  __name(displayR2CredentialsInstructions, "displayR2CredentialsInstructions");
331286
- COMPRESSION_CHOICES = [
331425
+ JSON_COMPRESSION_CHOICES = [
331426
+ { title: "uncompressed", value: "uncompressed" },
331427
+ { title: "gzip", value: "gzip" }
331428
+ ];
331429
+ PARQUET_COMPRESSION_CHOICES = [
331287
331430
  { title: "uncompressed", value: "uncompressed" },
331288
331431
  { title: "snappy", value: "snappy" },
331289
331432
  { title: "gzip", value: "gzip" },
331290
331433
  { title: "zstd", value: "zstd" },
331291
331434
  { title: "lz4", value: "lz4" }
331292
331435
  ];
331293
- __name(promptCompression, "promptCompression");
331436
+ __name(promptJsonCompression, "promptJsonCompression");
331437
+ __name(promptParquetCompression, "promptParquetCompression");
331294
331438
  __name(promptRollingPolicy, "promptRollingPolicy");
331295
331439
  __name(promptCatalogToken, "promptCatalogToken");
331296
331440
  __name(promptR2Credentials, "promptR2Credentials");
@@ -331399,7 +331543,11 @@ ${title}:`);
331399
331543
  const format9 = {
331400
331544
  Type: sink.format.type
331401
331545
  };
331402
- if (sink.format.type === "parquet") {
331546
+ if (sink.format.type === "json") {
331547
+ if (sink.format.compression) {
331548
+ format9.Compression = sink.format.compression;
331549
+ }
331550
+ } else {
331403
331551
  const defaultParquet = SINK_DEFAULTS.format.type === "parquet" ? SINK_DEFAULTS.format : null;
331404
331552
  if (defaultParquet) {
331405
331553
  const compression = sink.format.compression || defaultParquet.compression;
@@ -331439,6 +331587,12 @@ var init_utils19 = __esm({
331439
331587
  });
331440
331588
 
331441
331589
  // src/pipelines/cli/sinks/create.ts
331590
+ function isJsonCompression(compression) {
331591
+ return compression === "uncompressed" || compression === "gzip";
331592
+ }
331593
+ function isParquetCompression(compression) {
331594
+ return compression === "uncompressed" || compression === "snappy" || compression === "gzip" || compression === "zstd" || compression === "lz4";
331595
+ }
331442
331596
  function parseSinkType(type) {
331443
331597
  if (type === "r2" || type === "r2-data-catalog") {
331444
331598
  return type === "r2-data-catalog" ? "r2_data_catalog" : "r2";
@@ -331461,6 +331615,8 @@ var init_create15 = __esm({
331461
331615
  init_pipelines2();
331462
331616
  init_validate5();
331463
331617
  init_utils19();
331618
+ __name(isJsonCompression, "isJsonCompression");
331619
+ __name(isParquetCompression, "isParquetCompression");
331464
331620
  __name(parseSinkType, "parseSinkType");
331465
331621
  pipelinesSinksCreateCommand = createCommand({
331466
331622
  metadata: {
@@ -331493,10 +331649,9 @@ var init_create15 = __esm({
331493
331649
  default: SINK_DEFAULTS.format.type
331494
331650
  },
331495
331651
  compression: {
331496
- describe: "Compression method (parquet only)",
331652
+ describe: "Compression method (JSON supports uncompressed and gzip; Parquet defaults to zstd)",
331497
331653
  type: "string",
331498
- choices: ["uncompressed", "snappy", "gzip", "zstd", "lz4"],
331499
- default: SINK_DEFAULTS.format.compression
331654
+ choices: ["uncompressed", "snappy", "gzip", "zstd", "lz4"]
331500
331655
  },
331501
331656
  "target-row-group-size": {
331502
331657
  describe: "Target row group size for parquet format",
@@ -331585,6 +331740,24 @@ var init_create15 = __esm({
331585
331740
  );
331586
331741
  }
331587
331742
  }
331743
+ if (args.format === "json") {
331744
+ if (args.compression && !isJsonCompression(args.compression)) {
331745
+ throw new CommandLineArgsError(
331746
+ "JSON sinks only support 'uncompressed' or 'gzip' compression",
331747
+ {
331748
+ telemetryMessage: "pipelines sinks create invalid json compression"
331749
+ }
331750
+ );
331751
+ }
331752
+ if (args.targetRowGroupSize) {
331753
+ throw new CommandLineArgsError(
331754
+ "--target-row-group-size is only supported for Parquet sinks",
331755
+ {
331756
+ telemetryMessage: "pipelines sinks create invalid json row group size"
331757
+ }
331758
+ );
331759
+ }
331760
+ }
331588
331761
  }, "validateArgs"),
331589
331762
  async handler(args, { config: config2 }) {
331590
331763
  const accountId = await requireAuth(config2);
@@ -331600,13 +331773,16 @@ var init_create15 = __esm({
331600
331773
  if (args.format || args.compression || args.targetRowGroupSize) {
331601
331774
  let formatConfig;
331602
331775
  if (args.format === "json") {
331603
- formatConfig = { type: "json" };
331776
+ formatConfig = {
331777
+ type: "json",
331778
+ ...isJsonCompression(args.compression) && {
331779
+ compression: args.compression
331780
+ }
331781
+ };
331604
331782
  } else {
331605
331783
  formatConfig = {
331606
331784
  type: "parquet",
331607
- ...args.compression && {
331608
- compression: args.compression
331609
- },
331785
+ compression: isParquetCompression(args.compression) ? args.compression : SINK_DEFAULTS.format.compression,
331610
331786
  ...args.targetRowGroupSize && {
331611
331787
  row_group_bytes: parseInt(args.targetRowGroupSize.replace(/MB$/i, "")) * 1024 * 1024
331612
331788
  }
@@ -346567,7 +346743,7 @@ async function fetchLocalResult(port, path106, init4) {
346567
346743
  }
346568
346744
  return json2.result;
346569
346745
  }
346570
- async function getLocalInstanceIdFromArgs(port, args) {
346746
+ async function getLocalInstanceIdFromArgs(port, args, options = {}) {
346571
346747
  let id = args.id;
346572
346748
  if (id === "latest") {
346573
346749
  const instances = await fetchLocalResult(port, `/workflows/${encodeURIComponent(args.name)}/instances`);
@@ -346580,7 +346756,9 @@ async function getLocalInstanceIdFromArgs(port, args) {
346580
346756
  (a7, b10) => (b10.created_on ?? "").localeCompare(a7.created_on ?? "")
346581
346757
  );
346582
346758
  id = sorted[0].id;
346583
- logger2.info(`Latest instance is "${id}"`);
346759
+ if (!options.quiet) {
346760
+ logger2.info(`Latest instance is "${id}"`);
346761
+ }
346584
346762
  }
346585
346763
  return id;
346586
346764
  }
@@ -346590,7 +346768,7 @@ async function updateLocalInstanceStatus(port, workflowName, instanceId, action,
346590
346768
  ...from ? { from } : {},
346591
346769
  ...action === "terminate" && rollback === true ? { rollback: true } : {}
346592
346770
  };
346593
- await fetchLocalResult(
346771
+ return fetchLocalResult(
346594
346772
  port,
346595
346773
  `/workflows/${encodeURIComponent(workflowName)}/instances/${encodeURIComponent(instanceId)}/status`,
346596
346774
  {
@@ -346626,150 +346804,6 @@ var init_local = __esm({
346626
346804
  }
346627
346805
  });
346628
346806
 
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
346807
  // src/workflows/utils.ts
346774
346808
  function withUtcDesignator(value) {
346775
346809
  const timeIndex = value.indexOf("T");
@@ -346828,7 +346862,7 @@ async function updateInstanceStatus(config2, accountId, workflowName, instanceId
346828
346862
  ...from ? { from } : {},
346829
346863
  ...status2 === "terminate" && rollback === true ? { rollback: true } : {}
346830
346864
  };
346831
- await fetchResult2(
346865
+ return fetchResult2(
346832
346866
  config2,
346833
346867
  `/accounts/${accountId}/workflows/${workflowName}/instances/${instanceId}/status`,
346834
346868
  {
@@ -346840,12 +346874,19 @@ async function updateInstanceStatus(config2, accountId, workflowName, instanceId
346840
346874
  }
346841
346875
  );
346842
346876
  }
346843
- var emojifyInstanceStatus, emojifyInstanceTriggerName, emojifyStepType, validateStatus, ISO_DATE_PREFIX_REG_EXP, UTC_DESIGNATOR_REG_EXP;
346877
+ var jsonWorkflowArgs, emojifyInstanceStatus, emojifyInstanceTriggerName, emojifyStepType, validateStatus, ISO_DATE_PREFIX_REG_EXP, UTC_DESIGNATOR_REG_EXP;
346844
346878
  var init_utils22 = __esm({
346845
346879
  "src/workflows/utils.ts"() {
346846
346880
  init_import_meta_url();
346847
346881
  init_src();
346848
346882
  init_cfetch2();
346883
+ jsonWorkflowArgs = {
346884
+ json: {
346885
+ describe: "Output the raw API response as JSON",
346886
+ type: "boolean",
346887
+ default: false
346888
+ }
346889
+ };
346849
346890
  emojifyInstanceStatus = /* @__PURE__ */ __name((status2) => {
346850
346891
  switch (status2) {
346851
346892
  case "complete":
@@ -346933,6 +346974,183 @@ var init_utils22 = __esm({
346933
346974
  }
346934
346975
  });
346935
346976
 
346977
+ // src/workflows/commands/delete.ts
346978
+ var workflowsDeleteCommand;
346979
+ var init_delete26 = __esm({
346980
+ "src/workflows/commands/delete.ts"() {
346981
+ init_import_meta_url();
346982
+ init_cfetch2();
346983
+ init_create_command();
346984
+ init_logger2();
346985
+ init_user3();
346986
+ init_local();
346987
+ init_utils22();
346988
+ workflowsDeleteCommand = createCommand({
346989
+ metadata: {
346990
+ description: "Delete workflow - when deleting a workflow, it will also delete it's own instances",
346991
+ owner: "Product: Workflows",
346992
+ status: "stable"
346993
+ },
346994
+ args: {
346995
+ ...localWorkflowArgs,
346996
+ ...jsonWorkflowArgs,
346997
+ name: {
346998
+ describe: "Name of the workflow",
346999
+ type: "string",
347000
+ demandOption: true
347001
+ }
347002
+ },
347003
+ positionalArgs: ["name"],
347004
+ behaviour: {
347005
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
347006
+ },
347007
+ async handler(args, { config: config2 }) {
347008
+ let result;
347009
+ if (args.local) {
347010
+ result = await fetchLocalResult(
347011
+ args.port,
347012
+ `/workflows/${encodeURIComponent(args.name)}`,
347013
+ { method: "DELETE" }
347014
+ );
347015
+ if (args.json) {
347016
+ logger2.json(result);
347017
+ return;
347018
+ }
347019
+ logger2.log(
347020
+ `\u2705 Workflow "${args.name}" instances removed successfully from local dev session.`
347021
+ );
347022
+ } else {
347023
+ const accountId = await requireAuth(config2);
347024
+ result = await fetchResult2(
347025
+ config2,
347026
+ `/accounts/${accountId}/workflows/${args.name}`,
347027
+ { method: "DELETE" }
347028
+ );
347029
+ if (args.json) {
347030
+ logger2.json(result);
347031
+ return;
347032
+ }
347033
+ logger2.log(
347034
+ `\u2705 Workflow "${args.name}" removed successfully.
347035
+ Note that running instances might take a few minutes to be properly terminated.`
347036
+ );
347037
+ }
347038
+ }
347039
+ });
347040
+ }
347041
+ });
347042
+
347043
+ // src/workflows/commands/describe.ts
347044
+ var workflowsDescribeCommand;
347045
+ var init_describe = __esm({
347046
+ "src/workflows/commands/describe.ts"() {
347047
+ init_import_meta_url();
347048
+ init_dist6();
347049
+ init_colors();
347050
+ init_cfetch2();
347051
+ init_create_command();
347052
+ init_logger2();
347053
+ init_user3();
347054
+ init_render_labelled_values();
347055
+ init_local();
347056
+ init_utils22();
347057
+ workflowsDescribeCommand = createCommand({
347058
+ metadata: {
347059
+ description: "Describe Workflow resource",
347060
+ owner: "Product: Workflows",
347061
+ status: "stable"
347062
+ },
347063
+ args: {
347064
+ ...localWorkflowArgs,
347065
+ ...jsonWorkflowArgs,
347066
+ name: {
347067
+ describe: "Name of the workflow",
347068
+ type: "string",
347069
+ demandOption: true
347070
+ }
347071
+ },
347072
+ positionalArgs: ["name"],
347073
+ behaviour: {
347074
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
347075
+ },
347076
+ async handler(args, { config: config2 }) {
347077
+ if (args.local) {
347078
+ const workflow = await fetchLocalResult(
347079
+ args.port,
347080
+ `/workflows/${encodeURIComponent(args.name)}`
347081
+ );
347082
+ if (args.json) {
347083
+ logger2.json({
347084
+ name: workflow.name,
347085
+ script_name: workflow.script_name,
347086
+ class_name: workflow.class_name,
347087
+ instances: workflow.instances
347088
+ });
347089
+ return;
347090
+ }
347091
+ logRaw(
347092
+ formatLabelledValues({
347093
+ Name: workflow.name,
347094
+ "Script Name": workflow.script_name,
347095
+ "Class Name": workflow.class_name
347096
+ })
347097
+ );
347098
+ if (workflow.instances) {
347099
+ logRaw(white2("Instance Status Counts:"));
347100
+ logRaw(
347101
+ formatLabelledValues(
347102
+ Object.fromEntries(
347103
+ Object.entries(workflow.instances).map(([status2, count]) => [
347104
+ status2,
347105
+ String(count)
347106
+ ])
347107
+ ),
347108
+ { indentationCount: 2 }
347109
+ )
347110
+ );
347111
+ }
347112
+ } else {
347113
+ const accountId = await requireAuth(config2);
347114
+ const workflow = await fetchResult2(
347115
+ config2,
347116
+ `/accounts/${accountId}/workflows/${args.name}`
347117
+ );
347118
+ const versions2 = await fetchResult2(
347119
+ config2,
347120
+ `/accounts/${accountId}/workflows/${args.name}/versions`
347121
+ );
347122
+ const latestVersion = versions2[0];
347123
+ if (args.json) {
347124
+ logger2.json({ ...workflow, latest_version: latestVersion ?? null });
347125
+ return;
347126
+ }
347127
+ logRaw(
347128
+ formatLabelledValues({
347129
+ Name: workflow.name,
347130
+ Id: workflow.id,
347131
+ "Script Name": workflow.script_name,
347132
+ "Class Name": workflow.class_name,
347133
+ "Created On": workflow.created_on,
347134
+ "Modified On": workflow.modified_on
347135
+ })
347136
+ );
347137
+ logRaw(white2("Latest Version:"));
347138
+ logRaw(
347139
+ formatLabelledValues(
347140
+ {
347141
+ Id: latestVersion.id,
347142
+ "Created On": workflow.created_on,
347143
+ "Modified On": workflow.modified_on
347144
+ },
347145
+ { indentationCount: 2 }
347146
+ )
347147
+ );
347148
+ }
347149
+ }
347150
+ });
347151
+ }
347152
+ });
347153
+
346936
347154
  // src/workflows/commands/instances/delete.ts
346937
347155
  var workflowsInstancesDeleteCommand;
346938
347156
  var init_delete27 = __esm({
@@ -346954,6 +347172,7 @@ var init_delete27 = __esm({
346954
347172
  positionalArgs: ["name", "id"],
346955
347173
  args: {
346956
347174
  ...localWorkflowArgs,
347175
+ ...jsonWorkflowArgs,
346957
347176
  name: {
346958
347177
  describe: "Name of the workflow",
346959
347178
  type: "string",
@@ -346969,6 +347188,9 @@ var init_delete27 = __esm({
346969
347188
  type: "string"
346970
347189
  }
346971
347190
  },
347191
+ behaviour: {
347192
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
347193
+ },
346972
347194
  async handler(args, { config: config2 }) {
346973
347195
  let fileIds = [];
346974
347196
  if (args.filename) {
@@ -346999,10 +347221,11 @@ var init_delete27 = __esm({
346999
347221
  let result;
347000
347222
  if (args.local) {
347001
347223
  if (ids.includes("latest")) {
347002
- const latestId = await getLocalInstanceIdFromArgs(args.port, {
347003
- id: "latest",
347004
- name: args.name
347005
- });
347224
+ const latestId = await getLocalInstanceIdFromArgs(
347225
+ args.port,
347226
+ { id: "latest", name: args.name },
347227
+ { quiet: args.json }
347228
+ );
347006
347229
  ids = ids.map((id) => id === "latest" ? latestId : id);
347007
347230
  }
347008
347231
  result = await fetchLocalResult(
@@ -347034,7 +347257,13 @@ var init_delete27 = __esm({
347034
347257
  }
347035
347258
  );
347036
347259
  }
347037
- if (result.deleted.length > 0) {
347260
+ if (args.json) {
347261
+ logger2.json(result);
347262
+ if (result.errors.length === 0) {
347263
+ return;
347264
+ }
347265
+ }
347266
+ if (!args.json && result.deleted.length > 0) {
347038
347267
  logger2.info(
347039
347268
  `\u{1F5D1}\uFE0F Deleted workflow instances from "${args.name}": ${result.deleted.map(({ id }) => `"${id}"`).join(", ")}`
347040
347269
  );
@@ -349987,6 +350216,7 @@ var init_describe2 = __esm({
349987
350216
  positionalArgs: ["name", "id"],
349988
350217
  args: {
349989
350218
  ...localWorkflowArgs,
350219
+ ...jsonWorkflowArgs,
349990
350220
  name: {
349991
350221
  describe: "Name of the workflow",
349992
350222
  type: "string",
@@ -350009,11 +350239,16 @@ var init_describe2 = __esm({
350009
350239
  default: 5e3
350010
350240
  }
350011
350241
  },
350242
+ behaviour: {
350243
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350244
+ },
350012
350245
  async handler(args, { config: config2 }) {
350013
350246
  let id;
350014
350247
  let instance;
350015
350248
  if (args.local) {
350016
- id = await getLocalInstanceIdFromArgs(args.port, args);
350249
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350250
+ quiet: args.json
350251
+ });
350017
350252
  instance = await fetchLocalResult(
350018
350253
  args.port,
350019
350254
  `/workflows/${encodeURIComponent(args.name)}/instances/${encodeURIComponent(id)}`
@@ -350026,6 +350261,10 @@ var init_describe2 = __esm({
350026
350261
  `/accounts/${accountId}/workflows/${args.name}/instances/${id}`
350027
350262
  );
350028
350263
  }
350264
+ if (args.json) {
350265
+ logger2.json({ id, ...instance });
350266
+ return;
350267
+ }
350029
350268
  renderInstanceDetails(args, id, instance);
350030
350269
  }
350031
350270
  });
@@ -350068,6 +350307,7 @@ var init_list35 = __esm({
350068
350307
  positionalArgs: ["name"],
350069
350308
  args: {
350070
350309
  ...localWorkflowArgs,
350310
+ ...jsonWorkflowArgs,
350071
350311
  name: {
350072
350312
  describe: "Name of the workflow",
350073
350313
  type: "string",
@@ -350102,6 +350342,9 @@ var init_list35 = __esm({
350102
350342
  type: "number"
350103
350343
  }
350104
350344
  },
350345
+ behaviour: {
350346
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350347
+ },
350105
350348
  async handler(args, { config: config2 }) {
350106
350349
  const { dateStart, dateEnd } = validateDateRange(
350107
350350
  args.dateStart,
@@ -350127,6 +350370,13 @@ var init_list35 = __esm({
350127
350370
  const queryString = URLParams.toString();
350128
350371
  const path106 = `/workflows/${encodeURIComponent(args.name)}/instances${queryString ? `?${queryString}` : ""}`;
350129
350372
  const instances = await fetchLocalResult(args.port, path106);
350373
+ const sortedInstances = instances.sort(
350374
+ (a7, b10) => args.reverse ? (a7.created_on ?? "").localeCompare(b10.created_on ?? "") : (b10.created_on ?? "").localeCompare(a7.created_on ?? "")
350375
+ );
350376
+ if (args.json) {
350377
+ logger2.json(sortedInstances);
350378
+ return;
350379
+ }
350130
350380
  if (instances.length === 0 && args.page === 1) {
350131
350381
  logger2.warn(
350132
350382
  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 +350392,6 @@ var init_list35 = __esm({
350142
350392
  logger2.info(
350143
350393
  `Showing ${instances.length} instance${instances.length > 1 ? "s" : ""} from page ${args.page}:`
350144
350394
  );
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
350395
  const prettierInstances = sortedInstances.map((instance) => ({
350149
350396
  "Instance ID": instance.id,
350150
350397
  Created: instance.created_on ? new Date(instance.created_on).toLocaleString() : "N/A",
@@ -350174,6 +350421,13 @@ var init_list35 = __esm({
350174
350421
  void 0,
350175
350422
  URLParams
350176
350423
  );
350424
+ const sortedInstances = instances.sort(
350425
+ (a7, b10) => args.reverse ? a7.created_on.localeCompare(b10.created_on) : b10.created_on.localeCompare(a7.created_on)
350426
+ );
350427
+ if (args.json) {
350428
+ logger2.json(sortedInstances);
350429
+ return;
350430
+ }
350177
350431
  if (instances.length === 0 && args.page === 1) {
350178
350432
  logger2.warn(
350179
350433
  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 +350443,7 @@ var init_list35 = __esm({
350189
350443
  logger2.info(
350190
350444
  `Showing ${instances.length} instance${instances.length > 1 ? "s" : ""} from page ${args.page}:`
350191
350445
  );
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) => ({
350446
+ const prettierInstances = sortedInstances.map((instance) => ({
350195
350447
  "Instance ID": instance.id,
350196
350448
  Version: instance.version_id,
350197
350449
  Created: new Date(instance.created_on).toLocaleString(),
@@ -350224,6 +350476,7 @@ var init_pause = __esm({
350224
350476
  positionalArgs: ["name", "id"],
350225
350477
  args: {
350226
350478
  ...localWorkflowArgs,
350479
+ ...jsonWorkflowArgs,
350227
350480
  name: {
350228
350481
  describe: "Name of the workflow",
350229
350482
  type: "string",
@@ -350235,15 +350488,36 @@ var init_pause = __esm({
350235
350488
  demandOption: true
350236
350489
  }
350237
350490
  },
350491
+ behaviour: {
350492
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350493
+ },
350238
350494
  async handler(args, { config: config2 }) {
350239
350495
  let id;
350496
+ let result;
350240
350497
  if (args.local) {
350241
- id = await getLocalInstanceIdFromArgs(args.port, args);
350242
- await updateLocalInstanceStatus(args.port, args.name, id, "pause");
350498
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350499
+ quiet: args.json
350500
+ });
350501
+ result = await updateLocalInstanceStatus(
350502
+ args.port,
350503
+ args.name,
350504
+ id,
350505
+ "pause"
350506
+ );
350243
350507
  } else {
350244
350508
  const accountId = await requireAuth(config2);
350245
350509
  id = await getInstanceIdFromArgs(accountId, args, config2);
350246
- await updateInstanceStatus(config2, accountId, args.name, id, "pause");
350510
+ result = await updateInstanceStatus(
350511
+ config2,
350512
+ accountId,
350513
+ args.name,
350514
+ id,
350515
+ "pause"
350516
+ );
350517
+ }
350518
+ if (args.json) {
350519
+ logger2.json(result);
350520
+ return;
350247
350521
  }
350248
350522
  logger2.info(
350249
350523
  `\u23F8\uFE0F The instance "${id}" from ${args.name} was paused successfully`
@@ -350297,6 +350571,7 @@ var init_restart = __esm({
350297
350571
  positionalArgs: ["name", "id"],
350298
350572
  args: {
350299
350573
  ...localWorkflowArgs,
350574
+ ...jsonWorkflowArgs,
350300
350575
  name: {
350301
350576
  describe: "Name of the workflow",
350302
350577
  type: "string",
@@ -350324,12 +350599,18 @@ var init_restart = __esm({
350324
350599
  demandOption: false
350325
350600
  }
350326
350601
  },
350602
+ behaviour: {
350603
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350604
+ },
350327
350605
  async handler(args, { config: config2 }) {
350328
350606
  let id;
350607
+ let result;
350329
350608
  const from = getRestartFrom(args);
350330
350609
  if (args.local) {
350331
- id = await getLocalInstanceIdFromArgs(args.port, args);
350332
- await updateLocalInstanceStatus(
350610
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350611
+ quiet: args.json
350612
+ });
350613
+ result = await updateLocalInstanceStatus(
350333
350614
  args.port,
350334
350615
  args.name,
350335
350616
  id,
@@ -350339,7 +350620,7 @@ var init_restart = __esm({
350339
350620
  } else {
350340
350621
  const accountId = await requireAuth(config2);
350341
350622
  id = await getInstanceIdFromArgs(accountId, args, config2);
350342
- await updateInstanceStatus(
350623
+ result = await updateInstanceStatus(
350343
350624
  config2,
350344
350625
  accountId,
350345
350626
  args.name,
@@ -350348,6 +350629,10 @@ var init_restart = __esm({
350348
350629
  from
350349
350630
  );
350350
350631
  }
350632
+ if (args.json) {
350633
+ logger2.json(result);
350634
+ return;
350635
+ }
350351
350636
  logger2.info(
350352
350637
  `\u{1F977} The instance "${id}" from ${args.name} was restarted successfully`
350353
350638
  );
@@ -350375,6 +350660,7 @@ var init_resume = __esm({
350375
350660
  positionalArgs: ["name", "id"],
350376
350661
  args: {
350377
350662
  ...localWorkflowArgs,
350663
+ ...jsonWorkflowArgs,
350378
350664
  name: {
350379
350665
  describe: "Name of the workflow",
350380
350666
  type: "string",
@@ -350386,15 +350672,36 @@ var init_resume = __esm({
350386
350672
  demandOption: true
350387
350673
  }
350388
350674
  },
350675
+ behaviour: {
350676
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350677
+ },
350389
350678
  async handler(args, { config: config2 }) {
350390
350679
  let id;
350680
+ let result;
350391
350681
  if (args.local) {
350392
- id = await getLocalInstanceIdFromArgs(args.port, args);
350393
- await updateLocalInstanceStatus(args.port, args.name, id, "resume");
350682
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350683
+ quiet: args.json
350684
+ });
350685
+ result = await updateLocalInstanceStatus(
350686
+ args.port,
350687
+ args.name,
350688
+ id,
350689
+ "resume"
350690
+ );
350394
350691
  } else {
350395
350692
  const accountId = await requireAuth(config2);
350396
350693
  id = await getInstanceIdFromArgs(accountId, args, config2);
350397
- await updateInstanceStatus(config2, accountId, args.name, id, "resume");
350694
+ result = await updateInstanceStatus(
350695
+ config2,
350696
+ accountId,
350697
+ args.name,
350698
+ id,
350699
+ "resume"
350700
+ );
350701
+ }
350702
+ if (args.json) {
350703
+ logger2.json(result);
350704
+ return;
350398
350705
  }
350399
350706
  logger2.info(
350400
350707
  `\u{1F504} The instance "${id}" from ${args.name} was resumed successfully`
@@ -350425,6 +350732,7 @@ var init_send_event2 = __esm({
350425
350732
  positionalArgs: ["name", "id"],
350426
350733
  args: {
350427
350734
  ...localWorkflowArgs,
350735
+ ...jsonWorkflowArgs,
350428
350736
  name: {
350429
350737
  describe: "Name of the workflow",
350430
350738
  type: "string",
@@ -350447,6 +350755,9 @@ var init_send_event2 = __esm({
350447
350755
  default: "{}"
350448
350756
  }
350449
350757
  },
350758
+ behaviour: {
350759
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350760
+ },
350450
350761
  async handler(args, { config: config2 }) {
350451
350762
  let payload;
350452
350763
  try {
@@ -350458,9 +350769,12 @@ var init_send_event2 = __esm({
350458
350769
  );
350459
350770
  }
350460
350771
  let id;
350772
+ let result;
350461
350773
  if (args.local) {
350462
- id = await getLocalInstanceIdFromArgs(args.port, args);
350463
- await fetchLocalResult(
350774
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350775
+ quiet: args.json
350776
+ });
350777
+ result = await fetchLocalResult(
350464
350778
  args.port,
350465
350779
  `/workflows/${encodeURIComponent(args.name)}/instances/${encodeURIComponent(id)}/events/${encodeURIComponent(args.type)}`,
350466
350780
  {
@@ -350472,7 +350786,7 @@ var init_send_event2 = __esm({
350472
350786
  } else {
350473
350787
  const accountId = await requireAuth(config2);
350474
350788
  id = await getInstanceIdFromArgs(accountId, args, config2);
350475
- await fetchResult2(
350789
+ result = await fetchResult2(
350476
350790
  config2,
350477
350791
  `/accounts/${accountId}/workflows/${args.name}/instances/${id}/events/${args.type}`,
350478
350792
  {
@@ -350482,6 +350796,10 @@ var init_send_event2 = __esm({
350482
350796
  }
350483
350797
  );
350484
350798
  }
350799
+ if (args.json) {
350800
+ logger2.json(result);
350801
+ return;
350802
+ }
350485
350803
  const payloadInfo = Object.keys(payload).length > 0 ? ` and payload "${args.payload}"` : "";
350486
350804
  logger2.info(
350487
350805
  `\u{1F4E4} The event with type "${args.type}"${payloadInfo} was sent to the instance "${id}" from ${args.name}`
@@ -350510,6 +350828,7 @@ var init_terminate = __esm({
350510
350828
  positionalArgs: ["name", "id"],
350511
350829
  args: {
350512
350830
  ...localWorkflowArgs,
350831
+ ...jsonWorkflowArgs,
350513
350832
  name: {
350514
350833
  describe: "Name of the workflow",
350515
350834
  type: "string",
@@ -350526,11 +350845,17 @@ var init_terminate = __esm({
350526
350845
  default: false
350527
350846
  }
350528
350847
  },
350848
+ behaviour: {
350849
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350850
+ },
350529
350851
  async handler(args, { config: config2 }) {
350530
350852
  let id;
350853
+ let result;
350531
350854
  if (args.local) {
350532
- id = await getLocalInstanceIdFromArgs(args.port, args);
350533
- await updateLocalInstanceStatus(
350855
+ id = await getLocalInstanceIdFromArgs(args.port, args, {
350856
+ quiet: args.json
350857
+ });
350858
+ result = await updateLocalInstanceStatus(
350534
350859
  args.port,
350535
350860
  args.name,
350536
350861
  id,
@@ -350541,7 +350866,7 @@ var init_terminate = __esm({
350541
350866
  } else {
350542
350867
  const accountId = await requireAuth(config2);
350543
350868
  id = await getInstanceIdFromArgs(accountId, args, config2);
350544
- await updateInstanceStatus(
350869
+ result = await updateInstanceStatus(
350545
350870
  config2,
350546
350871
  accountId,
350547
350872
  args.name,
@@ -350551,6 +350876,10 @@ var init_terminate = __esm({
350551
350876
  args.rollback
350552
350877
  );
350553
350878
  }
350879
+ if (args.json) {
350880
+ logger2.json(result);
350881
+ return;
350882
+ }
350554
350883
  logger2.info(
350555
350884
  `\u{1F977} The instance "${id}" from ${args.name} was terminated successfully`
350556
350885
  );
@@ -350569,6 +350898,7 @@ var init_terminate_all = __esm({
350569
350898
  init_create_command();
350570
350899
  init_logger2();
350571
350900
  init_user3();
350901
+ init_utils22();
350572
350902
  workflowsInstancesTerminateAllCommand = createCommand({
350573
350903
  metadata: {
350574
350904
  description: "Terminate all workflow instances",
@@ -350578,6 +350908,7 @@ var init_terminate_all = __esm({
350578
350908
  },
350579
350909
  positionalArgs: ["name"],
350580
350910
  args: {
350911
+ ...jsonWorkflowArgs,
350581
350912
  name: {
350582
350913
  describe: "Name of the workflow",
350583
350914
  type: "string",
@@ -350588,6 +350919,9 @@ var init_terminate_all = __esm({
350588
350919
  type: "string"
350589
350920
  }
350590
350921
  },
350922
+ behaviour: {
350923
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
350924
+ },
350591
350925
  validateArgs: /* @__PURE__ */ __name((args) => {
350592
350926
  const validStatusToTerminate = [
350593
350927
  "queued",
@@ -350616,6 +350950,10 @@ var init_terminate_all = __esm({
350616
350950
  },
350617
350951
  maybeURLQueryString
350618
350952
  );
350953
+ if (args.json) {
350954
+ logger2.json(result);
350955
+ return;
350956
+ }
350619
350957
  if (result.status === "ok") {
350620
350958
  logger2.info(
350621
350959
  `\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 +350978,7 @@ var init_list36 = __esm({
350640
350978
  init_logger2();
350641
350979
  init_user3();
350642
350980
  init_local();
350981
+ init_utils22();
350643
350982
  workflowsListCommand = createCommand({
350644
350983
  metadata: {
350645
350984
  description: "List Workflows associated to account",
@@ -350648,6 +350987,7 @@ var init_list36 = __esm({
350648
350987
  },
350649
350988
  args: {
350650
350989
  ...localWorkflowArgs,
350990
+ ...jsonWorkflowArgs,
350651
350991
  page: {
350652
350992
  describe: 'Show a sepecific page from the listing, can configure page size using "per-page"',
350653
350993
  type: "number",
@@ -350658,12 +350998,19 @@ var init_list36 = __esm({
350658
350998
  type: "number"
350659
350999
  }
350660
351000
  },
351001
+ behaviour: {
351002
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
351003
+ },
350661
351004
  async handler(args, { config: config2 }) {
350662
351005
  if (args.local) {
350663
351006
  const workflows = await fetchLocalResult(
350664
351007
  args.port,
350665
351008
  "/workflows"
350666
351009
  );
351010
+ if (args.json) {
351011
+ logger2.json(workflows);
351012
+ return;
351013
+ }
350667
351014
  if (workflows.length === 0) {
350668
351015
  logger2.warn("There are no Workflows in the local dev session");
350669
351016
  return;
@@ -350690,6 +351037,13 @@ var init_list36 = __esm({
350690
351037
  void 0,
350691
351038
  URLParams
350692
351039
  );
351040
+ const sortedWorkflows = workflows.sort(
351041
+ (a7, b10) => b10.created_on.localeCompare(a7.created_on)
351042
+ );
351043
+ if (args.json) {
351044
+ logger2.json(sortedWorkflows);
351045
+ return;
351046
+ }
350693
351047
  if (workflows.length === 0 && args.page === 1) {
350694
351048
  logger2.warn("There are no deployed Workflows in this account");
350695
351049
  return;
@@ -350703,7 +351057,7 @@ var init_list36 = __esm({
350703
351057
  logger2.info(
350704
351058
  `Showing ${workflows.length} workflow${workflows.length > 1 ? "s" : ""} from page ${args.page}:`
350705
351059
  );
350706
- const prettierWorkflows = workflows.sort((a7, b10) => b10.created_on.localeCompare(a7.created_on)).map((workflow) => ({
351060
+ const prettierWorkflows = sortedWorkflows.map((workflow) => ({
350707
351061
  Name: workflow.name,
350708
351062
  "Script name": workflow.script_name,
350709
351063
  "Class name": workflow.class_name,
@@ -350727,6 +351081,7 @@ var init_trigger = __esm({
350727
351081
  init_create_command();
350728
351082
  init_user3();
350729
351083
  init_local();
351084
+ init_utils22();
350730
351085
  workflowsTriggerCommand = createCommand({
350731
351086
  metadata: {
350732
351087
  description: "Trigger a workflow, creating a new instance. Can optionally take a JSON string to pass a parameter into the workflow instance",
@@ -350735,6 +351090,7 @@ var init_trigger = __esm({
350735
351090
  },
350736
351091
  args: {
350737
351092
  ...localWorkflowArgs,
351093
+ ...jsonWorkflowArgs,
350738
351094
  name: {
350739
351095
  describe: "Name of the workflow",
350740
351096
  type: "string",
@@ -350752,6 +351108,9 @@ var init_trigger = __esm({
350752
351108
  }
350753
351109
  },
350754
351110
  positionalArgs: ["name", "params"],
351111
+ behaviour: {
351112
+ printBanner: /* @__PURE__ */ __name((args) => !args.json, "printBanner")
351113
+ },
350755
351114
  async handler(args, { config: config2, logger: logger6 }) {
350756
351115
  if (args.params.length != 0) {
350757
351116
  try {
@@ -350779,6 +351138,10 @@ var init_trigger = __esm({
350779
351138
  }
350780
351139
  );
350781
351140
  instanceId = response.id;
351141
+ if (args.json) {
351142
+ logger6.json(response);
351143
+ return;
351144
+ }
350782
351145
  logger6.info(
350783
351146
  `\u{1F680} Workflow instance "${instanceId}" has been triggered successfully`
350784
351147
  );
@@ -350797,6 +351160,10 @@ var init_trigger = __esm({
350797
351160
  }
350798
351161
  );
350799
351162
  instanceId = response.id;
351163
+ if (args.json) {
351164
+ logger6.json(response);
351165
+ return;
351166
+ }
350800
351167
  logger6.info(
350801
351168
  `\u{1F680} Workflow instance "${instanceId}" has been queued successfully`
350802
351169
  );