@vercel/build-utils 14.21.3 → 14.23.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.
@@ -1,21 +1,26 @@
1
- import type { Schedule } from './types';
1
+ import type { Schedule, ScheduleDefinition, Schedules } from './types';
2
2
  /**
3
- * A `vercel.json` schedule. `entrypoint` targets are resolved to `function`
4
- * before the schedule reaches Build Output.
3
+ * A `vercel.json` schedule without its name, which is its key in `schedules`.
4
+ * `entrypoint` targets are resolved to `function` before the schedule reaches
5
+ * Build Output.
5
6
  */
6
- export type VercelJsonSchedule = Schedule | (Pick<Schedule, 'name' | 'schedule' | 'timezone' | 'jitter'> & {
7
+ export type VercelJsonScheduleDefinition = ScheduleDefinition | (Pick<ScheduleDefinition, 'schedule' | 'timezone' | 'jitter'> & {
7
8
  entrypoint: string;
8
9
  });
9
- declare const SCHEDULE_TARGET_KEYS: readonly ["path", "function", "topic", "entrypoint"];
10
- export type ScheduleTargetKey = (typeof SCHEDULE_TARGET_KEYS)[number];
10
+ /** `vercel.json#schedules`: schedules keyed by name. */
11
+ export type VercelJsonSchedules = Record<string, VercelJsonScheduleDefinition>;
12
+ /** A `vercel.json` schedule with its name. */
13
+ export type VercelJsonSchedule = {
14
+ name: string;
15
+ } & VercelJsonScheduleDefinition;
11
16
  /**
12
- * Name for a schedule without one: a hex hash of `type|ref|expression`, which
13
- * always satisfies the schedule name pattern. Build Output omits these names
14
- * (except for entrypoint schedules) and the API derives its own; using the
15
- * same hash keeps `vercel dev` names the same as deployed ones. A function
16
- * target's service is appended as `|service`, matching the API.
17
+ * The schedules in `schedules` with their names, in key order. Accepts the
18
+ * deprecated array format, which already names each schedule.
17
19
  */
18
- export declare function defaultScheduleName(type: ScheduleTargetKey, ref: string, expression: string, service?: string): string;
19
- /** The schedule's `name`, or its default name when it has none. */
20
- export declare function getScheduleName(schedule: VercelJsonSchedule): string;
21
- export {};
20
+ export declare function getNamedSchedules(schedules: Schedules | readonly Schedule[] | undefined): Schedule[];
21
+ export declare function getNamedSchedules(schedules: VercelJsonSchedules | readonly VercelJsonSchedule[] | undefined): VercelJsonSchedule[];
22
+ /** Named schedules keyed by name, for `schedules` in Build Output. */
23
+ export declare function toScheduleRecord(schedules: readonly Schedule[]): Schedules;
24
+ export declare function toScheduleRecord(schedules: readonly VercelJsonSchedule[]): VercelJsonSchedules;
25
+ /** Warning for `schedules` in the deprecated array format. */
26
+ export declare function getSchedulesArrayDeprecationWarning(source: string): string;
package/dist/schedules.js CHANGED
@@ -18,37 +18,32 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var schedules_exports = {};
20
20
  __export(schedules_exports, {
21
- defaultScheduleName: () => defaultScheduleName,
22
- getScheduleName: () => getScheduleName
21
+ getNamedSchedules: () => getNamedSchedules,
22
+ getSchedulesArrayDeprecationWarning: () => getSchedulesArrayDeprecationWarning,
23
+ toScheduleRecord: () => toScheduleRecord
23
24
  });
24
25
  module.exports = __toCommonJS(schedules_exports);
25
- var import_crypto = require("crypto");
26
- const SCHEDULE_TARGET_KEYS = [
27
- "path",
28
- "function",
29
- "topic",
30
- "entrypoint"
31
- ];
32
- const DEFAULT_NAME_HASH_LENGTH = 12;
33
- function defaultScheduleName(type, ref, expression, service) {
34
- const input = `${type}|${ref}|${expression}`;
35
- return (0, import_crypto.createHash)("sha1").update(service === void 0 ? input : `${input}|${service}`).digest("hex").slice(0, DEFAULT_NAME_HASH_LENGTH);
26
+ function getNamedSchedules(schedules) {
27
+ if (schedules === void 0)
28
+ return [];
29
+ if (Array.isArray(schedules))
30
+ return [...schedules];
31
+ return Object.entries(schedules).map(([name, schedule]) => ({
32
+ name,
33
+ ...schedule
34
+ }));
36
35
  }
37
- function getScheduleName(schedule) {
38
- if (schedule.name !== void 0)
39
- return schedule.name;
40
- const type = SCHEDULE_TARGET_KEYS.find((key) => key in schedule);
41
- if (type === void 0) {
42
- throw new Error(
43
- "Schedule must include one of `path`, `function`, `topic`, or `entrypoint`."
44
- );
45
- }
46
- const ref = schedule[type];
47
- const service = type === "function" && "service" in schedule ? schedule.service : void 0;
48
- return defaultScheduleName(type, ref ?? "", schedule.schedule, service);
36
+ function toScheduleRecord(schedules) {
37
+ return Object.fromEntries(
38
+ schedules.map(({ name, ...schedule }) => [name, schedule])
39
+ );
40
+ }
41
+ function getSchedulesArrayDeprecationWarning(source) {
42
+ return `Listing \`schedules\` as an array in ${source} is deprecated. Key each schedule by its name instead, like \`"schedules": { "nightly": { "schedule": "0 0 * * *", "path": "/api/cron" } }\`.`;
49
43
  }
50
44
  // Annotate the CommonJS export names for ESM import in node:
51
45
  0 && (module.exports = {
52
- defaultScheduleName,
53
- getScheduleName
46
+ getNamedSchedules,
47
+ getSchedulesArrayDeprecationWarning,
48
+ toScheduleRecord
54
49
  });
package/dist/schemas.d.ts CHANGED
@@ -67,6 +67,10 @@ export declare const getFunctionsSchema: () => {
67
67
  type: string;
68
68
  maxLength: number;
69
69
  };
70
+ installCommand: {
71
+ type: string;
72
+ maxLength: number;
73
+ };
70
74
  experimentalTriggers: {
71
75
  type: string;
72
76
  items: {
@@ -165,6 +169,10 @@ export declare const functionsSchema: {
165
169
  type: string;
166
170
  maxLength: number;
167
171
  };
172
+ installCommand: {
173
+ type: string;
174
+ maxLength: number;
175
+ };
168
176
  experimentalTriggers: {
169
177
  type: string;
170
178
  items: {
package/dist/schemas.js CHANGED
@@ -169,6 +169,10 @@ const getFunctionsSchema = () => ({
169
169
  type: "string",
170
170
  maxLength: 256
171
171
  },
172
+ installCommand: {
173
+ type: "string",
174
+ maxLength: 256
175
+ },
172
176
  experimentalTriggers: {
173
177
  type: "array",
174
178
  items: triggerEventSchema
package/dist/types.d.ts CHANGED
@@ -454,11 +454,19 @@ export interface BuilderFunctions {
454
454
  runtime?: string;
455
455
  includeFiles?: string;
456
456
  excludeFiles?: string;
457
+ /**
458
+ * Overrides how dependencies are installed for this function. An empty
459
+ * string skips the install. Only honored by `@vercel/node`.
460
+ */
461
+ installCommand?: string;
457
462
  experimentalTriggers?: TriggerEventInput[];
458
463
  supportsCancellation?: boolean;
459
464
  };
460
465
  }
461
466
  export interface ProjectSettings {
467
+ vercelFlags?: {
468
+ enabledAt?: number;
469
+ };
462
470
  framework?: string | null;
463
471
  devCommand?: string | null;
464
472
  installCommand?: string | null;
@@ -527,8 +535,11 @@ export interface GetDevManifestOptions {
527
535
  export interface DevManifest {
528
536
  /** Complete replacement snapshot for the invoking builder scope. */
529
537
  functions: DevFunction[];
530
- /** Native framework schedules, using the static Build Output API schema. */
531
- schedules?: Schedule[];
538
+ /**
539
+ * Native framework schedules keyed by name, using the static Build Output
540
+ * API schema. The array format is deprecated.
541
+ */
542
+ schedules?: Schedules | Schedule[];
532
543
  /** Authored functions keys resolved by this provider, for unmatched diagnostics. */
533
544
  matchedFunctionPatterns: string[];
534
545
  }
@@ -660,12 +671,10 @@ export interface Cron {
660
671
  schedule: string;
661
672
  }
662
673
  export type ScheduleRequestMethod = 'GET' | 'POST';
663
- export type Schedule = {
664
- /**
665
- * Unique name of the schedule within the deployment. Defaults to a hash of
666
- * the target and cron expression.
667
- */
668
- name?: string;
674
+ /**
675
+ * A schedule without its name, which is its key in `schedules`.
676
+ */
677
+ export type ScheduleDefinition = {
669
678
  /** Cron expression describing when the schedule fires (REQUIRED) */
670
679
  schedule: string;
671
680
  /** IANA timezone for cron evaluation, e.g. "America/New_York". Defaults to UTC. */
@@ -689,6 +698,13 @@ export type Schedule = {
689
698
  /** Name of the queue topic to publish to */
690
699
  topic: string;
691
700
  });
701
+ /** Schedules keyed by name, as in Build Output `config.json#schedules`. */
702
+ export type Schedules = Record<string, ScheduleDefinition>;
703
+ /** A schedule with its name. */
704
+ export type Schedule = {
705
+ /** Unique name of the schedule within the deployment (REQUIRED) */
706
+ name: string;
707
+ } & ScheduleDefinition;
692
708
  export interface ServiceQueueTopic {
693
709
  topic: string;
694
710
  retryAfterSeconds?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "14.21.3",
3
+ "version": "14.23.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",