@upstash/qstash 2.6.4 → 2.6.5-workflow-url-canary

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/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
 
5
+ var _chunkF6QRAN74js = require('./chunk-F6QRAN74.js');
5
6
 
6
7
 
7
8
 
@@ -12,13 +13,12 @@
12
13
 
13
14
 
14
15
 
15
- var _chunkMZSHBRF6js = require('./chunk-MZSHBRF6.js');
16
16
 
17
17
 
18
18
 
19
- var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
20
19
 
21
20
 
21
+ var _chunkMFQHGR5Vjs = require('./chunk-MFQHGR5V.js');
22
22
 
23
23
 
24
24
 
@@ -33,4 +33,8 @@ var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
33
33
 
34
34
 
35
35
 
36
- exports.Chat = _chunkMZSHBRF6js.Chat; exports.Client = _chunkMZSHBRF6js.Client; exports.Messages = _chunkMZSHBRF6js.Messages; exports.QstashChatRatelimitError = _chunkMZSHBRF6js.QstashChatRatelimitError; exports.QstashDailyRatelimitError = _chunkMZSHBRF6js.QstashDailyRatelimitError; exports.QstashError = _chunkMZSHBRF6js.QstashError; exports.QstashRatelimitError = _chunkMZSHBRF6js.QstashRatelimitError; exports.Receiver = _chunkUUR7N6E6js.Receiver; exports.Schedules = _chunkMZSHBRF6js.Schedules; exports.SignatureError = _chunkUUR7N6E6js.SignatureError; exports.UrlGroups = _chunkMZSHBRF6js.UrlGroups; exports.custom = _chunkMZSHBRF6js.custom; exports.openai = _chunkMZSHBRF6js.openai; exports.setupAnalytics = _chunkMZSHBRF6js.setupAnalytics; exports.upstash = _chunkMZSHBRF6js.upstash;
36
+
37
+
38
+
39
+
40
+ exports.Chat = _chunkMFQHGR5Vjs.Chat; exports.Client = _chunkMFQHGR5Vjs.Client; exports.Messages = _chunkMFQHGR5Vjs.Messages; exports.QstashChatRatelimitError = _chunkMFQHGR5Vjs.QstashChatRatelimitError; exports.QstashDailyRatelimitError = _chunkMFQHGR5Vjs.QstashDailyRatelimitError; exports.QstashError = _chunkMFQHGR5Vjs.QstashError; exports.QstashRatelimitError = _chunkMFQHGR5Vjs.QstashRatelimitError; exports.QstashWorkflowAbort = _chunkMFQHGR5Vjs.QstashWorkflowAbort; exports.QstashWorkflowError = _chunkMFQHGR5Vjs.QstashWorkflowError; exports.Receiver = _chunkMFQHGR5Vjs.Receiver; exports.Schedules = _chunkMFQHGR5Vjs.Schedules; exports.SignatureError = _chunkMFQHGR5Vjs.SignatureError; exports.UrlGroups = _chunkMFQHGR5Vjs.UrlGroups; exports.custom = _chunkF6QRAN74js.custom; exports.formatWorkflowError = _chunkMFQHGR5Vjs.formatWorkflowError; exports.openai = _chunkF6QRAN74js.openai; exports.upstash = _chunkF6QRAN74js.upstash;
package/index.mjs CHANGED
@@ -1,3 +1,8 @@
1
+ import {
2
+ custom,
3
+ openai,
4
+ upstash
5
+ } from "./chunk-TAUBWUPA.mjs";
1
6
  import {
2
7
  Chat,
3
8
  Client,
@@ -6,17 +11,14 @@ import {
6
11
  QstashDailyRatelimitError,
7
12
  QstashError,
8
13
  QstashRatelimitError,
14
+ QstashWorkflowAbort,
15
+ QstashWorkflowError,
16
+ Receiver,
9
17
  Schedules,
18
+ SignatureError,
10
19
  UrlGroups,
11
- custom,
12
- openai,
13
- setupAnalytics,
14
- upstash
15
- } from "./chunk-6HSNQRF3.mjs";
16
- import {
17
- Receiver,
18
- SignatureError
19
- } from "./chunk-CP4IU45K.mjs";
20
+ formatWorkflowError
21
+ } from "./chunk-DH2LYTLA.mjs";
20
22
  export {
21
23
  Chat,
22
24
  Client,
@@ -25,12 +27,14 @@ export {
25
27
  QstashDailyRatelimitError,
26
28
  QstashError,
27
29
  QstashRatelimitError,
30
+ QstashWorkflowAbort,
31
+ QstashWorkflowError,
28
32
  Receiver,
29
33
  Schedules,
30
34
  SignatureError,
31
35
  UrlGroups,
32
36
  custom,
37
+ formatWorkflowError,
33
38
  openai,
34
- setupAnalytics,
35
39
  upstash
36
40
  };
package/nextjs.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { NextApiHandler } from 'next';
2
2
  import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';
3
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.mjs';
4
+ import 'neverthrow';
3
5
 
4
6
  type VerifySignatureConfig = {
5
7
  currentSigningKey?: string;
@@ -21,5 +23,6 @@ declare function verifySignature(handler: NextApiHandler, config?: VerifySignatu
21
23
  declare function verifySignatureEdge(handler: (request: NextRequest, nfe?: NextFetchEvent) => NextResponse | Promise<NextResponse>, config?: VerifySignatureConfig): (request: NextRequest, nfe: NextFetchEvent) => Promise<NextResponse<unknown>>;
22
24
  type VerifySignatureAppRouterResponse = NextResponse | Promise<NextResponse> | Response | Promise<Response>;
23
25
  declare function verifySignatureAppRouter(handler: ((request: Request) => VerifySignatureAppRouterResponse) | ((request: NextRequest) => VerifySignatureAppRouterResponse), config?: VerifySignatureConfig): (request: NextRequest | Request) => Promise<Response>;
26
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<NextResponse, TInitialPayload>, "onStepFinish">) => ((request: NextRequest) => Promise<NextResponse>);
24
27
 
25
- export { type VerifySignatureConfig, verifySignature, verifySignatureAppRouter, verifySignatureEdge };
28
+ export { type VerifySignatureConfig, serve, verifySignature, verifySignatureAppRouter, verifySignatureEdge };
package/nextjs.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { NextApiHandler } from 'next';
2
2
  import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';
3
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.js';
4
+ import 'neverthrow';
3
5
 
4
6
  type VerifySignatureConfig = {
5
7
  currentSigningKey?: string;
@@ -21,5 +23,6 @@ declare function verifySignature(handler: NextApiHandler, config?: VerifySignatu
21
23
  declare function verifySignatureEdge(handler: (request: NextRequest, nfe?: NextFetchEvent) => NextResponse | Promise<NextResponse>, config?: VerifySignatureConfig): (request: NextRequest, nfe: NextFetchEvent) => Promise<NextResponse<unknown>>;
22
24
  type VerifySignatureAppRouterResponse = NextResponse | Promise<NextResponse> | Response | Promise<Response>;
23
25
  declare function verifySignatureAppRouter(handler: ((request: Request) => VerifySignatureAppRouterResponse) | ((request: NextRequest) => VerifySignatureAppRouterResponse), config?: VerifySignatureConfig): (request: NextRequest | Request) => Promise<Response>;
26
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<NextResponse, TInitialPayload>, "onStepFinish">) => ((request: NextRequest) => Promise<NextResponse>);
24
27
 
25
- export { type VerifySignatureConfig, verifySignature, verifySignatureAppRouter, verifySignatureEdge };
28
+ export { type VerifySignatureConfig, serve, verifySignature, verifySignatureAppRouter, verifySignatureEdge };
package/nextjs.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
3
+
4
+
5
+ var _chunkMFQHGR5Vjs = require('./chunk-MFQHGR5V.js');
4
6
 
5
7
  // platforms/nextjs.ts
6
8
  var _server = require('next/server');
@@ -18,7 +20,7 @@ function verifySignature(handler, config) {
18
20
  "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
19
21
  );
20
22
  }
21
- const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
23
+ const receiver = new (0, _chunkMFQHGR5Vjs.Receiver)({
22
24
  currentSigningKey,
23
25
  nextSigningKey
24
26
  });
@@ -70,7 +72,7 @@ function verifySignatureEdge(handler, config) {
70
72
  "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
71
73
  );
72
74
  }
73
- const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
75
+ const receiver = new (0, _chunkMFQHGR5Vjs.Receiver)({
74
76
  currentSigningKey,
75
77
  nextSigningKey
76
78
  });
@@ -110,7 +112,7 @@ function verifySignatureAppRouter(handler, config) {
110
112
  "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
111
113
  );
112
114
  }
