@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@valbuild/core');
|
|
4
4
|
var server = require('@valbuild/ui/server');
|
|
5
|
-
var ValRouterCore = require('./ValRouterCore-
|
|
5
|
+
var ValRouterCore = require('./ValRouterCore-a0ea46bf.cjs.prod.js');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var ts = require('typescript');
|
|
8
8
|
var z = require('zod');
|
|
@@ -2205,7 +2205,7 @@ function createFsSketchpadStore(rootDir, now = () => new Date()) {
|
|
|
2205
2205
|
* as a bundler does.
|
|
2206
2206
|
*/
|
|
2207
2207
|
function loadTypeScriptKit() {
|
|
2208
|
-
return Promise.resolve().then(function () { return require('./publishKit-
|
|
2208
|
+
return Promise.resolve().then(function () { return require('./publishKit-6e52ffa6.cjs.prod.js'); });
|
|
2209
2209
|
}
|
|
2210
2210
|
|
|
2211
2211
|
/** Serializes a schema, or gives up quietly — serialization errors are reported elsewhere. */
|
|
@@ -4914,7 +4914,7 @@ async function patchModuleText(text, patch$1) {
|
|
|
4914
4914
|
const {
|
|
4915
4915
|
tsOps,
|
|
4916
4916
|
parseValFile
|
|
4917
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
4917
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-6e52ffa6.cjs.prod.js'); });
|
|
4918
4918
|
const applied = patch.applyPatch(parseValFile(text), tsOps, patch$1);
|
|
4919
4919
|
if (fp.result.isErr(applied)) {
|
|
4920
4920
|
const reason = messagesOf(applied.error).join(" ");
|
|
@@ -5012,7 +5012,7 @@ async function jsonEntryFilesOf(moduleFilePath, text) {
|
|
|
5012
5012
|
parseValFile,
|
|
5013
5013
|
analyzeValModule,
|
|
5014
5014
|
analyzeJsonValuesEntries
|
|
5015
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
5015
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-6e52ffa6.cjs.prod.js'); });
|
|
5016
5016
|
try {
|
|
5017
5017
|
const analysis = analyzeValModule(parseValFile(text));
|
|
5018
5018
|
if (fp.result.isErr(analysis)) return files;
|
|
@@ -5066,7 +5066,7 @@ async function stagedModuleSources(files) {
|
|
|
5066
5066
|
parseValFile,
|
|
5067
5067
|
analyzeValModule,
|
|
5068
5068
|
evaluateModuleSource
|
|
5069
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
5069
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-6e52ffa6.cjs.prod.js'); });
|
|
5070
5070
|
const sources = {};
|
|
5071
5071
|
for (const {
|
|
5072
5072
|
path,
|
|
@@ -5303,6 +5303,126 @@ function createHttpSketchpadStore(options) {
|
|
|
5303
5303
|
};
|
|
5304
5304
|
}
|
|
5305
5305
|
|
|
5306
|
+
/**
|
|
5307
|
+
* What to tell a person when the content service did not do what was asked.
|
|
5308
|
+
*
|
|
5309
|
+
* Written because the old sentences guessed, and guessed wrong. The patches
|
|
5310
|
+
* request answered "It is most likely due to a network issue. Check your
|
|
5311
|
+
* network connection" for ANY non-2xx answer -- including a 500 from a content
|
|
5312
|
+
* service whose database was missing a column, while the editor's network was
|
|
5313
|
+
* fine. A status code is an answer, and an answer means the network worked.
|
|
5314
|
+
*
|
|
5315
|
+
* So there are two shapes and they say different things:
|
|
5316
|
+
*
|
|
5317
|
+
* - **The service answered** with an error (`status`). It is named, the
|
|
5318
|
+
* sentence says it answered with an error or refused, and the status line
|
|
5319
|
+
* and the service's own words go in `details` for whoever has to report it.
|
|
5320
|
+
* - **The service could not be reached** (`unreachable`: `fetch` threw). That
|
|
5321
|
+
* IS a connection failure -- but between this site's server and the
|
|
5322
|
+
* service, not the editor's: the editor reached this server, or nothing
|
|
5323
|
+
* would have asked. So it never says "your connection" either.
|
|
5324
|
+
*
|
|
5325
|
+
* `retryable` is what decides whether a caller offers Try again: a 5xx, a
|
|
5326
|
+
* timeout or a service that could not be reached may well work the next time;
|
|
5327
|
+
* a 4xx is the same refusal again, and a button that leads to the same error
|
|
5328
|
+
* is worse than none.
|
|
5329
|
+
*/
|
|
5330
|
+
|
|
5331
|
+
/** Long enough for a database error, short enough for a dialog. */
|
|
5332
|
+
const MAX_BODY_LENGTH = 500;
|
|
5333
|
+
|
|
5334
|
+
/**
|
|
5335
|
+
* The content service, by a name a person would recognise.
|
|
5336
|
+
*
|
|
5337
|
+
* `content.val.build` is Val Build. Anything else -- a self-hosted engine, a
|
|
5338
|
+
* staging host, the e2e mock -- is named by its host, so the person can tell
|
|
5339
|
+
* WHICH service failed rather than being told "the server", which in a page
|
|
5340
|
+
* that is itself a server says nothing.
|
|
5341
|
+
*/
|
|
5342
|
+
function contentServiceName(contentUrl) {
|
|
5343
|
+
let host;
|
|
5344
|
+
try {
|
|
5345
|
+
host = new URL(contentUrl).host;
|
|
5346
|
+
} catch {
|
|
5347
|
+
return "the content service";
|
|
5348
|
+
}
|
|
5349
|
+
if (host === "val.build" || host.endsWith(".val.build")) {
|
|
5350
|
+
return "Val Build";
|
|
5351
|
+
}
|
|
5352
|
+
return `the content service at ${host}`;
|
|
5353
|
+
}
|
|
5354
|
+
|
|
5355
|
+
/**
|
|
5356
|
+
* The service answered `status`.
|
|
5357
|
+
*
|
|
5358
|
+
* `what` completes "could not ...": "load your changes", "save your change".
|
|
5359
|
+
* `body` is the raw response text; a JSON body is read the way the rest of
|
|
5360
|
+
* `ValOpsHttp` reads one, so `home`'s `{ message: "Internal Server Error",
|
|
5361
|
+
* details: "<the real cause>" }` keeps the real cause.
|
|
5362
|
+
*/
|
|
5363
|
+
function contentServiceAnswered(service, what, response) {
|
|
5364
|
+
const retryable = response.status >= 500 || response.status === 408 || response.status === 429;
|
|
5365
|
+
const Service = capitalize(service);
|
|
5366
|
+
const message = retryable ? `${Service} answered with an error, so Val could not ${what}.` : `${Service} refused to ${what}.`;
|
|
5367
|
+
const statusLine = `HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ""} from ${service}`;
|
|
5368
|
+
const said = bodyText(response.body);
|
|
5369
|
+
return {
|
|
5370
|
+
message,
|
|
5371
|
+
details: said === null ? statusLine : `${statusLine}: ${said}`,
|
|
5372
|
+
retryable
|
|
5373
|
+
};
|
|
5374
|
+
}
|
|
5375
|
+
|
|
5376
|
+
/** `fetch` threw: the service was never heard from. */
|
|
5377
|
+
function contentServiceUnreachable(service, what, error) {
|
|
5378
|
+
return {
|
|
5379
|
+
message: `${capitalize(service)} could not be reached from this site's server, so Val could not ${what}.`,
|
|
5380
|
+
details: errorText(error),
|
|
5381
|
+
retryable: true
|
|
5382
|
+
};
|
|
5383
|
+
}
|
|
5384
|
+
function bodyText(body) {
|
|
5385
|
+
const trimmed = body.trim();
|
|
5386
|
+
if (trimmed === "") return null;
|
|
5387
|
+
let text = trimmed;
|
|
5388
|
+
try {
|
|
5389
|
+
const json = JSON.parse(trimmed);
|
|
5390
|
+
text = internal.getErrorMessageFromUnknownJson(json, trimmed);
|
|
5391
|
+
} catch {
|
|
5392
|
+
// Not JSON: the text is what the service said.
|
|
5393
|
+
}
|
|
5394
|
+
return text.length <= MAX_BODY_LENGTH ? text : `${text.slice(0, MAX_BODY_LENGTH)}…`;
|
|
5395
|
+
}
|
|
5396
|
+
|
|
5397
|
+
/**
|
|
5398
|
+
* The reason a `fetch` threw, with its cause.
|
|
5399
|
+
*
|
|
5400
|
+
* Node's `fetch` throws `TypeError: fetch failed` and hides what failed in
|
|
5401
|
+
* `cause` (`ECONNREFUSED`, a DNS miss, a certificate), which is the half
|
|
5402
|
+
* support needs.
|
|
5403
|
+
*/
|
|
5404
|
+
function errorText(error) {
|
|
5405
|
+
if (!(error instanceof Error)) {
|
|
5406
|
+
return String(error);
|
|
5407
|
+
}
|
|
5408
|
+
const cause = error.cause;
|
|
5409
|
+
if (cause instanceof Error && cause.message !== error.message) {
|
|
5410
|
+
return `${error.message}: ${cause.message}`;
|
|
5411
|
+
}
|
|
5412
|
+
return error.message;
|
|
5413
|
+
}
|
|
5414
|
+
function capitalize(text) {
|
|
5415
|
+
return text.length === 0 ? text : text[0].toUpperCase() + text.slice(1);
|
|
5416
|
+
}
|
|
5417
|
+
|
|
5418
|
+
/**
|
|
5419
|
+
* One string, for the error shapes that carry only a `message`: the sentence
|
|
5420
|
+
* first, the evidence after it in brackets.
|
|
5421
|
+
*/
|
|
5422
|
+
function contentServiceFailureText(failure) {
|
|
5423
|
+
return `${failure.message} (${failure.details})`;
|
|
5424
|
+
}
|
|
5425
|
+
|
|
5306
5426
|
const textEncoder$2 = new TextEncoder();
|
|
5307
5427
|
|
|
5308
5428
|
/** The body of the content API's 403 for a write the project's plan refuses. */
|
|
@@ -7460,7 +7580,7 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7460
7580
|
return {
|
|
7461
7581
|
status: "error",
|
|
7462
7582
|
error: {
|
|
7463
|
-
message:
|
|
7583
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "connect for live updates", e))
|
|
7464
7584
|
}
|
|
7465
7585
|
};
|
|
7466
7586
|
});
|
|
@@ -7726,7 +7846,12 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7726
7846
|
}
|
|
7727
7847
|
};
|
|
7728
7848
|
}
|
|
7729
|
-
|
|
7849
|
+
const failure = contentServiceAnswered(contentServiceName(this.contentUrl), "load your changes", {
|
|
7850
|
+
status: patchesRes.status,
|
|
7851
|
+
statusText: patchesRes.statusText,
|
|
7852
|
+
body: await patchesRes.text().catch(() => "")
|
|
7853
|
+
});
|
|
7854
|
+
core.Internal.log.error(`Could not get patches. ${failure.message} ${failure.details}`);
|
|
7730
7855
|
if (patchesRes.status === 401) {
|
|
7731
7856
|
return {
|
|
7732
7857
|
patches,
|
|
@@ -7735,19 +7860,29 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7735
7860
|
}
|
|
7736
7861
|
};
|
|
7737
7862
|
}
|
|
7863
|
+
/*
|
|
7864
|
+
* The service ANSWERED, so this is not a network problem -- it used to
|
|
7865
|
+
* say "most likely due to a network issue. Check your network
|
|
7866
|
+
* connection" about a 500, to an editor whose network was fine. What it
|
|
7867
|
+
* said goes in `details`. The Studio asks again on the next `/stat`,
|
|
7868
|
+
* which fails fast and is retried while the service is failing.
|
|
7869
|
+
*/
|
|
7738
7870
|
return {
|
|
7739
7871
|
patches,
|
|
7740
7872
|
error: {
|
|
7741
|
-
message:
|
|
7873
|
+
message: failure.message,
|
|
7874
|
+
details: failure.details
|
|
7742
7875
|
}
|
|
7743
7876
|
};
|
|
7744
7877
|
} catch (err) {
|
|
7745
|
-
|
|
7878
|
+
const failure = contentServiceUnreachable(contentServiceName(this.contentUrl), "load your changes", err);
|
|
7879
|
+
core.Internal.log.error(`Could not get patches. ${failure.message} ${failure.details}`);
|
|
7746
7880
|
return {
|
|
7747
7881
|
patches: [],
|
|
7748
7882
|
networkError: true,
|
|
7749
7883
|
error: {
|
|
7750
|
-
message:
|
|
7884
|
+
message: failure.message,
|
|
7885
|
+
details: failure.details
|
|
7751
7886
|
}
|
|
7752
7887
|
};
|
|
7753
7888
|
}
|
|
@@ -7781,7 +7916,6 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7781
7916
|
coreVersion: core.Internal.VERSION.core
|
|
7782
7917
|
})
|
|
7783
7918
|
}).then(async res => {
|
|
7784
|
-
var _res$headers$get3;
|
|
7785
7919
|
if (res.ok) {
|
|
7786
7920
|
const parsed = SavePatchResponse.safeParse(await res.json());
|
|
7787
7921
|
if (parsed.success) {
|
|
@@ -7803,8 +7937,27 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7803
7937
|
message: "Conflict: " + (await res.text())
|
|
7804
7938
|
});
|
|
7805
7939
|
}
|
|
7806
|
-
|
|
7807
|
-
|
|
7940
|
+
const body = await res.text();
|
|
7941
|
+
const failure = contentServiceAnswered(contentServiceName(this.contentUrl), "save your change", {
|
|
7942
|
+
status: res.status,
|
|
7943
|
+
statusText: res.statusText,
|
|
7944
|
+
body
|
|
7945
|
+
});
|
|
7946
|
+
if (failure.retryable) {
|
|
7947
|
+
/*
|
|
7948
|
+
* The SERVICE failed -- a 500 from a database missing a column was
|
|
7949
|
+
* the one that found this. It used to be an `other`, which the
|
|
7950
|
+
* Studio is told is a bad patch and drops: the field went back to
|
|
7951
|
+
* its old value and the status bar said "All changes saved".
|
|
7952
|
+
*/
|
|
7953
|
+
return fp.result.err({
|
|
7954
|
+
errorType: "service-error",
|
|
7955
|
+
message: failure.message,
|
|
7956
|
+
details: failure.details
|
|
7957
|
+
});
|
|
7958
|
+
}
|
|
7959
|
+
const json = parseJsonOrNull(body);
|
|
7960
|
+
if (json !== null) {
|
|
7808
7961
|
const message = internal.getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
7809
7962
|
/*
|
|
7810
7963
|
* Refused for the plan: the patch is fine, and the reason comes as
|
|
@@ -7829,12 +7982,14 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7829
7982
|
}
|
|
7830
7983
|
return fp.result.err({
|
|
7831
7984
|
errorType: "other",
|
|
7832
|
-
message:
|
|
7985
|
+
message: `${failure.message} ${failure.details}`
|
|
7833
7986
|
});
|
|
7834
7987
|
}).catch(e => {
|
|
7988
|
+
const failure = contentServiceUnreachable(contentServiceName(this.contentUrl), "save your change", e);
|
|
7835
7989
|
return fp.result.err({
|
|
7836
|
-
errorType: "
|
|
7837
|
-
message:
|
|
7990
|
+
errorType: "service-error",
|
|
7991
|
+
message: failure.message,
|
|
7992
|
+
details: failure.details
|
|
7838
7993
|
});
|
|
7839
7994
|
});
|
|
7840
7995
|
}
|
|
@@ -7875,13 +8030,17 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7875
8030
|
}
|
|
7876
8031
|
return {
|
|
7877
8032
|
error: {
|
|
7878
|
-
message: "
|
|
8033
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "save the file", {
|
|
8034
|
+
status: res.status,
|
|
8035
|
+
statusText: res.statusText,
|
|
8036
|
+
body: await res.text().catch(() => "")
|
|
8037
|
+
}))
|
|
7879
8038
|
}
|
|
7880
8039
|
};
|
|
7881
8040
|
}).catch(e => {
|
|
7882
8041
|
return {
|
|
7883
8042
|
error: {
|
|
7884
|
-
message:
|
|
8043
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "save the file", e))
|
|
7885
8044
|
}
|
|
7886
8045
|
};
|
|
7887
8046
|
});
|
|
@@ -7919,13 +8078,17 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
7919
8078
|
}
|
|
7920
8079
|
return {
|
|
7921
8080
|
error: {
|
|
7922
|
-
message:
|
|
8081
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "load the files", {
|
|
8082
|
+
status: res.status,
|
|
8083
|
+
statusText: res.statusText,
|
|
8084
|
+
body: await res.text().catch(() => "")
|
|
8085
|
+
}))
|
|
7923
8086
|
}
|
|
7924
8087
|
};
|
|
7925
8088
|
}).catch(e => {
|
|
7926
8089
|
return {
|
|
7927
8090
|
error: {
|
|
7928
|
-
message:
|
|
8091
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "load the files", e))
|
|
7929
8092
|
}
|
|
7930
8093
|
};
|
|
7931
8094
|
});
|
|
@@ -8071,14 +8234,18 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
8071
8234
|
}
|
|
8072
8235
|
return {
|
|
8073
8236
|
errors: [{
|
|
8074
|
-
message:
|
|
8237
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "read the file's details", {
|
|
8238
|
+
status: metadataRes.status,
|
|
8239
|
+
statusText: metadataRes.statusText,
|
|
8240
|
+
body: await metadataRes.text().catch(() => "")
|
|
8241
|
+
})),
|
|
8075
8242
|
filePath
|
|
8076
8243
|
}]
|
|
8077
8244
|
};
|
|
8078
8245
|
} catch (err) {
|
|
8079
8246
|
return {
|
|
8080
8247
|
errors: [{
|
|
8081
|
-
message:
|
|
8248
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "read the file's details", err))
|
|
8082
8249
|
}]
|
|
8083
8250
|
};
|
|
8084
8251
|
}
|
|
@@ -8143,13 +8310,17 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
8143
8310
|
}
|
|
8144
8311
|
return {
|
|
8145
8312
|
error: {
|
|
8146
|
-
message:
|
|
8313
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "discard the changes", {
|
|
8314
|
+
status: res.status,
|
|
8315
|
+
statusText: res.statusText,
|
|
8316
|
+
body: await res.text().catch(() => "")
|
|
8317
|
+
}))
|
|
8147
8318
|
}
|
|
8148
8319
|
};
|
|
8149
8320
|
}).catch(e => {
|
|
8150
8321
|
return {
|
|
8151
8322
|
error: {
|
|
8152
|
-
message:
|
|
8323
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "discard the changes", e))
|
|
8153
8324
|
}
|
|
8154
8325
|
};
|
|
8155
8326
|
});
|
|
@@ -8162,7 +8333,7 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
8162
8333
|
*/
|
|
8163
8334
|
intoProposal) {
|
|
8164
8335
|
try {
|
|
8165
|
-
var _this$proposal4
|
|
8336
|
+
var _this$proposal4;
|
|
8166
8337
|
/*
|
|
8167
8338
|
* A save in a proposal is a commit on the proposal's branch, at its own
|
|
8168
8339
|
* route: the site's `/commit` refuses a proposal's patches, which is
|
|
@@ -8256,34 +8427,37 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
8256
8427
|
}
|
|
8257
8428
|
};
|
|
8258
8429
|
}
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
isNotFastForward: true,
|
|
8266
|
-
error: {
|
|
8267
|
-
message: "Could not commit. Not a fast-forward commit"
|
|
8268
|
-
}
|
|
8269
|
-
};
|
|
8270
|
-
}
|
|
8271
|
-
const message = internal.getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
8430
|
+
const body = await res.text().catch(() => "");
|
|
8431
|
+
const payload = parseJsonOrNull(body);
|
|
8432
|
+
const notFastForward = z.z.object({
|
|
8433
|
+
isNotFastForward: z.z.boolean().optional()
|
|
8434
|
+
}).safeParse(payload);
|
|
8435
|
+
if (notFastForward.success && notFastForward.data.isNotFastForward) {
|
|
8272
8436
|
return {
|
|
8437
|
+
isNotFastForward: true,
|
|
8273
8438
|
error: {
|
|
8274
|
-
message
|
|
8439
|
+
message: "Could not commit. Not a fast-forward commit"
|
|
8275
8440
|
}
|
|
8276
8441
|
};
|
|
8277
8442
|
}
|
|
8443
|
+
/*
|
|
8444
|
+
* The service's own words, read from the PAYLOAD. This used to hand
|
|
8445
|
+
* `getErrorMessageFromUnknownJson` the zod `safeParse` result, which
|
|
8446
|
+
* has no `message`, so every commit failure read "Unknown error".
|
|
8447
|
+
*/
|
|
8278
8448
|
return {
|
|
8279
8449
|
error: {
|
|
8280
|
-
message:
|
|
8450
|
+
message: contentServiceFailureText(contentServiceAnswered(contentServiceName(this.contentUrl), "publish", {
|
|
8451
|
+
status: res.status,
|
|
8452
|
+
statusText: res.statusText,
|
|
8453
|
+
body
|
|
8454
|
+
}))
|
|
8281
8455
|
}
|
|
8282
8456
|
};
|
|
8283
8457
|
} catch (err) {
|
|
8284
8458
|
return {
|
|
8285
8459
|
error: {
|
|
8286
|
-
message:
|
|
8460
|
+
message: contentServiceFailureText(contentServiceUnreachable(contentServiceName(this.contentUrl), "publish", err))
|
|
8287
8461
|
}
|
|
8288
8462
|
};
|
|
8289
8463
|
}
|
|
@@ -8322,9 +8496,9 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
8322
8496
|
});
|
|
8323
8497
|
}
|
|
8324
8498
|
if (!res.ok) {
|
|
8325
|
-
var _res$headers$
|
|
8499
|
+
var _res$headers$get3;
|
|
8326
8500
|
let message = `${res.status} ${res.statusText}`;
|
|
8327
|
-
if ((_res$headers$
|
|
8501
|
+
if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
|
|
8328
8502
|
message = internal.getErrorMessageFromUnknownJson(await res.json(), message);
|
|
8329
8503
|
}
|
|
8330
8504
|
// A 5xx from the service reading a record it says it has is a real
|
|
@@ -5114,12 +5114,16 @@ class ValOps {
|
|
|
5114
5114
|
// sends it again later, so an error line here would be one a minute.
|
|
5115
5115
|
return fp.result.err(saveRes.error);
|
|
5116
5116
|
}
|
|
5117
|
-
core.Internal.log.error(`Could not save source patch at path: '${path}'. Error: ${saveRes.error.errorType === "other" ? saveRes.error.message : saveRes.error.errorType}`);
|
|
5117
|
+
core.Internal.log.error(`Could not save source patch at path: '${path}'. Error: ${saveRes.error.errorType === "other" ? saveRes.error.message : saveRes.error.errorType === "service-error" ? `${saveRes.error.message} (${saveRes.error.details})` : saveRes.error.errorType}`);
|
|
5118
5118
|
if (saveRes.error.errorType === "patch-head-conflict") {
|
|
5119
5119
|
return fp.result.err({
|
|
5120
5120
|
errorType: "patch-head-conflict"
|
|
5121
5121
|
});
|
|
5122
5122
|
}
|
|
5123
|
+
if (saveRes.error.errorType === "service-error") {
|
|
5124
|
+
// Not the patch's fault: the Studio keeps it and offers to retry.
|
|
5125
|
+
return fp.result.err(saveRes.error);
|
|
5126
|
+
}
|
|
5123
5127
|
return fp.result.err({
|
|
5124
5128
|
errorType: "other",
|
|
5125
5129
|
error: saveRes.error
|
|
@@ -5460,6 +5464,18 @@ function isFileSource(value) {
|
|
|
5460
5464
|
return typeof value === "object" && value !== null && "path" in value && typeof value.path === "string";
|
|
5461
5465
|
}
|
|
5462
5466
|
|
|
5467
|
+
/**
|
|
5468
|
+
* The content service failed to take the patch: it answered with a server
|
|
5469
|
+
* error, or could not be reached at all.
|
|
5470
|
+
*
|
|
5471
|
+
* Its own error rather than an `other`, for the same reason
|
|
5472
|
+
* {@link PlanRefusedError} is: an `other` becomes a 400, and the Studio drops a
|
|
5473
|
+
* patch it is told is bad -- the field reverts and the edit is gone. Nothing is
|
|
5474
|
+
* wrong with this patch. The service is, and the Studio keeps the edit and
|
|
5475
|
+
* offers to send it again. Only `retryable` failures are this; a 4xx from the
|
|
5476
|
+
* service is still a refusal of the patch.
|
|
5477
|
+
*/
|
|
5478
|
+
|
|
5463
5479
|
/**
|
|
5464
5480
|
* The content API refused a write for the project's plan (a 403 that says why
|
|
5465
5481
|
* as data), as opposed to refusing the patch.
|
|
@@ -6183,7 +6199,7 @@ var packageJson = {
|
|
|
6183
6199
|
],
|
|
6184
6200
|
exports: true
|
|
6185
6201
|
},
|
|
6186
|
-
version: "0.
|
|
6202
|
+
version: "0.152.0",
|
|
6187
6203
|
scripts: {
|
|
6188
6204
|
typecheck: "tsc --noEmit",
|
|
6189
6205
|
test: "jest",
|
|
@@ -8518,7 +8534,9 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
8518
8534
|
return {
|
|
8519
8535
|
status: 503,
|
|
8520
8536
|
json: {
|
|
8521
|
-
|
|
8537
|
+
// Which service could not be reached, rather than "Network
|
|
8538
|
+
// error": the editor reached THIS server, so it is not theirs.
|
|
8539
|
+
message: currentStat.error.message
|
|
8522
8540
|
}
|
|
8523
8541
|
};
|
|
8524
8542
|
}
|
|
@@ -9074,6 +9092,24 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
9074
9092
|
...savedSoFar()
|
|
9075
9093
|
}
|
|
9076
9094
|
};
|
|
9095
|
+
} else if (createPatchRes.error.errorType === "service-error") {
|
|
9096
|
+
/*
|
|
9097
|
+
* The content service failed, not the patch: a 502, never the
|
|
9098
|
+
* 400 below. A 400 tells the Studio the patch is bad, and it
|
|
9099
|
+
* drops it -- the editor's change reverted with nothing said
|
|
9100
|
+
* but "All changes saved". The patches before this one in the
|
|
9101
|
+
* batch ARE saved, and are reported as a 200 would report them,
|
|
9102
|
+
* so a retry sends only what is left.
|
|
9103
|
+
*/
|
|
9104
|
+
return {
|
|
9105
|
+
status: 502,
|
|
9106
|
+
json: {
|
|
9107
|
+
type: "service-error",
|
|
9108
|
+
message: createPatchRes.error.message,
|
|
9109
|
+
details: createPatchRes.error.details,
|
|
9110
|
+
...savedSoFar()
|
|
9111
|
+
}
|
|
9112
|
+
};
|
|
9077
9113
|
} else {
|
|
9078
9114
|
return {
|
|
9079
9115
|
status: 400,
|
|
@@ -9133,11 +9169,18 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
9133
9169
|
if (fetchedPatchesRes.error) {
|
|
9134
9170
|
// Error is singular
|
|
9135
9171
|
core.Internal.log.error("Failed to get patches", fetchedPatchesRes.error);
|
|
9172
|
+
const details = fetchedPatchesRes.error.details;
|
|
9136
9173
|
return {
|
|
9137
9174
|
status: 500,
|
|
9138
9175
|
json: {
|
|
9139
9176
|
message: fetchedPatchesRes.error.message,
|
|
9140
|
-
error:
|
|
9177
|
+
error: {
|
|
9178
|
+
message: fetchedPatchesRes.error.message
|
|
9179
|
+
},
|
|
9180
|
+
// What the content service said, for the Studio's "Details".
|
|
9181
|
+
...(typeof details === "string" ? {
|
|
9182
|
+
details
|
|
9183
|
+
} : {})
|
|
9141
9184
|
}
|
|
9142
9185
|
};
|
|
9143
9186
|
}
|
|
@@ -5108,12 +5108,16 @@ class ValOps {
|
|
|
5108
5108
|
// sends it again later, so an error line here would be one a minute.
|
|
5109
5109
|
return result.err(saveRes.error);
|
|
5110
5110
|
}
|
|
5111
|
-
Internal.log.error(`Could not save source patch at path: '${path}'. Error: ${saveRes.error.errorType === "other" ? saveRes.error.message : saveRes.error.errorType}`);
|
|
5111
|
+
Internal.log.error(`Could not save source patch at path: '${path}'. Error: ${saveRes.error.errorType === "other" ? saveRes.error.message : saveRes.error.errorType === "service-error" ? `${saveRes.error.message} (${saveRes.error.details})` : saveRes.error.errorType}`);
|
|
5112
5112
|
if (saveRes.error.errorType === "patch-head-conflict") {
|
|
5113
5113
|
return result.err({
|
|
5114
5114
|
errorType: "patch-head-conflict"
|
|
5115
5115
|
});
|
|
5116
5116
|
}
|
|
5117
|
+
if (saveRes.error.errorType === "service-error") {
|
|
5118
|
+
// Not the patch's fault: the Studio keeps it and offers to retry.
|
|
5119
|
+
return result.err(saveRes.error);
|
|
5120
|
+
}
|
|
5117
5121
|
return result.err({
|
|
5118
5122
|
errorType: "other",
|
|
5119
5123
|
error: saveRes.error
|
|
@@ -5454,6 +5458,18 @@ function isFileSource(value) {
|
|
|
5454
5458
|
return typeof value === "object" && value !== null && "path" in value && typeof value.path === "string";
|
|
5455
5459
|
}
|
|
5456
5460
|
|
|
5461
|
+
/**
|
|
5462
|
+
* The content service failed to take the patch: it answered with a server
|
|
5463
|
+
* error, or could not be reached at all.
|
|
5464
|
+
*
|
|
5465
|
+
* Its own error rather than an `other`, for the same reason
|
|
5466
|
+
* {@link PlanRefusedError} is: an `other` becomes a 400, and the Studio drops a
|
|
5467
|
+
* patch it is told is bad -- the field reverts and the edit is gone. Nothing is
|
|
5468
|
+
* wrong with this patch. The service is, and the Studio keeps the edit and
|
|
5469
|
+
* offers to send it again. Only `retryable` failures are this; a 4xx from the
|
|
5470
|
+
* service is still a refusal of the patch.
|
|
5471
|
+
*/
|
|
5472
|
+
|
|
5457
5473
|
/**
|
|
5458
5474
|
* The content API refused a write for the project's plan (a 403 that says why
|
|
5459
5475
|
* as data), as opposed to refusing the patch.
|
|
@@ -6177,7 +6193,7 @@ var packageJson = {
|
|
|
6177
6193
|
],
|
|
6178
6194
|
exports: true
|
|
6179
6195
|
},
|
|
6180
|
-
version: "0.
|
|
6196
|
+
version: "0.152.0",
|
|
6181
6197
|
scripts: {
|
|
6182
6198
|
typecheck: "tsc --noEmit",
|
|
6183
6199
|
test: "jest",
|
|
@@ -8512,7 +8528,9 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
8512
8528
|
return {
|
|
8513
8529
|
status: 503,
|
|
8514
8530
|
json: {
|
|
8515
|
-
|
|
8531
|
+
// Which service could not be reached, rather than "Network
|
|
8532
|
+
// error": the editor reached THIS server, so it is not theirs.
|
|
8533
|
+
message: currentStat.error.message
|
|
8516
8534
|
}
|
|
8517
8535
|
};
|
|
8518
8536
|
}
|
|
@@ -9068,6 +9086,24 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
9068
9086
|
...savedSoFar()
|
|
9069
9087
|
}
|
|
9070
9088
|
};
|
|
9089
|
+
} else if (createPatchRes.error.errorType === "service-error") {
|
|
9090
|
+
/*
|
|
9091
|
+
* The content service failed, not the patch: a 502, never the
|
|
9092
|
+
* 400 below. A 400 tells the Studio the patch is bad, and it
|
|
9093
|
+
* drops it -- the editor's change reverted with nothing said
|
|
9094
|
+
* but "All changes saved". The patches before this one in the
|
|
9095
|
+
* batch ARE saved, and are reported as a 200 would report them,
|
|
9096
|
+
* so a retry sends only what is left.
|
|
9097
|
+
*/
|
|
9098
|
+
return {
|
|
9099
|
+
status: 502,
|
|
9100
|
+
json: {
|
|
9101
|
+
type: "service-error",
|
|
9102
|
+
message: createPatchRes.error.message,
|
|
9103
|
+
details: createPatchRes.error.details,
|
|
9104
|
+
...savedSoFar()
|
|
9105
|
+
}
|
|
9106
|
+
};
|
|
9071
9107
|
} else {
|
|
9072
9108
|
return {
|
|
9073
9109
|
status: 400,
|
|
@@ -9127,11 +9163,18 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
9127
9163
|
if (fetchedPatchesRes.error) {
|
|
9128
9164
|
// Error is singular
|
|
9129
9165
|
Internal.log.error("Failed to get patches", fetchedPatchesRes.error);
|
|
9166
|
+
const details = fetchedPatchesRes.error.details;
|
|
9130
9167
|
return {
|
|
9131
9168
|
status: 500,
|
|
9132
9169
|
json: {
|
|
9133
9170
|
message: fetchedPatchesRes.error.message,
|
|
9134
|
-
error:
|
|
9171
|
+
error: {
|
|
9172
|
+
message: fetchedPatchesRes.error.message
|
|
9173
|
+
},
|
|
9174
|
+
// What the content service said, for the Studio's "Details".
|
|
9175
|
+
...(typeof details === "string" ? {
|
|
9176
|
+
details
|
|
9177
|
+
} : {})
|
|
9135
9178
|
}
|
|
9136
9179
|
};
|
|
9137
9180
|
}
|