@valbuild/server 0.151.0 → 0.152.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 +22 -0
- package/browser/dist/valbuild-server-browser.cjs.dev.js +2 -2
- package/browser/dist/valbuild-server-browser.cjs.prod.js +2 -2
- package/browser/dist/valbuild-server-browser.esm.js +2 -2
- package/dist/{ValRouter-2827d620.esm.js → ValRouter-05fcb0da.esm.js} +218 -44
- package/dist/{ValRouter-ca467c83.cjs.dev.js → ValRouter-afcba447.cjs.dev.js} +217 -43
- package/dist/{ValRouter-d43e0a33.cjs.prod.js → ValRouter-b4e5b412.cjs.prod.js} +217 -43
- package/dist/{ValRouterCore-eb1f53f5.cjs.prod.js → ValRouterCore-a0ea46bf.cjs.prod.js} +47 -4
- package/dist/{ValRouterCore-6c29fb75.esm.js → ValRouterCore-b5d70504.esm.js} +47 -4
- package/dist/{ValRouterCore-0921fe9c.cjs.dev.js → ValRouterCore-d16c3327.cjs.dev.js} +47 -4
- package/dist/declarations/src/ValOps.d.ts +20 -2
- package/dist/{inTabFetch-35cf5698.cjs.prod.js → inTabFetch-095bb2be.cjs.prod.js} +1 -1
- package/dist/{inTabFetch-49db354b.cjs.dev.js → inTabFetch-2cbbfaa4.cjs.dev.js} +1 -1
- package/dist/{inTabFetch-0cd45721.esm.js → inTabFetch-91c3e85e.esm.js} +1 -1
- package/dist/{publishKit-3afe011d.cjs.dev.js → publishKit-4e2b0014.cjs.dev.js} +2 -2
- package/dist/{publishKit-24e1406b.cjs.prod.js → publishKit-6e52ffa6.cjs.prod.js} +2 -2
- package/dist/{publishKit-d2e3e44d.esm.js → publishKit-af14cd7a.esm.js} +3 -3
- package/dist/valbuild-server.cjs.dev.js +2 -2
- package/dist/valbuild-server.cjs.prod.js +2 -2
- package/dist/valbuild-server.esm.js +4 -4
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +2 -2
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +2 -2
- package/internal/browser/dist/valbuild-server-internal-browser.esm.js +2 -2
- package/internal/dist/valbuild-server-internal.cjs.dev.js +2 -2
- package/internal/dist/valbuild-server-internal.cjs.prod.js +2 -2
- package/internal/dist/valbuild-server-internal.esm.js +2 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @valbuild/server
|
|
2
2
|
|
|
3
|
+
## 0.152.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1013](https://github.com/valbuild/val/pull/1013) [`3bb76d7`](https://github.com/valbuild/val/commit/3bb76d74d82b499aa15023838d63018a70fd7ce7) Thanks [@freekh](https://github.com/freekh)! - A save that the content service fails to take no longer looks like a successful one.
|
|
8
|
+
|
|
9
|
+
Before, when the content service answered a save with a server error (or could not be reached), the Studio treated the edit as invalid and dropped it: the field went back to its old value, and the status bar kept saying "All changes saved". Now:
|
|
10
|
+
|
|
11
|
+
- **Your edit is kept.** The field keeps what you typed.
|
|
12
|
+
- **The Studio says the save failed.** The status bar shows "Could not save" (never "All changes saved" while a save has failed or is still pending), and a notice says which service failed, with the service's own message under **Details**.
|
|
13
|
+
- **Try again** sends the same save again. The Studio also retries by itself in the background, so if you leave the tab open your changes are saved once the service is back.
|
|
14
|
+
|
|
15
|
+
Pressing Publish while a save has failed now says what failed, in the service's words, with a **Save again** button, instead of "Check the connection and try again".
|
|
16
|
+
|
|
17
|
+
Saves that the service refuses because of your plan, and saves that conflict with someone else's change, work as before.
|
|
18
|
+
|
|
19
|
+
Error messages from the content service also stop blaming your network. "Could not get your changes. It is most likely due to a network issue. Check your network connection" was shown even when the service had answered with a 500. These messages now say what actually happened (the service answered with an error, refused the request, or could not be reached from your site's server) and name the service. The status code and the service's response are kept as details for whoever needs to look into it. Publish failures now also show the service's own message, where they used to say "Unknown error".
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`f4e0660`](https://github.com/valbuild/val/commit/f4e06601495dbee680a4b9000344f84cd3af717f), [`3bb76d7`](https://github.com/valbuild/val/commit/3bb76d74d82b499aa15023838d63018a70fd7ce7), [`08a3977`](https://github.com/valbuild/val/commit/08a39779dbe43702a72ae57cbf8cf29b14e64672)]:
|
|
22
|
+
- @valbuild/ui@0.152.0
|
|
23
|
+
- @valbuild/shared@0.152.0
|
|
24
|
+
|
|
3
25
|
## 0.151.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var inTabFetch = require('../../dist/inTabFetch-
|
|
5
|
+
var inTabFetch = require('../../dist/inTabFetch-2cbbfaa4.cjs.dev.js');
|
|
6
6
|
require('@valbuild/core');
|
|
7
|
-
require('../../dist/ValRouterCore-
|
|
7
|
+
require('../../dist/ValRouterCore-d16c3327.cjs.dev.js');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('@valbuild/shared/internal');
|
|
10
10
|
require('zod-validation-error');
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var inTabFetch = require('../../dist/inTabFetch-
|
|
5
|
+
var inTabFetch = require('../../dist/inTabFetch-095bb2be.cjs.prod.js');
|
|
6
6
|
require('@valbuild/core');
|
|
7
|
-
require('../../dist/ValRouterCore-
|
|
7
|
+
require('../../dist/ValRouterCore-a0ea46bf.cjs.prod.js');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('@valbuild/shared/internal');
|
|
10
10
|
require('zod-validation-error');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { c as createInTabValFetch } from '../../dist/inTabFetch-
|
|
1
|
+
export { c as createInTabValFetch } from '../../dist/inTabFetch-91c3e85e.esm.js';
|
|
2
2
|
import '@valbuild/core';
|
|
3
|
-
import '../../dist/ValRouterCore-
|
|
3
|
+
import '../../dist/ValRouterCore-b5d70504.esm.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@valbuild/shared/internal';
|
|
6
6
|
import 'zod-validation-error';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Internal, deserializeSchema, DEFAULT_CONTENT_HOST, DEFAULT_VAL_REMOTE_HOST } from '@valbuild/core';
|
|
2
2
|
import { createUIRequestHandler } from '@valbuild/ui/server';
|
|
3
|
-
import { r as resolveExistingJsonPath, s as summaryOf, m as matchesFilter, h as byUpdatedAt, n as newSketchpad, i as isSketchpadId, j as applySketchpadChange, k as ValOps, V as VAL_CLIENT_HEADERS, l as bufferFromDataUrl, o as getFieldsForType, u as uploadRemoteFile, d as getFileExt, p as guessMimeTypeFromPath, q as createMetadataFromBuffer, D as DEFAULT_ANALYTICS_INGEST_URL, e as ValOpsMemory, t as sessionAuth, w as isHttpOps, x as isHlsMasterPlaylist, y as sumHlsSegmentDurations, z as parseHlsMasterVariants, A as largestHlsVariant, B as fallbackRefOf, C as mapHlsUris, E as movedRemoteHost, F as needsHostCheck, G as rewriteRefHost, H as fallbackRemoteHost, J as checkRemoteFiles, K as ValServer, L as createValRequestHandler } from './ValRouterCore-
|
|
3
|
+
import { r as resolveExistingJsonPath, s as summaryOf, m as matchesFilter, h as byUpdatedAt, n as newSketchpad, i as isSketchpadId, j as applySketchpadChange, k as ValOps, V as VAL_CLIENT_HEADERS, l as bufferFromDataUrl, o as getFieldsForType, u as uploadRemoteFile, d as getFileExt, p as guessMimeTypeFromPath, q as createMetadataFromBuffer, D as DEFAULT_ANALYTICS_INGEST_URL, e as ValOpsMemory, t as sessionAuth, w as isHttpOps, x as isHlsMasterPlaylist, y as sumHlsSegmentDurations, z as parseHlsMasterVariants, A as largestHlsVariant, B as fallbackRefOf, C as mapHlsUris, E as movedRemoteHost, F as needsHostCheck, G as rewriteRefHost, H as fallbackRemoteHost, J as checkRemoteFiles, K as ValServer, L as createValRequestHandler } from './ValRouterCore-b5d70504.esm.js';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import ts from 'typescript';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import { fromError } from 'zod-validation-error';
|
|
9
9
|
import { result, pipe } from '@valbuild/core/fp';
|
|
10
|
-
import { Patch, Sketchpad, STAGED_SCHEMA_PREFIX, schemaErrorsOf, PatchSets, joinSharedChanges, schemaTypesOfPath, sideFiles, sideSource, rebaseContentOp, JSONValue, SketchpadSummary, PlanRefusalError, PatchId as PatchId$1, SerializedSchema, valModulesEntryPath,
|
|
10
|
+
import { Patch, Sketchpad, STAGED_SCHEMA_PREFIX, schemaErrorsOf, PatchSets, joinSharedChanges, schemaTypesOfPath, sideFiles, sideSource, rebaseContentOp, JSONValue, SketchpadSummary, getErrorMessageFromUnknownJson, PlanRefusalError, PatchId as PatchId$1, SerializedSchema, valModulesEntryPath, newestCommitSha, LOCAL_FILE_IN_REMOTE_PROJECT_WARNING, LOCAL_FILE_IN_REMOTE_PROJECT_HINT, traverseSchemaSource, richTextImageSchema, forEachRichTextImage, isStudioFix } from '@valbuild/shared/internal';
|
|
11
11
|
import os from 'os';
|
|
12
12
|
import crypto$1, { randomBytes, createHash } from 'crypto';
|
|
13
13
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
@@ -2171,7 +2171,7 @@ function createFsSketchpadStore(rootDir, now = () => new Date()) {
|
|
|
2171
2171
|
* as a bundler does.
|
|
2172
2172
|
*/
|
|
2173
2173
|
function loadTypeScriptKit() {
|
|
2174
|
-
return import('./publishKit-
|
|
2174
|
+
return import('./publishKit-af14cd7a.esm.js');
|
|
2175
2175
|
}
|
|
2176
2176
|
|
|
2177
2177
|
/** Serializes a schema, or gives up quietly — serialization errors are reported elsewhere. */
|
|
@@ -4880,7 +4880,7 @@ async function patchModuleText(text, patch) {
|
|
|
4880
4880
|
const {
|
|
4881
4881
|
tsOps,
|
|
4882
4882
|
parseValFile
|
|
4883
|
-
} = await import('./publishKit-
|
|
4883
|
+
} = await import('./publishKit-af14cd7a.esm.js');
|
|
4884
4884
|
const applied = applyPatch(parseValFile(text), tsOps, patch);
|
|
4885
4885
|
if (result.isErr(applied)) {
|
|
4886
4886
|
const reason = messagesOf(applied.error).join(" ");
|
|
@@ -4978,7 +4978,7 @@ async function jsonEntryFilesOf(moduleFilePath, text) {
|
|
|
4978
4978
|
parseValFile,
|
|
4979
4979
|
analyzeValModule,
|
|
4980
4980
|
analyzeJsonValuesEntries
|
|
4981
|
-
} = await import('./publishKit-
|
|
4981
|
+
} = await import('./publishKit-af14cd7a.esm.js');
|
|
4982
4982
|
try {
|
|
4983
4983
|
const analysis = analyzeValModule(parseValFile(text));
|
|
4984
4984
|
if (result.isErr(analysis)) return files;
|
|
@@ -5032,7 +5032,7 @@ async function stagedModuleSources(files) {
|
|
|
5032
5032
|
parseValFile,
|
|
5033
5033
|
analyzeValModule,
|
|
5034
5034
|
evaluateModuleSource
|
|
5035
|
-
} = await import('./publishKit-
|
|
5035
|
+
} = await import('./publishKit-af14cd7a.esm.js');
|
|
5036
5036
|
const sources = {};
|
|
5037
5037
|
for (const {
|
|
5038
5038
|
path,
|
|
@@ -5269,6 +5269,126 @@ function createHttpSketchpadStore(options) {
|
|
|
5269
5269
|
};
|
|
5270
5270
|
}
|
|
5271
5271
|
|
|
5272
|
+
/**
|
|
5273
|
+
* What to tell a person when the content service did not do what was asked.
|
|
5274
|
+
*
|
|
5275
|
+
* Written because the old sentences guessed, and guessed wrong. The patches
|
|
5276
|
+
* request answered "It is most likely due to a network issue. Check your
|
|
5277
|
+
* network connection" for ANY non-2xx answer -- including a 500 from a content
|
|
5278
|
+
* service whose database was missing a column, while the editor's network was
|
|
5279
|
+
* fine. A status code is an answer, and an answer means the network worked.
|
|
5280
|
+
*
|
|
5281
|
+
* So there are two shapes and they say different things:
|
|
5282
|
+
*
|
|
5283
|
+
* - **The service answered** with an error (`status`). It is named, the
|
|
5284
|
+
* sentence says it answered with an error or refused, and the status line
|
|
5285
|
+
* and the service's own words go in `details` for whoever has to report it.
|
|
5286
|
+
* - **The service could not be reached** (`unreachable`: `fetch` threw). That
|
|
5287
|
+
* IS a connection failure -- but between this site's server and the
|
|
5288
|
+
* service, not the editor's: the editor reached this server, or nothing
|
|
5289
|
+
* would have asked. So it never says "your connection" either.
|
|
5290
|
+
*
|
|
5291
|
+
* `retryable` is what decides whether a caller offers Try again: a 5xx, a
|
|
5292
|
+
* timeout or a service that could not be reached may well work the next time;
|
|
5293
|
+
* a 4xx is the same refusal again, and a button that leads to the same error
|
|
5294
|
+
* is worse than none.
|
|
5295
|
+
*/
|
|
5296
|
+
|
|
5297
|
+
/** Long enough for a database error, short enough for a dialog. */
|
|
5298
|
+
const MAX_BODY_LENGTH = 500;
|
|
5299
|
+
|
|
5300
|
+
/**
|
|
5301
|
+
* The content service, by a name a person would recognise.
|
|
5302
|
+
*
|
|
5303
|
+
* `content.val.build` is Val Build. Anything else -- a self-hosted engine, a
|
|
5304
|
+
* staging host, the e2e mock -- is named by its host, so the person can tell
|
|
5305
|
+
* WHICH service failed rather than being told "the server", which in a page
|
|
5306
|
+
* that is itself a server says nothing.
|
|
5307
|
+
*/
|
|
5308
|
+
function contentServiceName(contentUrl) {
|
|
5309
|
+
let host;
|
|
5310
|
+
try {
|
|
5311
|
+
host = new URL(contentUrl).host;
|
|
5312
|
+
} catch {
|
|
5313
|
+
return "the content service";
|
|
5314
|
+
}
|
|
5315
|
+
if (host === "val.build" || host.endsWith(".val.build")) {
|
|
5316
|
+
return "Val Build";
|
|
5317
|
+
}
|
|
5318
|
+
return `the content service at ${host}`;
|
|
5319
|
+
}
|
|
5320
|
+
|
|
5321
|
+
/**
|
|
5322
|
+
* The service answered `status`.
|
|
5323
|
+
*
|
|
5324
|
+
* `what` completes "could not ...": "load your changes", "save your change".
|
|
5325
|
+
* `body` is the raw response text; a JSON body is read the way the rest of
|
|
5326
|
+
* `ValOpsHttp` reads one, so `home`'s `{ message: "Internal Server Error",
|
|
5327
|
+
* details: "<the real cause>" }` keeps the real cause.
|
|
5328
|
+
*/
|
|
5329
|
+
function contentServiceAnswered(service, what, response) {
|
|
5330
|
+
const retryable = response.status >= 500 || response.status === 408 || response.status === 429;
|
|
5331
|
+
const Service = capitalize(service);
|
|
5332
|
+
const message = retryable ? `${Service} answered with an error, so Val could not ${what}.` : `${Service} refused to ${what}.`;
|
|
5333
|
+
const statusLine = `HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ""} from ${service}`;
|
|
5334
|
+
const said = bodyText(response.body);
|
|
5335
|
+
return {
|
|
5336
|
+
message,
|
|
5337
|
+
details: said === null ? statusLine : `${statusLine}: ${said}`,
|
|
5338
|
+
retryable
|
|
5339
|
+
};
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5342
|
+
/** `fetch` threw: the service was never heard from. */
|
|
5343
|
+
function contentServiceUnreachable(service, what, error) {
|
|
5344
|
+
return {
|
|
5345
|
+
message: `${capitalize(service)} could not be reached from this site's server, so Val could not ${what}.`,
|
|
5346
|
+
details: errorText(error),
|
|
5347
|
+
retryable: true
|
|
5348
|
+
};
|
|
5349
|
+
}
|
|
5350
|
+
function bodyText(body) {
|
|
5351
|
+
const trimmed = body.trim();
|
|
5352
|
+
if (trimmed === "") return null;
|
|
5353
|
+
let text = trimmed;
|
|
5354
|
+
try {
|
|
5355
|
+
const json = JSON.parse(trimmed);
|
|
5356
|
+
text = getErrorMessageFromUnknownJson(json, trimmed);
|
|
5357
|
+
} catch {
|
|
5358
|
+
// Not JSON: the text is what the service said.
|
|
5359
|
+
}
|
|
5360
|
+
return text.length <= MAX_BODY_LENGTH ? text : `${text.slice(0, MAX_BODY_LENGTH)}…`;
|
|
5361
|
+
}
|
|
5362
|
+
|
|
5363
|
+
/**
|
|
5364
|
+
* The reason a `fetch` threw, with its cause.
|
|
5365
|
+
*
|
|
5366
|
+
* Node's `fetch` throws `TypeError: fetch failed` and hides what failed in
|
|
5367
|
+
* `cause` (`ECONNREFUSED`, a DNS miss, a certificate), which is the half
|
|
5368
|
+
* support needs.
|
|
5369
|
+
*/
|
|
5370
|
+
function errorText(error) {
|
|
5371
|
+
if (!(error instanceof Error)) {
|
|
5372
|
+
return String(error);
|
|
5373
|
+
}
|
|
5374
|
+
const cause = error.cause;
|
|
5375
|
+
if (cause instanceof Error && cause.message !== error.message) {
|
|
5376
|
+
return `${error.message}: ${cause.message}`;
|
|
5377
|
+
}
|
|
5378
|
+
return error.message;
|
|
5379
|
+
}
|
|
5380
|
+
function capitalize(text) {
|
|
5381
|
+
return text.length === 0 ? text : text[0].toUpperCase() + text.slice(1);
|
|
5382
|
+
}
|
|
5383
|
+
|
|
5384
|
+
/**
|
|
5385
|
+
* One string, for the error shapes that carry only a `message`: the sentence
|
|
5386
|
+
* first, the evidence after it in brackets.
|
|
5387
|
+
*/
|
|
5388
|
+
function contentServiceFailureText(failure) {
|
|
5389
|
+
return `${failure.message} (${failure.details})`;
|
|
5390
|
+
}
|
|
5391
|
+
|
|
5272
5392
|
const textEncoder$2 = new TextEncoder();
|
|
5273
5393
|
|
|
5274
5394
|
/** The body of the content API's 403 for a write the project's plan refuses. */
|
|
@@ -7426,7 +7546,7 @@ class ValOpsHttp extends ValOps {
|
|
|
7426
7546
|
return {
|
|
7427
7547
|
status: "error",
|
|
7428
7548
|
error: {
|
|
7429
|
-
message:
|
|
7549
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "connect for live updates", e))
|
|
7430
7550
|
}
|
|
7431
7551
|
};
|
|
7432
7552
|
});
|
|
@@ -7692,7 +7812,12 @@ class ValOpsHttp extends ValOps {
|
|
|
7692
7812
|
}
|
|
7693
7813
|
};
|
|
7694
7814
|
}
|
|
7695
|
-
|
|
7815
|
+
const failure = contentServiceAnswered(contentServiceName(this.contentUrl), "load your changes", {
|
|
7816
|
+
status: patchesRes.status,
|
|
7817
|
+
statusText: patchesRes.statusText,
|
|
7818
|
+
body: await patchesRes.text().catch(() => "")
|
|
7819
|
+
});
|
|
7820
|
+
Internal.log.error(`Could not get patches. ${failure.message} ${failure.details}`);
|
|
7696
7821
|
if (patchesRes.status === 401) {
|
|
7697
7822
|
return {
|
|
7698
7823
|
patches,
|
|
@@ -7701,19 +7826,29 @@ class ValOpsHttp extends ValOps {
|
|
|
7701
7826
|
}
|
|
7702
7827
|
};
|
|
7703
7828
|
}
|
|
7829
|
+
/*
|
|
7830
|
+
* The service ANSWERED, so this is not a network problem -- it used to
|
|
7831
|
+
* say "most likely due to a network issue. Check your network
|
|
7832
|
+
* connection" about a 500, to an editor whose network was fine. What it
|
|
7833
|
+
* said goes in `details`. The Studio asks again on the next `/stat`,
|
|
7834
|
+
* which fails fast and is retried while the service is failing.
|
|
7835
|
+
*/
|
|
7704
7836
|
return {
|
|
7705
7837
|
patches,
|
|
7706
7838
|
error: {
|
|
7707
|
-
message:
|
|
7839
|
+
message: failure.message,
|
|
7840
|
+
details: failure.details
|
|
7708
7841
|
}
|
|
7709
7842
|
};
|
|
7710
7843
|
} catch (err) {
|
|
7711
|
-
|
|
7844
|
+
const failure = contentServiceUnreachable(contentServiceName(this.contentUrl), "load your changes", err);
|
|
7845
|
+
Internal.log.error(`Could not get patches. ${failure.message} ${failure.details}`);
|
|
7712
7846
|
return {
|
|
7713
7847
|
patches: [],
|
|
7714
7848
|
networkError: true,
|
|
7715
7849
|
error: {
|
|
7716
|
-
message:
|
|
7850
|
+
message: failure.message,
|
|
7851
|
+
details: failure.details
|
|
7717
7852
|
}
|
|
7718
7853
|
};
|
|
7719
7854
|
}
|
|
@@ -7747,7 +7882,6 @@ class ValOpsHttp extends ValOps {
|
|
|
7747
7882
|
coreVersion: Internal.VERSION.core
|
|
7748
7883
|
})
|
|
7749
7884
|
}).then(async res => {
|
|
7750
|
-
var _res$headers$get3;
|
|
7751
7885
|
if (res.ok) {
|
|
7752
7886
|
const parsed = SavePatchResponse.safeParse(await res.json());
|
|
7753
7887
|
if (parsed.success) {
|
|
@@ -7769,8 +7903,27 @@ class ValOpsHttp extends ValOps {
|
|
|
7769
7903
|
message: "Conflict: " + (await res.text())
|
|
7770
7904
|
});
|
|
7771
7905
|
}
|
|
7772
|
-
|
|
7773
|
-
|
|
7906
|
+
const body = await res.text();
|
|
7907
|
+
const failure = contentServiceAnswered(contentServiceName(this.contentUrl), "save your change", {
|
|
7908
|
+
status: res.status,
|
|
7909
|
+
statusText: res.statusText,
|
|
7910
|
+
body
|
|
7911
|
+
});
|
|
7912
|
+
if (failure.retryable) {
|
|
7913
|
+
/*
|
|
7914
|
+
* The SERVICE failed -- a 500 from a database missing a column was
|
|
7915
|
+
* the one that found this. It used to be an `other`, which the
|
|
7916
|
+
* Studio is told is a bad patch and drops: the field went back to
|
|
7917
|
+
* its old value and the status bar said "All changes saved".
|
|
7918
|
+
*/
|
|
7919
|
+
return result.err({
|
|
7920
|
+
errorType: "service-error",
|
|
7921
|
+
message: failure.message,
|
|
7922
|
+
details: failure.details
|
|
7923
|
+
});
|
|
7924
|
+
}
|
|
7925
|
+
const json = parseJsonOrNull(body);
|
|
7926
|
+
if (json !== null) {
|
|
7774
7927
|
const message = getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
7775
7928
|
/*
|
|
7776
7929
|
* Refused for the plan: the patch is fine, and the reason comes as
|
|
@@ -7795,12 +7948,14 @@ class ValOpsHttp extends ValOps {
|
|
|
7795
7948
|
}
|
|
7796
7949
|
return result.err({
|
|
7797
7950
|
errorType: "other",
|
|
7798
|
-
message:
|
|
7951
|
+
message: `${failure.message} ${failure.details}`
|
|
7799
7952
|
});
|
|
7800
7953
|
}).catch(e => {
|
|
7954
|
+
const failure = contentServiceUnreachable(contentServiceName(this.contentUrl), "save your change", e);
|
|
7801
7955
|
return result.err({
|
|
7802
|
-
errorType: "
|
|
7803
|
-
message:
|
|
7956
|
+
errorType: "service-error",
|
|
7957
|
+
message: failure.message,
|
|
7958
|
+
details: failure.details
|
|
7804
7959
|
});
|
|
7805
7960
|
});
|
|
7806
7961
|
}
|
|
@@ -7841,13 +7996,17 @@ class ValOpsHttp extends ValOps {
|
|
|
7841
7996
|
}
|
|
7842
7997
|
return {
|
|
7843
7998
|
error: {
|
|
7844
|
-
message: "
|
|
7999
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "save the file", {
|
|
8000
|
+
status: res.status,
|
|
8001
|
+
statusText: res.statusText,
|
|
8002
|
+
body: await res.text().catch(() => "")
|
|
8003
|
+
}))
|
|
7845
8004
|
}
|
|
7846
8005
|
};
|
|
7847
8006
|
}).catch(e => {
|
|
7848
8007
|
return {
|
|
7849
8008
|
error: {
|
|
7850
|
-
message:
|
|
8009
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "save the file", e))
|
|
7851
8010
|
}
|
|
7852
8011
|
};
|
|
7853
8012
|
});
|
|
@@ -7885,13 +8044,17 @@ class ValOpsHttp extends ValOps {
|
|
|
7885
8044
|
}
|
|
7886
8045
|
return {
|
|
7887
8046
|
error: {
|
|
7888
|
-
message:
|
|
8047
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "load the files", {
|
|
8048
|
+
status: res.status,
|
|
8049
|
+
statusText: res.statusText,
|
|
8050
|
+
body: await res.text().catch(() => "")
|
|
8051
|
+
}))
|
|
7889
8052
|
}
|
|
7890
8053
|
};
|
|
7891
8054
|
}).catch(e => {
|
|
7892
8055
|
return {
|
|
7893
8056
|
error: {
|
|
7894
|
-
message:
|
|
8057
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "load the files", e))
|
|
7895
8058
|
}
|
|
7896
8059
|
};
|
|
7897
8060
|
});
|
|
@@ -8037,14 +8200,18 @@ class ValOpsHttp extends ValOps {
|
|
|
8037
8200
|
}
|
|
8038
8201
|
return {
|
|
8039
8202
|
errors: [{
|
|
8040
|
-
message:
|
|
8203
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "read the file's details", {
|
|
8204
|
+
status: metadataRes.status,
|
|
8205
|
+
statusText: metadataRes.statusText,
|
|
8206
|
+
body: await metadataRes.text().catch(() => "")
|
|
8207
|
+
})),
|
|
8041
8208
|
filePath
|
|
8042
8209
|
}]
|
|
8043
8210
|
};
|
|
8044
8211
|
} catch (err) {
|
|
8045
8212
|
return {
|
|
8046
8213
|
errors: [{
|
|
8047
|
-
message:
|
|
8214
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "read the file's details", err))
|
|
8048
8215
|
}]
|
|
8049
8216
|
};
|
|
8050
8217
|
}
|
|
@@ -8109,13 +8276,17 @@ class ValOpsHttp extends ValOps {
|
|
|
8109
8276
|
}
|
|
8110
8277
|
return {
|
|
8111
8278
|
error: {
|
|
8112
|
-
message:
|
|
8279
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "discard the changes", {
|
|
8280
|
+
status: res.status,
|
|
8281
|
+
statusText: res.statusText,
|
|
8282
|
+
body: await res.text().catch(() => "")
|
|
8283
|
+
}))
|
|
8113
8284
|
}
|
|
8114
8285
|
};
|
|
8115
8286
|
}).catch(e => {
|
|
8116
8287
|
return {
|
|
8117
8288
|
error: {
|
|
8118
|
-
message:
|
|
8289
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "discard the changes", e))
|
|
8119
8290
|
}
|
|
8120
8291
|
};
|
|
8121
8292
|
});
|
|
@@ -8128,7 +8299,7 @@ class ValOpsHttp extends ValOps {
|
|
|
8128
8299
|
*/
|
|
8129
8300
|
intoProposal) {
|
|
8130
8301
|
try {
|
|
8131
|
-
var _this$proposal4
|
|
8302
|
+
var _this$proposal4;
|
|
8132
8303
|
/*
|
|
8133
8304
|
* A save in a proposal is a commit on the proposal's branch, at its own
|
|
8134
8305
|
* route: the site's `/commit` refuses a proposal's patches, which is
|
|
@@ -8222,34 +8393,37 @@ class ValOpsHttp extends ValOps {
|
|
|
8222
8393
|
}
|
|
8223
8394
|
};
|
|
8224
8395
|
}
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
isNotFastForward: true,
|
|
8232
|
-
error: {
|
|
8233
|
-
message: "Could not commit. Not a fast-forward commit"
|
|
8234
|
-
}
|
|
8235
|
-
};
|
|
8236
|
-
}
|
|
8237
|
-
const message = getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
8396
|
+
const body = await res.text().catch(() => "");
|
|
8397
|
+
const payload = parseJsonOrNull(body);
|
|
8398
|
+
const notFastForward = z.object({
|
|
8399
|
+
isNotFastForward: z.boolean().optional()
|
|
8400
|
+
}).safeParse(payload);
|
|
8401
|
+
if (notFastForward.success && notFastForward.data.isNotFastForward) {
|
|
8238
8402
|
return {
|
|
8403
|
+
isNotFastForward: true,
|
|
8239
8404
|
error: {
|
|
8240
|
-
message
|
|
8405
|
+
message: "Could not commit. Not a fast-forward commit"
|
|
8241
8406
|
}
|
|
8242
8407
|
};
|
|
8243
8408
|
}
|
|
8409
|
+
/*
|
|
8410
|
+
* The service's own words, read from the PAYLOAD. This used to hand
|
|
8411
|
+
* `getErrorMessageFromUnknownJson` the zod `safeParse` result, which
|
|
8412
|
+
* has no `message`, so every commit failure read "Unknown error".
|
|
8413
|
+
*/
|
|
8244
8414
|
return {
|
|
8245
8415
|
error: {
|
|
8246
|
-
message:
|
|
8416
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "publish", {
|
|
8417
|
+
status: res.status,
|
|
8418
|
+
statusText: res.statusText,
|
|
8419
|
+
body
|
|
8420
|
+
}))
|
|
8247
8421
|
}
|
|
8248
8422
|
};
|
|
8249
8423
|
} catch (err) {
|
|
8250
8424
|
return {
|
|
8251
8425
|
error: {
|
|
8252
|
-
message:
|
|
8426
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "publish", err))
|
|
8253
8427
|
}
|
|
8254
8428
|
};
|
|
8255
8429
|
}
|
|
@@ -8288,9 +8462,9 @@ class ValOpsHttp extends ValOps {
|
|
|
8288
8462
|
});
|
|
8289
8463
|
}
|
|
8290
8464
|
if (!res.ok) {
|
|
8291
|
-
var _res$headers$
|
|
8465
|
+
var _res$headers$get3;
|
|
8292
8466
|
let message = `${res.status} ${res.statusText}`;
|
|
8293
|
-
if ((_res$headers$
|
|
8467
|
+
if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
|
|
8294
8468
|
message = getErrorMessageFromUnknownJson(await res.json(), message);
|
|
8295
8469
|
}
|
|
8296
8470
|
// A 5xx from the service reading a record it says it has is a real
|