113
- const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
115
+ const receiver = new (0, _chunkMFQHGR5Vjs.Receiver)({
114
116
  currentSigningKey,
115
117
  nextSigningKey
116
118
  });
@@ -137,8 +139,25 @@ function verifySignatureAppRouter(handler, config) {
137
139
  return handler(request);
138
140
  };
139
141
  }
142
+ var serve2 = (routeFunction, options) => {
143
+ const handler = _chunkMFQHGR5Vjs.serve.call(void 0, routeFunction, {
144
+ onStepFinish: (workflowRunId) => new (0, _server.NextResponse)(JSON.stringify({ workflowRunId }), { status: 200 }),
145
+ ...options
146
+ });
147
+ return async (request) => {
148
+ try {
149
+ return await handler(request);
150
+ } catch (error) {
151
+ console.error(error);
152
+ return new (0, _server.NextResponse)(JSON.stringify(_chunkMFQHGR5Vjs.formatWorkflowError.call(void 0, error)), {
153
+ status: 500
154
+ });
155
+ }
156
+ };
157
+ };
158
+
140
159
 
141
160
 
142
161
 
143
162
 
144
- exports.verifySignature = verifySignature; exports.verifySignatureAppRouter = verifySignatureAppRouter; exports.verifySignatureEdge = verifySignatureEdge;
163
+ exports.serve = serve2; exports.verifySignature = verifySignature; exports.verifySignatureAppRouter = verifySignatureAppRouter; exports.verifySignatureEdge = verifySignatureEdge;
package/nextjs.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  import {
2
- Receiver
3
- } from "./chunk-CP4IU45K.mjs";
2
+ Receiver,
3
+ formatWorkflowError,
4
+ serve
5
+ } from "./chunk-DH2LYTLA.mjs";
4
6
 
