@valbuild/server 0.141.0 → 0.141.1

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,18 @@
1
1
  # @valbuild/server
2
2
 
3
+ ## 0.141.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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`.
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ - Updated dependencies [[`6faacda`](https://github.com/valbuild/val/commit/6faacda398fc92bec187b7afe07a53228a6f2a3b), [`14b18d7`](https://github.com/valbuild/val/commit/14b18d7cb145cec1bc1cd832b9ca857ff4b45adc)]:
14
+ - @valbuild/ui@0.141.1
15
+
3
16
  ## 0.141.0
4
17
 
5
18
  ### Minor Changes
@@ -2498,6 +2498,24 @@ function defineExternal(definition) {
2498
2498
  throw new Error("defineExternal is not implemented yet: phase 0 lands the contract, the registry that executes it arrives with the read endpoints.");
2499
2499
  }
2500
2500
 
2501
+ /**
2502
+ * Does saving this commit upload a file to Val's remote host?
2503
+ *
2504
+ * The question `/save` asks before it reads remote credentials. It used to ask
2505
+ * the SCHEMAS instead -- "is any of them remote?" -- and with
2506
+ * `files: { remote: true }` every media schema is, so every save needed a
2507
+ * `val login` token or an api key: a corrected typo included. Only a remote
2508
+ * FILE is uploaded, so only a commit carrying one needs credentials.
2509
+ */
2510
+ function commitCarriesRemoteFiles(preparedCommit) {
2511
+ return Object.values(preparedCommit.patchedBinaryFilesDescriptors).some(descriptor => descriptor.remote);
2512
+ }
2513
+
2514
+ /** Does this commit carry any file at all, remote or local? */
2515
+ function commitCarriesFiles(preparedCommit) {
2516
+ return Object.keys(preparedCommit.patchedBinaryFilesDescriptors).length > 0;
2517
+ }
2518
+
2501
2519
  const JwtPayloadSchema = z.z.object({
2502
2520
  sub: z.z.string(),
2503
2521
  exp: z.z.number(),
@@ -15732,7 +15750,13 @@ const ValServer = (valModules, options, callbacks) => {
15732
15750
  * tree; a store with no working tree does only the push.
15733
15751
  */
15734
15752
  if (serverOps instanceof ValOpsMemory) {
15735
- const isRemoteRequired = getIsRemoteRequired(await serverOps.getSchemas());
15753
+ /*
15754
+ * A commit with no files uploads nothing and needs no credentials;
15755
+ * see `commitCarriesRemoteFiles`. One with a LOCAL file still goes
15756
+ * through `uploadRemoteFiles` where the project is remote, because
15757
+ * that is where a local file is refused rather than dropped.
15758
+ */
15759
+ const isRemoteRequired = commitCarriesRemoteFiles(preparedCommit) || commitCarriesFiles(preparedCommit) && getIsRemoteRequired(await serverOps.getSchemas());
15736
15760
  if (isRemoteRequired) {
15737
15761
  const authRes = await getRemoteFileAuth();
15738
15762
  if (authRes.status !== 200) {
@@ -15755,7 +15779,9 @@ const ValServer = (valModules, options, callbacks) => {
15755
15779
  }
15756
15780
  if (serverOps instanceof ValOpsFS) {
15757
15781
  var _remoteFileAuthRes;
15758
- const isRemoteRequired = getIsRemoteRequired(await serverOps.getSchemas());
15782
+ // Credentials when THIS save uploads a remote file, not whenever
15783
+ // the project has a remote schema. See `commitCarriesRemoteFiles`.
15784
+ const isRemoteRequired = commitCarriesRemoteFiles(preparedCommit);
15759
15785
  let mode;
15760
15786
  let remoteFileAuthRes;
15761
15787
  if (isRemoteRequired) {
@@ -2498,6 +2498,24 @@ function defineExternal(definition) {
2498
2498
  throw new Error("defineExternal is not implemented yet: phase 0 lands the contract, the registry that executes it arrives with the read endpoints.");
2499
2499
  }
2500
2500
 
2501
+ /**
2502
+ * Does saving this commit upload a file to Val's remote host?
2503
+ *
2504
+ * The question `/save` asks before it reads remote credentials. It used to ask
2505
+ * the SCHEMAS instead -- "is any of them remote?" -- and with
2506
+ * `files: { remote: true }` every media schema is, so every save needed a
2507
+ * `val login` token or an api key: a corrected typo included. Only a remote
2508
+ * FILE is uploaded, so only a commit carrying one needs credentials.
2509
+ */
2510
+ function commitCarriesRemoteFiles(preparedCommit) {
2511
+ return Object.values(preparedCommit.patchedBinaryFilesDescriptors).some(descriptor => descriptor.remote);
2512
+ }
2513
+
2514
+ /** Does this commit carry any file at all, remote or local? */
2515
+ function commitCarriesFiles(preparedCommit) {
2516
+ return Object.keys(preparedCommit.patchedBinaryFilesDescriptors).length > 0;
2517
+ }
2518
+
2501
2519
  const JwtPayloadSchema = z.z.object({
2502
2520
  sub: z.z.string(),
2503
2521
  exp: z.z.number(),
@@ -15732,7 +15750,13 @@ const ValServer = (valModules, options, callbacks) => {
15732
15750
  * tree; a store with no working tree does only the push.
15733
15751
  */
15734
15752
  if (serverOps instanceof ValOpsMemory) {
15735
- const isRemoteRequired = getIsRemoteRequired(await serverOps.getSchemas());
15753
+ /*
15754
+ * A commit with no files uploads nothing and needs no credentials;
15755
+ * see `commitCarriesRemoteFiles`. One with a LOCAL file still goes
15756
+ * through `uploadRemoteFiles` where the project is remote, because
15757
+ * that is where a local file is refused rather than dropped.
15758
+ */
15759
+ const isRemoteRequired = commitCarriesRemoteFiles(preparedCommit) || commitCarriesFiles(preparedCommit) && getIsRemoteRequired(await serverOps.getSchemas());
15736
15760
  if (isRemoteRequired) {
15737
15761
  const authRes = await getRemoteFileAuth();
15738
15762
  if (authRes.status !== 200) {
@@ -15755,7 +15779,9 @@ const ValServer = (valModules, options, callbacks) => {
15755
15779
  }
15756
15780
  if (serverOps instanceof ValOpsFS) {
15757
15781
  var _remoteFileAuthRes;
15758
- const isRemoteRequired = getIsRemoteRequired(await serverOps.getSchemas());
15782
+ // Credentials when THIS save uploads a remote file, not whenever
15783
+ // the project has a remote schema. See `commitCarriesRemoteFiles`.
15784
+ const isRemoteRequired = commitCarriesRemoteFiles(preparedCommit);
15759
15785
  let mode;
15760
15786
  let remoteFileAuthRes;
15761
15787
  if (isRemoteRequired) {
@@ -2461,6 +2461,24 @@ function defineExternal(definition) {
2461
2461
  throw new Error("defineExternal is not implemented yet: phase 0 lands the contract, the registry that executes it arrives with the read endpoints.");
2462
2462
  }
2463
2463
 
2464
+ /**
2465
+ * Does saving this commit upload a file to Val's remote host?
2466
+ *
2467
+ * The question `/save` asks before it reads remote credentials. It used to ask
2468
+ * the SCHEMAS instead -- "is any of them remote?" -- and with
2469
+ * `files: { remote: true }` every media schema is, so every save needed a
2470
+ * `val login` token or an api key: a corrected typo included. Only a remote
2471
+ * FILE is uploaded, so only a commit carrying one needs credentials.
2472
+ */
2473
+ function commitCarriesRemoteFiles(preparedCommit) {
2474
+ return Object.values(preparedCommit.patchedBinaryFilesDescriptors).some(descriptor => descriptor.remote);
2475
+ }
2476
+
2477
+ /** Does this commit carry any file at all, remote or local? */
2478
+ function commitCarriesFiles(preparedCommit) {
2479
+ return Object.keys(preparedCommit.patchedBinaryFilesDescriptors).length > 0;
2480
+ }
2481
+
2464
2482
  const JwtPayloadSchema = z.object({
2465
2483
  sub: z.string(),
2466
2484
  exp: z.number(),
@@ -15695,7 +15713,13 @@ const ValServer = (valModules, options, callbacks) => {
15695
15713
  * tree; a store with no working tree does only the push.
15696
15714
  */
15697
15715
  if (serverOps instanceof ValOpsMemory) {
15698
- const isRemoteRequired = getIsRemoteRequired(await serverOps.getSchemas());
15716
+ /*
15717
+ * A commit with no files uploads nothing and needs no credentials;
15718
+ * see `commitCarriesRemoteFiles`. One with a LOCAL file still goes
15719
+ * through `uploadRemoteFiles` where the project is remote, because
15720
+ * that is where a local file is refused rather than dropped.
15721
+ */
15722
+ const isRemoteRequired = commitCarriesRemoteFiles(preparedCommit) || commitCarriesFiles(preparedCommit) && getIsRemoteRequired(await serverOps.getSchemas());
15699
15723
  if (isRemoteRequired) {
15700
15724
  const authRes = await getRemoteFileAuth();
15701
15725
  if (authRes.status !== 200) {
@@ -15718,7 +15742,9 @@ const ValServer = (valModules, options, callbacks) => {
15718
15742
  }
15719
15743
  if (serverOps instanceof ValOpsFS) {
15720
15744
  var _remoteFileAuthRes;
15721
- const isRemoteRequired = getIsRemoteRequired(await serverOps.getSchemas());
15745
+ // Credentials when THIS save uploads a remote file, not whenever
15746
+ // the project has a remote schema. See `commitCarriesRemoteFiles`.
15747
+ const isRemoteRequired = commitCarriesRemoteFiles(preparedCommit);
15722
15748
  let mode;
15723
15749
  let remoteFileAuthRes;
15724
15750
  if (isRemoteRequired) {
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "./package.json": "./package.json"
17
17
  },
18
18
  "types": "dist/valbuild-server.cjs.d.ts",
19
- "version": "0.141.0",
19
+ "version": "0.141.1",
20
20
  "devDependencies": {
21
21
  "@prettier/sync": "^0.6.1",
22
22
  "@types/jest": "^30.0.0",
@@ -30,9 +30,9 @@
30
30
  "typescript": "^6.0.3",
31
31
  "zod": "^4.4.3",
32
32
  "zod-validation-error": "^5.0.0",
33
+ "@valbuild/core": "0.141.0",
33
34
  "@valbuild/shared": "0.141.0",
34
- "@valbuild/ui": "0.141.0",
35
- "@valbuild/core": "0.141.0"
35
+ "@valbuild/ui": "0.141.1"
36
36
  },
37
37
  "engines": {
38
38
  "node": "^20.19.0 || >=22"