@samebase/alchemy-convex 0.31.0 → 0.32.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 +36 -36
- package/lib/{State-t0BZggNl.js → State-CuktZaOh.js} +6 -6
- package/lib/{State-t0BZggNl.js.map → State-CuktZaOh.js.map} +1 -1
- package/lib/cli.js +1 -1
- package/lib/index.d.ts +9 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -6
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/LocalDeployment.ts +1 -1
- package/src/RunRecord.ts +10 -5
- package/src/SharedHubClient.ts +14 -12
- package/src/store/component/_generated/component.ts +5 -5
- package/src/store/component/runRecord.ts +2 -2
- package/src/store/convex/version.ts +2 -1
package/README.md
CHANGED
|
@@ -182,20 +182,20 @@ export default Alchemy.Stack(
|
|
|
182
182
|
);
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
Every run needs the team token in `CONVEX_ACCESS_TOKEN`, or the Convex CLI login on a
|
|
186
|
-
state and the projects are in the team of that credential. A team access token and an
|
|
187
|
-
a team name their team. The Convex CLI login names no team, so the run uses the team
|
|
188
|
-
deployment that the Convex CLI selected: `CONVEX_DEPLOYMENT` in the environment or in
|
|
189
|
-
which `npx convex dev` writes. A logged-in local deployment gives the team of its
|
|
190
|
-
folder's `.convex/local/default/config.json`. An anonymous deployment is in no
|
|
191
|
-
stops and asks for a deployment of a project. The first run of a team creates the
|
|
192
|
-
`alchemy-state-store` and pushes the store functions to its production deployment with the
|
|
193
|
-
CLI of the app; a later version of this package pushes a newer store when it finds an older
|
|
194
|
-
store that is newer than the package fails the run with both versions, so the repositories of
|
|
195
|
-
upgrade the package together. Each run makes a deploy key of that deployment that can only
|
|
196
|
-
store's internal functions, and deletes it at the end. Rows are in the tables `resources`
|
|
197
|
-
`outputs` of the component `alchemyState` in the dashboard, under the stack name. The store has
|
|
198
|
-
lock: run one deploy of a stage at a time, such as with a CI concurrency group. The store and its
|
|
185
|
+
Every run needs the team token in `CONVEX_ACCESS_TOKEN`, or the Convex CLI login on a development
|
|
186
|
+
machine. The state and the projects are in the team of that credential. A team access token and an
|
|
187
|
+
OAuth token of a team name their team. The Convex CLI login names no team, so the run uses the team
|
|
188
|
+
of the deployment that the Convex CLI selected: `CONVEX_DEPLOYMENT` in the environment or in
|
|
189
|
+
`.env.local`, which `npx convex dev` writes. A logged-in local deployment gives the team of its
|
|
190
|
+
project, from the folder's `.convex/local/default/config.json`. An anonymous deployment is in no
|
|
191
|
+
team, so the run stops and asks for a deployment of a project. The first run of a team creates the
|
|
192
|
+
project `alchemy-state-store` and pushes the store functions to its production deployment with the
|
|
193
|
+
Convex CLI of the app; a later version of this package pushes a newer store when it finds an older
|
|
194
|
+
one. A store that is newer than the package fails the run with both versions, so the repositories of
|
|
195
|
+
a team upgrade the package together. Each run makes a deploy key of that deployment that can only
|
|
196
|
+
run the store's internal functions, and deletes it at the end. Rows are in the tables `resources`
|
|
197
|
+
and `outputs` of the component `alchemyState` in the dashboard, under the stack name. The store has
|
|
198
|
+
no lock: run one deploy of a stage at a time, such as with a CI concurrency group. The store and its
|
|
199
199
|
readers (Samebase) are released and upgraded together.
|
|
200
200
|
|
|
201
201
|
Store version 3 supports native subscriptions. A trusted server checks repository access, then calls
|
|
@@ -236,8 +236,8 @@ To rotate the key, from a directory that selects the project `alchemy-state-stor
|
|
|
236
236
|
|
|
237
237
|
Alchemy state holds no time, commit, branch, or run. `Convex.state()` adds them to the stage output:
|
|
238
238
|
the document that `setOutput` stores is the stack's output plus the key `samebase.run`. On GitHub
|
|
239
|
-
Actions the record comes from the run's variables and the event payload; on a
|
|
240
|
-
needs a branch and an `origin` remote. It holds no secret.
|
|
239
|
+
Actions the record comes from the run's variables and the event payload; on a development machine
|
|
240
|
+
from git, which needs a branch and an `origin` remote. It holds no secret.
|
|
241
241
|
|
|
242
242
|
```json
|
|
243
243
|
{
|
|
@@ -257,13 +257,13 @@ needs a branch and an `origin` remote. It holds no secret.
|
|
|
257
257
|
```
|
|
258
258
|
|
|
259
259
|
`stackFile` is the working directory of the run below the repository root plus `alchemy.run.ts`.
|
|
260
|
-
`pullRequest` and `runUrl` are `null` for a push and for a
|
|
261
|
-
value that the stack itself returns under `samebase.run` stays. A checkout
|
|
262
|
-
such as a tarball without git or a detached HEAD, writes its outputs without
|
|
263
|
-
why. Alchemy writes the output once after a full successful deploy, so a
|
|
264
|
-
previous record, and a deploy of selected resources writes none. A reader
|
|
265
|
-
stack, with its resources and output, from the store function
|
|
266
|
-
call.
|
|
260
|
+
`pullRequest` and `runUrl` are `null` for a push and for a checkout outside GitHub Actions, where
|
|
261
|
+
`source` is `checkout`. A value that the stack itself returns under `samebase.run` stays. A checkout
|
|
262
|
+
that gives no record, such as a tarball without git or a detached HEAD, writes its outputs without
|
|
263
|
+
one, and the log says why. Alchemy writes the output once after a full successful deploy, so a
|
|
264
|
+
failed deploy leaves the previous record, and a deploy of selected resources writes none. A reader
|
|
265
|
+
gets every stage of a stack, with its resources and output, from the store function
|
|
266
|
+
`state:readStack({ stack })` in one call.
|
|
267
267
|
|
|
268
268
|
## Resources
|
|
269
269
|
|
|
@@ -307,7 +307,7 @@ call.
|
|
|
307
307
|
- `Convex.SharedHubClient`:
|
|
308
308
|
`{ app, redirectUri, deploymentType, initialAccessToken?, softwareVersion? }` gets a client of the
|
|
309
309
|
central identity hub, for an app that deploys in its own GitHub Actions run, on any host, and for
|
|
310
|
-
|
|
310
|
+
development as a stage of the same stack. `deploymentType` is `production`, `preview`, or
|
|
311
311
|
`development`. A production or preview client needs `permissions: id-token: write` in the
|
|
312
312
|
workflow, and no key and no Samebase account. `app` is at most 64 characters. The origin of an
|
|
313
313
|
https `redirectUri` must serve `/samebase-verification.json` with the numeric GitHub id of the
|
|
@@ -319,9 +319,9 @@ call.
|
|
|
319
319
|
repository id, which the state keeps. A renewal keeps both. They are empty for a preview, for a
|
|
320
320
|
development client, and for the off values.
|
|
321
321
|
- A development client needs `initialAccessToken`, and only a development client takes it. The
|
|
322
|
-
client asks the hub with this token in place of the GitHub OIDC token, so it works
|
|
323
|
-
With an empty token, the client gets the off values, and the log says "deploy to
|
|
324
|
-
Google sign-in
|
|
322
|
+
client asks the hub with this token in place of the GitHub OIDC token, so it works in
|
|
323
|
+
development. With an empty token, the client gets the off values, and the log says "deploy to
|
|
324
|
+
main once for Google sign-in in development". See "The development stage" below.
|
|
325
325
|
- Each deploy reads the saved client on the hub with its own token. A client that is gone gets a
|
|
326
326
|
new one, and a client on another `redirectUri` or of another `deploymentType` too.
|
|
327
327
|
- A new client logs the link to the terms of the shared sign-in service. A refusal logs its
|
|
@@ -330,7 +330,7 @@ call.
|
|
|
330
330
|
- No failure stops a deploy or a destroy. A failed renewal keeps the saved values. Without saved
|
|
331
331
|
values, `status` is `off`, and `issuer`, `clientId`, and `clientSecret` are the `no-hub` values
|
|
332
332
|
of a checkout without a hub. A production or preview run without a GitHub OIDC token, such as on
|
|
333
|
-
a
|
|
333
|
+
a development machine, does the same, and logs no warning.
|
|
334
334
|
- `required: true` makes the run fail unless the hub confirms the client in this run: a refusal, a
|
|
335
335
|
hub that does not answer a registration or a renewal, or a suspended client fails it. Set it
|
|
336
336
|
where sign-in is the product, so a deploy never ships guest sign-in, or a client that the hub
|
|
@@ -343,7 +343,7 @@ call.
|
|
|
343
343
|
- `Convex.SharedHubClient.read(id, { stage })` gives the attributes of the client `id` in another
|
|
344
344
|
stage of the same stack, from the state store of the stack. When that stage has no row, it gives
|
|
345
345
|
the off attributes and does not fail. `Convex.SharedHubClient.ref` fails when the row is
|
|
346
|
-
missing, and a
|
|
346
|
+
missing, and a development stage before the first deploy to main has no `prod` row.
|
|
347
347
|
- A destroy deletes a preview or development client. It does nothing to a production client,
|
|
348
348
|
because the production deployment can stay.
|
|
349
349
|
- `HUB_URL` replaces `https://auth.samebase.com`, the hub that the run asks at `/hub-clients`.
|
|
@@ -364,11 +364,11 @@ call.
|
|
|
364
364
|
|
|
365
365
|
### The development stage
|
|
366
366
|
|
|
367
|
-
A
|
|
368
|
-
dev start: `npx convex dev` has made and selected the dev deployment and pushed the
|
|
369
|
-
`alchemy deploy --stage dev-<name>` gives that deployment its variables. The stage
|
|
370
|
-
and pushes nothing. It has three rows on the deployment that `.env.local` selects,
|
|
371
|
-
Convex name:
|
|
367
|
+
A development checkout gets its client from a stage `dev-<name>` of the app's stack, run on purpose,
|
|
368
|
+
not at each dev start: `npx convex dev` has made and selected the dev deployment and pushed the
|
|
369
|
+
code, and then `alchemy deploy --stage dev-<name>` gives that deployment its variables. The stage
|
|
370
|
+
creates nothing and pushes nothing. It has three rows on the deployment that `.env.local` selects,
|
|
371
|
+
taken over by its Convex name:
|
|
372
372
|
|
|
373
373
|
```ts
|
|
374
374
|
// `selected` is the name in CONVEX_DEPLOYMENT of .env.local, such as happy-animal-123, and
|
|
@@ -412,8 +412,8 @@ The imports are `alchemy/AdoptPolicy` for `adopt` and `alchemy/Output` for `Outp
|
|
|
412
412
|
`/samebase-verification.json`. `adopt` takes over the deployment and the variables that the dev
|
|
413
413
|
start set before.
|
|
414
414
|
3. "HubClient" asks the hub for a development client on the deployment's site URL with the token. A
|
|
415
|
-
later run renews it. A sign-in renews it too, so a
|
|
416
|
-
development client expires 14 days after its last run or sign-in.
|
|
415
|
+
later run renews it. A sign-in renews it too, so a development server in use never needs the
|
|
416
|
+
stage again; a development client expires 14 days after its last run or sign-in.
|
|
417
417
|
4. "Site" writes the three variables. It removes only a name that leaves its own `env`, so
|
|
418
418
|
`SAMEBASE_REPOSITORY_ID` stays.
|
|
419
419
|
|
|
@@ -1513,7 +1513,7 @@ const fromGit = (where) => Effect.gen(function* () {
|
|
|
1513
1513
|
pullRequest: null,
|
|
1514
1514
|
headCommit: yield* git(cwd, ["rev-parse", "HEAD"]),
|
|
1515
1515
|
runUrl: null,
|
|
1516
|
-
source: "
|
|
1516
|
+
source: "checkout",
|
|
1517
1517
|
recordedAt: yield* now
|
|
1518
1518
|
};
|
|
1519
1519
|
});
|
|
@@ -1679,7 +1679,7 @@ const storeDirectory = () => join(dirname(fileURLToPath(import.meta.url)), "..",
|
|
|
1679
1679
|
*/
|
|
1680
1680
|
const pushStore = (options, deployment) => Effect.gen(function* () {
|
|
1681
1681
|
const cli = yield* installedCli(join(options.store, ".."));
|
|
1682
|
-
yield* Effect.logInfo(`Convex state: pushing the store version
|
|
1682
|
+
yield* Effect.logInfo(`Convex state: pushing the store version 6 to ${deployment.name}`);
|
|
1683
1683
|
yield* withPushKey(options.api, deployment.name, PUSH_KEY_ACTIONS, (key) => push(options.spawner, key, {
|
|
1684
1684
|
deployment: deployment.name,
|
|
1685
1685
|
url: deployment.deploymentUrl,
|
|
@@ -1762,15 +1762,15 @@ const makeConvexState = (options) => Effect.gen(function* () {
|
|
|
1762
1762
|
return next.call(path, args);
|
|
1763
1763
|
})))) };
|
|
1764
1764
|
let version = yield* storeVersion(functions);
|
|
1765
|
-
if (version === void 0 || version <
|
|
1765
|
+
if (version === void 0 || version < 6) {
|
|
1766
1766
|
if (version === void 0 && deployment.lastDeployTime) return yield* failure(`project ${STORE_PROJECT_NAME} (${project.id}) of team ${teamId} has code that is not the state store, and Convex.state does not push over it. Rename that project in the Convex dashboard.`);
|
|
1767
1767
|
version = yield* storeVersion(functions);
|
|
1768
|
-
if (version === void 0 || version <
|
|
1768
|
+
if (version === void 0 || version < 6) {
|
|
1769
1769
|
yield* pushStore(options, deployment);
|
|
1770
1770
|
version = yield* storeVersion(functions);
|
|
1771
1771
|
}
|
|
1772
1772
|
}
|
|
1773
|
-
if (version !==
|
|
1773
|
+
if (version !== 6) return yield* failure(`${deployment.name} answers store version ${version ?? "none"}, and this package needs store version 6.`);
|
|
1774
1774
|
yield* ensureSealed(options, deployment, functions);
|
|
1775
1775
|
const remote = remoteOf(functions, options.run);
|
|
1776
1776
|
/** The stack's output plus the record, when the run has one and the output has a place for it. */
|
|
@@ -1840,4 +1840,4 @@ const state = () => Layer.effect(State, Effect.gen(function* () {
|
|
|
1840
1840
|
//#endregion
|
|
1841
1841
|
export { ManagementApi as A, ConvexCliNotFound as C, parseDeployOutput as D, VariablesOwnedBySomeoneElse as E, CredentialsError as F, DEPLOY_KEY_ENV as I, fromConfig as L, readLocalDeployment as M, ACCESS_TOKEN_ENV as N, push as O, Credentials as P, fromValues as R, ConvexAppNotFound as S, PushTargetMismatch as T, DeploymentIdentityChange as _, runRecord as a, ProductionDeploymentNotFound as b, CreatedProjectNotFound as c, ProjectNotFound as d, ProjectProvider as f, Deployment as g, AmbiguousDeployment as h, RunRecordError as i, ManagementApiLive as j, ConvexApiError as k, Project as l, AbsoluteRootDir as m, state as n, withRunRecord as o, ProjectTeamChange as p, RUN_RECORD_KEY as r, AmbiguousProject as s, STORE_PROJECT_NAME as t, ProjectDeploymentChange as u, DeploymentProvider as v, EnvironmentNeedsDeployKey as w, CodePushFailed as x, DeploymentResource as y };
|
|
1842
1842
|
|
|
1843
|
-
//# sourceMappingURL=State-
|
|
1843
|
+
//# sourceMappingURL=State-CuktZaOh.js.map
|