@valbuild/core 0.97.0 → 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/extractValModules.d.ts +27 -0
- package/dist/declarations/src/index.d.ts +1 -0
- 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/selector/index.d.ts +0 -1
- 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-f203e2fa.cjs.prod.js → index-30ac56b6.cjs.prod.js} +537 -144
- package/dist/{index-50fd9c06.esm.js → index-6aa8e224.esm.js} +537 -145
- package/dist/{index-96716d5d.cjs.dev.js → index-a169d6a7.cjs.dev.js} +537 -144
- package/dist/valbuild-core.cjs.dev.js +2 -1
- package/dist/valbuild-core.cjs.prod.js +2 -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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ValModules } from "./modules.js";
|
|
2
|
+
import type { Schema, SerializedSchema } from "./schema/index.js";
|
|
3
|
+
import { SelectorSource } from "./selector/index.js";
|
|
4
|
+
import { Source } from "./source/index.js";
|
|
5
|
+
import { ModuleFilePath } from "./val/index.js";
|
|
6
|
+
export type ExtractedModuleError = {
|
|
7
|
+
message: string;
|
|
8
|
+
path?: ModuleFilePath;
|
|
9
|
+
};
|
|
10
|
+
export type ExtractedValModules = {
|
|
11
|
+
sources: Record<ModuleFilePath, Source>;
|
|
12
|
+
schemas: Record<ModuleFilePath, Schema<SelectorSource>>;
|
|
13
|
+
serializedSchemas: Record<ModuleFilePath, SerializedSchema>;
|
|
14
|
+
baseSha: string;
|
|
15
|
+
schemaSha: string;
|
|
16
|
+
sourcesSha: string;
|
|
17
|
+
configSha: string;
|
|
18
|
+
moduleErrors: ExtractedModuleError[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Extracts schemas and sources from a ValModules registry and computes the
|
|
22
|
+
* deterministic SHAs that the server and client both use to detect changes.
|
|
23
|
+
*
|
|
24
|
+
* Used by ValOps on the server and by ValSyncEngine on the client so the
|
|
25
|
+
* hash algorithm has a single source of truth.
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractValModules(valModules: ValModules): Promise<ExtractedValModules>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { initVal, type ConfigDirectory } from "./initVal.js";
|
|
2
2
|
export { modules, type ValModules } from "./modules.js";
|
|
3
|
+
export { extractValModules, type ExtractedValModules, type ExtractedModuleError, } from "./extractValModules.js";
|
|
3
4
|
export type { InitVal, ValConfig, ValConstructor, ContentConstructor, } from "./initVal.js";
|
|
4
5
|
export { Schema, type SerializedSchema, type SelectorOfSchema } from "./schema/index.js";
|
|
5
6
|
export type { ImageMetadata } from "./schema/image.js";
|
|
@@ -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;
|