5
7
  // platforms/nextjs.ts
6
8
  import { NextResponse } from "next/server";
@@ -137,7 +139,24 @@ function verifySignatureAppRouter(handler, config) {
137
139
  return handler(request);
138
140
  };
139
141
  }
142
+ var serve2 = (routeFunction, options) => {
143
+ const handler = serve(routeFunction, {
144
+ onStepFinish: (workflowRunId) => new NextResponse(JSON.stringify({ workflowRunId }), { status: 200 }),
145
+ ...options
146
+ });
147
+ return async (request) => {
148
+ try {
149
+ return await handler(request);
150
+ } catch (error) {
151
+ console.error(error);
152
+ return new NextResponse(JSON.stringify(formatWorkflowError(error)), {
153
+ status: 500
154
+ });
155
+ }
156
+ };
157
+ };
140
158
  export {
159
+ serve2 as serve,
141
160
  verifySignature,
142
161
  verifySignatureAppRouter,
143
162
  verifySignatureEdge
package/nuxt.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as h3 from 'h3';
2
2
  import { H3Event } from 'h3';
3
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.mjs';
4
+ import 'neverthrow';
3
5
 
4
6
  type VerifySignatureConfig = {
5
7
  currentSigningKey?: string;
@@ -7,5 +9,9 @@ type VerifySignatureConfig = {
7
9
  clockTolerance?: number;
8
10
  };
9
11
  declare const verifySignatureNuxt: (handler: (event: H3Event) => Promise<unknown>, config?: VerifySignatureConfig) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
12
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => h3.EventHandler<h3.EventHandlerRequest, Promise<Response | {
13
+ status: number;
14
+ body: string;
15
+ }>>;
10
16
 
11
- export { verifySignatureNuxt };
17
+ export { serve, verifySignatureNuxt };
package/nuxt.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as h3 from 'h3';
2
2
  import { H3Event } from 'h3';
3
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.js';
4
+ import 'neverthrow';
3
5
 
4
6
  type VerifySignatureConfig = {
5
7
  currentSigningKey?: string;
@@ -7,5 +9,9 @@ type VerifySignatureConfig = {
7
9
  clockTolerance?: number;
8
10
  };
9
11
  declare const verifySignatureNuxt: (handler: (event: H3Event) => Promise<unknown>, config?: VerifySignatureConfig) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
12
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => h3.EventHandler<h3.EventHandlerRequest, Promise<Response | {
13
+ status: number;
14
+ body: string;
15
+ }>>;
10
16
 
11
- export { verifySignatureNuxt };
17
+ export { serve, verifySignatureNuxt };
package/nuxt.js CHANGED
@@ -1,7 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-MZSHBRF6.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-F6QRAN74.js');
2
2
 
3
3
 
4
- var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
4
+
5
+
6
+ var _chunkMFQHGR5Vjs = require('./chunk-MFQHGR5V.js');
5
7
 
6
8
  // platforms/nuxt.ts
7
9
  var _h3 = require('h3');
@@ -18,7 +20,7 @@ var verifySignatureNuxt = (handler, config) => {
18
20
  "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
19
21
  );
20
22
  }
21
- const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
23
+ const receiver = new (0, _chunkMFQHGR5Vjs.Receiver)({
22
24
  currentSigningKey,
23
25
  nextSigningKey
24
26
  });
@@ -43,6 +45,43 @@ var verifySignatureNuxt = (handler, config) => {
43
45
  return handler(event);
44
46
  });
45
47
  };
