@vercel/build-utils 14.17.0 → 14.19.0
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/CHANGELOG.md +19 -0
- package/DEV_MANIFEST.md +1 -1
- package/dist/fs/run-user-scripts.d.ts +19 -1
- package/dist/fs/run-user-scripts.js +112 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +15 -15
- package/dist/schedules.d.ts +15 -24
- package/dist/schedules.js +16 -119
- package/dist/static-files/bundle.d.ts +11 -0
- package/dist/static-files/bundle.js +67 -0
- package/dist/static-files/index.d.ts +11 -0
- package/dist/static-files/index.js +49 -0
- package/dist/static-files/promote.d.ts +19 -0
- package/dist/static-files/promote.js +90 -0
- package/dist/static-files/routes.d.ts +60 -0
- package/dist/static-files/routes.js +205 -0
- package/dist/static-files/types.d.ts +81 -0
- package/dist/static-files/types.js +32 -0
- package/dist/static-files/utils.d.ts +23 -0
- package/dist/static-files/utils.js +58 -0
- package/dist/types.d.ts +14 -27
- package/package.json +1 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var routes_exports = {};
|
|
30
|
+
__export(routes_exports, {
|
|
31
|
+
MAX_ROUTE_SRC_LENGTH: () => MAX_ROUTE_SRC_LENGTH,
|
|
32
|
+
NAVIGATION_ACCEPT_RE: () => NAVIGATION_ACCEPT_RE,
|
|
33
|
+
staticDirectoryRedirects: () => staticDirectoryRedirects,
|
|
34
|
+
staticFallbackRoutes: () => staticFallbackRoutes,
|
|
35
|
+
staticShadowRoutes: () => staticShadowRoutes
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(routes_exports);
|
|
38
|
+
var import_fs = __toESM(require("fs"));
|
|
39
|
+
var import_path = require("path");
|
|
40
|
+
var import_debug = __toESM(require("../debug"));
|
|
41
|
+
var import_utils = require("./utils");
|
|
42
|
+
const MAX_ROUTE_SRC_LENGTH = 4096;
|
|
43
|
+
function shadowSrc(bodies) {
|
|
44
|
+
return `^/((?:${bodies.join("|")})/?)$`;
|
|
45
|
+
}
|
|
46
|
+
function redirectSrc(bodies) {
|
|
47
|
+
return `^/((?:${bodies.join("|")}))$`;
|
|
48
|
+
}
|
|
49
|
+
const SHADOW_SRC_WRAPPER_LENGTH = shadowSrc([]).length;
|
|
50
|
+
const REDIRECT_SRC_WRAPPER_LENGTH = redirectSrc([]).length;
|
|
51
|
+
function chunkBodies(bodies, wrapperLength) {
|
|
52
|
+
const chunks = [];
|
|
53
|
+
let srcLen = 0;
|
|
54
|
+
let dropped = 0;
|
|
55
|
+
for (const body of bodies) {
|
|
56
|
+
if (wrapperLength + body.length > MAX_ROUTE_SRC_LENGTH) {
|
|
57
|
+
dropped += 1;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const current = chunks[chunks.length - 1];
|
|
61
|
+
if (current && srcLen + 1 + body.length <= MAX_ROUTE_SRC_LENGTH) {
|
|
62
|
+
current.push(body);
|
|
63
|
+
srcLen += 1 + body.length;
|
|
64
|
+
} else {
|
|
65
|
+
chunks.push([body]);
|
|
66
|
+
srcLen = wrapperLength + body.length;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { chunks, dropped };
|
|
70
|
+
}
|
|
71
|
+
function staticShadowRoutes(shadowRoutes, lambdaPath, opts) {
|
|
72
|
+
const byMethods = /* @__PURE__ */ new Map();
|
|
73
|
+
for (const sr of shadowRoutes) {
|
|
74
|
+
const key = sr.methods === null ? "" : JSON.stringify([...sr.methods].sort());
|
|
75
|
+
const group = byMethods.get(key);
|
|
76
|
+
if (group) {
|
|
77
|
+
group.push(sr.body);
|
|
78
|
+
} else {
|
|
79
|
+
byMethods.set(key, [sr.body]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const routes = [];
|
|
83
|
+
let dropped = 0;
|
|
84
|
+
for (const [methodsKey, bodies] of byMethods) {
|
|
85
|
+
const methods = methodsKey === "" ? void 0 : JSON.parse(methodsKey);
|
|
86
|
+
const { chunks, dropped: d } = chunkBodies(
|
|
87
|
+
bodies,
|
|
88
|
+
SHADOW_SRC_WRAPPER_LENGTH
|
|
89
|
+
);
|
|
90
|
+
dropped += d;
|
|
91
|
+
for (const chunk of chunks) {
|
|
92
|
+
routes.push({
|
|
93
|
+
src: shadowSrc(chunk),
|
|
94
|
+
dest: `/${lambdaPath}`,
|
|
95
|
+
...methods ? { methods } : {},
|
|
96
|
+
transforms: [{ type: "request.path", op: "set", args: "/$1" }]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (dropped > 0) {
|
|
101
|
+
(0, import_debug.default)(
|
|
102
|
+
`${(0, import_utils.logLabel)(opts)}: ${dropped} shadow route(s) over the ${MAX_ROUTE_SRC_LENGTH} char cap left unshadowed`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return routes;
|
|
106
|
+
}
|
|
107
|
+
function staticDirectoryRedirects(mounts, opts) {
|
|
108
|
+
const redirects = [];
|
|
109
|
+
let redirectDropped = 0;
|
|
110
|
+
const higherPriority = [];
|
|
111
|
+
for (const mount of (0, import_utils.byCopyPriority)(mounts)) {
|
|
112
|
+
if (!mount.html && !mount.frontend) {
|
|
113
|
+
higherPriority.push((0, import_utils.trimTrailingSlashes)(mount.urlPath));
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const urlPrefix = (0, import_utils.trimSlashes)(mount.urlPath);
|
|
117
|
+
const bodies = [];
|
|
118
|
+
const collectBodies = (absDir, urlPath) => {
|
|
119
|
+
if (higherPriority.some((base) => (0, import_utils.mountCovers)(base, `/${urlPath}`))) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (urlPath && import_fs.default.existsSync((0, import_path.join)(absDir, "index.html"))) {
|
|
123
|
+
bodies.push((0, import_utils.escapeRegex)(urlPath));
|
|
124
|
+
}
|
|
125
|
+
for (const entry of import_fs.default.readdirSync(absDir, { withFileTypes: true })) {
|
|
126
|
+
if (!entry.isDirectory())
|
|
127
|
+
continue;
|
|
128
|
+
collectBodies(
|
|
129
|
+
(0, import_path.join)(absDir, entry.name),
|
|
130
|
+
urlPath ? `${urlPath}/${entry.name}` : entry.name
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
try {
|
|
135
|
+
collectBodies(mount.directory, urlPrefix);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
(0, import_debug.default)(
|
|
138
|
+
`${(0, import_utils.logLabel)(opts)}: skipping bare-dir redirects for ${mount.urlPath} (${err})`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
higherPriority.push((0, import_utils.trimTrailingSlashes)(mount.urlPath));
|
|
142
|
+
const { chunks, dropped } = chunkBodies(
|
|
143
|
+
bodies,
|
|
144
|
+
REDIRECT_SRC_WRAPPER_LENGTH
|
|
145
|
+
);
|
|
146
|
+
redirectDropped += dropped;
|
|
147
|
+
for (const chunk of chunks) {
|
|
148
|
+
redirects.push({
|
|
149
|
+
src: redirectSrc(chunk),
|
|
150
|
+
dest: "/$1/",
|
|
151
|
+
status: 307,
|
|
152
|
+
methods: ["GET", "HEAD"]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (redirectDropped > 0) {
|
|
157
|
+
(0, import_debug.default)(
|
|
158
|
+
`${(0, import_utils.logLabel)(opts)}: ${redirectDropped} redirect(s) over the ${MAX_ROUTE_SRC_LENGTH} char cap left unredirected`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return redirects;
|
|
162
|
+
}
|
|
163
|
+
const NAVIGATION_ACCEPT_RE = ".*(?:^|[,\\s])(?:text/html|application/xhtml\\+xml)(?=[,;\\s]|$)(?![^,]*;\\s*q=0(?:\\.0+)?(?:[,;\\s]|$)).*";
|
|
164
|
+
function staticFallbackRoutes(copied, discovered, opts) {
|
|
165
|
+
const mountPrefixes = discovered.map((m) => (0, import_utils.trimTrailingSlashes)(m.urlPath));
|
|
166
|
+
return copied.flatMap((mount) => {
|
|
167
|
+
const fb = mount.fallback;
|
|
168
|
+
if (!fb)
|
|
169
|
+
return [];
|
|
170
|
+
const isNavigation = fb.status === 200;
|
|
171
|
+
const prefix = (0, import_utils.trimTrailingSlashes)(mount.urlPath);
|
|
172
|
+
const nested = mountPrefixes.filter((urlPath) => urlPath.startsWith(`${prefix}/`)).map((urlPath) => urlPath.slice(prefix.length + 1));
|
|
173
|
+
const siblingGuard = nested.length ? `(?!(?:${nested.map(import_utils.escapeRegex).join("|")})(?:/|$))` : "";
|
|
174
|
+
const useExtensionGuard = isNavigation && !opts?.useFallbackForExtensionedPaths;
|
|
175
|
+
const extensionGuard = useExtensionGuard ? "(?!.*[^/.]\\.[^/]*$)" : "";
|
|
176
|
+
const src = `^${(0, import_utils.escapeRegex)(prefix)}/${siblingGuard}${extensionGuard}.*$`;
|
|
177
|
+
if (src.length > MAX_ROUTE_SRC_LENGTH) {
|
|
178
|
+
(0, import_debug.default)(
|
|
179
|
+
`${(0, import_utils.logLabel)(opts)}: fallback route for ${mount.urlPath} over the ${MAX_ROUTE_SRC_LENGTH} char cap, served by the Lambda`
|
|
180
|
+
);
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
const route = {
|
|
184
|
+
src,
|
|
185
|
+
dest: `${prefix}/${fb.file}`,
|
|
186
|
+
status: fb.status,
|
|
187
|
+
check: true,
|
|
188
|
+
methods: ["GET", "HEAD"],
|
|
189
|
+
...isNavigation ? {
|
|
190
|
+
has: [
|
|
191
|
+
{ type: "header", key: "accept", value: NAVIGATION_ACCEPT_RE }
|
|
192
|
+
]
|
|
193
|
+
} : {}
|
|
194
|
+
};
|
|
195
|
+
return [route];
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
199
|
+
0 && (module.exports = {
|
|
200
|
+
MAX_ROUTE_SRC_LENGTH,
|
|
201
|
+
NAVIGATION_ACCEPT_RE,
|
|
202
|
+
staticDirectoryRedirects,
|
|
203
|
+
staticFallbackRoutes,
|
|
204
|
+
staticShadowRoutes
|
|
205
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Files } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Types for static-file promotion: the discovery contract a builder's
|
|
4
|
+
* framework-specific discovery step hands in, plus the options and results of
|
|
5
|
+
* the shared promotion steps.
|
|
6
|
+
*/
|
|
7
|
+
/** A mount's miss fallback: which file to serve, and with what status. */
|
|
8
|
+
export interface StaticFallback {
|
|
9
|
+
/** File to serve for unmatched paths under the mount (e.g. "index.html"). */
|
|
10
|
+
file: string;
|
|
11
|
+
/** Status to serve it with (200 for index.html, 404 for 404.html). */
|
|
12
|
+
status: number;
|
|
13
|
+
}
|
|
14
|
+
/** One directory served by the app at a URL prefix. */
|
|
15
|
+
export interface StaticMount {
|
|
16
|
+
/** URL prefix, no trailing slash ("/" for root). */
|
|
17
|
+
urlPath: string;
|
|
18
|
+
/** Absolute source directory. */
|
|
19
|
+
directory: string;
|
|
20
|
+
/** Miss fallback for this mount, or null for none. */
|
|
21
|
+
fallback: StaticFallback | null;
|
|
22
|
+
/** Low-priority SPA-style mount, copied after all plain mounts. */
|
|
23
|
+
frontend: boolean;
|
|
24
|
+
/** Directory-index + bare-directory redirect mode. */
|
|
25
|
+
html: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** A path the app owns ahead of the CDN. */
|
|
28
|
+
export interface ShadowRoute {
|
|
29
|
+
/** Regex body matched against the path minus its leading slash. */
|
|
30
|
+
body: string;
|
|
31
|
+
/** Sorted HTTP methods, or null for all methods. */
|
|
32
|
+
methods: string[] | null;
|
|
33
|
+
}
|
|
34
|
+
/** Discovery output: the contract between a builder and this module. */
|
|
35
|
+
export interface StaticDiscovery {
|
|
36
|
+
/** Mounts in declaration order. */
|
|
37
|
+
mounts: StaticMount[];
|
|
38
|
+
/** Paths the app owns, sorted by body. */
|
|
39
|
+
shadowRoutes: ShadowRoute[];
|
|
40
|
+
/** CDN URL paths (leading slash) the app owns; sorted and deduplicated. */
|
|
41
|
+
excludedFiles: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The discovery result for "nothing to promote". Frozen (arrays included) so
|
|
45
|
+
* the shared instance can't be mutated by a caller.
|
|
46
|
+
*/
|
|
47
|
+
export declare const EMPTY_DISCOVERY: StaticDiscovery;
|
|
48
|
+
/** Options shared by every promotion step. */
|
|
49
|
+
export interface StaticPromotionOptions {
|
|
50
|
+
/** Prefix for debug log lines (e.g. "FastAPI"). */
|
|
51
|
+
debugLabel?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Serve fallback for navigation requests to extensioned paths
|
|
54
|
+
* like `/app/main.js`. Defaults to false.
|
|
55
|
+
*/
|
|
56
|
+
useFallbackForExtensionedPaths?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Outcome of promoting a discovery's mounts, for wiring routes and output. */
|
|
59
|
+
export interface StaticPromotionResult {
|
|
60
|
+
/**
|
|
61
|
+
* The full discovery. `discovery.mounts` (every discovered mount, copied or
|
|
62
|
+
* not) drives redirects, bundle exclusion and the fallback nested-mount
|
|
63
|
+
* guard, since a mount owns its namespace at runtime even if its copy failed.
|
|
64
|
+
*/
|
|
65
|
+
discovery: StaticDiscovery;
|
|
66
|
+
/**
|
|
67
|
+
* Mounts actually copied, in copy-priority order. Only these get fallback
|
|
68
|
+
* routes: a `check: true` destination that doesn't exist ends the request
|
|
69
|
+
* instead of reaching the Lambda.
|
|
70
|
+
*/
|
|
71
|
+
copiedMounts: StaticMount[];
|
|
72
|
+
/** Static output dir the mounts were copied into. */
|
|
73
|
+
outputStaticDir: string;
|
|
74
|
+
}
|
|
75
|
+
/** Lambda bundle adjustments for promoted mounts. */
|
|
76
|
+
export interface StaticBundleExclusions {
|
|
77
|
+
/** Glob patterns that exclude promoted mount directories from the Lambda. */
|
|
78
|
+
excludePatterns: string[];
|
|
79
|
+
/** Stub files that keep excluded mount directories present in the Lambda. */
|
|
80
|
+
directoryStubs: Files;
|
|
81
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
EMPTY_DISCOVERY: () => EMPTY_DISCOVERY
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(types_exports);
|
|
24
|
+
const EMPTY_DISCOVERY = Object.freeze({
|
|
25
|
+
mounts: Object.freeze([]),
|
|
26
|
+
shadowRoutes: Object.freeze([]),
|
|
27
|
+
excludedFiles: Object.freeze([])
|
|
28
|
+
});
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
EMPTY_DISCOVERY
|
|
32
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StaticMount, StaticPromotionOptions } from './types';
|
|
2
|
+
/** `urlPath` with trailing slashes removed, so the root mount ("/") is ''. */
|
|
3
|
+
export declare function trimTrailingSlashes(urlPath: string): string;
|
|
4
|
+
export declare function trimSlashes(urlPath: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* True when `urlPath` is `base` or under it. `base` is a normalized (no
|
|
7
|
+
* trailing slash) mount prefix, so '' is the root mount and covers everything.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mountCovers(base: string, urlPath: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Mounts in CDN copy-priority order: plain mounts (declaration order), then
|
|
12
|
+
* frontends (longest prefix first). An earlier mount owns every colliding
|
|
13
|
+
* path under its prefix.
|
|
14
|
+
*/
|
|
15
|
+
export declare function byCopyPriority(mounts: StaticMount[]): StaticMount[];
|
|
16
|
+
/**
|
|
17
|
+
* Escape regex metacharacters in a literal path segment before it goes into a
|
|
18
|
+
* route `src`. Discovery emits shadow bodies already escaped, but mount
|
|
19
|
+
* prefixes are raw URL paths and must be escaped here.
|
|
20
|
+
*/
|
|
21
|
+
export declare function escapeRegex(text: string): string;
|
|
22
|
+
/** Debug-log prefix for a step. */
|
|
23
|
+
export declare function logLabel(opts: StaticPromotionOptions | undefined): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
byCopyPriority: () => byCopyPriority,
|
|
22
|
+
escapeRegex: () => escapeRegex,
|
|
23
|
+
logLabel: () => logLabel,
|
|
24
|
+
mountCovers: () => mountCovers,
|
|
25
|
+
trimSlashes: () => trimSlashes,
|
|
26
|
+
trimTrailingSlashes: () => trimTrailingSlashes
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
function trimTrailingSlashes(urlPath) {
|
|
30
|
+
return urlPath.replace(/\/+$/, "");
|
|
31
|
+
}
|
|
32
|
+
function trimSlashes(urlPath) {
|
|
33
|
+
return urlPath.replace(/^\/+|\/+$/g, "");
|
|
34
|
+
}
|
|
35
|
+
function mountCovers(base, urlPath) {
|
|
36
|
+
return base === "" || urlPath === base || urlPath.startsWith(base + "/");
|
|
37
|
+
}
|
|
38
|
+
function byCopyPriority(mounts) {
|
|
39
|
+
return [
|
|
40
|
+
...mounts.filter((m) => !m.frontend),
|
|
41
|
+
...mounts.filter((m) => m.frontend).sort((a, b) => b.urlPath.length - a.urlPath.length)
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
function escapeRegex(text) {
|
|
45
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
46
|
+
}
|
|
47
|
+
function logLabel(opts) {
|
|
48
|
+
return opts?.debugLabel ?? "static-files";
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
byCopyPriority,
|
|
53
|
+
escapeRegex,
|
|
54
|
+
logLabel,
|
|
55
|
+
mountCovers,
|
|
56
|
+
trimSlashes,
|
|
57
|
+
trimTrailingSlashes
|
|
58
|
+
});
|
package/dist/types.d.ts
CHANGED
|
@@ -654,42 +654,29 @@ export interface Cron {
|
|
|
654
654
|
path: string;
|
|
655
655
|
schedule: string;
|
|
656
656
|
}
|
|
657
|
-
export
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
export type ScheduleTarget = {
|
|
664
|
-
/** Build output path of the function to invoke, e.g. "api/cron" */
|
|
665
|
-
function: string;
|
|
666
|
-
} | {
|
|
667
|
-
/** Deployment path to invoke over HTTP, like `crons[].path`. Must start with `/`. */
|
|
668
|
-
path: string;
|
|
669
|
-
} | {
|
|
670
|
-
/** Name of the queue topic to publish to */
|
|
671
|
-
topic: string;
|
|
672
|
-
};
|
|
673
|
-
export interface Schedule {
|
|
674
|
-
/** Unique name of the schedule within the deployment (REQUIRED) */
|
|
675
|
-
name: string;
|
|
676
|
-
expression: ScheduleExpression;
|
|
677
|
-
/** IANA timezone for cron evaluation, e.g. "America/New_York". Defaults to UTC. */
|
|
678
|
-
timezone?: string;
|
|
679
|
-
target: ScheduleTarget;
|
|
680
|
-
}
|
|
681
|
-
/** Flat schedule shape in Build Output API `config.json`. */
|
|
682
|
-
export type FlatBuildOutputSchedule = {
|
|
683
|
-
/** Defaults to a hash of the target and cron expression. */
|
|
657
|
+
export type ScheduleRequestMethod = 'GET' | 'POST';
|
|
658
|
+
export type Schedule = {
|
|
659
|
+
/**
|
|
660
|
+
* Unique name of the schedule within the deployment. Defaults to a hash of
|
|
661
|
+
* the target and cron expression.
|
|
662
|
+
*/
|
|
684
663
|
name?: string;
|
|
664
|
+
/** Cron expression describing when the schedule fires (REQUIRED) */
|
|
685
665
|
schedule: string;
|
|
666
|
+
/** IANA timezone for cron evaluation, e.g. "America/New_York". Defaults to UTC. */
|
|
686
667
|
timezone?: string;
|
|
668
|
+
/** Maximum random delay applied to each firing, from 1 to 15 whole minutes (OPTIONAL) */
|
|
687
669
|
jitter?: number;
|
|
688
670
|
} & ({
|
|
671
|
+
/** Deployment path to invoke over HTTP, like `crons[].path`. Must start with `/`. */
|
|
689
672
|
path: string;
|
|
673
|
+
/** HTTP method used to invoke `path`. Defaults to `POST`. */
|
|
674
|
+
requestMethod?: ScheduleRequestMethod;
|
|
690
675
|
} | {
|
|
676
|
+
/** Build output path of the function to invoke, e.g. "api/cron" */
|
|
691
677
|
function: string;
|
|
692
678
|
} | {
|
|
679
|
+
/** Name of the queue topic to publish to */
|
|
693
680
|
topic: string;
|
|
694
681
|
});
|
|
695
682
|
export interface ServiceQueueTopic {
|