@vercel/build-utils 14.14.0 → 14.16.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 +12 -0
- package/dist/daemons.d.ts +30 -0
- package/dist/daemons.js +37 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/dist/schedules.d.ts +18 -1
- package/dist/schedules.js +12 -5
- package/dist/types.d.ts +2 -1
- package/package.json +3 -3
package/dist/schedules.d.ts
CHANGED
|
@@ -8,5 +8,22 @@ export type VercelJsonSchedule = Omit<Schedule, 'target'> & {
|
|
|
8
8
|
entrypoint: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
+
declare const FLAT_TARGET_KEYS: readonly ["path", "function", "topic", "entrypoint"];
|
|
12
|
+
type FlatTargetKey = (typeof FLAT_TARGET_KEYS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* Name for a flat schedule without one: a hex hash of `type|ref|expression`,
|
|
15
|
+
* which always satisfies the schedule name pattern. Build Output omits these
|
|
16
|
+
* names (except for entrypoint schedules) and the API derives its own; using
|
|
17
|
+
* the same hash keeps `vercel dev` names the same as deployed ones.
|
|
18
|
+
*/
|
|
19
|
+
export declare function defaultScheduleName(type: FlatTargetKey, ref: string, expression: string): string;
|
|
11
20
|
export declare function parseScheduleDefinition(raw: unknown): VercelJsonSchedule;
|
|
12
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Format a schedule for Build Output `config.json`. Pass `includeName: false`
|
|
23
|
+
* for a name derived by `parseScheduleDefinition`; the API derives the same
|
|
24
|
+
* name for a flat Build Output schedule without one.
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatBuildOutputSchedule(schedule: Schedule, { includeName }?: {
|
|
27
|
+
includeName?: boolean;
|
|
28
|
+
}): FlatBuildOutputSchedule;
|
|
29
|
+
export {};
|
package/dist/schedules.js
CHANGED
|
@@ -18,11 +18,17 @@ 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,
|
|
21
22
|
formatBuildOutputSchedule: () => formatBuildOutputSchedule,
|
|
22
23
|
parseScheduleDefinition: () => parseScheduleDefinition
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(schedules_exports);
|
|
26
|
+
var import_crypto = require("crypto");
|
|
25
27
|
const FLAT_TARGET_KEYS = ["path", "function", "topic", "entrypoint"];
|
|
28
|
+
const DEFAULT_NAME_HASH_LENGTH = 12;
|
|
29
|
+
function defaultScheduleName(type, ref, expression) {
|
|
30
|
+
return (0, import_crypto.createHash)("sha1").update(`${type}|${ref}|${expression}`).digest("hex").slice(0, DEFAULT_NAME_HASH_LENGTH);
|
|
31
|
+
}
|
|
26
32
|
function isRecord(value) {
|
|
27
33
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
28
34
|
}
|
|
@@ -87,7 +93,7 @@ function parseLegacySchedule(obj) {
|
|
|
87
93
|
}
|
|
88
94
|
function parseFlatSchedule(obj) {
|
|
89
95
|
const { name, schedule, timezone, jitter } = obj;
|
|
90
|
-
if (typeof name !== "string") {
|
|
96
|
+
if (name !== void 0 && typeof name !== "string") {
|
|
91
97
|
throw new Error("Schedule `name` must be a string.");
|
|
92
98
|
}
|
|
93
99
|
if (typeof schedule !== "string") {
|
|
@@ -108,7 +114,7 @@ function parseFlatSchedule(obj) {
|
|
|
108
114
|
[targetKey]: targetValue
|
|
109
115
|
};
|
|
110
116
|
return {
|
|
111
|
-
name,
|
|
117
|
+
name: name ?? defaultScheduleName(targetKey, targetValue, schedule),
|
|
112
118
|
expression: {
|
|
113
119
|
cron: schedule,
|
|
114
120
|
...jitter !== void 0 ? { jitter } : {}
|
|
@@ -129,12 +135,12 @@ function parseScheduleDefinition(raw) {
|
|
|
129
135
|
return parseFlatSchedule(raw);
|
|
130
136
|
}
|
|
131
137
|
throw new Error(
|
|
132
|
-
"Schedule must use either the legacy shape (`expression`, `target`, `name`) or the flat shape (`schedule
|
|
138
|
+
"Schedule must use either the legacy shape (`expression`, `target`, `name`) or the flat shape (`schedule` and one target field)."
|
|
133
139
|
);
|
|
134
140
|
}
|
|
135
|
-
function formatBuildOutputSchedule(schedule) {
|
|
141
|
+
function formatBuildOutputSchedule(schedule, { includeName = true } = {}) {
|
|
136
142
|
return {
|
|
137
|
-
name: schedule.name,
|
|
143
|
+
...includeName ? { name: schedule.name } : {},
|
|
138
144
|
schedule: schedule.expression.cron,
|
|
139
145
|
...schedule.target,
|
|
140
146
|
...schedule.timezone !== void 0 ? { timezone: schedule.timezone } : {},
|
|
@@ -143,6 +149,7 @@ function formatBuildOutputSchedule(schedule) {
|
|
|
143
149
|
}
|
|
144
150
|
// Annotate the CommonJS export names for ESM import in node:
|
|
145
151
|
0 && (module.exports = {
|
|
152
|
+
defaultScheduleName,
|
|
146
153
|
formatBuildOutputSchedule,
|
|
147
154
|
parseScheduleDefinition
|
|
148
155
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -671,7 +671,8 @@ export interface Schedule {
|
|
|
671
671
|
}
|
|
672
672
|
/** Flat schedule shape in Build Output API `config.json`. */
|
|
673
673
|
export type FlatBuildOutputSchedule = {
|
|
674
|
-
|
|
674
|
+
/** Defaults to a hash of the target and cron expression. */
|
|
675
|
+
name?: string;
|
|
675
676
|
schedule: string;
|
|
676
677
|
timezone?: string;
|
|
677
678
|
jitter?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/build-utils",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.16.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/
|
|
56
|
-
"@vercel/
|
|
55
|
+
"@vercel/error-utils": "2.2.1",
|
|
56
|
+
"@vercel/routing-utils": "6.6.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "node build.mjs",
|