@vite-hub/queue 0.3.1 → 0.4.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.
Files changed (40) hide show
  1. package/README.md +20 -18
  2. package/dist/{client-Cj50hQYp.js → client-B53_G4ky.js} +11 -9
  3. package/dist/{cloudflare-client-DYsAjM8B.js → cloudflare-client-CoISDpIx.js} +22 -8
  4. package/dist/{cloudflare-resource-name-BJHYRCMQ.js → cloudflare-resource-name-BIfBglC2.js} +1 -1
  5. package/dist/{config-BcTDeQIP.js → config-B2eaXaT5.js} +1 -1
  6. package/dist/{errors-DL3pcNO4.js → duration-tujyhAKt.js} +40 -6
  7. package/dist/{error-diagnostics-DSkCJC_L.js → error-diagnostics-CQ4BUqRe.js} +5 -1
  8. package/dist/{error-diagnostics-BRartC1z.js → error-diagnostics-mJXBjmQx.js} +7 -7
  9. package/dist/{handler-response-By0Fpspv.js → handler-response-B6lz9nCn.js} +1 -1
  10. package/dist/index.d.ts +7 -3
  11. package/dist/index.js +19 -9
  12. package/dist/internal/runtime/cloudflare-client.d.ts +1 -1
  13. package/dist/internal/runtime/cloudflare-client.js +1 -1
  14. package/dist/internal/runtime/cloudflare-vite.d.ts +1 -1
  15. package/dist/internal/runtime/cloudflare-vite.js +8 -8
  16. package/dist/internal/runtime/local-client.d.ts +3 -3
  17. package/dist/internal/runtime/local-client.js +4 -4
  18. package/dist/internal/runtime/postgres-client.d.ts +3 -3
  19. package/dist/internal/runtime/postgres-client.js +24 -14
  20. package/dist/internal/runtime/state.d.ts +2 -2
  21. package/dist/internal/runtime/state.js +1 -1
  22. package/dist/internal/runtime/vercel-client.d.ts +1 -1
  23. package/dist/internal/runtime/vercel-client.js +23 -11
  24. package/dist/internal/runtime/worker-client.d.ts +2 -2
  25. package/dist/internal/runtime/worker-client.js +1 -1
  26. package/dist/{local-CVVRVWeR.d.ts → local-CUaWoRUx.d.ts} +2 -1
  27. package/dist/{local-CGckW5nr.js → local-Di0FrVUw.js} +27 -14
  28. package/dist/{operation-definition-8gOe-ubD.d.ts → operation-definition-nmRu_O3V.d.ts} +5 -0
  29. package/dist/{operations-Crwjca91.js → operations-BVV-9Q0N.js} +10 -5
  30. package/dist/operations.d.ts +5 -4
  31. package/dist/operations.js +15 -47
  32. package/dist/runtime/hosted.d.ts +1 -1
  33. package/dist/runtime/hosted.js +4 -4
  34. package/dist/{state-mVA2X_wa.js → state-DLqTqF6V.js} +1 -1
  35. package/dist/{types-BD-8U9zS.d.ts → types-CiuSIPR0.d.ts} +42 -22
  36. package/dist/{types-DS_rqu9l.d.ts → types-Dsbb_Pvp.d.ts} +1 -1
  37. package/dist/{vercel-region-D1CivgdA.js → vercel-region-B95MAMXN.js} +1 -1
  38. package/dist/vite.d.ts +4 -2
  39. package/dist/vite.js +4 -4
  40. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
- import { S as QueueDefinitionRegistry, b as QueueDefinition, k as QueueJobStore, y as QueueClient } from "../../types-BD-8U9zS.js";
2
- import { n as QueueRuntimeOptions, t as QueueRuntimeDriverOptions } from "../../types-DS_rqu9l.js";
1
+ import { A as QueueJobStore, C as QueueDefinitionRegistry, b as QueueClient, x as QueueDefinition } from "../../types-CiuSIPR0.js";
2
+ import { n as QueueRuntimeOptions, t as QueueRuntimeDriverOptions } from "../../types-Dsbb_Pvp.js";
3
3
  //#region src/internal/runtime/state.d.ts
4
4
  export type QueueRuntimeClientFactory = (options: QueueRuntimeDriverOptions) => QueueClient | Promise<QueueClient>;
5
5
  export declare function missingQueueDefinitionError(queue: string): Error;
@@ -1,2 +1,2 @@
1
- import { a as getQueueRuntimeEvent, c as loadQueueDefinition, d as setQueueRuntimeConfig, f as setQueueRuntimeEventDefaults, i as getQueueRuntimeConfig, l as missingQueueDefinitionError, m as setQueueRuntimeRegistry, n as getOrCreateQueueClient, o as getQueueRuntimeJobStore, p as setQueueRuntimeJobStore, r as getQueueRuntimeClientFactory, s as listQueueDefinitionNames, t as enterQueueRuntimeEvent, u as runWithQueueRuntimeEvent } from "../../state-mVA2X_wa.js";
1
+ import { a as getQueueRuntimeEvent, c as loadQueueDefinition, d as setQueueRuntimeConfig, f as setQueueRuntimeEventDefaults, i as getQueueRuntimeConfig, l as missingQueueDefinitionError, m as setQueueRuntimeRegistry, n as getOrCreateQueueClient, o as getQueueRuntimeJobStore, p as setQueueRuntimeJobStore, r as getQueueRuntimeClientFactory, s as listQueueDefinitionNames, t as enterQueueRuntimeEvent, u as runWithQueueRuntimeEvent } from "../../state-DLqTqF6V.js";
2
2
  export { enterQueueRuntimeEvent, getOrCreateQueueClient, getQueueRuntimeClientFactory, getQueueRuntimeConfig, getQueueRuntimeEvent, getQueueRuntimeJobStore, listQueueDefinitionNames, loadQueueDefinition, missingQueueDefinitionError, runWithQueueRuntimeEvent, setQueueRuntimeConfig, setQueueRuntimeEventDefaults, setQueueRuntimeJobStore, setQueueRuntimeRegistry };