48
+ function transformHeaders(headers) {
49
+ const formattedHeaders = Object.entries(headers).map(([key, value]) => [
50
+ key,
51
+ Array.isArray(value) ? value.join(", ") : _nullishCoalesce(value, () => ( ""))
52
+ ]);
53
+ return formattedHeaders;
54
+ }
55
+ var serve2 = (routeFunction, options) => {
56
+ const handler = _h3.defineEventHandler.call(void 0, async (event) => {
57
+ const method = event.node.req.method;
58
+ if (_optionalChain([method, 'optionalAccess', _4 => _4.toUpperCase, 'call', _5 => _5()]) !== "POST") {
59
+ return {
60
+ status: 405,
61
+ body: "Only POST requests are allowed in worklfows"
62
+ };
63
+ }
64
+ const request_ = event.node.req;
65
+ const protocol = request_.headers["x-forwarded-proto"];
66
+ const host = request_.headers.host;
67
+ const url = `${protocol}://${host}${event.path}`;
68
+ const headers = transformHeaders(request_.headers);
69
+ const request = new Request(url, {
70
+ headers,
71
+ body: await _h3.readRawBody.call(void 0, event),
72
+ method: "POST"
73
+ });
74
+ const serveHandler = _chunkMFQHGR5Vjs.serve.call(void 0, routeFunction, options);
75
+ try {
76
+ return await serveHandler(request);
77
+ } catch (error) {
78
+ console.error(error);
79
+ return new Response(JSON.stringify(_chunkMFQHGR5Vjs.formatWorkflowError.call(void 0, error)), { status: 500 });
80
+ }
81
+ });
82
+ return handler;
83
+ };
84
+
46
85
 
47
86
 
