@vercel/queue 0.0.1 → 0.0.2
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 +14 -3
- package/dist/index.d.mts +26 -5
- package/dist/index.d.ts +26 -5
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -332,15 +332,26 @@ export const { send, receive, handleCallback, handleNodeCallback } = queue;
|
|
|
332
332
|
|
|
333
333
|
The client sends requests to `https://${region}.vercel-queue.com`. When `handleCallback` receives a message, it reads the `ce-vqsregion` header and routes follow-up API calls to the correct regional endpoint.
|
|
334
334
|
|
|
335
|
-
To customize the URL scheme, provide a `resolveBaseUrl`:
|
|
335
|
+
To customize the URL scheme, provide a `resolveBaseUrl` that returns a `URL`:
|
|
336
336
|
|
|
337
337
|
```typescript
|
|
338
|
+
// Custom domain
|
|
338
339
|
const queue = new QueueClient({
|
|
339
340
|
region: process.env.QUEUE_REGION!,
|
|
340
|
-
resolveBaseUrl: (region) => `https://${region}.my-proxy.example
|
|
341
|
+
resolveBaseUrl: (region) => new URL(`https://${region}.my-proxy.example`),
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Custom domain with a base path (e.g. reverse proxy prefix)
|
|
345
|
+
const queue = new QueueClient({
|
|
346
|
+
region: process.env.QUEUE_REGION!,
|
|
347
|
+
resolveBaseUrl: (region) =>
|
|
348
|
+
new URL(`https://my-proxy.example/queues/${region}`),
|
|
349
|
+
// → requests go to https://my-proxy.example/queues/<region>/api/v3/…
|
|
341
350
|
});
|
|
342
351
|
```
|
|
343
352
|
|
|
353
|
+
The SDK always appends its own API path (`/api/v3/…`) to the returned URL.
|
|
354
|
+
|
|
344
355
|
## Transports
|
|
345
356
|
|
|
346
357
|
The transport controls how message payloads are serialized and deserialized.
|
|
@@ -552,7 +563,7 @@ import { QueueClient } from "@vercel/queue";
|
|
|
552
563
|
|
|
553
564
|
const queue = new QueueClient({
|
|
554
565
|
region: process.env.QUEUE_REGION!, // Required — see Quick Start for env setup
|
|
555
|
-
resolveBaseUrl: (r) => `https://${r}.vercel-queue.com
|
|
566
|
+
resolveBaseUrl: (r) => new URL(`https://${r}.vercel-queue.com`), // Default resolver
|
|
556
567
|
token: "my-token", // Auto-fetched via OIDC if omitted
|
|
557
568
|
headers: { "X-Custom": "value" },
|
|
558
569
|
transport: new JsonTransport(), // Default: JsonTransport
|
package/dist/index.d.mts
CHANGED
|
@@ -130,11 +130,24 @@ declare class StreamTransport implements Transport<ReadableStream<Uint8Array>> {
|
|
|
130
130
|
*/
|
|
131
131
|
type VercelRegion = "arn1" | "bom1" | "cdg1" | "cle1" | "cpt1" | "dub1" | "dxb1" | "fra1" | "gru1" | "hkg1" | "hnd1" | "iad1" | "icn1" | "kix1" | "lhr1" | "pdx1" | "sfo1" | "sin1" | "syd1" | "yul1" | (string & {});
|
|
132
132
|
/**
|
|
133
|
-
* Resolves a region code to a base URL for the Vercel Queue Service API.
|
|
133
|
+
* Resolves a region code to a base {@link URL} for the Vercel Queue Service API.
|
|
134
134
|
*
|
|
135
|
-
*
|
|
135
|
+
* The SDK appends its own API path (`/api/v3/…`) to the returned URL.
|
|
136
|
+
* To add a prefix (e.g. when routing through a reverse proxy), include it
|
|
137
|
+
* in the pathname of the returned URL:
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* // Default — domain only, no prefix:
|
|
141
|
+
* (region) => new URL(`https://${region}.vercel-queue.com`)
|
|
142
|
+
*
|
|
143
|
+
* // Custom domain with a base path:
|
|
144
|
+
* (region) => new URL(`https://my-proxy.example/custom-prefix`)
|
|
145
|
+
* // → requests go to https://my-proxy.example/custom-prefix/api/v3/…
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* Default: `` (region) => new URL(`https://${region}.vercel-queue.com`) ``
|
|
136
149
|
*/
|
|
137
|
-
type BaseUrlResolver = (region: string) =>
|
|
150
|
+
type BaseUrlResolver = (region: string) => URL;
|
|
138
151
|
interface QueueClientOptions {
|
|
139
152
|
/**
|
|
140
153
|
* Vercel region code for API routing.
|
|
@@ -152,8 +165,16 @@ interface QueueClientOptions {
|
|
|
152
165
|
*/
|
|
153
166
|
region: VercelRegion;
|
|
154
167
|
/**
|
|
155
|
-
* Custom resolver that maps a region code to a base URL.
|
|
156
|
-
*
|
|
168
|
+
* Custom resolver that maps a region code to a base {@link URL}.
|
|
169
|
+
*
|
|
170
|
+
* The SDK always appends its own API path (`/api/v3/…`) to the returned URL.
|
|
171
|
+
* Include a pathname to add a prefix (e.g. for reverse-proxy routing):
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* resolveBaseUrl: (region) => new URL(`https://my-proxy.example/prefix`)
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @default (region) => new URL(`https://${region}.vercel-queue.com`)
|
|
157
178
|
*/
|
|
158
179
|
resolveBaseUrl?: BaseUrlResolver;
|
|
159
180
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -130,11 +130,24 @@ declare class StreamTransport implements Transport<ReadableStream<Uint8Array>> {
|
|
|
130
130
|
*/
|
|
131
131
|
type VercelRegion = "arn1" | "bom1" | "cdg1" | "cle1" | "cpt1" | "dub1" | "dxb1" | "fra1" | "gru1" | "hkg1" | "hnd1" | "iad1" | "icn1" | "kix1" | "lhr1" | "pdx1" | "sfo1" | "sin1" | "syd1" | "yul1" | (string & {});
|
|
132
132
|
/**
|
|
133
|
-
* Resolves a region code to a base URL for the Vercel Queue Service API.
|
|
133
|
+
* Resolves a region code to a base {@link URL} for the Vercel Queue Service API.
|
|
134
134
|
*
|
|
135
|
-
*
|
|
135
|
+
* The SDK appends its own API path (`/api/v3/…`) to the returned URL.
|
|
136
|
+
* To add a prefix (e.g. when routing through a reverse proxy), include it
|
|
137
|
+
* in the pathname of the returned URL:
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* // Default — domain only, no prefix:
|
|
141
|
+
* (region) => new URL(`https://${region}.vercel-queue.com`)
|
|
142
|
+
*
|
|
143
|
+
* // Custom domain with a base path:
|
|
144
|
+
* (region) => new URL(`https://my-proxy.example/custom-prefix`)
|
|
145
|
+
* // → requests go to https://my-proxy.example/custom-prefix/api/v3/…
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* Default: `` (region) => new URL(`https://${region}.vercel-queue.com`) ``
|
|
136
149
|
*/
|
|
137
|
-
type BaseUrlResolver = (region: string) =>
|
|
150
|
+
type BaseUrlResolver = (region: string) => URL;
|
|
138
151
|
interface QueueClientOptions {
|
|
139
152
|
/**
|
|
140
153
|
* Vercel region code for API routing.
|
|
@@ -152,8 +165,16 @@ interface QueueClientOptions {
|
|
|
152
165
|
*/
|
|
153
166
|
region: VercelRegion;
|
|
154
167
|
/**
|
|
155
|
-
* Custom resolver that maps a region code to a base URL.
|
|
156
|
-
*
|
|
168
|
+
* Custom resolver that maps a region code to a base {@link URL}.
|
|
169
|
+
*
|
|
170
|
+
* The SDK always appends its own API path (`/api/v3/…`) to the returned URL.
|
|
171
|
+
* Include a pathname to add a prefix (e.g. for reverse-proxy routing):
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* resolveBaseUrl: (region) => new URL(`https://my-proxy.example/prefix`)
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* @default (region) => new URL(`https://${region}.vercel-queue.com`)
|
|
157
178
|
*/
|
|
158
179
|
resolveBaseUrl?: BaseUrlResolver;
|
|
159
180
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1021,7 +1021,7 @@ function parseQueueHeaders(headers) {
|
|
|
1021
1021
|
receiptHandle
|
|
1022
1022
|
};
|
|
1023
1023
|
}
|
|
1024
|
-
var DEFAULT_BASE_URL_RESOLVER = (region) => `https://${region}.vercel-queue.com
|
|
1024
|
+
var DEFAULT_BASE_URL_RESOLVER = (region) => new URL(`https://${region}.vercel-queue.com`);
|
|
1025
1025
|
function resolveBaseUrl(region, resolver) {
|
|
1026
1026
|
return (resolver ?? DEFAULT_BASE_URL_RESOLVER)(region);
|
|
1027
1027
|
}
|
|
@@ -1112,7 +1112,8 @@ var ApiClient = class _ApiClient {
|
|
|
1112
1112
|
const encodedQueue = encodeURIComponent(queueName);
|
|
1113
1113
|
const segments = pathSegments.map((s) => encodeURIComponent(s));
|
|
1114
1114
|
const path2 = segments.length > 0 ? "/" + segments.join("/") : "";
|
|
1115
|
-
|
|
1115
|
+
const basePath = this.baseUrl.pathname.replace(/\/+$/, "");
|
|
1116
|
+
return `${this.baseUrl.origin}${basePath}${BASE_PATH}/${encodedQueue}${path2}`;
|
|
1116
1117
|
}
|
|
1117
1118
|
async fetch(url, init) {
|
|
1118
1119
|
const method = init.method || "GET";
|
|
@@ -1136,7 +1137,7 @@ var ApiClient = class _ApiClient {
|
|
|
1136
1137
|
}
|
|
1137
1138
|
console.debug("[VQS Debug] Request:", JSON.stringify(logData, null, 2));
|
|
1138
1139
|
}
|
|
1139
|
-
init.headers.set("User-Agent", `@vercel/queue/${"0.0.
|
|
1140
|
+
init.headers.set("User-Agent", `@vercel/queue/${"0.0.2"}`);
|
|
1140
1141
|
init.headers.set("Vqs-Client-Ts", (/* @__PURE__ */ new Date()).toISOString());
|
|
1141
1142
|
const response = await fetch(url, init);
|
|
1142
1143
|
if (isDebugEnabled()) {
|