@@ -1,4 +1,4 @@
1
- import { w as QueueDriverOptions, y as QueueClient } from "../../types-BD-8U9zS.js";
1
+ import { T as QueueDriverOptions, b as QueueClient } from "../../types-CiuSIPR0.js";
2
2
  //#region src/internal/runtime/vercel-client.d.ts
3
3
  export declare function createVercelQueueRuntimeClient(options: QueueDriverOptions): Promise<QueueClient>;
4
4
  //#endregion
@@ -1,6 +1,6 @@
1
- import { t as queueErrorDiagnostics } from "../../error-diagnostics-BRartC1z.js";
2
- import { c as createQueueMessageId, l as normalizeQueueEnqueueInput, o as queueProviderResult, s as queueUnsupportedOptionsError } from "../../errors-DL3pcNO4.js";
3
- import { t as resolveVercelQueueRegion } from "../../vercel-region-D1CivgdA.js";
1
+ import { t as queueErrorDiagnostics } from "../../error-diagnostics-mJXBjmQx.js";
2
+ import { c as queueRemovedOptionsError, d as normalizeQueueEnqueueInput, l as queueUnsupportedOptionsError, s as queueProviderResult, t as readQueueTimes, u as createQueueMessageId } from "../../duration-tujyhAKt.js";
3
+ import { t as resolveVercelQueueRegion } from "../../vercel-region-B95MAMXN.js";
4
4
  //#region src/providers/vercel.ts
5
5
  function invalidVercelSendResponse(cause) {
6
6
  return [queueErrorDiagnostics.QUEUE_PROVIDER_INVALID_RESPONSE({ cause }), void 0];
@@ -125,11 +125,13 @@ async function createVercelQueueClient(provider) {
125
125
  const normalized = normalizeQueueEnqueueInput(payload, options);
126
126
  const optionsError = queueUnsupportedOptionsError(normalized.options, "vercel");
127
127
  if (optionsError) return [optionsError, void 0];
128
+ const [timeError, times] = readQueueTimes(normalized.options, "ceil");
129
+ if (timeError) return [timeError, void 0];
128
130
  const [error, response] = await queueProviderResult("vercel", "send", () => client.send(topic, normalized.payload, {
129
- delaySeconds: normalized.options.delaySeconds,
131
+ delaySeconds: times.delaySeconds,
130
132
  idempotencyKey: normalized.options.idempotencyKey || normalized.id,
131
133
  region: normalized.options.region ?? provider.region,
132
- retentionSeconds: normalized.options.retentionSeconds
134
+ retentionSeconds: times.retentionSeconds
133
135
  }));
134
136
  if (error) return [error, void 0];
135
137
  const [responseError, messageId] = parseVercelMessageId(response);
@@ -140,12 +142,22 @@ async function createVercelQueueClient(provider) {
140
142
  }];
141
143
  },