48
- exports.verifySignatureNuxt = verifySignatureNuxt;
87
+ exports.serve = serve2; exports.verifySignatureNuxt = verifySignatureNuxt;
package/nuxt.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import "./chunk-6HSNQRF3.mjs";
1
+ import "./chunk-TAUBWUPA.mjs";
2
2
  import {
3
- Receiver
4
- } from "./chunk-CP4IU45K.mjs";
3
+ Receiver,
4
+ formatWorkflowError,
5
+ serve
6
+ } from "./chunk-DH2LYTLA.mjs";
5
7
 
6
8
  // platforms/nuxt.ts
7
9
  import { defineEventHandler, getHeader, readRawBody } from "h3";
@@ -43,6 +45,43 @@ var verifySignatureNuxt = (handler, config) => {
43
45
  return handler(event);
44
46
  });
45
47
  };
48
+ function transformHeaders(headers) {
49
+ const formattedHeaders = Object.entries(headers).map(([key, value]) => [
50
+ key,
51
+ Array.isArray(value) ? value.join(", ") : value ?? ""
52
+ ]);
53
+ return formattedHeaders;
54
+ }
55
+ var serve2 = (routeFunction, options) => {
56
+ const handler = defineEventHandler(async (event) => {
57
+ const method = event.node.req.method;
58
+ if (method?.toUpperCase() !== "POST") {
59
+ return {
60
+ status: 405,
61
+ body: "Only POST requests are allowed in worklfows"
62
+ };
63
+ }
64
+ const request_ = event.node.req;
65
+ const protocol = request_.headers["x-forwarded-proto"];
66
+ const host = request_.headers.host;
67
+ const url = `${protocol}://${host}${event.path}`;
68
+ const headers = transformHeaders(request_.headers);
69
+ const request = new Request(url, {
70
+ headers,
71
+ body: await readRawBody(event),
72
+ method: "POST"
73
+ });
74
+ const serveHandler = serve(routeFunction, options);
75
+ try {
76
+ return await serveHandler(request);
77
+ } catch (error) {
78
+ console.error(error);
79
+ return new Response(JSON.stringify(formatWorkflowError(error)), { status: 500 });
80
+ }
81
+ });
82
+ return handler;
83
+ };
46
84
  export {
85
+ serve2 as serve,
47
86
  verifySignatureNuxt
48
87
  };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"version":"v2.6.4","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./**"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./nextjs":{"types":"./nextjs.d.ts","import":"./nextjs.mjs","require":"./nextjs.js"},"./dist/nextjs":{"types":"./nextjs.d.ts","import":"./nextjs.mjs","require":"./nextjs.js"},"./nuxt":{"types":"./nuxt.d.ts","import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"types":"./svelte.d.ts","import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"types":"./solidjs.d.ts","import":"./solidjs.mjs","require":"./solidjs.js"}},"typesVersions":{"*":{"nextjs":["./nextjs.d.ts"]}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test","fmt":"prettier --write .","lint":"tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^7.0.1","@typescript-eslint/parser":"^7.0.1","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^8","eslint-plugin-unicorn":"^51.0.1","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","crypto-js":">=4.2.0","h3":"^1.12.0","jose":"^ 5.2.3"}}
