@vite-hub/queue 0.1.0 → 0.3.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/README.md +141 -20
- package/dist/client-Cj50hQYp.js +180 -0
- package/dist/{cloudflare-client-COzQ8fHk.js → cloudflare-client-DYsAjM8B.js} +9 -16
- package/dist/{cloudflare-resource-name-CCuLDvSP.js → cloudflare-resource-name-BJHYRCMQ.js} +1 -1
- package/dist/config-BcTDeQIP.js +105 -0
- package/dist/durability.d.ts +13 -0
- package/dist/durability.js +47 -0
- package/dist/error-diagnostics-BRartC1z.js +181 -0
- package/dist/error-diagnostics-DSkCJC_L.js +266 -0
- package/dist/errors-DL3pcNO4.js +77 -0
- package/dist/{handler-response-CBwIkmTS.js → handler-response-By0Fpspv.js} +9 -4
- package/dist/index.d.ts +15 -31
- package/dist/index.js +23 -11
- package/dist/internal/runtime/cloudflare-client.d.ts +2 -2
- package/dist/internal/runtime/cloudflare-client.js +1 -1
- package/dist/internal/runtime/cloudflare-vite.d.ts +30 -2
- package/dist/internal/runtime/cloudflare-vite.js +111 -1
- package/dist/internal/runtime/local-client.d.ts +17 -0
- package/dist/internal/runtime/local-client.js +71 -0
- package/dist/internal/runtime/postgres-client.d.ts +46 -0
- package/dist/internal/runtime/postgres-client.js +560 -0
- package/dist/internal/runtime/state.d.ts +11 -4
- package/dist/internal/runtime/state.js +2 -2
- package/dist/internal/runtime/vercel-client.d.ts +2 -2
- package/dist/internal/runtime/vercel-client.js +52 -26
- package/dist/internal/runtime/worker-client.d.ts +6 -0
- package/dist/internal/runtime/worker-client.js +11 -0
- package/dist/invariant-D8_xBqmZ.js +22 -0
- package/dist/local-CGckW5nr.js +540 -0
- package/dist/local-CVVRVWeR.d.ts +22 -0
- package/dist/object-D8pRdprI.js +15 -0
- package/dist/{operations-tNUdj3G4.d.ts → operation-definition-8gOe-ubD.d.ts} +37 -15
- package/dist/operations-Crwjca91.js +124 -0
- package/dist/operations.d.ts +45 -8
- package/dist/operations.js +173 -24
- package/dist/runtime/hosted.d.ts +3 -5
- package/dist/runtime/hosted.js +21 -45
- package/dist/{state-G9s378-e.js → state-mVA2X_wa.js} +59 -47
- package/dist/types-BD-8U9zS.d.ts +420 -0
- package/dist/types-DS_rqu9l.d.ts +10 -0
- package/dist/vercel-region-D1CivgdA.js +26 -0
- package/dist/virtual.d.ts +4 -0
- package/dist/vite.d.ts +364 -49
- package/dist/vite.js +2071 -2
- package/package.json +39 -46
- package/dist/client-CIc3jsj2.js +0 -114
- package/dist/cloudflare-vite-BCuJOXcT.js +0 -111
- package/dist/cloudflare-vite-CjdP5yBN.d.ts +0 -29
- package/dist/config-BINujLv4.js +0 -74
- package/dist/enqueue-CnQ0QR3O.js +0 -22
- package/dist/error-diagnostics-A_8Kp-48.js +0 -116
- package/dist/error-diagnostics-qzRF6IVB.js +0 -109
- package/dist/errors-DIFaM9tW.js +0 -42
- package/dist/nuxt.d.ts +0 -39
- package/dist/nuxt.js +0 -34
- package/dist/object-B1NW521B.js +0 -7
- package/dist/operations-Cnjbz8kk.js +0 -63
- package/dist/types-1GRMYES1.d.ts +0 -180
- package/dist/vercel-region-cjskrOKl.js +0 -122
- package/dist/vite-ChWLzOVu.js +0 -1512
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/durability.ts
|
|
2
|
+
const hostedDrivers = {
|
|
3
|
+
cloudflare: "Cloudflare Queues deliver each job once.",
|
|
4
|
+
vercel: "Vercel Queues deliver each job once."
|
|
5
|
+
};
|
|
6
|
+
/** The durability of Queue jobs, from the driver. */
|
|
7
|
+
function queueDurability(input, context) {
|
|
8
|
+
const hosted = hostedDrivers[input.driver];
|
|
9
|
+
if (hosted) return [{
|
|
10
|
+
primitive: "queue",
|
|
11
|
+
store: input.driver,
|
|
12
|
+
scope: "shared",
|
|
13
|
+
reason: hosted
|
|
14
|
+
}];
|
|
15
|
+
if (input.driver === "postgres") {
|
|
16
|
+
if (context.env.QUEUE_POSTGRES_URL?.trim()) return [{
|
|
17
|
+
primitive: "queue",
|
|
18
|
+
store: "postgres",
|
|
19
|
+
scope: "shared",
|
|
20
|
+
reason: "Jobs in Postgres at QUEUE_POSTGRES_URL."
|
|
21
|
+
}];
|
|
22
|
+
const name = input.database ?? "default";
|
|
23
|
+
const database = context.find("database", name);
|
|
24
|
+
return [database ? {
|
|
25
|
+
primitive: "queue",
|
|
26
|
+
store: "postgres",
|
|
27
|
+
scope: database.scope,
|
|
28
|
+
reason: `Jobs in the ${name} Database. ${database.reason}`,
|
|
29
|
+
...database.fix ? { fix: database.fix } : {}
|
|
30
|
+
} : {
|
|
31
|
+
primitive: "queue",
|
|
32
|
+
store: "postgres",
|
|
33
|
+
scope: "process",
|
|
34
|
+
reason: `The ${name} Database is off, so the Queue has no connection.`,
|
|
35
|
+
fix: "Set QUEUE_POSTGRES_URL, or turn on a Postgres Default Database."
|
|
36
|
+
}];
|
|
37
|
+
}
|
|
38
|
+
return [{
|
|
39
|
+
primitive: "queue",
|
|
40
|
+
store: input.driver,
|
|
41
|
+
scope: "host",
|
|
42
|
+
reason: `Job files in ${input.base ?? ".vitehub/data/queue"}. One server process must own this folder.`,
|
|
43
|
+
fix: "Use the `postgres` driver with a Postgres Default Database."
|
|
44
|
+
}];
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { queueDurability };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { defineErrors } from "@vite-hub/runtime";
|
|
2
|
+
//#region src/error-diagnostics.ts
|
|
3
|
+
const queueErrorDiagnostics = /*#__PURE__*/ defineErrors({
|
|
4
|
+
docs: "https://vitehub.dev/docs/queue/diagnostics",
|
|
5
|
+
codes: {
|
|
6
|
+
QUEUE_PROVIDER_FAILED: {
|
|
7
|
+
why: ({ operation, provider }) => `The ${provider} queue provider failed during ${operation}.`,
|
|
8
|
+
fix: "Read `error.cause` for the provider error. Retry when the provider is available again. Pass `idempotencyKey` on Vercel so that a retry does not enqueue the job two times."
|
|
9
|
+
},
|
|
10
|
+
QUEUE_PROVIDER_INVALID_RESPONSE: {
|
|
11
|
+
why: "The Vercel queue provider accepted the job, but returned an invalid `messageId`.",
|
|
12
|
+
fix: "Do not send the job again without an `idempotencyKey`, because the provider can have it. Check the installed `@vercel/queue` version."
|
|
13
|
+
},
|
|
14
|
+
QUEUE_UNSUPPORTED_OPTION: {
|
|
15
|
+
why: ({ options, provider }) => `The ${provider} queue provider does not support the enqueue option ${options}.`,
|
|
16
|
+
fix: ({ options }) => options.includes("`id`") ? "Remove `id`. ViteHub generates the message ID. To deduplicate sends, pass `idempotencyKey` on a provider that supports it." : "Remove the option for this provider. The enqueue options table on the Queue Server API page shows which provider supports each option."
|
|
17
|
+
},
|
|
18
|
+
QUEUE_LOCAL_LIMIT_EXCEEDED: {
|
|
19
|
+
why: ({ limit, max, min, provider, value }) => ({
|
|
20
|
+
"batch-bytes": `${provider} accepts up to ${max} bytes in one \`sendBatch()\`, got ${value} bytes of JSON.`,
|
|
21
|
+
"batch-empty": "Vercel requires at least one job in a `sendBatch()`.",
|
|
22
|
+
"batch-jobs": `${provider} accepts up to ${max} jobs in one \`sendBatch()\`, got ${value}.`,
|
|
23
|
+
"delay": `\`delaySeconds\` must be a number of seconds from 0, got ${value}.`,
|
|
24
|
+
"delay-max": `${provider} accepts \`delaySeconds\` up to ${max}, got ${value}.`,
|
|
25
|
+
"payload": `${provider} accepts a payload of up to ${max} bytes, got ${value} bytes of JSON.`,
|
|
26
|
+
"retention": `${provider} accepts \`retentionSeconds\` from ${min} to ${max}, got ${value}.`
|
|
27
|
+
})[limit],
|
|
28
|
+
fix: "Change the job as the message says: `delaySeconds`, `retentionSeconds`, the payload size, or the number or size of the jobs in one `sendBatch()`. The local provider applies the limits of the production provider, so the same job fails there too."
|
|
29
|
+
},
|
|
30
|
+
QUEUE_VERCEL_BATCH_REJECTED: {
|
|
31
|
+
why: ({ failed, total }) => `@vercel/queue did not accept ${failed} of ${total} batch messages.`,
|
|
32
|
+
fix: "Read `results` on this error for the result of each job. Send the failed jobs again with the same `idempotencyKey`, so that Vercel does not enqueue an accepted job two times."
|
|
33
|
+
},
|
|
34
|
+
QUEUE_VERCEL_SEND_BATCH_UNAVAILABLE: {
|
|
35
|
+
why: "The Vercel queue client has no `sendBatch()`. Install `@vercel/queue` 0.10 or later.",
|
|
36
|
+
fix: "Install `@vercel/queue` 0.10 or later, for example with `pnpm add @vercel/queue@latest`. Or pass a `client` that has `sendBatch()`."
|
|
37
|
+
},
|
|
38
|
+
QUEUE_DEFINITION_NAME_INVALID: {
|
|
39
|
+
why: "The queue name is not a valid Queue Definition name.",
|
|
40
|
+
fix: "Pass the name of a Queue Definition. `vitehub queue list` shows them."
|
|
41
|
+
},
|
|
42
|
+
QUEUE_JOBS_UNAVAILABLE: {
|
|
43
|
+
why: ({ driver }) => `The ${driver} queue driver does not let the app read its jobs. Only the local and postgres drivers store jobs that ViteHub can list.`,
|
|
44
|
+
fix: "Run the app with `vite dev`, which runs every job in the dev server, or on a Node server with the local or postgres driver. Read hosted jobs in the Cloudflare or Vercel dashboard."
|
|
45
|
+
},
|
|
46
|
+
QUEUE_JOB_DUPLICATE: {
|
|
47
|
+
why: "A newer pending or running job has the idempotency key of this dead job, so the dead job cannot run again.",
|
|
48
|
+
fix: "Wait for the newer job to end, or remove the dead job with `vitehub queue jobs clear --state dead`."
|
|
49
|
+
},
|
|
50
|
+
QUEUE_JOB_NOT_FOUND: {
|
|
51
|
+
why: "No stored job has this message ID. The local and postgres drivers delete a job when its handler succeeds.",
|
|
52
|
+
fix: "Run `vitehub queue jobs list` for the IDs of the pending, running, and dead jobs."
|
|
53
|
+
},
|
|
54
|
+
QUEUE_JOB_RUNNING: {
|
|
55
|
+
why: "The job is running now.",
|
|
56
|
+
fix: "Wait for the attempt to end, then run `vitehub queue jobs show` for its state."
|
|
57
|
+
},
|
|
58
|
+
QUEUE_BINDING_NOT_FOUND: {
|
|
59
|
+
why: ({ binding }) => binding ? `The Cloudflare queue binding "${binding}" is not in the Worker env.` : "The Cloudflare queue client has no binding.",
|
|
60
|
+
fix: "Run the Worker that `vite build` writes, with `wrangler dev` or a deployment, so its configuration has the generated binding. A custom Worker configuration must keep that binding. `vite dev` runs Queue jobs in the dev server and needs no binding."
|
|
61
|
+
},
|
|
62
|
+
QUEUE_DEFINITION_LOAD_FAILED: {
|
|
63
|
+
why: ({ queue }) => queue ? `The Queue Definition "${queue}" failed to load.` : "A Queue Definition failed to load.",
|
|
64
|
+
fix: "Read `error.cause` for the import error, and fix the Queue Definition module."
|
|
65
|
+
},
|
|
66
|
+
QUEUE_DEFINITION_NOT_FOUND: {
|
|
67
|
+
why: ({ queue }) => queue ? `No Queue Definition has the name "${queue}".` : "No Queue Definition has the requested name.",
|
|
68
|
+
fix: "Add `server/queues/<name>.ts` with a default `defineQueue()` export, and build again with Queue enabled. The generated server output loads the Queue Definitions, so a script that runs outside of it, or an app built without Queue, finds none."
|
|
69
|
+
},
|
|
70
|
+
QUEUE_DISABLED: {
|
|
71
|
+
why: "Queue is disabled in this runtime.",
|
|
72
|
+
fix: "In `vitehub()`, set `queue.driver` to the driver of the host, or remove `driver`. With `@vite-hub/queue` alone, do not pass `false` to `hubQueue()`, and set a `driver` that matches the host."
|
|
73
|
+
},
|
|
74
|
+
QUEUE_DRIVER_MISMATCH: {
|
|
75
|
+
why: ({ driver, expected }) => `The ${expected} Queue runtime received the ${driver} driver.`,
|
|
76
|
+
fix: "Set `queue.driver` to the driver of the deployment preset, and build again."
|
|
77
|
+
},
|
|
78
|
+
QUEUE_INVALID_BINDING: {
|
|
79
|
+
why: "The Cloudflare queue binding does not have `send()` and `sendBatch()`.",
|
|
80
|
+
fix: "Pass a Cloudflare Queue producer binding, for example `env.WELCOME_QUEUE`."
|
|
81
|
+
},
|
|
82
|
+
QUEUE_MISSING_REGION: {
|
|
83
|
+
why: "The installed `@vercel/queue` needs a region, and ViteHub cannot find one.",
|
|
84
|
+
fix: "Set `queue.region` in the Vite config, or set the `QUEUE_REGION` environment variable."
|
|
85
|
+
},
|
|
86
|
+
QUEUE_MISSING_QUEUE: {
|
|
87
|
+
why: "A direct local queue client needs a `queue` name.",
|
|
88
|
+
fix: "Pass the name of a Queue Definition as `queue` to `createQueueClient()`, or use `useQueue()`."
|
|
89
|
+
},
|
|
90
|
+
QUEUE_LOCAL_MODE_MISMATCH: {
|
|
91
|
+
why: "The local Queue directory already has an engine with a different development error disclosure mode.",
|
|
92
|
+
fix: "Use `useQueue()` in the generated server runtime, or give the direct client a separate directory."
|
|
93
|
+
},
|
|
94
|
+
QUEUE_MISSING_TOPIC: {
|
|
95
|
+
why: "A direct Vercel queue client needs a `topic`.",
|
|
96
|
+
fix: "Pass `topic` to `createQueueClient()`, or use `useQueue()` for a discovered Queue Definition."
|
|
97
|
+
},
|
|
98
|
+
QUEUE_POSTGRES_CLOSING: {
|
|
99
|
+
why: "The Postgres Queue runtime is shutting down and cannot accept more jobs or connections.",
|
|
100
|
+
fix: "Send jobs before server shutdown starts, or send them from another running instance."
|
|
101
|
+
},
|
|
102
|
+
QUEUE_POSTGRES_INVALID_URL: {
|
|
103
|
+
why: ({ variable }) => `${variable} is set, and its value is not a \`postgres://\` or \`postgresql://\` URL.`,
|
|
104
|
+
fix: "Set `QUEUE_POSTGRES_URL` to the Postgres URL of the jobs, or remove it to use the connection of the Default Database."
|
|
105
|
+
},
|
|
106
|
+
QUEUE_POSTGRES_MISSING_CONNECTION: {
|
|
107
|
+
why: ({ database }) => database ? `The postgres queue provider uses the connection of the Database "${database}", and that Database has no Postgres client in this runtime.` : "The postgres queue provider has no connection: the build found no Postgres Default Database, and `QUEUE_POSTGRES_URL` is not set.",
|
|
108
|
+
fix: "Add a Default Database with `dialect: 'postgresql'` and build again, or set `QUEUE_POSTGRES_URL` on the server to the Postgres URL of the jobs."
|
|
109
|
+
},
|
|
110
|
+
QUEUE_RUNTIME_NOT_INSTALLED: {
|
|
111
|
+
why: "The Queue runtime has no client factory. The generated server output installs it.",
|
|
112
|
+
fix: "Set `queue` in `vitehub()`, or add `hubQueue()` to the Vite plugins when you use `@vite-hub/queue` alone. Then build the app and run the built server."
|
|
113
|
+
},
|
|
114
|
+
QUEUE_VERCEL_SDK_INVALID: {
|
|
115
|
+
why: "`@vercel/queue` does not have the client API that ViteHub uses.",
|
|
116
|
+
fix: "Install a supported `@vercel/queue` version, or pass a `client` that has `send()` and `handleCallback()`."
|
|
117
|
+
},
|
|
118
|
+
QUEUE_VERCEL_SDK_UNAVAILABLE: {
|
|
119
|
+
why: "`@vercel/queue` or `@vercel/functions` cannot be loaded.",
|
|
120
|
+
fix: "Add `@vercel/queue` and `@vercel/functions` to the app dependencies. Read `error.cause` for the import error."
|
|
121
|
+
},
|
|
122
|
+
QUEUE_BINDING_CONFLICT: {
|
|
123
|
+
why: "A custom `queue.binding` works with one Queue Definition only, and this app has more.",
|
|
124
|
+
fix: "Remove `queue.binding`, so that each Queue Definition gets its own generated binding."
|
|
125
|
+
},
|
|
126
|
+
QUEUE_CONTRIBUTION_INVALID: {
|
|
127
|
+
why: ({ message }) => message,
|
|
128
|
+
fix: "Correct the `vitehub.queues` entry of the plugin that the message names. Give it a `name` and `definition: { module }`, where `module` is the absolute path or `file:` URL of a file with `export default defineQueue(...)`."
|
|
129
|
+
},
|
|
130
|
+
QUEUE_CRYPTO_UNAVAILABLE: {
|
|
131
|
+
why: "Cloudflare queue names for long Queue Definition names need the `node:crypto` module, and this runtime does not have it.",
|
|
132
|
+
fix: "Enable the `nodejs_compat` compatibility flag, or use a shorter Queue Definition name."
|
|
133
|
+
},
|
|
134
|
+
QUEUE_DEFINITIONS_CHANGED: {
|
|
135
|
+
why: ({ context }) => `The ${context} Queue Definitions changed after Vite resolved the config.`,
|
|
136
|
+
fix: "Generate Queue Definition files before the Vite config resolves, then build again."
|
|
137
|
+
},
|
|
138
|
+
QUEUE_DEFINITION_DUPLICATE: {
|
|
139
|
+
why: ({ message }) => message,
|
|
140
|
+
fix: "Rename or remove one of the two Queue Definitions that the message lists. Each Queue name must have one file or one plugin contribution."
|
|
141
|
+
},
|
|
142
|
+
QUEUE_INVALID_CONFIG: {
|
|
143
|
+
why: "`queue` must be a plain object or `false`.",
|
|
144
|
+
fix: "Pass an object, for example `queue: { driver: 'cloudflare' }`."
|
|
145
|
+
},
|
|
146
|
+
QUEUE_INVALID_DEFINITION: {
|
|
147
|
+
why: "`defineQueue()` needs a handler function.",
|
|
148
|
+
fix: "Pass the handler as the first argument, for example `defineQueue(async (job) => { ... })`."
|
|
149
|
+
},
|
|
150
|
+
QUEUE_INVALID_DRIVER: {
|
|
151
|
+
why: ({ driver }) => `\`queue.driver\` "${driver}" is not a Queue driver.`,
|
|
152
|
+
fix: "Set `queue.driver` to \"cloudflare\", \"vercel\", \"local\", or \"postgres\"."
|
|
153
|
+
},
|
|
154
|
+
QUEUE_INVALID_NAME: {
|
|
155
|
+
why: ({ name }) => `The Cloudflare queue name "${name}" can contain only letters, numbers, and dashes, and must start and end with a letter or number.`,
|
|
156
|
+
fix: "Change `queue.namePrefix` so that it contains only letters, numbers, and dashes."
|
|
157
|
+
},
|
|
158
|
+
QUEUE_MISSING_DRIVER: {
|
|
159
|
+
why: ({ hosting }) => `ViteHub cannot select a Queue driver for ${hosting} hosting.`,
|
|
160
|
+
fix: "Set `queue.driver`, select the Cloudflare, Vercel, or Node deployment preset, or set `queue: false`."
|
|
161
|
+
},
|
|
162
|
+
QUEUE_NAME_COLLISION: {
|
|
163
|
+
why: ({ first, resolved, second }) => `The Queue Definitions "${first}" and "${second}" have the same provider name "${resolved}".`,
|
|
164
|
+
fix: "Rename one of the two Queue Definition files."
|
|
165
|
+
},
|
|
166
|
+
QUEUE_PLUGIN_INCOMPATIBLE: {
|
|
167
|
+
why: "The `hubQueue()` plugin in the Vite config does not expose the Queue Nitro config.",
|
|
168
|
+
fix: "Install one version of `@vite-hub/queue`, and use `hubQueue()` from it."
|
|
169
|
+
},
|
|
170
|
+
QUEUE_PROVISION_FAILED: {
|
|
171
|
+
why: "Cloudflare returned an invalid queue list during provisioning.",
|
|
172
|
+
fix: "Run `vitehub provision run --host cloudflare --dry-run` again, and check the Cloudflare token permissions."
|
|
173
|
+
},
|
|
174
|
+
QUEUE_RENAMED_PROVIDER_KEY: {
|
|
175
|
+
why: ({ value }) => `\`queue.provider\` is ${value}. ViteHub renamed this key to \`driver\`, and it does not read \`provider\`, so Queue would not use the driver you chose.`,
|
|
176
|
+
fix: ({ value }) => `Set \`queue: { driver: ${value} }\`, or run \`npx @vite-hub/codemods driver-key\` to rename it in every config file.`
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//#endregion
|
|
181
|
+
export { queueErrorDiagnostics as t };
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { defineDiagnostics } from "nostics";
|
|
2
|
+
//#region ../internal/src/error-diagnostics.ts
|
|
3
|
+
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
|
+
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
|
+
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
6
|
+
codes: {
|
|
7
|
+
INTERNAL_R0012: {
|
|
8
|
+
...dynamicError,
|
|
9
|
+
fix: "Check the URL, the headers, and the credentials of the HTTP request. `error.status` holds the status that the server sent."
|
|
10
|
+
},
|
|
11
|
+
INTERNAL_R0013: {
|
|
12
|
+
...dynamicError,
|
|
13
|
+
fix: "Check that the provider token can manage the resource in the path that the message names. `error.kind` and `error.codes` hold the provider failure."
|
|
14
|
+
},
|
|
15
|
+
INTERNAL_R0014: {
|
|
16
|
+
why: ({ path }) => `Cannot read Provision State from "${path}".`,
|
|
17
|
+
fix: "Check file access and restore valid JSON while preserving existing resource IDs."
|
|
18
|
+
},
|
|
19
|
+
INTERNAL_R0020: {
|
|
20
|
+
fix: "Give the operation a name like `content.publish`, a description, a section, a kind, an input schema, and a run function.",
|
|
21
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
22
|
+
},
|
|
23
|
+
INTERNAL_R0021: {
|
|
24
|
+
fix: "Run `vitehub inspect definitions --kind operation` to list the operations of this app.",
|
|
25
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
26
|
+
},
|
|
27
|
+
INTERNAL_R0022: {
|
|
28
|
+
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
|
|
29
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
30
|
+
},
|
|
31
|
+
INTERNAL_R0024: {
|
|
32
|
+
fix: "Start the dev server with `vite dev`, or pass `--url <origin>` of a deployed app and set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key whose public key the app has in VITEHUB_CONSOLE_KEY_<NAME>.",
|
|
33
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
34
|
+
},
|
|
35
|
+
INTERNAL_R0023: {
|
|
36
|
+
fix: "Ask for access to the section of this operation.",
|
|
37
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
38
|
+
},
|
|
39
|
+
INTERNAL_B0001: {
|
|
40
|
+
...dynamicError,
|
|
41
|
+
fix: "Give the resource that the message names another name or binding in the `vitehub()` options of its feature, so that two different Cloudflare resources do not share one name."
|
|
42
|
+
},
|
|
43
|
+
INTERNAL_B0015: {
|
|
44
|
+
...dynamicError,
|
|
45
|
+
fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`."
|
|
46
|
+
},
|
|
47
|
+
INTERNAL_B0016: {
|
|
48
|
+
...dynamicError,
|
|
49
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
50
|
+
},
|
|
51
|
+
INTERNAL_B0017: {
|
|
52
|
+
...dynamicError,
|
|
53
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
54
|
+
},
|
|
55
|
+
INTERNAL_B0018: {
|
|
56
|
+
...dynamicError,
|
|
57
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
58
|
+
},
|
|
59
|
+
INTERNAL_B0019: {
|
|
60
|
+
...dynamicError,
|
|
61
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
62
|
+
},
|
|
63
|
+
INTERNAL_B0020: {
|
|
64
|
+
...dynamicError,
|
|
65
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
66
|
+
},
|
|
67
|
+
INTERNAL_B0021: {
|
|
68
|
+
...dynamicError,
|
|
69
|
+
fix: "Install the package that the message names in the app, for example with `pnpm add <name>`, then build again."
|
|
70
|
+
},
|
|
71
|
+
INTERNAL_B0022: {
|
|
72
|
+
...dynamicError,
|
|
73
|
+
fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`."
|
|
74
|
+
},
|
|
75
|
+
INTERNAL_B0025: {
|
|
76
|
+
...dynamicError,
|
|
77
|
+
fix: "Replace the `new URL(\"./...\", import.meta.url)` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import` of that file."
|
|
78
|
+
},
|
|
79
|
+
INTERNAL_B0026: {
|
|
80
|
+
...dynamicError,
|
|
81
|
+
fix: "Replace the computed `import()` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import` or with `import(\"<literal path>\")`."
|
|
82
|
+
},
|
|
83
|
+
INTERNAL_B0027: {
|
|
84
|
+
...dynamicError,
|
|
85
|
+
fix: "Replace the computed `require()` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import`."
|
|
86
|
+
},
|
|
87
|
+
INTERNAL_B0028: {
|
|
88
|
+
...dynamicError,
|
|
89
|
+
fix: "Wait for the other build of this app to finish, or stop the process that the message names, then build again."
|
|
90
|
+
},
|
|
91
|
+
INTERNAL_B0029: {
|
|
92
|
+
...dynamicError,
|
|
93
|
+
fix: "Stop the other builds that write the same Deno output folder, delete the `.vitehub-lock` folder next to that output folder, such as `.output.vitehub-lock`, then build again."
|
|
94
|
+
},
|
|
95
|
+
INTERNAL_B0031: {
|
|
96
|
+
...dynamicError,
|
|
97
|
+
fix: "Import `./schedule/deno-cron.mjs` at the top level of the project-root `main.ts`, for example with `await import(new URL(\"./schedule/deno-cron.mjs\", import.meta.url).href)` outside any condition."
|
|
98
|
+
},
|
|
99
|
+
INTERNAL_B0032: {
|
|
100
|
+
...dynamicError,
|
|
101
|
+
fix: "Import `./server/index.mjs` at the top level of the project-root `main.ts`, for example with `await import(new URL(\"./server/index.mjs\", import.meta.url).href)` outside any condition."
|
|
102
|
+
},
|
|
103
|
+
INTERNAL_B0035: {
|
|
104
|
+
...dynamicError,
|
|
105
|
+
fix: "Delete the provider output folder that holds the file that the message names, such as `dist/<app>` for Cloudflare, and build again."
|
|
106
|
+
},
|
|
107
|
+
INTERNAL_B0039: {
|
|
108
|
+
...dynamicError,
|
|
109
|
+
fix: "Fix the build error that ViteHub showed before this one. ViteHub stops writing the provider output when another part of the build fails."
|
|
110
|
+
},
|
|
111
|
+
INTERNAL_B0040: {
|
|
112
|
+
...dynamicError,
|
|
113
|
+
fix: "Remove the custom Nitro `output.serverDir`, so that the Nitro preset of the host writes the server entry that the message names."
|
|
114
|
+
},
|
|
115
|
+
INTERNAL_B0043: {
|
|
116
|
+
...dynamicError,
|
|
117
|
+
fix: "Delete the build output folder, such as `.output` or `.vercel/output`, and build again."
|
|
118
|
+
},
|
|
119
|
+
INTERNAL_B0046: {
|
|
120
|
+
...dynamicError,
|
|
121
|
+
fix: "Install the package that the message names in the app, for example with `pnpm add <name>`, then build again."
|
|
122
|
+
},
|
|
123
|
+
INTERNAL_B0047: {
|
|
124
|
+
...dynamicError,
|
|
125
|
+
fix: "Correct the `package.json` file that the message names so that it holds one JSON object, or run `pnpm install` again to restore an installed package."
|
|
126
|
+
},
|
|
127
|
+
INTERNAL_B0048: {
|
|
128
|
+
fix: "Rename one of the two operations. A name is `<section>.<verb>` and is unique in the app.",
|
|
129
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
130
|
+
},
|
|
131
|
+
INTERNAL_B0049: {
|
|
132
|
+
fix: "Set `cli: { namespace, command }` on one of the two operations.",
|
|
133
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
134
|
+
},
|
|
135
|
+
INTERNAL_B0050: {
|
|
136
|
+
fix: "Rename one of the two operations, or set `mcp: false` on it. MCP tool names replace every character outside letters, digits, `_`, and `-` with `_`.",
|
|
137
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
138
|
+
},
|
|
139
|
+
INTERNAL_B0051: {
|
|
140
|
+
why: ({ field, generated, name, path, project, scope }) => `The Cloudflare ${path} entry "${name}"${scope} is written by ViteHub and by the project's Wrangler config with a different ${field}: ${generated} and ${project}.`,
|
|
141
|
+
fix: "Remove the entry from the project's Wrangler config, since ViteHub writes it, or give one of them another name."
|
|
142
|
+
},
|
|
143
|
+
INTERNAL_B0052: {
|
|
144
|
+
why: ({ column, section }) => `The column "${column}" of the Console section "${section}" needs both \`format: "switch"\` and a \`switch\` operation name such as "skills.set".`,
|
|
145
|
+
fix: "Give a switch column `format: \"switch\"` and `switch: { operation, input }` with a registered operation name, or remove both."
|
|
146
|
+
},
|
|
147
|
+
INTERNAL_R0025: {
|
|
148
|
+
fix: "Start `vite dev` in the project that you run the command from, or pass `--url` of that server.",
|
|
149
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
150
|
+
},
|
|
151
|
+
INTERNAL_R0026: {
|
|
152
|
+
why: "The server parsed a destructive operation that the CLI did not confirm.",
|
|
153
|
+
fix: "Review the operation, then run it again with --yes to confirm the change."
|
|
154
|
+
},
|
|
155
|
+
INTERNAL_C0001: {
|
|
156
|
+
...dynamicError,
|
|
157
|
+
fix: "Rename or remove one of the two files that the message lists. ViteHub takes the Definition name from the file path."
|
|
158
|
+
},
|
|
159
|
+
INTERNAL_C0002: {
|
|
160
|
+
...dynamicError,
|
|
161
|
+
fix: "Rename or remove one of the two files that the message lists. ViteHub takes the Definition name from the file path."
|
|
162
|
+
},
|
|
163
|
+
INTERNAL_R0001: {
|
|
164
|
+
...dynamicError,
|
|
165
|
+
fix: "Set `host` in `vitehub()`, or in the `vitehub` options of `nuxt.config.ts`, to `cloudflare`, `deno`, `netlify`, `node`, or `vercel`. Or remove `host` so that ViteHub finds the host from the environment."
|
|
166
|
+
},
|
|
167
|
+
INTERNAL_R0002: {
|
|
168
|
+
...dynamicError,
|
|
169
|
+
fix: "Stop using the feature that the message names, or set `host` in `vitehub()` to a host that provides it. For Blob, you can also set `blob: { driver: \"s3\" }` with a remote store."
|
|
170
|
+
},
|
|
171
|
+
INTERNAL_R0004: {
|
|
172
|
+
...dynamicError,
|
|
173
|
+
fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `fetch()` Source options, or ask the server for a smaller response."
|
|
174
|
+
},
|
|
175
|
+
INTERNAL_R0005: {
|
|
176
|
+
...dynamicError,
|
|
177
|
+
fix: "Set `method` of the HTTP request to `GET`, `HEAD`, or `POST`."
|
|
178
|
+
},
|
|
179
|
+
INTERNAL_R0006: {
|
|
180
|
+
...dynamicError,
|
|
181
|
+
fix: "Set `timeout` of the HTTP request to a number of milliseconds from 1 to 2147483647, or remove it to use the default."
|
|
182
|
+
},
|
|
183
|
+
INTERNAL_R0007: {
|
|
184
|
+
...dynamicError,
|
|
185
|
+
fix: "Set `maxResponseBytes` of the HTTP request to a positive integer no greater than the limit that the message names, or remove it to use the default."
|
|
186
|
+
},
|
|
187
|
+
INTERNAL_R0008: {
|
|
188
|
+
...dynamicError,
|
|
189
|
+
fix: "Make the value that the message names match its schema: the input, query, or body that you send, or the response schema that you declare for the request."
|
|
190
|
+
},
|
|
191
|
+
INTERNAL_R0009: {
|
|
192
|
+
...dynamicError,
|
|
193
|
+
fix: "Use a Standard Schema whose `validate()` returns `{ value }` or `{ issues }` for the value that the message names."
|
|
194
|
+
},
|
|
195
|
+
INTERNAL_R0010: {
|
|
196
|
+
...dynamicError,
|
|
197
|
+
fix: "Run the command again. If the error stays, check the Cloudflare API status, because Cloudflare sent a response that ViteHub cannot read."
|
|
198
|
+
},
|
|
199
|
+
INTERNAL_R0011: {
|
|
200
|
+
...dynamicError,
|
|
201
|
+
fix: "Pass an h3 app, an object with a `fetch(request)` method, or a fetch function as `app`."
|
|
202
|
+
},
|
|
203
|
+
INTERNAL_CONSOLE_KEY_NAME_INVALID: {
|
|
204
|
+
why: ({ name }) => `[vitehub] The Console key name ${JSON.stringify(name)} must be 1 to 64 of A-Z, 0-9, and _.`,
|
|
205
|
+
fix: "Name the Console key with 1 to 64 characters from A-Z, 0-9, and _, such as `CI`. The app reads its public key from `VITEHUB_CONSOLE_KEY_<NAME>`."
|
|
206
|
+
},
|
|
207
|
+
INTERNAL_CONSOLE_PRIVATE_KEY_INVALID: {
|
|
208
|
+
why: "[vitehub] A Console private key is the 32-byte Ed25519 seed as base64url (43 characters). `vitehub secret console-key` makes one.",
|
|
209
|
+
fix: "Run `vitehub secret console-key` and use the 43-character private key that it prints, without spaces or quotes."
|
|
210
|
+
},
|
|
211
|
+
INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLES_MULTIPLE: {
|
|
212
|
+
why: ({ prefix, variables }) => `[vitehub] Set one ${prefix}<NAME> variable. This environment has ${variables}.`,
|
|
213
|
+
fix: "Keep one `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` variable in the environment of the command, and unset the others that the message names."
|
|
214
|
+
},
|
|
215
|
+
INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLE_INVALID: {
|
|
216
|
+
why: ({ variable }) => `[vitehub] ${variable} must be the 43-character private key that \`vitehub secret console-key\` prints, and its name 1 to 64 of A-Z, 0-9, and _.`,
|
|
217
|
+
fix: "Set the variable that the message names to the private key that `vitehub secret console-key` prints, and name it `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` with A-Z, 0-9, and _ in `<NAME>`."
|
|
218
|
+
},
|
|
219
|
+
INTERNAL_FORGE_NOT_INSTALLED: {
|
|
220
|
+
why: ({ feature }) => `${feature} needs @vite-hub/forge, and the app did not install it.`,
|
|
221
|
+
fix: "Install Forge in your app with `pnpm add @vite-hub/forge`, then build again."
|
|
222
|
+
},
|
|
223
|
+
INTERNAL_MCP_ARGUMENTS_INVALID: {
|
|
224
|
+
why: ({ detail }) => detail,
|
|
225
|
+
fix: "Pass the prompt or resource the arguments that `prompts/list` or `resources/templates/list` describes for it."
|
|
226
|
+
},
|
|
227
|
+
INTERNAL_MCP_METHOD_FAILED: {
|
|
228
|
+
why: ({ name }) => `${name} failed on the server.`,
|
|
229
|
+
fix: "Read the server log for the error of the MCP prompt or resource that the message names, and fix its handler."
|
|
230
|
+
},
|
|
231
|
+
INTERNAL_MCP_RESOURCE_NOT_FOUND: {
|
|
232
|
+
why: ({ uri }) => `Resource not found: ${uri}. Call resources/list or resources/templates/list for the resources of this server.`,
|
|
233
|
+
fix: "Call `resources/list` or `resources/templates/list`, and read a URI that one of them returns."
|
|
234
|
+
},
|
|
235
|
+
INTERNAL_PRESET_OPTION_UNKNOWN: {
|
|
236
|
+
why: ({ key, label }) => `[vitehub] Unknown ${label} option "${key}".`,
|
|
237
|
+
fix: "Remove the option that the message names from the preset options, or correct its spelling to an option that the preset declares."
|
|
238
|
+
},
|
|
239
|
+
INTERNAL_PRESET_TUPLE_INVALID: {
|
|
240
|
+
why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
|
|
241
|
+
fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
|
|
242
|
+
},
|
|
243
|
+
INTERNAL_SECRET_PURPOSE_MISSING: {
|
|
244
|
+
why: "[vitehub] A derived secret requires a purpose.",
|
|
245
|
+
fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
|
|
246
|
+
},
|
|
247
|
+
INTERNAL_SECRET_TOO_SHORT: {
|
|
248
|
+
why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
|
|
249
|
+
fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
|
|
250
|
+
},
|
|
251
|
+
INTERNAL_SQLITE_ARGUMENT_INVALID: {
|
|
252
|
+
why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
|
|
253
|
+
fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
|
|
254
|
+
},
|
|
255
|
+
INTERNAL_SQLITE_INTEGER_UNSAFE: {
|
|
256
|
+
why: "Received integer which cannot be safely represented as a JavaScript number",
|
|
257
|
+
fix: "Create the client with `intMode: \"bigint\"` or `intMode: \"string\"`, or read the column with `CAST(column AS TEXT)` in the query."
|
|
258
|
+
},
|
|
259
|
+
INTERNAL_VALIBOT_JSON_SCHEMA_TARGET_UNSUPPORTED: {
|
|
260
|
+
why: ({ target }) => `[vitehub] Valibot cannot convert a schema to the ${target} JSON Schema target.`,
|
|
261
|
+
fix: "Ask for the `draft-07`, `draft-2020-12`, or `openapi-3.0` JSON Schema target, or pass one of them as `withValibotJsonSchema(schema, { target })`."
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
//#endregion
|
|
266
|
+
export { internalErrorDiagnostics as t };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { t as queueErrorDiagnostics } from "./error-diagnostics-BRartC1z.js";
|
|
2
|
+
//#region src/enqueue.ts
|
|
3
|
+
let fallbackCounter = 0;
|
|
4
|
+
function createQueueMessageId(prefix = "queue") {
|
|
5
|
+
const uuid = globalThis.crypto?.randomUUID?.();
|
|
6
|
+
if (uuid) return `${prefix}_${uuid}`;
|
|
7
|
+
fallbackCounter = fallbackCounter + 1 >>> 0;
|
|
8
|
+
return `${prefix}_${Date.now().toString(36)}_${fallbackCounter.toString(36)}`;
|
|
9
|
+
}
|
|
10
|
+
/** Payload properties never select enqueue options. The message ID is always generated. */
|
|
11
|
+
function normalizeQueueEnqueueInput(payload, options = {}) {
|
|
12
|
+
return {
|
|
13
|
+
id: createQueueMessageId(),
|
|
14
|
+
options: { ...options },
|
|
15
|
+
payload
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/errors.ts
|
|
20
|
+
const cloudflareUnsupportedEnqueueOptions = [
|
|
21
|
+
"idempotencyKey",
|
|
22
|
+
"region",
|
|
23
|
+
"retentionSeconds"
|
|
24
|
+
];
|
|
25
|
+
const localUnsupportedEnqueueOptions = [
|
|
26
|
+
"contentType",
|
|
27
|
+
"region",
|
|
28
|
+
"retentionSeconds"
|
|
29
|
+
];
|
|
30
|
+
const postgresUnsupportedEnqueueOptions = localUnsupportedEnqueueOptions;
|
|
31
|
+
const unsupportedEnqueueOptions = {
|
|
32
|
+
cloudflare: cloudflareUnsupportedEnqueueOptions,
|
|
33
|
+
local: localUnsupportedEnqueueOptions,
|
|
34
|
+
postgres: postgresUnsupportedEnqueueOptions,
|
|
35
|
+
vercel: ["contentType"]
|
|
36
|
+
};
|
|
37
|
+
/** Shared pre-dispatch option validation for provider clients and the test backend. */
|
|
38
|
+
function queueUnsupportedOptionsError(options, provider, names = unsupportedEnqueueOptions[provider]) {
|
|
39
|
+
const unsupported = [...Object.hasOwn(options, "id") ? ["id"] : [], ...names.filter((option) => options[option] !== void 0)];
|
|
40
|
+
return unsupported.length ? queueErrorDiagnostics.QUEUE_UNSUPPORTED_OPTION({
|
|
41
|
+
options: formatQueueOptionNames(unsupported),
|
|
42
|
+
provider
|
|
43
|
+
}) : void 0;
|
|
44
|
+
}
|
|
45
|
+
/** Returns `true` for an error from the Queue catalog. Pass `codes` to accept only some codes. */
|
|
46
|
+
function isQueueError(error, codes) {
|
|
47
|
+
return queueErrorDiagnostics.is(error) && (!codes || codes.some((code) => code === error.code));
|
|
48
|
+
}
|
|
49
|
+
/** Formats option names for an error `why`, for example `"region" and "retentionSeconds"`. */
|
|
50
|
+
function formatQueueOptionNames(names) {
|
|
51
|
+
const quoted = names.map((name) => `\`${name}\``);
|
|
52
|
+
return quoted.length > 1 ? `${quoted.slice(0, -1).join(", ")} and ${quoted.at(-1)}` : quoted.join("");
|
|
53
|
+
}
|
|
54
|
+
function normalizePublicQueueIdentifier(value) {
|
|
55
|
+
if (typeof value !== "string" || !value || value.length > 128 || value.trim() !== value) return;
|
|
56
|
+
if (!/^[a-z\d][a-z\d._/-]*$/i.test(value)) return;
|
|
57
|
+
if (/^[a-z][a-z\d+.-]*:\/\//i.test(value) || /^[a-z]:\//i.test(value)) return;
|
|
58
|
+
if (value.split("/").some((part) => part === "." || part === "..")) return;
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Runs one provider call and returns `[error, data]`.
|
|
63
|
+
* Any failure becomes `QUEUE_PROVIDER_FAILED` with the failure in `cause`.
|
|
64
|
+
*/
|
|
65
|
+
async function queueProviderResult(provider, operation, run) {
|
|
66
|
+
try {
|
|
67
|
+
return [void 0, await run()];
|
|
68
|
+
} catch (cause) {
|
|
69
|
+
return [queueErrorDiagnostics.QUEUE_PROVIDER_FAILED({
|
|
70
|
+
cause,
|
|
71
|
+
operation,
|
|
72
|
+
provider
|
|
73
|
+
}), void 0];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { postgresUnsupportedEnqueueOptions as a, createQueueMessageId as c, normalizePublicQueueIdentifier as i, normalizeQueueEnqueueInput as l, isQueueError as n, queueProviderResult as o, localUnsupportedEnqueueOptions as r, queueUnsupportedOptionsError as s, cloudflareUnsupportedEnqueueOptions as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { i as normalizePublicQueueIdentifier,
|
|
1
|
+
import { i as normalizePublicQueueIdentifier, n as isQueueError } from "./errors-DL3pcNO4.js";
|
|
2
2
|
import { getViteHubErrorShape, toResponse } from "@vite-hub/runtime";
|
|
3
3
|
//#region src/internal/delivery-error.ts
|
|
4
4
|
const retryableQueueCodes = /* @__PURE__ */ new Set(["QUEUE_PROVIDER_FAILED", "QUEUE_PROVIDER_INVALID_RESPONSE"]);
|
|
5
5
|
function isNonRetryableQueueError(error) {
|
|
6
6
|
return isQueueError(error) && !retryableQueueCodes.has(error.code);
|
|
7
7
|
}
|
|
8
|
-
function toReportError(error) {
|
|
8
|
+
function toReportError(error, development) {
|
|
9
9
|
if (isQueueError(error)) return {
|
|
10
10
|
code: error.code,
|
|
11
11
|
docs: error.docs,
|
|
@@ -20,6 +20,11 @@ function toReportError(error) {
|
|
|
20
20
|
message: shape.message,
|
|
21
21
|
name: "ViteHubError"
|
|
22
22
|
};
|
|
23
|
+
if (development && error instanceof Error) return {
|
|
24
|
+
message: error.message,
|
|
25
|
+
name: error.name,
|
|
26
|
+
...error.stack ? { stack: error.stack } : {}
|
|
27
|
+
};
|
|
23
28
|
return {
|
|
24
29
|
message: "[vitehub] Queue Delivery failed.",
|
|
25
30
|
name: "Error"
|
|
@@ -33,7 +38,7 @@ function createQueueDeliveryErrorReport(error, context) {
|
|
|
33
38
|
provider: context.provider,
|
|
34
39
|
...id ? { id } : {},
|
|
35
40
|
...queue ? { queue } : {},
|
|
36
|
-
error: toReportError(error),
|
|
41
|
+
error: toReportError(error, context.development === true),
|
|
37
42
|
retryable: !isNonRetryableQueueError(error)
|
|
38
43
|
};
|
|
39
44
|
}
|
|
@@ -53,4 +58,4 @@ function checkQueueHandlerResponse(value) {
|
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
//#endregion
|
|
56
|
-
export {
|
|
61
|
+
export { reportQueueDeliveryError as i, createQueueDeliveryErrorReport as n, isNonRetryableQueueError as r, checkQueueHandlerResponse as t };
|