142
144
  async sendBatch(items, options) {
143
- const messages = items.map((item) => ({
144
- delaySeconds: item.delaySeconds ?? options?.delaySeconds,
145
- idempotencyKey: item.idempotencyKey || createQueueMessageId(),
146
- payload: item.body,
147
- retentionSeconds: item.retentionSeconds ?? options?.retentionSeconds
148
- }));
145
+ const removed = queueRemovedOptionsError("vercel", options, items);
146
+ if (removed) return [removed, void 0];
147
+ const messages = [];
148
+ for (const item of items) {
149
+ const [timeError, times] = readQueueTimes({
150
+ delay: item.delay ?? options?.delay,
151
+ retention: item.retention ?? options?.retention
152
+ }, "ceil");
153
+ if (timeError) return [timeError, void 0];
154
+ messages.push({
155
+ delaySeconds: times.delaySeconds,
156
+ idempotencyKey: item.idempotencyKey || createQueueMessageId(),
157
+ payload: item.body,
158
+ retentionSeconds: times.retentionSeconds
159
+ });
160
+ }
149
161
  const [error, response] = await queueProviderResult("vercel", "send-batch", async () => {
150
162
  if (typeof client.sendBatch !== "function") throw queueErrorDiagnostics.QUEUE_VERCEL_SEND_BATCH_UNAVAILABLE();
151
163
  const results = await client.sendBatch(topic, messages);
@@ -1,5 +1,5 @@
1
- import { y as QueueClient } from "../../types-BD-8U9zS.js";
2
- import { t as QueueRuntimeDriverOptions } from "../../types-DS_rqu9l.js";
1
+ import { b as QueueClient } from "../../types-CiuSIPR0.js";
2
+ import { t as QueueRuntimeDriverOptions } from "../../types-Dsbb_Pvp.js";
3
3
  //#region src/internal/runtime/worker-client.d.ts
4
4
  /** Worker package conditions keep the Node driver and its optional peer outside the build graph. */
5
5
  export declare function createPostgresQueueRuntimeClient(options: QueueRuntimeDriverOptions): Promise<QueueClient>;
@@ -1,4 +1,4 @@
1
- import { t as queueErrorDiagnostics } from "../../error-diagnostics-BRartC1z.js";
1
+ import { t as queueErrorDiagnostics } from "../../error-diagnostics-mJXBjmQx.js";
2
2
  //#region src/internal/runtime/worker-client.ts
3
3
  /** Worker package conditions keep the Node driver and its optional peer outside the build graph. */
4
4
  async function createPostgresQueueRuntimeClient(options) {
@@ -1,5 +1,6 @@
1
- import { k as QueueJobStore } from "./types-BD-8U9zS.js";
1
+ import { A as QueueJobStore } from "./types-CiuSIPR0.js";
2
2
  //#region src/providers/local.d.ts
3
+ /** One job for the engine. `vite dev` and the clients read `delay` and `retention` into seconds first. */
3
4
  interface LocalQueueEntry {
4
5
  delaySeconds?: number;
5
6
  id: string;
@@ -1,6 +1,6 @@
1
- import { t as queueErrorDiagnostics } from "./error-diagnostics-BRartC1z.js";
2
- import { a as postgresUnsupportedEnqueueOptions, c as createQueueMessageId, l as normalizeQueueEnqueueInput, o as queueProviderResult, r as localUnsupportedEnqueueOptions, s as queueUnsupportedOptionsError, t as cloudflareUnsupportedEnqueueOptions } from "./errors-DL3pcNO4.js";
3
- import { i as reportQueueDeliveryError, n as createQueueDeliveryErrorReport, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "./handler-response-By0Fpspv.js";
1
+ import { t as queueErrorDiagnostics } from "./error-diagnostics-mJXBjmQx.js";
2
+ import { c as queueRemovedOptionsError, d as normalizeQueueEnqueueInput, i as localUnsupportedEnqueueOptions, l as queueUnsupportedOptionsError, n as cloudflareUnsupportedEnqueueOptions, o as postgresUnsupportedEnqueueOptions, s as queueProviderResult, t as readQueueTimes, u as createQueueMessageId } from "./duration-tujyhAKt.js";
3
+ import { i as reportQueueDeliveryError, n as createQueueDeliveryErrorReport, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "./handler-response-B6lz9nCn.js";
4
4
  import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
5
5
  import { join, resolve } from "pathe";
6
6
  import { randomUUID } from "node:crypto";
@@ -258,7 +258,7 @@ function createLocalQueueEngine(options) {
258
258
  try {
259
259
  const definition = await options.load(job.queue);
260
260
  if (!definition) throw options.missing(job.queue);
261
- const limit = Number(definition.options?.concurrency ?? 1);
261
+ const limit = Number(definition.concurrency ?? 1);
262
262
  concurrency.set(job.queue, Number.isFinite(limit) ? Math.max(1, Math.floor(limit)) : 1);
263
263
  schedule();
264
264
  await runInRunScopes(async () => {
@@ -499,6 +499,7 @@ function unsupportedOptions(options, rules) {
499
499
  return queueUnsupportedOptionsError(options, rules.rules, rules.unsupportedOptions);
500
500
  }
501
501
  function createLocalQueueClient(engine, queue) {
502
+ const round = engine.rules.rules === "vercel" || engine.rules.rules === "cloudflare" ? "ceil" : void 0;
502
503
  return {
503
504
  provider: "local",
504
505
  native: engine,
@@ -507,12 +508,13 @@ function createLocalQueueClient(engine, queue) {
507
508
  const normalized = normalizeQueueEnqueueInput(payload, options);
508
509
  const optionsError = unsupportedOptions(normalized.options, engine.rules);
509
510
  if (optionsError) return [optionsError, void 0];
511
+ const [timeError, times] = readQueueTimes(normalized.options, round);
512
+ if (timeError) return [timeError, void 0];
510
513
  const [error, ids] = await queueProviderResult("local", "send", () => engine.enqueue(queue, [{
511
- delaySeconds: normalized.options.delaySeconds,
514
+ ...times,
512
515
  id: normalized.id,
513
516
  idempotencyKey: normalized.options.idempotencyKey,
514
- payload: normalized.payload,
515
- retentionSeconds: normalized.options.retentionSeconds
517
+ payload: normalized.payload
516
518
  }]));
517
519
  if (error) return [error, void 0];
518
520
  return [void 0, {
@@ -521,13 +523,24 @@ function createLocalQueueClient(engine, queue) {
521
523
  }];
522
524
  },
523
525
  async sendBatch(items, options) {
524
- const [error, ids] = await queueProviderResult("local", "send-batch", () => engine.enqueue(queue, items.map((item) => ({
525
- delaySeconds: item.delaySeconds ?? options?.delaySeconds,
526
- id: createQueueMessageId(),
527
- idempotencyKey: item.idempotencyKey,
528
- payload: item.body,
529
- retentionSeconds: "retentionSeconds" in item && typeof item.retentionSeconds === "number" ? item.retentionSeconds : options && "retentionSeconds" in options && typeof options.retentionSeconds === "number" ? options.retentionSeconds : void 0
530
- }))));
526
+ const removed = queueRemovedOptionsError(engine.rules.rules, options, items);
527
+ if (removed) return [removed, void 0];
528
+ const entries = [];
529
+ for (const item of items) {
530
+ const retention = ("retention" in item ? item.retention : void 0) ?? (options && "retention" in options ? options.retention : void 0);
531
+ const [timeError, times] = readQueueTimes({
532
+ delay: item.delay ?? options?.delay,
533
+ retention
534
+ }, round);
535
+ if (timeError) return [timeError, void 0];
536
+ entries.push({
537
+ ...times,
538
+ id: createQueueMessageId(),
539
+ idempotencyKey: item.idempotencyKey,
540
+ payload: item.body
541
+ });
542
+ }
543
+ const [error, ids] = await queueProviderResult("local", "send-batch", () => engine.enqueue(queue, entries));
531
544
  if (error) return [error, void 0];
532
545
  return [void 0, ids.map((messageId) => ({
533
546
  messageId,
@@ -115,6 +115,11 @@ interface OperationContext {
115
115
  surface: "console" | "cli" | "mcp" | "agent";
116
116
  /** Set by the host from generated build identity, never from request input or runtime NODE_ENV. */
117
117
  development?: boolean;
118
+ /**
119
+ * The project root of a development server, for operations that read build files, such as `bundle.report`. Hosts set
120
+ * it only with `development`, so a deployed server never reads project files through it.
121
+ */
122
+ projectRoot?: string;
118
123
  env?: Record<string, unknown>;
119
124
  waitUntil?: (task: Promise<unknown>) => void;
120
125
  request?: Request;
@@ -1,8 +1,9 @@
1
- import { t as queueErrorDiagnostics } from "./error-diagnostics-BRartC1z.js";
2
- import { i as normalizePublicQueueIdentifier, n as isQueueError } from "./errors-DL3pcNO4.js";
3
- import { i as getQueueRuntimeConfig, o as getQueueRuntimeJobStore, s as listQueueDefinitionNames } from "./state-mVA2X_wa.js";
4
- import { n as dynamicQueue } from "./client-Cj50hQYp.js";
1
+ import { t as queueErrorDiagnostics } from "./error-diagnostics-mJXBjmQx.js";
2
+ import { a as normalizePublicQueueIdentifier, r as isQueueError } from "./duration-tujyhAKt.js";
3
+ import { i as getQueueRuntimeConfig, o as getQueueRuntimeJobStore, s as listQueueDefinitionNames } from "./state-DLqTqF6V.js";
4
+ import { n as dynamicQueue } from "./client-B53_G4ky.js";
5
5
  import { t as redactInspectionText } from "./inspect-PeuckaC3.js";
6
+ import { runtimeErrorDiagnostics } from "@vite-hub/runtime";
6
7
  //#region src/runtime/operations.ts
7
8
  /** The HTTP status that the CLI, the Console, and Agents report for each code of a failed operation. */
8
9
  const statuses = {
@@ -19,6 +20,10 @@ const statuses = {
19
20
  };
20
21
  /** Gives a Queue catalog error the status and the redacted message that the CLI and the Console report. */
21
22
  function failure(error) {
23
+ if (runtimeErrorDiagnostics.RUNTIME_DURATION_INVALID.is(error)) return Object.assign(error, {
24
+ status: 400,
25
+ statusMessage: redactInspectionText(error.message)
26
+ });
22
27
  if (!isQueueError(error)) return error;
23
28
  return Object.assign(error, {
24
29
  status: statuses[error.code] ?? 500,
@@ -62,7 +67,7 @@ async function sendToQueue(input) {
62
67
  const queue = normalizePublicQueueIdentifier(input.queue);
63
68
  if (!queue) throw failure(queueErrorDiagnostics.QUEUE_DEFINITION_NAME_INVALID());
64
69
  const options = {
65
- ...input.delaySeconds === void 0 ? {} : { delaySeconds: input.delaySeconds },
70
+ ...input.delay === void 0 ? {} : { delay: input.delay },
66
71
  ...input.idempotencyKey === void 0 ? {} : { idempotencyKey: input.idempotencyKey }
67
72
  };
68
73
  let result;
@@ -1,6 +1,6 @@
1
- import { C as QueueDriver, d as LocalQueueJobDetail, f as LocalQueueRules, k as QueueJobStore, m as LocalQueueStatus, u as LocalQueueJob } from "./types-BD-8U9zS.js";
2
- import "./local-CVVRVWeR.js";
3
- import { t as AnyOperation } from "./operation-definition-8gOe-ubD.js";
1
+ import { A as QueueJobStore, d as LocalQueueJob, f as LocalQueueJobDetail, h as LocalQueueStatus, p as LocalQueueRules, w as QueueDriver } from "./types-CiuSIPR0.js";
2
+ import "./local-CUaWoRUx.js";
3
+ import { t as AnyOperation } from "./operation-definition-nmRu_O3V.js";
4
4
  //#region src/runtime/operations.d.ts
5
5
  interface QueueListResult {
6
6
  /** `undefined` when the runtime has not installed a Queue configuration. */
@@ -52,7 +52,8 @@ interface QueueSendOperationResult {
52
52
  status: "queued";
53
53
  }
54
54
  interface QueueSendOperationInput {
55
- delaySeconds?: number;
55
+ /** Time before delivery, such as `"1m"`. The send reads it, and a wrong one fails with `RUNTIME_DURATION_INVALID`. */
56
+ delay?: string;
56
57
  idempotencyKey?: string;
57
58
  payload: unknown;
58
59
  queue: string;
@@ -1,5 +1,5 @@
1
- import { t as internalErrorDiagnostics } from "./error-diagnostics-DSkCJC_L.js";
2
1
  import { r as isRecordOrFunction } from "./object-D8pRdprI.js";
2
+ import { t as internalErrorDiagnostics } from "./error-diagnostics-CQ4BUqRe.js";
3
3
  //#region ../internal/src/standard-schema.ts
4
4
  function readOwn(value, key) {
5
5
  if (value === null || Object(value) !== value) return;
@@ -934,20 +934,20 @@ function _standardSchema(schema) {
934
934
  };
935
935
  return schema;
936
936
  }
937
+ /**
938
+ * Creates a description metadata action.
939
+ *
940
+ * @param description_ The description text.
941
+ *
942
+ * @returns A description action.
943
+ */
937
944
  /* @__NO_SIDE_EFFECTS__ */
938
- function integer(message$1) {
945
+ function description(description_) {
939
946
  return {
940
- kind: "validation",
941
- type: "integer",
942
- reference: integer,
943
- async: false,
944
- expects: null,
945
- requirement: Number.isInteger,
946
- message: message$1,
947
- "~run"(dataset, config$1) {
948
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
949
- return dataset;
950
- }
947
+ kind: "metadata",
948
+ type: "description",
949
+ reference: description,
950
+ description: description_
951
951
  };
952
952
  }
953
953
  /* @__NO_SIDE_EFFECTS__ */
@@ -966,22 +966,6 @@ function minLength(requirement, message$1) {
966
966
  }
967
967
  };
968
968
  }
969
- /* @__NO_SIDE_EFFECTS__ */
970
- function minValue(requirement, message$1) {
971
- return {
972
- kind: "validation",
973
- type: "min_value",
974
- reference: minValue,
975
- async: false,
976
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
977
- requirement,
978
- message: message$1,
979
- "~run"(dataset, config$1) {
980
- if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
981
- return dataset;
982
- }
983
- };
984
- }
985
969
  /**
986
970
  * Returns the fallback value of the schema.
987
971
  *
@@ -1009,22 +993,6 @@ function getDefault(schema, dataset, config$1) {
1009
993
  return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
1010
994
  }
1011
995
  /* @__NO_SIDE_EFFECTS__ */
1012
- function number(message$1) {
1013
- return _standardSchema({
1014
- kind: "schema",
1015
- type: "number",
1016
- reference: number,
1017
- expects: "number",
1018
- async: false,
1019
- message: message$1,
1020
- "~run"(dataset, config$1) {
1021
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
1022
- else _addIssue(this, "type", dataset, config$1);
1023
- return dataset;
1024
- }
1025
- });
1026
- }
1027
- /* @__NO_SIDE_EFFECTS__ */
1028
996
  function optional(wrapped, default_) {
1029
997
  return _standardSchema({
1030
998
  kind: "schema",
@@ -1195,7 +1163,7 @@ function pipe(...pipe$1) {
1195
1163
  }
1196
1164
  //#endregion
1197
1165
  //#region src/operations.ts
1198
- const runtime = () => import("./operations-Crwjca91.js");
1166
+ const runtime = () => import("./operations-BVV-9Q0N.js");
1199
1167
  function defineQueueOperation(definition) {
1200
1168
  return defineOperation({
1201
1169
  ...definition,
@@ -1218,7 +1186,7 @@ const send = defineQueueOperation({
1218
1186
  },
1219
1187
  description: "Send one job to a Queue Definition. The payload is a JSON value.",
1220
1188
  input: /* @__PURE__ */ strictObject({
1221
- delaySeconds: /* @__PURE__ */ optional(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ integer(), /* @__PURE__ */ minValue(0))),
1189
+ delay: /* @__PURE__ */ optional(/* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1), /* @__PURE__ */ description("Time before delivery, such as 1m or 30s."))),
1222
1190
  idempotencyKey: /* @__PURE__ */ optional(/* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1))),
1223
1191
  payload: /* @__PURE__ */ unknown(),
1224
1192
  queue: /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1))
@@ -1,4 +1,4 @@
1
- import { b as QueueDefinition } from "../types-BD-8U9zS.js";
1
+ import { x as QueueDefinition } from "../types-CiuSIPR0.js";
2
2
  //#region src/runtime/hosted.d.ts
3
3
  export declare const hostedVercelWaitUntil: (promise: Promise<unknown>) => void | undefined;
4
4
  /** Handle one Vercel Queue delivery. The generated consumer route is a Fetchable module that passes its Request here. */
@@ -1,6 +1,6 @@
1
- import { t as queueErrorDiagnostics } from "../error-diagnostics-BRartC1z.js";
2
- import { n as dynamicQueue } from "../client-Cj50hQYp.js";
3
- import { i as reportQueueDeliveryError, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "../handler-response-By0Fpspv.js";
1
+ import { t as queueErrorDiagnostics } from "../error-diagnostics-mJXBjmQx.js";
2
+ import { n as dynamicQueue } from "../client-B53_G4ky.js";
3
+ import { i as reportQueueDeliveryError, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "../handler-response-B6lz9nCn.js";
4
4
  import { runInRunScopes } from "@vite-hub/runtime/internal/run-scope";
5
5
  import { waitUntil } from "@vercel/functions";
6
6
  //#region src/runtime/hosted.ts
@@ -43,7 +43,7 @@ async function handleHostedVercelQueueCallback(request, name, definition) {
43
43
  driver: queue.provider,
44
44
  expected: "vercel"
45
45
  });
46
- const result = await queue.callback(createVercelJobHandler(definition), createVercelCallbackOptions(name, definition.options?.callbackOptions))(request);
46
+ const result = await queue.callback(createVercelJobHandler(definition), createVercelCallbackOptions(name, definition.callbackOptions))(request);
47
47
  if (result instanceof Response) return result;
48
48
  return result === void 0 ? new Response(null, { status: 204 }) : Response.json(result);
49
49
  }
@@ -1,5 +1,5 @@
1
- import { t as queueErrorDiagnostics } from "./error-diagnostics-BRartC1z.js";
2
1
  import { n as isRecord } from "./object-D8pRdprI.js";
2
+ import { t as queueErrorDiagnostics } from "./error-diagnostics-mJXBjmQx.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  //#region ../internal/src/runtime/cloudflare-env-lookup.ts
5
5
  /** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
@@ -1,4 +1,4 @@
1
- import { Result } from "@vite-hub/runtime";
1
+ import { Duration, Result } from "@vite-hub/runtime";
2
2
  //#region src/types.d.ts
3
3
  type QueueDriver = "cloudflare" | "local" | "postgres" | "vercel";
4
4
  /** The Queue drivers that run jobs in a Node server process. */
@@ -14,6 +14,13 @@ interface CloudflareQueueSendBatchOptions {
14
14
  interface CloudflareQueueSendBatchMessage<T = unknown> extends CloudflareQueueSendOptions {
15
15
  body: T;
16
16
  }
17
+ /** One job in `sendBatch()` of a Cloudflare QueueClient. */
18
+ interface CloudflareQueueSendBatchItem<T = unknown> {
19
+ body: T;
20
+ contentType?: CloudflareQueueContentType;
21
+ /** Time before delivery, such as `"1m"`. */
22
+ delay?: Duration;
23
+ }
17
24
  interface CloudflareQueueRetryOptions {
18
25
  delaySeconds?: number;
19
26
  }
@@ -35,8 +42,11 @@ interface CloudflareQueueMessageBatch<T = unknown> {
35
42
  queue: string;
36
43
  retryAll: (options?: CloudflareQueueRetryOptions) => void;
37
44
  }
45
+ /** What `onError` returns: `"ack"`, `"retry"`, or `{ retry: { delay: "30s" } }` to retry after a time. */
38
46
  type CloudflareQueueBatchErrorAction = "ack" | "retry" | {
39
- retry: CloudflareQueueRetryOptions;
47
+ retry: {
48
+ delay?: Duration;
49
+ };
40
50
  };
41
51
  interface CloudflareQueueBatchHandlerOptions<T = unknown> {
42
52
  concurrency?: number;
@@ -85,14 +95,16 @@ type VercelQueueBatchSendResult = {
85
95
  */
86
96
  interface VercelQueueSendBatchMessage<T = unknown> {
87
97
  body: T;
88
- delaySeconds?: number;
98
+ /** Time before delivery, such as `"1m"`. */
99
+ delay?: Duration;
89
100
  idempotencyKey?: string;
90
- retentionSeconds?: number;
101
+ /** How long Vercel keeps the job: a duration such as `"1h"`, or a number of seconds. */
102
+ retention?: Duration | number;
91
103
  }
92
104
  /** Options that apply to every job of a Vercel `sendBatch()` unless the job sets its own. */
93
105
  interface VercelQueueSendBatchOptions {
94
- delaySeconds?: number;
95
- retentionSeconds?: number;
106
+ delay?: Duration;
107
+ retention?: Duration | number;
96
108
  }
97
109
  type VercelQueueMessageHandler<T = unknown> = (payload: T, metadata?: unknown) => unknown | Promise<unknown>;
98
110
  type VercelQueueCallbackReturn = (request: Request) => Promise<unknown> | unknown;
@@ -179,13 +191,18 @@ interface ResolvedLocalQueueOptions extends LocalQueueModuleDriverOptions {
179
191
  rules?: LocalQueueRules;
180
192
  }
181
193
  type ResolvedQueueOptions = CloudflareQueueModuleDriverOptions | ResolvedLocalQueueOptions | ResolvedPostgresQueueOptions | VercelQueueModuleDriverOptions;
194
+ /** The one object that a Queue handler receives: the `payload` that was sent, and the delivery details. */
182
195
  interface QueueJob<TPayload = unknown> {
196
+ /** Delivery count of this job, from 1. */
183
197
  attempts: number;
198
+ /** Message ID of this job. */
184
199
  id: string;
200
+ /** Delivery metadata of the provider, when it gives some. */
185
201
  metadata?: unknown;
186
202
  payload: TPayload;
187
203
  }
188
204
  type QueueHandler<TPayload = unknown, TResult = unknown> = (job: QueueJob<TPayload>) => TResult;
205
+ /** Options of `defineQueue()`, next to `handler`. */
189
206
  interface QueueDefinitionOptions {
190
207
  cache?: boolean;
191
208
  callbackOptions?: VercelQueueCallbackOptions;
@@ -195,9 +212,9 @@ interface QueueDefinitionOptions {
195
212
  }) => unknown | Promise<unknown>;
196
213
  onError?: CloudflareQueueBatchHandlerOptions["onError"];
197
214
  }
198
- interface QueueDefinition<TPayload = unknown, TResult = unknown> {
215
+ /** A Queue Definition: `defineQueue({ handler, ...options })`. */
216
+ interface QueueDefinition<TPayload = unknown, TResult = unknown> extends QueueDefinitionOptions {
199
217
  handler: QueueHandler<TPayload, TResult>;
200
- options?: QueueDefinitionOptions;
201
218
  }
202
219
  /**
203
220
  * Options of `sendQueue()` and `send()`. ViteHub generates the message ID. To deduplicate sends, pass `idempotencyKey`
@@ -205,27 +222,30 @@ interface QueueDefinition<TPayload = unknown, TResult = unknown> {
205
222
  */
206
223
  interface QueueEnqueueOptions {
207
224
  contentType?: CloudflareQueueContentType;
208
- delaySeconds?: number;
225
+ /** Time before delivery, such as `"30s"`, `"5m"`, or `"1 day"`. A number fails with `RUNTIME_DURATION_INVALID`. */
226
+ delay?: Duration;
209
227
  idempotencyKey?: string;
210
228
  region?: string;
211
- retentionSeconds?: number;
229
+ /** How long the provider keeps the job: a duration such as `"1h"`, or a number of seconds. */
230
+ retention?: Duration | number;
212
231
  }
213
232
  type QueueSendResult = {
214
233
  messageId?: string;
215
234
  status: "queued";
216
235
  };
217
236
  /** Codes that Queue operations return in the `[error, data]` tuple. Config errors throw instead. */
218
- type QueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_PROVIDER_INVALID_RESPONSE" | "QUEUE_UNSUPPORTED_OPTION";
237
+ type QueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_PROVIDER_INVALID_RESPONSE" | "QUEUE_UNSUPPORTED_OPTION" | "RUNTIME_DURATION_INVALID";
219
238
  /** Codes that `send()` and `sendBatch()` of a Cloudflare QueueClient return. */
220
- type CloudflareQueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_UNSUPPORTED_OPTION";
239
+ type CloudflareQueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_UNSUPPORTED_OPTION" | "RUNTIME_DURATION_INVALID";
221
240
  /** Codes that `send()` and `sendBatch()` of a local QueueClient return. */
222
- type LocalQueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_UNSUPPORTED_OPTION";
241
+ type LocalQueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_UNSUPPORTED_OPTION" | "RUNTIME_DURATION_INVALID";
223
242
  /** Codes that `send()` and `sendBatch()` of a postgres QueueClient return. */
224
- type PostgresQueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_UNSUPPORTED_OPTION";
243
+ type PostgresQueueErrorCode = "QUEUE_PROVIDER_FAILED" | "QUEUE_UNSUPPORTED_OPTION" | "RUNTIME_DURATION_INVALID";
225
244
  /** One job in `sendBatch()` of a local or postgres QueueClient. */
226
245
  interface LocalQueueSendBatchMessage<T = unknown> {
227
246
  body: T;
228
- delaySeconds?: number;
247
+ /** Time before delivery, such as `"1m"`. */
248
+ delay?: Duration;
229
249
  idempotencyKey?: string;
230
250
  }
231
251
  /** Codes that `send()` and `sendBatch()` of a Vercel QueueClient return. */
@@ -241,7 +261,7 @@ interface CloudflareQueueClient<TPayload = unknown> extends QueueClientBase<"clo
241
261
  readonly binding: CloudflareQueueBinding;
242
262
  createBatchHandler: <TMessage = unknown>(options: CloudflareQueueBatchHandlerOptions<TMessage>) => (batch: CloudflareQueueMessageBatch<TMessage>) => Promise<void>;
243
263
  send: (payload: TPayload, options?: QueueEnqueueOptions) => Promise<Result<QueueSendResult, CloudflareQueueErrorCode>>;
244
- sendBatch: (items: CloudflareQueueSendBatchMessage<TPayload>[], options?: QueueEnqueueOptions) => Promise<Result<QueueSendResult[], CloudflareQueueErrorCode>>;
264
+ sendBatch: (items: CloudflareQueueSendBatchItem<TPayload>[], options?: QueueEnqueueOptions) => Promise<Result<QueueSendResult[], CloudflareQueueErrorCode>>;
245
265
  }
246
266
  /**
247
267
  * `send()` and `sendBatch()` return `[error, data]`. `error.code` is one of the codes in the method type.
@@ -266,7 +286,7 @@ interface LocalQueueClient<TPayload = unknown> extends QueueClientBase<"local">
266
286
  readonly queue: string;
267
287
  send: (payload: TPayload, options?: QueueEnqueueOptions) => Promise<Result<QueueSendResult, LocalQueueErrorCode>>;
268
288
  sendBatch: (items: LocalQueueSendBatchMessage<TPayload>[], options?: {
269
- delaySeconds?: number;
289
+ delay?: Duration;
270
290
  }) => Promise<Result<QueueSendResult[], LocalQueueErrorCode>>;
271
291
  }
272
292
  /**
@@ -278,7 +298,7 @@ interface PostgresQueueClient<TPayload = unknown> extends QueueClientBase<"postg
278
298
  send: (payload: TPayload, options?: QueueEnqueueOptions) => Promise<Result<QueueSendResult, PostgresQueueErrorCode>>;
279
299
  /** Inserts all jobs in one transaction. When one insert fails, no job of the batch is stored. */
280
300
  sendBatch: (items: LocalQueueSendBatchMessage<TPayload>[], options?: {
281
- delaySeconds?: number;
301
+ delay?: Duration;
282
302
  }) => Promise<Result<QueueSendResult[], PostgresQueueErrorCode>>;
283
303
  }
284
304
  interface QueueClientMap<TPayload> {
@@ -322,7 +342,7 @@ interface QueueDeliveryErrorDetails {
322
342
  interface LocalQueueDeliveryRules {
323
343
  /** Deliveries before a failing job becomes a dead job. `Infinity` retries until the job expires. */
324
344
  maxAttempts: number;
325
- /** Largest `delaySeconds` that a send accepts. */
345
+ /** Largest `delay`, in seconds, that a send accepts. */
326
346
  maxDelaySeconds?: number;
327
347
  /** Largest number of jobs in one `sendBatch()`. */
328
348
  maxBatchJobs?: number;
@@ -330,7 +350,7 @@ interface LocalQueueDeliveryRules {
330
350
  maxBatchBytes?: number;
331
351
  /** Largest JSON size in bytes of one payload. */
332
352
  maxPayloadBytes?: number;
333
- /** Accepted `retentionSeconds`. A job expires at the end of its retention, whether it ran or not. */
353
+ /** Accepted `retention`, in seconds. A job expires at the end of its retention, whether it ran or not. */
334
354
  retention?: {
335
355
  defaultSeconds: number;
336
356
  maxSeconds: number;
@@ -341,7 +361,7 @@ interface LocalQueueDeliveryRules {
341
361
  /** The provider whose documented rules these are. */
342
362
  rules: LocalQueueRules;
343
363
  /** Enqueue options that fail with `QUEUE_UNSUPPORTED_OPTION`. */
344
- unsupportedOptions: readonly ("contentType" | "idempotencyKey" | "region" | "retentionSeconds")[];
364
+ unsupportedOptions: readonly ("contentType" | "idempotencyKey" | "region" | "retention")[];
345
365
  }
346
366
  interface LocalQueueStatus {
347
367
  /** Absolute directory of the local provider, or the Postgres table and database, without the password. */
@@ -417,4 +437,4 @@ interface QueueJobStore {
417
437
  status: () => Promise<LocalQueueStatus>;
418
438
  }
419
439
  //#endregion
420
- export { QueueModuleDriverOptions as A, VercelQueueClient as B, QueueDriver as C, QueueHandler as D, QueueErrorCode as E, QueueSendResult as F, VercelQueueSendBatchOptions as G, VercelQueueRetryDirective as H, ResolvedLocalQueueOptions as I, VercelQueueSendResult as K, ResolvedQueueOptions as L, QueueOptions as M, QueuePayload as N, QueueJob as O, QueueRegistry as P, VercelQueueBatchSendResult as R, QueueDefinitionRegistry as S, QueueEnqueueOptions as T, VercelQueueRetryHandler as U, VercelQueueErrorCode as V, VercelQueueSendBatchMessage as W, PostgresQueueDriverOptions as _, CloudflareQueueMessageBatch as a, QueueDefinition as b, LocalQueueDriverOptions as c, LocalQueueJobDetail as d, LocalQueueRules as f, PostgresQueueClient as g, NodeQueueDriver as h, CloudflareQueueMessage as i, QueueName as j, QueueJobStore as k, LocalQueueErrorCode as l, LocalQueueStatus as m, CloudflareQueueClient as n, DiscoveredQueueDefinition as o, LocalQueueSendBatchMessage as p, CloudflareQueueErrorCode as r, LocalQueueClient as s, CloudflareQueueBatchHandlerOptions as t, LocalQueueJob as u, PostgresQueueErrorCode as v, QueueDriverOptions as w, QueueDefinitionOptions as x, QueueClient as y, VercelQueueCallbackOptions as z };
440
+ export { QueueJobStore as A, VercelQueueCallbackOptions as B, QueueDefinitionRegistry as C, QueueErrorCode as D, QueueEnqueueOptions as E, QueueRegistry as F, VercelQueueSendBatchMessage as G, VercelQueueErrorCode as H, QueueSendResult as I, VercelQueueSendBatchOptions as K, ResolvedLocalQueueOptions as L, QueueName as M, QueueOptions as N, QueueHandler as O, QueuePayload as P, ResolvedQueueOptions as R, QueueDefinitionOptions as S, QueueDriverOptions as T, VercelQueueRetryDirective as U, VercelQueueClient as V, VercelQueueRetryHandler as W, PostgresQueueClient as _, CloudflareQueueMessageBatch as a, QueueClient as b, LocalQueueClient as c, LocalQueueJob as d, LocalQueueJobDetail as f, NodeQueueDriver as g, LocalQueueStatus as h, CloudflareQueueMessage as i, QueueModuleDriverOptions as j, QueueJob as k, LocalQueueDriverOptions as l, LocalQueueSendBatchMessage as m, CloudflareQueueClient as n, CloudflareQueueSendBatchItem as o, LocalQueueRules as p, VercelQueueSendResult as q, CloudflareQueueErrorCode as r, DiscoveredQueueDefinition as s, CloudflareQueueBatchHandlerOptions as t, LocalQueueErrorCode as u, PostgresQueueDriverOptions as v, QueueDriver as w, QueueDefinition as x, PostgresQueueErrorCode as y, VercelQueueBatchSendResult as z };
@@ -1,4 +1,4 @@
1
- import { L as ResolvedQueueOptions, w as QueueDriverOptions } from "./types-BD-8U9zS.js";
1
+ import { R as ResolvedQueueOptions, T as QueueDriverOptions } from "./types-CiuSIPR0.js";
2
2
  //#region src/internal/runtime/types.d.ts
3
3
  /** Only the generated development integration enables handler error details. */
4
4
  interface QueueDevelopmentOptions {
@@ -1,4 +1,4 @@
1
- import { a as getQueueRuntimeEvent } from "./state-mVA2X_wa.js";
1
+ import { a as getQueueRuntimeEvent } from "./state-DLqTqF6V.js";
2
2
  //#region src/internal/vercel-region.ts
3
3
  function readHeader(headers, name) {
4
4
  const get = headers?.get;
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as QueueOptions, o as DiscoveredQueueDefinition } from "./types-BD-8U9zS.js";
2
- import { n as OperationContributionEntry } from "./operation-definition-8gOe-ubD.js";
1
+ import { N as QueueOptions, s as DiscoveredQueueDefinition } from "./types-CiuSIPR0.js";
2
+ import { n as OperationContributionEntry } from "./operation-definition-nmRu_O3V.js";
3
3
  import "nostics";
4
4
  import { Plugin, UserConfig } from "vite";
5
5
  //#region ../internal/src/deployment.d.ts
@@ -683,6 +683,8 @@ interface ViteHubConsoleDocumentHint {
683
683
  * failing without a reason.
684
684
  */
685
685
  interface ViteHubConsoleDocumentSetup {
686
+ /** The project has GitHub Sources but no document collections. */
687
+ sourceHeadsOnly?: true;
686
688
  /** Present when no user can read anything because the owner has no access policy. */
687
689
  access?: ViteHubConsoleDocumentHint;
688
690
  /**
package/dist/vite.js CHANGED
@@ -1,12 +1,12 @@
1
- import { t as queueErrorDiagnostics } from "./error-diagnostics-BRartC1z.js";
2
- import { t as internalErrorDiagnostics } from "./error-diagnostics-DSkCJC_L.js";
3
- import { a as resolveHost, i as getHostingProvider, n as normalizeQueueOptions, o as resolveHostPreset, r as postgresQueueUrlVariable, t as defaultLocalQueueBase } from "./config-BcTDeQIP.js";
4
1
  import { n as isRecord, r as isRecordOrFunction, t as cloneRecord } from "./object-D8pRdprI.js";
2
+ import { t as queueErrorDiagnostics } from "./error-diagnostics-mJXBjmQx.js";
3
+ import { t as internalErrorDiagnostics } from "./error-diagnostics-CQ4BUqRe.js";
4
+ import { a as resolveHost, i as getHostingProvider, n as normalizeQueueOptions, o as resolveHostPreset, r as postgresQueueUrlVariable, t as defaultLocalQueueBase } from "./config-B2eaXaT5.js";
5
5
  import { t as getCloudflareQueueBindingName } from "./cloudflare-GosJefIK.js";
6
6
  import { t as getVercelQueueTopicName } from "./vercel-C_4vqxcl.js";
7
7
  import { n as summarizeDefinitions } from "./inspect-PeuckaC3.js";
8
8
  import { t as invariant } from "./invariant-D8_xBqmZ.js";
9
- import { t as getCloudflareQueueName } from "./cloudflare-resource-name-BJHYRCMQ.js";
9
+ import { t as getCloudflareQueueName } from "./cloudflare-resource-name-BIfBglC2.js";
10
10
  import { createRequire } from "node:module";
11
11
  import { existsSync, readdirSync, realpathSync, statSync } from "node:fs";
12
12
  import { tmpdir } from "node:os";