@samebase/alchemy-convex 0.1.0 → 0.2.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.
Files changed (51) hide show
  1. package/README.md +85 -17
  2. package/lib/index.d.ts +352 -9
  3. package/lib/index.d.ts.map +1 -1
  4. package/lib/index.js +962 -10
  5. package/lib/index.js.map +1 -1
  6. package/package.json +7 -4
  7. package/src/Adoption.ts +30 -0
  8. package/src/DefaultEnvironmentVariable.ts +127 -29
  9. package/src/Deploy.ts +37 -15
  10. package/src/DeployKey.ts +221 -60
  11. package/src/EnvironmentVariable.ts +174 -41
  12. package/src/ManagementApi.ts +57 -1
  13. package/src/PreviewDeployKey.ts +65 -38
  14. package/src/Project.ts +236 -52
  15. package/src/index.ts +9 -0
  16. package/lib/Credentials.d.ts +0 -39
  17. package/lib/Credentials.d.ts.map +0 -1
  18. package/lib/Credentials.js +0 -49
  19. package/lib/Credentials.js.map +0 -1
  20. package/lib/DefaultEnvironmentVariable.d.ts +0 -58
  21. package/lib/DefaultEnvironmentVariable.d.ts.map +0 -1
  22. package/lib/DefaultEnvironmentVariable.js +0 -93
  23. package/lib/DefaultEnvironmentVariable.js.map +0 -1
  24. package/lib/Deploy.d.ts +0 -62
  25. package/lib/Deploy.d.ts.map +0 -1
  26. package/lib/Deploy.js +0 -92
  27. package/lib/Deploy.js.map +0 -1
  28. package/lib/DeployKey.d.ts +0 -48
  29. package/lib/DeployKey.d.ts.map +0 -1
  30. package/lib/DeployKey.js +0 -104
  31. package/lib/DeployKey.js.map +0 -1
  32. package/lib/EnvironmentVariable.d.ts +0 -37
  33. package/lib/EnvironmentVariable.d.ts.map +0 -1
  34. package/lib/EnvironmentVariable.js +0 -65
  35. package/lib/EnvironmentVariable.js.map +0 -1
  36. package/lib/ManagementApi.d.ts +0 -50
  37. package/lib/ManagementApi.d.ts.map +0 -1
  38. package/lib/ManagementApi.js +0 -103
  39. package/lib/ManagementApi.js.map +0 -1
  40. package/lib/PreviewDeployKey.d.ts +0 -34
  41. package/lib/PreviewDeployKey.d.ts.map +0 -1
  42. package/lib/PreviewDeployKey.js +0 -78
  43. package/lib/PreviewDeployKey.js.map +0 -1
  44. package/lib/Project.d.ts +0 -29
  45. package/lib/Project.d.ts.map +0 -1
  46. package/lib/Project.js +0 -114
  47. package/lib/Project.js.map +0 -1
  48. package/lib/Providers.d.ts +0 -13
  49. package/lib/Providers.d.ts.map +0 -1
  50. package/lib/Providers.js +0 -30
  51. package/lib/Providers.js.map +0 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ This package manages the control plane around it.
