@valbuild/core 0.97.1 → 0.97.4
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/initSchema.d.ts +1 -1
- package/dist/declarations/src/initVal.d.ts +1 -1
- package/dist/declarations/src/remote/splitRemoteRef.d.ts +1 -1
- package/dist/declarations/src/schema/images.d.ts +6 -2
- package/dist/declarations/src/schema/record.d.ts +2 -0
- package/dist/declarations/src/selector/file.d.ts +2 -2
- package/dist/declarations/src/source/file.d.ts +2 -2
- package/dist/declarations/src/source/image.d.ts +2 -2
- package/dist/declarations/src/source/remote.d.ts +2 -2
- package/dist/{index-4da4ac5a.cjs.prod.js → index-30ac56b6.cjs.prod.js} +38 -7
- package/dist/{index-8c26d8f4.esm.js → index-6aa8e224.esm.js} +38 -7
- package/dist/{index-039896b7.cjs.dev.js → index-a169d6a7.cjs.dev.js} +38 -7
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
|
@@ -285,7 +285,7 @@ export declare function initSchema(): {
|
|
|
285
285
|
datetime: (options?: Record<string, never>) => import("./schema/datetime.js").DateTimeSchema<import("./schema/string.js").RawString>;
|
|
286
286
|
route: <T extends string>(options?: Record<string, never>) => import("./schema/route.js").RouteSchema<T>;
|
|
287
287
|
router: typeof router;
|
|
288
|
-
images: <Accept extends `image/${string}`>(options
|
|
288
|
+
images: <Accept extends `image/${string}`>(options?: import("./schema/images.js").ImagesOptions<Accept>) => import("./schema/record.js").RecordSchema<import("./schema/object.js").ObjectSchema<{
|
|
289
289
|
width: import("./schema/number.js").NumberSchema<number>;
|
|
290
290
|
height: import("./schema/number.js").NumberSchema<number>;
|
|
291
291
|
mimeType: import("./schema/string.js").StringSchema<string>;
|
|
@@ -13,7 +13,7 @@ export type ContentConstructor = {
|
|
|
13
13
|
export type ValConstructor = {
|
|
14
14
|
unstable_getPath: typeof getPath;
|
|
15
15
|
};
|
|
16
|
-
export type ConfigDirectory = `/public
|
|
16
|
+
export type ConfigDirectory = `/public` | `/public/${string}`;
|
|
17
17
|
export type ValConfig = {
|
|
18
18
|
project?: string;
|
|
19
19
|
root?: string;
|
|
@@ -14,8 +14,9 @@ export type AltSchema = StringSchema<string> | StringSchema<string | null> | Rec
|
|
|
14
14
|
export type ImagesOptions<Accept extends `image/${string}`> = {
|
|
15
15
|
/**
|
|
16
16
|
* The accepted mime type pattern. Must be an image type (e.g., "image/png", "image/webp", "image/*")
|
|
17
|
+
* @default "image/*"
|
|
17
18
|
*/
|
|
18
|
-
accept
|
|
19
|
+
accept?: Accept;
|
|
19
20
|
/**
|
|
20
21
|
* The directory where images should be stored.
|
|
21
22
|
* Must start with "/public" (e.g., "/public/val/images")
|
|
@@ -64,6 +65,9 @@ type ImagesItemSrc = {
|
|
|
64
65
|
/**
|
|
65
66
|
* Define a collection of images.
|
|
66
67
|
*
|
|
68
|
+
* All options are optional: `s.images()` accepts any image type (`"image/*"`) in
|
|
69
|
+
* the default `/public/val` directory, with nullable alt text and remote disabled.
|
|
70
|
+
*
|
|
67
71
|
* @example
|
|
68
72
|
* ```typescript
|
|
69
73
|
* const schema = s.images({
|
|
@@ -81,5 +85,5 @@ type ImagesItemSrc = {
|
|
|
81
85
|
* });
|
|
82
86
|
* ```
|
|
83
87
|
*/
|
|
84
|
-
export declare const images: <Accept extends `image/${string}`>(options
|
|
88
|
+
export declare const images: <Accept extends `image/${string}`>(options?: ImagesOptions<Accept>) => RecordSchema<ObjectSchema<ImagesItemProps, ImagesItemSrc>, Schema<string>, Record<string, ImagesEntryMetadata>>;
|
|
85
89
|
export {};
|
|
@@ -45,6 +45,8 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Sc
|
|
|
45
45
|
validate(validationFunction: (src: Src) => false | string): RecordSchema<T, K, Src>;
|
|
46
46
|
protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
|
|
47
47
|
private isRemoteUrl;
|
|
48
|
+
/** Marks the validation errors reported at `path` as key errors (in place). */
|
|
49
|
+
private markKeyErrorsAtPath;
|
|
48
50
|
private validateMediaKey;
|
|
49
51
|
private validateMediaEntry;
|
|
50
52
|
private validateMediaMimeType;
|
|
@@ -5,6 +5,6 @@ export type FileSelector<Metadata extends FileMetadata | undefined> = GenericSel
|
|
|
5
5
|
url: string;
|
|
6
6
|
}> & {
|
|
7
7
|
readonly url: UnknownSelector<string>;
|
|
8
|
-
} & Metadata extends undefined ? {} : Metadata extends Source ? {
|
|
8
|
+
} & (Metadata extends undefined ? {} : Metadata extends Source ? {
|
|
9
9
|
readonly metadata: UnknownSelector<Metadata>;
|
|
10
|
-
} : {};
|
|
10
|
+
} : {});
|
|
@@ -22,7 +22,7 @@ export type FileSource<Metadata extends FileMetadata | undefined = FileMetadata
|
|
|
22
22
|
export declare const initFile: (config?: ValConfig) => {
|
|
23
23
|
<Metadata extends {
|
|
24
24
|
readonly [key: string]: Json;
|
|
25
|
-
}>(ref: `${"
|
|
26
|
-
(ref: `${"
|
|
25
|
+
}>(ref: `${import("../initVal.js").ConfigDirectory}/${string}`, metadata: Metadata): FileSource<Metadata>;
|
|
26
|
+
(ref: `${import("../initVal.js").ConfigDirectory}/${string}`, metadata?: undefined): FileSource<undefined>;
|
|
27
27
|
};
|
|
28
28
|
export declare function isFile(obj: unknown): obj is FileSource;
|
|
@@ -14,6 +14,6 @@ export type ImageSource<Metadata extends ImageMetadata | undefined = ImageMetada
|
|
|
14
14
|
readonly patch_id?: string;
|
|
15
15
|
};
|
|
16
16
|
export declare const initImage: (config?: ValConfig) => {
|
|
17
|
-
(ref: `${"
|
|
18
|
-
(ref: `${"
|
|
17
|
+
(ref: `${import("../initVal.js").ConfigDirectory}/${string}`, metadata: ImageMetadata): ImageSource<ImageMetadata>;
|
|
18
|
+
(ref: `${import("../initVal.js").ConfigDirectory}/${string}`, metadata?: undefined): ImageSource<undefined>;
|
|
19
19
|
};
|
|
@@ -12,12 +12,12 @@ export type RemoteSource<Metadata extends FileMetadata | undefined = FileMetadat
|
|
|
12
12
|
readonly patch_id?: string;
|
|
13
13
|
};
|
|
14
14
|
export declare const initRemote: (config?: ValConfig) => <Metadata extends FileMetadata | ImageMetadata>(ref: RemoteRef, metadata?: Metadata) => RemoteSource<Metadata>;
|
|
15
|
-
export type RemoteRef = `${string}/file/p/${string}/v/${string}/h/${string}/f/${string}/p/public
|
|
15
|
+
export type RemoteRef = `${string}/file/p/${string}/b/${string}/v/${string}/h/${string}/f/${string}/p/public/${string}`;
|
|
16
16
|
export declare function createRemoteRef(remoteHost: string, { publicProjectId, coreVersion, validationHash, fileHash, filePath, bucket, }: {
|
|
17
17
|
publicProjectId: string;
|
|
18
18
|
coreVersion: string;
|
|
19
19
|
validationHash: string;
|
|
20
20
|
fileHash: string;
|
|
21
|
-
filePath: `public
|
|
21
|
+
filePath: `public/${string}`;
|
|
22
22
|
bucket: string;
|
|
23
23
|
}): RemoteRef;
|
|
@@ -2892,7 +2892,15 @@ function splitRemoteRef(ref) {
|
|
|
2892
2892
|
error: "Invalid remote ref: " + ref
|
|
2893
2893
|
};
|
|
2894
2894
|
}
|
|
2895
|
-
if (match[7].indexOf("public/
|
|
2895
|
+
if (match[7].indexOf("public/") !== 0) {
|
|
2896
|
+
return {
|
|
2897
|
+
status: "error",
|
|
2898
|
+
error: "Invalid remote ref: " + ref
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
if (match[7].split("/").some(function (segment) {
|
|
2902
|
+
return segment === "." || segment === "..";
|
|
2903
|
+
})) {
|
|
2896
2904
|
return {
|
|
2897
2905
|
status: "error",
|
|
2898
2906
|
error: "Invalid remote ref: " + ref
|
|
@@ -3056,13 +3064,17 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3056
3064
|
// Should! never happen
|
|
3057
3065
|
src);
|
|
3058
3066
|
} else if (_this2.mediaOptions) {
|
|
3059
|
-
// Media collection: validate key (path/URL) and entry (metadata)
|
|
3067
|
+
// Media collection: validate key (path/URL) and entry (metadata).
|
|
3068
|
+
// Gallery entries are keyed by their file path and the metadata is
|
|
3069
|
+
// derived, so surface entry errors on the key rather than the value.
|
|
3060
3070
|
var keyErr = _this2.validateMediaKey(subPath, key);
|
|
3061
3071
|
if (keyErr) {
|
|
3072
|
+
_this2.markKeyErrorsAtPath(keyErr, subPath);
|
|
3062
3073
|
error = error ? _objectSpread2(_objectSpread2({}, error), keyErr) : keyErr;
|
|
3063
3074
|
}
|
|
3064
3075
|
var entryErr = _this2.validateMediaEntry(subPath, elem);
|
|
3065
3076
|
if (entryErr) {
|
|
3077
|
+
_this2.markKeyErrorsAtPath(entryErr, subPath);
|
|
3066
3078
|
error = error ? _objectSpread2(_objectSpread2({}, error), entryErr) : entryErr;
|
|
3067
3079
|
}
|
|
3068
3080
|
} else {
|
|
@@ -3081,6 +3093,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3081
3093
|
value: function isRemoteUrl(url) {
|
|
3082
3094
|
return url.startsWith("https://") || url.startsWith("http://");
|
|
3083
3095
|
}
|
|
3096
|
+
|
|
3097
|
+
/** Marks the validation errors reported at `path` as key errors (in place). */
|
|
3098
|
+
}, {
|
|
3099
|
+
key: "markKeyErrorsAtPath",
|
|
3100
|
+
value: function markKeyErrorsAtPath(errors, path) {
|
|
3101
|
+
if (errors && errors[path]) {
|
|
3102
|
+
errors[path] = errors[path].map(function (err) {
|
|
3103
|
+
return _objectSpread2(_objectSpread2({}, err), {}, {
|
|
3104
|
+
keyError: true
|
|
3105
|
+
});
|
|
3106
|
+
});
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3084
3109
|
}, {
|
|
3085
3110
|
key: "validateMediaKey",
|
|
3086
3111
|
value: function validateMediaKey(path, key) {
|
|
@@ -4905,6 +4930,9 @@ function router(router, item) {
|
|
|
4905
4930
|
/**
|
|
4906
4931
|
* Define a collection of images.
|
|
4907
4932
|
*
|
|
4933
|
+
* All options are optional: `s.images()` accepts any image type (`"image/*"`) in
|
|
4934
|
+
* the default `/public/val` directory, with nullable alt text and remote disabled.
|
|
4935
|
+
*
|
|
4908
4936
|
* @example
|
|
4909
4937
|
* ```typescript
|
|
4910
4938
|
* const schema = s.images({
|
|
@@ -4923,9 +4951,9 @@ function router(router, item) {
|
|
|
4923
4951
|
* ```
|
|
4924
4952
|
*/
|
|
4925
4953
|
var images = function images(options) {
|
|
4926
|
-
var _options$directory, _options$alt, _options$remote;
|
|
4927
|
-
var directory = (_options$directory = options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
|
|
4928
|
-
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
4954
|
+
var _options$directory, _options$alt, _options$accept, _options$remote;
|
|
4955
|
+
var directory = (_options$directory = options === null || options === void 0 ? void 0 : options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
|
|
4956
|
+
var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
4929
4957
|
var itemSchema = new ObjectSchema({
|
|
4930
4958
|
width: new NumberSchema(undefined, false),
|
|
4931
4959
|
height: new NumberSchema(undefined, false),
|
|
@@ -4934,9 +4962,9 @@ var images = function images(options) {
|
|
|
4934
4962
|
}, false);
|
|
4935
4963
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
4936
4964
|
type: "images",
|
|
4937
|
-
accept: options.accept,
|
|
4965
|
+
accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
4938
4966
|
directory: directory,
|
|
4939
|
-
remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
4967
|
+
remote: (_options$remote = options === null || options === void 0 ? void 0 : options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
4940
4968
|
altSchema: altSchema
|
|
4941
4969
|
});
|
|
4942
4970
|
};
|
|
@@ -5042,6 +5070,9 @@ var initRemote = function initRemote(config) {
|
|
|
5042
5070
|
}
|
|
5043
5071
|
return remote;
|
|
5044
5072
|
};
|
|
5073
|
+
|
|
5074
|
+
// NOTE: the segments must match the ref built by createRemoteRef below and the RegEx in splitRemoteRef.
|
|
5075
|
+
|
|
5045
5076
|
function createRemoteRef(remoteHost, _ref2) {
|
|
5046
5077
|
var publicProjectId = _ref2.publicProjectId,
|
|
5047
5078
|
coreVersion = _ref2.coreVersion,
|
|
@@ -2890,7 +2890,15 @@ function splitRemoteRef(ref) {
|
|
|
2890
2890
|
error: "Invalid remote ref: " + ref
|
|
2891
2891
|
};
|
|
2892
2892
|
}
|
|
2893
|
-
if (match[7].indexOf("public/
|
|
2893
|
+
if (match[7].indexOf("public/") !== 0) {
|
|
2894
|
+
return {
|
|
2895
|
+
status: "error",
|
|
2896
|
+
error: "Invalid remote ref: " + ref
|
|
2897
|
+
};
|
|
2898
|
+
}
|
|
2899
|
+
if (match[7].split("/").some(function (segment) {
|
|
2900
|
+
return segment === "." || segment === "..";
|
|
2901
|
+
})) {
|
|
2894
2902
|
return {
|
|
2895
2903
|
status: "error",
|
|
2896
2904
|
error: "Invalid remote ref: " + ref
|
|
@@ -3054,13 +3062,17 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3054
3062
|
// Should! never happen
|
|
3055
3063
|
src);
|
|
3056
3064
|
} else if (_this2.mediaOptions) {
|
|
3057
|
-
// Media collection: validate key (path/URL) and entry (metadata)
|
|
3065
|
+
// Media collection: validate key (path/URL) and entry (metadata).
|
|
3066
|
+
// Gallery entries are keyed by their file path and the metadata is
|
|
3067
|
+
// derived, so surface entry errors on the key rather than the value.
|
|
3058
3068
|
var keyErr = _this2.validateMediaKey(subPath, key);
|
|
3059
3069
|
if (keyErr) {
|
|
3070
|
+
_this2.markKeyErrorsAtPath(keyErr, subPath);
|
|
3060
3071
|
error = error ? _objectSpread2(_objectSpread2({}, error), keyErr) : keyErr;
|
|
3061
3072
|
}
|
|
3062
3073
|
var entryErr = _this2.validateMediaEntry(subPath, elem);
|
|
3063
3074
|
if (entryErr) {
|
|
3075
|
+
_this2.markKeyErrorsAtPath(entryErr, subPath);
|
|
3064
3076
|
error = error ? _objectSpread2(_objectSpread2({}, error), entryErr) : entryErr;
|
|
3065
3077
|
}
|
|
3066
3078
|
} else {
|
|
@@ -3079,6 +3091,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3079
3091
|
value: function isRemoteUrl(url) {
|
|
3080
3092
|
return url.startsWith("https://") || url.startsWith("http://");
|
|
3081
3093
|
}
|
|
3094
|
+
|
|
3095
|
+
/** Marks the validation errors reported at `path` as key errors (in place). */
|
|
3096
|
+
}, {
|
|
3097
|
+
key: "markKeyErrorsAtPath",
|
|
3098
|
+
value: function markKeyErrorsAtPath(errors, path) {
|
|
3099
|
+
if (errors && errors[path]) {
|
|
3100
|
+
errors[path] = errors[path].map(function (err) {
|
|
3101
|
+
return _objectSpread2(_objectSpread2({}, err), {}, {
|
|
3102
|
+
keyError: true
|
|
3103
|
+
});
|
|
3104
|
+
});
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3082
3107
|
}, {
|
|
3083
3108
|
key: "validateMediaKey",
|
|
3084
3109
|
value: function validateMediaKey(path, key) {
|
|
@@ -4903,6 +4928,9 @@ function router(router, item) {
|
|
|
4903
4928
|
/**
|
|
4904
4929
|
* Define a collection of images.
|
|
4905
4930
|
*
|
|
4931
|
+
* All options are optional: `s.images()` accepts any image type (`"image/*"`) in
|
|
4932
|
+
* the default `/public/val` directory, with nullable alt text and remote disabled.
|
|
4933
|
+
*
|
|
4906
4934
|
* @example
|
|
4907
4935
|
* ```typescript
|
|
4908
4936
|
* const schema = s.images({
|
|
@@ -4921,9 +4949,9 @@ function router(router, item) {
|
|
|
4921
4949
|
* ```
|
|
4922
4950
|
*/
|
|
4923
4951
|
var images = function images(options) {
|
|
4924
|
-
var _options$directory, _options$alt, _options$remote;
|
|
4925
|
-
var directory = (_options$directory = options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
|
|
4926
|
-
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
4952
|
+
var _options$directory, _options$alt, _options$accept, _options$remote;
|
|
4953
|
+
var directory = (_options$directory = options === null || options === void 0 ? void 0 : options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
|
|
4954
|
+
var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
4927
4955
|
var itemSchema = new ObjectSchema({
|
|
4928
4956
|
width: new NumberSchema(undefined, false),
|
|
4929
4957
|
height: new NumberSchema(undefined, false),
|
|
@@ -4932,9 +4960,9 @@ var images = function images(options) {
|
|
|
4932
4960
|
}, false);
|
|
4933
4961
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
4934
4962
|
type: "images",
|
|
4935
|
-
accept: options.accept,
|
|
4963
|
+
accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
4936
4964
|
directory: directory,
|
|
4937
|
-
remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
4965
|
+
remote: (_options$remote = options === null || options === void 0 ? void 0 : options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
4938
4966
|
altSchema: altSchema
|
|
4939
4967
|
});
|
|
4940
4968
|
};
|
|
@@ -5040,6 +5068,9 @@ var initRemote = function initRemote(config) {
|
|
|
5040
5068
|
}
|
|
5041
5069
|
return remote;
|
|
5042
5070
|
};
|
|
5071
|
+
|
|
5072
|
+
// NOTE: the segments must match the ref built by createRemoteRef below and the RegEx in splitRemoteRef.
|
|
5073
|
+
|
|
5043
5074
|
function createRemoteRef(remoteHost, _ref2) {
|
|
5044
5075
|
var publicProjectId = _ref2.publicProjectId,
|
|
5045
5076
|
coreVersion = _ref2.coreVersion,
|
|
@@ -2892,7 +2892,15 @@ function splitRemoteRef(ref) {
|
|
|
2892
2892
|
error: "Invalid remote ref: " + ref
|
|
2893
2893
|
};
|
|
2894
2894
|
}
|
|
2895
|
-
if (match[7].indexOf("public/
|
|
2895
|
+
if (match[7].indexOf("public/") !== 0) {
|
|
2896
|
+
return {
|
|
2897
|
+
status: "error",
|
|
2898
|
+
error: "Invalid remote ref: " + ref
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
if (match[7].split("/").some(function (segment) {
|
|
2902
|
+
return segment === "." || segment === "..";
|
|
2903
|
+
})) {
|
|
2896
2904
|
return {
|
|
2897
2905
|
status: "error",
|
|
2898
2906
|
error: "Invalid remote ref: " + ref
|
|
@@ -3056,13 +3064,17 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3056
3064
|
// Should! never happen
|
|
3057
3065
|
src);
|
|
3058
3066
|
} else if (_this2.mediaOptions) {
|
|
3059
|
-
// Media collection: validate key (path/URL) and entry (metadata)
|
|
3067
|
+
// Media collection: validate key (path/URL) and entry (metadata).
|
|
3068
|
+
// Gallery entries are keyed by their file path and the metadata is
|
|
3069
|
+
// derived, so surface entry errors on the key rather than the value.
|
|
3060
3070
|
var keyErr = _this2.validateMediaKey(subPath, key);
|
|
3061
3071
|
if (keyErr) {
|
|
3072
|
+
_this2.markKeyErrorsAtPath(keyErr, subPath);
|
|
3062
3073
|
error = error ? _objectSpread2(_objectSpread2({}, error), keyErr) : keyErr;
|
|
3063
3074
|
}
|
|
3064
3075
|
var entryErr = _this2.validateMediaEntry(subPath, elem);
|
|
3065
3076
|
if (entryErr) {
|
|
3077
|
+
_this2.markKeyErrorsAtPath(entryErr, subPath);
|
|
3066
3078
|
error = error ? _objectSpread2(_objectSpread2({}, error), entryErr) : entryErr;
|
|
3067
3079
|
}
|
|
3068
3080
|
} else {
|
|
@@ -3081,6 +3093,19 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3081
3093
|
value: function isRemoteUrl(url) {
|
|
3082
3094
|
return url.startsWith("https://") || url.startsWith("http://");
|
|
3083
3095
|
}
|
|
3096
|
+
|
|
3097
|
+
/** Marks the validation errors reported at `path` as key errors (in place). */
|
|
3098
|
+
}, {
|
|
3099
|
+
key: "markKeyErrorsAtPath",
|
|
3100
|
+
value: function markKeyErrorsAtPath(errors, path) {
|
|
3101
|
+
if (errors && errors[path]) {
|
|
3102
|
+
errors[path] = errors[path].map(function (err) {
|
|
3103
|
+
return _objectSpread2(_objectSpread2({}, err), {}, {
|
|
3104
|
+
keyError: true
|
|
3105
|
+
});
|
|
3106
|
+
});
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3084
3109
|
}, {
|
|
3085
3110
|
key: "validateMediaKey",
|
|
3086
3111
|
value: function validateMediaKey(path, key) {
|
|
@@ -4905,6 +4930,9 @@ function router(router, item) {
|
|
|
4905
4930
|
/**
|
|
4906
4931
|
* Define a collection of images.
|
|
4907
4932
|
*
|
|
4933
|
+
* All options are optional: `s.images()` accepts any image type (`"image/*"`) in
|
|
4934
|
+
* the default `/public/val` directory, with nullable alt text and remote disabled.
|
|
4935
|
+
*
|
|
4908
4936
|
* @example
|
|
4909
4937
|
* ```typescript
|
|
4910
4938
|
* const schema = s.images({
|
|
@@ -4923,9 +4951,9 @@ function router(router, item) {
|
|
|
4923
4951
|
* ```
|
|
4924
4952
|
*/
|
|
4925
4953
|
var images = function images(options) {
|
|
4926
|
-
var _options$directory, _options$alt, _options$remote;
|
|
4927
|
-
var directory = (_options$directory = options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
|
|
4928
|
-
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
4954
|
+
var _options$directory, _options$alt, _options$accept, _options$remote;
|
|
4955
|
+
var directory = (_options$directory = options === null || options === void 0 ? void 0 : options.directory) !== null && _options$directory !== void 0 ? _options$directory : "/public/val";
|
|
4956
|
+
var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
4929
4957
|
var itemSchema = new ObjectSchema({
|
|
4930
4958
|
width: new NumberSchema(undefined, false),
|
|
4931
4959
|
height: new NumberSchema(undefined, false),
|
|
@@ -4934,9 +4962,9 @@ var images = function images(options) {
|
|
|
4934
4962
|
}, false);
|
|
4935
4963
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
4936
4964
|
type: "images",
|
|
4937
|
-
accept: options.accept,
|
|
4965
|
+
accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
4938
4966
|
directory: directory,
|
|
4939
|
-
remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
4967
|
+
remote: (_options$remote = options === null || options === void 0 ? void 0 : options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
4940
4968
|
altSchema: altSchema
|
|
4941
4969
|
});
|
|
4942
4970
|
};
|
|
@@ -5042,6 +5070,9 @@ var initRemote = function initRemote(config) {
|
|
|
5042
5070
|
}
|
|
5043
5071
|
return remote;
|
|
5044
5072
|
};
|
|
5073
|
+
|
|
5074
|
+
// NOTE: the segments must match the ref built by createRemoteRef below and the RegEx in splitRemoteRef.
|
|
5075
|
+
|
|
5045
5076
|
function createRemoteRef(remoteHost, _ref2) {
|
|
5046
5077
|
var publicProjectId = _ref2.publicProjectId,
|
|
5047
5078
|
coreVersion = _ref2.coreVersion,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, g as DEFAULT_VAL_REMOTE_HOST, p as DateSchema, q as DateTimeSchema, F as FATAL_ERROR_TYPES, h as FILE_REF_PROP, j as FILE_REF_SUBTYPE_TAG, o as FileSchema, G as GenericSelector, n as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, t as RichTextSchema, r as RouteSchema, S as Schema, l as StringSchema, U as UnionSchema, V as VAL_EXTENSION, k as derefPatch, u as deserializeSchema, f as extractValModules, v as getSourcePathFromRoute, i as initVal, m as modules } from './index-
|
|
1
|
+
export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, g as DEFAULT_VAL_REMOTE_HOST, p as DateSchema, q as DateTimeSchema, F as FATAL_ERROR_TYPES, h as FILE_REF_PROP, j as FILE_REF_SUBTYPE_TAG, o as FileSchema, G as GenericSelector, n as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, t as RichTextSchema, r as RouteSchema, S as Schema, l as StringSchema, U as UnionSchema, V as VAL_EXTENSION, k as derefPatch, u as deserializeSchema, f as extractValModules, v as getSourcePathFromRoute, i as initVal, m as modules } from './index-6aa8e224.esm.js';
|
|
2
2
|
import './result-4bd63123.esm.js';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
|
5
|
+
var dist_valbuildCore = require('../../dist/index-a169d6a7.cjs.dev.js');
|
|
6
6
|
var result = require('../../dist/result-bb1f436e.cjs.dev.js');
|
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
|
5
|
+
var dist_valbuildCore = require('../../dist/index-30ac56b6.cjs.prod.js');
|
|
6
6
|
var result = require('../../dist/result-787e35f6.cjs.prod.js');
|
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-
|
|
2
|
-
export { P as PatchError } from '../../dist/index-
|
|
1
|
+
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-6aa8e224.esm.js';
|
|
2
|
+
export { P as PatchError } from '../../dist/index-6aa8e224.esm.js';
|
|
3
3
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-4bd63123.esm.js';
|
|
4
4
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
|
5
5
|
|