@valbuild/server 0.141.0 → 0.142.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/CHANGELOG.md +33 -0
- package/dist/declarations/src/ValOps.d.ts +43 -0
- package/dist/declarations/src/ValOpsHttp.d.ts +62 -0
- package/dist/declarations/src/ValRouter.d.ts +7 -0
- package/dist/declarations/src/ValServer.d.ts +16 -1
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/proposal.d.ts +72 -0
- package/dist/valbuild-server.cjs.dev.js +615 -37
- package/dist/valbuild-server.cjs.prod.js +615 -37
- package/dist/valbuild-server.esm.js +614 -38
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @valbuild/server
|
|
2
2
|
|
|
3
|
+
## 0.142.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#805](https://github.com/valbuild/val/pull/805) [`1ec4ff4`](https://github.com/valbuild/val/commit/1ec4ff4165a33f2248b52608ff58e626523e4212) Thanks [@freekh](https://github.com/freekh)! - Fix: a draft preview could miss a change its editor had just saved. Draft pages scoped to your own changes worked out which pending changes are yours from a list of patch groups remembered for a second, so a save followed by a reload inside that second rendered without the save. The draft page now takes your changes from the same answer as the changes themselves, and any save, discard, stage or unstage through the server forgets the remembered list.
|
|
8
|
+
|
|
9
|
+
- [#805](https://github.com/valbuild/val/pull/805) [`bb63738`](https://github.com/valbuild/val/commit/bb63738aabed1cf1287611ecaab7c35fc4b08a12) Thanks [@freekh](https://github.com/freekh)! - Publish in a proposal: merging it into the site. The dialog shows whether it can go now, and names who to ask when it cannot; Publish saves anything unsaved, builds the site with the proposal in this tab, and content checks it renders and makes it live as one change. A merged proposal is finished: its Studio says so above the editor, and anything written in it while it merged is moved to a new proposal, which the Studio offers to open. Review in a proposal now compares it with the site, saved and unsaved changes alike.
|
|
10
|
+
|
|
11
|
+
- [#805](https://github.com/valbuild/val/pull/805) [`fa03698`](https://github.com/valbuild/val/commit/fa03698ef0f2c7a6df334b4ba0e41843bde60029) Thanks [@freekh](https://github.com/freekh)! - Groundwork for proposals on the Val platform: a server can be told it is running at a proposal's address (`proposal` in the http options, `proposalFromEnv` to read it from the platform). There, the content the proposal has saved replaces the bundled content for those modules on every read, edits go to the proposal's branch, and Save commits to the proposal instead of the site. Nothing changes for a site that is not given a proposal.
|
|
12
|
+
|
|
13
|
+
- [#805](https://github.com/valbuild/val/pull/805) [`3d2b9e8`](https://github.com/valbuild/val/commit/3d2b9e8c11aa6a4449527e2a1bbb363566797a14) Thanks [@freekh](https://github.com/freekh)! - Proposals in the Studio, for projects on the Val platform that have them turned on: a switcher in the top bar to move between the site and its proposals, New proposal, Rename, Close and All proposals (with Reopen), and — inside a proposal — Save where Publish is, in the proposal's colour. Nothing is shown for a project without proposals. At a proposal's address the server now refuses to publish to the site, so a Save there can never start a site build.
|
|
14
|
+
|
|
15
|
+
- [#815](https://github.com/valbuild/val/pull/815) [`a3236a5`](https://github.com/valbuild/val/commit/a3236a5f2c41b92422b40340dba060b53218c6ab) Thanks [@freekh](https://github.com/freekh)! - Fixed: a project that is not connected to Val Build yet (no `project` in `val.config`) no longer gets errors from the Studio on every page load. The Studio used to ask for the assistant, its conversations and the project's members anyway, and got `401` and `500` answers that showed up in the browser console and as an issue badge in the Next.js dev overlay. It now asks only once there is a project to ask about, and the assistant is hidden until there is. The chat used to say "Login to use AI chat" in that state, which no login could fix.
|
|
16
|
+
|
|
17
|
+
A project named only in the `VAL_PROJECT` environment variable counts as connected, as it always did on the server.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`1671bce`](https://github.com/valbuild/val/commit/1671bce6f0b65dac77e51655f24ef825f4671ebb), [`bb63738`](https://github.com/valbuild/val/commit/bb63738aabed1cf1287611ecaab7c35fc4b08a12), [`3d2b9e8`](https://github.com/valbuild/val/commit/3d2b9e8c11aa6a4449527e2a1bbb363566797a14), [`a3236a5`](https://github.com/valbuild/val/commit/a3236a5f2c41b92422b40340dba060b53218c6ab), [`f14e0aa`](https://github.com/valbuild/val/commit/f14e0aabedba07b832b1453d49635af5d2fbc019), [`521fe94`](https://github.com/valbuild/val/commit/521fe9400c0b660aa5b3642942cd0cc26622f193)]:
|
|
20
|
+
- @valbuild/ui@0.142.0
|
|
21
|
+
- @valbuild/shared@0.142.0
|
|
22
|
+
|
|
23
|
+
## 0.141.1
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#808](https://github.com/valbuild/val/pull/808) [`14b18d7`](https://github.com/valbuild/val/commit/14b18d7cb145cec1bc1cd832b9ca857ff4b45adc) Thanks [@freekh](https://github.com/freekh)! - A project with `files: { remote: true }` can save text edits without remote-file credentials: in local development without `val login` or a project id, and on a server without `VAL_API_KEY`.
|
|
28
|
+
|
|
29
|
+
Before, a save asked for remote credentials whenever any schema in the project was remote. With `files: { remote: true }` that is every media schema, so every save was refused, even a typo fix. Now it asks only when the change being saved contains a remote file.
|
|
30
|
+
|
|
31
|
+
When uploads are unavailable, the Studio now shows a card above the editor. It says what is wrong and gives the fix: a link to admin.val.build or the `val login` command to copy. When the cause is missing setup (no project id, not logged in, no API key) it also says that text edits still save and publish. Dismissing it leaves an "Uploads off" item in the status bar, or in the account sheet on a phone, that brings it back. This replaces the red bar that covered the top of the Studio, the Publish button included, and the login dialog that opened on every load.
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`6faacda`](https://github.com/valbuild/val/commit/6faacda398fc92bec187b7afe07a53228a6f2a3b), [`14b18d7`](https://github.com/valbuild/val/commit/14b18d7cb145cec1bc1cd832b9ca857ff4b45adc)]:
|
|
34
|
+
- @valbuild/ui@0.141.1
|
|
35
|
+
|
|
3
36
|
## 0.141.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
|
@@ -43,6 +43,14 @@ export type ValOpsOptions = {
|
|
|
43
43
|
disableFilePolling?: boolean;
|
|
44
44
|
disableFileWatcher?: boolean;
|
|
45
45
|
config: ValConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Source that replaces what the modules evaluate to, for the modules it
|
|
48
|
+
* names: a proposal's saves (`ValProposal` in `./proposal`), the third
|
|
49
|
+
* source provider beside committed and draft. Applied once, as the modules
|
|
50
|
+
* are first read, so every read after it -- the tree, validation, previews,
|
|
51
|
+
* the next save's prepare -- starts from it, and the SHAs describe it.
|
|
52
|
+
*/
|
|
53
|
+
snapshotSources?: Sources;
|
|
46
54
|
};
|
|
47
55
|
export declare abstract class ValOps {
|
|
48
56
|
private readonly valModules;
|
|
@@ -76,6 +84,12 @@ export declare abstract class ValOps {
|
|
|
76
84
|
* hash. Re-folding with the wrong list changes the base SHA for no reason.
|
|
77
85
|
*/
|
|
78
86
|
private shaModuleErrors;
|
|
87
|
+
/**
|
|
88
|
+
* The SITE's Source for the modules a proposal's snapshot replaced: what the
|
|
89
|
+
* bundle evaluated to before the snapshot went over it. Kept for
|
|
90
|
+
* {@link siteSourcesUnderSnapshot}, and only where there is a snapshot.
|
|
91
|
+
*/
|
|
92
|
+
private siteSourcesBeforeSnapshot;
|
|
79
93
|
/**
|
|
80
94
|
* What a save has told us each `.jsonValues()` entry now holds.
|
|
81
95
|
*
|
|
@@ -156,6 +170,13 @@ export declare abstract class ValOps {
|
|
|
156
170
|
networkError?: boolean;
|
|
157
171
|
}>;
|
|
158
172
|
private initSources;
|
|
173
|
+
/**
|
|
174
|
+
* In a proposal: the SITE's Source for every module the proposal has saved,
|
|
175
|
+
* as the build it is based on evaluated it -- what the proposal is compared
|
|
176
|
+
* against, and what merging it changes. Every other module is the same in
|
|
177
|
+
* both, so it is not sent. `null` anywhere that is not a proposal.
|
|
178
|
+
*/
|
|
179
|
+
siteSourcesUnderSnapshot(): Promise<Sources | null>;
|
|
159
180
|
/**
|
|
160
181
|
* These patches are on disk now: adopt what they produced as the committed
|
|
161
182
|
* sources.
|
|
@@ -486,6 +507,28 @@ export declare abstract class ValOps {
|
|
|
486
507
|
body: string;
|
|
487
508
|
contentType: string;
|
|
488
509
|
}>;
|
|
510
|
+
/**
|
|
511
|
+
* The proposal this server runs at the address of, or `null` on the site --
|
|
512
|
+
* and always in `fs` and memory mode, which have no proposals. See
|
|
513
|
+
* `ValProposal`.
|
|
514
|
+
*/
|
|
515
|
+
currentProposal(): {
|
|
516
|
+
name: string;
|
|
517
|
+
branch: string;
|
|
518
|
+
} | null;
|
|
519
|
+
/**
|
|
520
|
+
* The content service's proposals API, for the Studio's switcher, list and
|
|
521
|
+
* dialogs. Refused here for the reason {@link publishApi} is: there is no
|
|
522
|
+
* content service to forward to. `profileId` is the person asking.
|
|
523
|
+
*/
|
|
524
|
+
proposalsApi(_path: string, _init: {
|
|
525
|
+
method: string;
|
|
526
|
+
body?: string;
|
|
527
|
+
}, _profileId: string | null): Promise<{
|
|
528
|
+
status: number;
|
|
529
|
+
body: string;
|
|
530
|
+
contentType: string;
|
|
531
|
+
}>;
|
|
489
532
|
/**
|
|
490
533
|
* Whether a commit here produces `.val.ts` TEXT as well as data.
|
|
491
534
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ValProposal } from "./proposal.js";
|
|
1
2
|
import { type PatchId, type ModuleFilePath, ValModules } from "@valbuild/core";
|
|
2
3
|
import type { Patch as PatchT, ParentRef as ParentRefT } from "@valbuild/core/patch";
|
|
3
4
|
import { type AuthorId, type BaseSha, BinaryFileType, type CommitSha, GenericErrorMessage, MetadataOfType, OpsMetadata, PreparedCommit, ValOps, ValOpsOptions, WithGenericError, SaveSourceFilePatchResult, type PatchGroupMembership, SchemaSha, OrderedPatchesMetadata, OrderedPatches, SourcesSha, type PublishRefusal } from "./ValOps.js";
|
|
@@ -78,6 +79,8 @@ export declare class ValOpsHttp extends ValOps {
|
|
|
78
79
|
private readonly publishJob;
|
|
79
80
|
/** See `publishBuild` on {@link ValApiOptions}; sent with every position. */
|
|
80
81
|
private readonly publishBuild;
|
|
82
|
+
/** See `proposal` on {@link ValApiOptions}; `null` on the site. */
|
|
83
|
+
private readonly proposal;
|
|
81
84
|
/** Did the host hand over the running build's source? See `projectSource`. */
|
|
82
85
|
embedsSource(): boolean;
|
|
83
86
|
/**
|
|
@@ -148,6 +151,8 @@ export declare class ValOpsHttp extends ValOps {
|
|
|
148
151
|
publishJob?: string;
|
|
149
152
|
/** See `publishBuild` on {@link ValApiOptions}. */
|
|
150
153
|
publishBuild?: string;
|
|
154
|
+
/** See `proposal` on {@link ValApiOptions}. */
|
|
155
|
+
proposal?: ValProposal;
|
|
151
156
|
});
|
|
152
157
|
/**
|
|
153
158
|
* A deployment that cannot mirror a project which expects to be mirrored.
|
|
@@ -272,6 +277,35 @@ export declare class ValOpsHttp extends ValOps {
|
|
|
272
277
|
body: string;
|
|
273
278
|
contentType: string;
|
|
274
279
|
}>;
|
|
280
|
+
currentProposal(): {
|
|
281
|
+
name: string;
|
|
282
|
+
branch: string;
|
|
283
|
+
} | null;
|
|
284
|
+
/**
|
|
285
|
+
* Which proposal calls the browser may make, by method and the path after
|
|
286
|
+
* `/proposals`: list and open, read and rename one, and close, reopen and
|
|
287
|
+
* retry its setup. Not `/save` -- the Studio saves through `/save`, which
|
|
288
|
+
* prepares the commit here -- and not `/patches`, which moves the site's
|
|
289
|
+
* changes into a proposal and has no screen yet.
|
|
290
|
+
*/
|
|
291
|
+
private static proposalsApiAllowed;
|
|
292
|
+
/**
|
|
293
|
+
* What a proposal's address may reach of the publish API: building ITS OWN
|
|
294
|
+
* merge, and nothing that publishes the site's changes. The merge's prepare
|
|
295
|
+
* (content's, from the proposal's last save), the build it needs -- the
|
|
296
|
+
* site's build target and source, declaring and uploading the build -- and
|
|
297
|
+
* the job's own steps. Not a press of the site's Publish, not `next` (which
|
|
298
|
+
* would hand this tab a site job), and not the site job's prepare.
|
|
299
|
+
*/
|
|
300
|
+
private static mergeApiPathAllowed;
|
|
301
|
+
proposalsApi(path: string, init: {
|
|
302
|
+
method: string;
|
|
303
|
+
body?: string;
|
|
304
|
+
}, profileId: string | null): Promise<{
|
|
305
|
+
status: number;
|
|
306
|
+
body: string;
|
|
307
|
+
contentType: string;
|
|
308
|
+
}>;
|
|
275
309
|
/**
|
|
276
310
|
* A publish job's prepare, sent to content: the job's sources, archived
|
|
277
311
|
* there before the job is built (valbuild/home, docs/app-mode.md, "The
|
|
@@ -349,6 +383,19 @@ export declare class ValOpsHttp extends ValOps {
|
|
|
349
383
|
unauthorized?: boolean;
|
|
350
384
|
networkError?: boolean;
|
|
351
385
|
}>;
|
|
386
|
+
/**
|
|
387
|
+
* Where this server sits in the content service's chain, as every request
|
|
388
|
+
* that asks about a position says it.
|
|
389
|
+
*
|
|
390
|
+
* In a proposal: its branch, and the save its snapshot is (none before the
|
|
391
|
+
* first). The content service then answers with what came after that save
|
|
392
|
+
* and nothing else -- never the site's position, which would replay the
|
|
393
|
+
* proposal's own saves over a snapshot that already holds them. Otherwise
|
|
394
|
+
* the commit this build was made from, or, for a build a tab made, its job.
|
|
395
|
+
*/
|
|
396
|
+
private position;
|
|
397
|
+
/** The branch this server's patches are on, where it knows it. */
|
|
398
|
+
private ownBranch;
|
|
352
399
|
getWebSocketNonce(profileId: string): Promise<{
|
|
353
400
|
status: "success";
|
|
354
401
|
data: {
|
|
@@ -458,6 +505,20 @@ export declare class ValOpsHttp extends ValOps {
|
|
|
458
505
|
* cache: a second render a second later asks again.
|
|
459
506
|
*/
|
|
460
507
|
private patchGroupsCache;
|
|
508
|
+
/**
|
|
509
|
+
* Forget the remembered group list, after a write through this server.
|
|
510
|
+
*
|
|
511
|
+
* A write changes membership -- a save joins its author's group, a delete or
|
|
512
|
+
* an unstage leaves it -- and the window above is long enough for the next
|
|
513
|
+
* render to be served the list from before it: an editor who saved and
|
|
514
|
+
* reloaded inside a second was shown their draft without the change they had
|
|
515
|
+
* just made. Called once the write has answered, so a read that started
|
|
516
|
+
* while it was in flight cannot leave the old list behind it.
|
|
517
|
+
*
|
|
518
|
+
* Only this instance's writes. Another instance's write is still seen at
|
|
519
|
+
* most one window late, which is what the window is for.
|
|
520
|
+
*/
|
|
521
|
+
private forgetPatchGroups;
|
|
461
522
|
getPatchGroups(options?: {
|
|
462
523
|
/**
|
|
463
524
|
* Ask the content API even if a recent answer is remembered.
|
|
@@ -493,6 +554,7 @@ export declare class ValOpsHttp extends ValOps {
|
|
|
493
554
|
*/
|
|
494
555
|
private ownGroupBranch;
|
|
495
556
|
private mutatePatchGroup;
|
|
557
|
+
private mutatePatchGroupRequest;
|
|
496
558
|
protected saveSourceFilePatch(path: ModuleFilePath, patch: PatchT, patchId: PatchId, parentRef: ParentRefT, authorId: AuthorId | null, sessionId: string | null, patchGroup?: PatchGroupMembership): Promise<SaveSourceFilePatchResult>;
|
|
497
559
|
/**
|
|
498
560
|
* @deprecated For HTTP ops use direct upload instead (i.e. client should upload the files directly) since hosting platforms (Vercel) might have low limits on the size of the request body.
|
|
@@ -8,6 +8,7 @@ type Versions = {
|
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
import type { ValPatchStore } from "./ValOpsMemory.js";
|
|
11
|
+
import type { ValProposal } from "./proposal.js";
|
|
11
12
|
import type { CommitContext, CommitResult } from "./ValServer.js";
|
|
12
13
|
export type ValApiOptions = ValServerOverrides & ValConfig & Versions;
|
|
13
14
|
type ValServerOverrides = Partial<{
|
|
@@ -156,6 +157,12 @@ type ValServerOverrides = Partial<{
|
|
|
156
157
|
* one -- whose changes it does not hold, so they drop out of the overlay.
|
|
157
158
|
*/
|
|
158
159
|
publishBuild?: string;
|
|
160
|
+
/**
|
|
161
|
+
* The proposal this server runs at the address of, when a platform serves
|
|
162
|
+
* one. See {@link ValProposal}: its branch, its position, its save route,
|
|
163
|
+
* and the snapshot that replaces the bundle's Source for what it saved.
|
|
164
|
+
*/
|
|
165
|
+
proposal?: ValProposal;
|
|
159
166
|
/**
|
|
160
167
|
* The base url of Val.
|
|
161
168
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ValProposal } from "./proposal.js";
|
|
1
2
|
import { ValModules, PatchId, ModuleFilePath, ValConfig } from "@valbuild/core";
|
|
2
|
-
import { Api, ServerOf } from "@valbuild/shared/internal";
|
|
3
|
+
import { Api, ServerOf, type PatchGroupT } from "@valbuild/shared/internal";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { AuthorId, CommitSha, ValOps, type GenericErrorMessage, type PreparedCommit } from "./ValOps.js";
|
|
5
6
|
import { ValOpsHttp } from "./ValOpsHttp.js";
|
|
@@ -145,6 +146,8 @@ export type ValServerConfig = ValServerOptions & ({
|
|
|
145
146
|
publishJob?: string;
|
|
146
147
|
/** See `publishBuild` on {@link ValApiOptions}. */
|
|
147
148
|
publishBuild?: string;
|
|
149
|
+
/** See `proposal` on {@link ValApiOptions}. */
|
|
150
|
+
proposal?: ValProposal;
|
|
148
151
|
config: ValConfig;
|
|
149
152
|
}
|
|
150
153
|
/**
|
|
@@ -261,6 +264,18 @@ chain: readonly {
|
|
|
261
264
|
* `undefined` means "apply everything", which is what every caller that does
|
|
262
265
|
* not ask for scoping gets and must keep getting.
|
|
263
266
|
*/
|
|
267
|
+
/** The patches in this author's OPEN groups: what a scoped draft shows. */
|
|
268
|
+
export declare function ownPatchIdsIn(patchGroups: PatchGroupT[], authorId: string): PatchId[];
|
|
269
|
+
/**
|
|
270
|
+
* Whose pending patches a scoped draft shows, taken from the SAME response as
|
|
271
|
+
* the patches when it says, and from the list read beforehand only when not.
|
|
272
|
+
*
|
|
273
|
+
* See the call in `/sources/~`: the list read beforehand can be older than the
|
|
274
|
+
* chain, and the response's membership cannot be.
|
|
275
|
+
*/
|
|
276
|
+
export declare function ownPatchScopeFor(fetched: {
|
|
277
|
+
patchGroups?: PatchGroupT[];
|
|
278
|
+
}, authorId: string | undefined, remembered: PatchId[] | undefined): PatchId[] | undefined;
|
|
264
279
|
export declare function resolveOwnPatchScope(serverOps: ValOps, opts: {
|
|
265
280
|
/** A caller that named a list already knows what it wants. */
|
|
266
281
|
explicitPatchIds: PatchId[] | undefined;
|
|
@@ -2,6 +2,8 @@ export { createService, Service } from "./Service.js";
|
|
|
2
2
|
export { defineExternal, ok, err, isExternalResult, EXTERNAL_RESULT, } from "./externalRecords.js";
|
|
3
3
|
export type { AdapterFor, BoundExternalRecord, ExternalAuthor, ExternalBuilder, ExternalCtx, ExternalDefinition, ExternalFile, ExternalIssue, ExternalKeyPage, ExternalRecords, ExternalResult, ExternalSearchHit, ExternalSearchPage, ExternalSort, ItemOfModule, ReadonlyRecordHasNoWrites, Returns, } from "./externalRecords.js";
|
|
4
4
|
export { createValApiRouter, createValServer, safeReadGit } from "./ValRouter.js";
|
|
5
|
+
export { proposalFromEnv, proposalSnapshot } from "./proposal.js";
|
|
6
|
+
export type { ValProposal } from "./proposal.js";
|
|
5
7
|
export { initHandlerOptions, createValOps } from "./valServerConfig.js";
|
|
6
8
|
export { resolveRemoteFileAuth } from "./valServerConfig.js";
|
|
7
9
|
export { APP_MODE_REQUIRES_REMOTE_FILES } from "./valServerConfig.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Json, ModuleFilePath } from "@valbuild/core";
|
|
2
|
+
/**
|
|
3
|
+
* A proposal this server runs at the address of: an editor-managed branch of
|
|
4
|
+
* the project's content, served from its own copy of the content the
|
|
5
|
+
* proposal has saved -- the **snapshot**. valbuild/home `docs/proposals.md`,
|
|
6
|
+
* "Saving".
|
|
7
|
+
*
|
|
8
|
+
* A third place Source can come from, beside the two Val already has:
|
|
9
|
+
*
|
|
10
|
+
* | source provider | Source comes from |
|
|
11
|
+
* | --------------- | -------------------------------------- |
|
|
12
|
+
* | committed | the bundle |
|
|
13
|
+
* | draft | content, pending patches applied |
|
|
14
|
+
* | snapshot | the proposal's saves |
|
|
15
|
+
*
|
|
16
|
+
* The snapshot REPLACES the bundle's Source for the modules the proposal has
|
|
17
|
+
* saved and nothing else, on every read: a committed render, the draft a page
|
|
18
|
+
* starts from, the Studio's tree, validation and the next save's prepare. The
|
|
19
|
+
* proposal's pending patches apply on top of it, as the site's apply on top of
|
|
20
|
+
* the bundle.
|
|
21
|
+
*
|
|
22
|
+
* Handed over by the platform that serves the address, per isolate: the
|
|
23
|
+
* snapshot only changes with a save, and a save is a new isolate.
|
|
24
|
+
*/
|
|
25
|
+
export type ValProposal = {
|
|
26
|
+
/** The proposal's name: twenty hex characters, the hash of its inputs. */
|
|
27
|
+
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* The content branch the proposal's patches and saves are on
|
|
30
|
+
* (`val/p/<name>`). Sent wherever a request names a branch, so the patches
|
|
31
|
+
* this server reads and writes are the proposal's, never the site's.
|
|
32
|
+
*/
|
|
33
|
+
branch: string;
|
|
34
|
+
/**
|
|
35
|
+
* The save the snapshot is, as a commit on {@link branch}; `null` before the
|
|
36
|
+
* first. Sent as this server's position, so the content service hands back
|
|
37
|
+
* only what came after it -- the snapshot already holds that save, and a
|
|
38
|
+
* save's patches applied twice would add every array item twice.
|
|
39
|
+
*/
|
|
40
|
+
commit: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Saved Source, by module file path. As the platform parsed it: read it
|
|
43
|
+
* with {@link proposalSnapshot}, which checks that it is JSON.
|
|
44
|
+
*/
|
|
45
|
+
modules: Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Saved `.val.ts` text, by path with no leading slash, laid over the
|
|
48
|
+
* build's `projectSource`: the next save patches the text the last one
|
|
49
|
+
* wrote, not the text the base build was made from.
|
|
50
|
+
*/
|
|
51
|
+
files: Record<string, string>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The proposal a platform describes in its runtime env, or `undefined` when
|
|
55
|
+
* this is not a proposal's address.
|
|
56
|
+
*
|
|
57
|
+
* `VAL_PROPOSAL` and `VAL_BRANCH` name it; `VAL_OVERLAY` is the snapshot as
|
|
58
|
+
* JSON (`{ commit, modules, files }`). Throws on a snapshot that does not
|
|
59
|
+
* parse rather than serving the base build as though it were the proposal: a
|
|
60
|
+
* reviewer would be looking at the wrong content and nothing would say so.
|
|
61
|
+
*/
|
|
62
|
+
export declare function proposalFromEnv(env: {
|
|
63
|
+
VAL_PROPOSAL?: string | undefined;
|
|
64
|
+
VAL_BRANCH?: string | undefined;
|
|
65
|
+
VAL_OVERLAY?: string | undefined;
|
|
66
|
+
}): ValProposal | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* The proposal's saved Source, as Source: every module whose value is JSON.
|
|
69
|
+
* One place, so the server and the readers that render without it agree on
|
|
70
|
+
* what the snapshot holds.
|
|
71
|
+
*/
|
|
72
|
+
export declare function proposalSnapshot(proposal: Pick<ValProposal, "modules">): Record<ModuleFilePath, Json>;
|