8
8
  Alchemy has no built-in Convex provider ([alchemy-run/alchemy-async#1306](https://github.com/alchemy-run/alchemy-async/issues/1306)).
9
9
  This is a community provider, maintained by [Samebase](https://samebase.com).
10
10
 
11
- Status: 0.1, pinned to `alchemy@2.0.0-beta.80` and Effect 4. Alchemy ships breaking changes
11
+ Status: 0.2, pinned to `alchemy@2.0.0-beta.80` and Effect 4. Alchemy ships breaking changes
12
12
  between betas; upgrade this package and Alchemy together. Verified end to end on a Vite app with a
13
13
  Cloudflare Worker: production on `main`, a Convex preview deployment plus a Worker Preview per pull
14
14
  request, destroy on close.
@@ -52,7 +52,7 @@ export default Alchemy.Stack(
52
52
  state: Cloudflare.state(),
53
53
  },
54
54
  Effect.gen(function* () {
55
- const project = yield* Convex.Project("Backend", {
55
+ const project = yield* Convex.Project("Project", {
56
56
  team: "my-team",
57
57
  name: "my-app",
58
58
  });
@@ -93,28 +93,83 @@ Preview stages: give `Convex.Deploy` a `PreviewDeployKey` and `previewName: <bra
93
93
  request stages, and the production key on `prod`. Variables that every preview deployment needs,
94
94
  such as auth keys, go on the project as `DefaultEnvironmentVariable` for `preview`.
95
95
 
96
+ ## Data safety
97
+
98
+ Deleting a Convex project deletes all of its deployments and data. This package does not delete,
99
+ replace, or overwrite your data by accident:
100
+
101
+ - `Convex.Project` has the removal policy `retain`. When you remove the resource or run
102
+ `alchemy destroy`, Alchemy forgets the project and Convex keeps it. To delete the project with
103
+ the resource, add `RemovalPolicy.destroy()`:
104
+
105
+ ```ts
106
+ yield * Convex.Project("Project", { team, name }).pipe(Alchemy.RemovalPolicy.destroy());
107
+ ```
108
+
109
+ - A project is never replaced. A change to `name` renames the project in place
110
+ (`PATCH /projects/{project_id}`). The id, the slug, the deployments, and the data stay.
111
+ - A change to `team`, `deploymentType`, or `deploymentRegion` stops the deploy with
112
+ `ProjectTeamChange` or `ProjectDeploymentChange`. Convex cannot move a project or change its
113
+ first deployment. Set the old value again, or create a new resource with a new logical id and
114
+ move the data yourself.
115
+ - With state, the provider finds the project only by the id in state. Without state, it finds a
116
+ project by its exact name, on all pages of the team's project list, and takes it over only with
117
+ `--adopt`. When two projects have that name, the deploy stops with `AmbiguousProject`.
118
+ - Each `DeployKey` and `PreviewDeployKey` requests a name that is unique to the resource: the
119
+ `name` prop, a dash, and a hash of the resource identity. The provider deletes a key only by its
120
+ secret, so it cannot revoke the key of another resource. When the key list does not show
121
+ exactly one key with the requested name, the deploy stops with `DeployKeyRecoveryRequired`,
122
+ which lists the key ids. The provider never revokes a key on a failed create.
123
+ - With an OAuth token as the credential, Convex creates no new key: it returns the OAuth token
124
+ with a new prefix. The key resources then stop with `DeployKeyIsCredential` and do not keep that
125
+ value, because a delete would revoke the OAuth token. Use a team access token or the Convex CLI
126
+ login.
127
+ - An `EnvironmentVariable` or a `DefaultEnvironmentVariable` that exists but is not in state
128
+ belongs to someone else. The provider overwrites it only with `--adopt`.
129
+ - A variable keeps its name and deployment (a default keeps its project, name, and deployment
130
+ type). A change stops the deploy with `VariableIdentityChange`. To rename or move a variable,
131
+ create a new resource with a new logical id and remove the old one. A rename in place would
132
+ need a cleanup step that can fail and leave a variable or a revoked deploy key behind.
133
+ - A variable write runs again after a Convex write conflict or a 5xx answer, at most four more
134
+ times. The write sets a value, so a second write has the same result.
135
+
136
+ Upgrade from 0.1: state from 0.1 records the policy `destroy` for each project. Run
137
+ `alchemy deploy` one time with 0.2 while the stack still declares the project. That deploy records
138
+ `retain`. Do this before you remove a project from the stack or run `alchemy destroy`.
139
+ Deploy keys from 0.1 state keep working, but 0.2 does not delete them: their state cannot show that
140
+ the secret is a new key and not an OAuth token. When you remove or replace such a key, delete it in
141
+ the Convex dashboard.
142
+
96
143
  ## Resources
97
144
 
98
145
  - `Convex.Project`: `{ team: slug | id, name, deploymentRegion?, deploymentType? }`. Creates a
99
146
  project with its default deployment. Outputs `projectId`, `slug`, `teamId`,
100
- `prodDeploymentName`, `prodDeploymentUrl`. There is no project update API, so a changed property
101
- replaces the project. An existing project with the same name is adopted only with `--adopt`.
102
- Deleting the resource deletes the project with all of its deployments and data.
103
- - `Convex.DeployKey`: `{ deployment, name, allowedActions? }`. Outputs `uniqueName` and the
104
- `deployKey` secret. Any change replaces the key. Keys are never adopted: a key without its secret
105
- is useless.
147
+ `prodDeploymentName`, `prodDeploymentUrl`. A changed `name` renames the project in place. A
148
+ changed `team`, `deploymentRegion`, or `deploymentType` stops the deploy. An existing project
149
+ with the same name is adopted only with `--adopt`. The removal policy is `retain`: only a
150
+ resource with `RemovalPolicy.destroy()` deletes the project with its deployments and data.
151
+ - `Convex.DeployKey`: `{ deployment, name, allowedActions? }`. Outputs `uniqueName`, `keyId`, and
152
+ the `deployKey` secret. Any change replaces the key. Delete revokes the key by its secret; a key
153
+ from 0.1 state stays. Keys are never adopted: a key without its secret is useless.
106
154
  - `Convex.PreviewDeployKey`: `{ projectId, name }`. Project-level key for preview deployments.
107
- Outputs `uniqueName` and `previewDeployKey`.
155
+ Outputs `uniqueName`, `keyId`, and `previewDeployKey`.
108
156
  - `Convex.EnvironmentVariable`: `{ deployment, deployKey, name, value }`. One variable on one
109
157
  deployment, set through the deployment API with that deployment's key. An existing variable with
110
- the same name is adopted and overwritten.
158
+ the same name is adopted and overwritten only with `--adopt`. A new `value` or `deployKey` is an
159
+ update in place. A new `name` or `deployment` stops the deploy with `VariableIdentityChange`:
160
+ use a new logical id. Outputs `deployment`, `name`, and `deployKey`. Read and delete use the
161
+ deploy key in the outputs, not the props.
111
162
  - `Convex.DefaultEnvironmentVariable`: `{ projectId, name, value, deploymentType }`. A project
112
- default that new deployments of that type inherit. Use it for preview and dev deployments.
163
+ default that new deployments of that type inherit. Use it for preview and dev deployments. An
164
+ existing default with the same name and type is adopted and overwritten only with `--adopt`. A
165
+ new `value` is an update in place. A new `projectId`, `name`, or `deploymentType` stops the
166
+ deploy with `VariableIdentityChange`: use a new logical id.
113
167
  - `Convex.Deploy`: `{ cwd?, env?, deployKey, previewName?, previewCreate?, previewRun?, extraArgs?,
114
168
  memo?, timeout? }`. Runs `npx convex deploy` with `CONVEX_DEPLOY_KEY` set and parses the
115
169
  deployment URL from the CLI output. Outputs `url`, `deploymentName`, `hash`. Memoized by content
116
- hash like Alchemy's own build steps. Deleting the resource does nothing; the deployment belongs to
117
- the project, and preview deployments expire on Convex's schedule.
170
+ hash like Alchemy's own build steps, except with `previewName` or `previewCreate`: a preview
171
+ deployment can expire, so a preview deploy always pushes. Deleting the resource does nothing;
172
+ the deployment belongs to the project, and preview deployments expire on Convex's schedule.
118
173
 
119
174
  ## Limits
120
175
 
@@ -123,6 +178,9 @@ memo?, timeout? }`. Runs `npx convex deploy` with `CONVEX_DEPLOY_KEY` set and pa
123
178
  - Deploy keys and other secret outputs are part of Alchemy state. Alchemy's Cloudflare state store
124
179
  encrypts state at rest; the local file store does not.
125
180
  - A deleted deploy key keeps working on the deployment API for roughly 30 seconds.
181
+ - A run that stops between a key create and the state write leaves a key that state does not
182
+ know. The next run stops with `DeployKeyRecoveryRequired`. Delete the listed key in the Convex
183
+ dashboard, then run the deploy again.
126
184
  - Not covered: dev deployments, custom domains, log streams, teams and members, components,
127
185
  snapshots.
128
186
 
@@ -131,16 +189,26 @@ memo?, timeout? }`. Runs `npx convex deploy` with `CONVEX_DEPLOY_KEY` set and pa
131
189
  ```sh
132
190
  pnpm install
133
191
  pnpm run check # format, lint, typecheck, unit tests
134
- pnpm run build # lib/ with declarations
192
+ pnpm run build # lib/ with declarations, then publint and attw
135
193
  pnpm run test:live # real API calls, see below
136
194
  ```
137
195
 
196
+ Use Node 24 (`.node-version`) and pnpm 11. `pnpm install` also installs a pre-commit hook that
197
+ runs `vp staged`.
198
+
138
199
  Unit tests run against recorded Management API payloads in `test/fixtures/management/`. Live tests
139
- need `ALCHEMY_CONVEX_LIVE=1`, a Convex login or `CONVEX_ACCESS_TOKEN`, and a throwaway project.
200
+ run only with `ALCHEMY_CONVEX_LIVE=1`, which `pnpm run test:live` sets. They need a Convex login or
201
+ `CONVEX_ACCESS_TOKEN`, and a throwaway project.
140
202
  Point them at yours with `ALCHEMY_CONVEX_LIVE_TEAM`, `ALCHEMY_CONVEX_LIVE_PROJECT_ID`,
141
203
  `ALCHEMY_CONVEX_LIVE_DEPLOYMENT`, and `ALCHEMY_CONVEX_LIVE_PROJECT_DIR` (a Convex app directory for
142
204
  the deploy test). They create resources named `tmp-alchemy-convex-*` and remove them again.
143
-
144
- Releases: push a `v*` tag; `.github/workflows/release.yml` publishes with npm trusted publishing.
205
+ A file argument runs one live file only, for example
206
+ `pnpm run test:live test/live/safety.live.test.ts`. That test runs the data safety contract
207
+ through the Alchemy engine. It creates a project `tmp-alchemy-convex-<8 hex>` in
208
+ `ALCHEMY_CONVEX_LIVE_TEAM` and deletes it at the end, also after a failure. It refuses to delete a
209
+ project whose name does not start with `tmp-alchemy-convex-`.
210
+
211
+ Releases: change `version` in `package.json` in a pull request. After the merge,
212
+ `.github/workflows/release.yml` publishes that version from `main` with npm trusted publishing.
145
213
 
146
214
  License: Apache 2.0.
package/lib/index.d.ts CHANGED
@@ -1,10 +1,353 @@
1
- export { ACCESS_TOKEN_ENV, Credentials, CredentialsError, fromConfig, fromToken, } from "./Credentials.ts";
2
- export { DefaultEnvironmentVariable, type DefaultEnvironmentVariableAttributes, type DefaultEnvironmentVariableProps, type DeploymentType, } from "./DefaultEnvironmentVariable.ts";
3
- export { Deploy, type DeployAttributes, deployArgs, type DeployProps, parseDeployOutput, } from "./Deploy.ts";
4
- export { DeployKey, type DeployKeyAction, type DeployKeyAttributes, type DeployKeyProps, } from "./DeployKey.ts";
5
- export { EnvironmentVariable, type EnvironmentVariableAttributes, type EnvironmentVariableProps, } from "./EnvironmentVariable.ts";
6
- export { ConvexApiError, ManagementApi } from "./ManagementApi.ts";
7
- export { PreviewDeployKey, type PreviewDeployKeyAttributes, type PreviewDeployKeyProps, } from "./PreviewDeployKey.ts";
8
- export { type DeploymentRegion, Project, type ProjectAttributes, type ProjectProps, } from "./Project.ts";
9
- export { Providers, providers } from "./Providers.ts";
1
+ import * as Context from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as Redacted from "effect/Redacted";
5
+ import * as Schema from "effect/Schema";
6
+ import { Resource } from "alchemy";
7
+ import * as Provider from "alchemy/Provider";
8
+ import { createDeploymentClient, createManagementClient } from "@convex-dev/platform";
9
+ import { CommandExecutor, CommandRunProps } from "alchemy/Command";
10
+ import { MemoOptions } from "alchemy/Command/Memo";
11
+ import { components } from "@convex-dev/platform/managementApi";
12
+ //#region src/Credentials.d.ts
13
+ interface ResolvedCredentials {
14
+ /** Bearer token accepted by https://api.convex.dev/v1: a team access token, an OAuth token, or the Convex CLI login. */
15
+ readonly accessToken: Redacted.Redacted<string>;
16
+ /** Where the token came from, for error messages only. */
17
+ readonly source: "env" | "explicit" | "convex-cli-login";
18
+ }
19
+ declare const Credentials_base: Context.ServiceClass<Credentials, "@samebase/alchemy-convex/Credentials", Effect.Effect<ResolvedCredentials, never, never>>;
20
+ declare class Credentials extends Credentials_base {}
21
+ /** Environment variable read by {@link fromConfig}. */
22
+ declare const ACCESS_TOKEN_ENV = "CONVEX_ACCESS_TOKEN";
23
+ declare const CredentialsError_base: Schema.Class<CredentialsError, Schema.TaggedStruct<"CredentialsError", {
24
+ readonly reason: Schema.String;
25
+ }>, import("effect/Cause").YieldableError>;
26
+ declare class CredentialsError extends CredentialsError_base {}
27
+ /**
28
+ * Default resolution: `CONVEX_ACCESS_TOKEN` from the stack ConfigProvider
29
+ * (process env, `.env`, stack secrets), then the Convex CLI login on this
30
+ * machine. CI sets the variable; a developer who ran `npx convex login` needs
31
+ * nothing.
32
+ */
33
+ declare const fromConfig: () => Layer.Layer<Credentials>;
34
+ /** Explicit token, for tests or callers that already hold a value. */
35
+ declare const fromToken: (accessToken: Redacted.Redacted<string>) => Layer.Layer<Credentials>;
36
+ //#endregion
37
+ //#region src/ManagementApi.d.ts
38
+ type ManagementClient = ReturnType<typeof createManagementClient>;
39
+ type DeploymentClient = ReturnType<typeof createDeploymentClient>;
40
+ /** Shape of every openapi-fetch result we consume. */
41
+ interface FetchResult<T> {
42
+ readonly data?: T;
43
+ readonly error?: unknown;
44
+ readonly response: Response;
45
+ }
46
+ declare const ConvexApiError_base: Schema.Class<ConvexApiError, Schema.TaggedStruct<"ConvexApiError", {
47
+ readonly operation: Schema.String;
48
+ readonly status: Schema.Number;
49
+ readonly code: Schema.optionalKey<Schema.String>;
50
+ readonly message: Schema.String;
51
+ }>, import("effect/Cause").YieldableError>;
52
+ /**
53
+ * One error for every control-plane and deployment call. Resources branch on
54
+ * `status` (404 means absent for read and delete), so the class is load
55
+ * bearing, not decorative.
56
+ */
57
+ declare class ConvexApiError extends ConvexApiError_base {}
58
+ interface ManagementApiService {
59
+ /** Run one management call with the resolved credentials. */
60
+ readonly request: <T>(operation: string, run: (client: ManagementClient) => Promise<FetchResult<T>>) => Effect.Effect<T, ConvexApiError>;
61
+ /** Run one management call whose success response has no body. */
62
+ readonly requestVoid: (operation: string, run: (client: ManagementClient) => Promise<FetchResult<unknown>>) => Effect.Effect<void, ConvexApiError>;
63
+ /** Run one deployment-scoped call authenticated with a deploy key. */
64
+ readonly deploymentRequest: <T>(operation: string, deploymentUrlOrName: string, deployKey: Redacted.Redacted<string>, run: (client: DeploymentClient) => Promise<FetchResult<T>>) => Effect.Effect<T, ConvexApiError>;
65
+ /** Team id for a slug or numeric id. */
66
+ readonly resolveTeamId: (team: string | number) => Effect.Effect<number, ConvexApiError>;
67
+ /**
68
+ * True when a deploy key that Convex returned carries the token of the
69
+ * Management API credential itself. With an OAuth token, create_deploy_key
70
+ * and create_preview_deploy_key create no new key: they return the OAuth
71
+ * token with a new prefix, and the part after "|" is the same. A delete of
72
+ * that key would revoke the credential.
73
+ */
74
+ readonly isCredentialToken: (secret: string) => Effect.Effect<boolean>;
75
+ }
76
+ declare const ManagementApi_base: Context.ServiceClass<ManagementApi, "@samebase/alchemy-convex/ManagementApi", ManagementApiService>;
77
+ declare class ManagementApi extends ManagementApi_base {}
78
+ //#endregion
79
+ //#region src/Providers.d.ts
80
+ declare const Providers_base: Provider.ProviderCollection<Providers, "Convex">;
81
+ declare class Providers extends Providers_base {}
82
+ /**
83
+ * All Convex resource providers. Pass a credentials layer to override the
84
+ * default lookup (`CONVEX_ACCESS_TOKEN`, then the Convex CLI login).
85
+ */
86
+ declare const providers: (credentials?: Layer.Layer<Credentials>) => Layer.Layer<Providers, never, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
87
+ //#endregion
88
+ //#region src/DefaultEnvironmentVariable.d.ts
89
+ /** Deployment types a default can target, from the generated schema. */
90
+ type DeploymentType = components["schemas"]["DeploymentType"];
91
+ interface DefaultEnvironmentVariableProps {
92
+ /** Numeric project id, such as `project.projectId`. */
93
+ readonly projectId: number;
94
+ readonly name: string;
95
+ readonly value: string | Redacted.Redacted<string>;
96
+ /** Deployments of this type that Convex creates from now on get the variable. */
97
+ readonly deploymentType: DeploymentType;
98
+ }
99
+ interface DefaultEnvironmentVariableAttributes {
100
+ readonly projectId: number;
101
+ readonly name: string;
102
+ readonly deploymentType: DeploymentType;
103
+ }
104
+ type DefaultEnvironmentVariable = Resource<"Convex.DefaultEnvironmentVariable", DefaultEnvironmentVariableProps, DefaultEnvironmentVariableAttributes, never, Providers>;
105
+ declare const DefaultEnvironmentVariable: import("alchemy").ResourceClass<DefaultEnvironmentVariable>;
106
+ //#endregion
107
+ //#region src/Deploy.d.ts
108
+ interface DeployProps extends Pick<CommandRunProps, "cwd" | "env" | "timeout"> {
109
+ /**
110
+ * Deploy key that selects the target deployment: a production, development,
111
+ * project, or preview deploy key. The CLI receives it as `CONVEX_DEPLOY_KEY`,
112
+ * and Alchemy removes its value from the logged output.
113
+ */
114
+ readonly deployKey: Redacted.Redacted<string>;
115
+ /**
116
+ * Preview deployment name for a preview deploy key. The CLI reuses an
117
+ * existing preview deployment with this name.
118
+ */
119
+ readonly previewName?: string;
120
+ /**
121
+ * Like {@link previewName}, but the CLI deletes and recreates an existing
122
+ * preview deployment with this name, so every run gets a new URL.
123
+ */
124
+ readonly previewCreate?: string;
125
+ /**
126
+ * Function to run after the push, such as `init:seed`. The CLI runs it only
127
+ * when the push created a new preview deployment.
128
+ */
129
+ readonly previewRun?: string;
130
+ /**
131
+ * More `convex deploy` flags, added after the preview flags. Alchemy splits
132
+ * the command on whitespace, so an argument cannot contain whitespace: use
133
+ * `--typecheck=disable`, not `--typecheck disable` as one argument.
134
+ */
135
+ readonly extraArgs?: readonly string[];
136
+ /**
137
+ * Files hashed to skip an unchanged push. By default every non-gitignored
138
+ * file under `cwd` and the nearest lockfile. Use
139
+ * `{ include: ["convex/**"], lockfile: true }` to ignore frontend changes,
140
+ * or `false` to push on every deploy. A preview deploy (`previewName` or
141
+ * `previewCreate`) pushes on every deploy: Convex can delete an expired
142
+ * preview deployment, and the hash cannot show that.
143
+ * @default true
144
+ */
145
+ readonly memo?: MemoOptions | boolean;
146
+ }
147
+ interface DeployAttributes {
148
+ /** Client URL of the deployment that received the push, such as `https://happy-otter-123.convex.cloud`. */
149
+ readonly url: string;
150
+ /** First label of the URL host, such as `happy-otter-123`. */
151
+ readonly deploymentName: string;
152
+ /** Hash of the memoized input files after the push, or `undefined` when `memo` is `false`. */
153
+ readonly hash: string | undefined;
154
+ }
155
+ type Deploy = Resource<"Convex.Deploy", DeployProps, DeployAttributes, never, Providers>;
156
+ declare const Deploy: import("alchemy").ResourceClass<Deploy>;
157
+ /** Reads the deployment URL from `convex deploy` output. ANSI escape codes are removed first. */
158
+ declare const parseDeployOutput: (text: string) => {
159
+ url: string;
160
+ deploymentName: string;
161
+ } | undefined;
162
+ /** The `convex deploy` argv, starting with `npx`. */
163
+ declare const deployArgs: (props: Pick<DeployProps, "previewName" | "previewCreate" | "previewRun" | "extraArgs">) => readonly string[];
164
+ declare const DeployArgumentError_base: Schema.Class<DeployArgumentError, Schema.TaggedStruct<"DeployArgumentError", {
165
+ readonly argument: Schema.String;
166
+ }>, import("effect/Cause").YieldableError>;
167
+ /** A `convex deploy` argument contains whitespace, which Alchemy's command runner splits on. */
168
+ declare class DeployArgumentError extends DeployArgumentError_base {
169
+ get message(): string;
170
+ }
171
+ declare const DeployOutputError_base: Schema.Class<DeployOutputError, Schema.TaggedStruct<"DeployOutputError", {
172
+ readonly outputTail: Schema.String;
173
+ }>, import("effect/Cause").YieldableError>;
174
+ /** `npx convex deploy` exited 0 but did not print the deployment URL. */
175
+ declare class DeployOutputError extends DeployOutputError_base {
176
+ get message(): string;
177
+ }
178
+ //#endregion
179
+ //#region src/DeployKey.d.ts
180
+ /** Actions a deploy key can be limited to, from the generated schema. */
181
+ type DeployKeyAction = NonNullable<components["schemas"]["PlatformCreateDeployKeyArgs"]["allowedActions"]>[number];
182
+ declare const DeployKeyRecoveryRequired_base: Schema.Class<DeployKeyRecoveryRequired, Schema.TaggedStruct<"DeployKeyRecoveryRequired", {
183
+ /** Where the keys live, such as `deployment happy-otter-123` or `project 3145389`. */
184
+ readonly target: Schema.String;
185
+ /** The requested name. */
186
+ readonly name: Schema.String;
187
+ /** The listed keys with the requested name. */
188
+ readonly keys: Schema.$Array<Schema.Struct<{
189
+ readonly id: Schema.Number;
190
+ readonly name: Schema.String;
191
+ }>>;
192
+ /** True when this run created a key before the listing check failed. */
193
+ readonly afterCreate: Schema.Boolean;
194
+ }>, import("effect/Cause").YieldableError>;
195
+ /**
196
+ * A key cannot be tied to one resource: before the create, listed keys
197
+ * already have the requested name, or after the create, not exactly one has it.
198
+ */
199
+ declare class DeployKeyRecoveryRequired extends DeployKeyRecoveryRequired_base {
200
+ get message(): string;
201
+ }
202
+ declare const DeployKeyIsCredential_base: Schema.Class<DeployKeyIsCredential, Schema.TaggedStruct<"DeployKeyIsCredential", {
203
+ readonly target: Schema.String;
204
+ readonly name: Schema.String;
205
+ }>, import("effect/Cause").YieldableError>;
206
+ /**
207
+ * Convex returned the Management API credential itself as the new key. This
208
+ * happens with an OAuth token: Convex creates no key. A delete of the
209
+ * returned secret would revoke the credential, so the resource does not keep it.
210
+ */
211
+ declare class DeployKeyIsCredential extends DeployKeyIsCredential_base {
212
+ get message(): string;
213
+ }
214
+ interface DeployKeyProps {
215
+ /** Deployment name, such as `project.prodDeploymentName`. */
216
+ readonly deployment: string;
217
+ /**
218
+ * Key name. The provider requests this name, a dash, and a hash of the
219
+ * resource identity, so two resources with one `name` get different keys.
220
+ */
221
+ readonly name: string;
222
+ /** Limits the key to these actions. Convex grants every deployment action when omitted. */
223
+ readonly allowedActions?: readonly DeployKeyAction[];
224
+ }
225
+ interface DeployKeyAttributes {
226
+ /** The name Convex lists the key under, such as "ci-3f2a1b0c9d8e". */
227
+ readonly uniqueName: string;
228
+ /** Numeric id of the key in the listing. Undefined in state written by 0.1.x. */
229
+ readonly keyId: number | undefined;
230
+ readonly deployment: string;
231
+ /** The secret, such as `prod:<deployment>|<token>`. Convex returns it only at creation. */
232
+ readonly deployKey: Redacted.Redacted<string>;
233
+ }
234
+ type DeployKey = Resource<"Convex.DeployKey", DeployKeyProps, DeployKeyAttributes, never, Providers>;
235
+ declare const DeployKey: import("alchemy").ResourceClass<DeployKey>;
236
+ //#endregion
237
+ //#region src/EnvironmentVariable.d.ts
238
+ interface EnvironmentVariableProps {
239
+ /** Deployment name, or its URL for deployments outside US East. */
240
+ readonly deployment: string;
241
+ /** Deploy key for `deployment`, such as `deployKey.deployKey`. */
242
+ readonly deployKey: Redacted.Redacted<string>;
243
+ readonly name: string;
244
+ readonly value: string | Redacted.Redacted<string>;
245
+ }
246
+ interface EnvironmentVariableAttributes {
247
+ readonly deployment: string;
248
+ readonly name: string;
249
+ /** Deploy key for `deployment`, for read and delete. Undefined in state from 0.1.x. */
250
+ readonly deployKey: Redacted.Redacted<string> | undefined;
251
+ }
252
+ type EnvironmentVariable = Resource<"Convex.EnvironmentVariable", EnvironmentVariableProps, EnvironmentVariableAttributes, never, Providers>;
253
+ declare const EnvironmentVariable: import("alchemy").ResourceClass<EnvironmentVariable>;
254
+ declare const VariableIdentityChange_base: Schema.Class<VariableIdentityChange, Schema.TaggedStruct<"VariableIdentityChange", {
255
+ readonly resourceType: Schema.String;
256
+ readonly field: Schema.Literals<readonly ["name", "deployment", "projectId", "deploymentType"]>;
257
+ readonly current: Schema.String;
258
+ readonly requested: Schema.String;
259
+ }>, import("effect/Cause").YieldableError>;
260
+ /**
261
+ * The props name another variable than the one in state. Used by
262
+ * Convex.EnvironmentVariable and Convex.DefaultEnvironmentVariable.
263
+ */
264
+ declare class VariableIdentityChange extends VariableIdentityChange_base {
265
+ get message(): string;
266
+ }
267
+ //#endregion
268
+ //#region src/PreviewDeployKey.d.ts
269
+ interface PreviewDeployKeyProps {
270
+ /** Numeric project id, such as `project.projectId`. */
271
+ readonly projectId: number;
272
+ /**
273
+ * Key name. The provider requests this name, a dash, and a hash of the
274
+ * resource identity, so two resources with one `name` get different keys.
275
+ */
276
+ readonly name: string;
277
+ }
278
+ interface PreviewDeployKeyAttributes {
279
+ /** The name Convex lists the key under, such as "ci-3f2a1b0c9d8e". */
280
+ readonly uniqueName: string;
281
+ /** Numeric id of the key in the listing. Undefined in state written by 0.1.x. */
282
+ readonly keyId: number | undefined;
283
+ readonly projectId: number;
284
+ /** The secret, such as `preview:<team>:<project>|<token>`. Convex returns it only at creation. */
285
+ readonly previewDeployKey: Redacted.Redacted<string>;
286
+ }
287
+ type PreviewDeployKey = Resource<"Convex.PreviewDeployKey", PreviewDeployKeyProps, PreviewDeployKeyAttributes, never, Providers>;
288
+ declare const PreviewDeployKey: import("alchemy").ResourceClass<PreviewDeployKey>;
289
+ //#endregion
290
+ //#region src/Project.d.ts
291
+ /** Region names the Management API accepts, from the generated schema. */
292
+ type DeploymentRegion = components["schemas"]["RegionName"];
293
+ interface ProjectProps {
294
+ /** Team slug or numeric team id. A slug costs one extra lookup per run. Cannot change. */
295
+ readonly team: string | number;
296
+ /** Display name. Convex derives the slug from it at creation. A change renames the project. */
297
+ readonly name: string;
298
+ /** Region of the deployment created with the project. Defaults to the team default. Cannot change. */
299
+ readonly deploymentRegion?: DeploymentRegion;
300
+ /** Deployment created with the project. Defaults to `prod`. Cannot change. */
301
+ readonly deploymentType?: "prod" | "dev";
302
+ }
303
+ interface ProjectAttributes {
304
+ readonly projectId: number;
305
+ readonly slug: string;
306
+ readonly name: string;
307
+ readonly teamId: number;
308
+ readonly prodDeploymentName: string | undefined;
309
+ readonly prodDeploymentUrl: string | undefined;
310
+ }
311
+ type Project = Resource<"Convex.Project", ProjectProps, ProjectAttributes, never, Providers>;
312
+ declare const Project: import("alchemy").ResourceClass<Project>;
313
+ declare const ProjectTeamChange_base: Schema.Class<ProjectTeamChange, Schema.TaggedStruct<"ProjectTeamChange", {
314
+ readonly projectId: Schema.Number;
315
+ readonly teamId: Schema.Number;
316
+ readonly requestedTeamId: Schema.Number;
317
+ }>, import("effect/Cause").YieldableError>;
318
+ /** The props change the team of an existing project. Convex cannot move a project. */
319
+ declare class ProjectTeamChange extends ProjectTeamChange_base {
320
+ get message(): string;
321
+ }
322
+ declare const ProjectDeploymentChange_base: Schema.Class<ProjectDeploymentChange, Schema.TaggedStruct<"ProjectDeploymentChange", {
323
+ readonly projectId: Schema.Number;
324
+ readonly field: Schema.Literals<readonly ["deploymentType", "deploymentRegion"]>;
325
+ readonly current: Schema.UndefinedOr<Schema.String>;
326
+ readonly requested: Schema.UndefinedOr<Schema.String>;
327
+ }>, import("effect/Cause").YieldableError>;
328
+ /**
329
+ * The props change `deploymentType` or `deploymentRegion` of an existing
330
+ * project. Convex uses them only when it creates the project.
331
+ */
332
+ declare class ProjectDeploymentChange extends ProjectDeploymentChange_base {
333
+ get message(): string;
334
+ }
335
+ declare const AmbiguousProject_base: Schema.Class<AmbiguousProject, Schema.TaggedStruct<"AmbiguousProject", {
336
+ readonly teamId: Schema.Number;
337
+ readonly name: Schema.String;
338
+ readonly projectIds: Schema.$Array<Schema.Number>;
339
+ }>, import("effect/Cause").YieldableError>;
340
+ /** More than one project in the team has the name, so the lookup cannot choose one. */
341
+ declare class AmbiguousProject extends AmbiguousProject_base {
342
+ get message(): string;
343
+ }
344
+ declare const CreatedProjectNotFound_base: Schema.Class<CreatedProjectNotFound, Schema.TaggedStruct<"CreatedProjectNotFound", {
345
+ readonly projectId: Schema.Number;
346
+ }>, import("effect/Cause").YieldableError>;
347
+ /** Convex answered a create call but then did not return the project. */
348
+ declare class CreatedProjectNotFound extends CreatedProjectNotFound_base {
349
+ get message(): string;
350
+ }
351
+ //#endregion
352
+ export { ACCESS_TOKEN_ENV, AmbiguousProject, ConvexApiError, CreatedProjectNotFound, Credentials, CredentialsError, DefaultEnvironmentVariable, type DefaultEnvironmentVariableAttributes, type DefaultEnvironmentVariableProps, Deploy, DeployArgumentError, type DeployAttributes, DeployKey, type DeployKeyAction, type DeployKeyAttributes, DeployKeyIsCredential, type DeployKeyProps, DeployKeyRecoveryRequired, DeployOutputError, type DeployProps, type DeploymentRegion, type DeploymentType, EnvironmentVariable, type EnvironmentVariableAttributes, type EnvironmentVariableProps, ManagementApi, PreviewDeployKey, type PreviewDeployKeyAttributes, type PreviewDeployKeyProps, Project, type ProjectAttributes, ProjectDeploymentChange, type ProjectProps, ProjectTeamChange, Providers, VariableIdentityChange, deployArgs, fromConfig, fromToken, parseDeployOutput, providers };
10
353
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,0BAA0B,EAC1B,KAAK,oCAAoC,EACzC,KAAK,+BAA+B,EACpC,KAAK,cAAc,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,MAAM,EACN,KAAK,gBAAgB,EACrB,UAAU,EACV,KAAK,WAAW,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,gBAAgB,EACrB,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/Credentials.ts","../src/ManagementApi.ts","../src/Providers.ts","../src/DefaultEnvironmentVariable.ts","../src/Deploy.ts","../src/DeployKey.ts","../src/EnvironmentVariable.ts","../src/PreviewDeployKey.ts","../src/Project.ts"],"mappings":";;;;;;;;;;;;UAgBiB;;WAEN,aAAa,SAAS;;WAEtB;;;cAGE,oBAAoB;;cAKpB;;;;cAyBA,yBAAyB;;;;;;;cAUzB,kBAAiB,MAAM,MAAM;;cAa7B,YAAa,aAAa,SAAS,qBAAmB,MAAM,MAAM;;;KC7DnE,mBAAmB,kBAAkB;KACrC,mBAAmB,kBAAkB;;UAGhC,YAAY;WAClB,OAAO;WACP;WACA,UAAU;;;;;;;;;;;;;cAQR,uBAAuB;UAuBnB;;WAEN,UAAU,GACjB,mBACA,MAAM,QAAQ,qBAAqB,QAAQ,YAAY,QACpD,OAAO,OAAO,GAAG;;WAEb,cACP,mBACA,MAAM,QAAQ,qBAAqB,QAAQ,0BACxC,OAAO,aAAa;;WAEhB,oBAAoB,GAC3B,mBACA,6BACA,WAAW,SAAS,kBACpB,MAAM,QAAQ,qBAAqB,QAAQ,YAAY,QACpD,OAAO,OAAO,GAAG;;WAEb,gBAAgB,0BAA0B,OAAO,eAAe;;;;;;;;WAQhE,oBAAoB,mBAAmB,OAAO;;;cAM5C,sBAAsB;;;;cCrEtB,kBAAkB;;;;;cAMlB,YAAa,cAAa,MAAM,MAAM,iBAA2B,MAAA,MAAA,+DAAA,kDAAA,mCAAA;;;;KCalE,iBAAiB;UAgGZ;;WAEN;WACA;WACA,gBAAgB,SAAS;;WAEzB,gBAAgB;;UAGV;WACN;WACA;WACA,gBAAgB;;KAGf,6BAA6B,8CAEvC,iCACA,6CAEA;cAEW,8CAA0B,cAAA;;;UCzItB,oBAAoB,KAAK;;;;;;WAM/B,WAAW,SAAS;;;;;WAKpB;;;;;WAKA;;;;;WAKA;;;;;;WAMA;;;;;;;;;;WAUA,OAAO;;UAGD;;WAEN;;WAEA;;WAEA;;KAGC,SAAS,0BAA0B,aAAa,yBAAyB;cACxE,0BAAM,cAAA;;cAYN,oBACX;EACG;EAAa;;;cAQL,aACX,OAAO,KAAK;;;;;cAeD,4BAA4B;MAI1B;;;;;;cAMF,0BAA0B;MAIxB;;;;;KC/EH,kBAAkB,YAC5B;;;;;;;;;;;;;;;;;;cA6DW,kCAAkC;MAahC;;;;;;;;;;;cAgBF,8BAA8B;MAI5B;;UAwEE;;WAEN;;;;;WAKA;;WAEA,0BAA0B;;UAGpB;;WAEN;;WAEA;WACA;;WAEA,WAAW,SAAS;;KAGnB,YAAY,6BAEtB,gBACA,4BAEA;cAEW,6BAAS,cAAA;;;UC/HL;;WAEN;;WAEA,WAAW,SAAS;WACpB;WACA,gBAAgB,SAAS;;UAGnB;WACN;WACA;;WAEA,WAAW,SAAS;;KAGnB,sBAAsB,uCAEhC,0BACA,sCAEA;cAEW,uCAAmB,cAAA;;;;;;;;;;;cAMnB,+BAA+B;MAS7B;;;;UCpHE;;WAEN;;;;;WAKA;;UAGM;;WAEN;;WAEA;WACA;;WAEA,kBAAkB,SAAS;;KAG1B,mBAAmB,oCAE7B,uBACA,mCAEA;cAEW,oCAAgB,cAAA;;;;KChCjB,mBAAmB;UAEd;;WAEN;;WAEA;;WAEA,mBAAmB;;WAEnB;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA;;KAGC,UAAU,2BAA2B,cAAc,0BAA0B;cAC5E,2BAAO,cAAA;;;;;;;cAGP,0BAA0B;MAIxB;;;;;;;;;;;;cASF,gCAAgC;MAS9B;;;;;;;;cAOF,yBAAyB;MAKvB;;;;;;cAMF,+BAA+B;MAI7B"}