alchemy 0.16.7 → 0.16.9

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,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":"","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,SAAS,EACd,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,YAAY,iBA8BpB"}
@@ -0,0 +1,170 @@
1
+ import { Resource } from "../resource.js";
2
+ import { isSecret } from "../secret.js";
3
+ import { createVercelApi } from "./api.js";
4
+ const decryptEnvironmentVariable = (envVar) => {
5
+ let { type, value } = envVar;
6
+ // Decrypt Secret & default `type`
7
+ if (isSecret(value)) {
8
+ value = value.unencrypted;
9
+ type ??= "encrypted";
10
+ }
11
+ else {
12
+ // Otherwise, default to `plain`
13
+ type ??= "plain";
14
+ }
15
+ return { ...envVar, type, value };
16
+ };
17
+ /**
18
+ * Create and manage Vercel projects.
19
+ *
20
+ * @example
21
+ * // With accessToken
22
+ * const project = await Project("my-app", {
23
+ * accessToken: alchemy.secret(process.env.VERCEL_ACCESS_TOKEN),
24
+ * name: "my-app",
25
+ * framework: "astro",
26
+ * });
27
+ *
28
+ * @example
29
+ * // With GitHub
30
+ * const project = await Project("my-app", {
31
+ * name: "my-app",
32
+ * framework: "nextjs",
33
+ * gitRepository: {
34
+ * type: "github",
35
+ * repo: "username/my-app",
36
+ * },
37
+ * });
38
+ *
39
+ * @example
40
+ * // With plain text environment variable
41
+ * const project = await Project("my-app", {
42
+ * name: "my-app",
43
+ * environmentVariables: [
44
+ * {
45
+ * key: "PUBLIC_URL",
46
+ * target: ["production", "preview", "development"],
47
+ * value: "https://example.com",
48
+ * },
49
+ * ],
50
+ * });
51
+ *
52
+ * @example
53
+ * // With encrypted environment variable
54
+ * const project = await Project("my-app", {
55
+ * name: "my-app",
56
+ * environmentVariables: [
57
+ * {
58
+ * key: "DATABASE_URL",
59
+ * target: ["production", "preview"],
60
+ * value: alchemy.secret("DATABASE_URL"),
61
+ * },
62
+ * ],
63
+ * });
64
+ *
65
+ * @example
66
+ * // With sensitive environment variable
67
+ * const project = await Project("my-app", {
68
+ * name: "my-app",
69
+ * environmentVariables: [
70
+ * {
71
+ * key: "DATABASE_URL",
72
+ * target: ["production", "preview"],
73
+ * type: "sensitive",
74
+ * value: alchemy.secret("DATABASE_URL"),
75
+ * },
76
+ * ],
77
+ * });
78
+ *
79
+ * @example
80
+ * // With custom build settings
81
+ * const project = await Project("my-app", {
82
+ * name: "my-app",
83
+ * buildCommand: "npm run build",
84
+ * outputDirectory: "dist",
85
+ * installCommand: "npm install",
86
+ * devCommand: "npm run dev",
87
+ * });
88
+ */
89
+ export const Project = Resource("vercel::Project", async function (id, { accessToken, ...props }) {
90
+ switch (this.phase) {
91
+ case "delete": {
92
+ const api = await createVercelApi({
93
+ baseUrl: "https://api.vercel.com/v9",
94
+ accessToken,
95
+ });
96
+ try {
97
+ if (this.output?.id) {
98
+ await api.delete(`/projects/${this.output.id}`);
99
+ }
100
+ }
101
+ catch (error) {
102
+ console.error("Error deleting project:", error);
103
+ }
104
+ return this.destroy();
105
+ }
106
+ case "update": {
107
+ const api = await createVercelApi({
108
+ baseUrl: "https://api.vercel.com/v9",
109
+ accessToken,
110
+ });
111
+ if (!this.output?.id) {
112
+ throw new Error(`Cannot update project ${id}: missing previous output.id`);
113
+ }
114
+ // 409 Conflict: Can't update name, so remove it from the props
115
+ // 400 Invalid Request: Should NOT have additional property `environmentVariables`
116
+ const { name, environmentVariables, ...rest } = props;
117
+ const response = await api.patch(`/projects/${this.output.id}`, rest);
118
+ const data = (await response.json());
119
+ if (environmentVariables) {
120
+ const envApi = await createVercelApi({
121
+ baseUrl: "https://api.vercel.com/v10",
122
+ accessToken,
123
+ });
124
+ await updateEnvironmentVariables(envApi, this.output, props);
125
+ }
126
+ return this({
127
+ id: data.id,
128
+ accountId: data.accountId,
129
+ createdAt: data.createdAt,
130
+ updatedAt: data.updatedAt,
131
+ latestDeployment: data.latestDeployment,
132
+ ...props,
133
+ });
134
+ }
135
+ case "create": {
136
+ const api = await createVercelApi({
137
+ baseUrl: "https://api.vercel.com/v11",
138
+ accessToken,
139
+ });
140
+ const project = await createProject(api, props);
141
+ return this.create({ ...props, ...project });
142
+ }
143
+ }
144
+ });
145
+ export async function createProject(api, props) {
146
+ const response = await api.post("/projects", {
147
+ ...props,
148
+ environmentVariables: props.environmentVariables?.map(decryptEnvironmentVariable),
149
+ });
150
+ const data = (await response.json());
151
+ return data;
152
+ }
153
+ export async function updateEnvironmentVariables(api, output, props) {
154
+ if (!props.environmentVariables) {
155
+ return;
156
+ }
157
+ // Update explicitly set environment variables
158
+ await api.post(`/projects/${output.id}/env?upsert=true`, props.environmentVariables.map(decryptEnvironmentVariable));
159
+ // Find previous env vars that are not in the new list and delete them
160
+ const { envs } = (await api
161
+ .get(`/projects/${output.id}/env`)
162
+ .then((res) => res.json()));
163
+ for (const previousEnv of envs) {
164
+ if (props.environmentVariables.some((envVar) => envVar.key === previousEnv.key)) {
165
+ continue;
166
+ }
167
+ await api.delete(`/projects/${output.id}/env/${previousEnv.id}`);
168
+ }
169
+ }
170
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/vercel/project.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAe,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,eAAe,EAAkB,MAAM,UAAU,CAAC;AAiR3D,MAAM,0BAA0B,GAAG,CAAC,MAA2B,EAAE,EAAE;IACjE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAE7B,kCAAkC;IAClC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;QAC1B,IAAI,KAAK,WAAW,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,gCAAgC;QAChC,IAAI,KAAK,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;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AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,GAAc,EACd,MAAe,EACf,KAAmB;IAEnB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAChC,OAAO;IACT,CAAC;IAED,8CAA8C;IAC9C,MAAM,GAAG,CAAC,IAAI,CACZ,aAAa,MAAM,CAAC,EAAE,kBAAkB,EACxC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAC3D,CAAC;IAEF,sEAAsE;IACtE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,GAAG;SACxB,GAAG,CAAC,aAAa,MAAM,CAAC,EAAE,MAAM,CAAC;SACjC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAE3B,CAAC;IAEF,KAAK,MAAM,WAAW,IAAI,IAAI,EAAE,CAAC;QAC/B,IACE,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAC7B,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,KAAK,WAAW,CAAC,GAAG,CAC3C,EACD,CAAC;YACD,SAAS;QACX,CAAC;QAED,MAAM,GAAG,CAAC,MAAM,CAAC,aAAa,MAAM,CAAC,EAAE,QAAQ,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemy",
3
- "version": "0.16.7",
3
+ "version": "0.16.9",
4
4
  "type": "module",
