@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.
@@ -110,18 +110,6 @@ var MessageAlreadyProcessedError = class extends Error {
110
110
  this.name = "MessageAlreadyProcessedError";
111
111
  }
112
112
  };
113
- var ConcurrencyLimitError = class extends Error {
114
- /** Current number of in-flight messages for this consumer group. */
115
- currentInflight;
116
- /** Maximum allowed concurrent messages (as configured). */
117
- maxConcurrency;
118
- constructor(message = "Concurrency limit exceeded", currentInflight, maxConcurrency) {
119
- super(message);
120
- this.name = "ConcurrencyLimitError";
121
- this.currentInflight = currentInflight;
122
- this.maxConcurrency = maxConcurrency;
123
- }
124
- };
125
113
  var DuplicateMessageError = class extends Error {
126
114
  idempotencyKey;
127
115
  constructor(message, idempotencyKey) {
@@ -525,13 +513,30 @@ var QueueClient = class {
525
513
  payload,
526
514
  idempotencyKey,
527
515
  retentionSeconds,
528
- delaySeconds
516
+ delaySeconds,
517
+ headers: optionHeaders
529
518
  } = options;
530
- const headers = new Headers({
531
- Authorization: `Bearer ${await this.getToken()}`,
532
- "Content-Type": transport.contentType,
533
- ...this.customHeaders
534
- });
519
+ const headers = new Headers();
520
+ if (this.customHeaders) {
521
+ for (const [name, value] of Object.entries(this.customHeaders)) {
522
+ headers.append(name, value);
523
+ }
524
+ }
525
+ if (optionHeaders) {
526
+ const protectedHeaderNames = /* @__PURE__ */ new Set(["authorization", "content-type"]);
527
+ const isProtectedHeader = (name) => {
528
+ const lower = name.toLowerCase();
529
+ if (protectedHeaderNames.has(lower)) return true;
530
+ return lower.startsWith("vqs-");
531
+ };
532
+ for (const [name, value] of Object.entries(optionHeaders)) {
533
+ if (!isProtectedHeader(name) && value !== void 0) {
534
+ headers.append(name, value);
535
+ }
536
+ }
537
+ }
538
+ headers.set("Authorization", `Bearer ${await this.getToken()}`);
539
+ headers.set("Content-Type", transport.contentType);
535
540
  const deploymentId = this.getSendDeploymentId();
536
541
  if (deploymentId) {
537
542
  headers.set("Vqs-Deployment-Id", deploymentId);
@@ -589,25 +594,17 @@ var QueueClient = class {
589
594
  * @param options.consumerGroup - Consumer group name (pattern: `[A-Za-z0-9_-]+`)
590
595
  * @param options.visibilityTimeoutSeconds - Lock duration (default: 30, min: 0, max: 3600)
591
596
  * @param options.limit - Max messages to retrieve (default: 1, min: 1, max: 10)
592
- * @param options.maxConcurrency - Max in-flight messages (default: unlimited, min: 1)
593
597
  * @param transport - Deserializer for message payloads
594
598
  * @yields Message objects with payload, messageId, receiptHandle, etc.
595
599
  * @throws {QueueEmptyError} When no messages available
596
600
  * @throws {InvalidLimitError} When limit is outside 1-10 range
597
- * @throws {ConcurrencyLimitError} When maxConcurrency exceeded
598
601
  * @throws {BadRequestError} When parameters are invalid
599
602
  * @throws {UnauthorizedError} When authentication fails
600
603
  * @throws {ForbiddenError} When access is denied
601
604
  * @throws {InternalServerError} When server encounters an error
602
605
  */
603
606
  async *receiveMessages(options, transport) {
604
- const {
605
- queueName,
606
- consumerGroup,
607
- visibilityTimeoutSeconds,
608
- limit,
609
- maxConcurrency
610
- } = options;
607
+ const { queueName, consumerGroup, visibilityTimeoutSeconds, limit } = options;
611
608
  if (limit !== void 0 && (limit < 1 || limit > 10)) {
612
609
  throw new InvalidLimitError(limit);
613
610
  }
@@ -625,9 +622,6 @@ var QueueClient = class {
625
622
  if (limit !== void 0) {
626
623
  headers.set("Vqs-Max-Messages", limit.toString());
627
624
  }
628
- if (maxConcurrency !== void 0) {
629
- headers.set("Vqs-Max-Concurrency", maxConcurrency.toString());
630
- }
631
625
  const effectiveDeploymentId = this.getConsumeDeploymentId();
632
626
  if (effectiveDeploymentId) {
633
627
  headers.set("Vqs-Deployment-Id", effectiveDeploymentId);
@@ -644,18 +638,6 @@ var QueueClient = class {
644
638
  }
645
639
  if (!response.ok) {
646
640
  const errorText = await response.text();
647
- if (response.status === 429) {
648
- let errorData = {};
649
- try {
650
- errorData = JSON.parse(errorText);
651
- } catch {
652
- }
653
- throw new ConcurrencyLimitError(
654
- errorData.error || "Concurrency limit exceeded or throttled",
655
- errorData.currentInflight,
656
- errorData.maxConcurrency
657
- );
658
- }
659
641
  throwCommonHttpError(
660
642
  response.status,
661
643
  response.statusText,
@@ -693,26 +675,18 @@ var QueueClient = class {
693
675
  * @param options.consumerGroup - Consumer group name (pattern: `[A-Za-z0-9_-]+`)
694
676
  * @param options.messageId - Message ID to retrieve
695
677
  * @param options.visibilityTimeoutSeconds - Lock duration (default: 30, min: 0, max: 3600)
696
- * @param options.maxConcurrency - Max in-flight messages (default: unlimited, min: 1)
697
678
  * @param transport - Deserializer for the message payload
698
679
  * @returns Promise with the message
699
680
  * @throws {MessageNotFoundError} When message doesn't exist
700
681
  * @throws {MessageNotAvailableError} When message is in wrong state or was a duplicate
701
682
  * @throws {MessageAlreadyProcessedError} When message was already processed
702
- * @throws {ConcurrencyLimitError} When maxConcurrency exceeded
703
683
  * @throws {BadRequestError} When parameters are invalid
704
684
  * @throws {UnauthorizedError} When authentication fails
705
685
  * @throws {ForbiddenError} When access is denied
706
686
  * @throws {InternalServerError} When server encounters an error
707
687
  */
708
688
  async receiveMessageById(options, transport) {
709
- const {
710
- queueName,
711
- consumerGroup,
712
- messageId,
713
- visibilityTimeoutSeconds,
714
- maxConcurrency
715
- } = options;
689
+ const { queueName, consumerGroup, messageId, visibilityTimeoutSeconds } = options;
716
690
  const headers = new Headers({
717
691
  Authorization: `Bearer ${await this.getToken()}`,
718
692
  Accept: "multipart/mixed",
@@ -724,9 +698,6 @@ var QueueClient = class {
724
698
  visibilityTimeoutSeconds.toString()
725
699
  );
726
700
  }
727
- if (maxConcurrency !== void 0) {
728
- headers.set("Vqs-Max-Concurrency", maxConcurrency.toString());
729
- }
730
701
  const effectiveDeploymentId = this.getConsumeDeploymentId();
731
702
  if (effectiveDeploymentId) {
732
703
  headers.set("Vqs-Deployment-Id", effectiveDeploymentId);
@@ -760,18 +731,6 @@ var QueueClient = class {
760
731
  if (response.status === 410) {
761
732
  throw new MessageAlreadyProcessedError(messageId);
762
733
  }
763
- if (response.status === 429) {
764
- let errorData = {};
765
- try {
766
- errorData = JSON.parse(errorText);
767
- } catch {
768
- }
769
- throw new ConcurrencyLimitError(
770
- errorData.error || "Concurrency limit exceeded or throttled",
771
- errorData.currentInflight,
772
- errorData.maxConcurrency
773
- );
774
- }
775
734
  throwCommonHttpError(
776
735
  response.status,
777
736
  response.statusText,
@@ -1178,7 +1137,8 @@ var Topic = class {
1178
1137
  payload,
1179
1138
  idempotencyKey: options?.idempotencyKey,
1180
1139
  retentionSeconds: options?.retentionSeconds,
1181
- delaySeconds: options?.delaySeconds
1140
+ delaySeconds: options?.delaySeconds,
1141
+ headers: options?.headers
1182
1142
  },
1183
1143
  this.transport
1184
1144
  );