@samebase/alchemy-convex 0.3.0 → 0.4.1

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/lib/index.d.ts CHANGED
@@ -1,14 +1,12 @@
1
- import { Resource } from "alchemy";
2
- import * as Provider from "alchemy/Provider";
1
+ import * as Context from "effect/Context";
3
2
  import * as Effect from "effect/Effect";
4
- import "effect/process/ChildProcessSpawner";
3
+ import * as Layer from "effect/Layer";
5
4
  import * as Redacted from "effect/Redacted";
6
5
  import * as Schema from "effect/Schema";
6
+ import { Resource } from "alchemy";
7
+ import * as Provider from "alchemy/Provider";
8
+ import "effect/process/ChildProcessSpawner";
7
9
  import { createDeploymentClient, createManagementClient } from "@convex-dev/platform";
8
- import * as Context from "effect/Context";
9
- import * as Layer from "effect/Layer";
10
- import { CommandExecutor, CommandRunProps } from "alchemy/Command";
11
- import { MemoOptions } from "alchemy/Command/Memo";
12
10
  import { components } from "@convex-dev/platform/managementApi";
13
11
  //#region src/Credentials.d.ts
14
12
  interface ResolvedCredentials {
@@ -17,23 +15,38 @@ interface ResolvedCredentials {
17
15
  /** Where the token came from, for error messages only. */
18
16
  readonly source: "env" | "explicit" | "convex-cli-login";
19
17
  }
20
- declare const Credentials_base: Context.ServiceClass<Credentials, "@samebase/alchemy-convex/Credentials", Effect.Effect<ResolvedCredentials, never, never>>;
21
- declare class Credentials extends Credentials_base {}
22
- /** Environment variable read by {@link fromConfig}. */
23
- declare const ACCESS_TOKEN_ENV = "CONVEX_ACCESS_TOKEN";
18
+ interface CredentialsService {
19
+ /** The Management API token. Dies when there is none. */
20
+ readonly accessToken: Effect.Effect<ResolvedCredentials>;
21
+ /** True when there is a Management API token. */
22
+ readonly hasAccessToken: Effect.Effect<boolean>;
23
+ /** A deploy key or a preview deploy key, or undefined. */
24
+ readonly deployKey: Effect.Effect<Redacted.Redacted<string> | undefined>;
25
+ }
26
+ declare const Credentials_base: Context.ServiceClass<Credentials, "@samebase/alchemy-convex/Credentials", CredentialsService>;
27
+ export declare class Credentials extends Credentials_base {}
28
+ /** Environment variable for the access token, read by {@link fromConfig}. */
29
+ export declare const ACCESS_TOKEN_ENV = "CONVEX_ACCESS_TOKEN";
30
+ /** Environment variable for the deploy key, read by {@link fromConfig}. The Convex CLI reads the same name. */
31
+ export declare const DEPLOY_KEY_ENV = "CONVEX_DEPLOY_KEY";
24
32
  declare const CredentialsError_base: Schema.Class<CredentialsError, Schema.TaggedStruct<"CredentialsError", {
25
33
  readonly reason: Schema.String;
26
34
  }>, import("effect/Cause").YieldableError>;
27
- declare class CredentialsError extends CredentialsError_base {}
35
+ export declare class CredentialsError extends CredentialsError_base {}
28
36
  /**
29
- * Default resolution: `CONVEX_ACCESS_TOKEN` from the stack ConfigProvider
30
- * (process env, `.env`, stack secrets), then the Convex CLI login on this
31
- * machine. CI sets the variable; a developer who ran `npx convex login` needs
32
- * nothing.
37
+ * Default resolution through the stack ConfigProvider (process env, `.env`,
38
+ * stack secrets): `CONVEX_ACCESS_TOKEN`, then the Convex CLI login on this
39
+ * machine, for the access token; `CONVEX_DEPLOY_KEY` for the deploy key. A
40
+ * developer who ran `npx convex login` needs nothing. CI sets only the
41
+ * deploy key when the stack pushes to deployments that exist, and the access
42
+ * token when the stack also creates projects or deployments.
33
43
  */
34
- declare const fromConfig: () => Layer.Layer<Credentials>;
35
- /** Explicit token, for tests or callers that already hold a value. */
36
- declare const fromToken: (accessToken: Redacted.Redacted<string>) => Layer.Layer<Credentials>;
44
+ export declare const fromConfig: () => Layer.Layer<Credentials>;
45
+ /** Explicit values, for tests or callers that already hold them. */
46
+ export declare const fromValues: (values: {
47
+ readonly accessToken?: Redacted.Redacted<string>;
48
+ readonly deployKey?: Redacted.Redacted<string>;
49
+ }) => Layer.Layer<Credentials>;
37
50
  //#endregion
38
51
  //#region src/ManagementApi.d.ts
39
52
  type ManagementClient = ReturnType<typeof createManagementClient>;
@@ -55,7 +68,7 @@ declare const ConvexApiError_base: Schema.Class<ConvexApiError, Schema.TaggedStr
55
68
  * `status` (404 means absent for read and delete), so the class is load
56
69
  * bearing, not decorative.
57
70
  */
58
- declare class ConvexApiError extends ConvexApiError_base {}
71
+ export declare class ConvexApiError extends ConvexApiError_base {}
59
72
  interface ManagementApiService {
60
73
  /** Run one management call with the resolved credentials. */
61
74
  readonly request: <T>(operation: string, run: (client: ManagementClient) => Promise<FetchResult<T>>) => Effect.Effect<T, ConvexApiError>;
@@ -73,154 +86,63 @@ interface ManagementApiService {
73
86
  * that key would revoke the credential.
74
87
  */
75
88
  readonly isCredentialToken: (secret: string) => Effect.Effect<boolean>;
89
+ /**
90
+ * The same calls with another bearer token, such as a preview deploy key,
91
+ * which the Management API takes for the preview deployments of its project.
92
+ */
93
+ readonly withToken: (token: Redacted.Redacted<string>) => ManagementApiService;
76
94
  }
77
95
  declare const ManagementApi_base: Context.ServiceClass<ManagementApi, "@samebase/alchemy-convex/ManagementApi", ManagementApiService>;
78
- declare class ManagementApi extends ManagementApi_base {}
96
+ export declare class ManagementApi extends ManagementApi_base {}
79
97
  //#endregion
80
98
  //#region src/Providers.d.ts
81
99
  declare const Providers_base: Provider.ProviderCollection<Providers, "Convex">;
82
- declare class Providers extends Providers_base {}
100
+ export declare class Providers extends Providers_base {}
83
101
  /**
84
- * All Convex resource providers. Pass a credentials layer to override the
85
- * default lookup (`CONVEX_ACCESS_TOKEN`, then the Convex CLI login).
102
+ * The Convex resource providers. Pass a credentials layer to override the
103
+ * default lookup (`CONVEX_ACCESS_TOKEN`, then the Convex CLI login, and
104
+ * `CONVEX_DEPLOY_KEY`).
86
105
  */
87
- declare const providers: (credentials?: Layer.Layer<Credentials>) => Layer.Layer<Providers, never, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
88
- //#endregion
89
- //#region src/Deployment.d.ts
90
- type DeploymentProps = {
91
- /** Numeric project id, such as `project.projectId`. Cannot change. */
92
- readonly projectId: number;
93
- /** The project's default production deployment. Cannot change. */
94
- readonly type: "prod";
95
- } | {
96
- /** Numeric project id, such as `project.projectId`. Cannot change. */
97
- readonly projectId: number;
98
- /** A dev deployment or a preview deployment that this resource creates. Cannot change. */
99
- readonly type: "dev" | "preview";
100
- /**
101
- * The dev reference, such as `staging`, or the preview name, such as a
102
- * pull request or stage name. Unique in the project. Cannot change.
103
- */
104
- readonly name: string;
105
- };
106
- interface DeploymentAttributes {
107
- readonly projectId: number;
108
- readonly type: DeploymentProps["type"];
109
- /** Deployment name, such as `happy-animal-123`. */
110
- readonly name: string;
111
- /** The reference that Convex lists, such as `production`, `staging`, or `preview/pr-42`. */
112
- readonly reference: string;
113
- /** The preview name of a preview deployment. Undefined for prod and dev. */
114
- readonly previewName: string | undefined;
115
- /** Client URL, such as `https://happy-animal-123.convex.cloud`. */
116
- readonly url: string;
117
- /** HTTP actions URL, such as `https://happy-animal-123.convex.site`. */
118
- readonly siteUrl: string;
119
- }
120
- type Deployment = Resource<"Convex.Deployment", DeploymentProps, DeploymentAttributes, never, Providers>;
121
- declare const Deployment: import("alchemy").ResourceClass<Deployment>;
122
- declare const DeploymentIdentityChange_base: Schema.Class<DeploymentIdentityChange, Schema.TaggedStruct<"DeploymentIdentityChange", {
123
- /** Name of the deployment in state, such as `happy-animal-123`. */
124
- readonly deployment: Schema.String;
125
- readonly field: Schema.Literals<readonly ["projectId", "type", "name"]>;
126
- readonly current: Schema.String;
127
- readonly requested: Schema.String;
128
- }>, import("effect/Cause").YieldableError>;
129
- /** The props name another deployment than the one in state. */
130
- declare class DeploymentIdentityChange extends DeploymentIdentityChange_base {
131
- get message(): string;
132
- }
133
- declare const ProductionDeploymentNotFound_base: Schema.Class<ProductionDeploymentNotFound, Schema.TaggedStruct<"ProductionDeploymentNotFound", {
134
- readonly projectId: Schema.Number;
135
- }>, import("effect/Cause").YieldableError>;
136
- /** The project has no default production deployment for a `prod` resource to take over. */
137
- declare class ProductionDeploymentNotFound extends ProductionDeploymentNotFound_base {
138
- get message(): string;
139
- }
140
- declare const AmbiguousDeployment_base: Schema.Class<AmbiguousDeployment, Schema.TaggedStruct<"AmbiguousDeployment", {
141
- readonly projectId: Schema.Number;
142
- readonly type: Schema.Literals<readonly ["dev", "preview"]>;
143
- readonly name: Schema.String;
144
- readonly deployments: Schema.$Array<Schema.String>;
145
- }>, import("effect/Cause").YieldableError>;
146
- /** More than one deployment of the project has the name, so the lookup cannot choose one. */
147
- declare class AmbiguousDeployment extends AmbiguousDeployment_base {
148
- get message(): string;
149
- }
106
+ export declare const providers: (credentials?: Layer.Layer<Credentials>) => Layer.Layer<Providers, never, import("effect/FileSystem").FileSystem | import("effect/Path").Path | import("effect/process/ChildProcessSpawner").ChildProcessSpawner>;
150
107
  //#endregion
151
- //#region src/Code.d.ts
152
- /** The attributes of a Convex.Deployment that a push needs. Pass the resource itself. */
153
- type CodeDeployment = Pick<DeploymentAttributes, "name" | "type" | "url" | "previewName">;
154
- interface CodeProps {
155
- /**
156
- * The deployment that receives the push: a Convex.Deployment resource, or a
157
- * deployment name such as `happy-animal-123`. A preview deploy key needs the
158
- * resource. For `env` on a deployment outside US East, pass the resource.
159
- */
160
- readonly deployment: string | CodeDeployment;
108
+ //#region src/Push.d.ts
109
+ /** A value of the `env` prop: a string, or a secret such as `Config.Redacted("AUTH_SECRET")`. */
110
+ type EnvValue = string | Redacted.Redacted<string>;
111
+ /**
112
+ * The `source` prop: the Convex functions directory, such as `./convex`, or
113
+ * that directory with a push command and more files for the content identity.
114
+ */
115
+ type Source = string | {
116
+ /** The Convex functions directory, such as `./convex`. */
117
+ readonly path: string;
161
118
  /**
162
- * A deploy key of `deployment` (Convex.DeployKey), or, for a preview
163
- * deployment, a preview deploy key of its project (Convex.PreviewDeployKey).
119
+ * Replaces `convex deploy`: a program and its arguments, run in the app
120
+ * directory with CONVEX_DEPLOY_KEY in its environment, such as
121
+ * `["pnpm", "exec", "convex-hosting", "deploy", "--build", "pnpm run build", "--dist", "dist"]`.
122
+ * It must push with `convex deploy`, such as through `--cmd`, so that
123
+ * its output has the CLI's "Deployed Convex functions to" line.
164
124
  */
165
- readonly deployKey: Redacted.Redacted<string>;
166
- /** The Convex app directory: the one with `convex/` and the `convex` package installed. */
167
- readonly cwd: string;
125
+ readonly command?: readonly [string, ...string[]];
168
126
  /**
169
- * The program and first arguments that run the Convex CLI, such as
170
- * `["pnpm", "exec", "convex"]`. Code adds `deploy` and its flags. By
171
- * default, the `convex` package that `cwd` resolves, run with this Node.js.
127
+ * The files of the content identity, as globs relative to the app
128
+ * directory, next to `path`, package.json, convex.json, and the
129
+ * lockfile, such as the build inputs `["src/**", "vite.config.ts"]`.
130
+ * By default, every file of the app that git does not ignore.
172
131
  */
173
- readonly command?: readonly [string, ...string[]];
174
- /** Environment variables to set on the deployment before the push. Needs a deploy key of the deployment. */
175
- readonly env?: Readonly<Record<string, string | Redacted.Redacted<string>>>;
176
- /** `convex deploy --typecheck`. The CLI default is `try`. */
177
- readonly typecheck?: "enable" | "try" | "disable";
178
- /** `convex deploy --codegen`. The CLI default is `enable`. */
179
- readonly codegen?: "enable" | "disable";
180
- }
181
- interface CodeAttributes {
182
- /** The deployment that received the push, such as `happy-animal-123`. */
183
- readonly deploymentName: string;
184
- /** Client URL, such as `https://happy-animal-123.convex.cloud`. */
185
- readonly url: string;
186
- /** HTTP actions URL, such as `https://happy-animal-123.convex.site`. */
187
- readonly siteUrl: string;
188
- /** When the push finished, in milliseconds since the Unix epoch. */
189
- readonly deployedAt: number;
190
- /** The names of the `env` variables that this resource set on the deployment, sorted. */
191
- readonly envNames: readonly string[];
192
- }
193
- type Code = Resource<"Convex.Code", CodeProps, CodeAttributes, never, Providers>;
194
- declare const Code: import("alchemy").ResourceClass<Code>;
195
- /** Reads the deployment URL from `convex deploy` output. ANSI escape codes are removed first. */
196
- declare const parseDeployOutput: (text: string) => {
197
- url: string;
198
- deploymentName: string;
199
- } | undefined;
200
- declare const DeployKeyMismatch_base: Schema.Class<DeployKeyMismatch, Schema.TaggedStruct<"DeployKeyMismatch", {
201
- /** The deployment that should receive the push. */
202
- readonly deployment: Schema.String;
203
- /** What the key targets. */
204
- readonly key: Schema.Literals<readonly ["deployment", "preview", "project", "unknown"]>;
205
- /** For a deployment key: the deployment in the key prefix. Never the secret. */
206
- readonly keyDeployment: Schema.UndefinedOr<Schema.String>;
207
- }>, import("effect/Cause").YieldableError>;
208
- /** The deploy key does not fit the deployment. Checked before the push. */
209
- declare class DeployKeyMismatch extends DeployKeyMismatch_base {
210
- get message(): string;
211
- }
212
- declare const EnvironmentNeedsDeployKey_base: Schema.Class<EnvironmentNeedsDeployKey, Schema.TaggedStruct<"EnvironmentNeedsDeployKey", {
213
- readonly deployment: Schema.String;
132
+ readonly include?: readonly string[];
133
+ };
134
+ declare const ConvexCliNotFound_base: Schema.Class<ConvexCliNotFound, Schema.TaggedStruct<"ConvexCliNotFound", {
135
+ readonly cwd: Schema.String;
214
136
  }>, import("effect/Cause").YieldableError>;
215
- /** `env` needs the deployment API, which takes only a deploy key of the deployment. */
216
- declare class EnvironmentNeedsDeployKey extends EnvironmentNeedsDeployKey_base {
137
+ /** No `convex` package resolves from the app directory. */
138
+ export declare class ConvexCliNotFound extends ConvexCliNotFound_base {
217
139
  get message(): string;
218
140
  }
219
- declare const ConvexCliNotFound_base: Schema.Class<ConvexCliNotFound, Schema.TaggedStruct<"ConvexCliNotFound", {
220
- readonly cwd: Schema.String;
141
+ declare const ConvexAppNotFound_base: Schema.Class<ConvexAppNotFound, Schema.TaggedStruct<"ConvexAppNotFound", {
142
+ readonly source: Schema.String;
221
143
  }>, import("effect/Cause").YieldableError>;
222
- /** No `convex` package resolves from `cwd`. */
223
- declare class ConvexCliNotFound extends ConvexCliNotFound_base {
144
+ /** No directory at or above the parent of `source` has a package.json. */
145
+ export declare class ConvexAppNotFound extends ConvexAppNotFound_base {
224
146
  get message(): string;
225
147
  }
226
148
  declare const CodePushFailed_base: Schema.Class<CodePushFailed, Schema.TaggedStruct<"CodePushFailed", {
@@ -230,225 +152,122 @@ declare const CodePushFailed_base: Schema.Class<CodePushFailed, Schema.TaggedStr
230
152
  readonly outputTail: Schema.String;
231
153
  }>, import("effect/Cause").YieldableError>;
232
154
  /** The Convex CLI failed, or exited 0 without the deployment URL. The output tail never contains the key. */
233
- declare class CodePushFailed extends CodePushFailed_base {
155
+ export declare class CodePushFailed extends CodePushFailed_base {
234
156
  get message(): string;
235
157
  }
236
158
  declare const PushTargetMismatch_base: Schema.Class<PushTargetMismatch, Schema.TaggedStruct<"PushTargetMismatch", {
237
159
  readonly expected: Schema.String;
238
160
  readonly actual: Schema.String;
239
161
  }>, import("effect/Cause").YieldableError>;
240
- /** The CLI pushed to another deployment than the one in the props. Checked after the push. */
241
- declare class PushTargetMismatch extends PushTargetMismatch_base {
162
+ /** The CLI pushed to another deployment than the one of the resource. Checked after the push. */
163
+ export declare class PushTargetMismatch extends PushTargetMismatch_base {
242
164
  get message(): string;
243
165
  }
244
- //#endregion
245
- //#region src/DefaultEnvironmentVariable.d.ts
246
- /** Deployment types a default can target, from the generated schema. */
247
- type DeploymentType = components["schemas"]["DeploymentType"];
248
- interface DefaultEnvironmentVariableProps {
249
- /** Numeric project id, such as `project.projectId`. */
250
- readonly projectId: number;
251
- readonly name: string;
252
- readonly value: string | Redacted.Redacted<string>;
253
- /** Deployments of this type that Convex creates from now on get the variable. */
254
- readonly deploymentType: DeploymentType;
255
- }
256
- interface DefaultEnvironmentVariableAttributes {
257
- readonly projectId: number;
258
- readonly name: string;
259
- readonly deploymentType: DeploymentType;
260
- }
261
- type DefaultEnvironmentVariable = Resource<"Convex.DefaultEnvironmentVariable", DefaultEnvironmentVariableProps, DefaultEnvironmentVariableAttributes, never, Providers>;
262
- declare const DefaultEnvironmentVariable: import("alchemy").ResourceClass<DefaultEnvironmentVariable>;
263
- //#endregion
264
- //#region src/Deploy.d.ts
265
- interface DeployProps extends Pick<CommandRunProps, "cwd" | "env" | "timeout"> {
266
- /**
267
- * Deploy key that selects the target deployment: a production, development,
268
- * project, or preview deploy key. The CLI receives it as `CONVEX_DEPLOY_KEY`,
269
- * and Alchemy removes its value from the logged output.
270
- */
271
- readonly deployKey: Redacted.Redacted<string>;
272
- /**
273
- * Preview deployment name for a preview deploy key. The CLI reuses an
274
- * existing preview deployment with this name.
275
- */
276
- readonly previewName?: string;
277
- /**
278
- * Like {@link previewName}, but the CLI deletes and recreates an existing
279
- * preview deployment with this name, so every run gets a new URL.
280
- */
281
- readonly previewCreate?: string;
282
- /**
283
- * Function to run after the push, such as `init:seed`. The CLI runs it only
284
- * when the push created a new preview deployment.
285
- */
286
- readonly previewRun?: string;
287
- /**
288
- * More `convex deploy` flags, added after the preview flags. Alchemy splits
289
- * the command on whitespace, so an argument cannot contain whitespace: use
290
- * `--typecheck=disable`, not `--typecheck disable` as one argument.
291
- */
292
- readonly extraArgs?: readonly string[];
293
- /**
294
- * Files hashed to skip an unchanged push. By default every non-gitignored
295
- * file under `cwd` and the nearest lockfile. Use
296
- * `{ include: ["convex/**"], lockfile: true }` to ignore frontend changes,
297
- * or `false` to push on every deploy. A preview deploy (`previewName` or
298
- * `previewCreate`) pushes on every deploy: Convex can delete an expired
299
- * preview deployment, and the hash cannot show that.
300
- * @default true
301
- */
302
- readonly memo?: MemoOptions | boolean;
303
- }
304
- interface DeployAttributes {
305
- /** Client URL of the deployment that received the push, such as `https://happy-otter-123.convex.cloud`. */
306
- readonly url: string;
307
- /** First label of the URL host, such as `happy-otter-123`. */
308
- readonly deploymentName: string;
309
- /** Hash of the memoized input files after the push, or `undefined` when `memo` is `false`. */
310
- readonly hash: string | undefined;
311
- }
312
- type Deploy = Resource<"Convex.Deploy", DeployProps, DeployAttributes, never, Providers>;
313
- /**
314
- * @deprecated Since 0.3.0. Use Convex.Code with a Convex.Deployment: it
315
- * runs the installed Convex CLI, keeps the deploy key out of the process
316
- * environment, checks that the key fits the deployment, and outputs the site
317
- * URL. Removing a Deploy resource changes nothing in Convex.
318
- */
319
- declare const Deploy: import("alchemy").ResourceClass<Deploy>;
320
- /** The `convex deploy` argv, starting with `npx`. */
321
- declare const deployArgs: (props: Pick<DeployProps, "previewName" | "previewCreate" | "previewRun" | "extraArgs">) => readonly string[];
322
- declare const DeployArgumentError_base: Schema.Class<DeployArgumentError, Schema.TaggedStruct<"DeployArgumentError", {
323
- readonly argument: Schema.String;
166
+ declare const VariablesOwnedBySomeoneElse_base: Schema.Class<VariablesOwnedBySomeoneElse, Schema.TaggedStruct<"VariablesOwnedBySomeoneElse", {
167
+ readonly deployment: Schema.String;
168
+ readonly names: Schema.$Array<Schema.String>;
324
169
  }>, import("effect/Cause").YieldableError>;
325
- /** A `convex deploy` argument contains whitespace, which Alchemy's command runner splits on. */
326
- declare class DeployArgumentError extends DeployArgumentError_base {
170
+ /** Variables in `env` exist on the deployment with other values, and adoption is off. */
171
+ export declare class VariablesOwnedBySomeoneElse extends VariablesOwnedBySomeoneElse_base {
327
172
  get message(): string;
328
173
  }
329
- declare const DeployOutputError_base: Schema.Class<DeployOutputError, Schema.TaggedStruct<"DeployOutputError", {
330
- readonly outputTail: Schema.String;
174
+ declare const EnvironmentNeedsDeployKey_base: Schema.Class<EnvironmentNeedsDeployKey, Schema.TaggedStruct<"EnvironmentNeedsDeployKey", {
175
+ readonly deployment: Schema.String;
331
176
  }>, import("effect/Cause").YieldableError>;
332
- /** `npx convex deploy` exited 0 but did not print the deployment URL. */
333
- declare class DeployOutputError extends DeployOutputError_base {
177
+ /** A preview deploy key cannot set variables: the deployment API takes only a deploy key of the deployment. */
178
+ export declare class EnvironmentNeedsDeployKey extends EnvironmentNeedsDeployKey_base {
334
179
  get message(): string;
335
180
  }
181
+ /** Reads the deployment URL from `convex deploy` output. ANSI escape codes are removed first. */
182
+ export declare const parseDeployOutput: (text: string) => {
183
+ url: string;
184
+ deploymentName: string;
185
+ } | undefined;
336
186
  //#endregion
337
- //#region src/DeployKey.d.ts
338
- /** Actions a deploy key can be limited to, from the generated schema. */
339
- type DeployKeyAction = NonNullable<components["schemas"]["PlatformCreateDeployKeyArgs"]["allowedActions"]>[number];
340
- declare const DeployKeyRecoveryRequired_base: Schema.Class<DeployKeyRecoveryRequired, Schema.TaggedStruct<"DeployKeyRecoveryRequired", {
341
- /** Where the keys live, such as `deployment happy-otter-123` or `project 3145389`. */
342
- readonly target: Schema.String;
343
- /** The requested name. */
344
- readonly name: Schema.String;
345
- /** The listed keys with the requested name. */
346
- readonly keys: Schema.$Array<Schema.Struct<{
347
- readonly id: Schema.Number;
348
- readonly name: Schema.String;
349
- }>>;
350
- /** True when this run created a key before the listing check failed. */
351
- readonly afterCreate: Schema.Boolean;
352
- }>, import("effect/Cause").YieldableError>;
353
- /**
354
- * A key cannot be tied to one resource: before the create, listed keys
355
- * already have the requested name, or after the create, not exactly one has it.
356
- */
357
- declare class DeployKeyRecoveryRequired extends DeployKeyRecoveryRequired_base {
358
- get message(): string;
359
- }
360
- declare const DeployKeyIsCredential_base: Schema.Class<DeployKeyIsCredential, Schema.TaggedStruct<"DeployKeyIsCredential", {
361
- readonly target: Schema.String;
362
- readonly name: Schema.String;
363
- }>, import("effect/Cause").YieldableError>;
364
- /**
365
- * Convex returned the Management API credential itself as the new key. This
366
- * happens with an OAuth token: Convex creates no key. A delete of the
367
- * returned secret would revoke the credential, so the resource does not keep it.
368
- */
369
- declare class DeployKeyIsCredential extends DeployKeyIsCredential_base {
370
- get message(): string;
187
+ //#region src/Deployment.d.ts
188
+ interface DeploymentInputs {
189
+ /** The project: a Convex.Project resource, or `{ projectId }`. Cannot change. */
190
+ readonly project: {
191
+ readonly projectId: number;
192
+ };
193
+ /**
194
+ * The Convex functions directory, such as `./convex`, or that directory
195
+ * with a push command and more hashed files. The push runs in the nearest
196
+ * directory above it with a package.json. Without `source`, the resource
197
+ * pushes nothing.
198
+ */
199
+ readonly source?: Source;
200
+ /** Environment variables to set on the deployment before the push. */
201
+ readonly env?: Readonly<Record<string, EnvValue>>;
371
202
  }
372
- interface DeployKeyProps {
373
- /** Deployment name, such as `project.prodDeploymentName`. */
374
- readonly deployment: string;
203
+ type DeploymentProps = (DeploymentInputs & {
204
+ /** The project's default production deployment. Cannot change. */
205
+ readonly type: "prod";
206
+ }) | (DeploymentInputs & {
207
+ /** A dev deployment or a preview deployment that this resource creates. Cannot change. */
208
+ readonly type: "dev" | "preview";
375
209
  /**
376
- * Key name. The provider requests this name, a dash, and a hash of the
377
- * resource identity, so two resources with one `name` get different keys.
210
+ * The dev reference, such as `staging`, or the preview name, such as
211
+ * the stage name. Unique in the project. Cannot change.
378
212
  */
379
213
  readonly name: string;
380
- /** Limits the key to these actions. Convex grants every deployment action when omitted. */
381
- readonly allowedActions?: readonly DeployKeyAction[];
382
- }
383
- interface DeployKeyAttributes {
384
- /** The name Convex lists the key under, such as "ci-3f2a1b0c9d8e". */
385
- readonly uniqueName: string;
386
- /** Numeric id of the key in the listing. Undefined in state written by 0.1.x. */
387
- readonly keyId: number | undefined;
388
- readonly deployment: string;
389
- /** The secret, such as `prod:<deployment>|<token>`. Convex returns it only at creation. */
390
- readonly deployKey: Redacted.Redacted<string>;
391
- }
392
- type DeployKey = Resource<"Convex.DeployKey", DeployKeyProps, DeployKeyAttributes, never, Providers>;
393
- declare const DeployKey: import("alchemy").ResourceClass<DeployKey>;
394
- //#endregion
395
- //#region src/EnvironmentVariable.d.ts
396
- interface EnvironmentVariableProps {
397
- /** Deployment name, or its URL for deployments outside US East. */
398
- readonly deployment: string;
399
- /** Deploy key for `deployment`, such as `deployKey.deployKey`. */
400
- readonly deployKey: Redacted.Redacted<string>;
214
+ });
215
+ /** The deployment itself, without the state of the push. */
216
+ interface DeploymentTarget {
217
+ readonly projectId: number;
218
+ readonly type: DeploymentProps["type"];
219
+ /** Deployment name, such as `happy-animal-123`. */
401
220
  readonly name: string;
402
- readonly value: string | Redacted.Redacted<string>;
221
+ /** The reference that Convex lists, such as `production`, `staging`, or `preview/pr-42`. */
222
+ readonly reference: string;
223
+ /** The preview name of a preview deployment. Undefined for prod and dev. */
224
+ readonly previewName: string | undefined;
225
+ /** Client URL, such as `https://happy-animal-123.convex.cloud`. */
226
+ readonly url: string;
227
+ /** HTTP actions URL, such as `https://happy-animal-123.convex.site`. */
228
+ readonly siteUrl: string;
403
229
  }
404
- interface EnvironmentVariableAttributes {
405
- readonly deployment: string;
406
- readonly name: string;
407
- /** Deploy key for `deployment`, for read and delete. Undefined in state from 0.1.x. */
408
- readonly deployKey: Redacted.Redacted<string> | undefined;
230
+ interface DeploymentAttributes extends DeploymentTarget {
231
+ /** Content identity of the last push and `env`. Undefined when the resource pushed nothing. */
232
+ readonly hash: string | undefined;
233
+ /** The names of the `env` variables that this resource set on the deployment, sorted. */
234
+ readonly envNames: readonly string[];
409
235
  }
410
- type EnvironmentVariable = Resource<"Convex.EnvironmentVariable", EnvironmentVariableProps, EnvironmentVariableAttributes, never, Providers>;
411
- declare const EnvironmentVariable: import("alchemy").ResourceClass<EnvironmentVariable>;
412
- declare const VariableIdentityChange_base: Schema.Class<VariableIdentityChange, Schema.TaggedStruct<"VariableIdentityChange", {
413
- readonly resourceType: Schema.String;
414
- readonly field: Schema.Literals<readonly ["name", "deployment", "projectId", "deploymentType"]>;
236
+ export type Deployment = Resource<"Convex.Deployment", DeploymentProps, DeploymentAttributes, never, Providers>;
237
+ export declare const Deployment: import("alchemy").ResourceClass<Deployment>;
238
+ declare const DeploymentIdentityChange_base: Schema.Class<DeploymentIdentityChange, Schema.TaggedStruct<"DeploymentIdentityChange", {
239
+ /** Name of the deployment in state, such as `happy-animal-123`. */
240
+ readonly deployment: Schema.String;
241
+ readonly field: Schema.Literals<readonly ["projectId", "type", "name"]>;
415
242
  readonly current: Schema.String;
416
243
  readonly requested: Schema.String;
417
244
  }>, import("effect/Cause").YieldableError>;
418
- /**
419
- * The props name another variable than the one in state. Used by
420
- * Convex.EnvironmentVariable and Convex.DefaultEnvironmentVariable.
421
- */
422
- declare class VariableIdentityChange extends VariableIdentityChange_base {
245
+ /** The props name another deployment than the one in state. */
246
+ export declare class DeploymentIdentityChange extends DeploymentIdentityChange_base {
423
247
  get message(): string;
424
248
  }
425
- //#endregion
426
- //#region src/PreviewDeployKey.d.ts
427
- interface PreviewDeployKeyProps {
428
- /** Numeric project id, such as `project.projectId`. */
429
- readonly projectId: number;
430
- /**
431
- * Key name. The provider requests this name, a dash, and a hash of the
432
- * resource identity, so two resources with one `name` get different keys.
433
- */
434
- readonly name: string;
249
+ declare const ProductionDeploymentNotFound_base: Schema.Class<ProductionDeploymentNotFound, Schema.TaggedStruct<"ProductionDeploymentNotFound", {
250
+ readonly projectId: Schema.Number;
251
+ }>, import("effect/Cause").YieldableError>;
252
+ /** The project has no default production deployment for a `prod` resource to take over. */
253
+ export declare class ProductionDeploymentNotFound extends ProductionDeploymentNotFound_base {
254
+ get message(): string;
435
255
  }
436
- interface PreviewDeployKeyAttributes {
437
- /** The name Convex lists the key under, such as "ci-3f2a1b0c9d8e". */
438
- readonly uniqueName: string;
439
- /** Numeric id of the key in the listing. Undefined in state written by 0.1.x. */
440
- readonly keyId: number | undefined;
441
- readonly projectId: number;
442
- /** The secret, such as `preview:<team>:<project>|<token>`. Convex returns it only at creation. */
443
- readonly previewDeployKey: Redacted.Redacted<string>;
256
+ declare const AmbiguousDeployment_base: Schema.Class<AmbiguousDeployment, Schema.TaggedStruct<"AmbiguousDeployment", {
257
+ readonly projectId: Schema.Number;
258
+ readonly type: Schema.Literals<readonly ["dev", "preview"]>;
259
+ readonly name: Schema.String;
260
+ readonly deployments: Schema.$Array<Schema.String>;
261
+ }>, import("effect/Cause").YieldableError>;
262
+ /** More than one deployment of the project has the name, so the lookup cannot choose one. */
263
+ export declare class AmbiguousDeployment extends AmbiguousDeployment_base {
264
+ get message(): string;
444
265
  }
445
- type PreviewDeployKey = Resource<"Convex.PreviewDeployKey", PreviewDeployKeyProps, PreviewDeployKeyAttributes, never, Providers>;
446
- declare const PreviewDeployKey: import("alchemy").ResourceClass<PreviewDeployKey>;
447
266
  //#endregion
448
267
  //#region src/Project.d.ts
449
268
  /** Region names the Management API accepts, from the generated schema. */
450
269
  type DeploymentRegion = components["schemas"]["RegionName"];
451
- interface ProjectProps {
270
+ type ProjectProps = {
452
271
  /** Team slug or numeric team id. A slug costs one extra lookup per run. Cannot change. */
453
272
  readonly team: string | number;
454
273
  /** Display name. Convex derives the slug from it at creation. A change renames the project. */
@@ -457,7 +276,12 @@ interface ProjectProps {
457
276
  readonly deploymentRegion?: DeploymentRegion;
458
277
  /** Deployment created with the project. Defaults to `prod`. Cannot change. */
459
278
  readonly deploymentType?: "prod" | "dev";
460
- }
279
+ } | {
280
+ /** Team slug or numeric team id. Cannot change. */
281
+ readonly team: string | number;
282
+ /** Slug of an existing project, such as `score-four`. The resource never creates a project. Cannot change. */
283
+ readonly slug: string;
284
+ };
461
285
  interface ProjectAttributes {
462
286
  readonly projectId: number;
463
287
  readonly slug: string;
@@ -466,15 +290,15 @@ interface ProjectAttributes {
466
290
  readonly prodDeploymentName: string | undefined;
467
291
  readonly prodDeploymentUrl: string | undefined;
468
292
  }
469
- type Project = Resource<"Convex.Project", ProjectProps, ProjectAttributes, never, Providers>;
470
- declare const Project: import("alchemy").ResourceClass<Project>;
293
+ export type Project = Resource<"Convex.Project", ProjectProps, ProjectAttributes, never, Providers>;
294
+ export declare const Project: import("alchemy").ResourceClass<Project>;
471
295
  declare const ProjectTeamChange_base: Schema.Class<ProjectTeamChange, Schema.TaggedStruct<"ProjectTeamChange", {
472
296
  readonly projectId: Schema.Number;
473
297
  readonly teamId: Schema.Number;
474
298
  readonly requestedTeamId: Schema.Number;
475
299
  }>, import("effect/Cause").YieldableError>;
476
300
  /** The props change the team of an existing project. Convex cannot move a project. */
477
- declare class ProjectTeamChange extends ProjectTeamChange_base {
301
+ export declare class ProjectTeamChange extends ProjectTeamChange_base {
478
302
  get message(): string;
479
303
  }
480
304
  declare const ProjectDeploymentChange_base: Schema.Class<ProjectDeploymentChange, Schema.TaggedStruct<"ProjectDeploymentChange", {
@@ -487,7 +311,7 @@ declare const ProjectDeploymentChange_base: Schema.Class<ProjectDeploymentChange
487
311
  * The props change `deploymentType` or `deploymentRegion` of an existing
488
312
  * project. Convex uses them only when it creates the project.
489
313
  */
490
- declare class ProjectDeploymentChange extends ProjectDeploymentChange_base {
314
+ export declare class ProjectDeploymentChange extends ProjectDeploymentChange_base {
491
315
  get message(): string;
492
316
  }
493
317
  declare const AmbiguousProject_base: Schema.Class<AmbiguousProject, Schema.TaggedStruct<"AmbiguousProject", {
@@ -496,16 +320,24 @@ declare const AmbiguousProject_base: Schema.Class<AmbiguousProject, Schema.Tagge
496
320
  readonly projectIds: Schema.$Array<Schema.Number>;
497
321
  }>, import("effect/Cause").YieldableError>;
498
322
  /** More than one project in the team has the name, so the lookup cannot choose one. */
499
- declare class AmbiguousProject extends AmbiguousProject_base {
323
+ export declare class AmbiguousProject extends AmbiguousProject_base {
500
324
  get message(): string;
501
325
  }
502
326
  declare const CreatedProjectNotFound_base: Schema.Class<CreatedProjectNotFound, Schema.TaggedStruct<"CreatedProjectNotFound", {
503
327
  readonly projectId: Schema.Number;
504
328
  }>, import("effect/Cause").YieldableError>;
505
329
  /** Convex answered a create call but then did not return the project. */
506
- declare class CreatedProjectNotFound extends CreatedProjectNotFound_base {
330
+ export declare class CreatedProjectNotFound extends CreatedProjectNotFound_base {
331
+ get message(): string;
332
+ }
333
+ declare const ProjectNotFound_base: Schema.Class<ProjectNotFound, Schema.TaggedStruct<"ProjectNotFound", {
334
+ readonly team: Schema.String;
335
+ readonly slug: Schema.String;
336
+ }>, import("effect/Cause").YieldableError>;
337
+ /** No project in the team has the slug. A `slug` resource never creates one. */
338
+ export declare class ProjectNotFound extends ProjectNotFound_base {
507
339
  get message(): string;
508
340
  }
509
341
  //#endregion
510
- export { ACCESS_TOKEN_ENV, AmbiguousDeployment, AmbiguousProject, Code, type CodeAttributes, type CodeDeployment, type CodeProps, CodePushFailed, ConvexApiError, ConvexCliNotFound, CreatedProjectNotFound, Credentials, CredentialsError, DefaultEnvironmentVariable, type DefaultEnvironmentVariableAttributes, type DefaultEnvironmentVariableProps, Deploy, DeployArgumentError, type DeployAttributes, DeployKey, type DeployKeyAction, type DeployKeyAttributes, DeployKeyIsCredential, DeployKeyMismatch, type DeployKeyProps, DeployKeyRecoveryRequired, DeployOutputError, type DeployProps, Deployment, type DeploymentAttributes, DeploymentIdentityChange, type DeploymentProps, type DeploymentRegion, type DeploymentType, EnvironmentNeedsDeployKey, EnvironmentVariable, type EnvironmentVariableAttributes, type EnvironmentVariableProps, ManagementApi, PreviewDeployKey, type PreviewDeployKeyAttributes, type PreviewDeployKeyProps, ProductionDeploymentNotFound, Project, type ProjectAttributes, ProjectDeploymentChange, type ProjectProps, ProjectTeamChange, Providers, PushTargetMismatch, VariableIdentityChange, deployArgs, fromConfig, fromToken, parseDeployOutput, providers };
342
+ export type { DeploymentAttributes, DeploymentProps, DeploymentRegion, EnvValue, ProjectAttributes, ProjectProps, Source };
511
343
  //# sourceMappingURL=index.d.ts.map