@upstash/qstash 2.7.0-canary → 2.7.0-canary-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/index.d.mts +3 -1
- package/index.d.ts +3 -1
- package/index.js +18 -10
- package/index.mjs +18 -10
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -468,7 +468,8 @@ declare class DLQ {
|
|
|
468
468
|
|
|
469
469
|
declare class Chat {
|
|
470
470
|
private http;
|
|
471
|
-
|
|
471
|
+
private token;
|
|
472
|
+
constructor(http: Requester, token: string);
|
|
472
473
|
private static toChatRequest;
|
|
473
474
|
/**
|
|
474
475
|
* Calls the Upstash completions api given a ChatRequest.
|
|
@@ -957,6 +958,7 @@ type QueueRequest = {
|
|
|
957
958
|
};
|
|
958
959
|
declare class Client {
|
|
959
960
|
http: Requester;
|
|
961
|
+
private token;
|
|
960
962
|
constructor(config: ClientConfig);
|
|
961
963
|
/**
|
|
962
964
|
* Access the urlGroup API.
|
package/index.d.ts
CHANGED
|
@@ -468,7 +468,8 @@ declare class DLQ {
|
|
|
468
468
|
|
|
469
469
|
declare class Chat {
|
|
470
470
|
private http;
|
|
471
|
-
|
|
471
|
+
private token;
|
|
472
|
+
constructor(http: Requester, token: string);
|
|
472
473
|
private static toChatRequest;
|
|
473
474
|
/**
|
|
474
475
|
* Calls the Upstash completions api given a ChatRequest.
|
|
@@ -957,6 +958,7 @@ type QueueRequest = {
|
|
|
957
958
|
};
|
|
958
959
|
declare class Client {
|
|
959
960
|
http: Requester;
|
|
961
|
+
private token;
|
|
960
962
|
constructor(config: ClientConfig);
|
|
961
963
|
/**
|
|
962
964
|
* Access the urlGroup API.
|
package/index.js
CHANGED
|
@@ -204,8 +204,10 @@ var HttpClient = (_class = class {
|
|
|
204
204
|
// src/client/llm/chat.ts
|
|
205
205
|
var Chat = (_class2 = class _Chat {
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
|
|
208
|
+
constructor(http, token) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
|
|
208
209
|
this.http = http;
|
|
210
|
+
this.token = token;
|
|
209
211
|
}
|
|
210
212
|
static toChatRequest(request) {
|
|
211
213
|
const messages = [];
|
|
@@ -226,7 +228,7 @@ var Chat = (_class2 = class _Chat {
|
|
|
226
228
|
* @returns Chat completion or stream
|
|
227
229
|
*/
|
|
228
230
|
__init3() {this.create = async (request) => {
|
|
229
|
-
if (request.provider.owner
|
|
231
|
+
if (request.provider.owner != "upstash")
|
|
230
232
|
return this.createThirdParty(request);
|
|
231
233
|
const body = JSON.stringify(request);
|
|
232
234
|
if ("stream" in request && request.stream) {
|
|
@@ -237,7 +239,8 @@ var Chat = (_class2 = class _Chat {
|
|
|
237
239
|
"Content-Type": "application/json",
|
|
238
240
|
Connection: "keep-alive",
|
|
239
241
|
Accept: "text/event-stream",
|
|
240
|
-
"Cache-Control": "no-cache"
|
|
242
|
+
"Cache-Control": "no-cache",
|
|
243
|
+
Authorization: `Bearer ${this.token}`
|
|
241
244
|
},
|
|
242
245
|
body
|
|
243
246
|
});
|
|
@@ -245,7 +248,7 @@ var Chat = (_class2 = class _Chat {
|
|
|
245
248
|
return this.http.request({
|
|
246
249
|
path: ["llm", "v1", "chat", "completions"],
|
|
247
250
|
method: "POST",
|
|
248
|
-
headers: { "Content-Type": "application/json" },
|
|
251
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.token}` },
|
|
249
252
|
body
|
|
250
253
|
});
|
|
251
254
|
}}
|
|
@@ -320,7 +323,7 @@ function appendLLMOptionsIfNeeded(request, headers) {
|
|
|
320
323
|
throw new Error("baseUrl cannot be empty or undefined!");
|
|
321
324
|
if (!provider.token)
|
|
322
325
|
throw new Error("token cannot be empty or undefined!");
|
|
323
|
-
request.url = `${provider.baseUrl}/v1/chat/
|
|
326
|
+
request.url = `${provider.baseUrl}/v1/chat/completions`;
|
|
324
327
|
headers.set("Authorization", `Bearer ${provider.token}`);
|
|
325
328
|
}
|
|
326
329
|
}
|
|
@@ -704,12 +707,14 @@ var UrlGroups = class {
|
|
|
704
707
|
// src/client/client.ts
|
|
705
708
|
var Client = class {
|
|
706
709
|
|
|
710
|
+
|
|
707
711
|
constructor(config) {
|
|
708
712
|
this.http = new HttpClient({
|
|
709
713
|
retry: config.retry,
|
|
710
714
|
baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
|
|
711
715
|
authorization: `Bearer ${config.token}`
|
|
712
716
|
});
|
|
717
|
+
this.token = config.token;
|
|
713
718
|
}
|
|
714
719
|
/**
|
|
715
720
|
* Access the urlGroup API.
|
|
@@ -757,7 +762,7 @@ var Client = class {
|
|
|
757
762
|
* Call the create or prompt methods
|
|
758
763
|
*/
|
|
759
764
|
chat() {
|
|
760
|
-
return new Chat(this.http);
|
|
765
|
+
return new Chat(this.http, this.token);
|
|
761
766
|
}
|
|
762
767
|
async publish(request) {
|
|
763
768
|
const headers = processHeaders(request);
|
|
@@ -875,12 +880,10 @@ var Client = class {
|
|
|
875
880
|
|
|
876
881
|
// src/client/llm/providers.ts
|
|
877
882
|
var upstash = () => {
|
|
878
|
-
if (!process.env.QSTASH_TOKEN)
|
|
879
|
-
throw new Error("QSTASH_TOKEN cannot be empty or undefined!");
|
|
880
883
|
return {
|
|
881
884
|
owner: "upstash",
|
|
882
885
|
baseUrl: "https://qstash.upstash.io/llm",
|
|
883
|
-
token:
|
|
886
|
+
token: ""
|
|
884
887
|
};
|
|
885
888
|
};
|
|
886
889
|
var openai = ({
|
|
@@ -892,7 +895,12 @@ var custom = ({
|
|
|
892
895
|
baseUrl,
|
|
893
896
|
token
|
|
894
897
|
}) => {
|
|
895
|
-
|
|
898
|
+
const trimmedBaseUrl = baseUrl.replace(/\/(v1\/)?chat\/completions$/, "");
|
|
899
|
+
return {
|
|
900
|
+
token,
|
|
901
|
+
owner: "custom",
|
|
902
|
+
baseUrl: trimmedBaseUrl
|
|
903
|
+
};
|
|
896
904
|
};
|
|
897
905
|
|
|
898
906
|
|
package/index.mjs
CHANGED
|
@@ -204,8 +204,10 @@ var HttpClient = class {
|
|
|
204
204
|
// src/client/llm/chat.ts
|
|
205
205
|
var Chat = class _Chat {
|
|
206
206
|
http;
|
|
207
|
-
|
|
207
|
+
token;
|
|
208
|
+
constructor(http, token) {
|
|
208
209
|
this.http = http;
|
|
210
|
+
this.token = token;
|
|
209
211
|
}
|
|
210
212
|
static toChatRequest(request) {
|
|
211
213
|
const messages = [];
|
|
@@ -226,7 +228,7 @@ var Chat = class _Chat {
|
|
|
226
228
|
* @returns Chat completion or stream
|
|
227
229
|
*/
|
|
228
230
|
create = async (request) => {
|
|
229
|
-
if (request.provider.owner
|
|
231
|
+
if (request.provider.owner != "upstash")
|
|
230
232
|
return this.createThirdParty(request);
|
|
231
233
|
const body = JSON.stringify(request);
|
|
232
234
|
if ("stream" in request && request.stream) {
|
|
@@ -237,7 +239,8 @@ var Chat = class _Chat {
|
|
|
237
239
|
"Content-Type": "application/json",
|
|
238
240
|
Connection: "keep-alive",
|
|
239
241
|
Accept: "text/event-stream",
|
|
240
|
-
"Cache-Control": "no-cache"
|
|
242
|
+
"Cache-Control": "no-cache",
|
|
243
|
+
Authorization: `Bearer ${this.token}`
|
|
241
244
|
},
|
|
242
245
|
body
|
|
243
246
|
});
|
|
@@ -245,7 +248,7 @@ var Chat = class _Chat {
|
|
|
245
248
|
return this.http.request({
|
|
246
249
|
path: ["llm", "v1", "chat", "completions"],
|
|
247
250
|
method: "POST",
|
|
248
|
-
headers: { "Content-Type": "application/json" },
|
|
251
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.token}` },
|
|
249
252
|
body
|
|
250
253
|
});
|
|
251
254
|
};
|
|
@@ -320,7 +323,7 @@ function appendLLMOptionsIfNeeded(request, headers) {
|
|
|
320
323
|
throw new Error("baseUrl cannot be empty or undefined!");
|
|
321
324
|
if (!provider.token)
|
|
322
325
|
throw new Error("token cannot be empty or undefined!");
|
|
323
|
-
request.url = `${provider.baseUrl}/v1/chat/
|
|
326
|
+
request.url = `${provider.baseUrl}/v1/chat/completions`;
|
|
324
327
|
headers.set("Authorization", `Bearer ${provider.token}`);
|
|
325
328
|
}
|
|
326
329
|
}
|
|
@@ -704,12 +707,14 @@ var UrlGroups = class {
|
|
|
704
707
|
// src/client/client.ts
|
|
705
708
|
var Client = class {
|
|
706
709
|
http;
|
|
710
|
+
token;
|
|
707
711
|
constructor(config) {
|
|
708
712
|
this.http = new HttpClient({
|
|
709
713
|
retry: config.retry,
|
|
710
714
|
baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
|
|
711
715
|
authorization: `Bearer ${config.token}`
|
|
712
716
|
});
|
|
717
|
+
this.token = config.token;
|
|
713
718
|
}
|
|
714
719
|
/**
|
|
715
720
|
* Access the urlGroup API.
|
|
@@ -757,7 +762,7 @@ var Client = class {
|
|
|
757
762
|
* Call the create or prompt methods
|
|
758
763
|
*/
|
|
759
764
|
chat() {
|
|
760
|
-
return new Chat(this.http);
|
|
765
|
+
return new Chat(this.http, this.token);
|
|
761
766
|
}
|
|
762
767
|
async publish(request) {
|
|
763
768
|
const headers = processHeaders(request);
|
|
@@ -875,12 +880,10 @@ var Client = class {
|
|
|
875
880
|
|
|
876
881
|
// src/client/llm/providers.ts
|
|
877
882
|
var upstash = () => {
|
|
878
|
-
if (!process.env.QSTASH_TOKEN)
|
|
879
|
-
throw new Error("QSTASH_TOKEN cannot be empty or undefined!");
|
|
880
883
|
return {
|
|
881
884
|
owner: "upstash",
|
|
882
885
|
baseUrl: "https://qstash.upstash.io/llm",
|
|
883
|
-
token:
|
|
886
|
+
token: ""
|
|
884
887
|
};
|
|
885
888
|
};
|
|
886
889
|
var openai = ({
|
|
@@ -892,7 +895,12 @@ var custom = ({
|
|
|
892
895
|
baseUrl,
|
|
893
896
|
token
|
|
894
897
|
}) => {
|
|
895
|
-
|
|
898
|
+
const trimmedBaseUrl = baseUrl.replace(/\/(v1\/)?chat\/completions$/, "");
|
|
899
|
+
return {
|
|
900
|
+
token,
|
|
901
|
+
owner: "custom",
|
|
902
|
+
baseUrl: trimmedBaseUrl
|
|
903
|
+
};
|
|
896
904
|
};
|
|
897
905
|
export {
|
|
898
906
|
Chat,
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"v2.7.0-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":{"import":"./nextjs.js","require":"./nextjs.js"},"./dist/nextjs":{"import":"./nextjs.js","require":"./nextjs.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":{"crypto-js":">=4.2.0","jose":"^ 5.2.3"}}
|
|
1
|
+
{"version":"v2.7.0-canary-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":["./**"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./nextjs":{"import":"./nextjs.js","require":"./nextjs.js"},"./dist/nextjs":{"import":"./nextjs.js","require":"./nextjs.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":{"crypto-js":">=4.2.0","jose":"^ 5.2.3"}}
|