@samebase/alchemy-convex 0.11.0 → 0.13.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 +4 -3
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -10
- package/lib/index.js.map +1 -1
- package/package.json +5 -1
- package/src/State.ts +11 -9
- package/src/store/component/_generated/api.ts +54 -0
- package/src/store/component/_generated/component.ts +193 -0
- package/src/store/component/_generated/dataModel.ts +60 -0
- package/src/store/component/_generated/server.ts +169 -0
- package/src/store/component/convex.config.ts +3 -0
- package/src/store/component/reader.ts +104 -0
- package/src/store/component/state.ts +289 -0
- package/src/store/convex/_generated/api.d.ts +3 -3
- package/src/store/convex/_generated/dataModel.d.ts +16 -18
- package/src/store/convex/convex.config.ts +7 -0
- package/src/store/convex/reader.ts +10 -90
- package/src/store/convex/state.ts +59 -227
- package/src/store/convex/version.ts +4 -2
- package/src/store/package.json +1 -1
- /package/src/store/{convex → component}/runRecord.ts +0 -0
- /package/src/store/{convex → component}/schema.ts +0 -0
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ values explicitly: `Convex.providers(Convex.fromValues({ accessToken, deployKey
|
|
|
167
167
|
## State in Convex
|
|
168
168
|
|
|
169
169
|
`state: Convex.state({ team })` keeps the Alchemy state of every stack and stage of a Convex team in
|
|
170
|
-
one project of that team, `
|
|
170
|
+
one project of that team, `samebase`, so a repository holds one secret and a stack can create
|
|
171
171
|
and destroy its own project. [docs/design/convex-state.md](docs/design/convex-state.md) records the
|
|
172
172
|
decisions and the measurements.
|
|
173
173
|
|
|
@@ -185,12 +185,13 @@ Every run needs the team token in `CONVEX_ACCESS_TOKEN`, or the Convex CLI login
|
|
|
185
185
|
team access token names its team, so `Convex.state()` needs no `team` with one; a `team` slug that
|
|
186
186
|
is set must be the slug of that team, checked against its projects, and a token of another team
|
|
187
187
|
fails the run. The Convex CLI login needs the slug or the id. The first run of a team creates
|
|
188
|
-
the project `
|
|
188
|
+
the project `samebase` and pushes the store functions to its
|
|
189
189
|
production deployment with the Convex CLI of the app; a later version of this package pushes a
|
|
190
190
|
newer store when it finds an older one. A store that is newer than the package fails the run with
|
|
191
191
|
both versions, so the repositories of a team upgrade the package together. Each run makes a
|
|
192
192
|
deploy key of that deployment that can only run the store's internal functions, and deletes it at
|
|
193
|
-
the end. Rows are in the tables `resources` and `outputs`
|
|
193
|
+
the end. Rows are in the tables `resources` and `outputs` of the component `alchemyState` in the
|
|
194
|
+
dashboard, under the stack name.
|
|
194
195
|
The store has no lock: run one deploy of a stage at a time, such as with a CI concurrency group.
|
|
195
196
|
The store and its readers (Samebase) are released and upgraded together.
|
|
196
197
|
|
package/lib/index.d.ts
CHANGED
|
@@ -457,9 +457,9 @@ export declare const withRunRecord: (output: unknown, record: RunRecord) => obje
|
|
|
457
457
|
//#endregion
|
|
458
458
|
//#region src/State.d.ts
|
|
459
459
|
/** The name of the state project in each team. */
|
|
460
|
-
export declare const STORE_PROJECT_NAME = "
|
|
460
|
+
export declare const STORE_PROJECT_NAME = "samebase";
|
|
461
461
|
/**
|
|
462
|
-
* Alchemy state in the `
|
|
462
|
+
* Alchemy state in the `samebase` project of `team`, with the team token
|
|
463
463
|
* in CONVEX_ACCESS_TOKEN or the Convex CLI login. A team access token names
|
|
464
464
|
* its team, so `team` is optional with one; the Convex CLI login needs the
|
|
465
465
|
* slug or the id. The first use of the run finds or creates the project and
|
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/Component.ts","../src/Project.ts","../src/RunRecord.ts","../src/State.ts"],"mappings":";;;;;;;;;;;;;;;;UA6BiB;;WAEN,aAAa,SAAS;;WAEtB;;UAGM;;WAEN,aAAa,OAAO,OAAO;;WAE3B,gBAAgB,OAAO;;WAEvB,WAA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A;;;UAIL;WACC;WACA,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;UAGM,6BAA6B;;WAEnC;;WAEA;;YAGC,aAAa,8BAEvB,iBACA,sBACA,kBACA;;KAQU,kBAAkB,+BAA8B,KACxD,UAAU,kBACR,WAAW;;;;;qBAWJ,wBAAwB;MAGtB;;;;;;;;;;;;qBAeF,cAAU,YACV,OAAS,oBAAe,OAAA,OAAA,mBAAA;;;;;;EAYvB,MAAA,YAAM;IAAc;IAAgB;QAAgB,OAAA,OAAA;;;;;;;;;;qBAMrD,iCAAiC;MAU/B;;;;;;qBAMF,qCAAqC;MAInC;;;;;;;;;qBAMF,4BAA4B;MAS1B;;;;;UC1OE;WACN;WACA;WACA;;;;;;;;;qBAUE,gBAAiB;EAC5B,YAAY;EACZ;EACA,WAAW;MACZ,OAAA,yBAAA;;;;KCWW,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;;;;;qBC5GF;;UAMI;WACN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;WAEA;;;;;qBAGE,uBAAuB;MAGrB;;;UAME;WACN;WACA,KAAK,SAAS;;;;;;;;qBAuIZ,YAAa,OAAO,mBAAiB,OAAO,OAAO,WAAW;;;;;;;qBAgB9D,gBAAiB,iBAAiB,QAAQ;;;;
|
|
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/Component.ts","../src/Project.ts","../src/RunR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AQ;;;;qBCxH1C;;;;;;;;;qBAgXA,QACX;WAAoB;MACnB,MAAM,MAAM,cAAc,oBAAoB"}
|
package/lib/index.js
CHANGED
|
@@ -1545,7 +1545,7 @@ const withRunRecord = (output, record) => isPlainObject(output) ? "samebase.run"
|
|
|
1545
1545
|
//#endregion
|
|
1546
1546
|
//#region src/State.ts
|
|
1547
1547
|
/** The name of the state project in each team. */
|
|
1548
|
-
const STORE_PROJECT_NAME = "
|
|
1548
|
+
const STORE_PROJECT_NAME = "samebase";
|
|
1549
1549
|
/**
|
|
1550
1550
|
* The actions of the key of one run: the internal queries and mutations of
|
|
1551
1551
|
* the store, nothing else. Measured: `deployment:data:view` and
|
|
@@ -1663,7 +1663,8 @@ const storeVersion = (api) => api.call("state:version", {}).pipe(Effect.flatMap(
|
|
|
1663
1663
|
* The functions directory of the store app, `src/store/convex` of this
|
|
1664
1664
|
* package. This file is `src/State.ts` in a checkout and a chunk in `lib/`
|
|
1665
1665
|
* in the installed package, which ships `src` too, so the directory is
|
|
1666
|
-
* `../src/store/convex` from either place.
|
|
1666
|
+
* `../src/store/convex` from either place. Its `convex.config.ts` mounts the
|
|
1667
|
+
* alchemyState component of `src/store/component`, inside the same push root.
|
|
1667
1668
|
*/
|
|
1668
1669
|
const storeDirectory = () => join(dirname(fileURLToPath(import.meta.url)), "..", "src", "store", "convex");
|
|
1669
1670
|
/**
|
|
@@ -1673,7 +1674,7 @@ const storeDirectory = () => join(dirname(fileURLToPath(import.meta.url)), "..",
|
|
|
1673
1674
|
*/
|
|
1674
1675
|
const pushStore = (options, deployment) => Effect.gen(function* () {
|
|
1675
1676
|
const cli = yield* installedCli(join(options.store, ".."));
|
|
1676
|
-
yield* Effect.logInfo(`Convex state: pushing the store version
|
|
1677
|
+
yield* Effect.logInfo(`Convex state: pushing the store version 4 to ${deployment.name}`);
|
|
1677
1678
|
yield* withPushKey(options.api, deployment.name, PUSH_KEY_ACTIONS, (key) => push(options.spawner, key, {
|
|
1678
1679
|
deployment: deployment.name,
|
|
1679
1680
|
url: deployment.deploymentUrl,
|
|
@@ -1714,7 +1715,7 @@ const createStoreProject = (api, teamId, team) => Effect.gen(function* () {
|
|
|
1714
1715
|
return oldest;
|
|
1715
1716
|
});
|
|
1716
1717
|
/**
|
|
1717
|
-
* The StateService over the `
|
|
1718
|
+
* The StateService over the `samebase` project of the team: found or
|
|
1718
1719
|
* created, its store pushed when it is missing or older, and read and
|
|
1719
1720
|
* written with the keys of this run.
|
|
1720
1721
|
*/
|
|
@@ -1722,12 +1723,12 @@ const makeConvexState = (options) => Effect.gen(function* () {
|
|
|
1722
1723
|
const { api } = options;
|
|
1723
1724
|
const teamId = yield* api.resolveTeamId(options.team);
|
|
1724
1725
|
const team = options.team ?? teamId;
|
|
1725
|
-
const project = (yield* findProjectByName(api, teamId, "
|
|
1726
|
+
const project = (yield* findProjectByName(api, teamId, "samebase")) ?? (yield* createStoreProject(api, teamId, team));
|
|
1726
1727
|
const deployment = yield* prodDeploymentOf(api, project.id);
|
|
1727
1728
|
if (deployment === void 0) return yield* new ProductionDeploymentNotFound({ projectId: project.id });
|
|
1728
1729
|
const keys = [];
|
|
1729
1730
|
yield* Scope.addFinalizer(options.scope, Effect.suspend(() => Effect.forEach(keys, (key) => deleteDeployKey(api, deployment.name, key), { discard: true })));
|
|
1730
|
-
const mint = createDeployKey(api, deployment.name,
|
|
1731
|
+
const mint = createDeployKey(api, deployment.name, STORE_PROJECT_NAME, RUN_KEY_ACTIONS).pipe(Effect.map((key) => {
|
|
1731
1732
|
keys.push(key);
|
|
1732
1733
|
return makeFunctionApi(deployment.deploymentUrl, key);
|
|
1733
1734
|
}), Effect.mapError((error) => failure(`no key for ${deployment.name}: ${error.message}`)));
|
|
@@ -1737,15 +1738,15 @@ const makeConvexState = (options) => Effect.gen(function* () {
|
|
|
1737
1738
|
return next.call(path, args);
|
|
1738
1739
|
})))) };
|
|
1739
1740
|
let version = yield* storeVersion(functions);
|
|
1740
|
-
if (version === void 0 || version <
|
|
1741
|
+
if (version === void 0 || version < 4) {
|
|
1741
1742
|
if (version === void 0 && deployment.lastDeployTime) return yield* failure(`project ${STORE_PROJECT_NAME} (${project.id}) of team ${team} has code that is not the state store, and Convex.state does not push over it. Rename that project in the Convex dashboard.`);
|
|
1742
1743
|
version = yield* storeVersion(functions);
|
|
1743
|
-
if (version === void 0 || version <
|
|
1744
|
+
if (version === void 0 || version < 4) {
|
|
1744
1745
|
yield* pushStore(options, deployment);
|
|
1745
1746
|
version = yield* storeVersion(functions);
|
|
1746
1747
|
}
|
|
1747
1748
|
}
|
|
1748
|
-
if (version !==
|
|
1749
|
+
if (version !== 4) return yield* failure(`${deployment.name} answers store version ${version ?? "none"}, and this package needs store version 4.`);
|
|
1749
1750
|
const remote = remoteOf(functions, options.run);
|
|
1750
1751
|
/** The stack's output plus the record, when the run has one and the output has a place for it. */
|
|
1751
1752
|
const documentOf = (request) => Effect.gen(function* () {
|
|
@@ -1786,7 +1787,7 @@ const makeConvexState = (options) => Effect.gen(function* () {
|
|
|
1786
1787
|
};
|
|
1787
1788
|
});
|
|
1788
1789
|
/**
|
|
1789
|
-
* Alchemy state in the `
|
|
1790
|
+
* Alchemy state in the `samebase` project of `team`, with the team token
|
|
1790
1791
|
* in CONVEX_ACCESS_TOKEN or the Convex CLI login. A team access token names
|
|
1791
1792
|
* its team, so `team` is optional with one; the Convex CLI login needs the
|
|
1792
1793
|
* slug or the id. The first use of the run finds or creates the project and
|