@vite-hub/queue 0.4.1 → 0.5.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 +2 -2
- package/dist/{client-B53_G4ky.js → client-CwoCdKct.js} +9 -12
- package/dist/{cloudflare-GosJefIK.js → cloudflare-BMc35cBD.js} +2 -4
- package/dist/{cloudflare-client-CoISDpIx.js → cloudflare-client-xWteD-su.js} +7 -10
- package/dist/{cloudflare-resource-name-BIfBglC2.js → cloudflare-resource-name-Bv8Z7nDU.js} +3 -4
- package/dist/{config-B2eaXaT5.js → config-Bzp1xmdh.js} +4 -9
- package/dist/definition-CIiFfst2.js +26 -0
- package/dist/durability.d.ts +1 -3
- package/dist/durability.js +1 -2
- package/dist/{duration-tujyhAKt.js → duration-C5w_-Rf4.js} +14 -9
- package/dist/{error-diagnostics-mJXBjmQx.js → error-diagnostics-Dv6nKZQW.js} +9 -6
- package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
- package/dist/{handler-response-B6lz9nCn.js → handler-response-CchTXVjm.js} +10 -7
- package/dist/index.d.ts +1 -9
- package/dist/index.js +5 -24
- package/dist/{inspect-PeuckaC3.js → inspect-CwdWUhPj.js} +1 -2
- package/dist/internal/runtime/cloudflare-client.d.ts +2 -4
- package/dist/internal/runtime/cloudflare-client.js +1 -2
- package/dist/internal/runtime/cloudflare-vite.d.ts +2 -9
- package/dist/internal/runtime/cloudflare-vite.js +13 -16
- package/dist/internal/runtime/local-client.d.ts +4 -6
- package/dist/internal/runtime/local-client.js +5 -6
- package/dist/internal/runtime/postgres-client.d.ts +6 -8
- package/dist/internal/runtime/postgres-client.js +18 -13
- package/dist/internal/runtime/state.d.ts +3 -5
- package/dist/internal/runtime/state.js +1 -2
- package/dist/internal/runtime/vercel-client.d.ts +2 -4
- package/dist/internal/runtime/vercel-client.js +5 -8
- package/dist/internal/runtime/worker-client.d.ts +3 -5
- package/dist/internal/runtime/worker-client.js +2 -3
- package/dist/{invariant-D8_xBqmZ.js → invariant-CmdvZ3vp.js} +1 -2
- package/dist/{local-CUaWoRUx.d.ts → local-B72WRWkS.d.ts} +1 -3
- package/dist/{local-Di0FrVUw.js → local-RX10a_Sq.js} +26 -21
- package/dist/{object-D8pRdprI.js → object-DRSmpe04.js} +1 -2
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
- package/dist/{operations-BVV-9Q0N.js → operations-CoEXxfUW.js} +7 -14
- package/dist/operations.d.ts +3 -7
- package/dist/operations.js +10 -16
- package/dist/runtime/hosted.d.ts +2 -4
- package/dist/runtime/hosted.js +4 -5
- package/dist/scan-module-BaqBao0J.js +309 -0
- package/dist/{state-DLqTqF6V.js → state-DqxeV11k.js} +5 -8
- package/dist/{types-Dsbb_Pvp.d.ts → types-BevEYrUV.d.ts} +1 -4
- package/dist/{types-CiuSIPR0.d.ts → types-BzPGPV9z.d.ts} +8 -4
- package/dist/{vercel-region-B95MAMXN.js → vercel-region-DEsR1YJQ.js} +2 -3
- package/dist/{vercel-C_4vqxcl.js → vercel-sUJOxFBB.js} +2 -3
- package/dist/vite.d.ts +8 -30
- package/dist/vite.js +148 -139
- package/package.json +10 -10
package/dist/vite.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import { a as resolveHost, i as getHostingProvider, n as normalizeQueueOptions, o as resolveHostPreset, r as postgresQueueUrlVariable, t as defaultLocalQueueBase } from "./config-
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as getCloudflareQueueName } from "./cloudflare-resource-name-
|
|
1
|
+
import { t as invariant } from "./invariant-CmdvZ3vp.js";
|
|
2
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
|
|
3
|
+
import { n as isRecord, r as isRecordOrFunction, t as cloneRecord } from "./object-DRSmpe04.js";
|
|
4
|
+
import { a as resolveHost, i as getHostingProvider, n as normalizeQueueOptions, o as resolveHostPreset, r as postgresQueueUrlVariable, t as defaultLocalQueueBase } from "./config-Bzp1xmdh.js";
|
|
5
|
+
import { t as queueErrorDiagnostics } from "./error-diagnostics-Dv6nKZQW.js";
|
|
6
|
+
import { n as isQueueMaxBatchSize } from "./definition-CIiFfst2.js";
|
|
7
|
+
import { t as getCloudflareQueueBindingName } from "./cloudflare-BMc35cBD.js";
|
|
8
|
+
import { t as getVercelQueueTopicName } from "./vercel-sUJOxFBB.js";
|
|
9
|
+
import { t as getCloudflareQueueName } from "./cloudflare-resource-name-Bv8Z7nDU.js";
|
|
10
|
+
import { n as summarizeDefinitions } from "./inspect-CwdWUhPj.js";
|
|
10
11
|
import { createRequire } from "node:module";
|
|
11
|
-
import { existsSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
12
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
12
13
|
import { tmpdir } from "node:os";
|
|
13
14
|
import { basename, dirname, isAbsolute, parse, resolve } from "node:path";
|
|
14
15
|
import { fileURLToPath } from "node:url";
|
|
15
16
|
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
16
17
|
import { basename as basename$1, dirname as dirname$1, isAbsolute as isAbsolute$1, relative, resolve as resolve$1 } from "pathe";
|
|
17
|
-
|
|
18
|
+
// ../internal/src/build/vite.ts
|
|
18
19
|
const projectRootDirectoryMarkers = [
|
|
19
20
|
["server", "agents"],
|
|
20
21
|
["server", "channels"],
|
|
@@ -42,6 +43,7 @@ function createNoExternalAddition(...packageNames) {
|
|
|
42
43
|
function isServerEnvironment(name, config) {
|
|
43
44
|
return name === "ssr" || config.consumer === "server";
|
|
44
45
|
}
|
|
46
|
+
const VITEHUB_PROJECT_ROOT = "__vitehubProjectRoot";
|
|
45
47
|
/** The deployment host that `vitehub()` selected, such as `"cloudflare"`. */
|
|
46
48
|
const VITEHUB_DEPLOYMENT_HOST = "__vitehubDeploymentHost";
|
|
47
49
|
/**
|
|
@@ -98,7 +100,7 @@ function hasProjectRootDirectoryMarker(root) {
|
|
|
98
100
|
for (const marker of projectRootDirectoryMarkers) try {
|
|
99
101
|
if (statSync(resolve(root, ...marker)).isDirectory()) return true;
|
|
100
102
|
} catch (error) {
|
|
101
|
-
if (error
|
|
103
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
102
104
|
}
|
|
103
105
|
return false;
|
|
104
106
|
}
|
|
@@ -112,19 +114,21 @@ function hasProjectRootFileMarker(root, markers) {
|
|
|
112
114
|
try {
|
|
113
115
|
if (statSync(resolve(root, ...path)).isFile()) return true;
|
|
114
116
|
} catch (error) {
|
|
115
|
-
if (error
|
|
117
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
return false;
|
|
119
121
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
function isMissingProjectMarker(error) {
|
|
123
|
+
const code = error.code;
|
|
124
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
125
|
+
}
|
|
126
|
+
// ../internal/src/durability.ts
|
|
122
127
|
/** The `durability` module next to the Vite plugin module at `importMetaUrl`, in source and in `dist`. */
|
|
123
128
|
function durabilityModuleFile(importMetaUrl) {
|
|
124
129
|
return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
|
|
125
130
|
}
|
|
126
|
-
|
|
127
|
-
//#region ../internal/src/build/paths.ts
|
|
131
|
+
// ../internal/src/build/paths.ts
|
|
128
132
|
function generatedDirSegments(productName) {
|
|
129
133
|
return [".vitehub", productName];
|
|
130
134
|
}
|
|
@@ -174,8 +178,7 @@ function realpathIfExists(path) {
|
|
|
174
178
|
return resolve$1(path);
|
|
175
179
|
}
|
|
176
180
|
}
|
|
177
|
-
|
|
178
|
-
//#region ../internal/src/build/provider-output-config.ts
|
|
181
|
+
// ../internal/src/build/provider-output-config.ts
|
|
179
182
|
function isProviderJsonArray(value, ancestors) {
|
|
180
183
|
if (Object.getPrototypeOf(value) !== Array.prototype || ancestors.has(value)) return false;
|
|
181
184
|
if (Reflect.ownKeys(value).length !== value.length + 1) return false;
|
|
@@ -262,8 +265,7 @@ function mergeProviderOutputConfig(existing, value, ownership = {}) {
|
|
|
262
265
|
...mergeOwnedArrays(existing, value, ownership.arrays)
|
|
263
266
|
};
|
|
264
267
|
}
|
|
265
|
-
|
|
266
|
-
//#region ../internal/src/build/bundle-options.ts
|
|
268
|
+
// ../internal/src/build/bundle-options.ts
|
|
267
269
|
/** Select the runtime constants from one resolved Vite configuration. */
|
|
268
270
|
function resolveViteHubBundleDefines(config) {
|
|
269
271
|
const defines = {};
|
|
@@ -273,8 +275,7 @@ function resolveViteHubBundleDefines(config) {
|
|
|
273
275
|
}
|
|
274
276
|
return defines;
|
|
275
277
|
}
|
|
276
|
-
|
|
277
|
-
//#region ../internal/src/build/cloudflare-provider-output.ts
|
|
278
|
+
// ../internal/src/build/cloudflare-provider-output.ts
|
|
278
279
|
function isDeepStrictEqual(left, right) {
|
|
279
280
|
if (Object.is(left, right)) return true;
|
|
280
281
|
if (!left || !right || typeof left !== "object" || typeof right !== "object") return false;
|
|
@@ -297,7 +298,11 @@ function cloneProviderValue(value) {
|
|
|
297
298
|
if (value && typeof value === "object") return cloneProviderRecord(value);
|
|
298
299
|
return value;
|
|
299
300
|
}
|
|
300
|
-
|
|
301
|
+
/**
|
|
302
|
+
* The incoming entries that the app config does not have yet. An entry that the app already has must agree on
|
|
303
|
+
* `conflictKeys`, and on each of `setKeys` that the incoming entry sets, because the app's entry is the one that stays.
|
|
304
|
+
*/
|
|
305
|
+
function compatibleEntries(existing, incoming, identityKey, conflictKeys, owner, setKeys = []) {
|
|
301
306
|
const current = Array.isArray(existing) ? existing.map(cloneProviderRecord) : [];
|
|
302
307
|
return (incoming ?? []).filter((entry) => {
|
|
303
308
|
const identity = entry[identityKey];
|
|
@@ -307,6 +312,8 @@ function compatibleEntries(existing, incoming, identityKey, conflictKeys, owner)
|
|
|
307
312
|
return true;
|
|
308
313
|
}
|
|
309
314
|
if (conflictKeys.some((key) => !isDeepStrictEqual(match[key], entry[key]))) throw internalErrorDiagnostics.INTERNAL_B0001({ message: `[vitehub] Cloudflare ${identityKey} ${JSON.stringify(identity)} from ${owner} is already assigned to an incompatible resource.` });
|
|
315
|
+
const differentKey = setKeys.find((key) => entry[key] !== void 0 && !isDeepStrictEqual(match[key], entry[key]));
|
|
316
|
+
if (differentKey) throw internalErrorDiagnostics.INTERNAL_B0001({ message: `[vitehub] The Cloudflare ${identityKey} ${JSON.stringify(identity)} in the app's Wrangler config has ${differentKey} ${JSON.stringify(match[differentKey]) ?? "unset"}, but ${owner} sets ${JSON.stringify(entry[differentKey])}. Remove the entry from the Wrangler config, because ViteHub writes it, or give it the same value.` });
|
|
310
317
|
return false;
|
|
311
318
|
});
|
|
312
319
|
}
|
|
@@ -363,7 +370,7 @@ function mergeContribution(wrangler, owner, contribution) {
|
|
|
363
370
|
const queues = cloneProviderRecord(wrangler.queues);
|
|
364
371
|
const secrets = cloneProviderRecord(wrangler.secrets);
|
|
365
372
|
const environments = cloneProviderRecord(wrangler.env);
|
|
366
|
-
const consumers = compatibleEntries(queues.consumers, contribution.queues?.consumers, "queue", [], owner);
|
|
373
|
+
const consumers = compatibleEntries(queues.consumers, contribution.queues?.consumers, "queue", [], owner, ["max_batch_size"]);
|
|
367
374
|
const producers = compatibleEntries(queues.producers, contribution.queues?.producers, "binding", ["queue"], owner);
|
|
368
375
|
const r2Buckets = compatibleEntries(wrangler.r2_buckets, contribution.r2Buckets, "binding", ["bucket_name", "jurisdiction"], owner);
|
|
369
376
|
const rateLimits = compatibleEntries(wrangler.ratelimits, contribution.rateLimits, "name", ["namespace_id", "simple"], owner);
|
|
@@ -447,8 +454,7 @@ function composeNitroCloudflareProviderOutput(catalog, value, inheritedValue = v
|
|
|
447
454
|
associateProviderOutputCatalog(output, catalog);
|
|
448
455
|
return output;
|
|
449
456
|
}
|
|
450
|
-
|
|
451
|
-
//#region ../internal/src/build/provider-output-catalog.ts
|
|
457
|
+
// ../internal/src/build/provider-output-catalog.ts
|
|
452
458
|
var ProviderOutputCatalog = class {
|
|
453
459
|
bundleDefines = {};
|
|
454
460
|
#appliedCloudflareContributions = /* @__PURE__ */ new Map();
|
|
@@ -680,8 +686,8 @@ function contributeCloudflareProviderOutput(catalog, contribution) {
|
|
|
680
686
|
const { owner, ...value } = contribution;
|
|
681
687
|
catalog.replaceCloudflareContribution(owner, value);
|
|
682
688
|
}
|
|
683
|
-
|
|
684
|
-
|
|
689
|
+
Object.freeze({ vitehubAuthAccess: "handler" });
|
|
690
|
+
Object.freeze({ vitehubOwnAccess: true });
|
|
685
691
|
function cloneArray(value) {
|
|
686
692
|
return Array.isArray(value) ? [...value] : [];
|
|
687
693
|
}
|
|
@@ -717,8 +723,7 @@ function mergeNitroExternal(value, addition) {
|
|
|
717
723
|
if (typeof value === "function") return (source, importer, isResolved) => source === addition || Boolean(value(source, importer, isResolved));
|
|
718
724
|
return value;
|
|
719
725
|
}
|
|
720
|
-
|
|
721
|
-
//#region ../internal/src/contributions.ts
|
|
726
|
+
// ../internal/src/contributions.ts
|
|
722
727
|
const unnamedPlugin = "unnamed plugin";
|
|
723
728
|
function isNonEmptyString(value) {
|
|
724
729
|
return String(value) === value && value.length > 0;
|
|
@@ -756,6 +761,10 @@ async function collectContributions(plugins, options) {
|
|
|
756
761
|
const candidates = [];
|
|
757
762
|
await flattenPlugins(plugins ?? [], candidates, /* @__PURE__ */ new Set());
|
|
758
763
|
const collected = /* @__PURE__ */ new Map();
|
|
764
|
+
const context = {
|
|
765
|
+
...options.context,
|
|
766
|
+
plugins: candidates
|
|
767
|
+
};
|
|
759
768
|
for (const plugin of candidates) {
|
|
760
769
|
if (!Object.hasOwn(plugin, "vitehub")) continue;
|
|
761
770
|
const metadata = Reflect.get(plugin, "vitehub");
|
|
@@ -767,7 +776,7 @@ async function collectContributions(plugins, options) {
|
|
|
767
776
|
throw options.invalid(`[vitehub] Plugin ${JSON.stringify(contributor)} contributed an invalid ${options.kind}: ${reason}`);
|
|
768
777
|
};
|
|
769
778
|
const callable = typeof source === "function";
|
|
770
|
-
const entries = callable ? await Reflect.apply(source, void 0, [
|
|
779
|
+
const entries = callable ? await Reflect.apply(source, void 0, [context]) : source;
|
|
771
780
|
if (entries === void 0 && callable) continue;
|
|
772
781
|
if (!Array.isArray(entries)) fail(`\`vitehub.${options.key}\` must be an array or a function that returns one.`);
|
|
773
782
|
const list = entries;
|
|
@@ -819,8 +828,7 @@ function readContribution(entry, plugin, options, fail) {
|
|
|
819
828
|
...base
|
|
820
829
|
};
|
|
821
830
|
}
|
|
822
|
-
|
|
823
|
-
//#region src/contributions.ts
|
|
831
|
+
// src/contributions.ts
|
|
824
832
|
const queueNamePattern = /^[a-z0-9][a-z0-9._-]*(?:\/[a-z0-9][a-z0-9._-]*)*$/i;
|
|
825
833
|
function invalid(message) {
|
|
826
834
|
return queueErrorDiagnostics.QUEUE_CONTRIBUTION_INVALID({ message });
|
|
@@ -847,8 +855,7 @@ async function collectQueueContributions(plugins, context) {
|
|
|
847
855
|
}
|
|
848
856
|
return contributions;
|
|
849
857
|
}
|
|
850
|
-
|
|
851
|
-
//#region src/deployment-env.ts
|
|
858
|
+
// src/deployment-env.ts
|
|
852
859
|
const owners = ["queue"];
|
|
853
860
|
/**
|
|
854
861
|
* The variables that Queue reads on the deployed host. The `postgres` provider reads `QUEUE_POSTGRES_URL`, which is
|
|
@@ -873,8 +880,7 @@ function queueDeploymentEnv(queue) {
|
|
|
873
880
|
}];
|
|
874
881
|
return [];
|
|
875
882
|
}
|
|
876
|
-
|
|
877
|
-
//#region ../internal/src/definition-catalog.ts
|
|
883
|
+
// ../internal/src/definition-catalog.ts
|
|
878
884
|
const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
|
|
879
885
|
const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
|
|
880
886
|
const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
|
|
@@ -1024,8 +1030,7 @@ function createRuntimeRegistryContents(registryFile, definitions) {
|
|
|
1024
1030
|
""
|
|
1025
1031
|
].join("\n");
|
|
1026
1032
|
}
|
|
1027
|
-
|
|
1028
|
-
//#region src/discovery.ts
|
|
1033
|
+
// src/discovery.ts
|
|
1029
1034
|
const queueSuffixPattern = /\.queue\.(?:c|m)?[jt]s$/i;
|
|
1030
1035
|
/** Discovery source of Queue Definitions that Vite plugins contribute through `vitehub.queues`. */
|
|
1031
1036
|
const contributedQueueSource = "vite-plugin-contribution";
|
|
@@ -1052,11 +1057,10 @@ function mergeContributedQueueDefinitions(discovered, contributions) {
|
|
|
1052
1057
|
function discoverQueueDefinitions(options) {
|
|
1053
1058
|
if (options.mode === "server-queues") return mergeContributedQueueDefinitions(discoverDefinitions("queue", [createDirectoryDefinitionSource("server-queues", options.scanDirs, "queues")]), options.contributions);
|
|
1054
1059
|
const roots = resolveDefinitionScanRoots(options.rootDir, options.scanDirs);
|
|
1055
|
-
const serverScanDirs = options.serverDirs
|
|
1060
|
+
const serverScanDirs = [...new Set(options.serverDirs?.map((dir) => resolve$1(dir)) ?? (options.serverRootDirs ?? roots).map((root) => resolve$1(root, "server")))];
|
|
1056
1061
|
return mergeContributedQueueDefinitions(discoverDefinitions("queue", [createSuffixDefinitionSource("vite-suffix", roots, queueSuffixPattern, normalizeSuffixQueueName), createDirectoryDefinitionSource("server-queues", serverScanDirs, "queues")]), options.contributions);
|
|
1057
1062
|
}
|
|
1058
|
-
|
|
1059
|
-
//#region src/registry-types.ts
|
|
1063
|
+
// src/registry-types.ts
|
|
1060
1064
|
function createQueueTypes(file, definitions, importBase = "@vite-hub/queue") {
|
|
1061
1065
|
const entries = definitions.map((definition) => {
|
|
1062
1066
|
const path = relative(dirname$1(file), definition.handler);
|
|
@@ -1078,8 +1082,7 @@ async function writeQueueTypes(root, definitions, importBase = "@vite-hub/queue"
|
|
|
1078
1082
|
await mkdir(dirname$1(file), { recursive: true });
|
|
1079
1083
|
await writeFile(file, createQueueTypes(file, definitions, importBase), "utf8");
|
|
1080
1084
|
}
|
|
1081
|
-
|
|
1082
|
-
//#region src/internal/vite-build.ts
|
|
1085
|
+
// src/internal/vite-build.ts
|
|
1083
1086
|
const queuePackageName = "@vite-hub/queue";
|
|
1084
1087
|
const productName = "queue";
|
|
1085
1088
|
const generatedRegistryFileName = "registry.mjs";
|
|
@@ -1090,7 +1093,6 @@ const generatedQueueNitroVercelConsumerDir = ".vitehub/nitro/queue/vercel";
|
|
|
1090
1093
|
const vercelQueueConsumerRoutePrefix = "/api/vitehub/queues/vercel";
|
|
1091
1094
|
const packageDir = computePackageDir(import.meta.url);
|
|
1092
1095
|
const packageRequire = createRequire(resolve(packageDir, "package.json"));
|
|
1093
|
-
/** `@vercel/queue` and `@vercel/functions` are optional peers. A Vercel build needs both in the app. */
|
|
1094
1096
|
function resolveVercelDependency(specifier) {
|
|
1095
1097
|
try {
|
|
1096
1098
|
return packageRequire.resolve(specifier);
|
|
@@ -1106,11 +1108,6 @@ function resolveOutputQueueConfig(queue, hosting, postgresDatabase) {
|
|
|
1106
1108
|
postgresDatabase
|
|
1107
1109
|
}) || false;
|
|
1108
1110
|
}
|
|
1109
|
-
/**
|
|
1110
|
-
* The Queue configuration that the generated server installs. `vite dev` runs in Node, where Cloudflare and Vercel
|
|
1111
|
-
* cannot deliver jobs, so it runs them with the local driver and the delivery rules of the driver of the build.
|
|
1112
|
-
* A build keeps the configured driver.
|
|
1113
|
-
*/
|
|
1114
1111
|
function resolveRuntimeQueueConfig(queueConfig, development, rootDir) {
|
|
1115
1112
|
if (!development || queueConfig === false) return queueConfig;
|
|
1116
1113
|
if (queueConfig.driver === "local") return {
|
|
@@ -1139,11 +1136,42 @@ function createCloudflareQueueDefinitionNames(definitions, namePrefix = "") {
|
|
|
1139
1136
|
}
|
|
1140
1137
|
return Object.fromEntries([...names].map(([physicalName, definition]) => [physicalName, definition.name]));
|
|
1141
1138
|
}
|
|
1142
|
-
|
|
1139
|
+
/**
|
|
1140
|
+
* Reads `maxBatchSize` from `export default defineQueue({ ... })`. The Cloudflare consumer is configured at build time,
|
|
1141
|
+
* so the build fails when it cannot prove the value: a spread or computed key in those options, a value that is not a
|
|
1142
|
+
* number literal, or the option on a `defineQueue()` call that is not the default export.
|
|
1143
|
+
*/
|
|
1144
|
+
function readQueueMaxBatchSize(file, { argumentExpression, defaultExportExpression, findCalls, objectProperties, scanModule }) {
|
|
1145
|
+
const module = scanModule(readFileSync(file, "utf8"), file);
|
|
1146
|
+
const invalid = () => {
|
|
1147
|
+
throw queueErrorDiagnostics.QUEUE_MAX_BATCH_SIZE_INVALID({ where: file });
|
|
1148
|
+
};
|
|
1149
|
+
const exported = defaultExportExpression(module);
|
|
1150
|
+
let maxBatchSize;
|
|
1151
|
+
for (const call of findCalls(module, ["defineQueue"])) {
|
|
1152
|
+
const options = argumentExpression(call.arguments[0]);
|
|
1153
|
+
if (options?.type !== "ObjectExpression") return invalid();
|
|
1154
|
+
const properties = objectProperties(options);
|
|
1155
|
+
if (properties.some((property) => property.key === void 0 || property.computed)) return invalid();
|
|
1156
|
+
const property = properties.findLast((candidate) => candidate.key === "maxBatchSize");
|
|
1157
|
+
if (!property) continue;
|
|
1158
|
+
if (call !== exported || property.node.type !== "Property" || property.node.kind !== "init" || property.node.method || property.value?.type !== "Literal" || !isQueueMaxBatchSize(property.value.value)) return invalid();
|
|
1159
|
+
maxBatchSize = property.value.value;
|
|
1160
|
+
}
|
|
1161
|
+
return maxBatchSize;
|
|
1162
|
+
}
|
|
1163
|
+
async function createCloudflareQueueBindings(definitions, namePrefix = "") {
|
|
1143
1164
|
if (!definitions.length) return;
|
|
1144
|
-
|
|
1165
|
+
createCloudflareQueueDefinitionNames(definitions, namePrefix);
|
|
1166
|
+
const scanner = await import("./scan-module-BaqBao0J.js");
|
|
1145
1167
|
return {
|
|
1146
|
-
consumers:
|
|
1168
|
+
consumers: definitions.map((definition) => {
|
|
1169
|
+
const maxBatchSize = readQueueMaxBatchSize(definition.handler, scanner);
|
|
1170
|
+
return {
|
|
1171
|
+
...maxBatchSize === void 0 ? {} : { max_batch_size: maxBatchSize },
|
|
1172
|
+
queue: getCloudflareQueueName(definition.name, namePrefix)
|
|
1173
|
+
};
|
|
1174
|
+
}),
|
|
1147
1175
|
producers: definitions.map((definition) => ({
|
|
1148
1176
|
binding: getCloudflareQueueBindingName(definition.name),
|
|
1149
1177
|
queue: getCloudflareQueueName(definition.name, namePrefix)
|
|
@@ -1295,15 +1323,9 @@ function renderVercelQueueConsumerHandler(file, name) {
|
|
|
1295
1323
|
""
|
|
1296
1324
|
].join("\n");
|
|
1297
1325
|
}
|
|
1298
|
-
|
|
1299
|
-
//#region src/inspect.ts
|
|
1326
|
+
// src/inspect.ts
|
|
1300
1327
|
/** Summarizes discovered Queue Definitions for the CLI and Console. */
|
|
1301
|
-
function inspectQueueDefinitions(options) {
|
|
1302
|
-
const definitions = discoverQueueDefinitions({
|
|
1303
|
-
contributions: options.contributions,
|
|
1304
|
-
rootDir: options.rootDir,
|
|
1305
|
-
serverDirs: options.serverDirs
|
|
1306
|
-
});
|
|
1328
|
+
function inspectQueueDefinitions(options, definitions = discoverQueueDefinitions(options)) {
|
|
1307
1329
|
return summarizeDefinitions(options.projectRoot, definitions, "queue").map((summary, index) => {
|
|
1308
1330
|
const { contributor, reason } = definitions[index];
|
|
1309
1331
|
if (!contributor) return summary;
|
|
@@ -1320,12 +1342,8 @@ function inspectQueueDefinitions(options) {
|
|
|
1320
1342
|
});
|
|
1321
1343
|
}
|
|
1322
1344
|
/** Lists the Cloudflare Queues that Queue Definitions bind by name. Reads local files only. */
|
|
1323
|
-
function inspectQueueResources(options) {
|
|
1324
|
-
return
|
|
1325
|
-
contributions: options.contributions,
|
|
1326
|
-
rootDir: options.rootDir,
|
|
1327
|
-
serverDirs: options.serverDirs
|
|
1328
|
-
}).map((definition) => ({
|
|
1345
|
+
function inspectQueueResources(options, definitions = discoverQueueDefinitions(options)) {
|
|
1346
|
+
return definitions.map((definition) => ({
|
|
1329
1347
|
binding: options.binding ?? getCloudflareQueueBindingName(definition.name),
|
|
1330
1348
|
definition: definition.name,
|
|
1331
1349
|
host: "cloudflare",
|
|
@@ -1347,8 +1365,7 @@ const queueConsoleSection = {
|
|
|
1347
1365
|
notice: "Cloudflare and Vercel do not expose Queue backlog or delivery history through ViteHub. The local provider reports its job directory and job counts in `vitehub queue list`."
|
|
1348
1366
|
}
|
|
1349
1367
|
};
|
|
1350
|
-
|
|
1351
|
-
//#region ../internal/src/host-credentials.ts
|
|
1368
|
+
// ../internal/src/host-credentials.ts
|
|
1352
1369
|
/** Reads host credentials from environment variables only. Returns undefined when the token is not set. */
|
|
1353
1370
|
function readHostCredentialsFromEnv(host, env) {
|
|
1354
1371
|
switch (host) {
|
|
@@ -1382,8 +1399,7 @@ function trimmed(value) {
|
|
|
1382
1399
|
const result = value?.trim();
|
|
1383
1400
|
return result ? result : void 0;
|
|
1384
1401
|
}
|
|
1385
|
-
|
|
1386
|
-
//#region ../internal/src/provider-failure.ts
|
|
1402
|
+
// ../internal/src/provider-failure.ts
|
|
1387
1403
|
const cloudflareCodes = {
|
|
1388
1404
|
d1: {},
|
|
1389
1405
|
kv: { 10014: "conflict" },
|
|
@@ -1485,8 +1501,7 @@ function readProviderErrorCodes(body) {
|
|
|
1485
1501
|
const errors = Reflect.get(body, "errors");
|
|
1486
1502
|
return [error && typeof error === "object" ? Reflect.get(error, "code") : void 0, ...Array.isArray(errors) ? errors.map((entry) => entry && typeof entry === "object" ? Reflect.get(entry, "code") : void 0) : []].filter((code) => typeof code === "number" && Number.isFinite(code) || typeof code === "string" && /^[\w.-]{1,128}$/.test(code));
|
|
1487
1503
|
}
|
|
1488
|
-
|
|
1489
|
-
//#region ../internal/src/provision.ts
|
|
1504
|
+
// ../internal/src/provision.ts
|
|
1490
1505
|
/**
|
|
1491
1506
|
* Whether a value from Provision State can appear in a copyable shell command as is.
|
|
1492
1507
|
* The file is editable, so a hint shows a command only for plain names and ids.
|
|
@@ -1604,24 +1619,19 @@ async function listCloudflarePages(request, path, options) {
|
|
|
1604
1619
|
} else if (options.perPage === void 0 || pageItems.length < options.perPage) return items;
|
|
1605
1620
|
}
|
|
1606
1621
|
}
|
|
1607
|
-
|
|
1608
|
-
//#region src/provision.ts
|
|
1609
|
-
/** Provision State category for Cloudflare Queue names, keyed by Queue Definition name. Config never reads it, because Queue names come from Definitions. */
|
|
1622
|
+
// src/provision.ts
|
|
1610
1623
|
const QUEUE_CLOUDFLARE_PROVISION_CATEGORY = "queue";
|
|
1611
1624
|
function parseQueues(value) {
|
|
1612
1625
|
if (!Array.isArray(value) || Array.from(value).some((queue, index) => !(index in value) || queue === null || typeof queue !== "object" || Array.isArray(queue))) throw queueErrorDiagnostics.QUEUE_PROVISION_FAILED();
|
|
1613
1626
|
return value;
|
|
1614
1627
|
}
|
|
1615
|
-
function createQueueProvisionStep(
|
|
1628
|
+
function createQueueProvisionStep(resolveDefinitions, resolveNamePrefix = () => void 0) {
|
|
1616
1629
|
return {
|
|
1617
1630
|
id: "queue:cloudflare-queues",
|
|
1618
1631
|
provider: "cloudflare",
|
|
1619
1632
|
recordedState() {
|
|
1620
1633
|
const namePrefix = resolveNamePrefix();
|
|
1621
|
-
const queues = new Map(
|
|
1622
|
-
contributions: resolveContributions(),
|
|
1623
|
-
rootDir: resolveRootDir()
|
|
1624
|
-
}).map((definition) => [definition.name, getCloudflareQueueName(definition.name, namePrefix)]));
|
|
1634
|
+
const queues = new Map(resolveDefinitions().map((definition) => [definition.name, getCloudflareQueueName(definition.name, namePrefix)]));
|
|
1625
1635
|
return [{
|
|
1626
1636
|
category: QUEUE_CLOUDFLARE_PROVISION_CATEGORY,
|
|
1627
1637
|
declared: [...queues.keys()],
|
|
@@ -1638,10 +1648,7 @@ function createQueueProvisionStep(resolveRootDir, resolveNamePrefix = () => void
|
|
|
1638
1648
|
}
|
|
1639
1649
|
const request = createCloudflareProvisionClient(config, context.fetch);
|
|
1640
1650
|
const namePrefix = resolveNamePrefix();
|
|
1641
|
-
const queues =
|
|
1642
|
-
contributions: resolveContributions(),
|
|
1643
|
-
rootDir: resolveRootDir()
|
|
1644
|
-
}).map((definition) => ({
|
|
1651
|
+
const queues = resolveDefinitions().map((definition) => ({
|
|
1645
1652
|
definition: definition.name,
|
|
1646
1653
|
name: getCloudflareQueueName(definition.name, namePrefix)
|
|
1647
1654
|
}));
|
|
@@ -1663,8 +1670,7 @@ function createQueueProvisionStep(resolveRootDir, resolveNamePrefix = () => void
|
|
|
1663
1670
|
}
|
|
1664
1671
|
};
|
|
1665
1672
|
}
|
|
1666
|
-
|
|
1667
|
-
//#region src/vite.ts
|
|
1673
|
+
// src/vite.ts
|
|
1668
1674
|
const operationsModule = ownModule(import.meta.url, "operations");
|
|
1669
1675
|
const mergeNoExternal = createNoExternalAddition(queuePackageName);
|
|
1670
1676
|
const databaseVitePluginName = "@vite-hub/database/vite";
|
|
@@ -1674,10 +1680,6 @@ function findDatabasePlugin(plugins) {
|
|
|
1674
1680
|
if (found) return found;
|
|
1675
1681
|
} else if (plugin && typeof plugin === "object" && "name" in plugin && plugin.name === databaseVitePluginName) return plugin;
|
|
1676
1682
|
}
|
|
1677
|
-
/**
|
|
1678
|
-
* Whether the Database integration resolved the Default Database on Postgres, with its layers, contributions, and
|
|
1679
|
-
* server directories. A Node server then infers the postgres provider on the connection of that Database.
|
|
1680
|
-
*/
|
|
1681
1683
|
function hasPostgresDefaultDatabase(plugin) {
|
|
1682
1684
|
return plugin?.api?.getConfig?.()?.databases.default?.dialect === "postgresql";
|
|
1683
1685
|
}
|
|
@@ -1699,10 +1701,10 @@ function normalizeQueueForHosting(queue, hosting) {
|
|
|
1699
1701
|
}
|
|
1700
1702
|
return normalizeQueueOptions(queue, { hosting });
|
|
1701
1703
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1704
|
+
function frameworkProjectRoot(config) {
|
|
1705
|
+
const configured = Reflect.get(config, VITEHUB_PROJECT_ROOT);
|
|
1706
|
+
return typeof configured === "string" && configured ? resolve$1(configured) : void 0;
|
|
1707
|
+
}
|
|
1706
1708
|
function resolveQueueHost(config, nitro) {
|
|
1707
1709
|
return resolveHost({
|
|
1708
1710
|
nitro,
|
|
@@ -1727,7 +1729,6 @@ function isGeneratedNitroRegistration(value, generatedPath) {
|
|
|
1727
1729
|
function isGeneratedVercelConsumer(value) {
|
|
1728
1730
|
return typeof value === "string" && value.replaceAll("\\", "/").includes(`.vitehub/nitro/queue/vercel/`);
|
|
1729
1731
|
}
|
|
1730
|
-
/** Vercel delivers Queue messages to Nitro routes that have a queue trigger in `vercel.functionRules`. */
|
|
1731
1732
|
function hostsVercelQueueConsumers(nitro) {
|
|
1732
1733
|
const hosting = getHostingProvider(resolveHost({ nitro }));
|
|
1733
1734
|
return hosting === "vercel" || hosting === void 0 && Boolean(process.env.VERCEL);
|
|
@@ -1754,7 +1755,7 @@ function addVercelQueueConsumers(kit, definitions, root) {
|
|
|
1754
1755
|
functionRules
|
|
1755
1756
|
};
|
|
1756
1757
|
}
|
|
1757
|
-
function mergeNitroConfig(config, value, queue, root, definitions) {
|
|
1758
|
+
async function mergeNitroConfig(config, value, queue, root, definitions) {
|
|
1758
1759
|
const providerOutput = useProviderOutputCatalog(config);
|
|
1759
1760
|
const nitro = cloneRecord(value);
|
|
1760
1761
|
const nitroHosting = getHostingProvider(resolveHost({ nitro }));
|
|
@@ -1790,7 +1791,7 @@ function mergeNitroConfig(config, value, queue, root, definitions) {
|
|
|
1790
1791
|
const cloudflareQueues = supportsCloudflareQueues(nitro);
|
|
1791
1792
|
const rollupConfig = cloneRecord(nitro.rollupConfig);
|
|
1792
1793
|
const resolvedQueue = normalizeQueueOptions(queue, { hosting: queueHosting });
|
|
1793
|
-
const generated = createCloudflareQueueBindings(definitions, resolvedQueue?.driver === "cloudflare" ? resolvedQueue.namePrefix : void 0);
|
|
1794
|
+
const generated = await createCloudflareQueueBindings(definitions, resolvedQueue?.driver === "cloudflare" ? resolvedQueue.namePrefix : void 0);
|
|
1794
1795
|
const baseNitro = {
|
|
1795
1796
|
...nitro,
|
|
1796
1797
|
...cloudflareQueues ? { rollupConfig: {
|
|
@@ -1854,6 +1855,22 @@ function hubQueue(options, internalOptions = {}) {
|
|
|
1854
1855
|
serverDirs: dirs
|
|
1855
1856
|
});
|
|
1856
1857
|
}
|
|
1858
|
+
function discoverViteQueueDefinitions(viteRoot, outputRoot, found) {
|
|
1859
|
+
return resolve$1(viteRoot) === outputRoot ? discoverQueueDefinitions({
|
|
1860
|
+
contributions: found,
|
|
1861
|
+
rootDir: viteRoot
|
|
1862
|
+
}) : discoverQueueDefinitions({
|
|
1863
|
+
contributions: found,
|
|
1864
|
+
rootDir: outputRoot,
|
|
1865
|
+
serverDirs
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
function discoverCurrentQueueDefinitions() {
|
|
1869
|
+
return resolveNuxtDefinitions?.() ?? (resolved && buildStates.get(resolved)?.resolveDefinitions()) ?? discoverQueueDefinitions({
|
|
1870
|
+
contributions,
|
|
1871
|
+
rootDir: resolved?.root ?? process.cwd()
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1857
1874
|
let databasePlugin;
|
|
1858
1875
|
let postgresDatabase = false;
|
|
1859
1876
|
const database = () => ({
|
|
@@ -1904,34 +1921,31 @@ function hubQueue(options, internalOptions = {}) {
|
|
|
1904
1921
|
const resolvedQueue = normalizeQueueOptions(queue, { hosting });
|
|
1905
1922
|
if (!resolvedQueue?.driver) return;
|
|
1906
1923
|
const rootDir = resolved?.root ?? process.cwd();
|
|
1924
|
+
const projectRoot = nuxtProjectRoot ?? (resolved && frameworkProjectRoot(resolved)) ?? resolveViteHubProjectRoot(rootDir);
|
|
1907
1925
|
return {
|
|
1908
1926
|
definitions: [{
|
|
1909
1927
|
kind: "queue",
|
|
1910
1928
|
label: "Queues",
|
|
1911
1929
|
list: () => inspectQueueDefinitions({
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
serverDirs
|
|
1916
|
-
})
|
|
1930
|
+
projectRoot,
|
|
1931
|
+
rootDir
|
|
1932
|
+
}, discoverCurrentQueueDefinitions())
|
|
1917
1933
|
}],
|
|
1918
1934
|
resources: () => resolvedQueue.driver === "cloudflare" ? inspectQueueResources({
|
|
1919
1935
|
binding: resolvedQueue.binding,
|
|
1920
|
-
contributions,
|
|
1921
1936
|
namePrefix: resolvedQueue.namePrefix,
|
|
1922
|
-
projectRoot
|
|
1923
|
-
rootDir
|
|
1924
|
-
|
|
1925
|
-
}) : []
|
|
1937
|
+
projectRoot,
|
|
1938
|
+
rootDir
|
|
1939
|
+
}, discoverCurrentQueueDefinitions()) : []
|
|
1926
1940
|
};
|
|
1927
1941
|
},
|
|
1928
1942
|
cli: async () => {
|
|
1929
1943
|
return {
|
|
1930
1944
|
namespaces: [],
|
|
1931
|
-
provision: [createQueueProvisionStep(
|
|
1945
|
+
provision: [createQueueProvisionStep(discoverCurrentQueueDefinitions, () => {
|
|
1932
1946
|
const resolvedQueue = normalizeQueueOptions(queue, { hosting: "cloudflare" });
|
|
1933
1947
|
return resolvedQueue?.driver === "cloudflare" ? resolvedQueue.namePrefix : void 0;
|
|
1934
|
-
}
|
|
1948
|
+
})]
|
|
1935
1949
|
};
|
|
1936
1950
|
},
|
|
1937
1951
|
queue: { async createNitroConfig({ development = false, nitro, projectRoot, root, serverDirs, viteConfig }) {
|
|
@@ -1954,7 +1968,7 @@ function hubQueue(options, internalOptions = {}) {
|
|
|
1954
1968
|
});
|
|
1955
1969
|
const definitions = resolveNuxtDefinitions();
|
|
1956
1970
|
nuxtConfiguredDefinitions = definitions;
|
|
1957
|
-
const configuredNitro = mergeNitroConfig(config, nitro, projectQueue, projectRoot, definitions);
|
|
1971
|
+
const configuredNitro = await mergeNitroConfig(config, nitro, projectQueue, projectRoot, definitions);
|
|
1958
1972
|
databasePlugin = findDatabasePlugin(viteConfig?.plugins) ?? databasePlugin;
|
|
1959
1973
|
const host = resolveQueueHost(config, configuredNitro);
|
|
1960
1974
|
postgresDatabase = host === "node" && hasPostgresDefaultDatabase(databasePlugin);
|
|
@@ -1982,30 +1996,30 @@ function hubQueue(options, internalOptions = {}) {
|
|
|
1982
1996
|
queueOptions.set(resolve$1(config.root || process.cwd()), queue);
|
|
1983
1997
|
serverDirs = config["__vitehubServerDirs"] ?? serverDirs;
|
|
1984
1998
|
const root = config.root || process.cwd();
|
|
1985
|
-
|
|
1999
|
+
const configuredRoot = frameworkProjectRoot(config);
|
|
2000
|
+
const outputRoot = configuredRoot ?? resolve$1(root);
|
|
2001
|
+
contributions = await collectPluginQueueContributions(config.plugins, root, configuredRoot);
|
|
1986
2002
|
const nitro = config.nitro;
|
|
1987
|
-
config.nitro = mergeNitroConfig(config, nitro, queue, root,
|
|
1988
|
-
|
|
1989
|
-
rootDir: root
|
|
1990
|
-
}));
|
|
1991
|
-
if (process.env.VITEST) return { test: { setupFiles: [resolve$1(root, generatedQueueTestSetup)] } };
|
|
2003
|
+
config.nitro = await mergeNitroConfig(config, nitro, queue, outputRoot, discoverViteQueueDefinitions(root, outputRoot, contributions));
|
|
2004
|
+
if (process.env.VITEST) return { test: { setupFiles: [resolve$1(outputRoot, generatedQueueTestSetup)] } };
|
|
1992
2005
|
},
|
|
1993
2006
|
async configResolved(config) {
|
|
1994
2007
|
resolved = config;
|
|
1995
|
-
|
|
1996
|
-
const nuxtState = nuxtStates.get(config.root);
|
|
2008
|
+
const configuredRoot = frameworkProjectRoot(config);
|
|
2009
|
+
const nuxtState = nuxtStates.get(config.root) ?? (configuredRoot ? nuxtStates.get(configuredRoot) : void 0);
|
|
1997
2010
|
nuxtConfiguredDefinitions = nuxtState?.nuxtConfiguredDefinitions;
|
|
1998
2011
|
nuxtProjectRoot = nuxtState?.nuxtProjectRoot;
|
|
1999
2012
|
resolveNuxtDefinitions = nuxtState?.resolveNuxtDefinitions;
|
|
2013
|
+
const outputRoot = nuxtProjectRoot ?? configuredRoot ?? resolve$1(config.root);
|
|
2014
|
+
for (const root of /* @__PURE__ */ new Set([config.root, outputRoot])) resolvedConfigs.set(root, config);
|
|
2000
2015
|
queue = getResolvedFeatureOptions(config, "queue") ?? options;
|
|
2001
|
-
queueOptions.set(
|
|
2016
|
+
for (const root of /* @__PURE__ */ new Set([config.root, outputRoot])) queueOptions.set(root, queue);
|
|
2002
2017
|
const configuredNitro = config.nitro;
|
|
2003
|
-
contributions = await collectPluginQueueContributions(config.plugins, config.root);
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
const nitro = mergeNitroConfig(config, configuredNitro, queue, config.root, configuredDefinitions);
|
|
2018
|
+
contributions = await collectPluginQueueContributions(config.plugins, config.root, nuxtProjectRoot ?? configuredRoot);
|
|
2019
|
+
const resolveContributions = contributions;
|
|
2020
|
+
const resolveDefinitions = resolveNuxtDefinitions ?? (() => discoverViteQueueDefinitions(config.root, outputRoot, resolveContributions));
|
|
2021
|
+
configuredDefinitions = resolveDefinitions();
|
|
2022
|
+
const nitro = await mergeNitroConfig(config, configuredNitro, queue, outputRoot, configuredDefinitions);
|
|
2009
2023
|
config.nitro = nitro;
|
|
2010
2024
|
databasePlugin = findDatabasePlugin(config.plugins) ?? databasePlugin;
|
|
2011
2025
|
const host = resolveQueueHost(config, nitro);
|
|
@@ -2017,13 +2031,14 @@ function hubQueue(options, internalOptions = {}) {
|
|
|
2017
2031
|
nitroQueue = resolvedQueue?.driver && nitroHosting && resolvedQueue.driver !== nitroHosting ? false : queue;
|
|
2018
2032
|
validatesNitroDefinitions = hasNitroConfigContext(config) && nitroQueue !== false;
|
|
2019
2033
|
localDevelopment = config.command === "serve" && !preview;
|
|
2020
|
-
writtenQueue = await writeQueueNitroIntegration(
|
|
2021
|
-
recordNodeWrite(
|
|
2034
|
+
writtenQueue = await writeQueueNitroIntegration(outputRoot, nitroQueue, hosting, cloudflareQueues, configuredDefinitions, localDevelopment, internalOptions.importBase, database());
|
|
2035
|
+
recordNodeWrite(outputRoot, queue, host, configuredDefinitions);
|
|
2022
2036
|
buildStates.set(config, {
|
|
2023
2037
|
configuredDefinitions,
|
|
2024
2038
|
contributions,
|
|
2025
2039
|
nuxtConfiguredDefinitions,
|
|
2026
2040
|
queue,
|
|
2041
|
+
resolveDefinitions,
|
|
2027
2042
|
resolveNuxtDefinitions,
|
|
2028
2043
|
resolved: config,
|
|
2029
2044
|
validatesNitroDefinitions
|
|
@@ -2038,11 +2053,9 @@ function hubQueue(options, internalOptions = {}) {
|
|
|
2038
2053
|
const isDirectoryDefinition = /\.(?:c|m)?[jt]s$/i.test(file) && (/\/server\/queues\//.test(file) || nuxtServerQueueDirs.some((dir) => file.startsWith(dir)));
|
|
2039
2054
|
if (!/\.queue\.(?:c|m)?[jt]s$/i.test(file) && !isDirectoryDefinition) return;
|
|
2040
2055
|
resolved = context.server.config;
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
});
|
|
2045
|
-
writtenQueue = await writeQueueNitroIntegration(nuxtProjectRoot || resolved.root, nitroQueue, hosting, cloudflareQueues, definitions, localDevelopment, internalOptions.importBase, database());
|
|
2056
|
+
const outputRoot = nuxtProjectRoot || frameworkProjectRoot(resolved) || resolve$1(resolved.root);
|
|
2057
|
+
const definitions = resolveNuxtDefinitions?.() ?? discoverViteQueueDefinitions(resolved.root, outputRoot, contributions);
|
|
2058
|
+
writtenQueue = await writeQueueNitroIntegration(outputRoot, nitroQueue, hosting, cloudflareQueues, definitions, localDevelopment, internalOptions.importBase, database());
|
|
2046
2059
|
},
|
|
2047
2060
|
async buildStart() {
|
|
2048
2061
|
const databaseConfig = databasePlugin?.api?.getConfig?.();
|
|
@@ -2060,12 +2073,8 @@ function hubQueue(options, internalOptions = {}) {
|
|
|
2060
2073
|
const state = config ? buildStates.get(config) : void 0;
|
|
2061
2074
|
if (error || !state || shouldSkipViteProviderBuild(state.resolved.command)) return;
|
|
2062
2075
|
if (state.resolveNuxtDefinitions && state.nuxtConfiguredDefinitions) resolveStableQueueDefinitions(state.resolveNuxtDefinitions, state.nuxtConfiguredDefinitions, "Nuxt");
|
|
2063
|
-
else if (state.validatesNitroDefinitions) resolveStableQueueDefinitions(
|
|
2064
|
-
contributions: state.contributions,
|
|
2065
|
-
rootDir: state.resolved.root
|
|
2066
|
-
}), state.configuredDefinitions, "Nitro");
|
|
2076
|
+
else if (state.validatesNitroDefinitions) resolveStableQueueDefinitions(state.resolveDefinitions, state.configuredDefinitions, "Nitro");
|
|
2067
2077
|
}
|
|
2068
2078
|
};
|
|
2069
2079
|
}
|
|
2070
|
-
//#endregion
|
|
2071
2080
|
export { collectQueueContributions, contributedQueueSource, createQueueNitroConfig, discoverQueueDefinitions, hubQueue, inspectQueueDefinitions, queueConsoleSection };
|