alchemy 0.16.7 → 0.16.8

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,69 @@
1
+ import type { Secret } from "../secret.js";
2
+ /**
3
+ * Options for Vercel API requests
4
+ */
5
+ export interface VercelApiOptions {
6
+ /**
7
+ * Base URL for API
8
+ */
9
+ baseUrl: string;
10
+ /**
11
+ * API access token to use (overrides environment variable)
12
+ */
13
+ accessToken?: Secret;
14
+ }
15
+ /**
16
+ * Creates a VercelApi instance with automatic token validation
17
+ *
18
+ * @param options API options
19
+ * @returns Promise resolving to a VercelApi instance
20
+ */
21
+ export declare function createVercelApi(options: VercelApiOptions): Promise<VercelApi>;
22
+ /**
23
+ * Vercel API client using raw fetch
24
+ */
25
+ export declare class VercelApi {
26
+ /** Base URL for API */
27
+ readonly baseUrl: string;
28
+ /** API access token */
29
+ readonly accessToken: Secret;
30
+ /**
31
+ * Create a new API client
32
+ * Use createVercelApi factory function instead of direct constructor
33
+ * for automatic token validation.
34
+ *
35
+ * @param options API options
36
+ */
37
+ constructor(options: VercelApiOptions & {
38
+ accessToken: Secret;
39
+ });
40
+ /**
41
+ * Make a request to the API
42
+ *
43
+ * @param path API path (without base URL)
44
+ * @param init Fetch init options
45
+ * @returns Raw Response object from fetch
46
+ */
47
+ fetch(path: string, init?: RequestInit): Promise<Response>;
48
+ /**
49
+ * Helper for GET requests
50
+ */
51
+ get(path: string, init?: RequestInit): Promise<Response>;
52
+ /**
53
+ * Helper for POST requests
54
+ */
55
+ post(path: string, body: any, init?: RequestInit): Promise<Response>;
56
+ /**
57
+ * Helper for PUT requests
58
+ */
59
+ put(path: string, body: any, init?: RequestInit): Promise<Response>;
60
+ /**
61
+ * Helper for PATCH requests
62
+ */
63
+ patch(path: string, body: any, init?: RequestInit): Promise<Response>;
64
+ /**
65
+ * Helper for DELETE requests
66
+ */
67
+ delete(path: string, init?: RequestInit): Promise<Response>;
68
+ }
69
+ //# s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;IAQpB;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAGtE"}
@@ -0,0 +1,112 @@
1
+ import { alchemy } from "../alchemy.js";
2
+ /**
3
+ * Creates a VercelApi instance with automatic token validation
4
+ *
5
+ * @param options API options
6
+ * @returns Promise resolving to a VercelApi instance
7
+ */
8
+ export async function createVercelApi(options) {
9
+ const { accessToken = await alchemy.secret.env.VERCEL_ACCESS_TOKEN, baseUrl, } = options;
10
+ return new VercelApi({
11
+ baseUrl,
12
+ accessToken,
13
+ });
14
+ }
15
+ /**
16
+ * Vercel API client using raw fetch
17
+ */
18
+ export class VercelApi {
19
+ /** Base URL for API */
20
+ baseUrl;
21
+ /** API access token */
22
+ accessToken;
23
+ /**
24
+ * Create a new API client
25
+ * Use createVercelApi factory function instead of direct constructor
26
+ * for automatic token validation.
27
+ *
28
+ * @param options API options
29
+ */
30
+ constructor(options) {
31
+ this.baseUrl = options.baseUrl;
32
+ this.accessToken = options.accessToken;
33
+ }
34
+ /**
35
+ * Make a request to the API
36
+ *
37
+ * @param path API path (without base URL)
38
+ * @param init Fetch init options
39
+ * @returns Raw Response object from fetch
40
+ */
41
+ async fetch(path, init = {}) {
42
+ // Set up authentication headers
43
+ const headers = {
44
+ "Content-Type": "application/json",
45
+ Authorization: `Bearer ${this.accessToken.unencrypted}`,
46
+ };
47
+ // Add headers from init if provided
48
+ if (init.headers) {
49
+ const initHeaders = init.headers;
50
+ Object.keys(initHeaders).forEach((key) => {
51
+ headers[key] = initHeaders[key];
52
+ });
53
+ }
54
+ // For FormData, remove Content-Type
55
+ if (init.body instanceof FormData) {
56
+ delete headers["Content-Type"];
57
+ }
58
+ const response = await fetch(`${this.baseUrl}${path}`, {
59
+ ...init,
60
+ headers,
61
+ });
62
+ if (!response.ok) {
63
+ let error = new Error(`API error: ${response.statusText}`, {
64
+ cause: response,
65
+ });
66
+ try {
67
+ error = Object.assign(new Error(response.statusText, { cause: response }), (await response.json())?.error);
68
+ }
69
+ finally {
70
+ throw error;
71
+ }
72
+ }
73
+ return response;
74
+ }
75
+ /**
76
+ * Helper for GET requests
77
+ */
78
+ async get(path, init = {}) {
79
+ return this.fetch(path, { ...init, method: "GET" });
80
+ }
81
+ /**
82
+ * Helper for POST requests
83
+ */
84
+ async post(path, body, init = {}) {
85
+ const requestBody = body instanceof FormData ? body : JSON.stringify(body);
86
+ return this.fetch(path, { ...init, method: "POST", body: requestBody });
87
+ }
88
+ /**
89
+ * Helper for PUT requests
90
+ */
91
+ async put(path, body, init = {}) {
92
+ const requestBody = body instanceof FormData ? body : JSON.stringify(body);
93
+ return this.fetch(path, { ...init, method: "PUT", body: requestBody });
94
+ }
95
+ /**
96
+ * Helper for PATCH requests
97
+ */
98
+ async patch(path, body, init = {}) {
99
+ return this.fetch(path, {
100
+ ...init,
101
+ method: "PATCH",
102
+ body: JSON.stringify(body),
103
+ });
104
+ }
105
+ /**
106
+ * Helper for DELETE requests
107
+ */
108
+ async delete(path, init = {}) {
109
+ return this.fetch(path, { ...init, method: "DELETE" });
110
+ }
111
+ }
112
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/vercel/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAkBxC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAyB;IAEzB,MAAM,EACJ,WAAW,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAC1D,OAAO,GACR,GAAG,OAAO,CAAC;IAEZ,OAAO,IAAI,SAAS,CAAC;QACnB,OAAO;QACP,WAAW;KACZ,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,SAAS;IACpB,uBAAuB;IACd,OAAO,CAAS;IAEzB,uBAAuB;IACd,WAAW,CAAS;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AE,OAAO;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,OAAoB,EAAE;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzD,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export * from "./api.js";
2
+ export * from "./project-domain.js";
3
+ export * from "./project.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./api.js";
2
+ export * from "./project-domain.js";
3
+ export * from "./project.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,106 @@
1
+ import type { Context } from "../context.js";
2
+ import { Resource } from "../resource.js";
3
+ import type { Secret } from "../secret.js";
4
+ /**
5
+ * Properties for creating or updating a ProjectDomain
6
+ */
7
+ export interface ProjectDomainProps {
8
+ /**
9
+ * The domain name to add to the project
10
+ */
11
+ name: string;
12
+ /**
13
+ * The unique project identifier or the project name
14
+ */
15
+ project: string;
16
+ /**
17
+ * The Git branch to link the domain to
18
+ */
19
+ gitBranch?: string;
20
+ /**
21
+ * The unique custom environment identifier within the project
22
+ */
23
+ customEnvironment?: string;
24
+ /**
25
+ * The redirect target for the domain
26
+ */
27
+ redirect?: string;
28
+ /**
29
+ * The redirect status code
30
+ */
31
+ redirectStatusCode?: 301 | 302 | 307 | 308;
32
+ }
33
+ /**
34
+ * Output returned after ProjectDomain creation/update
35
+ */
36
+ export interface ProjectDomain extends Resource<"vercel::ProjectDomain">, ProjectDomainProps {
37
+ apexName: string;
38
+ /**
39
+ * `true` if the domain is verified for use with the project. If `false` it will not be used as an alias on this project until the challenge in `verification` is completed.
40
+ */
41
+ verified: boolean;
42
+ /**
43
+ * The time at which the domain was created
44
+ */
45
+ createdAt: number;
46
+ /**
47
+ * The time at which the domain was last updated
48
+ */
49
+ updatedAt: number;
50
+ /**
51
+ * A list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete `POST /projects/:idOrName/domains/:domain/verify` to verify the domain.
52
+ *
53
+ * Possible challenges:
54
+ * - If `verification.type = TXT` the `verification.domain` will be checked for a TXT record matching `verification.value`.
55
+ */
56
+ verification?: {
57
+ /**
58
+ * The type of verification
59
+ */
60
+ type: string;
61
+ /**
62
+ * The domain being verified
63
+ */
64
+ domain: string;
65
+ /**
66
+ * The verification value
67
+ */
68
+ value: string;
69
+ /**
70
+ * The reason for verification
71
+ */
72
+ reason: string;
73
+ }[];
74
+ }
75
+ /**
76
+ * Add and manage domains for Vercel projects.
77
+ *
78
+ * @example
79
+ * // Minimal
80
+ * const domain = await ProjectDomain("my-app.com", {
81
+ * name: "my-app.com",
82
+ * project: "prj_123",
83
+ * });
84
+ *
85
+ * @example
86
+ * // With accessToken
87
+ * const domain = await ProjectDomain("my-app.com", {
88
+ * accessToken: alchemy.secret(process.env.VERCEL_ACCESS_TOKEN),
89
+ * name: "my-app.com",
90
+ * project: "prj_123",
91
+ * });
92
+ *
93
+ * @example
94
+ * // With redirect
95
+ * const domain = await ProjectDomain("my-app.com", {
96
+ * name: "my-app.com",
97
+ * project: "prj_123",
98
+ * gitBranch: "main",
99
+ * redirect: "https://example.com",
100
+ * redirectStatusCode: 301,
101
+ * });
102
+ */
103
+ export declare const ProjectDomain: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<ProjectDomain>, id: string, { accessToken, ...props }: ProjectDomainProps & {
104
+ accessToken?: Secret;
105
+ }) => Promise<ProjectDomain>);
106
+ //# sourceMappingURL=project-domain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-domain.d.ts","sourceRoot":"","sources":["../../src/vercel/project-domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,kBAAkB,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,aACf,SAAQ,QAAQ,CAAC,uBAAuB,CAAC,EACvC,kBAAkB;IACpB,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,YAAY,CAAC,EAAE;QACb;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;QAEf;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;CACL;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,aAAa,yFAGhB,OAAO,CAAC,aAAa,CAAC,MACxB,MAAM,6BACiB,kBAAkB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,KACvE,OAAO,CAAC,aAAa,CAAC,CA6C1B,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { Resource } from "../resource.js";
2
+ import { createVercelApi } from "./api.js";
3
+ /**
4
+ * Add and manage domains for Vercel projects.
5
+ *
6
+ * @example
7
+ * // Minimal
8
+ * const domain = await ProjectDomain("my-app.com", {
9
+ * name: "my-app.com",
10
+ * project: "prj_123",
11
+ * });
12
+ *
13
+ * @example
14
+ * // With accessToken
15
+ * const domain = await ProjectDomain("my-app.com", {
16
+ * accessToken: alchemy.secret(process.env.VERCEL_ACCESS_TOKEN),
17
+ * name: "my-app.com",
18
+ * project: "prj_123",
19
+ * });
20
+ *
21
+ * @example
22
+ * // With redirect
23
+ * const domain = await ProjectDomain("my-app.com", {
24
+ * name: "my-app.com",
25
+ * project: "prj_123",
26
+ * gitBranch: "main",
27
+ * redirect: "https://example.com",
28
+ * redirectStatusCode: 301,
29
+ * });
30
+ */
31
+ export const ProjectDomain = Resource("vercel::ProjectDomain", async function (id, { accessToken, ...props }) {
32
+ switch (this.phase) {
33
+ case "create": {
34
+ const api = await createVercelApi({
35
+ baseUrl: "https://api.vercel.com/v10",
36
+ accessToken,
37
+ });
38
+ const domain = (await api
39
+ .post(`/projects/${props.project}/domains`, props)
40
+ .then((res) => res.json()));
41
+ return this.create({ ...props, ...domain });
42
+ }
43
+ case "update": {
44
+ const { gitBranch, redirect, redirectStatusCode } = props;
45
+ const api = await createVercelApi({
46
+ baseUrl: "https://api.vercel.com/v9",
47
+ accessToken,
48
+ });
49
+ const domain = (await api
50
+ .patch(`/projects/${props.project}/domains/${this.output.name}`, {
51
+ gitBranch,
52
+ redirect,
53
+ redirectStatusCode,
54
+ })
55
+ .then((res) => res.json()));
56
+ return this.create({ ...props, ...domain });
57
+ }
58
+ case "delete": {
59
+ const api = await createVercelApi({
60
+ baseUrl: "https://api.vercel.com/v9",
61
+ accessToken,
62
+ });
63
+ await api.delete(`/projects/${props.project}/domains/${this.output.name}`);
64
+ return this.destroy();
65
+ }
66
+ }
67
+ });
68
+ //# sourceMappingURL=project-domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-domain.js","sourceRoot":"","sources":["../../src/vercel/project-domain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAyF3C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CACnC,uBAAuB,EACvB,KAAK,WAEH,EAAU,EACV,EAAE,WAAW,EAAE,GAAG,KAAK,EAAiD;IAExE,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;QACnB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC;gBAChC,OAAO,EAAE,4BAA4B;gBACrC,WAAW;aACZ,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG;iBACtB,IAAI,CAAC,aAAa,KAAK,CAAC,OAAO,UAAU,EAAE,KAAK,CAAC;iBACjD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAkB,CAAC;YAE/C,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;QAC9C,CAAC;QAED,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;YAE1D,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC;gBAChC,OAAO,EAAE,2BAA2B;gBACpC,WAAW;aACZ,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG;iBACtB,KAAK,CAAC,aAAa,KAAK,CAAC,OAAO,YAAY,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE;gBAC/D,SAAS;gBACT,QAAQ;gBACR,kBAAkB;aACnB,CAAC;iBACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAkB,CAAC;YAE/C,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;QAC9C,CAAC;QAED,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC;gBAChC,OAAO,EAAE,2BAA2B;gBACpC,WAAW;aACZ,CAAC,CAAC;YACH,MAAM,GAAG,CAAC,MAAM,CACd,aAAa,KAAK,CAAC,OAAO,YAAY,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CACzD,CAAC;YAEF,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,272 @@
1
+ import type { Context } from "../context.js";
2
+ import { Resource } from "../resource.js";
3
+ import { type Secret } from "../secret.js";
4
+ import { type VercelApi } from "./api.js";
5
+ type TargetEnvironment = "production" | "preview" | "development";
6
+ export type EnvironmentVariable = {
7
+ /**
8
+ * The key of the environment variable
9
+ */
10
+ key: string;
11
+ /**
12
+ * The target environment
13
+ */
14
+ target: TargetEnvironment[];
15
+ /**
16
+ * The Git branch
17
+ */
18
+ gitBranch?: string;
19
+ /**
20
+ * The type of environment variable.
21
+ *
22
+ * Defaults to `plain` when `value` is a `string`, and `encrypted` when `value` is a `Secret`.
23
+ */
24
+ type?: "encrypted" | "plain" | "sensitive";
25
+ /**
26
+ * The value of the environment variable
27
+ */
28
+ value: Secret | string;
29
+ } & ({
30
+ type?: "plain" | "system";
31
+ value: string;
32
+ } | {
33
+ type?: "encrypted" | "sensitive";
34
+ value: Secret;
35
+ });
36
+ /**
37
+ * Properties for creating or updating a Project
38
+ */
39
+ export interface ProjectProps {
40
+ /**
41
+ * The desired name for the project
42
+ *
43
+ * Maximum length: `100`
44
+ * Example: `a-project-name`
45
+ */
46
+ name: string;
47
+ /**
48
+ * Opt-in to preview toolbar on the project level
49
+ */
50
+ enablePreviewFeedback?: boolean;
51
+ /**
52
+ * Opt-in to production toolbar on the project level
53
+ */
54
+ enableProductionFeedback?: boolean;
55
+ /**
56
+ * The build command for this project. When `null` is used this value will be automatically detected
57
+ */
58
+ buildCommand?: string;
59
+ commandForIgnoringBuildStep?: string;
60
+ /**
61
+ * The dev command for this project. When `null` is used this value will be automatically detected
62
+ */
63
+ devCommand?: string;
64
+ /**
65
+ * Collection of ENV Variables the Project will use
66
+ */
67
+ environmentVariables?: Array<EnvironmentVariable>;
68
+ /**
69
+ * The framework that is being used for this project. When `null` is used no framework is selected
70
+ */
71
+ framework?: "blitzjs" | "nextjs" | "gatsby" | "remix" | "react-router" | "astro" | "hexo" | "eleventy" | "docusaurus-2" | "docusaurus" | "preact" | "solidstart-1" | "solidstart" | "dojo" | "ember" | "vue" | "scully" | "ionic-angular" | "angular" | "polymer" | "svelte" | "sveltekit" | "sveltekit-1" | "ionic-react" | "create-react-app" | "gridsome" | "umijs" | "sapper" | "saber" | "stencil" | "nuxtjs" | "redwoodjs" | "hugo" | "jekyll" | "brunch" | "middleman" | "zola" | "hydrogen" | "vite" | "vitepress" | "vuepress" | "parcel" | "fasthtml" | "sanity-v3" | "sanity" | "storybook" | (string & {});
72
+ /**
73
+ * The Git Repository that will be connected to the project. When this is defined, any pushes to the specified connected Git Repository will be automatically deployed
74
+ */
75
+ gitRepository?: {
76
+ /**
77
+ * The Git Provider of the repository
78
+ */
79
+ type: "github" | "gitlab" | "bitbucket";
80
+ /**
81
+ * The name of the git repository. For example: `vercel/next.js`
82
+ */
83
+ repo: string;
84
+ };
85
+ /**
86
+ * The install command for this project. When `null` is used this value will be automatically detected
87
+ */
88
+ installCommand?: string;
89
+ /**
90
+ * The output directory of the build. When `null` is used this value will be automatically detected
91
+ */
92
+ outputDirectory?: string;
93
+ /**
94
+ * Specifies whether the source code and logs of the deployments for this project should be public or not
95
+ */
96
+ publicSource?: boolean;
97
+ /**
98
+ * The name of a directory or relative path to the source code of your project. When `null` is used it will default to the project root
99
+ */
100
+ rootDirectory?: string;
101
+ /**
102
+ * The region to deploy Serverless Functions in this project
103
+ */
104
+ serverlessFunctionRegion?: string;
105
+ /**
106
+ * Specifies whether Zero Config Failover is enabled for this project.
107
+ */
108
+ serverlessFunctionZeroConfigFailover?: boolean;
109
+ /**
110
+ * OpenID Connect JSON Web Token generation configuration.
111
+ */
112
+ oidcTokenConfig?: {
113
+ /**
114
+ * Whether or not to generate OpenID Connect JSON Web Tokens.
115
+ */
116
+ enabled: boolean;
117
+ /**
118
+ * team: `https://oidc.vercel.com/[team_slug]` global: `https://oidc.vercel.com`
119
+ */
120
+ issuerMode: "team" | "global";
121
+ };
122
+ /**
123
+ * Opt-in to skip deployments when there are no changes to the root directory and its dependencies
124
+ */
125
+ enableAffectedProjectsDeployments?: boolean;
126
+ /**
127
+ * Resource configuration
128
+ */
129
+ resourceConfig?: {
130
+ /**
131
+ * Whether fluid is enabled
132
+ */
133
+ fluid?: boolean;
134
+ /**
135
+ * Default regions for functions
136
+ */
137
+ functionDefaultRegions?: string[];
138
+ /**
139
+ * Default timeout for functions
140
+ */
141
+ functionDefaultTimeout?: number;
142
+ /**
143
+ * Default memory type for functions
144
+ */
145
+ functionDefaultMemoryType?: "standard_legacy" | "standard" | "performance";
146
+ /**
147
+ * Whether function zero config failover is enabled
148
+ */
149
+ functionZeroConfigFailover?: boolean;
150
+ /**
151
+ * Whether elastic concurrency is enabled
152
+ */
153
+ elasticConcurrencyEnabled?: boolean;
154
+ /**
155
+ * The build machine type
156
+ */
157
+ buildMachineType?: "enhanced" | "ultra";
158
+ };
159
+ }
160
+ /**
161
+ * Output returned after Project creation/update
162
+ */
163
+ export interface Project extends Resource<"vercel::Project">, ProjectProps {
164
+ /**
165
+ * The ID of the project
166
+ */
167
+ id: string;
168
+ /**
169
+ * The account ID that the project belongs to
170
+ */
171
+ accountId: string;
172
+ /**
173
+ * The time at which the project was created
174
+ */
175
+ createdAt: number;
176
+ /**
177
+ * The time at which the project was last updated
178
+ */
179
+ updatedAt: number;
180
+ /**
181
+ * The latest deployment of the project
182
+ */
183
+ latestDeployment?: {
184
+ /**
185
+ * The ID of the deployment
186
+ */
187
+ id: string;
188
+ /**
189
+ * The URL of the deployment
190
+ */
191
+ url: string;
192
+ };
193
+ }
194
+ /**
195
+ * Create and manage Vercel projects.
196
+ *
197
+ * @example
198
+ * // With accessToken
199
+ * const project = await Project("my-app", {
200
+ * accessToken: alchemy.secret(process.env.VERCEL_ACCESS_TOKEN),
201
+ * name: "my-app",
202
+ * framework: "astro",
203
+ * });
204
+ *
205
+ * @example
206
+ * // With GitHub
207
+ * const project = await Project("my-app", {
208
+ * name: "my-app",
209
+ * framework: "nextjs",
210
+ * gitRepository: {
211
+ * type: "github",
212
+ * repo: "username/my-app",
213
+ * },
214
+ * });
215
+ *
216
+ * @example
217
+ * // With plain text environment variable
218
+ * const project = await Project("my-app", {
219
+ * name: "my-app",
220
+ * environmentVariables: [
221
+ * {
222
+ * key: "PUBLIC_URL",
223
+ * target: ["production", "preview", "development"],
224
+ * value: "https://example.com",
225
+ * },
226
+ * ],
227
+ * });
228
+ *
229
+ * @example
230
+ * // With encrypted environment variable
231
+ * const project = await Project("my-app", {
232
+ * name: "my-app",
233
+ * environmentVariables: [
234
+ * {
235
+ * key: "DATABASE_URL",
236
+ * target: ["production", "preview"],
237
+ * value: alchemy.secret("DATABASE_URL"),
238
+ * },
239
+ * ],
240
+ * });
241
+ *
242
+ * @example
243
+ * // With sensitive environment variable
244
+ * const project = await Project("my-app", {
245
+ * name: "my-app",
246
+ * environmentVariables: [
247
+ * {
248
+ * key: "DATABASE_URL",
249
+ * target: ["production", "preview"],
250
+ * type: "sensitive",
251
+ * value: alchemy.secret("DATABASE_URL"),
252
+ * },
253
+ * ],
254
+ * });
255
+ *
256
+ * @example
257
+ * // With custom build settings
258
+ * const project = await Project("my-app", {
259
+ * name: "my-app",
260
+ * buildCommand: "npm run build",
261
+ * outputDirectory: "dist",
262
+ * installCommand: "npm install",
263
+ * devCommand: "npm run dev",
264
+ * });
265
+ */
266
+ export declare const Project: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Project>, id: string, { accessToken, ...props }: ProjectProps & {
267
+ accessToken?: Secret;
268
+ }) => Promise<Project>);
269
+ export declare function createProject(api: VercelApi, props: ProjectProps): Promise<Project>;
270
+ export declare function updateEnvironmentVariables(api: VercelApi, output: Project, props: ProjectProps): Promise<void>;
271
+ export {};
272
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/vercel/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE3D,KAAK,iBAAiB,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAE5B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,GAAG,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