@valbuild/shared 0.91.3 → 0.92.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/LICENSE.md +7 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/internal/ApiRoutes.d.ts +344 -3047
- package/dist/declarations/src/internal/getErrorMessageFromUnknownJson.d.ts +2 -0
- package/dist/declarations/src/internal/index.d.ts +1 -0
- package/dist/declarations/src/internal/richtext/conversion/remirrorTypes.d.ts +96 -1078
- package/dist/declarations/src/internal/zod/Patch.d.ts +71 -9
- package/dist/declarations/src/internal/zod/ValCommit.d.ts +1 -17
- package/dist/declarations/src/internal/zod/ValDeployment.d.ts +1 -13
- package/dist/declarations/src/utils.d.ts +8 -0
- package/dist/utils-00f3e1df.esm.js +21 -0
- package/dist/utils-32bcaca2.cjs.prod.js +23 -0
- package/dist/utils-d3d8b4b5.cjs.dev.js +23 -0
- package/dist/valbuild-shared.cjs.dev.js +3 -0
- package/dist/valbuild-shared.cjs.prod.js +3 -0
- package/dist/valbuild-shared.esm.js +2 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +62 -38
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +62 -38
- package/internal/dist/valbuild-shared-internal.esm.js +62 -40
- package/package.json +13 -10
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JSONValue as JSONValueT, PatchJSON as PatchJSONT, PatchBlock as PatchBlockT, ParentRef as ParentRefT } from "@valbuild/core/patch";
|
|
2
2
|
import type { PatchId as PatchIdT } from "@valbuild/core";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export declare const PatchJSON: z.ZodType<PatchJSONT>;
|
|
5
5
|
export type PatchJSON = PatchJSONT;
|
|
6
|
-
export declare const Patch: z.
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export declare const Patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7
|
+
op: z.ZodLiteral<"add">;
|
|
8
|
+
path: z.ZodArray<z.ZodString>;
|
|
9
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
10
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11
|
+
op: z.ZodLiteral<"remove">;
|
|
12
|
+
path: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
13
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
14
|
+
op: z.ZodLiteral<"replace">;
|
|
15
|
+
path: z.ZodArray<z.ZodString>;
|
|
16
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
17
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
+
op: z.ZodLiteral<"move">;
|
|
19
|
+
from: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
20
|
+
path: z.ZodArray<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
22
|
+
op: z.ZodLiteral<"copy">;
|
|
23
|
+
from: z.ZodArray<z.ZodString>;
|
|
24
|
+
path: z.ZodArray<z.ZodString>;
|
|
25
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
26
|
+
op: z.ZodLiteral<"test">;
|
|
27
|
+
path: z.ZodArray<z.ZodString>;
|
|
28
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
29
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
30
|
+
op: z.ZodLiteral<"file">;
|
|
31
|
+
path: z.ZodArray<z.ZodString>;
|
|
32
|
+
filePath: z.ZodString;
|
|
33
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
34
|
+
remote: z.ZodBoolean;
|
|
35
|
+
nestedFilePath: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
metadata: z.ZodOptional<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
|
|
37
|
+
}, z.core.$strict>], "op">>;
|
|
38
|
+
export type Patch = z.infer<typeof Patch>;
|
|
39
|
+
export declare const PatchId: z.ZodString & z.ZodType<PatchIdT, string, z.core.$ZodTypeInternals<PatchIdT, string>>;
|
|
9
40
|
type ParentRefInput = {
|
|
10
41
|
type: "head";
|
|
11
42
|
headBaseSha: string;
|
|
@@ -13,11 +44,42 @@ type ParentRefInput = {
|
|
|
13
44
|
type: "patch";
|
|
14
45
|
patchId: string;
|
|
15
46
|
};
|
|
16
|
-
export declare const ParentRef: z.ZodType<ParentRefT,
|
|
47
|
+
export declare const ParentRef: z.ZodType<ParentRefT, ParentRefInput>;
|
|
17
48
|
export type ParentRef = ParentRefT;
|
|
18
|
-
export declare const PatchBlock: z.
|
|
19
|
-
patch:
|
|
20
|
-
|
|
21
|
-
|
|
49
|
+
export declare const PatchBlock: z.ZodObject<{
|
|
50
|
+
patch: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
51
|
+
op: z.ZodLiteral<"add">;
|
|
52
|
+
path: z.ZodArray<z.ZodString>;
|
|
53
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
op: z.ZodLiteral<"remove">;
|
|
56
|
+
path: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
op: z.ZodLiteral<"replace">;
|
|
59
|
+
path: z.ZodArray<z.ZodString>;
|
|
60
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
61
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
62
|
+
op: z.ZodLiteral<"move">;
|
|
63
|
+
from: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
64
|
+
path: z.ZodArray<z.ZodString>;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
op: z.ZodLiteral<"copy">;
|
|
67
|
+
from: z.ZodArray<z.ZodString>;
|
|
68
|
+
path: z.ZodArray<z.ZodString>;
|
|
69
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
+
op: z.ZodLiteral<"test">;
|
|
71
|
+
path: z.ZodArray<z.ZodString>;
|
|
72
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
73
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
74
|
+
op: z.ZodLiteral<"file">;
|
|
75
|
+
path: z.ZodArray<z.ZodString>;
|
|
76
|
+
filePath: z.ZodString;
|
|
77
|
+
value: z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>;
|
|
78
|
+
remote: z.ZodBoolean;
|
|
79
|
+
nestedFilePath: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
|
+
metadata: z.ZodOptional<z.ZodType<JSONValueT, unknown, z.core.$ZodTypeInternals<JSONValueT, unknown>>>;
|
|
81
|
+
}, z.core.$strict>], "op">>;
|
|
82
|
+
parentRef: z.ZodType<ParentRefT, ParentRefInput, z.core.$ZodTypeInternals<ParentRefT, ParentRefInput>>;
|
|
83
|
+
}, z.core.$strip>;
|
|
22
84
|
export type PatchBlock = PatchBlockT;
|
|
23
85
|
export {};
|
|
@@ -7,21 +7,5 @@ export declare const ValCommit: z.ZodObject<{
|
|
|
7
7
|
creator: z.ZodString;
|
|
8
8
|
createdAt: z.ZodString;
|
|
9
9
|
commitMessage: z.ZodNullable<z.ZodString>;
|
|
10
|
-
},
|
|
11
|
-
commitSha: string;
|
|
12
|
-
clientCommitSha: string;
|
|
13
|
-
parentCommitSha: string;
|
|
14
|
-
branch: string;
|
|
15
|
-
creator: string;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
commitMessage: string | null;
|
|
18
|
-
}, {
|
|
19
|
-
commitSha: string;
|
|
20
|
-
clientCommitSha: string;
|
|
21
|
-
parentCommitSha: string;
|
|
22
|
-
branch: string;
|
|
23
|
-
creator: string;
|
|
24
|
-
createdAt: string;
|
|
25
|
-
commitMessage: string | null;
|
|
26
|
-
}>;
|
|
10
|
+
}, z.core.$strip>;
|
|
27
11
|
export type ValCommit = z.infer<typeof ValCommit>;
|
|
@@ -5,17 +5,5 @@ export declare const ValDeployment: z.ZodObject<{
|
|
|
5
5
|
commitSha: z.ZodString;
|
|
6
6
|
updatedAt: z.ZodString;
|
|
7
7
|
createdAt: z.ZodString;
|
|
8
|
-
},
|
|
9
|
-
commitSha: string;
|
|
10
|
-
createdAt: string;
|
|
11
|
-
deploymentId: string;
|
|
12
|
-
deploymentState: string;
|
|
13
|
-
updatedAt: string;
|
|
14
|
-
}, {
|
|
15
|
-
commitSha: string;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
deploymentId: string;
|
|
18
|
-
deploymentState: string;
|
|
19
|
-
updatedAt: string;
|
|
20
|
-
}>;
|
|
8
|
+
}, z.core.$strip>;
|
|
21
9
|
export type ValDeployment = z.infer<typeof ValDeployment>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
3
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
4
|
+
*
|
|
5
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
6
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
7
|
+
*/
|
|
8
|
+
export declare function base64DataUrlToUint8Array(dataUrl: string): Uint8Array;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
3
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
4
|
+
*
|
|
5
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
6
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
7
|
+
*/
|
|
8
|
+
function base64DataUrlToUint8Array(dataUrl) {
|
|
9
|
+
// Extract the base64 string from the data URL (everything after the comma)
|
|
10
|
+
var base64String = dataUrl.split(",")[1];
|
|
11
|
+
// Decode base64 to binary string
|
|
12
|
+
var binaryString = atob(base64String);
|
|
13
|
+
// Convert binary string to Uint8Array
|
|
14
|
+
var binaryData = new Uint8Array(binaryString.length);
|
|
15
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
16
|
+
binaryData[i] = binaryString.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return binaryData;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { base64DataUrlToUint8Array as b };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
5
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
6
|
+
*
|
|
7
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
8
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
9
|
+
*/
|
|
10
|
+
function base64DataUrlToUint8Array(dataUrl) {
|
|
11
|
+
// Extract the base64 string from the data URL (everything after the comma)
|
|
12
|
+
var base64String = dataUrl.split(",")[1];
|
|
13
|
+
// Decode base64 to binary string
|
|
14
|
+
var binaryString = atob(base64String);
|
|
15
|
+
// Convert binary string to Uint8Array
|
|
16
|
+
var binaryData = new Uint8Array(binaryString.length);
|
|
17
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
18
|
+
binaryData[i] = binaryString.charCodeAt(i);
|
|
19
|
+
}
|
|
20
|
+
return binaryData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.base64DataUrlToUint8Array = base64DataUrlToUint8Array;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a base64 data URL to a Uint8Array.
|
|
5
|
+
* This is a browser-compatible replacement for Node.js Buffer.from().
|
|
6
|
+
*
|
|
7
|
+
* @param dataUrl - A data URL string (e.g., "data:image/png;base64,iVBORw0KG...")
|
|
8
|
+
* @returns A Uint8Array containing the decoded binary data
|
|
9
|
+
*/
|
|
10
|
+
function base64DataUrlToUint8Array(dataUrl) {
|
|
11
|
+
// Extract the base64 string from the data URL (everything after the comma)
|
|
12
|
+
var base64String = dataUrl.split(",")[1];
|
|
13
|
+
// Decode base64 to binary string
|
|
14
|
+
var binaryString = atob(base64String);
|
|
15
|
+
// Convert binary string to Uint8Array
|
|
16
|
+
var binaryData = new Uint8Array(binaryString.length);
|
|
17
|
+
for (var i = 0; i < binaryString.length; i++) {
|
|
18
|
+
binaryData[i] = binaryString.charCodeAt(i);
|
|
19
|
+
}
|
|
20
|
+
return binaryData;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.base64DataUrlToUint8Array = base64DataUrlToUint8Array;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var utils = require('./utils-d3d8b4b5.cjs.dev.js');
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Val React **shared** types and utils.
|
|
7
9
|
*
|
|
@@ -12,4 +14,5 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
14
|
*/
|
|
13
15
|
var index = {};
|
|
14
16
|
|
|
17
|
+
exports.base64DataUrlToUint8Array = utils.base64DataUrlToUint8Array;
|
|
15
18
|
exports["default"] = index;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var utils = require('./utils-32bcaca2.cjs.prod.js');
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Val React **shared** types and utils.
|
|
7
9
|
*
|
|
@@ -12,4 +14,5 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
14
|
*/
|
|
13
15
|
var index = {};
|
|
14
16
|
|
|
17
|
+
exports.base64DataUrlToUint8Array = utils.base64DataUrlToUint8Array;
|
|
15
18
|
exports["default"] = index;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@valbuild/core');
|
|
6
|
-
var
|
|
6
|
+
var utils = require('../../dist/utils-d3d8b4b5.cjs.dev.js');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var zodValidationError = require('zod-validation-error');
|
|
9
9
|
|
|
@@ -307,8 +307,8 @@ var convertToNumber = function convertToNumber(value) {
|
|
|
307
307
|
var textEncoder = new TextEncoder();
|
|
308
308
|
function convertImageNode(path, node, files, configDirectory, remoteOptions) {
|
|
309
309
|
if (node.attrs && node.attrs.src.startsWith("data:")) {
|
|
310
|
-
var binaryData =
|
|
311
|
-
var fullFileHash = core.Internal.getSHA256Hash(
|
|
310
|
+
var binaryData = utils.base64DataUrlToUint8Array(node.attrs.src);
|
|
311
|
+
var fullFileHash = core.Internal.getSHA256Hash(binaryData);
|
|
312
312
|
var mimeType = core.Internal.getMimeType(node.attrs.src);
|
|
313
313
|
if (mimeType === undefined) {
|
|
314
314
|
throw new Error("Could not detect Mime Type for image: ".concat(node.attrs.src));
|
|
@@ -906,14 +906,14 @@ function _asyncToGenerator(n) {
|
|
|
906
906
|
}
|
|
907
907
|
|
|
908
908
|
var JSONValue = zod.z.lazy(function () {
|
|
909
|
-
return zod.z.union([zod.z.string(), zod.z.number(), zod.z["boolean"](), zod.z["null"](), zod.z.array(JSONValue), zod.z.record(JSONValue)]);
|
|
909
|
+
return zod.z.union([zod.z.string(), zod.z.number(), zod.z["boolean"](), zod.z["null"](), zod.z.array(JSONValue), zod.z.record(zod.z.string(), JSONValue)]);
|
|
910
910
|
});
|
|
911
911
|
var FileOperation = function FileOperation(path) {
|
|
912
912
|
return zod.z.object({
|
|
913
913
|
op: zod.z.literal("file"),
|
|
914
914
|
path: path,
|
|
915
915
|
filePath: zod.z.string(),
|
|
916
|
-
value:
|
|
916
|
+
value: JSONValue,
|
|
917
917
|
remote: zod.z["boolean"](),
|
|
918
918
|
nestedFilePath: zod.z.array(zod.z.string()).optional(),
|
|
919
919
|
metadata: JSONValue.optional() // TODO: remove optional
|
|
@@ -954,6 +954,7 @@ var OperationJSON = zod.z.discriminatedUnion("op", [zod.z.object({
|
|
|
954
954
|
value: JSONValue
|
|
955
955
|
}).strict(), FileOperation(zod.z.string()).strict()]);
|
|
956
956
|
var PatchJSON = zod.z.array(OperationJSON);
|
|
957
|
+
var nonEmptyArray = zod.z.tuple([zod.z.string()], zod.z.string());
|
|
957
958
|
/**
|
|
958
959
|
* Raw JSON patch operation.
|
|
959
960
|
*/
|
|
@@ -963,14 +964,14 @@ var Operation = zod.z.discriminatedUnion("op", [zod.z.object({
|
|
|
963
964
|
value: JSONValue
|
|
964
965
|
}).strict(), zod.z.object({
|
|
965
966
|
op: zod.z.literal("remove"),
|
|
966
|
-
path:
|
|
967
|
+
path: nonEmptyArray
|
|
967
968
|
}).strict(), zod.z.object({
|
|
968
969
|
op: zod.z.literal("replace"),
|
|
969
970
|
path: zod.z.array(zod.z.string()),
|
|
970
971
|
value: JSONValue
|
|
971
972
|
}).strict(), zod.z.object({
|
|
972
973
|
op: zod.z.literal("move"),
|
|
973
|
-
from:
|
|
974
|
+
from: nonEmptyArray,
|
|
974
975
|
path: zod.z.array(zod.z.string())
|
|
975
976
|
}).strict(), zod.z.object({
|
|
976
977
|
op: zod.z.literal("copy"),
|
|
@@ -1035,7 +1036,7 @@ var SerializedNumberSchema = zod.z.object({
|
|
|
1035
1036
|
var SerializedObjectSchema = zod.z.lazy(function () {
|
|
1036
1037
|
return zod.z.object({
|
|
1037
1038
|
type: zod.z.literal("object"),
|
|
1038
|
-
items: zod.z.record(SerializedSchema),
|
|
1039
|
+
items: zod.z.record(zod.z.string(), SerializedSchema),
|
|
1039
1040
|
opt: zod.z["boolean"]()
|
|
1040
1041
|
});
|
|
1041
1042
|
});
|
|
@@ -1070,26 +1071,28 @@ var SerializedImageSchema = zod.z.object({
|
|
|
1070
1071
|
options: ImageOptions.optional(),
|
|
1071
1072
|
opt: zod.z["boolean"]()
|
|
1072
1073
|
});
|
|
1073
|
-
var RichTextOptions = zod.z.
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1074
|
+
var RichTextOptions = zod.z.lazy(function () {
|
|
1075
|
+
return zod.z.object({
|
|
1076
|
+
style: zod.z.object({
|
|
1077
|
+
bold: zod.z["boolean"]().optional(),
|
|
1078
|
+
italic: zod.z["boolean"]().optional(),
|
|
1079
|
+
lineThrough: zod.z["boolean"]().optional()
|
|
1080
|
+
}).optional(),
|
|
1081
|
+
block: zod.z.object({
|
|
1082
|
+
h1: zod.z["boolean"]().optional(),
|
|
1083
|
+
h2: zod.z["boolean"]().optional(),
|
|
1084
|
+
h3: zod.z["boolean"]().optional(),
|
|
1085
|
+
h4: zod.z["boolean"]().optional(),
|
|
1086
|
+
h5: zod.z["boolean"]().optional(),
|
|
1087
|
+
h6: zod.z["boolean"]().optional(),
|
|
1088
|
+
ul: zod.z["boolean"]().optional(),
|
|
1089
|
+
ol: zod.z["boolean"]().optional()
|
|
1090
|
+
}).optional(),
|
|
1091
|
+
inline: zod.z.object({
|
|
1092
|
+
a: zod.z.union([zod.z["boolean"](), SerializedRouteSchema, SerializedStringSchema]).optional(),
|
|
1093
|
+
img: zod.z.union([zod.z["boolean"](), SerializedImageSchema]).optional()
|
|
1094
|
+
}).optional()
|
|
1095
|
+
});
|
|
1093
1096
|
});
|
|
1094
1097
|
var SerializedRichTextSchema = zod.z.object({
|
|
1095
1098
|
type: zod.z.literal("richtext"),
|
|
@@ -1803,9 +1806,9 @@ var Api = {
|
|
|
1803
1806
|
schemaSha: zod.z.string(),
|
|
1804
1807
|
sourcesSha: zod.z.string(),
|
|
1805
1808
|
modules: zod.z.record(ModuleFilePath, zod.z.object({
|
|
1806
|
-
render: zod.z.any(),
|
|
1809
|
+
render: zod.z.any().optional(),
|
|
1807
1810
|
// TODO: improve this type
|
|
1808
|
-
source: zod.z.any(),
|
|
1811
|
+
source: zod.z.any().optional(),
|
|
1809
1812
|
//.optional(), // TODO: Json zod type
|
|
1810
1813
|
patches: zod.z.object({
|
|
1811
1814
|
applied: zod.z.array(PatchId),
|
|
@@ -1891,7 +1894,7 @@ var Api = {
|
|
|
1891
1894
|
message: zod.z.string(),
|
|
1892
1895
|
details: zod.z.union([zod.z.object({
|
|
1893
1896
|
sourceFilePatchErrors: zod.z.record(ModuleFilePath, zod.z.array(GenericError)),
|
|
1894
|
-
binaryFilePatchErrors: zod.z.record(GenericError)
|
|
1897
|
+
binaryFilePatchErrors: zod.z.record(zod.z.string(), GenericError)
|
|
1895
1898
|
}), zod.z.array(GenericError)]).optional()
|
|
1896
1899
|
}), zod.z.object({
|
|
1897
1900
|
message: zod.z.string(),
|
|
@@ -1945,6 +1948,24 @@ var Api = {
|
|
|
1945
1948
|
* Do not change this without updating the ValRouter query parsing logic
|
|
1946
1949
|
* */
|
|
1947
1950
|
|
|
1951
|
+
function _typeof(o) {
|
|
1952
|
+
"@babel/helpers - typeof";
|
|
1953
|
+
|
|
1954
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
1955
|
+
return typeof o;
|
|
1956
|
+
} : function (o) {
|
|
1957
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1958
|
+
}, _typeof(o);
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
function getErrorMessageFromUnknownJson(json, fallback) {
|
|
1962
|
+
if (_typeof(json) === "object" && json !== null && "message" in json && typeof json.message === "string") {
|
|
1963
|
+
return json.message;
|
|
1964
|
+
}
|
|
1965
|
+
return fallback;
|
|
1966
|
+
}
|
|
1967
|
+
var DEFAULT_ERROR_MESSAGE = "Unknown error with unknown message from server";
|
|
1968
|
+
|
|
1948
1969
|
var createValClient = function createValClient(host, config // We want to use this in the future
|
|
1949
1970
|
) {
|
|
1950
1971
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2029,7 +2050,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2029
2050
|
message: "There was an issue validating your data. This is most likely a Val bug.",
|
|
2030
2051
|
type: "client_side_validation_error",
|
|
2031
2052
|
details: {
|
|
2032
|
-
validationError: zodValidationError.
|
|
2053
|
+
validationError: zodValidationError.fromError(reqBodyResult.error).toString(),
|
|
2033
2054
|
data: anyReq.body
|
|
2034
2055
|
}
|
|
2035
2056
|
}
|
|
@@ -2046,7 +2067,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2046
2067
|
}).then(/*#__PURE__*/function () {
|
|
2047
2068
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(res) {
|
|
2048
2069
|
var _apiEndpoint$res;
|
|
2049
|
-
var contentTypeHeaders, json, valClientResult, responseResult;
|
|
2070
|
+
var contentTypeHeaders, json, valClientResult, message, responseResult;
|
|
2050
2071
|
return _regenerator().w(function (_context) {
|
|
2051
2072
|
while (1) switch (_context.n) {
|
|
2052
2073
|
case 0:
|
|
@@ -2096,12 +2117,13 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2096
2117
|
break;
|
|
2097
2118
|
}
|
|
2098
2119
|
console.error("Server responded with an error", json);
|
|
2120
|
+
message = getErrorMessageFromUnknownJson(json, "Unknown error");
|
|
2099
2121
|
return _context.a(2, {
|
|
2100
2122
|
status: 500,
|
|
2101
|
-
json:
|
|
2123
|
+
json: {
|
|
2102
2124
|
type: "unknown",
|
|
2103
|
-
message:
|
|
2104
|
-
}
|
|
2125
|
+
message: message
|
|
2126
|
+
}
|
|
2105
2127
|
});
|
|
2106
2128
|
case 4:
|
|
2107
2129
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
|
@@ -2115,7 +2137,7 @@ var createValClient = function createValClient(host, config // We want to use th
|
|
|
2115
2137
|
message: "Response could not be validated. This could also be a result of mismatched Val versions.",
|
|
2116
2138
|
type: "client_side_validation_error",
|
|
2117
2139
|
details: {
|
|
2118
|
-
validationError: zodValidationError.
|
|
2140
|
+
validationError: zodValidationError.fromError(responseResult.error).toString(),
|
|
2119
2141
|
data: valClientResult
|
|
2120
2142
|
}
|
|
2121
2143
|
}
|
|
@@ -2288,7 +2310,7 @@ function getNextAppRouterSitemapTree(srcFolder, paths) {
|
|
|
2288
2310
|
root.page = {
|
|
2289
2311
|
fullPath: fullPath
|
|
2290
2312
|
};
|
|
2291
|
-
root.sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, fullPath);
|
|
2313
|
+
root.sourcePath = core.Internal.joinModuleFilePathAndModulePath(moduleFilePath, "\"".concat(fullPath, "\""));
|
|
2292
2314
|
root.moduleFilePath = moduleFilePath;
|
|
2293
2315
|
return 0; // continue
|
|
2294
2316
|
}
|
|
@@ -2533,6 +2555,7 @@ function createRegExpFromPattern(pattern) {
|
|
|
2533
2555
|
}
|
|
2534
2556
|
|
|
2535
2557
|
exports.Api = Api;
|
|
2558
|
+
exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
|
|
2536
2559
|
exports.ParentRef = ParentRef$1;
|
|
2537
2560
|
exports.Patch = Patch;
|
|
2538
2561
|
exports.PatchBlock = PatchBlock;
|
|
@@ -2560,6 +2583,7 @@ exports.ValDeployment = ValDeployment;
|
|
|
2560
2583
|
exports.createRegExpFromPattern = createRegExpFromPattern;
|
|
2561
2584
|
exports.createValClient = createValClient;
|
|
2562
2585
|
exports.filterRoutesByPatterns = filterRoutesByPatterns;
|
|
2586
|
+
exports.getErrorMessageFromUnknownJson = getErrorMessageFromUnknownJson;
|
|
2563
2587
|
exports.getNextAppRouterSitemapTree = getNextAppRouterSitemapTree;
|
|
2564
2588
|
exports.getNextAppRouterSourceFolder = getNextAppRouterSourceFolder;
|
|
2565
2589
|
exports.getPatternFromModuleFilePath = getPatternFromModuleFilePath;
|