@vercel/build-utils 13.17.0 → 13.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,25 @@
1
+ import type { Diagnostics } from './types';
2
+ export interface PackageManifestDependency {
3
+ name: string;
4
+ type: 'direct' | 'transitive' | 'peer';
5
+ scopes: string[];
6
+ requested?: string;
7
+ resolved: string;
8
+ source?: string;
9
+ sourceUrl?: string;
10
+ }
11
+ export interface PackageManifest {
12
+ version?: string;
13
+ runtime: string;
14
+ runtimeVersion?: {
15
+ requested?: string;
16
+ requestedSource?: string;
17
+ resolved: string;
18
+ };
19
+ dependencies: PackageManifestDependency[];
20
+ }
21
+ export declare const MANIFEST_VERSION = "20260304";
22
+ export declare const MANIFEST_FILENAME = "package-manifest.json";
23
+ export declare function manifestPath(runtime: string): string;
24
+ export declare function writeProjectManifest(manifest: PackageManifest, workPath: string, runtime: string): Promise<void>;
25
+ export declare function createDiagnostics(runtime: string): Diagnostics;
@@ -0,0 +1,71 @@
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 package_manifest_exports = {};
30
+ __export(package_manifest_exports, {
31
+ MANIFEST_FILENAME: () => MANIFEST_FILENAME,
32
+ MANIFEST_VERSION: () => MANIFEST_VERSION,
33
+ createDiagnostics: () => createDiagnostics,
34
+ manifestPath: () => manifestPath,
35
+ writeProjectManifest: () => writeProjectManifest
36
+ });
37
+ module.exports = __toCommonJS(package_manifest_exports);
38
+ var import_fs = __toESM(require("fs"));
39
+ var import_path = require("path");
40
+ var import_file_blob = __toESM(require("./file-blob"));
41
+ const MANIFEST_VERSION = "20260304";
42
+ const MANIFEST_FILENAME = "package-manifest.json";
43
+ function manifestPath(runtime) {
44
+ return (0, import_path.join)(".vercel", runtime, MANIFEST_FILENAME);
45
+ }
46
+ async function writeProjectManifest(manifest, workPath, runtime) {
47
+ const outPath = (0, import_path.join)(workPath, manifestPath(runtime));
48
+ await import_fs.default.promises.mkdir((0, import_path.dirname)(outPath), { recursive: true });
49
+ await import_fs.default.promises.writeFile(outPath, JSON.stringify(manifest, null, 2));
50
+ }
51
+ function createDiagnostics(runtime) {
52
+ return async ({ workPath }) => {
53
+ try {
54
+ const filePath = (0, import_path.join)(workPath, manifestPath(runtime));
55
+ const data = await import_fs.default.promises.readFile(filePath, "utf-8");
56
+ return {
57
+ [MANIFEST_FILENAME]: new import_file_blob.default({ data })
58
+ };
59
+ } catch {
60
+ return {};
61
+ }
62
+ };
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ MANIFEST_FILENAME,
67
+ MANIFEST_VERSION,
68
+ createDiagnostics,
69
+ manifestPath,
70
+ writeProjectManifest
71
+ });
package/dist/types.d.ts CHANGED
@@ -110,8 +110,10 @@ export interface BuildOptions {
110
110
  service?: {
111
111
  /** The service name as declared in the project configuration. */
112
112
  name?: string;
113
- /** The service type (e.g., "web", "cron", "worker"). */
113
+ /** The service type (e.g., "web", "worker", "job"). */
114
114
  type?: ServiceType;
115
+ /** The job trigger type (e.g., "queue", "schedule", "workflow"). */
116
+ trigger?: JobTrigger;
115
117
  /** URL path prefix where the service is mounted (e.g., "/api"). */
116
118
  routePrefix?: string;
117
119
  /** Optional subdomain this service is mounted on (e.g., "api"). */
@@ -492,9 +494,18 @@ export interface Cron {
492
494
  path: string;
493
495
  schedule: string;
494
496
  }
497
+ export interface ServiceQueueTopic {
498
+ topic: string;
499
+ retryAfterSeconds?: number;
500
+ initialDelaySeconds?: number;
501
+ }
502
+ export type ServiceTopics = string[] | ServiceQueueTopic[];
503
+ export declare const JOB_TRIGGERS: readonly ["queue", "schedule", "workflow"];
504
+ export type JobTrigger = (typeof JOB_TRIGGERS)[number];
495
505
  export interface Service {
496
506
  name: string;
497
507
  type: ServiceType;
508
+ trigger?: JobTrigger;
498
509
  group?: string;
499
510
  workspace: string;
500
511
  entrypoint?: string;
@@ -508,17 +519,27 @@ export interface Service {
508
519
  subdomain?: string;
509
520
  schedule?: string;
510
521
  handlerFunction?: string;
511
- topics?: string[];
522
+ topics?: ServiceTopics;
512
523
  consumer?: string;
513
524
  /** custom prefix to inject service URL env vars */
514
525
  envPrefix?: string;
515
526
  }
516
- /**
517
- * Returns the topics a worker service subscribes to, defaulting to ['default'].
518
- */
519
- export declare function getWorkerTopics(config: {
520
- topics?: string[];
521
- }): [string, ...string[]];
527
+ export declare function getServiceQueueTopicConfigs(config: {
528
+ type?: ServiceType;
529
+ topics?: ServiceTopics;
530
+ }): ServiceQueueTopic[];
531
+ export declare function getServiceQueueTopics(config: {
532
+ type?: ServiceType;
533
+ topics?: ServiceTopics;
534
+ }): string[];
535
+ export declare function isQueueTriggeredService(service: {
536
+ type?: ServiceType;
537
+ trigger?: JobTrigger;
538
+ }): boolean;
539
+ export declare function isScheduleTriggeredService(service: {
540
+ type?: ServiceType;
541
+ trigger?: JobTrigger;
542
+ }): boolean;
522
543
  /** The framework which created the function */
523
544
  export interface FunctionFramework {
524
545
  slug: string;
@@ -666,7 +687,7 @@ export interface TriggerEvent extends TriggerEventBase {
666
687
  consumer: string;
667
688
  }
668
689
  export type ServiceRuntime = 'node' | 'python' | 'go' | 'rust' | 'ruby';
669
- export type ServiceType = 'web' | 'cron' | 'worker';
690
+ export type ServiceType = 'web' | 'cron' | 'worker' | 'job';
670
691
  export interface ServiceMount {
671
692
  /** URL path prefix where the service is mounted. */
672
693
  path?: string;
@@ -679,6 +700,7 @@ export interface ServiceMount {
679
700
  */
680
701
  export interface ExperimentalServiceConfig {
681
702
  type?: ServiceType;
703
+ trigger?: JobTrigger;
682
704
  /**
683
705
  * Path to the service's root directory relative to the project root.
684
706
  * Should contain a manifest file (package.json, pyproject.toml, etc.).
@@ -711,9 +733,9 @@ export interface ExperimentalServiceConfig {
711
733
  routePrefix?: string;
712
734
  /** Subdomain this service should respond to (web services only). */
713
735
  subdomain?: string;
714
- /** Cron schedule expression (e.g., "0 0 * * *") */
736
+ /** Cron schedule expression(s) (e.g., "0 0 * * *") */
715
737
  schedule?: string;
716
- topics?: string[];
738
+ topics?: ServiceTopics;
717
739
  consumer?: string;
718
740
  /** Custom prefix to use to inject service URL env vars */
719
741
  envPrefix?: string;
package/dist/types.js CHANGED
@@ -19,9 +19,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var types_exports = {};
20
20
  __export(types_exports, {
21
21
  BunVersion: () => BunVersion,
22
+ JOB_TRIGGERS: () => JOB_TRIGGERS,
22
23
  NodeVersion: () => NodeVersion,
23
24
  Version: () => Version,
24
- getWorkerTopics: () => getWorkerTopics
25
+ getServiceQueueTopicConfigs: () => getServiceQueueTopicConfigs,
26
+ getServiceQueueTopics: () => getServiceQueueTopics,
27
+ isQueueTriggeredService: () => isQueueTriggeredService,
28
+ isScheduleTriggeredService: () => isScheduleTriggeredService
25
29
  });
26
30
  module.exports = __toCommonJS(types_exports);
27
31
  class Version {
@@ -48,13 +52,30 @@ class NodeVersion extends Version {
48
52
  }
49
53
  class BunVersion extends Version {
50
54
  }
51
- function getWorkerTopics(config) {
52
- return config.topics?.length ? config.topics : ["default"];
55
+ const JOB_TRIGGERS = ["queue", "schedule", "workflow"];
56
+ function getServiceQueueTopicConfigs(config) {
57
+ if (Array.isArray(config.topics) && config.topics.length > 0) {
58
+ return typeof config.topics[0] === "string" ? config.topics.map((topic) => ({ topic })) : config.topics;
59
+ }
60
+ return config.type === "worker" ? [{ topic: "default" }] : [];
61
+ }
62
+ function getServiceQueueTopics(config) {
63
+ return getServiceQueueTopicConfigs(config).map((topic) => topic.topic);
64
+ }
65
+ function isQueueTriggeredService(service) {
66
+ return service.type === "worker" || service.type === "job" && service.trigger === "queue";
67
+ }
68
+ function isScheduleTriggeredService(service) {
69
+ return service.type === "cron" || service.type === "job" && service.trigger === "schedule";
53
70
  }
54
71
  // Annotate the CommonJS export names for ESM import in node:
55
72
  0 && (module.exports = {
56
73
  BunVersion,
74
+ JOB_TRIGGERS,
57
75
  NodeVersion,
58
76
  Version,
59
- getWorkerTopics
77
+ getServiceQueueTopicConfigs,
78
+ getServiceQueueTopics,
79
+ isQueueTriggeredService,
80
+ isScheduleTriggeredService
60
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "13.17.0",
3
+ "version": "13.18.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",