@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 +21 -16
- package/lib/index.d.ts +11 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +234 -157
- package/lib/index.js.map +1 -1
- package/package.json +2 -3
- package/src/Deployment.ts +9 -2
- package/src/Project.ts +125 -88
- package/src/Push.ts +74 -46
- package/src/State.ts +278 -159
- package/src/index.ts +1 -1
- package/src/{component/_generated/api.ts → store/convex/_generated/api.d.ts} +9 -8
- package/src/store/convex/_generated/api.js +23 -0
- package/src/{component/_generated/server.ts → store/convex/_generated/server.d.ts} +18 -25
- package/src/store/convex/_generated/server.js +101 -0
- package/src/{component → store/convex}/state.ts +96 -46
- package/src/store/convex/version.ts +6 -0
- package/src/store/package.json +8 -0
- package/src/component/_generated/component.ts +0 -92
- package/src/component/convex.config.ts +0 -5
- /package/src/{component/_generated/dataModel.ts → store/convex/_generated/dataModel.d.ts} +0 -0
- /package/src/{component → store/convex}/schema.ts +0 -0
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
|
|
96
|
-
project, so
|
|
97
|
-
[docs/design/convex-state.md](docs/design/convex-state.md) records the
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
store
|
|
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
|
-
/**
|
|
345
|
-
export declare const
|
|
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
|
|
348
|
-
*
|
|
349
|
-
* the project
|
|
350
|
-
* `
|
|
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: (
|
|
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
|
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/Push.ts","../src/Deployment.ts","../src/Project.ts","../src/State.ts"],"mappings":"
|
|
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;;;;;;;;;qBAiC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