@samebase/alchemy-convex 0.27.3 → 0.28.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 +24 -18
- package/lib/{HubClient-Bs5_j18U.js → HubClient-BcegkjaP.js} +9 -6
- package/lib/HubClient-BcegkjaP.js.map +1 -0
- package/lib/cli.js +1 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/Deployment.ts +17 -7
- package/src/cli.ts +0 -0
- package/lib/HubClient-Bs5_j18U.js.map +0 -1
package/README.md
CHANGED
|
@@ -275,9 +275,11 @@ call.
|
|
|
275
275
|
- `prod` is the project's default production deployment (with a deploy key: the key's production
|
|
276
276
|
deployment). The resource never creates or deletes one. A production deployment with code that
|
|
277
277
|
is not in state is taken over only with `--adopt`.
|
|
278
|
-
- `dev` creates a dev deployment with `name` as its reference
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
- `dev` creates a dev deployment with `name` as its reference. With `--adopt`, `name` can also be
|
|
279
|
+
the Convex name of a dev deployment that exists, such as `happy-animal-123` from `.env.local`,
|
|
280
|
+
which `npx convex dev` made: the resource takes it over. A name that matches nothing creates a
|
|
281
|
+
dev deployment with that reference. `preview` creates a preview deployment with `name` as its
|
|
282
|
+
preview name. An expired preview is created again on the next deploy.
|
|
281
283
|
- `rootDir` is the app directory, relative to the directory where the deploy runs, `"."` by
|
|
282
284
|
default. It must be relative (`AbsoluteRootDir`) and have a package.json (`ConvexAppNotFound`).
|
|
283
285
|
There is no search in the directories above it. When convex.json puts the functions outside
|
|
@@ -371,27 +373,29 @@ variables. Each callback remains one exact registered URI.
|
|
|
371
373
|
|
|
372
374
|
### The development stage
|
|
373
375
|
|
|
374
|
-
A laptop
|
|
375
|
-
`
|
|
376
|
-
|
|
376
|
+
A laptop gets its client from a stage `dev-<name>` of the app's stack, run on purpose, not at each
|
|
377
|
+
dev start: `npx convex dev` has made and selected the dev deployment and pushed the code, and then
|
|
378
|
+
`alchemy deploy --stage dev-<name>` gives that deployment its variables. The stage creates nothing
|
|
379
|
+
and pushes nothing. It has three rows on the deployment that `.env.local` selects, taken over by its
|
|
380
|
+
Convex name:
|
|
377
381
|
|
|
378
382
|
```ts
|
|
379
|
-
//
|
|
383
|
+
// `selected` is the name in CONVEX_DEPLOYMENT of .env.local, such as happy-animal-123, and
|
|
384
|
+
// `project` is the project of stage `prod`.
|
|
380
385
|
const prod = Convex.SharedHubClient.read("HubClient", { stage: "prod" });
|
|
381
|
-
const
|
|
386
|
+
const site =
|
|
382
387
|
yield *
|
|
383
|
-
Convex.Deployment("
|
|
388
|
+
Convex.Deployment("Verification", {
|
|
384
389
|
project,
|
|
385
390
|
type: "dev",
|
|
386
|
-
name:
|
|
387
|
-
source: "./convex",
|
|
391
|
+
name: selected,
|
|
388
392
|
env: { SAMEBASE_REPOSITORY_ID: prod.repository },
|
|
389
393
|
}).pipe(adopt(true));
|
|
390
394
|
const hub =
|
|
391
395
|
yield *
|
|
392
396
|
Convex.SharedHubClient("HubClient", {
|
|
393
397
|
app: "scout",
|
|
394
|
-
redirectUri: Output.interpolate`${
|
|
398
|
+
redirectUri: Output.interpolate`${site.siteUrl}/auth/hub/callback`,
|
|
395
399
|
deploymentType: "development",
|
|
396
400
|
initialAccessToken: prod.initialAccessToken,
|
|
397
401
|
});
|
|
@@ -400,7 +404,7 @@ yield *
|
|
|
400
404
|
Convex.Deployment("Site", {
|
|
401
405
|
project,
|
|
402
406
|
type: "dev",
|
|
403
|
-
name:
|
|
407
|
+
name: selected,
|
|
404
408
|
env: {
|
|
405
409
|
HUB_ISSUER: variables.issuer,
|
|
406
410
|
HUB_CLIENT_ID: variables.clientId,
|
|
@@ -412,11 +416,13 @@ yield *
|
|
|
412
416
|
The imports are `alchemy/AdoptPolicy` for `adopt` and `alchemy/Output` for `Output`.
|
|
413
417
|
|
|
414
418
|
1. `read` gives the initial access token and the repository id from the `HubClient` row of stage
|
|
415
|
-
`prod`.
|
|
416
|
-
2. "
|
|
417
|
-
`
|
|
418
|
-
|
|
419
|
-
|
|
419
|
+
`prod`.
|
|
420
|
+
2. "Verification" sets `SAMEBASE_REPOSITORY_ID`, which the site serves as
|
|
421
|
+
`/samebase-verification.json`. `adopt` takes over the deployment and the variables that the dev
|
|
422
|
+
start set before.
|
|
423
|
+
3. "HubClient" asks the hub for a development client on the deployment's site URL with the token. A
|
|
424
|
+
later run renews it. A sign-in renews it too, so a laptop in use never needs the stage again; a
|
|
425
|
+
development client expires 14 days after its last run or sign-in.
|
|
420
426
|
4. "Site" writes the three variables. It removes only a name that leaves its own `env`, so
|
|
421
427
|
`SAMEBASE_REPOSITORY_ID` stays.
|
|
422
428
|
|
|
@@ -782,7 +782,8 @@ const checkIdentity = (current, news) => {
|
|
|
782
782
|
if (current.projectId !== news.project.projectId) return change("projectId", String(current.projectId), String(news.project.projectId));
|
|
783
783
|
if (current.type !== news.type) return change("type", current.type, news.type);
|
|
784
784
|
const currentName = nameOf(current);
|
|
785
|
-
|
|
785
|
+
const named = news.type === "dev" && current.name === news.name;
|
|
786
|
+
if (news.type !== "prod" && currentName !== news.name && !named) return change("name", currentName ?? "(none)", news.name);
|
|
786
787
|
return Effect.void;
|
|
787
788
|
};
|
|
788
789
|
const addressOf = (props) => ({
|
|
@@ -824,11 +825,13 @@ const DeploymentProvider = () => Provider.effect(DeploymentResource, Effect.gen(
|
|
|
824
825
|
/** The project's default production deployment, or undefined. */
|
|
825
826
|
const production = (management, projectId) => productionRow(management, projectId).pipe(Effect.map((row) => row === void 0 ? void 0 : targetOf(row, "prod", void 0)));
|
|
826
827
|
/**
|
|
827
|
-
* The one dev deployment with this reference, or the
|
|
828
|
-
* deployment with this preview name, or undefined.
|
|
828
|
+
* The one dev deployment with this reference or this Convex name, or the
|
|
829
|
+
* one preview deployment with this preview name, or undefined. The name
|
|
830
|
+
* form takes the dev deployment that `npx convex dev` made, such as the
|
|
831
|
+
* one `.env.local` selects, which has a reference the stack never chose.
|
|
829
832
|
*/
|
|
830
833
|
const findByName = (management, projectId, type, name) => Effect.gen(function* () {
|
|
831
|
-
const matches = (yield* listDeployments(management, projectId, type)).filter((row) => row.deploymentType === type && (type === "dev" ? row.reference === name : row.previewIdentifier === name));
|
|
834
|
+
const matches = (yield* listDeployments(management, projectId, type)).filter((row) => row.deploymentType === type && (type === "dev" ? row.reference === name || row.name === name : row.previewIdentifier === name));
|
|
832
835
|
if (matches.length > 1) return yield* new AmbiguousDeployment({
|
|
833
836
|
projectId,
|
|
834
837
|
type,
|
|
@@ -843,7 +846,7 @@ const DeploymentProvider = () => Provider.effect(DeploymentResource, Effect.gen(
|
|
|
843
846
|
const deployKeyTarget = (key, deployment, address) => Effect.gen(function* () {
|
|
844
847
|
const info = Schema.decodeUnknownSync(DeploymentInfo)(yield* api.deploymentRequest("get deployment info", deployment, key, (client) => client.GET("/deployment_info")));
|
|
845
848
|
const reference = info.reference ?? "";
|
|
846
|
-
if (info.projectId !== address.projectId || info.deploymentType !== address.type || address.type === "dev" && reference !== address.name) return;
|
|
849
|
+
if (info.projectId !== address.projectId || info.deploymentType !== address.type || address.type === "dev" && reference !== address.name && deployment !== address.name) return;
|
|
847
850
|
const urls = Schema.decodeUnknownSync(CanonicalUrls)(yield* api.deploymentRequest("get canonical urls", deployment, key, (client) => client.GET("/get_canonical_urls")));
|
|
848
851
|
return {
|
|
849
852
|
projectId: info.projectId,
|
|
@@ -1989,4 +1992,4 @@ const registerDevelopmentClient = (options) => Effect.gen(function* () {
|
|
|
1989
1992
|
//#endregion
|
|
1990
1993
|
export { PushTargetMismatch as A, DEPLOY_KEY_ENV as B, DeploymentProvider as C, ConvexAppNotFound as D, CodePushFailed as E, ManagementApi as F, fromValues as H, ManagementApiLive as I, ACCESS_TOKEN_ENV as L, installedCli as M, parseDeployOutput as N, ConvexCliNotFound as O, ConvexApiError as P, Credentials as R, DeploymentIdentityChange as S, ProductionDeploymentNotFound as T, fromConfig as V, ProjectProvider as _, registerDevelopmentClient as a, AmbiguousDeployment as b, RUN_RECORD_KEY as c, withRunRecord as d, AmbiguousProject as f, ProjectNotFound as g, ProjectDeploymentChange as h, HubClientProvider as i, VariablesOwnedBySomeoneElse as j, EnvironmentNeedsDeployKey as k, RunRecordError as l, Project as m, HubClient as n, STORE_PROJECT_NAME as o, CreatedProjectNotFound as p, HubClientFailed as r, state as s, HUB_PROJECT_NAME as t, runRecord as u, ProjectTeamChange as v, DeploymentResource as w, Deployment as x, AbsoluteRootDir as y, CredentialsError as z };
|
|
1991
1994
|
|
|
1992
|
-
//# sourceMappingURL=HubClient-
|
|
1995
|
+
//# sourceMappingURL=HubClient-BcegkjaP.js.map
|