@upstash/qstash 2.6.3 → 2.6.4-workflow-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,11 +55,11 @@ import { Client } from "@upstash/qstash";
55
55
  */
56
56
  import "isomorphic-fetch";
57
57
 
58
- const client = new Client({
58
+ const c = new Client({
59
59
  token: "<QSTASH_TOKEN>",
60
60
  });
61
61
 
62
- const res = await client.publishJSON({
62
+ const res = await c.publishJSON({
63
63
  url: "https://my-api...",
64
64
  // or urlGroup: "the name or id of a url group"
65
65
  body: {
@@ -107,7 +107,7 @@ No need for complicated setup your LLM request. We'll call LLM and schedule it f
107
107
  ```ts
108
108
  import { Client, openai } from "@upstash/qstash";
109
109
 
110
- const client = new Client({
110
+ const c = new Client({
111
111
  token: "<QSTASH_TOKEN>",
112
112
  });
113
113
 
@@ -131,11 +131,7 @@ const result = await client.publishJSON({
131
131
  You can easily start streaming Upstash or OpenAI responses from your favorite framework(Next.js) or library
132
132
 
133
133
  ```ts
134
- import { Client, upstash } from "@upstash/qstash";
135
-
136
- const client = new Client({
137
- token: "<QSTASH_TOKEN>",
138
- });
134
+ import { upstash } from "@upstash/qstash";
139
135
 
140
136
  const response = await client.chat().create({
141
137
  provider: upstash(), // Optionally, provider: "custom({token: "XXX", baseUrl: "https://api.openai.com"})". This will allow you to call every OpenAI compatible API out there.
@@ -155,43 +151,6 @@ const response = await client.chat().create({
155
151
  });
156
152
  ```
157
153
 
158
- ### Add Observability via Helicone
159
-
160
- Helicone is a powerful observability platform that provides valuable insights into your LLM usage. Integrating Helicone with QStash is straightforward.
161
-
162
- To enable Helicone observability in QStash, you simply need to pass your Helicone API key when initializing your model. Here's how to do it for both custom models and OpenAI:
163
-
164
- #### For Custom Models (e.g., Meta-Llama)
165
-
166
- ```ts
167
- import { Client, custom } from "@upstash/qstash";
168
-
169
- const client = new Client({
170
- token: "<QSTASH_TOKEN>",
171
- });
172
-
173
- await client.publishJSON({
174
- api: {
175
- name: "llm",
176
- provider: custom({
177
- token: "XXX",
178
- baseUrl: "https://api.together.xyz",
179
- }),
180
- analytics: { name: "helicone", token: process.env.HELICONE_API_KEY! },
181
- },
182
- body: {
183
- model: "meta-llama/Llama-3-8b-chat-hf",
184
- messages: [
185
- {
186
- role: "user",
187
- content: "hello",
188
- },
189
- ],
190
- },
191
- callback: "https://oz.requestcatcher.com/",
192
- });
193
- ```
194
-
195
154
  ## Docs
196
155
 
197
156
  See [the documentation](https://docs.upstash.com/qstash) for details.
@@ -199,7 +158,3 @@ See [the documentation](https://docs.upstash.com/qstash) for details.
199
158
  ## Contributing
200
159
 
201
160
  ### [Install Deno](https://deno.land/#installation)
202
-
203
- ```
204
-
205
- ```
package/package.json CHANGED
@@ -1 +1 @@
1
- {"version":"v2.6.3","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":"2.6.4-workflow-alpha.1","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":["dist"],"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"}}
@@ -1,59 +0,0 @@
1
- // src/receiver.ts
2
- import * as jose from "jose";
3
- import crypto from "crypto-js";
4
- var SignatureError = class extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = "SignatureError";
8
- }
9
- };
10
- var Receiver = class {
11
- currentSigningKey;
12
- nextSigningKey;
13
- constructor(config) {
14
- this.currentSigningKey = config.currentSigningKey;
15
- this.nextSigningKey = config.nextSigningKey;
16
- }
17
- /**
18
- * Verify the signature of a request.
19
- *
20
- * Tries to verify the signature with the current signing key.
21
- * If that fails, maybe because you have rotated the keys recently, it will
22
- * try to verify the signature with the next signing key.
23
- *
24
- * If that fails, the signature is invalid and a `SignatureError` is thrown.
25
- */
26
- async verify(request) {
27
- const isValid = await this.verifyWithKey(this.currentSigningKey, request);
28
- if (isValid) {
29
- return true;
30
- }
31
- return this.verifyWithKey(this.nextSigningKey, request);
32
- }
33
- /**
34
- * Verify signature with a specific signing key
35
- */
36
- async verifyWithKey(key, request) {
37
- const jwt = await jose.jwtVerify(request.signature, new TextEncoder().encode(key), {
38
- issuer: "Upstash",
39
- clockTolerance: request.clockTolerance
40
- }).catch((error) => {
41
- throw new SignatureError(error.message);
42
- });
43
- const p = jwt.payload;
44
- if (request.url !== void 0 && p.sub !== request.url) {
45
- throw new SignatureError(`invalid subject: ${p.sub}, want: ${request.url}`);
46
- }
47
- const bodyHash = crypto.SHA256(request.body).toString(crypto.enc.Base64url);
48
- const padding = new RegExp(/=+$/);
49
- if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
50
- throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${bodyHash}`);
51
- }
52
- return true;
53
- }
54
- };
55
-
56
- export {
57
- SignatureError,
58
- Receiver
59
- };