@valbuild/shared 0.67.1 → 0.68.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/dist/declarations/src/internal/ApiRoutes.d.ts +564 -349
- package/dist/declarations/src/internal/index.d.ts +1 -1
- package/dist/declarations/src/internal/richtext/conversion/remirrorTypes.d.ts +336 -12
- package/dist/declarations/src/internal/zod/Patch.d.ts +23 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +223 -622
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +223 -622
- package/internal/dist/valbuild-shared-internal.esm.js +219 -622
- package/package.json +2 -2
- package/dist/declarations/src/internal/ValCache.d.ts +0 -49
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
5
5
|
var core = require('@valbuild/core');
|
6
6
|
var zod = require('zod');
|
7
|
-
var fp = require('@valbuild/core/fp');
|
8
7
|
var zodValidationError = require('zod-validation-error');
|
9
8
|
|
10
9
|
function _toPrimitive(t, r) {
|
@@ -721,46 +720,6 @@ var VAL_SESSION_COOKIE = core.Internal.VAL_SESSION_COOKIE;
|
|
721
720
|
var VAL_STATE_COOKIE = core.Internal.VAL_STATE_COOKIE;
|
722
721
|
var VAL_ENABLE_COOKIE_NAME = core.Internal.VAL_ENABLE_COOKIE_NAME;
|
723
722
|
|
724
|
-
function _arrayWithHoles(r) {
|
725
|
-
if (Array.isArray(r)) return r;
|
726
|
-
}
|
727
|
-
|
728
|
-
function _iterableToArrayLimit(r, l) {
|
729
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
730
|
-
if (null != t) {
|
731
|
-
var e,
|
732
|
-
n,
|
733
|
-
i,
|
734
|
-
u,
|
735
|
-
a = [],
|
736
|
-
f = !0,
|
737
|
-
o = !1;
|
738
|
-
try {
|
739
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
740
|
-
if (Object(t) !== t) return;
|
741
|
-
f = !1;
|
742
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
743
|
-
} catch (r) {
|
744
|
-
o = !0, n = r;
|
745
|
-
} finally {
|
746
|
-
try {
|
747
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
748
|
-
} finally {
|
749
|
-
if (o) throw n;
|
750
|
-
}
|
751
|
-
}
|
752
|
-
return a;
|
753
|
-
}
|
754
|
-
}
|
755
|
-
|
756
|
-
function _nonIterableRest() {
|
757
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
758
|
-
}
|
759
|
-
|
760
|
-
function _slicedToArray(r, e) {
|
761
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
762
|
-
}
|
763
|
-
|
764
723
|
function _regeneratorRuntime() {
|
765
724
|
_regeneratorRuntime = function () {
|
766
725
|
return e;
|
@@ -1089,522 +1048,52 @@ function _asyncToGenerator(n) {
|
|
1089
1048
|
};
|
1090
1049
|
}
|
1091
1050
|
|
1092
|
-
function _classCallCheck(a, n) {
|
1093
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
function _defineProperties(e, r) {
|
1097
|
-
for (var t = 0; t < r.length; t++) {
|
1098
|
-
var o = r[t];
|
1099
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
1100
|
-
}
|
1101
|
-
}
|
1102
|
-
function _createClass(e, r, t) {
|
1103
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
1104
|
-
writable: !1
|
1105
|
-
}), e;
|
1106
|
-
}
|
1107
|
-
|
1108
|
-
var ValCache = /*#__PURE__*/function () {
|
1109
|
-
function ValCache(client) {
|
1110
|
-
_classCallCheck(this, ValCache);
|
1111
|
-
this.client = client;
|
1112
|
-
this.drafts = {};
|
1113
|
-
this.schema = {};
|
1114
|
-
}
|
1115
|
-
return _createClass(ValCache, [{
|
1116
|
-
key: "reloadPaths",
|
1117
|
-
value: function () {
|
1118
|
-
var _reloadPaths = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(paths) {
|
1119
|
-
var patchesResponse, patches, filteredPatches, treeRes, data, _i, _Object$keys, _data$modules, pathS, path;
|
1120
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1121
|
-
while (1) switch (_context.prev = _context.next) {
|
1122
|
-
case 0:
|
1123
|
-
_context.next = 2;
|
1124
|
-
return this.client("/patches/~", "GET", {
|
1125
|
-
query: {
|
1126
|
-
omit_patch: true,
|
1127
|
-
author: [],
|
1128
|
-
patch_id: [],
|
1129
|
-
module_file_path: paths
|
1130
|
-
}
|
1131
|
-
});
|
1132
|
-
case 2:
|
1133
|
-
patchesResponse = _context.sent;
|
1134
|
-
if (!(patchesResponse.status !== 200)) {
|
1135
|
-
_context.next = 6;
|
1136
|
-
break;
|
1137
|
-
}
|
1138
|
-
console.error("Val: failed to get patches", patchesResponse.json.message, patchesResponse.json);
|
1139
|
-
return _context.abrupt("return");
|
1140
|
-
case 6:
|
1141
|
-
patches = patchesResponse.json;
|
1142
|
-
filteredPatches = Object.keys(patches);
|
1143
|
-
_context.next = 10;
|
1144
|
-
return this.client("/sources", "PUT", {
|
1145
|
-
query: {
|
1146
|
-
validate_sources: true,
|
1147
|
-
validate_all: false,
|
1148
|
-
validate_binary_files: false
|
1149
|
-
},
|
1150
|
-
path: undefined,
|
1151
|
-
body: {
|
1152
|
-
patchIds: filteredPatches
|
1153
|
-
}
|
1154
|
-
});
|
1155
|
-
case 10:
|
1156
|
-
treeRes = _context.sent;
|
1157
|
-
_context.next = 13;
|
1158
|
-
return this.initialize();
|
1159
|
-
case 13:
|
1160
|
-
if (treeRes.status === 200) {
|
1161
|
-
data = treeRes.json;
|
1162
|
-
for (_i = 0, _Object$keys = Object.keys(data.modules); _i < _Object$keys.length; _i++) {
|
1163
|
-
pathS = _Object$keys[_i];
|
1164
|
-
path = pathS;
|
1165
|
-
this.drafts[path] = data === null || data === void 0 || (_data$modules = data.modules) === null || _data$modules === void 0 || (_data$modules = _data$modules[path]) === null || _data$modules === void 0 ? void 0 : _data$modules.source;
|
1166
|
-
this.emitEvent(path, this.drafts[path]);
|
1167
|
-
}
|
1168
|
-
} else {
|
1169
|
-
console.error("Val: failed to reload paths", paths, treeRes.json);
|
1170
|
-
}
|
1171
|
-
case 14:
|
1172
|
-
case "end":
|
1173
|
-
return _context.stop();
|
1174
|
-
}
|
1175
|
-
}, _callee, this);
|
1176
|
-
}));
|
1177
|
-
function reloadPaths(_x) {
|
1178
|
-
return _reloadPaths.apply(this, arguments);
|
1179
|
-
}
|
1180
|
-
return reloadPaths;
|
1181
|
-
}()
|
1182
|
-
}, {
|
1183
|
-
key: "reset",
|
1184
|
-
value: function () {
|
1185
|
-
var _reset = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
1186
|
-
var patchesRes, allPatches, treeRes, initRes, _i2, _Object$keys2, _treeRes$json, pathS, path;
|
1187
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1188
|
-
while (1) switch (_context2.prev = _context2.next) {
|
1189
|
-
case 0:
|
1190
|
-
_context2.next = 2;
|
1191
|
-
return this.client("/patches/~", "GET", {
|
1192
|
-
query: {
|
1193
|
-
omit_patch: true,
|
1194
|
-
author: [],
|
1195
|
-
patch_id: [],
|
1196
|
-
module_file_path: []
|
1197
|
-
}
|
1198
|
-
});
|
1199
|
-
case 2:
|
1200
|
-
patchesRes = _context2.sent;
|
1201
|
-
if (!(patchesRes.status !== 200)) {
|
1202
|
-
_context2.next = 6;
|
1203
|
-
break;
|
1204
|
-
}
|
1205
|
-
console.error("Val: failed to get patches", patchesRes.json);
|
1206
|
-
return _context2.abrupt("return", fp.result.err({
|
1207
|
-
errorType: "other",
|
1208
|
-
message: "Failed to get patches"
|
1209
|
-
}));
|
1210
|
-
case 6:
|
1211
|
-
allPatches = Object.keys(patchesRes.json.patches);
|
1212
|
-
_context2.next = 9;
|
1213
|
-
return this.client("/sources", "PUT", {
|
1214
|
-
path: undefined,
|
1215
|
-
query: {
|
1216
|
-
validate_sources: false,
|
1217
|
-
validate_all: false,
|
1218
|
-
validate_binary_files: false
|
1219
|
-
},
|
1220
|
-
body: {
|
1221
|
-
patchIds: allPatches
|
1222
|
-
}
|
1223
|
-
});
|
1224
|
-
case 9:
|
1225
|
-
treeRes = _context2.sent;
|
1226
|
-
_context2.next = 12;
|
1227
|
-
return this.initialize();
|
1228
|
-
case 12:
|
1229
|
-
initRes = _context2.sent;
|
1230
|
-
if (!fp.result.isErr(initRes)) {
|
1231
|
-
_context2.next = 16;
|
1232
|
-
break;
|
1233
|
-
}
|
1234
|
-
console.error("Failed to initialize inside reset", initRes.error);
|
1235
|
-
return _context2.abrupt("return", fp.result.err({
|
1236
|
-
errorType: "other",
|
1237
|
-
message: initRes.error.message
|
1238
|
-
}));
|
1239
|
-
case 16:
|
1240
|
-
if (!(treeRes.status === 200)) {
|
1241
|
-
_context2.next = 21;
|
1242
|
-
break;
|
1243
|
-
}
|
1244
|
-
for (_i2 = 0, _Object$keys2 = Object.keys(treeRes.json.modules); _i2 < _Object$keys2.length; _i2++) {
|
1245
|
-
pathS = _Object$keys2[_i2];
|
1246
|
-
path = pathS;
|
1247
|
-
this.drafts[path] = (_treeRes$json = treeRes.json) === null || _treeRes$json === void 0 || (_treeRes$json = _treeRes$json.modules) === null || _treeRes$json === void 0 || (_treeRes$json = _treeRes$json[path]) === null || _treeRes$json === void 0 ? void 0 : _treeRes$json.source;
|
1248
|
-
this.emitEvent(path, this.drafts[path]);
|
1249
|
-
}
|
1250
|
-
return _context2.abrupt("return", fp.result.ok(undefined));
|
1251
|
-
case 21:
|
1252
|
-
if (!(treeRes.status === 400 && "type" in treeRes.json)) {
|
1253
|
-
_context2.next = 25;
|
1254
|
-
break;
|
1255
|
-
}
|
1256
|
-
return _context2.abrupt("return", fp.result.err({
|
1257
|
-
errorType: "patch-error",
|
1258
|
-
errors: Object.entries(treeRes.json.errors).flatMap(function (_ref) {
|
1259
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
1260
|
-
moduleFilePath = _ref2[0],
|
1261
|
-
value = _ref2[1];
|
1262
|
-
return (value !== null && value !== void 0 ? value : []).map(function (item) {
|
1263
|
-
return {
|
1264
|
-
moduleFilePath: moduleFilePath,
|
1265
|
-
patchError: item.error.message,
|
1266
|
-
patchId: item.patchId,
|
1267
|
-
skipped: item.skipped
|
1268
|
-
};
|
1269
|
-
});
|
1270
|
-
})
|
1271
|
-
}));
|
1272
|
-
case 25:
|
1273
|
-
console.error("Val: failed to reset", treeRes.json);
|
1274
|
-
return _context2.abrupt("return", fp.result.err({
|
1275
|
-
errorType: "other",
|
1276
|
-
message: "Failed to reset " + JSON.stringify(treeRes.json)
|
1277
|
-
}));
|
1278
|
-
case 27:
|
1279
|
-
case "end":
|
1280
|
-
return _context2.stop();
|
1281
|
-
}
|
1282
|
-
}, _callee2, this);
|
1283
|
-
}));
|
1284
|
-
function reset() {
|
1285
|
-
return _reset.apply(this, arguments);
|
1286
|
-
}
|
1287
|
-
return reset;
|
1288
|
-
}()
|
1289
|
-
}, {
|
1290
|
-
key: "getModule",
|
1291
|
-
value: function () {
|
1292
|
-
var _getModule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(path) {
|
1293
|
-
var refetch,
|
1294
|
-
treeRes,
|
1295
|
-
_treeRes$json2,
|
1296
|
-
_treeRes$json3,
|
1297
|
-
fetchedSource,
|
1298
|
-
schema,
|
1299
|
-
_args3 = arguments;
|
1300
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1301
|
-
while (1) switch (_context3.prev = _context3.next) {
|
1302
|
-
case 0:
|
1303
|
-
refetch = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
|
1304
|
-
if (!(!refetch && this.drafts[path] && this.schema[path])) {
|
1305
|
-
_context3.next = 3;
|
1306
|
-
break;
|
1307
|
-
}
|
1308
|
-
return _context3.abrupt("return", fp.result.ok({
|
1309
|
-
source: this.drafts[path],
|
1310
|
-
schema: this.schema[path]
|
1311
|
-
}));
|
1312
|
-
case 3:
|
1313
|
-
_context3.next = 5;
|
1314
|
-
return this.client("/sources", "PUT", {
|
1315
|
-
path: path,
|
1316
|
-
body: {},
|
1317
|
-
query: {
|
1318
|
-
validate_sources: false,
|
1319
|
-
validate_all: false,
|
1320
|
-
validate_binary_files: false
|
1321
|
-
}
|
1322
|
-
});
|
1323
|
-
case 5:
|
1324
|
-
treeRes = _context3.sent;
|
1325
|
-
if (!(treeRes.status === 200)) {
|
1326
|
-
_context3.next = 26;
|
1327
|
-
break;
|
1328
|
-
}
|
1329
|
-
if ((_treeRes$json2 = treeRes.json) !== null && _treeRes$json2 !== void 0 && (_treeRes$json2 = _treeRes$json2.modules) !== null && _treeRes$json2 !== void 0 && _treeRes$json2[path]) {
|
1330
|
-
_context3.next = 10;
|
1331
|
-
break;
|
1332
|
-
}
|
1333
|
-
console.error("Val: could not find the module", {
|
1334
|
-
moduleIds: Object.keys(treeRes.json.modules),
|
1335
|
-
moduleId: path,
|
1336
|
-
data: treeRes
|
1337
|
-
});
|
1338
|
-
return _context3.abrupt("return", fp.result.err({
|
1339
|
-
message: "Could not fetch data.\nCould not find the module:\n" + path + "\n\nVerify that the val.modules file includes this module."
|
1340
|
-
}));
|
1341
|
-
case 10:
|
1342
|
-
fetchedSource = (_treeRes$json3 = treeRes.json) === null || _treeRes$json3 === void 0 || (_treeRes$json3 = _treeRes$json3.modules) === null || _treeRes$json3 === void 0 || (_treeRes$json3 = _treeRes$json3[path]) === null || _treeRes$json3 === void 0 ? void 0 : _treeRes$json3.source;
|
1343
|
-
schema = this.schema[path];
|
1344
|
-
if (this.schema[path]) {
|
1345
|
-
_context3.next = 17;
|
1346
|
-
break;
|
1347
|
-
}
|
1348
|
-
_context3.next = 15;
|
1349
|
-
return this.initialize();
|
1350
|
-
case 15:
|
1351
|
-
if (this.schema[path]) {
|
1352
|
-
_context3.next = 17;
|
1353
|
-
break;
|
1354
|
-
}
|
1355
|
-
return _context3.abrupt("return", fp.result.err({
|
1356
|
-
message: "Path not found in schema. Verify that the module exists."
|
1357
|
-
}));
|
1358
|
-
case 17:
|
1359
|
-
if (!(fetchedSource !== undefined)) {
|
1360
|
-
_context3.next = 22;
|
1361
|
-
break;
|
1362
|
-
}
|
1363
|
-
this.drafts[path] = fetchedSource;
|
1364
|
-
return _context3.abrupt("return", fp.result.ok({
|
1365
|
-
source: fetchedSource,
|
1366
|
-
schema: schema
|
1367
|
-
}));
|
1368
|
-
case 22:
|
1369
|
-
console.error("Val: could not find the module source");
|
1370
|
-
return _context3.abrupt("return", fp.result.err({
|
1371
|
-
message: "Could not fetch data. Verify that the module exists."
|
1372
|
-
}));
|
1373
|
-
case 24:
|
1374
|
-
_context3.next = 33;
|
1375
|
-
break;
|
1376
|
-
case 26:
|
1377
|
-
if (!(treeRes.status === 504)) {
|
1378
|
-
_context3.next = 31;
|
1379
|
-
break;
|
1380
|
-
}
|
1381
|
-
console.error("Val: timeout", treeRes.json);
|
1382
|
-
return _context3.abrupt("return", fp.result.err({
|
1383
|
-
message: "Timed out while fetching data. Try again later."
|
1384
|
-
}));
|
1385
|
-
case 31:
|
1386
|
-
console.error("Val: failed to get module", treeRes.json);
|
1387
|
-
return _context3.abrupt("return", fp.result.err({
|
1388
|
-
message: "Could not fetch data. Verify that is correctly configured."
|
1389
|
-
}));
|
1390
|
-
case 33:
|
1391
|
-
case "end":
|
1392
|
-
return _context3.stop();
|
1393
|
-
}
|
1394
|
-
}, _callee3, this);
|
1395
|
-
}));
|
1396
|
-
function getModule(_x2) {
|
1397
|
-
return _getModule.apply(this, arguments);
|
1398
|
-
}
|
1399
|
-
return getModule;
|
1400
|
-
}()
|
1401
|
-
}, {
|
1402
|
-
key: "deletePatches",
|
1403
|
-
value: function () {
|
1404
|
-
var _deletePatches = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(patchIds) {
|
1405
|
-
var patchesRes;
|
1406
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
1407
|
-
while (1) switch (_context4.prev = _context4.next) {
|
1408
|
-
case 0:
|
1409
|
-
_context4.next = 2;
|
1410
|
-
return this.client("/patches/~", "DELETE", {
|
1411
|
-
query: {
|
1412
|
-
id: patchIds
|
1413
|
-
}
|
1414
|
-
});
|
1415
|
-
case 2:
|
1416
|
-
patchesRes = _context4.sent;
|
1417
|
-
if (!(patchesRes.status === 200)) {
|
1418
|
-
_context4.next = 7;
|
1419
|
-
break;
|
1420
|
-
}
|
1421
|
-
return _context4.abrupt("return", fp.result.ok(patchesRes.json));
|
1422
|
-
case 7:
|
1423
|
-
console.error("Val: failed to delete patches", patchesRes.json);
|
1424
|
-
return _context4.abrupt("return", fp.result.err({
|
1425
|
-
message: patchesRes.json.message
|
1426
|
-
}));
|
1427
|
-
case 9:
|
1428
|
-
case "end":
|
1429
|
-
return _context4.stop();
|
1430
|
-
}
|
1431
|
-
}, _callee4, this);
|
1432
|
-
}));
|
1433
|
-
function deletePatches(_x3) {
|
1434
|
-
return _deletePatches.apply(this, arguments);
|
1435
|
-
}
|
1436
|
-
return deletePatches;
|
1437
|
-
}()
|
1438
|
-
}, {
|
1439
|
-
key: "applyPatch",
|
1440
|
-
value: function () {
|
1441
|
-
var _applyPatch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(path, patchIds, patch) {
|
1442
|
-
var treeRes, _treeRes$json4, newPatchIds, newPatchId, fetchedSource, _treeRes$json5;
|
1443
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
1444
|
-
while (1) switch (_context5.prev = _context5.next) {
|
1445
|
-
case 0:
|
1446
|
-
_context5.next = 2;
|
1447
|
-
return this.client("/sources", "PUT", {
|
1448
|
-
path: path,
|
1449
|
-
query: {
|
1450
|
-
validate_sources: false,
|
1451
|
-
validate_all: false,
|
1452
|
-
validate_binary_files: false
|
1453
|
-
},
|
1454
|
-
body: {
|
1455
|
-
patchIds: patchIds,
|
1456
|
-
addPatches: [{
|
1457
|
-
path: path,
|
1458
|
-
patch: patch
|
1459
|
-
}]
|
1460
|
-
}
|
1461
|
-
});
|
1462
|
-
case 2:
|
1463
|
-
treeRes = _context5.sent;
|
1464
|
-
if (!(treeRes.status === 200)) {
|
1465
|
-
_context5.next = 20;
|
1466
|
-
break;
|
1467
|
-
}
|
1468
|
-
newPatchIds = treeRes.json.newPatchIds;
|
1469
|
-
if (newPatchIds) {
|
1470
|
-
_context5.next = 8;
|
1471
|
-
break;
|
1472
|
-
}
|
1473
|
-
console.error("Val: could create patch", treeRes);
|
1474
|
-
return _context5.abrupt("return", fp.result.err({
|
1475
|
-
errorType: "other",
|
1476
|
-
message: "Val: could not create patch"
|
1477
|
-
}));
|
1478
|
-
case 8:
|
1479
|
-
newPatchId = newPatchIds[0];
|
1480
|
-
fetchedSource = (_treeRes$json4 = treeRes.json) === null || _treeRes$json4 === void 0 || (_treeRes$json4 = _treeRes$json4.modules) === null || _treeRes$json4 === void 0 || (_treeRes$json4 = _treeRes$json4[path]) === null || _treeRes$json4 === void 0 ? void 0 : _treeRes$json4.source;
|
1481
|
-
if (!(fetchedSource !== undefined)) {
|
1482
|
-
_context5.next = 16;
|
1483
|
-
break;
|
1484
|
-
}
|
1485
|
-
this.drafts[path] = fetchedSource;
|
1486
|
-
this.emitEvent(path, fetchedSource);
|
1487
|
-
return _context5.abrupt("return", fp.result.ok({
|
1488
|
-
newPatchId: newPatchId,
|
1489
|
-
modules: _defineProperty({}, path, {
|
1490
|
-
patchIds: ((_treeRes$json5 = treeRes.json) === null || _treeRes$json5 === void 0 || (_treeRes$json5 = _treeRes$json5.modules) === null || _treeRes$json5 === void 0 || (_treeRes$json5 = _treeRes$json5[path]) === null || _treeRes$json5 === void 0 || (_treeRes$json5 = _treeRes$json5.patches) === null || _treeRes$json5 === void 0 ? void 0 : _treeRes$json5.applied) || []
|
1491
|
-
})
|
1492
|
-
}));
|
1493
|
-
case 16:
|
1494
|
-
console.error("Val: could not patch");
|
1495
|
-
return _context5.abrupt("return", fp.result.err({
|
1496
|
-
errorType: "other",
|
1497
|
-
message: "Val: could not fetch data. Verify that the module exists."
|
1498
|
-
}));
|
1499
|
-
case 18:
|
1500
|
-
_context5.next = 26;
|
1501
|
-
break;
|
1502
|
-
case 20:
|
1503
|
-
if (!(treeRes.status === 400 && "type" in treeRes.json)) {
|
1504
|
-
_context5.next = 24;
|
1505
|
-
break;
|
1506
|
-
}
|
1507
|
-
return _context5.abrupt("return", fp.result.err({
|
1508
|
-
errorType: "patch-error",
|
1509
|
-
errors: Object.entries(treeRes.json.errors).flatMap(function (_ref3) {
|
1510
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
1511
|
-
moduleFilePath = _ref4[0],
|
1512
|
-
value = _ref4[1];
|
1513
|
-
return (value !== null && value !== void 0 ? value : []).map(function (item) {
|
1514
|
-
return {
|
1515
|
-
moduleFilePath: moduleFilePath,
|
1516
|
-
patchError: item.error.message,
|
1517
|
-
patchId: item.patchId,
|
1518
|
-
skipped: item.skipped
|
1519
|
-
};
|
1520
|
-
});
|
1521
|
-
})
|
1522
|
-
}));
|
1523
|
-
case 24:
|
1524
|
-
console.error("Val: failed to get module", treeRes.json);
|
1525
|
-
return _context5.abrupt("return", fp.result.err({
|
1526
|
-
errorType: "other",
|
1527
|
-
message: "Val: could not fetch data. Verify that is correctly configured."
|
1528
|
-
}));
|
1529
|
-
case 26:
|
1530
|
-
case "end":
|
1531
|
-
return _context5.stop();
|
1532
|
-
}
|
1533
|
-
}, _callee5, this);
|
1534
|
-
}));
|
1535
|
-
function applyPatch(_x4, _x5, _x6) {
|
1536
|
-
return _applyPatch.apply(this, arguments);
|
1537
|
-
}
|
1538
|
-
return applyPatch;
|
1539
|
-
}()
|
1540
|
-
}, {
|
1541
|
-
key: "emitEvent",
|
1542
|
-
value: function emitEvent(path, source) {
|
1543
|
-
var event = new CustomEvent("val-event", {
|
1544
|
-
detail: {
|
1545
|
-
type: "module-update",
|
1546
|
-
path: path,
|
1547
|
-
source: source
|
1548
|
-
}
|
1549
|
-
});
|
1550
|
-
window.dispatchEvent(event);
|
1551
|
-
}
|
1552
|
-
}, {
|
1553
|
-
key: "initialize",
|
1554
|
-
value: function () {
|
1555
|
-
var _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
1556
|
-
var schemaRes, paths, _i3, _arr, moduleId, schema, msg;
|
1557
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
1558
|
-
while (1) switch (_context6.prev = _context6.next) {
|
1559
|
-
case 0:
|
1560
|
-
_context6.next = 2;
|
1561
|
-
return this.client("/schema", "GET", {});
|
1562
|
-
case 2:
|
1563
|
-
schemaRes = _context6.sent;
|
1564
|
-
if (!(schemaRes.status === 200)) {
|
1565
|
-
_context6.next = 9;
|
1566
|
-
break;
|
1567
|
-
}
|
1568
|
-
paths = [];
|
1569
|
-
for (_i3 = 0, _arr = Object.keys(schemaRes.json.schemas); _i3 < _arr.length; _i3++) {
|
1570
|
-
moduleId = _arr[_i3];
|
1571
|
-
schema = schemaRes.json.schemas[moduleId];
|
1572
|
-
if (schema) {
|
1573
|
-
paths.push(moduleId);
|
1574
|
-
this.schema[moduleId] = schema;
|
1575
|
-
}
|
1576
|
-
}
|
1577
|
-
return _context6.abrupt("return", fp.result.ok(paths));
|
1578
|
-
case 9:
|
1579
|
-
msg = "Failed to fetch content. ";
|
1580
|
-
if (schemaRes.status === 401) {
|
1581
|
-
msg += "Authorization failed - check that you are logged in.";
|
1582
|
-
} else {
|
1583
|
-
msg += "Get a developer to verify that is correctly setup.";
|
1584
|
-
}
|
1585
|
-
return _context6.abrupt("return", fp.result.err({
|
1586
|
-
message: msg,
|
1587
|
-
details: {
|
1588
|
-
fetchError: schemaRes.json
|
1589
|
-
}
|
1590
|
-
}));
|
1591
|
-
case 12:
|
1592
|
-
case "end":
|
1593
|
-
return _context6.stop();
|
1594
|
-
}
|
1595
|
-
}, _callee6, this);
|
1596
|
-
}));
|
1597
|
-
function initialize() {
|
1598
|
-
return _initialize.apply(this, arguments);
|
1599
|
-
}
|
1600
|
-
return initialize;
|
1601
|
-
}()
|
1602
|
-
}]);
|
1603
|
-
}();
|
1604
|
-
|
1605
1051
|
var JSONValueT = zod.z.lazy(function () {
|
1606
1052
|
return zod.z.union([zod.z.string(), zod.z.number(), zod.z["boolean"](), zod.z["null"](), zod.z.array(JSONValueT), zod.z.record(JSONValueT)]);
|
1607
1053
|
});
|
1054
|
+
|
1055
|
+
/**
|
1056
|
+
* Raw JSON patch operation.
|
1057
|
+
*/
|
1058
|
+
var OperationJSONT = zod.z.discriminatedUnion("op", [zod.z.object({
|
1059
|
+
op: zod.z.literal("add"),
|
1060
|
+
path: zod.z.string(),
|
1061
|
+
value: JSONValueT
|
1062
|
+
}).strict(), zod.z.object({
|
1063
|
+
op: zod.z.literal("remove"),
|
1064
|
+
/**
|
1065
|
+
* Must be non-root
|
1066
|
+
*/
|
1067
|
+
path: zod.z.string()
|
1068
|
+
}).strict(), zod.z.object({
|
1069
|
+
op: zod.z.literal("replace"),
|
1070
|
+
path: zod.z.string(),
|
1071
|
+
value: JSONValueT
|
1072
|
+
}).strict(), zod.z.object({
|
1073
|
+
op: zod.z.literal("move"),
|
1074
|
+
/**
|
1075
|
+
* Must be non-root and not a proper prefix of "path".
|
1076
|
+
*/
|
1077
|
+
from: zod.z.string(),
|
1078
|
+
path: zod.z.string()
|
1079
|
+
}).strict(), zod.z.object({
|
1080
|
+
op: zod.z.literal("copy"),
|
1081
|
+
from: zod.z.string(),
|
1082
|
+
path: zod.z.string()
|
1083
|
+
}).strict(), zod.z.object({
|
1084
|
+
op: zod.z.literal("test"),
|
1085
|
+
path: zod.z.string(),
|
1086
|
+
value: JSONValueT
|
1087
|
+
}).strict(), zod.z.object({
|
1088
|
+
op: zod.z.literal("file"),
|
1089
|
+
path: zod.z.string(),
|
1090
|
+
filePath: zod.z.string(),
|
1091
|
+
value: zod.z.string()
|
1092
|
+
}).strict()]);
|
1093
|
+
var PatchJSON = zod.z.array(OperationJSONT);
|
1094
|
+
/**
|
1095
|
+
* Raw JSON patch operation.
|
1096
|
+
*/
|
1608
1097
|
var OperationT = zod.z.discriminatedUnion("op", [zod.z.object({
|
1609
1098
|
op: zod.z.literal("add"),
|
1610
1099
|
path: zod.z.array(zod.z.string()),
|
@@ -1633,11 +1122,24 @@ var OperationT = zod.z.discriminatedUnion("op", [zod.z.object({
|
|
1633
1122
|
path: zod.z.array(zod.z.string()),
|
1634
1123
|
filePath: zod.z.string(),
|
1635
1124
|
nestedFilePath: zod.z.array(zod.z.string()).optional(),
|
1636
|
-
value: zod.z.
|
1637
|
-
sha256: zod.z.string()
|
1638
|
-
})])
|
1125
|
+
value: zod.z.string()
|
1639
1126
|
}).strict()]);
|
1640
1127
|
var Patch = zod.z.array(OperationT);
|
1128
|
+
var PatchId = zod.z.string().refine(function (_id) {
|
1129
|
+
return true;
|
1130
|
+
} // TODO: validation
|
1131
|
+
);
|
1132
|
+
var ParentRef$1 = zod.z.union([zod.z.object({
|
1133
|
+
type: zod.z.literal("head"),
|
1134
|
+
headBaseSha: zod.z.string()
|
1135
|
+
}), zod.z.object({
|
1136
|
+
type: zod.z.literal("patch"),
|
1137
|
+
patchId: PatchId
|
1138
|
+
})]);
|
1139
|
+
var PatchBlock = zod.z.object({
|
1140
|
+
patch: Patch,
|
1141
|
+
parentRef: ParentRef$1
|
1142
|
+
});
|
1641
1143
|
|
1642
1144
|
var SourcePath = zod.z.string().transform(function (path) {
|
1643
1145
|
return path;
|
@@ -1767,14 +1269,17 @@ var SerializedImageSchema = zod.z.object({
|
|
1767
1269
|
});
|
1768
1270
|
var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedUnionSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedFileSchema, SerializedDateSchema, SerializedImageSchema]);
|
1769
1271
|
|
1770
|
-
var PatchId = zod.z.string().refine(function (_id) {
|
1771
|
-
return true;
|
1772
|
-
} // TODO:
|
1773
|
-
);
|
1774
1272
|
var ModuleFilePath = zod.z.string().refine(function (_path) {
|
1775
1273
|
return true;
|
1776
|
-
} // TODO:
|
1274
|
+
} // TODO: validation
|
1777
1275
|
);
|
1276
|
+
var ParentRef = zod.z.union([zod.z.object({
|
1277
|
+
type: zod.z.literal("head"),
|
1278
|
+
headBaseSha: zod.z.string()
|
1279
|
+
}), zod.z.object({
|
1280
|
+
type: zod.z.literal("patch"),
|
1281
|
+
patchId: PatchId
|
1282
|
+
})]);
|
1778
1283
|
var ValConfig = zod.z.object({
|
1779
1284
|
project: zod.z.string().optional(),
|
1780
1285
|
root: zod.z.string().optional(),
|
@@ -1791,15 +1296,28 @@ var ValidationError = zod.z.object({
|
|
1791
1296
|
fatal: zod.z["boolean"]().optional(),
|
1792
1297
|
fixes: zod.z.array(ValidationFixZ).optional()
|
1793
1298
|
});
|
1794
|
-
var
|
1299
|
+
var unauthorizedResponse = zod.z.object({
|
1795
1300
|
status: zod.z.literal(401),
|
1796
1301
|
json: zod.z.object({
|
1797
1302
|
message: zod.z.string()
|
1798
1303
|
})
|
1799
1304
|
});
|
1305
|
+
var notFoundResponse = zod.z.object({
|
1306
|
+
status: zod.z.literal(404),
|
1307
|
+
json: zod.z.object({
|
1308
|
+
message: zod.z.string()
|
1309
|
+
})
|
1310
|
+
});
|
1800
1311
|
var GenericError = zod.z.object({
|
1801
1312
|
message: zod.z.string()
|
1802
1313
|
});
|
1314
|
+
var GenericPatchError = zod.z.union([zod.z.object({
|
1315
|
+
patchId: PatchId,
|
1316
|
+
message: zod.z.string()
|
1317
|
+
}), zod.z.object({
|
1318
|
+
parentPatchId: zod.z.string(),
|
1319
|
+
message: zod.z.string()
|
1320
|
+
})]);
|
1803
1321
|
var ModulesError = zod.z.object({
|
1804
1322
|
message: zod.z.string(),
|
1805
1323
|
path: ModuleFilePath.optional()
|
@@ -2080,7 +1598,7 @@ var Api = {
|
|
2080
1598
|
})])
|
2081
1599
|
}
|
2082
1600
|
},
|
2083
|
-
"/patches
|
1601
|
+
"/patches": {
|
2084
1602
|
DELETE: {
|
2085
1603
|
req: {
|
2086
1604
|
query: {
|
@@ -2090,17 +1608,54 @@ var Api = {
|
|
2090
1608
|
val_session: zod.z.string().optional()
|
2091
1609
|
}
|
2092
1610
|
},
|
2093
|
-
res: zod.z.union([
|
1611
|
+
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
2094
1612
|
status: zod.z.literal(500),
|
2095
1613
|
json: zod.z.object({
|
2096
1614
|
message: zod.z.string(),
|
2097
|
-
|
1615
|
+
errors: zod.z.array(GenericPatchError)
|
2098
1616
|
})
|
2099
1617
|
}), zod.z.object({
|
2100
1618
|
status: zod.z.literal(200),
|
2101
1619
|
json: zod.z.array(PatchId)
|
2102
1620
|
})])
|
2103
1621
|
},
|
1622
|
+
PUT: {
|
1623
|
+
req: {
|
1624
|
+
body: zod.z.object({
|
1625
|
+
parentRef: ParentRef,
|
1626
|
+
patches: zod.z.array(zod.z.object({
|
1627
|
+
path: ModuleFilePath,
|
1628
|
+
patch: Patch
|
1629
|
+
}))
|
1630
|
+
}),
|
1631
|
+
cookies: {
|
1632
|
+
val_session: zod.z.string().optional()
|
1633
|
+
}
|
1634
|
+
},
|
1635
|
+
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
1636
|
+
status: zod.z.literal(409),
|
1637
|
+
// conflict: i.e. not a head of patches
|
1638
|
+
json: zod.z.object({
|
1639
|
+
type: zod.z.literal("patch-head-conflict"),
|
1640
|
+
message: zod.z.string()
|
1641
|
+
})
|
1642
|
+
}), zod.z.object({
|
1643
|
+
status: zod.z.literal(400),
|
1644
|
+
json: zod.z.object({
|
1645
|
+
type: zod.z.literal("patch-error"),
|
1646
|
+
message: zod.z.string(),
|
1647
|
+
errors: zod.z.record(ModuleFilePath, zod.z.array(zod.z.object({
|
1648
|
+
error: GenericError
|
1649
|
+
})))
|
1650
|
+
})
|
1651
|
+
}), zod.z.object({
|
1652
|
+
status: zod.z.literal(200),
|
1653
|
+
json: zod.z.object({
|
1654
|
+
newPatchIds: zod.z.array(PatchId),
|
1655
|
+
parentRef: ParentRef
|
1656
|
+
})
|
1657
|
+
})])
|
1658
|
+
},
|
2104
1659
|
GET: {
|
2105
1660
|
req: {
|
2106
1661
|
query: {
|
@@ -2113,18 +1668,25 @@ var Api = {
|
|
2113
1668
|
val_session: zod.z.string().optional()
|
2114
1669
|
}
|
2115
1670
|
},
|
2116
|
-
res: zod.z.union([
|
1671
|
+
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
2117
1672
|
status: zod.z.literal(500),
|
2118
1673
|
json: zod.z.object({
|
2119
1674
|
message: zod.z.string(),
|
2120
|
-
|
1675
|
+
patchErrors: zod.z.array(GenericPatchError)
|
1676
|
+
})
|
1677
|
+
}), zod.z.object({
|
1678
|
+
status: zod.z.literal(500),
|
1679
|
+
json: zod.z.object({
|
1680
|
+
message: zod.z.string(),
|
1681
|
+
error: GenericError
|
2121
1682
|
})
|
2122
1683
|
}), zod.z.object({
|
2123
1684
|
status: zod.z.literal(200),
|
2124
1685
|
json: zod.z.object({
|
2125
|
-
patches: zod.z.
|
1686
|
+
patches: zod.z.array(zod.z.object({
|
2126
1687
|
path: ModuleFilePath,
|
2127
1688
|
patch: Patch.optional(),
|
1689
|
+
patchId: PatchId,
|
2128
1690
|
createdAt: zod.z.string(),
|
2129
1691
|
authorId: zod.z.string().nullable(),
|
2130
1692
|
appliedAt: zod.z.object({
|
@@ -2135,6 +1697,7 @@ var Api = {
|
|
2135
1697
|
timestamp: zod.z.string()
|
2136
1698
|
}).nullable()
|
2137
1699
|
})),
|
1700
|
+
baseSha: zod.z.string(),
|
2138
1701
|
error: GenericError.optional(),
|
2139
1702
|
errors: zod.z.record(PatchId, GenericError).optional()
|
2140
1703
|
})
|
@@ -2148,7 +1711,7 @@ var Api = {
|
|
2148
1711
|
val_session: zod.z.string().optional()
|
2149
1712
|
}
|
2150
1713
|
},
|
2151
|
-
res: zod.z.union([
|
1714
|
+
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
2152
1715
|
status: zod.z.literal(500),
|
2153
1716
|
json: zod.z.object({
|
2154
1717
|
message: zod.z.string(),
|
@@ -2169,16 +1732,12 @@ var Api = {
|
|
2169
1732
|
})])
|
2170
1733
|
}
|
2171
1734
|
},
|
2172
|
-
"/sources": {
|
1735
|
+
"/sources/~": {
|
2173
1736
|
PUT: {
|
2174
1737
|
req: {
|
2175
1738
|
path: zod.z.string().optional(),
|
2176
1739
|
body: zod.z.object({
|
2177
|
-
patchIds: zod.z.array(PatchId).optional()
|
2178
|
-
addPatches: zod.z.array(zod.z.object({
|
2179
|
-
path: ModuleFilePath,
|
2180
|
-
patch: Patch
|
2181
|
-
})).optional()
|
1740
|
+
patchIds: zod.z.array(PatchId).optional()
|
2182
1741
|
}).optional(),
|
2183
1742
|
query: {
|
2184
1743
|
validate_all: zod.z["boolean"]().optional(),
|
@@ -2189,13 +1748,9 @@ var Api = {
|
|
2189
1748
|
val_session: zod.z.string().optional()
|
2190
1749
|
}
|
2191
1750
|
},
|
2192
|
-
res: zod.z.union([
|
1751
|
+
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
2193
1752
|
status: zod.z.literal(401),
|
2194
1753
|
json: GenericError
|
2195
|
-
}), zod.z.object({
|
2196
|
-
status: zod.z.literal(409),
|
2197
|
-
// conflict: i.e. not a head of patches
|
2198
|
-
json: GenericError
|
2199
1754
|
}), zod.z.object({
|
2200
1755
|
status: zod.z.literal(500),
|
2201
1756
|
json: zod.z.object({
|
@@ -2203,32 +1758,15 @@ var Api = {
|
|
2203
1758
|
details: zod.z.union([zod.z.array(ModulesError), GenericError])
|
2204
1759
|
})
|
2205
1760
|
}), zod.z.object({
|
2206
|
-
status: zod.z.literal(
|
1761
|
+
status: zod.z.literal(409),
|
2207
1762
|
json: zod.z.object({
|
2208
|
-
message: zod.z.string()
|
2209
|
-
details: zod.z.array(ModulesError)
|
1763
|
+
message: zod.z.string()
|
2210
1764
|
})
|
2211
1765
|
}), zod.z.object({
|
2212
1766
|
status: zod.z.literal(400),
|
2213
1767
|
json: zod.z.object({
|
2214
|
-
type: zod.z.literal("patch-error"),
|
2215
1768
|
message: zod.z.string(),
|
2216
|
-
|
2217
|
-
modules: zod.z.record(ModuleFilePath, zod.z.object({
|
2218
|
-
source: zod.z.any(),
|
2219
|
-
//.optional(), // TODO: Json zod type
|
2220
|
-
patches: zod.z.object({
|
2221
|
-
applied: zod.z.array(PatchId),
|
2222
|
-
skipped: zod.z.array(PatchId).optional(),
|
2223
|
-
errors: zod.z.record(PatchId, GenericError).optional()
|
2224
|
-
}).optional(),
|
2225
|
-
validationErrors: zod.z.record(SourcePath, zod.z.array(ValidationError)).optional()
|
2226
|
-
})),
|
2227
|
-
errors: zod.z.record(ModuleFilePath, zod.z.array(zod.z.object({
|
2228
|
-
patchId: PatchId,
|
2229
|
-
skipped: zod.z["boolean"](),
|
2230
|
-
error: GenericError
|
2231
|
-
})))
|
1769
|
+
details: zod.z.array(ModulesError)
|
2232
1770
|
})
|
2233
1771
|
}), zod.z.object({
|
2234
1772
|
status: zod.z.literal(200),
|
@@ -2243,12 +1781,32 @@ var Api = {
|
|
2243
1781
|
errors: zod.z.record(PatchId, GenericError).optional()
|
2244
1782
|
}).optional(),
|
2245
1783
|
validationErrors: zod.z.record(SourcePath, zod.z.array(ValidationError)).optional()
|
2246
|
-
}))
|
2247
|
-
newPatchIds: zod.z.array(PatchId).optional()
|
1784
|
+
}))
|
2248
1785
|
})
|
2249
1786
|
})])
|
2250
1787
|
}
|
2251
1788
|
},
|
1789
|
+
"/profiles": {
|
1790
|
+
GET: {
|
1791
|
+
req: {
|
1792
|
+
cookies: {
|
1793
|
+
val_session: zod.z.string().optional()
|
1794
|
+
}
|
1795
|
+
},
|
1796
|
+
res: zod.z.object({
|
1797
|
+
status: zod.z.literal(200),
|
1798
|
+
json: zod.z.object({
|
1799
|
+
profiles: zod.z.array(zod.z.object({
|
1800
|
+
profileId: zod.z.string(),
|
1801
|
+
fullName: zod.z.string(),
|
1802
|
+
avatar: zod.z.object({
|
1803
|
+
url: zod.z.string()
|
1804
|
+
}).nullable()
|
1805
|
+
}))
|
1806
|
+
})
|
1807
|
+
})
|
1808
|
+
}
|
1809
|
+
},
|
2252
1810
|
"/save": {
|
2253
1811
|
POST: {
|
2254
1812
|
req: {
|
@@ -2259,7 +1817,7 @@ var Api = {
|
|
2259
1817
|
val_session: zod.z.string().optional()
|
2260
1818
|
}
|
2261
1819
|
},
|
2262
|
-
res: zod.z.union([
|
1820
|
+
res: zod.z.union([unauthorizedResponse, zod.z.object({
|
2263
1821
|
status: zod.z.literal(200),
|
2264
1822
|
json: zod.z.object({}) // TODO:
|
2265
1823
|
}), zod.z.object({
|
@@ -2288,14 +1846,9 @@ var Api = {
|
|
2288
1846
|
patch_id: PatchId.optional()
|
2289
1847
|
}
|
2290
1848
|
},
|
2291
|
-
res: zod.z.union([zod.z.object({
|
1849
|
+
res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
|
2292
1850
|
status: zod.z.literal(200),
|
2293
1851
|
body: zod.z["instanceof"](ReadableStream)
|
2294
|
-
}), zod.z.object({
|
2295
|
-
status: zod.z.literal(404),
|
2296
|
-
json: zod.z.object({
|
2297
|
-
message: zod.z.string()
|
2298
|
-
})
|
2299
1852
|
})])
|
2300
1853
|
}
|
2301
1854
|
}
|
@@ -2391,9 +1944,13 @@ var createValClient = function createValClient(host) {
|
|
2391
1944
|
case 7:
|
2392
1945
|
reqBodyResult = (_apiEndpoint$req$body = apiEndpoint.req.body) === null || _apiEndpoint$req$body === void 0 ? void 0 : _apiEndpoint$req$body.safeParse(anyReq.body);
|
2393
1946
|
if (!(reqBodyResult && !reqBodyResult.success)) {
|
2394
|
-
_context2.next =
|
1947
|
+
_context2.next = 11;
|
2395
1948
|
break;
|
2396
1949
|
}
|
1950
|
+
console.error("Invalid request body", {
|
1951
|
+
body: anyReq.body,
|
1952
|
+
error: reqBodyResult.error
|
1953
|
+
});
|
2397
1954
|
return _context2.abrupt("return", {
|
2398
1955
|
status: null,
|
2399
1956
|
json: {
|
@@ -2405,9 +1962,9 @@ var createValClient = function createValClient(host) {
|
|
2405
1962
|
}
|
2406
1963
|
}
|
2407
1964
|
});
|
2408
|
-
case
|
2409
|
-
_context2.prev =
|
2410
|
-
_context2.next =
|
1965
|
+
case 11:
|
1966
|
+
_context2.prev = 11;
|
1967
|
+
_context2.next = 14;
|
2411
1968
|
return fetch("".concat(host).concat(fullPath), {
|
2412
1969
|
method: method,
|
2413
1970
|
headers: {
|
@@ -2430,7 +1987,7 @@ var createValClient = function createValClient(host) {
|
|
2430
1987
|
status: null,
|
2431
1988
|
json: {
|
2432
1989
|
type: "client_side_validation_error",
|
2433
|
-
message: "Invalid
|
1990
|
+
message: "Invalid response (expected JSON, but got something else). This could be a result of mismatched Val versions or a transient error.",
|
2434
1991
|
details: {
|
2435
1992
|
validationError: "Invalid content type",
|
2436
1993
|
data: {
|
@@ -2493,12 +2050,12 @@ var createValClient = function createValClient(host) {
|
|
2493
2050
|
return _ref2.apply(this, arguments);
|
2494
2051
|
};
|
2495
2052
|
}());
|
2496
|
-
case
|
2053
|
+
case 14:
|
2497
2054
|
res = _context2.sent;
|
2498
2055
|
return _context2.abrupt("return", res);
|
2499
|
-
case
|
2500
|
-
_context2.prev =
|
2501
|
-
_context2.t0 = _context2["catch"](
|
2056
|
+
case 18:
|
2057
|
+
_context2.prev = 18;
|
2058
|
+
_context2.t0 = _context2["catch"](11);
|
2502
2059
|
return _context2.abrupt("return", {
|
2503
2060
|
status: null,
|
2504
2061
|
json: {
|
@@ -2508,11 +2065,11 @@ var createValClient = function createValClient(host) {
|
|
2508
2065
|
details: _context2.t0 instanceof Error ? _context2.t0.message : JSON.stringify(_context2.t0)
|
2509
2066
|
}
|
2510
2067
|
});
|
2511
|
-
case
|
2068
|
+
case 21:
|
2512
2069
|
case "end":
|
2513
2070
|
return _context2.stop();
|
2514
2071
|
}
|
2515
|
-
}, _callee2, null, [[
|
2072
|
+
}, _callee2, null, [[11, 18]]);
|
2516
2073
|
}));
|
2517
2074
|
return function (_x, _x2, _x3) {
|
2518
2075
|
return _ref.apply(this, arguments);
|
@@ -2534,6 +2091,46 @@ function isRetryable(error) {
|
|
2534
2091
|
return false;
|
2535
2092
|
}
|
2536
2093
|
|
2094
|
+
function _arrayWithHoles(r) {
|
2095
|
+
if (Array.isArray(r)) return r;
|
2096
|
+
}
|
2097
|
+
|
2098
|
+
function _iterableToArrayLimit(r, l) {
|
2099
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
2100
|
+
if (null != t) {
|
2101
|
+
var e,
|
2102
|
+
n,
|
2103
|
+
i,
|
2104
|
+
u,
|
2105
|
+
a = [],
|
2106
|
+
f = !0,
|
2107
|
+
o = !1;
|
2108
|
+
try {
|
2109
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
2110
|
+
if (Object(t) !== t) return;
|
2111
|
+
f = !1;
|
2112
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
2113
|
+
} catch (r) {
|
2114
|
+
o = !0, n = r;
|
2115
|
+
} finally {
|
2116
|
+
try {
|
2117
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
2118
|
+
} finally {
|
2119
|
+
if (o) throw n;
|
2120
|
+
}
|
2121
|
+
}
|
2122
|
+
return a;
|
2123
|
+
}
|
2124
|
+
}
|
2125
|
+
|
2126
|
+
function _nonIterableRest() {
|
2127
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
2128
|
+
}
|
2129
|
+
|
2130
|
+
function _slicedToArray(r, e) {
|
2131
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
2132
|
+
}
|
2133
|
+
|
2537
2134
|
var urlOf = function urlOf() {
|
2538
2135
|
var route = arguments.length <= 0 ? undefined : arguments[0];
|
2539
2136
|
var query = arguments.length <= 1 ? undefined : arguments[1];
|
@@ -2554,6 +2151,11 @@ var urlOf = function urlOf() {
|
|
2554
2151
|
};
|
2555
2152
|
|
2556
2153
|
exports.Api = Api;
|
2154
|
+
exports.ParentRef = ParentRef$1;
|
2155
|
+
exports.Patch = Patch;
|
2156
|
+
exports.PatchBlock = PatchBlock;
|
2157
|
+
exports.PatchId = PatchId;
|
2158
|
+
exports.PatchJSON = PatchJSON;
|
2557
2159
|
exports.RemirrorBr = RemirrorBr;
|
2558
2160
|
exports.RemirrorBulletList = RemirrorBulletList;
|
2559
2161
|
exports.RemirrorHeading = RemirrorHeading;
|
@@ -2568,7 +2170,6 @@ exports.RemirrorTextMark = RemirrorTextMark;
|
|
2568
2170
|
exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
|
2569
2171
|
exports.VAL_SESSION_COOKIE = VAL_SESSION_COOKIE;
|
2570
2172
|
exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
|
2571
|
-
exports.ValCache = ValCache;
|
2572
2173
|
exports.createValClient = createValClient;
|
2573
2174
|
exports.remirrorToRichTextSource = remirrorToRichTextSource;
|
2574
2175
|
exports.richTextToRemirror = richTextToRemirror;
|