1
+ {"version":"v2.6.5-workflow-url-canary","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./**"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./nextjs":{"types":"./nextjs.d.ts","import":"./nextjs.mjs","require":"./nextjs.js"},"./dist/nextjs":{"types":"./nextjs.d.ts","import":"./nextjs.mjs","require":"./nextjs.js"},"./nuxt":{"types":"./nuxt.d.ts","import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"types":"./svelte.d.ts","import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"types":"./solidjs.d.ts","import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"types":"./workflow.d.ts","import":"./workflow.mjs","require":"./workflow.js"}},"typesVersions":{"*":{"nextjs":["./nextjs.d.ts"]}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test","fmt":"prettier --write .","lint":"tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^7.0.1","@typescript-eslint/parser":"^7.0.1","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^8","eslint-plugin-unicorn":"^51.0.1","husky":"^9.0.10","neverthrow":"^7.0.0","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","crypto-js":">=4.2.0","h3":"^1.12.0","jose":"^ 5.2.3"}}
package/solidjs.d.mts CHANGED
@@ -1,4 +1,6 @@
1
- import { APIHandler } from '@solidjs/start/server';
1
+ import { APIHandler, APIEvent } from '@solidjs/start/server';
2
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.mjs';
3
+ import 'neverthrow';
2
4
 
3
5
  type VerifySignatureConfig = {
4
6
  currentSigningKey?: string;
@@ -6,5 +8,6 @@ type VerifySignatureConfig = {
6
8
  clockTolerance?: number;
7
9
  };
8
10
  declare const verifySignatureSolidjs: (handler: APIHandler, config?: VerifySignatureConfig) => APIHandler;
11
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => (event: APIEvent) => Promise<Response>;
9
12
 
10
- export { verifySignatureSolidjs };
13
+ export { serve, verifySignatureSolidjs };
package/solidjs.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { APIHandler } from '@solidjs/start/server';
1
+ import { APIHandler, APIEvent } from '@solidjs/start/server';
2
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.js';
3
+ import 'neverthrow';
2
4
 
3
5
  type VerifySignatureConfig = {
4
6
  currentSigningKey?: string;
@@ -6,5 +8,6 @@ type VerifySignatureConfig = {
6
8
  clockTolerance?: number;
7
9
  };
8
10
  declare const verifySignatureSolidjs: (handler: APIHandler, config?: VerifySignatureConfig) => APIHandler;
11
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => (event: APIEvent) => Promise<Response>;
9
12
 
10
- export { verifySignatureSolidjs };
13
+ export { serve, verifySignatureSolidjs };
package/solidjs.js CHANGED
@@ -1,7 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-MZSHBRF6.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-F6QRAN74.js');
2
2
 
3
3
 
4
- var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
4
+
5
+
6
+ var _chunkMFQHGR5Vjs = require('./chunk-MFQHGR5V.js');
5
7
 
6
8
  // platforms/solidjs.ts
7
9
  var verifySignatureSolidjs = (handler, config) => {
@@ -13,7 +15,7 @@ var verifySignatureSolidjs = (handler, config) => {
13
15
  if (!nextSigningKey) {
14
16
  throw new Error("nextSigningKey is required, either in the config or from the env");
15
17
  }
16
- const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
18
+ const receiver = new (0, _chunkMFQHGR5Vjs.Receiver)({
17
19
  currentSigningKey,
18
20
  nextSigningKey
19
21
  });
@@ -38,6 +40,24 @@ var verifySignatureSolidjs = (handler, config) => {
38
40
  return handler(event);
39
41
  };
40
42
  };
43
+ var serve2 = (routeFunction, options) => {
44
+ const handler = async (event) => {
45
+ const method = event.request.method;
46
+ if (method.toUpperCase() !== "POST") {
47
+ return new Response("Only POST requests are allowed in worklfows", { status: 405 });
48
+ }
49
+ const serveHandler = _chunkMFQHGR5Vjs.serve.call(void 0, routeFunction, options);
50
+ try {
51
+ const result = await serveHandler(event.request);
52
+ return result;
53
+ } catch (error) {
54
+ console.error(error);
55
+ return new Response(JSON.stringify(_chunkMFQHGR5Vjs.formatWorkflowError.call(void 0, error)), { status: 500 });
56
+ }
57
+ };
58
+ return handler;
59
+ };
60
+
41
61
 
42
62
 
43
- exports.verifySignatureSolidjs = verifySignatureSolidjs;
63
+ exports.serve = serve2; exports.verifySignatureSolidjs = verifySignatureSolidjs;
package/solidjs.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import "./chunk-6HSNQRF3.mjs";
1
+ import "./chunk-TAUBWUPA.mjs";
2
2
  import {
3
- Receiver
4
- } from "./chunk-CP4IU45K.mjs";
3
+ Receiver,
4
+ formatWorkflowError,
5
+ serve
6
+ } from "./chunk-DH2LYTLA.mjs";
5
7
 
6
8
  // platforms/solidjs.ts
7
9
  var verifySignatureSolidjs = (handler, config) => {
@@ -38,6 +40,24 @@ var verifySignatureSolidjs = (handler, config) => {
38
40
  return handler(event);
39
41
  };
40
42
  };
43
+ var serve2 = (routeFunction, options) => {
44
+ const handler = async (event) => {
45
+ const method = event.request.method;
46
+ if (method.toUpperCase() !== "POST") {
47
+ return new Response("Only POST requests are allowed in worklfows", { status: 405 });
48
+ }
49
+ const serveHandler = serve(routeFunction, options);
50
+ try {
51
+ const result = await serveHandler(event.request);
52
+ return result;
53
+ } catch (error) {
54
+ console.error(error);
55
+ return new Response(JSON.stringify(formatWorkflowError(error)), { status: 500 });
56
+ }
57
+ };
58
+ return handler;
59
+ };
41
60
  export {
61
+ serve2 as serve,
42
62
  verifySignatureSolidjs
43
63
  };
package/svelte.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { RequestHandler } from '@sveltejs/kit';
2
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.mjs';
3
+ import 'neverthrow';
2
4
 
3
5
  type VerifySignatureConfig = {
4
6
  currentSigningKey: string;
@@ -6,5 +8,6 @@ type VerifySignatureConfig = {
6
8
  clockTolerance?: number;
7
9
  };
8
10
  declare const verifySignatureSvelte: <Parameters extends Partial<Record<string, string>> = Partial<Record<string, string>>, RouteId extends string | null = string | null>(handler: RequestHandler<Parameters, RouteId>, config: VerifySignatureConfig) => RequestHandler<Parameters, RouteId>;
11
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, qstashClient: WorkflowServeOptions["qstashClient"], options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish" | "qstashClient">) => RequestHandler;
9
12
 
10
- export { verifySignatureSvelte };
13
+ export { serve, verifySignatureSvelte };
package/svelte.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { RequestHandler } from '@sveltejs/kit';
2
+ import { $ as RouteFunction, a0 as WorkflowServeOptions } from './client-CzkJKX67.js';
3
+ import 'neverthrow';
2
4
 
3
5
  type VerifySignatureConfig = {
4
6
  currentSigningKey: string;
@@ -6,5 +8,6 @@ type VerifySignatureConfig = {
6
8
  clockTolerance?: number;
7
9
  };
8
10
  declare const verifySignatureSvelte: <Parameters extends Partial<Record<string, string>> = Partial<Record<string, string>>, RouteId extends string | null = string | null>(handler: RequestHandler<Parameters, RouteId>, config: VerifySignatureConfig) => RequestHandler<Parameters, RouteId>;
11
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, qstashClient: WorkflowServeOptions["qstashClient"], options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish" | "qstashClient">) => RequestHandler;
9
12
 
10
- export { verifySignatureSvelte };
13
+ export { serve, verifySignatureSvelte };
package/svelte.js CHANGED
@@ -1,7 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-MZSHBRF6.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-F6QRAN74.js');
2
2
 
3
3
 
4
- var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
4
+
5
+
6
+ var _chunkMFQHGR5Vjs = require('./chunk-MFQHGR5V.js');
5
7
 
6
8
  // platforms/svelte.ts
7
9
  var verifySignatureSvelte = (handler, config) => {
@@ -13,7 +15,7 @@ var verifySignatureSvelte = (handler, config) => {
13
15
  if (!nextSigningKey) {
14
16
  throw new Error("nextSigningKey is required, either in the config or from the env");
15
17
  }
16
- const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
18
+ const receiver = new (0, _chunkMFQHGR5Vjs.Receiver)({
17
19
  currentSigningKey,
18
20
  nextSigningKey
19
21
  });
@@ -39,6 +41,22 @@ var verifySignatureSvelte = (handler, config) => {
39
41
  };
40
42
  return wrappedHandler;
41
43
  };
44
+ var serve2 = (routeFunction, qstashClient, options) => {
45
+ const handler = async ({ request }) => {
46
+ const serveMethod = _chunkMFQHGR5Vjs.serve.call(void 0, routeFunction, {
47
+ qstashClient,
48
+ ...options
49
+ });
50
+ try {
51
+ return await serveMethod(request);
52
+ } catch (error) {
53
+ console.error(error);
54
+ return new Response(JSON.stringify(_chunkMFQHGR5Vjs.formatWorkflowError.call(void 0, error)), { status: 500 });
55
+ }
56
+ };
57
+ return handler;
58
+ };
59
+
42
60
 
43
61
 
44
- exports.verifySignatureSvelte = verifySignatureSvelte;
62
+ exports.serve = serve2; exports.verifySignatureSvelte = verifySignatureSvelte;
package/svelte.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import "./chunk-6HSNQRF3.mjs";
1
+ import "./chunk-TAUBWUPA.mjs";
2
2
  import {
3
- Receiver
4
- } from "./chunk-CP4IU45K.mjs";
3
+ Receiver,
4
+ formatWorkflowError,
5
+ serve
6
+ } from "./chunk-DH2LYTLA.mjs";
5
7
 
6
8
  // platforms/svelte.ts
7
9
  var verifySignatureSvelte = (handler, config) => {
@@ -39,6 +41,22 @@ var verifySignatureSvelte = (handler, config) => {
39
41
  };
40
42
  return wrappedHandler;
41
43
  };
44
+ var serve2 = (routeFunction, qstashClient, options) => {
45
+ const handler = async ({ request }) => {
46
+ const serveMethod = serve(routeFunction, {
47
+ qstashClient,
48
+ ...options
49
+ });
50
+ try {
51
+ return await serveMethod(request);
52
+ } catch (error) {
53
+ console.error(error);
54
+ return new Response(JSON.stringify(formatWorkflowError(error)), { status: 500 });
55
+ }
56
+ };
57
+ return handler;
58
+ };
42
59
  export {
60
+ serve2 as serve,
43
61
  verifySignatureSvelte
44
62
  };
package/workflow.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ export { a9 as AsyncStepFunction, a4 as DisabledWorkflowContext, F as FailureFunctionPayload, ac as FinishCondition, ae as LogLevel, ab as ParallelCallState, a7 as RawStep, ad as RequiredExceptFields, $ as RouteFunction, S as Step, aa as StepFunction, a6 as StepType, a5 as StepTypes, a8 as SyncStepFunction, a1 as Workflow, a3 as WorkflowContext, ag as WorkflowLogger, af as WorkflowLoggerOptions, a0 as WorkflowServeOptions, a2 as serve } from './client-CzkJKX67.mjs';
2
+ import 'neverthrow';
package/workflow.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { a9 as AsyncStepFunction, a4 as DisabledWorkflowContext, F as FailureFunctionPayload, ac as FinishCondition, ae as LogLevel, ab as ParallelCallState, a7 as RawStep, ad as RequiredExceptFields, $ as RouteFunction, S as Step, aa as StepFunction, a6 as StepType, a5 as StepTypes, a8 as SyncStepFunction, a1 as Workflow, a3 as WorkflowContext, ag as WorkflowLogger, af as WorkflowLoggerOptions, a0 as WorkflowServeOptions, a2 as serve } from './client-CzkJKX67.js';
2
+ import 'neverthrow';
package/workflow.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+ var _chunkMFQHGR5Vjs = require('./chunk-MFQHGR5V.js');
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ exports.DisabledWorkflowContext = _chunkMFQHGR5Vjs.DisabledWorkflowContext; exports.StepTypes = _chunkMFQHGR5Vjs.StepTypes; exports.Workflow = _chunkMFQHGR5Vjs.Workflow; exports.WorkflowContext = _chunkMFQHGR5Vjs.WorkflowContext; exports.WorkflowLogger = _chunkMFQHGR5Vjs.WorkflowLogger; exports.serve = _chunkMFQHGR5Vjs.serve;