@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/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as PushTargetMismatch, B as DEPLOY_KEY_ENV, C as DeploymentProvider, D as ConvexAppNotFound, E as CodePushFailed, F as ManagementApi, H as fromValues, I as ManagementApiLive, L as ACCESS_TOKEN_ENV, N as parseDeployOutput, O as ConvexCliNotFound, P as ConvexApiError, R as Credentials, S as DeploymentIdentityChange, T as ProductionDeploymentNotFound, V as fromConfig, _ as ProjectProvider, b as AmbiguousDeployment, c as RUN_RECORD_KEY, d as withRunRecord, f as AmbiguousProject, g as ProjectNotFound, h as ProjectDeploymentChange, i as HubClientProvider, j as VariablesOwnedBySomeoneElse, k as EnvironmentNeedsDeployKey, l as RunRecordError, m as Project, n as HubClient, o as STORE_PROJECT_NAME, p as CreatedProjectNotFound, r as HubClientFailed, s as state, t as HUB_PROJECT_NAME, u as runRecord, v as ProjectTeamChange, w as DeploymentResource, x as Deployment, y as AbsoluteRootDir, z as CredentialsError } from "./HubClient-Bs5_j18U.js";
1
+ import { A as PushTargetMismatch, B as DEPLOY_KEY_ENV, C as DeploymentProvider, D as ConvexAppNotFound, E as CodePushFailed, F as ManagementApi, H as fromValues, I as ManagementApiLive, L as ACCESS_TOKEN_ENV, N as parseDeployOutput, O as ConvexCliNotFound, P as ConvexApiError, R as Credentials, S as DeploymentIdentityChange, T as ProductionDeploymentNotFound, V as fromConfig, _ as ProjectProvider, b as AmbiguousDeployment, c as RUN_RECORD_KEY, d as withRunRecord, f as AmbiguousProject, g as ProjectNotFound, h as ProjectDeploymentChange, i as HubClientProvider, j as VariablesOwnedBySomeoneElse, k as EnvironmentNeedsDeployKey, l as RunRecordError, m as Project, n as HubClient, o as STORE_PROJECT_NAME, p as CreatedProjectNotFound, r as HubClientFailed, s as state, t as HUB_PROJECT_NAME, u as runRecord, v as ProjectTeamChange, w as DeploymentResource, x as Deployment, y as AbsoluteRootDir, z as CredentialsError } from "./HubClient-BcegkjaP.js";
2
2
  import { toPath } from "alchemy/FQN";
3
3
  import { Stack } from "alchemy/Stack";
4
4
  import * as Effect from "effect/Effect";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samebase/alchemy-convex",
3
- "version": "0.27.3",
3
+ "version": "0.28.0",
4
4
  "description": "The Convex plane for Alchemy v2: projects, deployments, environment variables, and the push of the functions",
5
5
  "keywords": [
6
6
  "alchemy",
package/src/Deployment.ts CHANGED
@@ -113,8 +113,11 @@ export type DeploymentProps =
113
113
  /** A dev deployment or a preview deployment that this resource creates. Cannot change. */
114
114
  readonly type: "dev" | "preview";
115
115
  /**
116
- * The dev reference, such as `staging`, or the preview name, such as
117
- * the stage name. Unique in the project. Cannot change.
116
+ * The dev reference, such as `staging`, or the Convex name of a dev
117
+ * deployment that exists, such as `happy-animal-123` from `.env.local`,
118
+ * which `adopt` takes over; a name that matches nothing creates a dev
119
+ * deployment with that reference. Or the preview name, such as the
120
+ * stage name. Unique in the project. Cannot change.
118
121
  */
119
122
  readonly name: string;
120
123
  });
@@ -334,7 +337,9 @@ const checkIdentity = (current: DeploymentTarget, news: DeploymentProps) => {
334
337
  }
335
338
  if (current.type !== news.type) return change("type", current.type, news.type);
336
339
  const currentName = nameOf(current);
337
- if (news.type !== "prod" && currentName !== news.name) {
340
+ // A dev deployment is also named by its Convex name, as `findByName` finds it.
341
+ const named = news.type === "dev" && current.name === news.name;
342
+ if (news.type !== "prod" && currentName !== news.name && !named) {
338
343
  return change("name", currentName ?? "(none)", news.name);
339
344
  }
340
345
  return Effect.void;
@@ -454,8 +459,10 @@ export const DeploymentProvider = () =>
454
459
  );
455
460
 
456
461
  /**
457
- * The one dev deployment with this reference, or the one preview
458
- * deployment with this preview name, or undefined.
462
+ * The one dev deployment with this reference or this Convex name, or the
463
+ * one preview deployment with this preview name, or undefined. The name
464
+ * form takes the dev deployment that `npx convex dev` made, such as the
465
+ * one `.env.local` selects, which has a reference the stack never chose.
459
466
  */
460
467
  const findByName = (
461
468
  management: ManagementApiService,
@@ -467,7 +474,9 @@ export const DeploymentProvider = () =>
467
474
  const matches = (yield* listDeployments(management, projectId, type)).filter(
468
475
  (row) =>
469
476
  row.deploymentType === type &&
470
- (type === "dev" ? row.reference === name : row.previewIdentifier === name),
477
+ (type === "dev"
478
+ ? row.reference === name || row.name === name
479
+ : row.previewIdentifier === name),
471
480
  );
472
481
  if (matches.length > 1) {
473
482
  return yield* new AmbiguousDeployment({
@@ -503,10 +512,11 @@ export const DeploymentProvider = () =>
503
512
  ),
504
513
  );
505
514
  const reference = info.reference ?? "";
515
+ // A dev address names the reference or the Convex name, as `findByName` finds it.
506
516
  if (
507
517
  info.projectId !== address.projectId ||
508
518
  info.deploymentType !== address.type ||
509
- (address.type === "dev" && reference !== address.name)
519
+ (address.type === "dev" && reference !== address.name && deployment !== address.name)
510
520
  ) {
511
521
  return undefined;
512
522
  }
package/src/cli.ts CHANGED
File without changes