@samebase/alchemy-convex 0.5.0 → 0.6.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 CHANGED
@@ -92,24 +92,29 @@ values explicitly: `Convex.providers(Convex.fromValues({ accessToken, deployKey
92
92
 
93
93
  ## State in Convex
94
94
 
95
- `state: Convex.state()` keeps the Alchemy state of every stage in the production deployment of the
96
- project, so the stack needs no Cloudflare token.
97
- [docs/design/convex-state.md](docs/design/convex-state.md) records the decisions.
95
+ `state: Convex.state({ team })` keeps the Alchemy state of every stack and stage of a Convex team in
96
+ one project of that team, `alchemy-state`, so a repository holds one secret and a stack can create
97
+ and destroy its own project. [docs/design/convex-state.md](docs/design/convex-state.md) records the
98
+ decisions and the measurements.
98
99
 
99
- 1. Mount the state component in `convex/convex.config.ts` with its default name:
100
-
101
- ```ts
102
- import alchemyState from "@samebase/alchemy-convex/convex.config";
103
- app.use(alchemyState);
104
- ```
105
-
106
- 2. Set `CONVEX_STATE_DEPLOY_KEY` in every run, a preview run too, to a production deploy key. A key
107
- with only the actions `deployment:data:view` and `deployment:data:write` is sufficient.
100
+ ```ts
101
+ export default Alchemy.Stack(
102
+ process.env["GITHUB_REPOSITORY"] ?? "my-org/my-app", // the stack name: the repository
103
+ { providers: Convex.providers(), state: Convex.state({ team: "my-team" }) },
104
+ Effect.gen(function* () {
105
+ /* ... */
106
+ }),
107
+ );
108
+ ```
108
109
 
109
- The first run starts with empty state, keeps it in memory until `Convex.Deployment` has pushed the
110
- component, and then writes it. A run whose push does not mount the component fails at the end.
111
- Rows are in the `alchemyState` component tables `resources` and `outputs` in the dashboard. The
112
- store has no lock: run one deploy of a stage at a time, such as with a CI concurrency group.
110
+ Every run needs the team token in `CONVEX_ACCESS_TOKEN`, or the Convex CLI login on a laptop. The
111
+ first run of a team creates the project `alchemy-state` and pushes the store functions to its
112
+ production deployment with the Convex CLI of the app; a later version of this package pushes a
113
+ newer store when it finds an older one, and never an older one over a newer one. Each run makes a
114
+ deploy key of that deployment that can only run the store's internal functions, and deletes it at
115
+ the end. Rows are in the tables `resources` and `outputs` in the dashboard, under the stack name.
116
+ The store has no lock: run one deploy of a stage at a time, such as with a CI concurrency group.
117
+ The names of the store functions are a wire contract: never renamed or removed.
113
118
 
114
119
  ## Resources
115
120
 
package/lib/index.d.ts CHANGED
@@ -5,8 +5,9 @@ import * as Redacted from "effect/Redacted";
5
5
  import * as Schema from "effect/Schema";
6
6
  import { Resource } from "alchemy";
7
7
  import * as Provider from "alchemy/Provider";
8
- import "effect/process/ChildProcessSpawner";
8
+ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
9
9
  import { createDeploymentClient, createManagementClient } from "@convex-dev/platform";
10
+ import "effect/Scope";
10
11
  import { State, StateStoreError } from "alchemy/State";
11
12
  import { components } from "@convex-dev/platform/managementApi";
12
13
  //#region src/Credentials.d.ts
@@ -341,15 +342,17 @@ export declare class ProjectNotFound extends ProjectNotFound_base {
341
342
  }
342
343
  //#endregion
343
344
  //#region src/State.d.ts
344
- /** Environment variable with the deploy key of the deployment that holds the state. */
345
- export declare const STATE_DEPLOY_KEY_ENV = "CONVEX_STATE_DEPLOY_KEY";
345
+ /** The name of the state project in each team. */
346
+ export declare const STORE_PROJECT_NAME = "alchemy-state";
346
347
  /**
347
- * Alchemy state in the alchemyState component of the deployment that the
348
- * deploy key in CONVEX_STATE_DEPLOY_KEY names: the production deployment of
349
- * the project. The key needs the actions `deployment:data:view` and
350
- * `deployment:data:write`.
348
+ * Alchemy state in the `alchemy-state` project of `team`, with the team token
349
+ * in CONVEX_ACCESS_TOKEN or the Convex CLI login. The first use of the run
350
+ * finds or creates the project and pushes the store when it is missing or
351
+ * older. `alchemy plan` on another stack never touches Convex.
351
352
  */
352
- export declare const state: () => Layer.Layer<State>;
353
+ export declare const state: (options: {
354
+ readonly team: string | number;
355
+ }) => Layer.Layer<State, never, ChildProcessSpawner.ChildProcessSpawner>;
353
356
  //#endregion
354
357
  export type { DeploymentAttributes, DeploymentProps, DeploymentRegion, EnvValue, ProjectAttributes, ProjectProps, Source };
355
358
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/Credentials.ts","../src/ManagementApi.ts","../src/Providers.ts","../src/Push.ts","../src/Deployment.ts","../src/Project.ts","../src/State.ts"],"mappings":";;;;;;;;;;;;UA6BiB;;WAEN,aAAa,SAAS;;WAEtB;;UAGM;;WAEN,aAAa,OAAO,OAAO;;WAE3B,gBAAgB,OAAO;;WAEvB,WAAW,OAAO,OAAO,SAAS;;;qBAGhC,oBAAoB;;qBAKpB;;qBAGA;;;;qBAOA,yBAAyB;;;;;;;;;qBAiCzB,kBAAiB,MAAM,MAAM;;qBA0B7B,aAAc;WAChB,cAAc,SAAS;WACvB,YAAY,SAAS;MAC5B,MAAM,MAAM;;;KC3GJ,mBAAmB,kBAAkB;KACrC,mBAAmB,kBAAkB;;UAGhC,YAAY;WAClB,OAAO;WACP;WACA,UAAU;;;;;;;;;;;;;qBAQR,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;;;;;WAK9C,YAAY,OAAO,SAAS,qBAAqB;;;qBAM/C,sBAAsB;;;;qBClFtB,kBAAkB;;;;;;qBAOlB,YAAa,cAAa,MAAM,MAAM,iBAA2B,MAAA,MAAA,8CAAA,mCAAA,oDAAA;;;;KC8BlE,oBAAoB,SAAS;;;;;KAM7B;;WAIG;;;;;;;;WAQA;;;;;;;WAOA;;;;;;qBA2BF,0BAA0B;MAIxB;;;;;;qBAMF,0BAA0B;MAIxB;;;;;;;;;qBAMF,uBAAuB;MAMrB;;;;;;;qBAQF,2BAA2B;MAIzB;;;;;;;qBAMF,oCAAoC;MAIlC;;;;;;qBAMF,kCAAkC;MAIhC;;;qBAuCF,oBACX;EACG;EAAa;;;;UCzHR;;WAEC;aAAoB;;;;;;;;WAOpB,SAAS;;WAET,MAAM,SAAS,eAAe;;KAG7B,mBACP;;WAEU;MAEV;;WAEU;;;;;WAKA;;;UAIL;WACC;WACA,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;UAGM,6BAA6B;;WAEnC;;WAEA;;YAGC,aAAa,8BAEvB,iBACA,6BAEA;qBAEW,8BAAU,cAAA;;;;;;;;;qBAKV,iCAAiC;MAU/B;;;;;;qBAMF,qCAAqC;MAInC;;;;;;;;;qBAMF,4BAA4B;MAS1B;;;;;KChJH,mBAAmB;KAEnB;;WAGG;;WAEA;;WAEA,mBAAmB;;WAEnB;;;WAIA;;WAEA;;UAGE;WACN;WACA;WACA;WACA;WACA;WACA;;YAGC,UAAU,2BAA2B,cAAc,0BAA0B;qBAC5E,2BAAO,cAAA;;;;;;;qBAGP,0BAA0B;MAIxB;;;;;;;;;;;;qBASF,gCAAgC;MAS9B;;;;;;;;qBAOF,yBAAyB;MAKvB;;;;;;qBAMF,+BAA+B;MAI7B;;;;;;;qBAMF,wBAAwB;MAItB;;;;;qBC7EF;;;;;;;qBAgQA,aAAY,MAAM,MAAM"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/Credentials.ts","../src/ManagementApi.ts","../src/Providers.ts","../src/Push.ts","../src/Deployment.ts","../src/Project.ts","../src/State.ts"],"mappings":";;;;;;;;;;;;;UA6BiB;;WAEN,aAAa,SAAS;;WAEtB;;UAGM;;WAEN,aAAa,OAAO,OAAO;;WAE3B,gBAAgB,OAAO;;WAEvB,WAAW,OAAO,OAAO,SAAS;;;qB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