5
5
  "module": "./lib/index.js",
6
6
  "scripts": {
@@ -28,6 +28,7 @@
28
28
  "./stripe": "./lib/stripe/index.js",
29
29
  "./test/bun": "./lib/test/bun.js",
30
30
  "./upstash": "./lib/upstash/index.js",
31
+ "./vercel": "./lib/vercel/index.js",
31
32
  "./web/astro": "./lib/web/astro/index.js",
32
33
  "./web/tailwind": "./lib/web/tailwind/index.js",
33
34
  "./web/vite": "./lib/web/vite/index.js",
@@ -151,6 +151,34 @@ export const VectorizeIndex = Resource(
151
151
  }
152
152
  }
153
153
  } else {
154
+ if (props.delete !== this.props.delete) {
155
+ // Only allow changing the delete property
156
+ if (!this.quiet) {
157
+ console.warn(
158
+ `Attempted to update Vectorize index ${indexName} but only the delete property can be changed.`,
159
+ );
160
+ }
161
+ return this({
162
+ ...this.output,
163
+ delete: props.delete,
164
+ });
165
+ }
166
+
167
+ // Check if this is a no-op update
168
+ if (
169
+ props.name === this.props.name &&
170
+ props.description === this.props.description &&
171
+ props.dimensions === this.props.dimensions &&
172
+ props.metric === this.props.metric
173
+ ) {
174
+ if (!this.quiet) {
175
+ console.warn(
176
+ `Attempted to update Vectorize index ${indexName} but it was a no-op.`,
177
+ );
178
+ }
179
+ return this(this.output);
180
+ }
181
+
154
182
  // Update operation is not supported by Vectorize API
155
183
  throw new Error(
156
184
  "Updating Vectorize indexes is not supported by the Cloudflare API. " +
@@ -107,6 +107,20 @@ export const VectorizeMetadataIndex = Resource(
107
107
  return this.destroy();
108
108
  }
109
109
  if (this.phase === "update") {
110
+ if (
111
+ props.email === this.props.email &&
112
+ props.index?.id === this.props.index?.id &&
113
+ props.propertyName === this.props.propertyName &&
114
+ props.indexType === this.props.indexType
115
+ ) {
116
+ // Update operation is not supported
117
+ if (!this.scope.quiet) {
118
+ console.warn(
119
+ `Attempted to update Vectorize metadata index ${this.props.propertyName} but it was a no-op.`,
120
+ );
121
+ }
122
+ return this(this.output);
123
+ }
110
124
  // Update operation is not supported
111
125
  throw new Error(
112
126
  "Updating Vectorize metadata indexes is not supported by the Cloudflare API. " +
package/src/context.ts CHANGED
@@ -87,6 +87,7 @@ export function context<
87
87
  seq,
88
88
  state,
89
89
  replace,
90
+ props,
90
91
  }: {
91
92
  scope: Scope;
92
93
  phase: "create" | "update" | "delete";
@@ -130,7 +131,7 @@ export function context<
130
131
  fqn: fqn,
131
132
  phase,
132
133
  output: state.output,
133
- props: state.props,
134
+ props,
134
135
  replace,
135
136
  get: (key: string) => state.data[key],
136
137
  set: async (key: string, value: any) => {