@upstash/qstash 2.10.1 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/svelte.js CHANGED
@@ -458,17 +458,23 @@ function normalizeCursor(response) {
458
458
  const cursor = response.cursor;
459
459
  return { ...response, cursor: cursor || void 0 };
460
460
  }
461
+ function _processGlobal() {
462
+ const proc = globalThis["process"];
463
+ return proc;
464
+ }
461
465
  function getRuntime() {
462
- if (typeof process === "object" && typeof process.versions == "object" && process.versions.bun)
463
- return `bun@${process.versions.bun}`;
466
+ const proc = _processGlobal();
467
+ if (proc?.versions?.bun)
468
+ return `bun@${proc.versions.bun}`;
464
469
  if (typeof EdgeRuntime === "string")
465
470
  return "edge-light";
466
- else if (typeof process === "object" && typeof process.version === "string")
467
- return `node@${process.version}`;
471
+ if (typeof proc?.version === "string")
472
+ return `node@${proc.version}`;
468
473
  return "";
469
474
  }
470
475
  function getSafeEnvironment() {
471
- return typeof process === "undefined" ? {} : process.env;
476
+ const proc = _processGlobal();
477
+ return proc?.env ?? {};
472
478
  }
473
479
 
474
480
  // src/client/multi-region/utils.ts
@@ -512,12 +518,451 @@ function normalizeRegionHeader(region) {
512
518
  return void 0;
513
519
  }
514
520
 
