@valbuild/server 0.150.2 → 0.150.5

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @valbuild/server
2
2
 
3
+ ## 0.150.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#956](https://github.com/valbuild/val/pull/956) [`47a31cc`](https://github.com/valbuild/val/commit/47a31cc3574841acf4f3207d5053f8bc728d25cd) Thanks [@freekh](https://github.com/freekh)! - The design tab: a proposal's code, changed with the assistant, in a tab of its own. Open it from a proposal's menu in the switcher ("Open design tab"). It opens at `/val/design/<proposal>` on the site's address, beside the proposal's, and shows the files the proposal changes against the site, each one's diff, the proposal's history, Build, and the proposal's address in a frame at desktop, tablet and phone widths. The assistant there changes the proposal's code (and only reads content).
8
+
9
+ The tab is served by the site's build, not the proposal's. So a change the assistant breaks the proposal with takes away the preview, never the tab or the tools that fix it. For that, the site's Val server now stages files in, and builds, a proposal it names; a proposal's address still writes only its own.
10
+
11
+ - Updated dependencies [[`47a31cc`](https://github.com/valbuild/val/commit/47a31cc3574841acf4f3207d5053f8bc728d25cd)]:
12
+ - @valbuild/ui@0.150.5
13
+
14
+ ## 0.150.3
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [[`bc0cc43`](https://github.com/valbuild/val/commit/bc0cc433e157cca08f9ee384a4fb8be9bd3dad2c)]:
19
+ - @valbuild/ui@0.150.3
20
+ - @valbuild/core@0.150.3
21
+ - @valbuild/shared@0.150.3
22
+
3
23
  ## 0.150.2
4
24
 
5
25
  ### Patch Changes
@@ -302,13 +302,33 @@ export declare class ValOpsHttp extends ValOps {
302
302
  * (valbuild/home `docs/adept.md`, step 6), reporting the typecheck of
303
303
  * them (step 7, decision 20), serving a build of it
304
304
  * (valbuild/home `docs/hosted-publishing.md`, step 7), or moving it onto the
305
- * site's code (step 8, "Update from the site") -- is made by the
306
- * proposal's own server and nobody else's: the file tools act on the
307
- * proposal the Studio is open in (P11), and the site's files change only
308
- * when a proposal is merged. The proposal it names, or `null` when this
309
- * path is not such a write.
305
+ * site's code (step 8, "Update from the site"). The proposal it names and
306
+ * what it does, or `null` when this path is not such a write.
307
+ *
308
+ * Who may make one is {@link ValOpsHttp.mayWriteFiles}.
310
309
  */
311
310
  private static proposalFilesWrite;
311
+ /**
312
+ * The writes the SITE's server may make to a proposal's files: what the
313
+ * design tab does (valbuild/home `docs/design-tab.md`, step 2) -- stage
314
+ * code and build it. The tab is served by the site's
315
+ * build so that a build the assistant breaks in the proposal cannot take
316
+ * down the tools it would fix it with; at the proposal's address those
317
+ * tools run on the proposal's own code.
318
+ *
319
+ * The rest stay the proposal's own: Update from the site and the lockfile
320
+ * are answered from the proposal's build and schemas, bringing back a
321
+ * point's code is the Studio at its address finishing a restore, and the
322
+ * typecheck it reports is what blocks its Publish (adept.md, decision 20).
323
+ */
324
+ private static readonly SITE_MAY_WRITE;
325
+ /**
326
+ * Whether this server may make a write to a proposal's files: the
327
+ * proposal's own server, any of them; the site's, the design tab's; and a
328
+ * proposal's address, none to another proposal. Either way the site's own
329
+ * files change only when a proposal is merged.
330
+ */
331
+ private mayWriteFiles;
312
332
  /**
313
333
  * What a proposal's address may reach of the publish API: building ITS OWN
314
334
  * merge, and nothing that publishes the site's changes. The merge's prepare
@@ -5842,16 +5842,44 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5842
5842
  * (valbuild/home `docs/adept.md`, step 6), reporting the typecheck of
5843
5843
  * them (step 7, decision 20), serving a build of it
5844
5844
  * (valbuild/home `docs/hosted-publishing.md`, step 7), or moving it onto the
5845
- * site's code (step 8, "Update from the site") -- is made by the
5846
- * proposal's own server and nobody else's: the file tools act on the
5847
- * proposal the Studio is open in (P11), and the site's files change only
5848
- * when a proposal is merged. The proposal it names, or `null` when this
5849
- * path is not such a write.
5845
+ * site's code (step 8, "Update from the site"). The proposal it names and
5846
+ * what it does, or `null` when this path is not such a write.
5847
+ *
5848
+ * Who may make one is {@link ValOpsHttp.mayWriteFiles}.
5850
5849
  */
5851
5850
  static proposalFilesWrite(method, path) {
5852
- var _exec;
5853
5851
  if (method !== "POST") return null;
5854
- return ((_exec = /^\/([0-9a-f]{20})\/(files|lockfile|typecheck|build|update-from-site|restore-code)$/.exec(path)) === null || _exec === void 0 ? void 0 : _exec[1]) ?? null;
5852
+ const match = /^\/([0-9a-f]{20})\/(files|lockfile|typecheck|build|update-from-site|restore-code)$/.exec(path);
5853
+ return match === null ? null : {
5854
+ name: match[1],
5855
+ write: match[2]
5856
+ };
5857
+ }
5858
+
5859
+ /**
5860
+ * The writes the SITE's server may make to a proposal's files: what the
5861
+ * design tab does (valbuild/home `docs/design-tab.md`, step 2) -- stage
5862
+ * code and build it. The tab is served by the site's
5863
+ * build so that a build the assistant breaks in the proposal cannot take
5864
+ * down the tools it would fix it with; at the proposal's address those
5865
+ * tools run on the proposal's own code.
5866
+ *
5867
+ * The rest stay the proposal's own: Update from the site and the lockfile
5868
+ * are answered from the proposal's build and schemas, bringing back a
5869
+ * point's code is the Studio at its address finishing a restore, and the
5870
+ * typecheck it reports is what blocks its Publish (adept.md, decision 20).
5871
+ */
5872
+ static SITE_MAY_WRITE = new Set(["files", "build"]);
5873
+
5874
+ /**
5875
+ * Whether this server may make a write to a proposal's files: the
5876
+ * proposal's own server, any of them; the site's, the design tab's; and a
5877
+ * proposal's address, none to another proposal. Either way the site's own
5878
+ * files change only when a proposal is merged.
5879
+ */
5880
+ mayWriteFiles(write) {
5881
+ if (this.proposal !== null) return write.name === this.proposal.name;
5882
+ return ValOpsHttp.SITE_MAY_WRITE.has(write.write);
5855
5883
  }
5856
5884
 
5857
5885
  /**
@@ -5878,13 +5906,13 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5878
5906
  return /^\/publish-jobs\/[A-Za-z0-9_-]{1,100}\/(merge-prepare|steps|renew|cancel)$/.test(path);
5879
5907
  }
5880
5908
  async proposalsApi(path, init, profileId) {
5881
- var _exec2, _exec3, _exec4, _exec5, _this$proposal;
5909
+ var _exec, _exec2, _exec3, _exec4;
5882
5910
  const json = "application/json";
5883
- const updating = (_exec2 = /^\/([0-9a-f]{20})\/update-content$/.exec(path)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
5911
+ const updating = (_exec = /^\/([0-9a-f]{20})\/update-content$/.exec(path)) === null || _exec === void 0 ? void 0 : _exec[1];
5884
5912
  if (updating !== undefined && init.method === "POST") {
5885
5913
  return this.updateContentFromSite(updating, init.body, profileId);
5886
5914
  }
5887
- const withCode = (_exec3 = /^\/([0-9a-f]{20})\/update-code$/.exec(path)) === null || _exec3 === void 0 ? void 0 : _exec3[1];
5915
+ const withCode = (_exec2 = /^\/([0-9a-f]{20})\/update-code$/.exec(path)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
5888
5916
  if (withCode !== undefined && init.method === "POST") {
5889
5917
  return this.updateCodeFromSite(withCode, init.body, profileId);
5890
5918
  }
@@ -5894,11 +5922,11 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5894
5922
  * build's schemas (step 8.2). Anywhere else they go to content as they
5895
5923
  * are, and the site's pending changes block as they always did.
5896
5924
  */
5897
- const checking = (_exec4 = /^\/([0-9a-f]{20})\/merge-checks$/.exec(path)) === null || _exec4 === void 0 ? void 0 : _exec4[1];
5925
+ const checking = (_exec3 = /^\/([0-9a-f]{20})\/merge-checks$/.exec(path)) === null || _exec3 === void 0 ? void 0 : _exec3[1];
5898
5926
  if (checking !== undefined && init.method === "GET" && (await this.answersMovesFor(checking, profileId))) {
5899
5927
  return this.mergeChecksWithMoves(checking, profileId);
5900
5928
  }
5901
- const pressing = (_exec5 = /^\/([0-9a-f]{20})\/merge$/.exec(path)) === null || _exec5 === void 0 ? void 0 : _exec5[1];
5929
+ const pressing = (_exec4 = /^\/([0-9a-f]{20})\/merge$/.exec(path)) === null || _exec4 === void 0 ? void 0 : _exec4[1];
5902
5930
  if (pressing !== undefined && init.method === "POST" && (await this.answersMovesFor(pressing, profileId))) {
5903
5931
  return this.pressMergeWithMoves(pressing, init.body, profileId);
5904
5932
  }
@@ -5912,12 +5940,12 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5912
5940
  };
5913
5941
  }
5914
5942
  const writes = ValOpsHttp.proposalFilesWrite(init.method, path);
5915
- if (writes !== null && writes !== ((_this$proposal = this.proposal) === null || _this$proposal === void 0 ? void 0 : _this$proposal.name)) {
5943
+ if (writes !== null && !this.mayWriteFiles(writes)) {
5916
5944
  return {
5917
5945
  status: 403,
5918
5946
  contentType: json,
5919
5947
  body: JSON.stringify({
5920
- message: this.proposal === null ? "The site's files are changed in a proposal: open one, and change them there." : "Files are changed in the proposal this Studio is open in, not in another."
5948
+ message: this.proposal === null ? "Only the proposal's own Studio does this: open the proposal, and do it there." : "Files are changed in the proposal this Studio is open in, not in another."
5921
5949
  })
5922
5950
  };
5923
5951
  }
@@ -5962,14 +5990,14 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5962
5990
  * with their `resolutions` merges.
5963
5991
  */
5964
5992
  async updateContentFromSite(name, body, profileId) {
5965
- var _this$proposal2;
5993
+ var _this$proposal;
5966
5994
  const json = "application/json";
5967
5995
  const answer = (status, value) => ({
5968
5996
  status,
5969
5997
  contentType: json,
5970
5998
  body: JSON.stringify(value)
5971
5999
  });
5972
- if (((_this$proposal2 = this.proposal) === null || _this$proposal2 === void 0 ? void 0 : _this$proposal2.name) !== name) {
6000
+ if (((_this$proposal = this.proposal) === null || _this$proposal === void 0 ? void 0 : _this$proposal.name) !== name) {
5973
6001
  return answer(403, {
5974
6002
  message: "A proposal is updated from the site at its own address, where its build is."
5975
6003
  });
@@ -6239,14 +6267,14 @@ class ValOpsHttp extends ValRouterCore.ValOps {
6239
6267
  * Only at the proposal's own address, as every write to its files is.
6240
6268
  */
6241
6269
  async updateCodeFromSite(name, body, profileId) {
6242
- var _this$proposal3;
6270
+ var _this$proposal2;
6243
6271
  const json = "application/json";
6244
6272
  const answer = (status, value) => ({
6245
6273
  status,
6246
6274
  contentType: json,
6247
6275
  body: JSON.stringify(value)
6248
6276
  });
6249
- if (((_this$proposal3 = this.proposal) === null || _this$proposal3 === void 0 ? void 0 : _this$proposal3.name) !== name) {
6277
+ if (((_this$proposal2 = this.proposal) === null || _this$proposal2 === void 0 ? void 0 : _this$proposal2.name) !== name) {
6250
6278
  return answer(403, {
6251
6279
  message: "A proposal is updated from the site at its own address, where its files are written."
6252
6280
  });
@@ -6692,8 +6720,8 @@ class ValOpsHttp extends ValRouterCore.ValOps {
6692
6720
 
6693
6721
  /** The branch this server's patches are on, where it knows it. */
6694
6722
  ownBranch() {
6695
- var _this$proposal4, _this$git;
6696
- return ((_this$proposal4 = this.proposal) === null || _this$proposal4 === void 0 ? void 0 : _this$proposal4.branch) ?? ((_this$git = this.git) === null || _this$git === void 0 ? void 0 : _this$git.branch);
6723
+ var _this$proposal3, _this$git;
6724
+ return ((_this$proposal3 = this.proposal) === null || _this$proposal3 === void 0 ? void 0 : _this$proposal3.branch) ?? ((_this$git = this.git) === null || _this$git === void 0 ? void 0 : _this$git.branch);
6697
6725
  }
6698
6726
  async getWebSocketNonce(profileId) {
6699
6727
  return fetch(`${this.contentUrl}/v1/${this.project}/websocket/nonces`, {
@@ -7458,13 +7486,13 @@ class ValOpsHttp extends ValRouterCore.ValOps {
7458
7486
  */
7459
7487
  intoProposal) {
7460
7488
  try {
7461
- var _this$proposal5, _res$headers$get3;
7489
+ var _this$proposal4, _res$headers$get3;
7462
7490
  /*
7463
7491
  * A save in a proposal is a commit on the proposal's branch, at its own
7464
7492
  * route: the site's `/commit` refuses a proposal's patches, which is
7465
7493
  * the line that keeps them off the site until a merge.
7466
7494
  */
7467
- const proposalName = intoProposal ?? ((_this$proposal5 = this.proposal) === null || _this$proposal5 === void 0 ? void 0 : _this$proposal5.name);
7495
+ const proposalName = intoProposal ?? ((_this$proposal4 = this.proposal) === null || _this$proposal4 === void 0 ? void 0 : _this$proposal4.name);
7468
7496
  const commitUrl = proposalName !== undefined ? `${this.contentUrl}/v1/${this.project}/proposals/${proposalName}/save` : `${this.contentUrl}/v1/${this.project}/commit`;
7469
7497
  const res = await fetch(commitUrl, {
7470
7498
  method: "POST",
@@ -5842,16 +5842,44 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5842
5842
  * (valbuild/home `docs/adept.md`, step 6), reporting the typecheck of
5843
5843
  * them (step 7, decision 20), serving a build of it
5844
5844
  * (valbuild/home `docs/hosted-publishing.md`, step 7), or moving it onto the
5845
- * site's code (step 8, "Update from the site") -- is made by the
5846
- * proposal's own server and nobody else's: the file tools act on the
5847
- * proposal the Studio is open in (P11), and the site's files change only
5848
- * when a proposal is merged. The proposal it names, or `null` when this
5849
- * path is not such a write.
5845
+ * site's code (step 8, "Update from the site"). The proposal it names and
5846
+ * what it does, or `null` when this path is not such a write.
5847
+ *
5848
+ * Who may make one is {@link ValOpsHttp.mayWriteFiles}.
5850
5849
  */
5851
5850
  static proposalFilesWrite(method, path) {
5852
- var _exec;
5853
5851
  if (method !== "POST") return null;
5854
- return ((_exec = /^\/([0-9a-f]{20})\/(files|lockfile|typecheck|build|update-from-site|restore-code)$/.exec(path)) === null || _exec === void 0 ? void 0 : _exec[1]) ?? null;
5852
+ const match = /^\/([0-9a-f]{20})\/(files|lockfile|typecheck|build|update-from-site|restore-code)$/.exec(path);
5853
+ return match === null ? null : {
5854
+ name: match[1],
5855
+ write: match[2]
5856
+ };
5857
+ }
5858
+
5859
+ /**
5860
+ * The writes the SITE's server may make to a proposal's files: what the
5861
+ * design tab does (valbuild/home `docs/design-tab.md`, step 2) -- stage
5862
+ * code and build it. The tab is served by the site's
5863
+ * build so that a build the assistant breaks in the proposal cannot take
5864
+ * down the tools it would fix it with; at the proposal's address those
5865
+ * tools run on the proposal's own code.
5866
+ *
5867
+ * The rest stay the proposal's own: Update from the site and the lockfile
5868
+ * are answered from the proposal's build and schemas, bringing back a
5869
+ * point's code is the Studio at its address finishing a restore, and the
5870
+ * typecheck it reports is what blocks its Publish (adept.md, decision 20).
5871
+ */
5872
+ static SITE_MAY_WRITE = new Set(["files", "build"]);
5873
+
5874
+ /**
5875
+ * Whether this server may make a write to a proposal's files: the
5876
+ * proposal's own server, any of them; the site's, the design tab's; and a
5877
+ * proposal's address, none to another proposal. Either way the site's own
5878
+ * files change only when a proposal is merged.
5879
+ */
5880
+ mayWriteFiles(write) {
5881
+ if (this.proposal !== null) return write.name === this.proposal.name;
5882
+ return ValOpsHttp.SITE_MAY_WRITE.has(write.write);
5855
5883
  }
5856
5884
 
5857
5885
  /**
@@ -5878,13 +5906,13 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5878
5906
  return /^\/publish-jobs\/[A-Za-z0-9_-]{1,100}\/(merge-prepare|steps|renew|cancel)$/.test(path);
5879
5907
  }
5880
5908
  async proposalsApi(path, init, profileId) {
5881
- var _exec2, _exec3, _exec4, _exec5, _this$proposal;
5909
+ var _exec, _exec2, _exec3, _exec4;
5882
5910
  const json = "application/json";
5883
- const updating = (_exec2 = /^\/([0-9a-f]{20})\/update-content$/.exec(path)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
5911
+ const updating = (_exec = /^\/([0-9a-f]{20})\/update-content$/.exec(path)) === null || _exec === void 0 ? void 0 : _exec[1];
5884
5912
  if (updating !== undefined && init.method === "POST") {
5885
5913
  return this.updateContentFromSite(updating, init.body, profileId);
5886
5914
  }
5887
- const withCode = (_exec3 = /^\/([0-9a-f]{20})\/update-code$/.exec(path)) === null || _exec3 === void 0 ? void 0 : _exec3[1];
5915
+ const withCode = (_exec2 = /^\/([0-9a-f]{20})\/update-code$/.exec(path)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
5888
5916
  if (withCode !== undefined && init.method === "POST") {
5889
5917
  return this.updateCodeFromSite(withCode, init.body, profileId);
5890
5918
  }
@@ -5894,11 +5922,11 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5894
5922
  * build's schemas (step 8.2). Anywhere else they go to content as they
5895
5923
  * are, and the site's pending changes block as they always did.
5896
5924
  */
5897
- const checking = (_exec4 = /^\/([0-9a-f]{20})\/merge-checks$/.exec(path)) === null || _exec4 === void 0 ? void 0 : _exec4[1];
5925
+ const checking = (_exec3 = /^\/([0-9a-f]{20})\/merge-checks$/.exec(path)) === null || _exec3 === void 0 ? void 0 : _exec3[1];
5898
5926
  if (checking !== undefined && init.method === "GET" && (await this.answersMovesFor(checking, profileId))) {
5899
5927
  return this.mergeChecksWithMoves(checking, profileId);
5900
5928
  }
5901
- const pressing = (_exec5 = /^\/([0-9a-f]{20})\/merge$/.exec(path)) === null || _exec5 === void 0 ? void 0 : _exec5[1];
5929
+ const pressing = (_exec4 = /^\/([0-9a-f]{20})\/merge$/.exec(path)) === null || _exec4 === void 0 ? void 0 : _exec4[1];
5902
5930
  if (pressing !== undefined && init.method === "POST" && (await this.answersMovesFor(pressing, profileId))) {
5903
5931
  return this.pressMergeWithMoves(pressing, init.body, profileId);
5904
5932
  }
@@ -5912,12 +5940,12 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5912
5940
  };
5913
5941
  }
5914
5942
  const writes = ValOpsHttp.proposalFilesWrite(init.method, path);
5915
- if (writes !== null && writes !== ((_this$proposal = this.proposal) === null || _this$proposal === void 0 ? void 0 : _this$proposal.name)) {
5943
+ if (writes !== null && !this.mayWriteFiles(writes)) {
5916
5944
  return {
5917
5945
  status: 403,
5918
5946
  contentType: json,
5919
5947
  body: JSON.stringify({
5920
- message: this.proposal === null ? "The site's files are changed in a proposal: open one, and change them there." : "Files are changed in the proposal this Studio is open in, not in another."
5948
+ message: this.proposal === null ? "Only the proposal's own Studio does this: open the proposal, and do it there." : "Files are changed in the proposal this Studio is open in, not in another."
5921
5949
  })
5922
5950
  };
5923
5951
  }
@@ -5962,14 +5990,14 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5962
5990
  * with their `resolutions` merges.
5963
5991
  */
5964
5992
  async updateContentFromSite(name, body, profileId) {
5965
- var _this$proposal2;
5993
+ var _this$proposal;
5966
5994
  const json = "application/json";
5967
5995
  const answer = (status, value) => ({
5968
5996
  status,
5969
5997
  contentType: json,
5970
5998
  body: JSON.stringify(value)
5971
5999
  });
5972
- if (((_this$proposal2 = this.proposal) === null || _this$proposal2 === void 0 ? void 0 : _this$proposal2.name) !== name) {
6000
+ if (((_this$proposal = this.proposal) === null || _this$proposal === void 0 ? void 0 : _this$proposal.name) !== name) {
5973
6001
  return answer(403, {
5974
6002
  message: "A proposal is updated from the site at its own address, where its build is."
5975
6003
  });
@@ -6239,14 +6267,14 @@ class ValOpsHttp extends ValRouterCore.ValOps {
6239
6267
  * Only at the proposal's own address, as every write to its files is.
6240
6268
  */
6241
6269
  async updateCodeFromSite(name, body, profileId) {
6242
- var _this$proposal3;
6270
+ var _this$proposal2;
6243
6271
  const json = "application/json";
6244
6272
  const answer = (status, value) => ({
6245
6273
  status,
6246
6274
  contentType: json,
6247
6275
  body: JSON.stringify(value)
6248
6276
  });
6249
- if (((_this$proposal3 = this.proposal) === null || _this$proposal3 === void 0 ? void 0 : _this$proposal3.name) !== name) {
6277
+ if (((_this$proposal2 = this.proposal) === null || _this$proposal2 === void 0 ? void 0 : _this$proposal2.name) !== name) {
6250
6278
  return answer(403, {
6251
6279
  message: "A proposal is updated from the site at its own address, where its files are written."
6252
6280
  });
@@ -6692,8 +6720,8 @@ class ValOpsHttp extends ValRouterCore.ValOps {
6692
6720
 
6693
6721
  /** The branch this server's patches are on, where it knows it. */
6694
6722
  ownBranch() {
6695
- var _this$proposal4, _this$git;
6696
- return ((_this$proposal4 = this.proposal) === null || _this$proposal4 === void 0 ? void 0 : _this$proposal4.branch) ?? ((_this$git = this.git) === null || _this$git === void 0 ? void 0 : _this$git.branch);
6723
+ var _this$proposal3, _this$git;
6724
+ return ((_this$proposal3 = this.proposal) === null || _this$proposal3 === void 0 ? void 0 : _this$proposal3.branch) ?? ((_this$git = this.git) === null || _this$git === void 0 ? void 0 : _this$git.branch);
6697
6725
  }
6698
6726
  async getWebSocketNonce(profileId) {
6699
6727
  return fetch(`${this.contentUrl}/v1/${this.project}/websocket/nonces`, {
@@ -7458,13 +7486,13 @@ class ValOpsHttp extends ValRouterCore.ValOps {
7458
7486
  */
7459
7487
  intoProposal) {
7460
7488
  try {
7461
- var _this$proposal5, _res$headers$get3;
7489
+ var _this$proposal4, _res$headers$get3;
7462
7490
  /*
7463
7491
  * A save in a proposal is a commit on the proposal's branch, at its own
7464
7492
  * route: the site's `/commit` refuses a proposal's patches, which is
7465
7493
  * the line that keeps them off the site until a merge.
7466
7494
  */
7467
- const proposalName = intoProposal ?? ((_this$proposal5 = this.proposal) === null || _this$proposal5 === void 0 ? void 0 : _this$proposal5.name);
7495
+ const proposalName = intoProposal ?? ((_this$proposal4 = this.proposal) === null || _this$proposal4 === void 0 ? void 0 : _this$proposal4.name);
7468
7496
  const commitUrl = proposalName !== undefined ? `${this.contentUrl}/v1/${this.project}/proposals/${proposalName}/save` : `${this.contentUrl}/v1/${this.project}/commit`;
7469
7497
  const res = await fetch(commitUrl, {
7470
7498
  method: "POST",
@@ -5806,16 +5806,44 @@ class ValOpsHttp extends ValOps {
5806
5806
  * (valbuild/home `docs/adept.md`, step 6), reporting the typecheck of
5807
5807
  * them (step 7, decision 20), serving a build of it
5808
5808
  * (valbuild/home `docs/hosted-publishing.md`, step 7), or moving it onto the
5809
- * site's code (step 8, "Update from the site") -- is made by the
5810
- * proposal's own server and nobody else's: the file tools act on the
5811
- * proposal the Studio is open in (P11), and the site's files change only
5812
- * when a proposal is merged. The proposal it names, or `null` when this
5813
- * path is not such a write.
5809
+ * site's code (step 8, "Update from the site"). The proposal it names and
5810
+ * what it does, or `null` when this path is not such a write.
5811
+ *
5812
+ * Who may make one is {@link ValOpsHttp.mayWriteFiles}.
5814
5813
  */
5815
5814
  static proposalFilesWrite(method, path) {
5816
- var _exec;
5817
5815
  if (method !== "POST") return null;
5818
- return ((_exec = /^\/([0-9a-f]{20})\/(files|lockfile|typecheck|build|update-from-site|restore-code)$/.exec(path)) === null || _exec === void 0 ? void 0 : _exec[1]) ?? null;
5816
+ const match = /^\/([0-9a-f]{20})\/(files|lockfile|typecheck|build|update-from-site|restore-code)$/.exec(path);
5817
+ return match === null ? null : {
5818
+ name: match[1],
5819
+ write: match[2]
5820
+ };
5821
+ }
5822
+
5823
+ /**
5824
+ * The writes the SITE's server may make to a proposal's files: what the
5825
+ * design tab does (valbuild/home `docs/design-tab.md`, step 2) -- stage
5826
+ * code and build it. The tab is served by the site's
5827
+ * build so that a build the assistant breaks in the proposal cannot take
5828
+ * down the tools it would fix it with; at the proposal's address those
5829
+ * tools run on the proposal's own code.
5830
+ *
5831
+ * The rest stay the proposal's own: Update from the site and the lockfile
5832
+ * are answered from the proposal's build and schemas, bringing back a
5833
+ * point's code is the Studio at its address finishing a restore, and the
5834
+ * typecheck it reports is what blocks its Publish (adept.md, decision 20).
5835
+ */
5836
+ static SITE_MAY_WRITE = new Set(["files", "build"]);
5837
+
5838
+ /**
5839
+ * Whether this server may make a write to a proposal's files: the
5840
+ * proposal's own server, any of them; the site's, the design tab's; and a
5841
+ * proposal's address, none to another proposal. Either way the site's own
5842
+ * files change only when a proposal is merged.
5843
+ */
5844
+ mayWriteFiles(write) {
5845
+ if (this.proposal !== null) return write.name === this.proposal.name;
5846
+ return ValOpsHttp.SITE_MAY_WRITE.has(write.write);
5819
5847
  }
5820
5848
 
5821
5849
  /**
@@ -5842,13 +5870,13 @@ class ValOpsHttp extends ValOps {
5842
5870
  return /^\/publish-jobs\/[A-Za-z0-9_-]{1,100}\/(merge-prepare|steps|renew|cancel)$/.test(path);
5843
5871
  }
5844
5872
  async proposalsApi(path, init, profileId) {
5845
- var _exec2, _exec3, _exec4, _exec5, _this$proposal;
5873
+ var _exec, _exec2, _exec3, _exec4;
5846
5874
  const json = "application/json";
5847
- const updating = (_exec2 = /^\/([0-9a-f]{20})\/update-content$/.exec(path)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
5875
+ const updating = (_exec = /^\/([0-9a-f]{20})\/update-content$/.exec(path)) === null || _exec === void 0 ? void 0 : _exec[1];
5848
5876
  if (updating !== undefined && init.method === "POST") {
5849
5877
  return this.updateContentFromSite(updating, init.body, profileId);
5850
5878
  }
5851
- const withCode = (_exec3 = /^\/([0-9a-f]{20})\/update-code$/.exec(path)) === null || _exec3 === void 0 ? void 0 : _exec3[1];
5879
+ const withCode = (_exec2 = /^\/([0-9a-f]{20})\/update-code$/.exec(path)) === null || _exec2 === void 0 ? void 0 : _exec2[1];
5852
5880
  if (withCode !== undefined && init.method === "POST") {
5853
5881
  return this.updateCodeFromSite(withCode, init.body, profileId);
5854
5882
  }
@@ -5858,11 +5886,11 @@ class ValOpsHttp extends ValOps {
5858
5886
  * build's schemas (step 8.2). Anywhere else they go to content as they
5859
5887
  * are, and the site's pending changes block as they always did.
5860
5888
  */
5861
- const checking = (_exec4 = /^\/([0-9a-f]{20})\/merge-checks$/.exec(path)) === null || _exec4 === void 0 ? void 0 : _exec4[1];
5889
+ const checking = (_exec3 = /^\/([0-9a-f]{20})\/merge-checks$/.exec(path)) === null || _exec3 === void 0 ? void 0 : _exec3[1];
5862
5890
  if (checking !== undefined && init.method === "GET" && (await this.answersMovesFor(checking, profileId))) {
5863
5891
  return this.mergeChecksWithMoves(checking, profileId);
5864
5892
  }
5865
- const pressing = (_exec5 = /^\/([0-9a-f]{20})\/merge$/.exec(path)) === null || _exec5 === void 0 ? void 0 : _exec5[1];
5893
+ const pressing = (_exec4 = /^\/([0-9a-f]{20})\/merge$/.exec(path)) === null || _exec4 === void 0 ? void 0 : _exec4[1];
5866
5894
  if (pressing !== undefined && init.method === "POST" && (await this.answersMovesFor(pressing, profileId))) {
5867
5895
  return this.pressMergeWithMoves(pressing, init.body, profileId);
5868
5896
  }
@@ -5876,12 +5904,12 @@ class ValOpsHttp extends ValOps {
5876
5904
  };
5877
5905
  }
5878
5906
  const writes = ValOpsHttp.proposalFilesWrite(init.method, path);
5879
- if (writes !== null && writes !== ((_this$proposal = this.proposal) === null || _this$proposal === void 0 ? void 0 : _this$proposal.name)) {
5907
+ if (writes !== null && !this.mayWriteFiles(writes)) {
5880
5908
  return {
5881
5909
  status: 403,
5882
5910
  contentType: json,
5883
5911
  body: JSON.stringify({
5884
- message: this.proposal === null ? "The site's files are changed in a proposal: open one, and change them there." : "Files are changed in the proposal this Studio is open in, not in another."
5912
+ message: this.proposal === null ? "Only the proposal's own Studio does this: open the proposal, and do it there." : "Files are changed in the proposal this Studio is open in, not in another."
5885
5913
  })
5886
5914
  };
5887
5915
  }
@@ -5926,14 +5954,14 @@ class ValOpsHttp extends ValOps {
5926
5954
  * with their `resolutions` merges.
5927
5955
  */
5928
5956
  async updateContentFromSite(name, body, profileId) {
5929
- var _this$proposal2;
5957
+ var _this$proposal;
5930
5958
  const json = "application/json";
5931
5959
  const answer = (status, value) => ({
5932
5960
  status,
5933
5961
  contentType: json,
5934
5962
  body: JSON.stringify(value)
5935
5963
  });
5936
- if (((_this$proposal2 = this.proposal) === null || _this$proposal2 === void 0 ? void 0 : _this$proposal2.name) !== name) {
5964
+ if (((_this$proposal = this.proposal) === null || _this$proposal === void 0 ? void 0 : _this$proposal.name) !== name) {
5937
5965
  return answer(403, {
5938
5966
  message: "A proposal is updated from the site at its own address, where its build is."
5939
5967
  });
@@ -6203,14 +6231,14 @@ class ValOpsHttp extends ValOps {
6203
6231
  * Only at the proposal's own address, as every write to its files is.
6204
6232
  */
6205
6233
  async updateCodeFromSite(name, body, profileId) {
6206
- var _this$proposal3;
6234
+ var _this$proposal2;
6207
6235
  const json = "application/json";
6208
6236
  const answer = (status, value) => ({
6209
6237
  status,
6210
6238
  contentType: json,
6211
6239
  body: JSON.stringify(value)
6212
6240
  });
6213
- if (((_this$proposal3 = this.proposal) === null || _this$proposal3 === void 0 ? void 0 : _this$proposal3.name) !== name) {
6241
+ if (((_this$proposal2 = this.proposal) === null || _this$proposal2 === void 0 ? void 0 : _this$proposal2.name) !== name) {
6214
6242
  return answer(403, {
6215
6243
  message: "A proposal is updated from the site at its own address, where its files are written."
6216
6244
  });
@@ -6656,8 +6684,8 @@ class ValOpsHttp extends ValOps {
6656
6684
 
6657
6685
  /** The branch this server's patches are on, where it knows it. */
6658
6686
  ownBranch() {
6659
- var _this$proposal4, _this$git;
6660
- return ((_this$proposal4 = this.proposal) === null || _this$proposal4 === void 0 ? void 0 : _this$proposal4.branch) ?? ((_this$git = this.git) === null || _this$git === void 0 ? void 0 : _this$git.branch);
6687
+ var _this$proposal3, _this$git;
6688
+ return ((_this$proposal3 = this.proposal) === null || _this$proposal3 === void 0 ? void 0 : _this$proposal3.branch) ?? ((_this$git = this.git) === null || _this$git === void 0 ? void 0 : _this$git.branch);
6661
6689
  }
6662
6690
  async getWebSocketNonce(profileId) {
6663
6691
  return fetch(`${this.contentUrl}/v1/${this.project}/websocket/nonces`, {
@@ -7422,13 +7450,13 @@ class ValOpsHttp extends ValOps {
7422
7450
  */
7423
7451
  intoProposal) {
7424
7452
  try {
7425
- var _this$proposal5, _res$headers$get3;
7453
+ var _this$proposal4, _res$headers$get3;
7426
7454
  /*
7427
7455
  * A save in a proposal is a commit on the proposal's branch, at its own
7428
7456
  * route: the site's `/commit` refuses a proposal's patches, which is
7429
7457
  * the line that keeps them off the site until a merge.
7430
7458
  */
7431
- const proposalName = intoProposal ?? ((_this$proposal5 = this.proposal) === null || _this$proposal5 === void 0 ? void 0 : _this$proposal5.name);
7459
+ const proposalName = intoProposal ?? ((_this$proposal4 = this.proposal) === null || _this$proposal4 === void 0 ? void 0 : _this$proposal4.name);
7432
7460
  const commitUrl = proposalName !== undefined ? `${this.contentUrl}/v1/${this.project}/proposals/${proposalName}/save` : `${this.contentUrl}/v1/${this.project}/commit`;
7433
7461
  const res = await fetch(commitUrl, {
7434
7462
  method: "POST",
package/package.json CHANGED
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "exports": true
29
29
  },
30
- "version": "0.150.2",
30
+ "version": "0.150.5",
31
31
  "devDependencies": {
32
32
  "@prettier/sync": "^0.6.1",
33
33
  "@types/jest": "^30.0.0",
@@ -41,9 +41,9 @@
41
41
  "typescript": "^6.0.3",
42
42
  "zod": "^4.4.3",
43
43
  "zod-validation-error": "^5.0.0",
44
- "@valbuild/shared": "0.150.2",
45
- "@valbuild/ui": "0.150.2",
46
- "@valbuild/core": "0.150.2"
44
+ "@valbuild/core": "0.150.3",
45
+ "@valbuild/shared": "0.150.3",
46
+ "@valbuild/ui": "0.150.5"
47
47
  },
48
48
  "engines": {
49
49
  "node": "^20.19.0 || >=22"