@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.
@@ -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: import("./schema/images.js").ImagesOptions<Accept>) => import("./schema/record.js").RecordSchema<import("./schema/object.js").ObjectSchema<{
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/val`;
16
+ export type ConfigDirectory = `/public` | `/public/${string}`;
17
17
  export type ValConfig = {
18
18
  project?: string;
19
19
  root?: string;
@@ -6,7 +6,7 @@ export declare function splitRemoteRef(ref: string): {
6
6
  version: string;
7
7
  validationHash: string;
8
8
  fileHash: string;
9
- filePath: `public/val/${string}`;
9
+ filePath: `public/${string}`;
10
10
  } | {
11
11
  status: "error";
12
12
  error: 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: 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: ImagesOptions<Accept>) => RecordSchema<ObjectSchema<ImagesItemProps, ImagesItemSrc>, Schema<string>, Record<string, ImagesEntryMetadata>>;
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
+ } : {});
@@ -23,7 +23,6 @@ export type SelectorSource = SourcePrimitive | undefined | readonly SelectorSour
23
23
  * @internal
24
24
  */
25
25
  export declare const GetSchema: unique symbol;
26
- /**
27
26
  /**
28
27
  * @internal
29
28
  */
@@ -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: `${"/public/val"}/${string}`, metadata: Metadata): FileSource<Metadata>;
26
- (ref: `${"/public/val"}/${string}`, metadata?: undefined): FileSource<undefined>;
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: `${"/public/val"}/${string}`, metadata: ImageMetadata): ImageSource<ImageMetadata>;
18
- (ref: `${"/public/val"}/${string}`, metadata?: undefined): ImageSource<undefined>;
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/val/${string}`;
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/val/${string}`;
21
+ filePath: `public/${string}`;
22
22
  bucket: string;
23
23
  }): RemoteRef;