521
+ // src/dev-server/constants.ts
522
+ var DEFAULT_DEV_PORT = 8080;
523
+ var DEV_CREDENTIALS = {
524
+ token: "eyJVc2VySUQiOiJkZWZhdWx0VXNlciIsIlBhc3N3b3JkIjoiZGVmYXVsdFBhc3N3b3JkIn0=",
525
+ currentSigningKey: "sig_7kYjw48mhY7kAjqNGcy6cr29RJ6r",
526
+ nextSigningKey: "sig_5ZB6DVzB1wjE8S6rZ7eenA8Pdnhs"
527
+ };
528
+ var GITHUB_RELEASES_URL = "https://api.github.com/repos/upstash/qstash-cli/releases/latest";
529
+ var BINARY_URL_BASE = "https://artifacts.upstash.com/qstash/versions";
530
+ var CONSOLE_URL = "https://console.upstash.com/qstash/local-mode-user";
531
+ var DEV_PREFIX = "\x1B[2m[QStash Dev]\x1B[0m";
532
+ var CLI_PREFIX = "\x1B[2m[QStash CLI]\x1B[0m";
533
+ var _n = (m) => `node:${m}`;
534
+ var importHttp = () => import(
535
+ /* webpackIgnore: true */
536
+ _n("http")
537
+ );
538
+ var importHttps = () => import(
539
+ /* webpackIgnore: true */
540
+ _n("https")
541
+ );
542
+ var importFs = () => import(
543
+ /* webpackIgnore: true */
544
+ _n("fs")
545
+ );
546
+ var importChildProcess = () => import(
547
+ /* webpackIgnore: true */
548
+ _n("child_process")
549
+ );
550
+ var importOs = () => import(
551
+ /* webpackIgnore: true */
552
+ _n("os")
553
+ );
554
+
555
+ // src/dev-server/http.ts
556
+ var HTTP_OK = 200;
557
+ var HTTP_MULTI_CHOICE = 300;
558
+ var nativeGet = async (url, headers, timeoutMs) => {
559
+ const parsedUrl = new URL(url);
560
+ const httpModule = parsedUrl.protocol === "https:" ? await importHttps() : await importHttp();
561
+ return new Promise((resolve, reject) => {
562
+ const request = httpModule.get(url, { headers }, (response) => {
563
+ const chunks = [];
564
+ response.on("data", (chunk) => chunks.push(chunk));
565
+ response.on("end", () => {
566
+ const statusCode = response.statusCode ?? 0;
567
+ resolve({
568
+ ok: statusCode >= HTTP_OK && statusCode < HTTP_MULTI_CHOICE,
569
+ statusCode,
570
+ body: Buffer.concat(chunks)
571
+ });
572
+ });
573
+ response.on("error", reject);
574
+ });
575
+ if (timeoutMs) {
576
+ request.setTimeout(timeoutMs, () => {
577
+ request.destroy(new Error("Request timed out"));
578
+ });
579
+ }
580
+ request.on("error", reject);
581
+ });
582
+ };
583
+
584
+ // src/dev-server/health.ts
585
+ var HEALTH_CHECK_TIMEOUT_MS = 2e3;
586
+ var isDevServerRunning = async (baseUrl) => {
587
+ try {
588
+ const { ok: ok4, body } = await nativeGet(
589
+ `${baseUrl}/v2/keys`,
590
+ { Authorization: `Bearer ${DEV_CREDENTIALS.token}` },
591
+ HEALTH_CHECK_TIMEOUT_MS
592
+ );
593
+ if (!ok4)
594
+ return false;
595
+ const data = JSON.parse(body.toString());
596
+ return data.current === DEV_CREDENTIALS.currentSigningKey && data.next === DEV_CREDENTIALS.nextSigningKey;
597
+ } catch {
598
+ return false;
599
+ }
600
+ };
601
+ var _didLogUnreachable = false;
602
+ var checkDevServerReachable = async (baseUrl, runtime) => {
603
+ if (await pingEdge(baseUrl))
604
+ return;
605
+ if (!_didLogUnreachable) {
606
+ console.error(unreachableMessage(baseUrl, runtime));
607
+ _didLogUnreachable = true;
608
+ }
609
+ throw new Error(`${DEV_PREFIX} dev server unreachable at ${baseUrl}`);
610
+ };
611
+ var pingEdge = async (baseUrl) => {
612
+ try {
613
+ const controller = new AbortController();
614
+ const timeout = setTimeout(() => controller.abort(), HEALTH_CHECK_TIMEOUT_MS);
615
+ const response = await fetch(`${baseUrl}/v2/keys`, {
616
+ headers: { Authorization: `Bearer ${DEV_CREDENTIALS.token}` },
617
+ signal: controller.signal
618
+ });
619
+ clearTimeout(timeout);
620
+ return response.ok;
621
+ } catch {
622
+ return false;
623
+ }
624
+ };
625
+ var unreachableMessage = (baseUrl, runtime) => {
626
+ const port = new URL(baseUrl).port;
627
+ const manualStartCmd = `npx @upstash/qstash-cli dev --port ${port}`;
628
+ const header = `
629
+ ${DEV_PREFIX} The dev server is not running at ${baseUrl}.
630
+
631
+ `;
632
+ if (runtime === "cloudflare-workers") {
633
+ return header + `Cloudflare Workers cannot start the dev server automatically.
634
+ Start it manually before running wrangler dev:
635
+
636
+ ${manualStartCmd}
637
+ `;
638
+ }
639
+ return header + `Edge runtimes cannot start the dev server automatically.
640
+ Either:
641
+ 1. Add the instrumentation hook to start it with your app:
642
+
643
+ // instrumentation.ts
644
+ import { registerQStashDev } from "@upstash/qstash/nextjs";
645
+ export async function register() { await registerQStashDev(); }
646
+
647
+ 2. Or start it manually:
648
+
649
+ ${manualStartCmd}
650
+ `;
651
+ };
652
+
653
+ // src/dev-server/binary.ts
654
+ var ensureBinary = async () => {
655
+ const fs = await importFs();
656
+ const os = await importOs();
657
+ const cacheDirectory = await findCacheDirectory();
658
+ const isWindows = os.platform() === "win32";
659
+ const binaryName = isWindows ? "qstash.exe" : "qstash";
660
+ const binaryPath = `${cacheDirectory}/${binaryName}`;
661
+ const versionFile = `${cacheDirectory}/.version`;
662
+ let version;
663
+ try {
664
+ version = await fetchLatestVersion();
665
+ } catch (error) {
666
+ if (fs.existsSync(binaryPath)) {
667
+ const cachedVersion = fs.existsSync(versionFile) ? fs.readFileSync(versionFile, "utf8").trim() : "unknown";
668
+ console.log(`${DEV_PREFIX} Offline, using local v${cachedVersion}`);
669
+ return binaryPath;
670
+ }
671
+ throw error;
672
+ }
673
+ return downloadBinary(version, cacheDirectory);
674
+ };
675
+ var fetchLatestVersion = async () => {
676
+ const { ok: ok4, statusCode, body } = await nativeGet(GITHUB_RELEASES_URL, {
677
+ Accept: "application/vnd.github.v3+json",
678
+ "User-Agent": "upstash-qstash-js"
679
+ });
680
+ if (!ok4) {
681
+ throw new Error(`[QStash Dev] Failed to fetch latest version: HTTP ${statusCode}`);
682
+ }
683
+ const data = JSON.parse(body.toString());
684
+ return data.tag_name.replace(/^v/, "");
685
+ };
686
+ var findCacheDirectory = async () => {
687
+ const fs = await importFs();
688
+ const os = await importOs();
689
+ const home = os.homedir();
690
+ const platform = os.platform();
691
+ let base;
692
+ if (platform === "darwin") {
693
+ base = `${home}/Library/Caches/upstash`;
694
+ } else if (platform === "win32") {
695
+ base = `${process.env.LOCALAPPDATA ?? `${home}/AppData/Local`}/upstash`;
696
+ } else {
697
+ base = `${home}/.cache/upstash`;
698
+ }
699
+ const cacheDirectory = `${base}/qstash-dev`;
700
+ await fs.promises.mkdir(cacheDirectory, { recursive: true });
701
+ return cacheDirectory;
702
+ };
703
+ var downloadBinary = async (version, cacheDirectory) => {
704
+ const fs = await importFs();
705
+ const childProcess = await importChildProcess();
706
+ const os = await importOs();
707
+ const osPlatform = os.platform();
708
+ const isWindows = osPlatform === "win32";
709
+ const platform = isWindows ? "windows" : osPlatform === "darwin" ? "darwin" : "linux";
710
+ const arch = os.arch() === "arm64" ? "arm64" : "amd64";
711
+ const archiveName = `qstash-server_${version}_${platform}_${arch}`;
712
+ const binaryName = isWindows ? "qstash.exe" : "qstash";
713
+ const binaryPath = `${cacheDirectory}/${binaryName}`;
714
+ const versionFile = `${cacheDirectory}/.version`;
715
+ if (fs.existsSync(binaryPath) && fs.existsSync(versionFile)) {
716
+ const cachedVersion = fs.readFileSync(versionFile, "utf8").trim();
717
+ if (cachedVersion === version) {
718
+ return binaryPath;
719
+ }
720
+ }
721
+ await fs.promises.rm(cacheDirectory, { recursive: true, force: true });
722
+ await fs.promises.mkdir(cacheDirectory, { recursive: true });
723
+ const extension = isWindows ? "zip" : "tar.gz";
724
+ const archiveUrl = `${BINARY_URL_BASE}/${version}/${archiveName}.${extension}`;
725
+ console.log(`${DEV_PREFIX} Downloading dev server v${version}...`);
726
+ const { ok: ok4, statusCode, body } = await nativeGet(archiveUrl);
727
+ if (!ok4) {
728
+ throw new Error(`[QStash Dev] Failed to download binary: HTTP ${statusCode}`);
729
+ }
730
+ const archivePath = `${cacheDirectory}/${archiveName}.${extension}`;
731
+ await fs.promises.writeFile(archivePath, new Uint8Array(body));
732
+ childProcess.execFileSync("tar", ["-xf", archivePath, "-C", cacheDirectory], {
733
+ stdio: "pipe"
734
+ });
735
+ if (!isWindows) {
736
+ const EXECUTABLE_PERMISSION = 493;
737
+ await fs.promises.chmod(binaryPath, EXECUTABLE_PERMISSION);
738
+ }
739
+ await fs.promises.writeFile(versionFile, version);
740
+ await fs.promises.unlink(archivePath).catch(() => {
741
+ });
742
+ return binaryPath;
743
+ };
744
+
745
+ // src/dev-server/process.ts
746
+ var STARTUP_TIMEOUT_MS = 3e4;
747
+ var _proc = () => {
748
+ return globalThis["process"] ?? {};
749
+ };
750
+ var spawnServer = async (binaryPath, port, onUnexpectedExit) => {
751
+ const childProcess = await importChildProcess();
752
+ const child = await new Promise((resolve, reject) => {
753
+ const child2 = childProcess.spawn(binaryPath, ["dev", "--port", String(port)], {
754
+ stdio: ["ignore", "pipe", "pipe"]
755
+ });
756
+ const timeout = setTimeout(() => {
757
+ child2.kill();
758
+ reject(new Error("[QStash Dev] Server failed to start within 30 seconds"));
759
+ }, STARTUP_TIMEOUT_MS);
760
+ let startupOutput = "";
761
+ let started = false;
762
+ const bufferLine = (line) => {
763
+ if (!started)
764
+ startupOutput += `${line}
765
+ `;
766
+ };
767
+ forwardWithPrefix(child2.stdout, _proc().stdout, (line) => {
768
+ bufferLine(line);
769
+ if (!started && /runn+ing( at|\.)/i.test(line)) {
770
+ clearTimeout(timeout);
771
+ started = true;
772
+ resolve(child2);
773
+ }
774
+ });
775
+ forwardWithPrefix(child2.stderr, _proc().stderr, bufferLine);
776
+ child2.on("error", (error) => {
777
+ clearTimeout(timeout);
778
+ reject(new Error(`[QStash Dev] Failed to start server: ${error.message}`));
779
+ });
780
+ child2.on("close", (code, _signal) => {
781
+ if (started) {
782
+ onUnexpectedExit?.();
783
+ return;
784
+ }
785
+ clearTimeout(timeout);
786
+ reject(new Error(formatStartupError(code, startupOutput)));
787
+ });
788
+ });
789
+ registerCleanup(child);
790
+ child.unref?.();
791
+ child.stdout?.unref?.();
792
+ child.stderr?.unref?.();
793
+ };
794
+ var formatStartupError = (code, startupOutput) => {
795
+ const cleaned = startupOutput.replaceAll(/\u001B\[[\d;]*m/g, "").replaceAll(/^\d{1,2}:\d{2}(AM|PM)\s+\w{3}\s+/gm, "").trim();
796
+ if (/address already in use/i.test(cleaned)) {
797
+ const match = /:(\d+)\s*$/.exec(cleaned);
798
+ const portHint = match ? ` on port ${match[1]}` : "";
799
+ return `[QStash Dev] Port already in use${portHint}. Set QSTASH_DEV_PORT to use a different port, or stop the process holding it.`;
800
+ }
801
+ const codeSuffix = code ? ` with code ${code}` : "";
802
+ const detail = cleaned ? `: ${cleaned}` : "";
803
+ return `[QStash Dev] Server exited unexpectedly${codeSuffix}${detail}`;
804
+ };
805
+ var forwardWithPrefix = (source, destination, onLine) => {
806
+ if (!source)
807
+ return;
808
+ let buffer = "";
809
+ const flushLine = (line) => {
810
+ destination?.write(`${CLI_PREFIX} ${line}
811
+ `);
812
+ onLine(line);
813
+ };
814
+ source.on("data", (data) => {
815
+ buffer += data.toString();
816
+ let newlineIndex = buffer.indexOf("\n");
817
+ while (newlineIndex !== -1) {
818
+ flushLine(buffer.slice(0, newlineIndex));
819
+ buffer = buffer.slice(newlineIndex + 1);
820
+ newlineIndex = buffer.indexOf("\n");
821
+ }
822
+ });
823
+ source.on("end", () => {
824
+ if (buffer.length > 0) {
825
+ flushLine(buffer);
826
+ buffer = "";
827
+ }
828
+ });
829
+ source.on("error", () => {
830
+ });
831
+ };
832
+ var currentChild;
833
+ var processHandlersRegistered = false;
834
+ var killCurrentChild = () => {
835
+ if (!currentChild)
836
+ return;
837
+ try {
838
+ currentChild.kill("SIGTERM");
839
+ } catch {
840
+ }
841
+ currentChild = void 0;
842
+ };
843
+ var registerCleanup = (child) => {
844
+ currentChild = child;
845
+ if (!processHandlersRegistered) {
846
+ processHandlersRegistered = true;
847
+ const proc = _proc();
848
+ proc.on?.("exit", killCurrentChild);
849
+ proc.on?.("SIGINT", () => {
850
+ killCurrentChild();
851
+ proc.exit?.(0);
852
+ });
853
+ proc.on?.("SIGTERM", () => {
854
+ killCurrentChild();
855
+ proc.exit?.(0);
856
+ });
857
+ }
858
+ };
859
+
860
+ // src/dev-server/index.ts
861
+ var _processGlobal2 = () => {
862
+ const proc = globalThis["process"];
863
+ return proc;
864
+ };
865
+ var devServerPromise;
866
+ var ensureDevelopmentServer = (env, devMode) => {
867
+ if (!shouldUseDevelopmentMode(devMode, env))
868
+ return Promise.resolve();
869
+ const procEnv = _processGlobal2()?.env;
870
+ if (procEnv?.NEXT_PHASE === "phase-production-build")
871
+ return Promise.resolve();
872
+ if (procEnv?.NODE_ENV === "production")
873
+ return Promise.resolve();
874
+ const runtime = getRuntime2();
875
+ if (runtime !== "nodejs") {
876
+ return checkDevServerReachable(getDevUrl(env), runtime);
877
+ }
878
+ if (!devServerPromise) {
879
+ devServerPromise = startPipeline(env).catch((error) => {
880
+ devServerPromise = void 0;
881
+ throw error;
882
+ });
883
+ }
884
+ return devServerPromise;
885
+ };
886
+ var startPipeline = async (env) => {
887
+ const baseUrl = getDevUrl(env);
888
+ const port = new URL(baseUrl).port;
889
+ const consoleLink = `\x1B[36m${CONSOLE_URL}?port=${port}\x1B[0m`;
890
+ if (await isDevServerRunning(baseUrl)) {
891
+ console.log(
892
+ `${DEV_PREFIX} Server already running at ${baseUrl}
893
+ ${DEV_PREFIX} Console: ${consoleLink}`
894
+ );
895
+ return;
896
+ }
897
+ const binaryPath = await ensureBinary();
898
+ await spawnServer(binaryPath, port, () => {
899
+ devServerPromise = void 0;
900
+ });
901
+ };
902
+ var shouldUseDevelopmentMode = (devMode, env) => {
903
+ if (devMode !== void 0)
904
+ return devMode;
905
+ const value = env?.QSTASH_DEV ?? getProcessEnvironment("QSTASH_DEV");
906
+ if (value === void 0 || value === "" || value === "false" || value === "0")
907
+ return false;
908
+ if (value === "true" || value === "1")
909
+ return true;
910
+ throw new Error(`[QStash Dev] Invalid value for QSTASH_DEV in environment: ${value}`);
911
+ };
912
+ var getDevelopmentCredentials = (env) => {
913
+ return {
914
+ ...DEV_CREDENTIALS,
915
+ baseUrl: getDevUrl(env)
916
+ };
917
+ };
918
+ var getDevUrl = (env) => {
919
+ const portString = env?.QSTASH_DEV_PORT ?? getProcessEnvironment("QSTASH_DEV_PORT");
920
+ let port = DEFAULT_DEV_PORT;
921
+ if (portString) {
922
+ const parsed = Number.parseInt(portString, 10);
923
+ if (!Number.isNaN(parsed) && parsed > 0) {
924
+ port = parsed;
925
+ }
926
+ }
927
+ return `http://127.0.0.1:${port}`;
928
+ };
929
+ var getRuntime2 = () => {
930
+ if (typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") {
931
+ return "cloudflare-workers";
932
+ }
933
+ const proc = _processGlobal2();
934
+ if (!proc) {
935
+ return "browser";
936
+ }
937
+ if (!proc.release?.name) {
938
+ return "edge";
939
+ }
940
+ return "nodejs";
941
+ };
942
+ var getProcessEnvironment = (key) => {
943
+ const proc = _processGlobal2();
944
+ return proc?.env ? proc.env[key] : void 0;
945
+ };
946
+
515
947
  // src/client/multi-region/incoming.ts
516
948
  var getReceiverSigningKeys = ({
517
949
  environment,
518
950
  regionFromHeader,
519
- config
951
+ config,
952
+ devMode
520
953
  }) => {
954
+ if (shouldUseDevelopmentMode(devMode, environment)) {
955
+ if (config?.currentSigningKey || config?.nextSigningKey) {
956
+ console.warn(
957
+ `${DEV_PREFIX} Dev mode is active. Ignoring signing keys from config. Set devMode: false to use your own keys.`
958
+ );
959
+ }
960
+ const developmentCreds = getDevelopmentCredentials(environment);
961
+ return {
962
+ currentSigningKey: developmentCreds.currentSigningKey,
963
+ nextSigningKey: developmentCreds.nextSigningKey
964
+ };
965
+ }
521
966
  if (config?.currentSigningKey && config.nextSigningKey) {
522
967
  return {
523
968
  currentSigningKey: config.currentSigningKey,
@@ -562,8 +1007,21 @@ var getClientCredentials = (clientCredentialConfig) => {
562
1007
  };
563
1008
  var resolveCredentials = ({
564
1009
  environment,
565
- config
1010
+ config,
1011
+ devMode
566
1012
  }) => {
1013
+ if (shouldUseDevelopmentMode(devMode, environment)) {
1014
+ if (config?.baseUrl || config?.token) {
1015
+ console.warn(
1016
+ `${DEV_PREFIX} Dev mode is active. Ignoring baseUrl/token from config. Set devMode: false to use your own credentials.`
1017
+ );
1018
+ }
1019
+ const developmentCreds = getDevelopmentCredentials(environment);
1020
+ return {
1021
+ baseUrl: developmentCreds.baseUrl,
1022
+ token: developmentCreds.token
1023
+ };
1024
+ }
567
1025
  if (config?.baseUrl && config.token) {
568
1026
  return {
569
1027
  baseUrl: config.baseUrl,
@@ -616,9 +1074,11 @@ var SignatureError = class extends Error {
616
1074
  var Receiver = class {
617
1075
  currentSigningKey;
618
1076
  nextSigningKey;
1077
+ devMode;
619
1078
  constructor(config) {
620
1079
  this.currentSigningKey = config?.currentSigningKey;
621
1080
  this.nextSigningKey = config?.nextSigningKey;
1081
+ this.devMode = config?.devMode;
622
1082
  }
623
1083
  /**
624
1084
  * Verify the signature of a request.
@@ -637,7 +1097,8 @@ var Receiver = class {
637
1097
  config: {
638
1098
  currentSigningKey: this.currentSigningKey,
639
1099
  nextSigningKey: this.nextSigningKey
640
- }
1100
+ },
1101
+ devMode: this.devMode
641
1102
  });
642
1103
  if (!signingKeys) {
643
1104
  throw new Error(
@@ -903,12 +1364,14 @@ var HttpClient = class {
903
1364
  baseUrl;
904
1365
  authorization;
905
1366
  options;
1367
+ devMode;
906
1368
  retry;
907
1369
  headers;
908
1370
  telemetryHeaders;
909
1371
  constructor(config) {
910
1372
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
911
1373
  this.authorization = config.authorization;
1374
+ this.devMode = config.devMode;
912
1375
  this.retry = // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
913
1376
  typeof config.retry === "boolean" && !config.retry ? {
914
1377
  attempts: 1,
@@ -921,6 +1384,7 @@ var HttpClient = class {
921
1384
  this.telemetryHeaders = config.telemetryHeaders;
922
1385
  }
923
1386
  async request(request) {
1387
+ await ensureDevelopmentServer(void 0, this.devMode);
924
1388
  const { response } = await this.requestWithBackoff(request);
925
1389
  if (request.parseResponseAsJson === false) {
926
1390
  return void 0;
@@ -928,6 +1392,7 @@ var HttpClient = class {
928
1392
  return await response.json();
929
1393
  }
930
1394
  async *requestStream(request) {
1395
+ await ensureDevelopmentServer(void 0, this.devMode);
931
1396
  const { response } = await this.requestWithBackoff(request);
932
1397
  if (!response.body) {
933
1398
  throw new Error("No response body");
@@ -3036,7 +3501,7 @@ var Workflow = class {
3036
3501
  };
3037
3502
 
3038
3503
  // version.ts
3039
- var VERSION = "2.10.1";
3504
+ var VERSION = "2.11.0";
3040
3505
 
3041
3506
  // src/client/client.ts
3042
3507
  var Client = class {
@@ -3044,7 +3509,14 @@ var Client = class {
3044
3509
  token;
3045
3510
  constructor(config) {
3046
3511
  const environment = getSafeEnvironment();
3047
- const { baseUrl, token } = getClientCredentials({ environment, config });
3512
+ const { baseUrl, token } = getClientCredentials({
3513
+ environment,
3514
+ config,
3515
+ devMode: config?.devMode
3516
+ });
3517
+ if (shouldUseDevelopmentMode(config?.devMode, environment)) {
3518
+ void ensureDevelopmentServer(environment, config?.devMode);
3519
+ }
3048
3520
  const enableTelemetry = environment.UPSTASH_DISABLE_TELEMETRY ? false : config?.enableTelemetry ?? true;
3049
3521
  const isCloudflare = typeof caches !== "undefined" && "default" in caches;
3050
3522
  const telemetryHeaders = new Headers(
@@ -3061,7 +3533,8 @@ var Client = class {
3061
3533
  //@ts-expect-error caused by undici and bunjs type overlap
3062
3534
  headers: prefixHeaders(new Headers(config?.headers ?? {})),
3063
3535
  //@ts-expect-error caused by undici and bunjs type overlap
3064
- telemetryHeaders
3536
+ telemetryHeaders,
3537
+ devMode: config?.devMode
3065
3538
  });
3066
3539
  this.token = token;
3067
3540
  }
package/svelte.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import "./chunk-Z37KJCW7.mjs";
1
+ import "./chunk-7DSF3QVE.mjs";
2
2
  import {
3
3
  Receiver,
4
4
  serve
5
- } from "./chunk-35B33QW3.mjs";
5
+ } from "./chunk-LB3C5PJP.mjs";
6
6
 
7
7
  // platforms/svelte.ts
8
8
  var verifySignatureSvelte = (handler, config) => {
package/workflow.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export { ar as AsyncStepFunction, ak as DisabledWorkflowContext, F as FailureFunctionPayload, au as FinishCondition, aw as LogLevel, at as ParallelCallState, ap as RawStep, av as RequiredExceptFields, ae as RouteFunction, S as Step, as as StepFunction, ao as StepType, an as StepTypes, aq as SyncStepFunction, ag as Workflow, al as WorkflowClient, aj as WorkflowContext, ay as WorkflowLogger, ax as WorkflowLoggerOptions, am as WorkflowReceiver, af as WorkflowServeOptions, ah as processOptions, ai as serve } from './client-CsM1dTnz.mjs';
1
+ export { ar as AsyncStepFunction, ak as DisabledWorkflowContext, F as FailureFunctionPayload, au as FinishCondition, aw as LogLevel, at as ParallelCallState, ap as RawStep, av as RequiredExceptFields, ae as RouteFunction, S as Step, as as StepFunction, ao as StepType, an as StepTypes, aq as SyncStepFunction, ag as Workflow, al as WorkflowClient, aj as WorkflowContext, ay as WorkflowLogger, ax as WorkflowLoggerOptions, am as WorkflowReceiver, af as WorkflowServeOptions, ah as processOptions, ai as serve } from './client-CUioGZfg.mjs';
2
2
  import 'neverthrow';
package/workflow.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { ar as AsyncStepFunction, ak as DisabledWorkflowContext, F as FailureFunctionPayload, au as FinishCondition, aw as LogLevel, at as ParallelCallState, ap as RawStep, av as RequiredExceptFields, ae as RouteFunction, S as Step, as as StepFunction, ao as StepType, an as StepTypes, aq as SyncStepFunction, ag as Workflow, al as WorkflowClient, aj as WorkflowContext, ay as WorkflowLogger, ax as WorkflowLoggerOptions, am as WorkflowReceiver, af as WorkflowServeOptions, ah as processOptions, ai as serve } from './client-CsM1dTnz.js';
1
+ export { ar as AsyncStepFunction, ak as DisabledWorkflowContext, F as FailureFunctionPayload, au as FinishCondition, aw as LogLevel, at as ParallelCallState, ap as RawStep, av as RequiredExceptFields, ae as RouteFunction, S as Step, as as StepFunction, ao as StepType, an as StepTypes, aq as SyncStepFunction, ag as Workflow, al as WorkflowClient, aj as WorkflowContext, ay as WorkflowLogger, ax as WorkflowLoggerOptions, am as WorkflowReceiver, af as WorkflowServeOptions, ah as processOptions, ai as serve } from './client-CUioGZfg.js';
2
2
  import 'neverthrow';