@vite-hub/queue 0.0.2 → 0.0.4
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/LICENSE +201 -0
- package/README.md +92 -50
- package/dist/{client-CBDT9GL9.js → client-DG9fweET.js} +2 -2
- package/dist/{cloudflare-vite-BNBVtEwG.js → cloudflare-vite-BlQfDVZD.js} +11 -6
- package/dist/{cloudflare-vite-krY8T3zM.d.ts → cloudflare-vite-nFPor46-.d.ts} +1 -1
- package/dist/{config-B7xkD1v0.js → config-CNgAeIND.js} +8 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/{runtime → internal/runtime}/cloudflare-vite.d.ts +1 -1
- package/dist/internal/runtime/cloudflare-vite.js +2 -0
- package/dist/{runtime → internal/runtime}/state.d.ts +2 -2
- package/dist/{runtime → internal/runtime}/state.js +1 -1
- package/dist/internal/runtime/vercel-client.js +1 -1
- package/dist/{runtime → internal/runtime}/vercel-vite.d.ts +3 -3
- package/dist/{runtime → internal/runtime}/vercel-vite.js +3 -3
- package/dist/nuxt.js +2 -1
- package/dist/runtime/hosted.d.ts +1 -2
- package/dist/runtime/hosted.js +1 -1
- package/dist/{state-BfUFGeC2.js → state-Cno9O7YS.js} +10 -5
- package/dist/vercel-runtime-package-copy-CEToJtCu.js +116 -0
- package/dist/vite-DOuoen0w.js +4414 -0
- package/dist/vite.d.ts +15 -2
- package/dist/vite.js +2 -2
- package/package.json +9 -6
- package/dist/runtime/cloudflare-vite.js +0 -2
- package/dist/vercel-runtime-package-copy-B8AEFWXT.js +0 -66
- package/dist/vite-C6yK76Sw.js +0 -1823
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,91 +1,133 @@
|
|
|
1
1
|
# @vite-hub/queue
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<a href="https://vitehub.dev"><img alt="ViteHub" src="https://img.shields.io/badge/ViteHub-vitehub.dev-646cff?style=flat-square"></a>
|
|
5
|
-
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-ready-3178c6?style=flat-square">
|
|
6
|
-
<img alt="Vite" src="https://img.shields.io/badge/Vite-discovery-646cff?style=flat-square">
|
|
7
|
-
<img alt="Queue" src="https://img.shields.io/badge/Queue-background%20jobs-9333ea?style=flat-square">
|
|
8
|
-
</p>
|
|
3
|
+
`@vite-hub/queue` discovers background job handlers during a Vite build and connects `runQueue()` to Cloudflare Queues or Vercel Queues. A successful enqueue means the provider accepted the job. It does not mean the handler finished.
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
Applications that already use the `vite-hub` framework distribution should enable Queue in `vitehub()` and import from `vite-hub/queue`. Install this owner package directly when you are building a custom composition, another framework integration, or package-level tooling. The [Queue guide](https://vitehub.dev/docs/server-primitives/queue) covers the framework-distribution setup.
|
|
11
6
|
|
|
12
|
-
## Install
|
|
7
|
+
## Install the owner package
|
|
13
8
|
|
|
14
9
|
```sh
|
|
15
10
|
pnpm add @vite-hub/queue
|
|
11
|
+
pnpm add -D @vite-hub/cli vite
|
|
16
12
|
```
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
The package requires Node 24 or newer. Vite is an optional peer dependency and is required for definition discovery and provider output. The ViteHub CLI provides the `vitehub provision` command used by the host guides.
|
|
19
15
|
|
|
20
|
-
Vercel
|
|
16
|
+
For Vercel Queues, also install the provider package and the ambient types used by generated functions:
|
|
21
17
|
|
|
22
18
|
```sh
|
|
19
|
+
pnpm add @vercel/queue
|
|
23
20
|
pnpm add -D @types/node @types/ws
|
|
24
21
|
```
|
|
25
22
|
|
|
26
|
-
##
|
|
23
|
+
## Build the first Queue Definition
|
|
24
|
+
|
|
25
|
+
Queue has no in-memory provider for local delivery. The first credential-free result is a build that discovers a Queue Definition and emits provider configuration. This example selects Cloudflare explicitly.
|
|
26
|
+
|
|
27
|
+
Define the handler in a discoverable file:
|
|
27
28
|
|
|
28
29
|
```ts
|
|
29
|
-
//
|
|
30
|
-
import { defineQueue } from "@vite-hub/queue"
|
|
30
|
+
// src/welcome-email.queue.ts
|
|
31
|
+
import { defineQueue } from "@vite-hub/queue";
|
|
31
32
|
|
|
32
|
-
export default defineQueue<{ email: string }>(async (
|
|
33
|
-
console.log(`Send welcome email to ${
|
|
34
|
-
})
|
|
33
|
+
export default defineQueue<{ email: string }>(async ({ payload }) => {
|
|
34
|
+
console.log(`Send welcome email to ${payload.email}`);
|
|
35
|
+
});
|
|
35
36
|
```
|
|
36
37
|
|
|
38
|
+
Enqueue it by its discovered name:
|
|
39
|
+
|
|
37
40
|
```ts
|
|
38
|
-
// server
|
|
39
|
-
import { runQueue } from "@vite-hub/queue"
|
|
40
|
-
import { defineEventHandler, readBody } from "h3"
|
|
41
|
+
// src/server.ts
|
|
42
|
+
import { runQueue } from "@vite-hub/queue";
|
|
41
43
|
|
|
42
|
-
export
|
|
43
|
-
return runQueue("welcome-email",
|
|
44
|
-
}
|
|
44
|
+
export async function enqueueWelcomeEmail(email: string) {
|
|
45
|
+
return await runQueue("welcome-email", { email });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default function handleRequest() {
|
|
49
|
+
return new Response("Queue producer ready");
|
|
50
|
+
}
|
|
45
51
|
```
|
|
46
52
|
|
|
53
|
+
Register the standalone Vite integration and give Vite a server entry:
|
|
54
|
+
|
|
47
55
|
```ts
|
|
48
56
|
// vite.config.ts
|
|
49
|
-
import {
|
|
50
|
-
|
|
57
|
+
import { resolve } from "node:path";
|
|
58
|
+
|
|
59
|
+
import { hubQueue } from "@vite-hub/queue/vite";
|
|
60
|
+
import { defineConfig } from "vite";
|
|
51
61
|
|
|
52
62
|
export default defineConfig({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
build: {
|
|
64
|
+
rollupOptions: {
|
|
65
|
+
input: resolve(import.meta.dirname, "src/server.ts"),
|
|
66
|
+
},
|
|
67
|
+
ssr: true,
|
|
68
|
+
},
|
|
69
|
+
plugins: [hubQueue({ provider: "cloudflare" })],
|
|
70
|
+
});
|
|
56
71
|
```
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
Run a production-shaped build:
|
|
59
74
|
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
import { defineQueue } from "@vite-hub/queue"
|
|
63
|
-
|
|
64
|
-
export default defineQueue<{ email?: string }>(async ({ payload }) => {
|
|
65
|
-
if (!payload.email) {
|
|
66
|
-
throw new ViteHubError("WELCOME_EMAIL_INVALID_PAYLOAD", "Welcome email payload requires an email address.", {
|
|
67
|
-
details: { field: "email" },
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await sendWelcomeEmail(payload.email)
|
|
72
|
-
})
|
|
75
|
+
```sh
|
|
76
|
+
pnpm vite build
|
|
73
77
|
```
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
A successful build writes `.vitehub/queue/registry.mjs` with the `welcome-email` definition. It also writes a Cloudflare Worker and `wrangler.json` under `dist`. The Wrangler configuration contains one generated producer binding and one consumer for the Queue Definition.
|
|
80
|
+
|
|
81
|
+
That build proves discovery and generated output only. `runQueue()` needs the generated runtime, a deployed Cloudflare binding, and an existing queue before it can return `{ status: "queued" }`. Use the [Cloudflare host guide](https://vitehub.dev/docs/frameworks-hosts/cloudflare) for provisioning and deployment checks. Do not import `.vitehub` or `dist` files from application code.
|
|
82
|
+
|
|
83
|
+
## Choose Cloudflare or Vercel
|
|
84
|
+
|
|
85
|
+
| Provider | Choose it when | Generated output | Enqueue options |
|
|
86
|
+
| ---------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
87
|
+
| Cloudflare | The deployed runtime supplies request-scoped Cloudflare Queue bindings | Worker bundle and `wrangler.json` producer and consumer entries | `contentType`, `delaySeconds` |
|
|
88
|
+
| Vercel | The deployment runs Vercel Queue callbacks and has a Queue region when the installed SDK requires one | Consumer functions and trigger configuration under `.vercel/output` | `delaySeconds`, `idempotencyKey`, `region`, `retentionSeconds` |
|
|
76
89
|
|
|
77
|
-
|
|
90
|
+
The ViteHub framework preset selects Cloudflare for `preset: "cloudflare"` and Vercel for `preset: "vercel"`. With the standalone owner package, set `provider` explicitly when host inference would be ambiguous. Netlify cannot infer one. ViteHub provides no Queue Provider for local delivery, Deno, or self-hosted Node. Check the [runtime and host support matrix](https://vitehub.dev/docs/frameworks-hosts/support-matrix) before choosing a deployment target.
|
|
78
91
|
|
|
79
|
-
|
|
92
|
+
Cloudflare needs a concrete request-scoped binding at runtime. Its generated queue resources can be created through the ViteHub Cloudflare provision step when the required account credentials are present. Cloudflare rejects Vercel-only options such as `idempotencyKey`, `region`, and `retentionSeconds`.
|
|
80
93
|
|
|
81
|
-
|
|
94
|
+
Vercel needs a generated topic and the `@vercel/queue` runtime. It rejects Cloudflare's `contentType` option. The [Vercel host guide](https://vitehub.dev/docs/frameworks-hosts/vercel) explains the generated Build Output boundary.
|
|
95
|
+
|
|
96
|
+
## Treat acceptance and delivery separately
|
|
97
|
+
|
|
98
|
+
`runQueue()` waits for provider enqueue and returns this portable result:
|
|
82
99
|
|
|
83
100
|
```ts
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
101
|
+
type QueueSendResult = {
|
|
102
|
+
messageId?: string;
|
|
103
|
+
status: "queued";
|
|
104
|
+
};
|
|
87
105
|
```
|
|
88
106
|
|
|
89
|
-
|
|
107
|
+
The optional message ID is provider-specific. Vercel returns the ID from its enqueue response. Cloudflare returns the input's `id`, generating one locally when omitted; it does not send that ID to Cloudflare, and the later delivery has a different Cloudflare message ID. In both cases, `status: "queued"` is the portable acceptance signal. Queue handlers run later and return no value to the producer. Use a [Workflow](https://vitehub.dev/docs/server-primitives/workflows) when the caller needs a tracked run, durable steps, waits, or progress.
|
|
108
|
+
|
|
109
|
+
`deferQueue()` does not wait for provider acceptance. It schedules enqueue work through the current request's `waitUntil`, logs dispatch failures, and calls the Queue Definition's `onDispatchError` hook when present.
|
|
110
|
+
|
|
111
|
+
Providers can retry failed delivery, so handlers must tolerate another invocation after a partial side effect. ViteHub does not expose an exactly-once delivery guarantee. Vercel sends an idempotency key, using the generated message ID by default; pass a stable application key when repeated enqueue attempts should share one key. Cloudflare does not accept `idempotencyKey`, so protect non-repeatable side effects inside the handler.
|
|
112
|
+
|
|
113
|
+
On Cloudflare, successful handlers acknowledge the message. Failed handlers retry by default unless ViteHub identifies a non-retryable built-in error or `onError` returns an explicit acknowledge or retry action. On Vercel, `callbackOptions.retry` can return an explicit directive; returning nothing preserves provider behavior. Application error codes do not choose retry policy.
|
|
114
|
+
|
|
115
|
+
Queue operations use the shared `ViteHubError` contract. Public `code` and JSON-safe `details` may appear in delivery reports. Put credentials, provider responses, and private resource locations in `cause`; serialized errors and Queue reports omit it. See the [Queue error and retry reference](https://vitehub.dev/docs/server-primitives/queue#errors) for built-in codes and provider callbacks.
|
|
116
|
+
|
|
117
|
+
## Public imports
|
|
118
|
+
|
|
119
|
+
| Import | Purpose |
|
|
120
|
+
| -------------------------------- | ----------------------------------------------------------------------------------- |
|
|
121
|
+
| `@vite-hub/queue` | Queue Definitions, enqueue helpers, direct clients, host adapters, and public types |
|
|
122
|
+
| `@vite-hub/queue/vite` | Vite discovery and Cloudflare or Vercel Provider Output |
|
|
123
|
+
| `@vite-hub/queue/nuxt` | Nuxt module that composes Queue into Nitro |
|
|
124
|
+
| `@vite-hub/queue/runtime/hosted` | Advanced hosted Vercel callback adapter |
|
|
125
|
+
|
|
126
|
+
`@vite-hub/queue/internal/*` exists for generated framework integration. Application code should not import it.
|
|
127
|
+
|
|
128
|
+
## Go deeper
|
|
90
129
|
|
|
91
|
-
|
|
130
|
+
- [Queue guide](https://vitehub.dev/docs/server-primitives/queue)
|
|
131
|
+
- [Runtime and host support](https://vitehub.dev/docs/frameworks-hosts/support-matrix)
|
|
132
|
+
- [Definitions and discovery](https://vitehub.dev/docs/concepts/definitions-and-discovery)
|
|
133
|
+
- [Public import paths](https://vitehub.dev/docs/reference/import-paths)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as normalizeQueueOptions } from "./config-
|
|
1
|
+
import { t as normalizeQueueOptions } from "./config-CNgAeIND.js";
|
|
2
2
|
import { i as isQueueBoundaryIdentity, l as normalizeQueueEnqueueInput, n as createQueueError, o as normalizePublicQueueIdentifier, s as runQueueProviderOperation } from "./errors-CjuG_qr-.js";
|
|
3
3
|
import { t as getCloudflareQueueBindingName } from "./cloudflare-GosJefIK.js";
|
|
4
4
|
import { t as getVercelQueueTopicName } from "./vercel-C_4vqxcl.js";
|
|
5
|
-
import { a as getQueueRuntimeEvent, f as getCloudflareEnv, i as getQueueRuntimeConfig, n as getQueueClientCache, o as loadQueueDefinition, p as resolveWaitUntil, r as getQueueRuntimeClientFactory, s as runWithQueueRuntimeEvent } from "./state-
|
|
5
|
+
import { a as getQueueRuntimeEvent, f as getCloudflareEnv, i as getQueueRuntimeConfig, n as getQueueClientCache, o as loadQueueDefinition, p as resolveWaitUntil, r as getQueueRuntimeClientFactory, s as runWithQueueRuntimeEvent } from "./state-Cno9O7YS.js";
|
|
6
6
|
//#region src/runtime/client.ts
|
|
7
7
|
function createQueueDefinitionNotFoundError(name) {
|
|
8
8
|
const queue = normalizePublicQueueIdentifier(name);
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { t as normalizeQueueOptions } from "./config-
|
|
1
|
+
import { t as normalizeQueueOptions } from "./config-CNgAeIND.js";
|
|
2
2
|
import { n as getCloudflareQueueDefinitionName } from "./cloudflare-GosJefIK.js";
|
|
3
3
|
import { n as createCloudflareQueueBatchHandler, t as createCloudflareQueueRuntimeClient } from "./cloudflare-client-w5vphoNn.js";
|
|
4
4
|
import { t as getCloudflareQueueName } from "./cloudflare-resource-name-R8zYQiZb.js";
|
|
5
|
-
import { c as setQueueRuntimeConfig, d as createCloudflareRuntimeEvent, m as runWithActiveCloudflareEnv, o as loadQueueDefinition, s as runWithQueueRuntimeEvent, u as setQueueRuntimeRegistry } from "./state-
|
|
5
|
+
import { c as setQueueRuntimeConfig, d as createCloudflareRuntimeEvent, m as runWithActiveCloudflareEnv, o as loadQueueDefinition, s as runWithQueueRuntimeEvent, u as setQueueRuntimeRegistry } from "./state-Cno9O7YS.js";
|
|
6
6
|
import { t as resolveAppFetch } from "./app-BZpq2cwC.js";
|
|
7
|
-
import { H3, toWebHandler } from "h3/cloudflare";
|
|
8
7
|
//#region ../internal/src/runtime/cloudflare-hosted.ts
|
|
9
8
|
function createWebRequestHandler(appHandler) {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
return async (request, context) => await Promise.resolve(appHandler ? appHandler(request, context) : new Response(JSON.stringify({
|
|
10
|
+
status: 404,
|
|
11
|
+
message: `Cannot find any route matching [${request.method}] ${request.url}`
|
|
12
|
+
}), {
|
|
13
|
+
headers: { "content-type": "application/json;charset=UTF-8" },
|
|
14
|
+
status: 404,
|
|
15
|
+
statusText: "Not Found"
|
|
16
|
+
}));
|
|
12
17
|
}
|
|
13
18
|
function createCloudflareHostedWorker(adapter) {
|
|
14
19
|
const requestHandler = createWebRequestHandler(resolveAppFetch(adapter.label, adapter.app));
|
|
@@ -36,7 +41,7 @@ function createQueueJob(message, batch) {
|
|
|
36
41
|
};
|
|
37
42
|
}
|
|
38
43
|
//#endregion
|
|
39
|
-
//#region src/runtime/cloudflare-vite.ts
|
|
44
|
+
//#region src/internal/runtime/cloudflare-vite.ts
|
|
40
45
|
function createRegistryDefinitionNames(registry, namePrefix) {
|
|
41
46
|
if (!registry) return void 0;
|
|
42
47
|
const definitions = {};
|
|
@@ -7,7 +7,7 @@ interface CloudflareWorkerExecutionContext {
|
|
|
7
7
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
|
-
//#region src/runtime/cloudflare-vite.d.ts
|
|
10
|
+
//#region src/internal/runtime/cloudflare-vite.d.ts
|
|
11
11
|
type CloudflareWorkerApp = QueueApp;
|
|
12
12
|
interface QueueCloudflareWorkerOptions {
|
|
13
13
|
app?: CloudflareWorkerApp;
|
|
@@ -22,7 +22,13 @@ function getHostingProvider(hosting) {
|
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region ../internal/src/object.ts
|
|
24
24
|
function isPlainObject(value) {
|
|
25
|
-
|
|
25
|
+
if (value === null || Object(value) !== value || Array.isArray(value)) return false;
|
|
26
|
+
try {
|
|
27
|
+
Function.prototype.toString.call(value);
|
|
28
|
+
return false;
|
|
29
|
+
} catch {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
33
|
//#endregion
|
|
28
34
|
//#region src/config.ts
|
|
@@ -44,4 +50,4 @@ function normalizeQueueOptions(options, input = {}) {
|
|
|
44
50
|
return resolveProvider(options || {}, normalizeHosting(input.hosting));
|
|
45
51
|
}
|
|
46
52
|
//#endregion
|
|
47
|
-
export {
|
|
53
|
+
export { isPlainObject as n, getHostingProvider as r, normalizeQueueOptions as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { C as VercelQueueRetryHandler, S as VercelQueueRetryDirective, _ as QueueProviderOptions, a as DiscoveredQueueDefinition, b as VercelQueueCallbackOptions, c as QueueDefinitionOptions, d as QueueEnqueueOptions, f as QueueHandler, g as QueueProvider, h as QueueModuleProviderOptions, i as CloudflareQueueMessageBatch, l as QueueDefinitionRegistry, m as QueueModuleOptions, n as CloudflareQueueClient, o as QueueClient, p as QueueJob, r as CloudflareQueueMessage, s as QueueDefinition, t as CloudflareQueueBatchHandlerOptions, u as QueueEnqueueInput, v as QueueSendResult, w as VercelQueueSendResult, x as VercelQueueClient, y as ResolvedQueueOptions } from "./types-CwvoMATy.js";
|
|
2
|
-
import { i as createQueueCloudflareWorker } from "./cloudflare-vite-
|
|
2
|
+
import { i as createQueueCloudflareWorker } from "./cloudflare-vite-nFPor46-.js";
|
|
3
3
|
import { ViteHubError, ViteHubErrorDetails } from "@vite-hub/runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/config.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as normalizeQueueOptions } from "./config-
|
|
1
|
+
import { t as normalizeQueueOptions } from "./config-CNgAeIND.js";
|
|
2
2
|
import { c as createQueueMessageId } from "./errors-CjuG_qr-.js";
|
|
3
3
|
import { n as getCloudflareQueueDefinitionName, t as getCloudflareQueueBindingName } from "./cloudflare-GosJefIK.js";
|
|
4
4
|
import { n as createCloudflareQueueBatchHandler } from "./cloudflare-client-w5vphoNn.js";
|
|
5
5
|
import { t as getCloudflareQueueName } from "./cloudflare-resource-name-R8zYQiZb.js";
|
|
6
6
|
import { t as getVercelQueueTopicName } from "./vercel-C_4vqxcl.js";
|
|
7
|
-
import { n as getQueue, r as runQueue, t as deferQueue } from "./client-
|
|
8
|
-
import { t as createQueueCloudflareWorker } from "./cloudflare-vite-
|
|
7
|
+
import { n as getQueue, r as runQueue, t as deferQueue } from "./client-DG9fweET.js";
|
|
8
|
+
import { t as createQueueCloudflareWorker } from "./cloudflare-vite-BlQfDVZD.js";
|
|
9
9
|
//#region src/definition.ts
|
|
10
10
|
function defineQueue(handler, options) {
|
|
11
11
|
if (typeof handler !== "function") throw new TypeError("`defineQueue()` requires a queue handler.");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createQueueCloudflareWorker, n as QueueCloudflareWorker, r as QueueCloudflareWorkerOptions, t as CloudflareWorkerApp } from "
|
|
1
|
+
import { i as createQueueCloudflareWorker, n as QueueCloudflareWorker, r as QueueCloudflareWorkerOptions, t as CloudflareWorkerApp } from "../../cloudflare-vite-nFPor46-.js";
|
|
2
2
|
export { CloudflareWorkerApp, QueueCloudflareWorker, QueueCloudflareWorkerOptions, createQueueCloudflareWorker };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as QueueProviderOptions, l as QueueDefinitionRegistry, o as QueueClient, s as QueueDefinition, y as ResolvedQueueOptions } from "
|
|
1
|
+
import { _ as QueueProviderOptions, l as QueueDefinitionRegistry, o as QueueClient, s as QueueDefinition, y as ResolvedQueueOptions } from "../../types-CwvoMATy.js";
|
|
2
2
|
|
|
3
|
-
//#region src/runtime/state.d.ts
|
|
3
|
+
//#region src/internal/runtime/state.d.ts
|
|
4
4
|
type QueueRuntimeClientFactory = (options: QueueProviderOptions) => QueueClient | Promise<QueueClient>;
|
|
5
5
|
declare function setQueueRuntimeConfig(config: false | ResolvedQueueOptions | undefined, createClient?: QueueRuntimeClientFactory): void;
|
|
6
6
|
declare function getQueueRuntimeConfig(): false | ResolvedQueueOptions | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getQueueRuntimeEvent, c as setQueueRuntimeConfig, i as getQueueRuntimeConfig, l as setQueueRuntimeEventDefaults, n as getQueueClientCache, o as loadQueueDefinition, r as getQueueRuntimeClientFactory, s as runWithQueueRuntimeEvent, t as enterQueueRuntimeEvent, u as setQueueRuntimeRegistry } from "
|
|
1
|
+
import { a as getQueueRuntimeEvent, c as setQueueRuntimeConfig, i as getQueueRuntimeConfig, l as setQueueRuntimeEventDefaults, n as getQueueClientCache, o as loadQueueDefinition, r as getQueueRuntimeClientFactory, s as runWithQueueRuntimeEvent, t as enterQueueRuntimeEvent, u as setQueueRuntimeRegistry } from "../../state-Cno9O7YS.js";
|
|
2
2
|
export { enterQueueRuntimeEvent, getQueueClientCache, getQueueRuntimeClientFactory, getQueueRuntimeConfig, getQueueRuntimeEvent, loadQueueDefinition, runWithQueueRuntimeEvent, setQueueRuntimeConfig, setQueueRuntimeEventDefaults, setQueueRuntimeRegistry };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as isQueueBoundaryIdentity, l as normalizeQueueEnqueueInput, n as createQueueError, s as runQueueProviderOperation } from "../../errors-CjuG_qr-.js";
|
|
2
|
-
import { a as getQueueRuntimeEvent } from "../../state-
|
|
2
|
+
import { a as getQueueRuntimeEvent } from "../../state-Cno9O7YS.js";
|
|
3
3
|
//#region src/providers/vercel.ts
|
|
4
4
|
function readHeader(headers, name) {
|
|
5
5
|
if (!headers) return;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { l as QueueDefinitionRegistry, y as ResolvedQueueOptions } from "
|
|
2
|
-
import { t as QueueApp } from "
|
|
1
|
+
import { l as QueueDefinitionRegistry, y as ResolvedQueueOptions } from "../../types-CwvoMATy.js";
|
|
2
|
+
import { t as QueueApp } from "../../_app-D29AwUdD.js";
|
|
3
3
|
import { QueueRuntimeClientFactory } from "./state.js";
|
|
4
4
|
|
|
5
|
-
//#region src/runtime/vercel-vite.d.ts
|
|
5
|
+
//#region src/internal/runtime/vercel-vite.d.ts
|
|
6
6
|
interface QueueVercelServerBaseOptions {
|
|
7
7
|
app?: QueueApp;
|
|
8
8
|
registry?: QueueDefinitionRegistry;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as setQueueRuntimeConfig, s as runWithQueueRuntimeEvent, u as setQueueRuntimeRegistry } from "
|
|
2
|
-
import { t as resolveAppFetch } from "
|
|
1
|
+
import { c as setQueueRuntimeConfig, s as runWithQueueRuntimeEvent, u as setQueueRuntimeRegistry } from "../../state-Cno9O7YS.js";
|
|
2
|
+
import { t as resolveAppFetch } from "../../app-BZpq2cwC.js";
|
|
3
3
|
import { waitUntil } from "@vercel/functions";
|
|
4
4
|
import { H3 } from "h3";
|
|
5
5
|
//#region ../internal/src/runtime/vercel-hosted.ts
|
|
@@ -28,7 +28,7 @@ function createVercelHostedServer(adapter) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region src/runtime/vercel-vite.ts
|
|
31
|
+
//#region src/internal/runtime/vercel-vite.ts
|
|
32
32
|
function createQueueVercelServer(options) {
|
|
33
33
|
if (options.queue !== false && !options.createClient) throw new TypeError("[vitehub] Enabled Vercel Queue output requires its generated client factory.");
|
|
34
34
|
return createVercelHostedServer({
|
package/dist/nuxt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as hubQueue, t as createQueueNitroConfig } from "./vite-
|
|
1
|
+
import { n as hubQueue, t as createQueueNitroConfig } from "./vite-DOuoen0w.js";
|
|
2
2
|
//#region src/nuxt.ts
|
|
3
3
|
function isQueueVitePlugin(value) {
|
|
4
4
|
return Boolean(value && typeof value === "object" && value.name === "@vite-hub/queue/vite");
|
|
@@ -17,6 +17,7 @@ function viteHubQueueNuxtModule(options = {}, nuxt) {
|
|
|
17
17
|
nuxt.hook?.("nitro:config", async (nitroConfig) => {
|
|
18
18
|
const projectRoot = nuxt.options.rootDir || process.cwd();
|
|
19
19
|
const nitro = await createQueueNitroConfig(plugin, {
|
|
20
|
+
development: nuxt.options.dev,
|
|
20
21
|
nitro: nitroConfig,
|
|
21
22
|
projectRoot,
|
|
22
23
|
root: nuxt.options.srcDir || projectRoot,
|
package/dist/runtime/hosted.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { s as QueueDefinition } from "../types-CwvoMATy.js";
|
|
2
|
-
import { waitUntil } from "@vercel/functions";
|
|
3
2
|
|
|
4
3
|
//#region src/runtime/hosted.d.ts
|
|
5
|
-
declare const hostedVercelWaitUntil:
|
|
4
|
+
declare const hostedVercelWaitUntil: (promise: Promise<unknown>) => void | undefined;
|
|
6
5
|
declare function handleHostedVercelQueueCallback(event: {
|
|
7
6
|
method?: string;
|
|
8
7
|
request?: Request;
|
package/dist/runtime/hosted.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as createQueueError } from "../errors-CjuG_qr-.js";
|
|
2
2
|
import { n as reportQueueDeliveryError, t as isNonRetryableQueueError } from "../delivery-error-glgYWC9g.js";
|
|
3
|
-
import { n as getQueue } from "../client-
|
|
3
|
+
import { n as getQueue } from "../client-DG9fweET.js";
|
|
4
4
|
import { waitUntil } from "@vercel/functions";
|
|
5
5
|
import { getRequestHeaders, getRequestURL, readRawBody } from "h3";
|
|
6
6
|
//#region src/runtime/hosted.ts
|