@vercel/build-utils 14.16.0 → 14.18.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.
@@ -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
@@ -5,6 +5,7 @@ import type { Lambda, LambdaAffinity, LambdaArchitecture } from './lambda';
5
5
  import type { Prerender } from './prerender';
6
6
  import type { EdgeFunction } from './edge-function';
7
7
  import type { ContainerImage } from './container-image';
8
+ import type { DaemonConfig, DaemonOutput } from './daemons';
8
9
  import type { Span } from './trace';
9
10
  import type { HasField, Route, Rewrite, Redirect, Header } from '@vercel/routing-utils';
10
11
  export interface Env {
@@ -73,10 +74,18 @@ export interface Config {
73
74
  buildpack?: string;
74
75
  /** Set when this build produces a function for schedule entrypoints. */
75
76
  scheduleFunction?: ScheduleFunctionBuildConfig;
77
+ /** Set when this build produces the named daemon. */
78
+ daemon?: DaemonConfig & {
79
+ name: string;
80
+ };
76
81
  [key: string]: unknown;
77
82
  }
78
83
  export type { HasField };
79
84
  export interface Meta {
85
+ daemonContext?: {
86
+ projectRoot: string;
87
+ daemons: Record<string, DaemonConfig>;
88
+ };
80
89
  isDev?: boolean;
81
90
  devCacheDir?: string;
82
91
  skipDownload?: boolean;
@@ -651,12 +660,15 @@ export interface ScheduleExpression {
651
660
  /** Maximum random delay applied to each firing, from 1 to 15 whole minutes (OPTIONAL) */
652
661
  jitter?: number;
653
662
  }
663
+ export type ScheduleRequestMethod = 'GET' | 'POST';
654
664
  export type ScheduleTarget = {
655
665
  /** Build output path of the function to invoke, e.g. "api/cron" */
656
666
  function: string;
657
667
  } | {
658
668
  /** Deployment path to invoke over HTTP, like `crons[].path`. Must start with `/`. */
659
669
  path: string;
670
+ /** HTTP method used to invoke `path`. Defaults to `POST`. */
671
+ requestMethod?: ScheduleRequestMethod;
660
672
  } | {
661
673
  /** Name of the queue topic to publish to */
662
674
  topic: string;
@@ -678,6 +690,7 @@ export type FlatBuildOutputSchedule = {
678
690
  jitter?: number;
679
691
  } & ({
680
692
  path: string;
693
+ requestMethod?: ScheduleRequestMethod;
681
694
  } | {
682
695
  function: string;
683
696
  } | {
@@ -827,6 +840,8 @@ export interface BuildResultV2Typical {
827
840
  */
828
841
  deploymentId?: string;
829
842
  crons?: Cron[];
843
+ /** Daemon descriptors, written to `daemons/<name>/.vc-config.json`. */
844
+ daemons?: Record<string, DaemonOutput>;
830
845
  }
831
846
  export type BuildResultVX = {
832
847
  resultVersion: 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "14.16.0",
3
+ "version": "14.18.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -52,8 +52,8 @@
52
52
  "vitest": "4.1.10",
53
53
  "typescript": "4.9.5",
54
54
  "yazl": "2.5.1",
55
- "@vercel/error-utils": "2.2.1",
56
- "@vercel/routing-utils": "6.6.0"
55
+ "@vercel/routing-utils": "6.6.0",
56
+ "@vercel/error-utils": "2.2.1"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "node build.mjs",