@vercel/queue 0.0.0-alpha.35 → 0.0.0-alpha.37
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 +4 -14
- package/dist/index.d.mts +2 -7
- package/dist/index.d.ts +2 -7
- package/dist/index.js +29 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -69
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs-pages.d.mts +1 -1
- package/dist/nextjs-pages.d.ts +1 -1
- package/dist/nextjs-pages.js +27 -67
- package/dist/nextjs-pages.js.map +1 -1
- package/dist/nextjs-pages.mjs +27 -67
- package/dist/nextjs-pages.mjs.map +1 -1
- package/dist/{types-BLG4ASI_.d.mts → types-CAA8nT8x.d.mts} +6 -25
- package/dist/{types-BLG4ASI_.d.ts → types-CAA8nT8x.d.ts} +6 -25
- package/package.json +1 -1
package/dist/nextjs-pages.js
CHANGED
|
@@ -146,18 +146,6 @@ var MessageAlreadyProcessedError = class extends Error {
|
|
|
146
146
|
this.name = "MessageAlreadyProcessedError";
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
|
-
var ConcurrencyLimitError = class extends Error {
|
|
150
|
-
/** Current number of in-flight messages for this consumer group. */
|
|
151
|
-
currentInflight;
|
|
152
|
-
/** Maximum allowed concurrent messages (as configured). */
|
|
153
|
-
maxConcurrency;
|
|
154
|
-
constructor(message = "Concurrency limit exceeded", currentInflight, maxConcurrency) {
|
|
155
|
-
super(message);
|
|
156
|
-
this.name = "ConcurrencyLimitError";
|
|
157
|
-
this.currentInflight = currentInflight;
|
|
158
|
-
this.maxConcurrency = maxConcurrency;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
149
|
var DuplicateMessageError = class extends Error {
|
|
162
150
|
idempotencyKey;
|
|
163
151
|
constructor(message, idempotencyKey) {
|
|
@@ -561,13 +549,30 @@ var QueueClient = class {
|
|
|
561
549
|
payload,
|
|
562
550
|
idempotencyKey,
|
|
563
551
|
retentionSeconds,
|
|
564
|
-
delaySeconds
|
|
552
|
+
delaySeconds,
|
|
553
|
+
headers: optionHeaders
|
|
565
554
|
} = options;
|
|
566
|
-
const headers = new Headers(
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
555
|
+
const headers = new Headers();
|
|
556
|
+
if (this.customHeaders) {
|
|
557
|
+
for (const [name, value] of Object.entries(this.customHeaders)) {
|
|
558
|
+
headers.append(name, value);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (optionHeaders) {
|
|
562
|
+
const protectedHeaderNames = /* @__PURE__ */ new Set(["authorization", "content-type"]);
|
|
563
|
+
const isProtectedHeader = (name) => {
|
|
564
|
+
const lower = name.toLowerCase();
|
|
565
|
+
if (protectedHeaderNames.has(lower)) return true;
|
|
566
|
+
return lower.startsWith("vqs-");
|
|
567
|
+
};
|
|
568
|
+
for (const [name, value] of Object.entries(optionHeaders)) {
|
|
569
|
+
if (!isProtectedHeader(name) && value !== void 0) {
|
|
570
|
+
headers.append(name, value);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
headers.set("Authorization", `Bearer ${await this.getToken()}`);
|
|
575
|
+
headers.set("Content-Type", transport.contentType);
|
|
571
576
|
const deploymentId = this.getSendDeploymentId();
|
|
572
577
|
if (deploymentId) {
|
|
573
578
|
headers.set("Vqs-Deployment-Id", deploymentId);
|
|
@@ -625,25 +630,17 @@ var QueueClient = class {
|
|
|
625
630
|
* @param options.consumerGroup - Consumer group name (pattern: `[A-Za-z0-9_-]+`)
|
|
626
631
|
* @param options.visibilityTimeoutSeconds - Lock duration (default: 30, min: 0, max: 3600)
|
|
627
632
|
* @param options.limit - Max messages to retrieve (default: 1, min: 1, max: 10)
|
|
628
|
-
* @param options.maxConcurrency - Max in-flight messages (default: unlimited, min: 1)
|
|
629
633
|
* @param transport - Deserializer for message payloads
|
|
630
634
|
* @yields Message objects with payload, messageId, receiptHandle, etc.
|
|
631
635
|
* @throws {QueueEmptyError} When no messages available
|
|
632
636
|
* @throws {InvalidLimitError} When limit is outside 1-10 range
|
|
633
|
-
* @throws {ConcurrencyLimitError} When maxConcurrency exceeded
|
|
634
637
|
* @throws {BadRequestError} When parameters are invalid
|
|
635
638
|
* @throws {UnauthorizedError} When authentication fails
|
|
636
639
|
* @throws {ForbiddenError} When access is denied
|
|
637
640
|
* @throws {InternalServerError} When server encounters an error
|
|
638
641
|
*/
|
|
639
642
|
async *receiveMessages(options, transport) {
|
|
640
|
-
const {
|
|
641
|
-
queueName,
|
|
642
|
-
consumerGroup,
|
|
643
|
-
visibilityTimeoutSeconds,
|
|
644
|
-
limit,
|
|
645
|
-
maxConcurrency
|
|
646
|
-
} = options;
|
|
643
|
+
const { queueName, consumerGroup, visibilityTimeoutSeconds, limit } = options;
|
|
647
644
|
if (limit !== void 0 && (limit < 1 || limit > 10)) {
|
|
648
645
|
throw new InvalidLimitError(limit);
|
|
649
646
|
}
|
|
@@ -661,9 +658,6 @@ var QueueClient = class {
|
|
|
661
658
|
if (limit !== void 0) {
|
|
662
659
|
headers.set("Vqs-Max-Messages", limit.toString());
|
|
663
660
|
}
|
|
664
|
-
if (maxConcurrency !== void 0) {
|
|
665
|
-
headers.set("Vqs-Max-Concurrency", maxConcurrency.toString());
|
|
666
|
-
}
|
|
667
661
|
const effectiveDeploymentId = this.getConsumeDeploymentId();
|
|
668
662
|
if (effectiveDeploymentId) {
|
|
669
663
|
headers.set("Vqs-Deployment-Id", effectiveDeploymentId);
|
|
@@ -680,18 +674,6 @@ var QueueClient = class {
|
|
|
680
674
|
}
|
|
681
675
|
if (!response.ok) {
|
|
682
676
|
const errorText = await response.text();
|
|
683
|
-
if (response.status === 429) {
|
|
684
|
-
let errorData = {};
|
|
685
|
-
try {
|
|
686
|
-
errorData = JSON.parse(errorText);
|
|
687
|
-
} catch {
|
|
688
|
-
}
|
|
689
|
-
throw new ConcurrencyLimitError(
|
|
690
|
-
errorData.error || "Concurrency limit exceeded or throttled",
|
|
691
|
-
errorData.currentInflight,
|
|
692
|
-
errorData.maxConcurrency
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
677
|
throwCommonHttpError(
|
|
696
678
|
response.status,
|
|
697
679
|
response.statusText,
|
|
@@ -729,26 +711,18 @@ var QueueClient = class {
|
|
|
729
711
|
* @param options.consumerGroup - Consumer group name (pattern: `[A-Za-z0-9_-]+`)
|
|
730
712
|
* @param options.messageId - Message ID to retrieve
|
|
731
713
|
* @param options.visibilityTimeoutSeconds - Lock duration (default: 30, min: 0, max: 3600)
|
|
732
|
-
* @param options.maxConcurrency - Max in-flight messages (default: unlimited, min: 1)
|
|
733
714
|
* @param transport - Deserializer for the message payload
|
|
734
715
|
* @returns Promise with the message
|
|
735
716
|
* @throws {MessageNotFoundError} When message doesn't exist
|
|
736
717
|
* @throws {MessageNotAvailableError} When message is in wrong state or was a duplicate
|
|
737
718
|
* @throws {MessageAlreadyProcessedError} When message was already processed
|
|
738
|
-
* @throws {ConcurrencyLimitError} When maxConcurrency exceeded
|
|
739
719
|
* @throws {BadRequestError} When parameters are invalid
|
|
740
720
|
* @throws {UnauthorizedError} When authentication fails
|
|
741
721
|
* @throws {ForbiddenError} When access is denied
|
|
742
722
|
* @throws {InternalServerError} When server encounters an error
|
|
743
723
|
*/
|
|
744
724
|
async receiveMessageById(options, transport) {
|
|
745
|
-
const {
|
|
746
|
-
queueName,
|
|
747
|
-
consumerGroup,
|
|
748
|
-
messageId,
|
|
749
|
-
visibilityTimeoutSeconds,
|
|
750
|
-
maxConcurrency
|
|
751
|
-
} = options;
|
|
725
|
+
const { queueName, consumerGroup, messageId, visibilityTimeoutSeconds } = options;
|
|
752
726
|
const headers = new Headers({
|
|
753
727
|
Authorization: `Bearer ${await this.getToken()}`,
|
|
754
728
|
Accept: "multipart/mixed",
|
|
@@ -760,9 +734,6 @@ var QueueClient = class {
|
|
|
760
734
|
visibilityTimeoutSeconds.toString()
|
|
761
735
|
);
|
|
762
736
|
}
|
|
763
|
-
if (maxConcurrency !== void 0) {
|
|
764
|
-
headers.set("Vqs-Max-Concurrency", maxConcurrency.toString());
|
|
765
|
-
}
|
|
766
737
|
const effectiveDeploymentId = this.getConsumeDeploymentId();
|
|
767
738
|
if (effectiveDeploymentId) {
|
|
768
739
|
headers.set("Vqs-Deployment-Id", effectiveDeploymentId);
|
|
@@ -796,18 +767,6 @@ var QueueClient = class {
|
|
|
796
767
|
if (response.status === 410) {
|
|
797
768
|
throw new MessageAlreadyProcessedError(messageId);
|
|
798
769
|
}
|
|
799
|
-
if (response.status === 429) {
|
|
800
|
-
let errorData = {};
|
|
801
|
-
try {
|
|
802
|
-
errorData = JSON.parse(errorText);
|
|
803
|
-
} catch {
|
|
804
|
-
}
|
|
805
|
-
throw new ConcurrencyLimitError(
|
|
806
|
-
errorData.error || "Concurrency limit exceeded or throttled",
|
|
807
|
-
errorData.currentInflight,
|
|
808
|
-
errorData.maxConcurrency
|
|
809
|
-
);
|
|
810
|
-
}
|
|
811
770
|
throwCommonHttpError(
|
|
812
771
|
response.status,
|
|
813
772
|
response.statusText,
|
|
@@ -1214,7 +1173,8 @@ var Topic = class {
|
|
|
1214
1173
|
payload,
|
|
1215
1174
|
idempotencyKey: options?.idempotencyKey,
|
|
1216
1175
|
retentionSeconds: options?.retentionSeconds,
|
|
1217
|
-
delaySeconds: options?.delaySeconds
|
|
1176
|
+
delaySeconds: options?.delaySeconds,
|
|
1177
|
+
headers: options?.headers
|
|
1218
1178
|
},
|
|
1219
1179
|
this.transport
|
|
1220
1180
|
);
|