@samebase/alchemy-convex 0.2.0 → 0.3.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.
- package/README.md +169 -46
- package/lib/index.d.ts +168 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +494 -45
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Code.ts +463 -0
- package/src/Deploy.ts +10 -20
- package/src/Deployment.ts +409 -0
- package/src/EnvironmentVariable.ts +33 -6
- package/src/Providers.ts +9 -1
- package/src/index.ts +20 -1
package/README.md
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# @samebase/alchemy-convex
|
|
2
2
|
|
|
3
|
-
Convex resources for [Alchemy v2](https://alchemy.run): projects, deploy keys,
|
|
4
|
-
variables, project default environment variables, and
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Convex resources for [Alchemy v2](https://alchemy.run): projects, deployments, deploy keys,
|
|
4
|
+
environment variables, project default environment variables, and the code push. One Alchemy stack
|
|
5
|
+
can own a Convex app end to end: it creates the deployment, pushes the functions, and gives the
|
|
6
|
+
deployment URLs to a Cloudflare Worker or a Vite site as ordinary outputs. The Convex CLI that
|
|
7
|
+
your app installs keeps doing typecheck, codegen, bundling, and the push.
|
|
7
8
|
|
|
8
9
|
Alchemy has no built-in Convex provider ([alchemy-run/alchemy-async#1306](https://github.com/alchemy-run/alchemy-async/issues/1306)).
|
|
9
10
|
This is a community provider, maintained by [Samebase](https://samebase.com).
|
|
10
11
|
|
|
11
|
-
Status: 0.
|
|
12
|
-
between betas; upgrade this package and Alchemy together.
|
|
13
|
-
Cloudflare Worker: production on `main`, a Convex preview deployment plus
|
|
14
|
-
request, destroy on close.
|
|
12
|
+
Status: 0.3, pinned to `alchemy@2.0.0-beta.80` and Effect 4. Alchemy ships breaking changes
|
|
13
|
+
between betas; upgrade this package and Alchemy together. The 0.2 deploy step was verified end to
|
|
14
|
+
end on a Vite app with a Cloudflare Worker: production on `main`, a Convex preview deployment plus
|
|
15
|
+
a Worker Preview per pull request, destroy on close. `Convex.Deployment` and `Convex.Code` are
|
|
16
|
+
verified by a live test with the real Convex CLI: a push to a production deployment and to a
|
|
17
|
+
preview deployment, then a delete of the preview.
|
|
15
18
|
|
|
16
19
|
## Install
|
|
17
20
|
|
|
@@ -52,46 +55,70 @@ export default Alchemy.Stack(
|
|
|
52
55
|
state: Cloudflare.state(),
|
|
53
56
|
},
|
|
54
57
|
Effect.gen(function* () {
|
|
55
|
-
const project = yield* Convex.Project("Project", {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const deployKey = yield* Convex.DeployKey("DeployKey", {
|
|
61
|
-
deployment: project.prodDeploymentName.as<string>(),
|
|
58
|
+
const project = yield* Convex.Project("Project", { team: 38516, name: "score-four" });
|
|
59
|
+
const prod = yield* Convex.Deployment("Prod", { projectId: project.projectId, type: "prod" });
|
|
60
|
+
const key = yield* Convex.DeployKey("DeployKey", {
|
|
61
|
+
deployment: prod.name,
|
|
62
62
|
name: "alchemy",
|
|
63
|
+
allowedActions: ["deployment:deploy", "deployment:env:view", "deployment:env:write"],
|
|
63
64
|
});
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
const backend = yield* Convex.Code("Backend", {
|
|
66
|
+
deployment: prod,
|
|
67
|
+
deployKey: key.deployKey,
|
|
66
68
|
cwd: ".",
|
|
67
|
-
deployKey: deployKey.deployKey,
|
|
68
69
|
});
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
env: { VITE_CONVEX_URL: backend.url },
|
|
74
|
-
assets: { notFoundHandling: "single-page-application" },
|
|
71
|
+
// backend.url and backend.siteUrl feed a Cloudflare Worker or a Vite site.
|
|
72
|
+
const site = yield* Cloudflare.Website.Vite("Site", {
|
|
73
|
+
env: { VITE_CONVEX_URL: backend.url, VITE_CONVEX_SITE_URL: backend.siteUrl },
|
|
75
74
|
});
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
deployment: backend.deploymentName,
|
|
79
|
-
deployKey: deployKey.deployKey,
|
|
80
|
-
name: "SITE_URL",
|
|
81
|
-
value: site.url,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
return { url: site.url, backendUrl: backend.url };
|
|
76
|
+
return { url: site.url, convexUrl: backend.url };
|
|
85
77
|
}),
|
|
86
78
|
);
|
|
87
79
|
```
|
|
88
80
|
|
|
89
|
-
Order follows the outputs: the project exists before its
|
|
90
|
-
|
|
81
|
+
Order follows the outputs: the project exists before its deployment, the deployment before its key,
|
|
82
|
+
the key before the push, and the push before the site build. On a Vite Worker, a `VITE_` key in
|
|
83
|
+
`env` goes into the client bundle as `import.meta.env.VITE_*` and is also a Worker variable.
|
|
84
|
+
`Cloudflare.Worker` takes the same `env`.
|
|
85
|
+
|
|
86
|
+
### Preview stages
|
|
91
87
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
On a pull request stage, push to a preview deployment of the same project. Name the preview after
|
|
89
|
+
the stage, and use a preview deploy key of the project:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const stack = yield * Alchemy.Stack; // stack.stage, such as "pr-42"
|
|
93
|
+
// The project that the stage "prod" owns. A preview stage reads it and does not own it.
|
|
94
|
+
const project = yield * Convex.Project.ref("Project", { stage: "prod" });
|
|
95
|
+
const preview =
|
|
96
|
+
yield *
|
|
97
|
+
Convex.Deployment("Preview", {
|
|
98
|
+
projectId: project.projectId,
|
|
99
|
+
type: "preview",
|
|
100
|
+
name: stack.stage,
|
|
101
|
+
}).pipe(Alchemy.RemovalPolicy.destroy());
|
|
102
|
+
const previewKey =
|
|
103
|
+
yield *
|
|
104
|
+
Convex.PreviewDeployKey("PreviewDeployKey", {
|
|
105
|
+
projectId: project.projectId,
|
|
106
|
+
name: "alchemy",
|
|
107
|
+
});
|
|
108
|
+
const backend =
|
|
109
|
+
yield *
|
|
110
|
+
Convex.Code("Backend", {
|
|
111
|
+
deployment: preview,
|
|
112
|
+
deployKey: previewKey.previewDeployKey,
|
|
113
|
+
cwd: ".",
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`alchemy destroy --stage pr-42` then deletes the preview deployment. Without
|
|
118
|
+
`RemovalPolicy.destroy()`, the preview deployment stays until Convex deletes it at expiry (14 days
|
|
119
|
+
by default). [`examples/app/alchemy.run.ts`](examples/app/alchemy.run.ts) has both stages in one
|
|
120
|
+
stack. Variables that every preview deployment needs, such as auth keys, go on the project as
|
|
121
|
+
`DefaultEnvironmentVariable` for `preview`.
|
|
95
122
|
|
|
96
123
|
## Data safety
|
|
97
124
|
|
|
@@ -124,8 +151,23 @@ replace, or overwrite your data by accident:
|
|
|
124
151
|
with a new prefix. The key resources then stop with `DeployKeyIsCredential` and do not keep that
|
|
125
152
|
value, because a delete would revoke the OAuth token. Use a team access token or the Convex CLI
|
|
126
153
|
login.
|
|
154
|
+
- `Convex.Deployment` has the removal policy `retain` for every type. It never deletes a
|
|
155
|
+
production deployment, also not with `RemovalPolicy.destroy()` and also not a dev deployment that
|
|
156
|
+
became a production deployment: delete the project for that. A
|
|
157
|
+
dev or preview deployment is deleted only with `RemovalPolicy.destroy()`.
|
|
158
|
+
- `Convex.Deployment` takes over the project's production deployment without `--adopt`: Convex
|
|
159
|
+
creates it with the project, and the resource never changes or deletes it. A dev or preview
|
|
160
|
+
deployment that exists but is not in state belongs to someone else, such as a preview that CI
|
|
161
|
+
made with `npx convex deploy --preview-name`. The resource takes it over only with `--adopt`.
|
|
162
|
+
It never creates over it: a Convex create for an existing preview name deletes that preview.
|
|
163
|
+
- A deployment keeps its `projectId`, `type`, and `name`. A change stops the deploy with
|
|
164
|
+
`DeploymentIdentityChange`. The resource is never replaced.
|
|
165
|
+
- `Convex.Code` checks before the push that the deploy key fits the deployment, and after the push
|
|
166
|
+
that the CLI pushed to that deployment. A production deploy key on a preview stage stops the deploy
|
|
167
|
+
before the push.
|
|
127
168
|
- An `EnvironmentVariable` or a `DefaultEnvironmentVariable` that exists but is not in state
|
|
128
|
-
belongs to someone else. The provider overwrites it only with `--adopt`.
|
|
169
|
+
belongs to someone else. The provider overwrites it only with `--adopt`. The same is true for a
|
|
170
|
+
`Convex.Code` `env` variable that exists with another value.
|
|
129
171
|
- A variable keeps its name and deployment (a default keeps its project, name, and deployment
|
|
130
172
|
type). A change stops the deploy with `VariableIdentityChange`. To rename or move a variable,
|
|
131
173
|
create a new resource with a new logical id and remove the old one. A rename in place would
|
|
@@ -133,6 +175,11 @@ replace, or overwrite your data by accident:
|
|
|
133
175
|
- A variable write runs again after a Convex write conflict or a 5xx answer, at most four more
|
|
134
176
|
times. The write sets a value, so a second write has the same result.
|
|
135
177
|
|
|
178
|
+
Upgrade from 0.2: `Convex.Deploy` keeps working. To move to `Convex.Code`, add a
|
|
179
|
+
`Convex.Deployment` and a `Convex.Code` with a new logical id and remove the `Convex.Deploy`.
|
|
180
|
+
Removing `Convex.Deploy` changes nothing in Convex. For a preview stage, use `previewName`, not
|
|
181
|
+
`previewCreate`, while you still use `Convex.Deploy`.
|
|
182
|
+
|
|
136
183
|
Upgrade from 0.1: state from 0.1 records the policy `destroy` for each project. Run
|
|
137
184
|
`alchemy deploy` one time with 0.2 while the stack still declares the project. That deploy records
|
|
138
185
|
`retain`. Do this before you remove a project from the stack or run `alchemy destroy`.
|
|
@@ -148,9 +195,53 @@ the Convex dashboard.
|
|
|
148
195
|
changed `team`, `deploymentRegion`, or `deploymentType` stops the deploy. An existing project
|
|
149
196
|
with the same name is adopted only with `--adopt`. The removal policy is `retain`: only a
|
|
150
197
|
resource with `RemovalPolicy.destroy()` deletes the project with its deployments and data.
|
|
198
|
+
- `Convex.Deployment`: `{ projectId, type: "prod" }` or
|
|
199
|
+
`{ projectId, type: "dev" | "preview", name }`. Outputs `name` (such as `happy-animal-123`),
|
|
200
|
+
`url` (`https://<name>.convex.cloud`, with the region outside US East), `siteUrl` (the same
|
|
201
|
+
host on `.convex.site`), `type`, `projectId`, `reference`, and `previewName`.
|
|
202
|
+
- `prod` takes over the project's default production deployment, and follows it when another
|
|
203
|
+
production deployment becomes the default. It never creates one: a project without one stops
|
|
204
|
+
the deploy with `ProductionDeploymentNotFound`.
|
|
205
|
+
- `dev` creates a dev deployment with `name` as its reference, through
|
|
206
|
+
`POST /projects/{project_id}/create_deployment`. Convex records the member of the access token
|
|
207
|
+
as its creator. It is not that member's default dev deployment, so `npx convex dev` does not
|
|
208
|
+
select it.
|
|
209
|
+
- `preview` creates a preview deployment with `name` as its preview name, through the same
|
|
210
|
+
call. `npx convex deploy --preview-name <name>` with a preview deploy key finds it.
|
|
211
|
+
- When the deployment in state is gone, such as an expired preview, the next deploy creates it
|
|
212
|
+
again. Two deployments with the name stop the deploy with `AmbiguousDeployment`.
|
|
213
|
+
- `Convex.Code`: `{ deployment, deployKey, cwd, command?, env?, typecheck?, codegen? }`. Pushes
|
|
214
|
+
the functions of the Convex app in `cwd` with `convex deploy`. Outputs `deploymentName`,
|
|
215
|
+
`url`, `siteUrl`, `deployedAt` (milliseconds since the Unix epoch), and `envNames`.
|
|
216
|
+
- `deployment` is a `Convex.Deployment` resource or a deployment name. `deployKey` is a
|
|
217
|
+
deploy key of that deployment, or, for a preview deployment, a preview deploy key of the
|
|
218
|
+
project: Code then runs `convex deploy --preview-name <name>`. Any other key stops the deploy
|
|
219
|
+
with `DeployKeyMismatch` before the push.
|
|
220
|
+
- Code pushes on every deploy. It does not hash the sources: a preview can expire, a push from
|
|
221
|
+
outside Alchemy can change the deployment, and a hash misses workspace packages. The CLI
|
|
222
|
+
uploads only the modules that changed.
|
|
223
|
+
- Code runs the `convex` package that `cwd` resolves, with the Node.js that runs Alchemy, and
|
|
224
|
+
never downloads one (`ConvexCliNotFound`). `command`, such as `["pnpm", "exec", "convex"]`,
|
|
225
|
+
replaces it.
|
|
226
|
+
- The key goes to the CLI only in an env file with mode 0600 (`--env-file`), in a temporary
|
|
227
|
+
directory that is removed after the run, also after a failure or an interruption. That
|
|
228
|
+
directory is the home directory of the CLI, so the CLI cannot use the Convex login of the
|
|
229
|
+
machine. Variables named `CONVEX_*` are not passed on.
|
|
230
|
+
- The CLI output stays out of the logs. A failure (`CodePushFailed`) shows the last 20 lines
|
|
231
|
+
with the key removed. A push to another deployment stops the deploy with
|
|
232
|
+
`PushTargetMismatch`.
|
|
233
|
+
- `env` sets variables on the deployment before the push, with the deploy key. A name that
|
|
234
|
+
leaves `env` is removed from the deployment. A preview deploy key cannot set variables
|
|
235
|
+
(`EnvironmentNeedsDeployKey`).
|
|
236
|
+
- `typecheck` (`enable`, `try`, `disable`) and `codegen` (`enable`, `disable`) go to
|
|
237
|
+
`convex deploy` as flags.
|
|
238
|
+
- Deleting the resource does nothing. The functions and the `env` variables stay: the deployment
|
|
239
|
+
runs them.
|
|
151
240
|
- `Convex.DeployKey`: `{ deployment, name, allowedActions? }`. Outputs `uniqueName`, `keyId`, and
|
|
152
241
|
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.
|
|
242
|
+
from 0.1 state stays. Keys are never adopted: a key without its secret is useless. The live test
|
|
243
|
+
pushes with `Convex.Code` and sets `env` with a key that has only `deployment:deploy`,
|
|
244
|
+
`deployment:env:view`, and `deployment:env:write`.
|
|
154
245
|
- `Convex.PreviewDeployKey`: `{ projectId, name }`. Project-level key for preview deployments.
|
|
155
246
|
Outputs `uniqueName`, `keyId`, and `previewDeployKey`.
|
|
156
247
|
- `Convex.EnvironmentVariable`: `{ deployment, deployKey, name, value }`. One variable on one
|
|
@@ -164,12 +255,28 @@ the Convex dashboard.
|
|
|
164
255
|
existing default with the same name and type is adopted and overwritten only with `--adopt`. A
|
|
165
256
|
new `value` is an update in place. A new `projectId`, `name`, or `deploymentType` stops the
|
|
166
257
|
deploy with `VariableIdentityChange`: use a new logical id.
|
|
167
|
-
- `Convex.Deploy
|
|
168
|
-
memo?, timeout? }`. Runs
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
258
|
+
- `Convex.Deploy` (deprecated since 0.3, use `Convex.Code`): `{ cwd?, env?, deployKey,
|
|
259
|
+
previewName?, previewCreate?, previewRun?, extraArgs?, memo?, timeout? }`. Runs
|
|
260
|
+
`npx convex deploy` with `CONVEX_DEPLOY_KEY` set and parses the deployment URL from the CLI
|
|
261
|
+
output. Outputs `url`, `deploymentName`, `hash`. It stays so that stacks and state from 0.1
|
|
262
|
+
and 0.2 keep working. Deleting the resource does nothing.
|
|
263
|
+
|
|
264
|
+
### Which Convex call each operation uses
|
|
265
|
+
|
|
266
|
+
| Operation | Path |
|
|
267
|
+
| ---------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
268
|
+
| Find the production deployment | `GET /projects/{project_id}/list_deployments?deploymentType=prod&isDefault=true` |
|
|
269
|
+
| Find a dev or preview deployment by name | `GET /projects/{project_id}/list_deployments?deploymentType=<type>` |
|
|
270
|
+
| Create a dev or preview deployment | `POST /projects/{project_id}/create_deployment` with `type` and `reference` |
|
|
271
|
+
| Check that a deployment exists | `GET /deployments/{deployment_name}` |
|
|
272
|
+
| Delete a dev or preview deployment | `POST /deployments/{deployment_name}/delete` |
|
|
273
|
+
| Push to a deployment | `convex deploy --env-file <file>` with a deploy key of the deployment |
|
|
274
|
+
| Push to a preview deployment | `convex deploy --preview-name <name> --env-file <file>` with a preview deploy key |
|
|
275
|
+
| Set `env` variables | `POST https://<deployment>/api/v1/update_environment_variables` with the deploy key |
|
|
276
|
+
|
|
277
|
+
Code uses `--preview-name`, not `--preview-create`: `--preview-create` deletes and creates the
|
|
278
|
+
preview deployment again on every push, so every deploy would lose the preview data and change its
|
|
279
|
+
URL.
|
|
173
280
|
|
|
174
281
|
## Limits
|
|
175
282
|
|
|
@@ -181,8 +288,20 @@ memo?, timeout? }`. Runs `npx convex deploy` with `CONVEX_DEPLOY_KEY` set and pa
|
|
|
181
288
|
- A run that stops between a key create and the state write leaves a key that state does not
|
|
182
289
|
know. The next run stops with `DeployKeyRecoveryRequired`. Delete the listed key in the Convex
|
|
183
290
|
dashboard, then run the deploy again.
|
|
184
|
-
-
|
|
185
|
-
|
|
291
|
+
- A run that stops between a deployment create and the state write leaves a dev or preview
|
|
292
|
+
deployment that state does not know. The next run stops with `OwnedBySomeoneElse`. Run it with
|
|
293
|
+
`--adopt` to take that deployment over.
|
|
294
|
+
- Between the lookup and the create of a preview deployment, another writer can create a preview
|
|
295
|
+
with the same name. The Convex create then replaces it. The Management API has no create that
|
|
296
|
+
fails for an existing preview name.
|
|
297
|
+
- `siteUrl` is the `.convex.site` URL. A custom domain is not used.
|
|
298
|
+
- When another production deployment becomes the default, a `DeployKey` with `deployment: prod.name`
|
|
299
|
+
gets a new key on the new deployment. Alchemy plans this as an update, not a replacement, so the
|
|
300
|
+
key on the old deployment stays. Delete it in the Convex dashboard.
|
|
301
|
+
- Variables that `Convex.Code` set on a deployment stay there when `deployment` changes to
|
|
302
|
+
another deployment, and when the resource is removed.
|
|
303
|
+
- Not covered: deployment regions and classes, custom domains, log streams, teams and members,
|
|
304
|
+
components, snapshots.
|
|
186
305
|
|
|
187
306
|
## Development
|
|
188
307
|
|
|
@@ -207,6 +326,10 @@ A file argument runs one live file only, for example
|
|
|
207
326
|
through the Alchemy engine. It creates a project `tmp-alchemy-convex-<8 hex>` in
|
|
208
327
|
`ALCHEMY_CONVEX_LIVE_TEAM` and deletes it at the end, also after a failure. It refuses to delete a
|
|
209
328
|
project whose name does not start with `tmp-alchemy-convex-`.
|
|
329
|
+
`test/live/deployment-code.live.test.ts` does the same for `Convex.Deployment` and
|
|
330
|
+
`Convex.Code`: it pushes the app in `test/fixtures/convex-app` with the real Convex CLI to the
|
|
331
|
+
production deployment and to a preview deployment, and it also refuses to delete a deployment of
|
|
332
|
+
another project.
|
|
210
333
|
|
|
211
334
|
Releases: change `version` in `package.json` in a pull request. After the merge,
|
|
212
335
|
`.github/workflows/release.yml` publishes that version from `main` with npm trusted publishing.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Resource } from "alchemy";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
2
3
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import
|
|
4
|
+
import "effect/process/ChildProcessSpawner";
|
|
4
5
|
import * as Redacted from "effect/Redacted";
|
|
5
6
|
import * as Schema from "effect/Schema";
|
|
6
|
-
import { Resource } from "alchemy";
|
|
7
|
-
import * as Provider from "alchemy/Provider";
|
|
8
7
|
import { createDeploymentClient, createManagementClient } from "@convex-dev/platform";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
9
10
|
import { CommandExecutor, CommandRunProps } from "alchemy/Command";
|
|
10
11
|
import { MemoOptions } from "alchemy/Command/Memo";
|
|
11
12
|
import { components } from "@convex-dev/platform/managementApi";
|
|
@@ -85,6 +86,162 @@ declare class Providers extends Providers_base {}
|
|
|
85
86
|
*/
|
|
86
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>;
|
|
87
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
|
+
}
|
|
150
|
+
//#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;
|
|
161
|
+
/**
|
|
162
|
+
* A deploy key of `deployment` (Convex.DeployKey), or, for a preview
|
|
163
|
+
* deployment, a preview deploy key of its project (Convex.PreviewDeployKey).
|
|
164
|
+
*/
|
|
165
|
+
readonly deployKey: Redacted.Redacted<string>;
|
|
166
|
+
/** The Convex app directory: the one with `convex/` and the `convex` package installed. */
|
|
167
|
+
readonly cwd: string;
|
|
168
|
+
/**
|
|
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.
|
|
172
|
+
*/
|
|
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;
|
|
214
|
+
}>, 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 {
|
|
217
|
+
get message(): string;
|
|
218
|
+
}
|
|
219
|
+
declare const ConvexCliNotFound_base: Schema.Class<ConvexCliNotFound, Schema.TaggedStruct<"ConvexCliNotFound", {
|
|
220
|
+
readonly cwd: Schema.String;
|
|
221
|
+
}>, import("effect/Cause").YieldableError>;
|
|
222
|
+
/** No `convex` package resolves from `cwd`. */
|
|
223
|
+
declare class ConvexCliNotFound extends ConvexCliNotFound_base {
|
|
224
|
+
get message(): string;
|
|
225
|
+
}
|
|
226
|
+
declare const CodePushFailed_base: Schema.Class<CodePushFailed, Schema.TaggedStruct<"CodePushFailed", {
|
|
227
|
+
/** Exit code of the CLI. Undefined when it did not start or a signal stopped it. */
|
|
228
|
+
readonly exitCode: Schema.UndefinedOr<Schema.Number>;
|
|
229
|
+
/** The last lines of the CLI output, with the deploy key removed. */
|
|
230
|
+
readonly outputTail: Schema.String;
|
|
231
|
+
}>, import("effect/Cause").YieldableError>;
|
|
232
|
+
/** 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 {
|
|
234
|
+
get message(): string;
|
|
235
|
+
}
|
|
236
|
+
declare const PushTargetMismatch_base: Schema.Class<PushTargetMismatch, Schema.TaggedStruct<"PushTargetMismatch", {
|
|
237
|
+
readonly expected: Schema.String;
|
|
238
|
+
readonly actual: Schema.String;
|
|
239
|
+
}>, 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 {
|
|
242
|
+
get message(): string;
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
88
245
|
//#region src/DefaultEnvironmentVariable.d.ts
|
|
89
246
|
/** Deployment types a default can target, from the generated schema. */
|
|
90
247
|
type DeploymentType = components["schemas"]["DeploymentType"];
|
|
@@ -153,12 +310,13 @@ interface DeployAttributes {
|
|
|
153
310
|
readonly hash: string | undefined;
|
|
154
311
|
}
|
|
155
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
|
+
*/
|
|
156
319
|
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
320
|
/** The `convex deploy` argv, starting with `npx`. */
|
|
163
321
|
declare const deployArgs: (props: Pick<DeployProps, "previewName" | "previewCreate" | "previewRun" | "extraArgs">) => readonly string[];
|
|
164
322
|
declare const DeployArgumentError_base: Schema.Class<DeployArgumentError, Schema.TaggedStruct<"DeployArgumentError", {
|
|
@@ -349,5 +507,5 @@ declare class CreatedProjectNotFound extends CreatedProjectNotFound_base {
|
|
|
349
507
|
get message(): string;
|
|
350
508
|
}
|
|
351
509
|
//#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 };
|
|
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 };
|
|
353
511
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/Credentials.ts","../src/ManagementApi.ts","../src/Providers.ts","../src/Deployment.ts","../src/Code.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;;;;cCnEtB,kBAAkB;;;;;cAMlB,YAAa,cAAa,MAAM,MAAM,iBAA2B,MAAA,MAAA,+DAAA,kDAAA,mCAAA;;;KCgBlE;;WAGG;;WAEA;;;WAIA;;WAEA;;;;;WAKA;;UAGE;WACN;WACA,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;KAGC,aAAa,8BAEvB,iBACA,6BAEA;cAEW,8BAAU,cAAA;;;;;;;;;cAKV,iCAAiC;MAU/B;;;;;;cAMF,qCAAqC;MAInC;;;;;;;;;cAMF,4BAA4B;MAS1B;;;;;KCpEH,iBAAiB,KAAK;UAEjB;;;;;;WAMN,qBAAqB;;;;;WAKrB,WAAW,SAAS;;WAEpB;;;;;;WAMA;;WAEA,MAAM,SAAS,wBAAwB,SAAS;;WAEhD;;WAEA;;UAGM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;KAGC,OAAO,wBAAwB,WAAW,uBAAuB;cAChE,wBAAI,cAAA;;cAYJ,oBACX;EACG;EAAa;;;;;;;;;;;cAgCL,0BAA0B;MAWxB;;;;;;cAeF,kCAAkC;MAIhC;;;;;;cAMF,0BAA0B;MAIxB;;;;;;;;;cAMF,uBAAuB;MAMrB;;;;;;;cAQF,2BAA2B;MAIzB;;;;;KC5KH,iBAAiB;UAgGZ;;WAEN;WACA;WACA,gBAAgB,SAAS;;WAEzB,gBAAgB;;UAGV;WACN;WACA;WACA,gBAAgB;;KAGf,6BAA6B,8CAEvC,iCACA,6CAEA;cAEW,8CAA0B,cAAA;;;UCtItB,oBAAoB,KAAK;;;;;;WAM/B,WAAW,SAAS;;;;;WAKpB;;;;;WAKA;;;;;WAKA;;;;;;WAMA;;;;;;;;;;WAUA,OAAO;;UAGD;;WAEN;;WAEA;;WAEA;;KAGC,SAAS,0BAA0B,aAAa,yBAAyB;;;;;;;cAOxE,0BAAM,cAAA;;cAGN,aACX,OAAO,KAAK;;;;;cAeD,4BAA4B;MAI1B;;;;;;cAMF,0BAA0B;MAIxB;;;;;KCrEH,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;;;UCpGL;;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;;;;UC/IE;;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"}
|