@valbuild/core 0.72.4 → 0.73.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.
Files changed (55) hide show
  1. package/dist/declarations/src/index.d.ts +20 -4
  2. package/dist/declarations/src/initSchema.d.ts +3 -3
  3. package/dist/declarations/src/initVal.d.ts +3 -1
  4. package/dist/declarations/src/patch/index.d.ts +1 -1
  5. package/dist/declarations/src/patch/operation.d.ts +3 -0
  6. package/dist/declarations/src/remote/fileHash.d.ts +5 -0
  7. package/dist/declarations/src/remote/splitRemoteRef.d.ts +13 -0
  8. package/dist/declarations/src/remote/validationBasis.d.ts +13 -0
  9. package/dist/declarations/src/schema/file.d.ts +7 -3
  10. package/dist/declarations/src/schema/image.d.ts +7 -3
  11. package/dist/declarations/src/schema/remote.d.ts +11 -0
  12. package/dist/declarations/src/schema/richtext.d.ts +5 -3
  13. package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
  14. package/dist/declarations/src/selector/index.d.ts +2 -1
  15. package/dist/declarations/src/source/file.d.ts +3 -3
  16. package/dist/declarations/src/source/image.d.ts +2 -2
  17. package/dist/declarations/src/source/index.d.ts +3 -4
  18. package/dist/declarations/src/source/remote.d.ts +23 -0
  19. package/dist/declarations/src/source/richtext.d.ts +30 -3
  20. package/dist/declarations/src/val/index.d.ts +4 -3
  21. package/dist/{index-25ee166a.cjs.prod.js → index-da9933cf.cjs.prod.js} +529 -1332
  22. package/dist/{index-a49a4c82.cjs.dev.js → index-f6fd3df3.cjs.dev.js} +529 -1332
  23. package/dist/{index-e01fe365.esm.js → index-fee3aa6d.esm.js} +531 -1326
  24. package/dist/{result-168dfc1d.esm.js → result-daff1cae.esm.js} +1 -1
  25. package/dist/valbuild-core.cjs.dev.js +27 -27
  26. package/dist/valbuild-core.cjs.prod.js +27 -27
  27. package/dist/valbuild-core.esm.js +2 -2
  28. package/fp/dist/valbuild-core-fp.esm.js +1 -1
  29. package/package.json +2 -9
  30. package/patch/dist/valbuild-core-patch.cjs.dev.js +38 -37
  31. package/patch/dist/valbuild-core-patch.cjs.prod.js +38 -37
  32. package/patch/dist/valbuild-core-patch.esm.js +5 -4
  33. package/dist/declarations/src/expr/eval.d.ts +0 -20
  34. package/dist/declarations/src/expr/expr.d.ts +0 -32
  35. package/dist/declarations/src/expr/index.d.ts +0 -3
  36. package/dist/declarations/src/expr/parser.d.ts +0 -8
  37. package/dist/declarations/src/future/fetchVal.d.ts +0 -5
  38. package/dist/declarations/src/selector/future/array.d.ts +0 -17
  39. package/dist/declarations/src/selector/future/boolean.d.ts +0 -2
  40. package/dist/declarations/src/selector/future/file.d.ts +0 -9
  41. package/dist/declarations/src/selector/future/i18n.d.ts +0 -11
  42. package/dist/declarations/src/selector/future/index.d.ts +0 -82
  43. package/dist/declarations/src/selector/future/number.d.ts +0 -2
  44. package/dist/declarations/src/selector/future/object.d.ts +0 -10
  45. package/dist/declarations/src/selector/future/primitive.d.ts +0 -9
  46. package/dist/declarations/src/selector/future/remote.d.ts +0 -7
  47. package/dist/declarations/src/selector/future/string.d.ts +0 -2
  48. package/dist/declarations/src/source/future/i18n.d.ts +0 -29
  49. package/dist/declarations/src/source/future/remote.d.ts +0 -29
  50. package/expr/dist/valbuild-core-expr.cjs.d.ts +0 -2
  51. package/expr/dist/valbuild-core-expr.cjs.dev.js +0 -17
  52. package/expr/dist/valbuild-core-expr.cjs.js +0 -7
  53. package/expr/dist/valbuild-core-expr.cjs.prod.js +0 -17
  54. package/expr/dist/valbuild-core-expr.esm.js +0 -2
  55. package/expr/package.json +0 -4
@@ -7,14 +7,15 @@ export type { FileMetadata } from "./schema/file.js";
7
7
  export type { ValModule, SerializedModule, InferValModuleType } from "./module.js";
8
8
  export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
9
9
  export type { FileSource } from "./source/file.js";
10
+ export type { RemoteSource, RemoteRef } from "./source/remote.js";
11
+ export { DEFAULT_VAL_REMOTE_HOST } from "./schema/remote.js";
10
12
  export type { RawString } from "./schema/string.js";
11
13
  export type { ImageSource } from "./source/image.js";
12
- export type { AllRichTextOptions, Bold, Styles, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, LinkNode, OrderedListNode, ParagraphNode, BrNode, RichTextNode, RichTextOptions, RichTextSource, BlockNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
14
+ export type { AllRichTextOptions, Bold, Styles, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, LinkNode, OrderedListNode, ParagraphNode, BrNode, RichTextNode, RichTextOptions, SerializedRichTextOptions, RichTextSource, BlockNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
13
15
  export { type Val, type SerializedVal, type ModuleFilePath, type PatchId, type ModulePath, type SourcePath, type JsonOfSource, type ParentPatchId, } from "./val/index.js";
14
16
  export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
15
17
  export type { ValidationError, ValidationErrors, } from "./schema/validation/ValidationError.js";
16
18
  export type { ValidationFix } from "./schema/validation/ValidationFix.js";
17
- export * as expr from "./expr/index.js";
18
19
  export { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from "./source/file.js";
19
20
  export { VAL_EXTENSION, type SourceArray } from "./source/index.js";
20
21
  export { derefPatch } from "./patch/deref.js";
@@ -26,12 +27,17 @@ import { getSchema } from "./selector/index.js";
26
27
  import { ModulePath, getValPath, isVal } from "./val/index.js";
27
28
  import { convertFileSource } from "./schema/file.js";
28
29
  import { createValPathOfItem } from "./selector/SelectorProxy.js";
29
- import { getVal } from "./future/fetchVal.js";
30
30
  import { Operation } from "./patch/index.js";
31
31
  import { initSchema } from "./initSchema.js";
32
32
  import { getMimeType, mimeTypeToFileExt, filenameToMimeType } from "./mimeType/index.js";
33
33
  import { type ImageMetadata } from "./schema/image.js";
34
34
  import { type FileMetadata } from "./schema/file.js";
35
+ import { isFile } from "./source/file.js";
36
+ import { createRemoteRef } from "./source/remote.js";
37
+ import { getValidationBasis, getValidationHash } from "./remote/validationBasis.js";
38
+ import { getFileHash, hashToRemoteFileHash } from "./remote/fileHash.js";
39
+ import { splitRemoteRef } from "./remote/splitRemoteRef.js";
40
+ import { convertRemoteSource } from "./schema/remote.js";
35
41
  export { type SerializedArraySchema, ArraySchema } from "./schema/array.js";
36
42
  export { type SerializedObjectSchema, ObjectSchema } from "./schema/object.js";
37
43
  export { type SerializedRecordSchema, RecordSchema } from "./schema/record.js";
@@ -53,14 +59,23 @@ declare const Internal: {
53
59
  core: string | null;
54
60
  };
55
61
  convertFileSource: typeof convertFileSource;
62
+ convertRemoteSource: typeof convertRemoteSource;
56
63
  getSchema: typeof getSchema;
57
64
  getValPath: typeof getValPath;
58
- getVal: typeof getVal;
59
65
  getSource: typeof getSource;
60
66
  resolvePath: typeof resolvePath;
61
67
  splitModuleFilePathAndModulePath: typeof splitModuleFilePathAndModulePath;
62
68
  joinModuleFilePathAndModulePath: typeof joinModuleFilePathAndModulePath;
69
+ remote: {
70
+ createRemoteRef: typeof createRemoteRef;
71
+ getValidationBasis: typeof getValidationBasis;
72
+ getValidationHash: typeof getValidationHash;
73
+ getFileHash: typeof getFileHash;
74
+ hashToRemoteFileHash: typeof hashToRemoteFileHash;
75
+ splitRemoteRef: typeof splitRemoteRef;
76
+ };
63
77
  isVal: typeof isVal;
78
+ isFile: typeof isFile;
64
79
  createValPathOfItem: typeof createValPathOfItem;
65
80
  getSHA256Hash: (bits: Uint8Array) => string;
66
81
  initSchema: typeof initSchema;
@@ -78,6 +93,7 @@ declare const Internal: {
78
93
  path: string[];
79
94
  filePath: string;
80
95
  value: string;
96
+ remote: boolean;
81
97
  };
82
98
  createPatchJSONPath: (modulePath: ModulePath) => string;
83
99
  createPatchPath: (modulePath: ModulePath) => string[];
@@ -92,13 +92,13 @@ export declare function initSchema(): {
92
92
  }>;
93
93
  inline: Partial<{
94
94
  a: boolean;
95
- img: boolean;
95
+ img: boolean | import("./schema/image.js").ImageSchema<import("./index.js").ImageSource | import("./index.js").RemoteSource<import("./schema/image.js").ImageMetadata>>;
96
96
  }>;
97
97
  }>>(options?: O | undefined) => import("./schema/richtext.js").RichTextSchema<O, import("./index.js").RichTextSource<O>>;
98
- image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").ImageSource>;
98
+ image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/image.js").ImageSchema<import("./index.js").ImageSource>;
99
99
  literal: <T_2 extends string>(value: T_2) => import("./schema/literal.js").LiteralSchema<T_2>;
100
100
  keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly import("./source/index.js").Source[] ? number : S_2 extends import("./source/index.js").SourceObject ? string extends keyof S_2 ? import("./schema/string.js").RawString : keyof S_2 : S_2 extends Record<string, import("./source/index.js").Source> ? import("./schema/string.js").RawString : never : never>;
101
101
  record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
102
- file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
102
+ file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/file.js").FileSchema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
103
103
  date: (options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
104
104
  };
@@ -3,15 +3,17 @@ import { InitSchema } from "./initSchema.js";
3
3
  import { getValPath as getPath } from "./val/index.js";
4
4
  import { initFile } from "./source/file.js";
5
5
  import { initImage } from "./source/image.js";
6
+ import { initRemote } from "./source/remote.js";
6
7
  export type ContentConstructor = {
7
8
  define: typeof define;
8
9
  file: ReturnType<typeof initFile>;
9
10
  image: ReturnType<typeof initImage>;
11
+ remote: ReturnType<typeof initRemote>;
10
12
  };
11
13
  export type ValConstructor = {
12
14
  unstable_getPath: typeof getPath;
13
15
  };
14
- export type ConfigDirectory = `/public/${string}`;
16
+ export type ConfigDirectory = `/public/val`;
15
17
  export type ValConfig = {
16
18
  project?: string;
17
19
  root?: string;
@@ -1,6 +1,6 @@
1
1
  export { JSONOps } from "./json.js";
2
2
  export { type OperationJSON, type Operation } from "./operation.js";
3
3
  export { parsePatch, parseJSONPointer, formatJSONPointer } from "./parse.js";
4
- export { type JSONValue, type Ops, PatchError } from "./ops.js";
4
+ export { type JSONValue, type Ops, PatchError, type ReadonlyJSONValue, } from "./ops.js";
5
5
  export { type PatchJSON, type Patch, applyPatch, type PatchBlock, type ParentRef, } from "./patch.js";
6
6
  export { isNotRoot, deepEqual, deepClone, parseAndValidateArrayIndex, sourceToPatchPath, } from "./util.js";
@@ -31,6 +31,7 @@ export type OperationJSON = {
31
31
  path: string;
32
32
  filePath: string;
33
33
  value: JSONValue;
34
+ remote: boolean;
34
35
  };
35
36
  /**
36
37
  * Parsed form of JSON patch operation.
@@ -70,4 +71,6 @@ export type Operation = {
70
71
  /** files can be nested within an object (for richtext), in order to find the actual file element this path can be used (we use this to add the patch_id on files) */
71
72
  nestedFilePath?: string[];
72
73
  value: JSONValue;
74
+ /** true if this is a remote file */
75
+ remote: boolean;
73
76
  };
@@ -0,0 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Buffer } from "buffer";
4
+ export declare function hashToRemoteFileHash(hash: string): string;
5
+ export declare function getFileHash(text: Buffer): string;
@@ -0,0 +1,13 @@
1
+ export declare function splitRemoteRef(ref: string): {
2
+ status: "success";
3
+ remoteHost: string;
4
+ bucket: string;
5
+ projectId: string;
6
+ version: string;
7
+ validationHash: string;
8
+ fileHash: string;
9
+ filePath: `public/val/${string}`;
10
+ } | {
11
+ status: "error";
12
+ error: string;
13
+ };
@@ -0,0 +1,13 @@
1
+ import { SerializedFileSchema } from "../schema/file.js";
2
+ import { SerializedImageSchema } from "../schema/image.js";
3
+ /**
4
+ * The validation basis is used in remote refs to determine if the remote content needs to be re-validated.
5
+ *
6
+ * If the validation basis changes, we need to re-validate the remote content.
7
+ *
8
+ * NOTE: We do not care if the file path is different as long as the extension is the same.
9
+ * This way we can rename a file, without having to re-validate it.
10
+ * The version is outside of the validation hash, so that it is possible to manually fix the version without having to re-validate.
11
+ */
12
+ export declare function getValidationBasis(coreVersion: string, schema: SerializedImageSchema | SerializedFileSchema, fileExt: string, metadata: Record<string, unknown> | undefined, fileHash: string): string;
13
+ export declare function getValidationHash(coreVersion: string, schema: SerializedImageSchema | SerializedFileSchema, fileExt: string, metadata: Record<string, unknown> | undefined, fileHash: string, textEncoder: TextEncoder): string;
@@ -3,27 +3,31 @@ import { FileSource } from "../source/file.js";
3
3
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
4
4
  import { SourcePath } from "../val/index.js";
5
5
  import { ValidationErrors } from "./validation/ValidationError.js";
6
+ import { RemoteSource } from "../index.js";
6
7
  export type FileOptions = {
7
8
  accept?: string;
8
9
  };
9
10
  export type SerializedFileSchema = {
10
11
  type: "file";
11
12
  options?: FileOptions;
13
+ remote?: boolean;
12
14
  opt: boolean;
13
15
  };
14
16
  export type FileMetadata = {
15
17
  mimeType?: string;
16
18
  };
17
- export declare class FileSchema<Src extends FileSource<FileMetadata | undefined> | null> extends Schema<Src> {
19
+ export declare class FileSchema<Src extends FileSource<FileMetadata | undefined> | RemoteSource<FileMetadata | undefined> | null> extends Schema<Src> {
18
20
  readonly options?: FileOptions | undefined;
19
21
  readonly opt: boolean;
20
- constructor(options?: FileOptions | undefined, opt?: boolean);
22
+ protected readonly isRemote: boolean;
23
+ constructor(options?: FileOptions | undefined, opt?: boolean, isRemote?: boolean);
24
+ remote(): FileSchema<Src | RemoteSource<FileMetadata | undefined>>;
21
25
  validate(path: SourcePath, src: Src): ValidationErrors;
22
26
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
23
27
  nullable(): Schema<Src | null>;
24
28
  serialize(): SerializedSchema;
25
29
  }
26
- export declare const file: (options?: FileOptions) => Schema<FileSource<FileMetadata>>;
30
+ export declare const file: (options?: FileOptions) => FileSchema<FileSource<FileMetadata>>;
27
31
  export declare function convertFileSource<Metadata extends {
28
32
  readonly [key: string]: Json;
29
33
  } | undefined = {
@@ -3,6 +3,7 @@ import { FileSource } from "../source/file.js";
3
3
  import { ImageSource } from "../source/image.js";
4
4
  import { SourcePath } from "../val/index.js";
5
5
  import { ValidationErrors } from "./validation/ValidationError.js";
6
+ import { RemoteSource } from "../source/remote.js";
6
7
  export type ImageOptions = {
7
8
  ext?: ["jpg"] | ["webp"];
8
9
  directory?: string;
@@ -13,6 +14,7 @@ export type SerializedImageSchema = {
13
14
  type: "image";
14
15
  options?: ImageOptions;
15
16
  opt: boolean;
17
+ remote?: boolean;
16
18
  };
17
19
  export type ImageMetadata = {
18
20
  width: number;
@@ -24,13 +26,15 @@ export type ImageMetadata = {
24
26
  y: number;
25
27
  };
26
28
  };
27
- export declare class ImageSchema<Src extends FileSource<ImageMetadata | undefined> | null> extends Schema<Src> {
29
+ export declare class ImageSchema<Src extends FileSource<ImageMetadata | undefined> | RemoteSource<ImageMetadata | undefined> | null> extends Schema<Src> {
28
30
  readonly options?: ImageOptions | undefined;
29
31
  readonly opt: boolean;
30
- constructor(options?: ImageOptions | undefined, opt?: boolean);
32
+ protected readonly isRemote: boolean;
33
+ constructor(options?: ImageOptions | undefined, opt?: boolean, isRemote?: boolean);
34
+ remote(): ImageSchema<Src | RemoteSource<ImageMetadata | undefined>>;
31
35
  validate(path: SourcePath, src: Src): ValidationErrors;
32
36
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
33
37
  nullable(): Schema<Src | null>;
34
38
  serialize(): SerializedSchema;
35
39
  }
36
- export declare const image: (options?: ImageOptions) => Schema<ImageSource>;
40
+ export declare const image: (options?: ImageOptions) => ImageSchema<ImageSource>;
@@ -0,0 +1,11 @@
1
+ import { Json } from "../index.js";
2
+ import { RemoteSource } from "../source/remote.js";
3
+ export declare const DEFAULT_VAL_REMOTE_HOST = "https://remote.val.build";
4
+ export declare function convertRemoteSource<Metadata extends {
5
+ readonly [key: string]: Json;
6
+ } | undefined = {
7
+ readonly [key: string]: Json;
8
+ } | undefined>(src: RemoteSource<Metadata>): {
9
+ url: string;
10
+ metadata?: Metadata;
11
+ };
@@ -1,6 +1,8 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
- import { RichTextSource, RichTextOptions } from "../source/richtext.js";
2
+ import { ImageSource } from "../source/image.js";
3
+ import { RichTextSource, RichTextOptions, SerializedRichTextOptions } from "../source/richtext.js";
3
4
  import { SourcePath } from "../val/index.js";
5
+ import { ImageSchema } from "./image.js";
4
6
  import { ValidationErrors } from "./validation/ValidationError.js";
5
7
  type ValidationOptions = {
6
8
  maxLength?: number;
@@ -9,7 +11,7 @@ type ValidationOptions = {
9
11
  export type SerializedRichTextSchema = {
10
12
  type: "richtext";
11
13
  opt: boolean;
12
- options?: RichTextOptions & ValidationOptions;
14
+ options?: SerializedRichTextOptions & ValidationOptions;
13
15
  };
14
16
  export declare class RichTextSchema<O extends RichTextOptions, Src extends RichTextSource<O> | null> extends Schema<Src> {
15
17
  readonly options: O & ValidationOptions;
@@ -42,7 +44,7 @@ export declare const richtext: <O extends Partial<{
42
44
  }>;
43
45
  inline: Partial<{
44
46
  a: boolean;
45
- img: boolean;
47
+ img: boolean | ImageSchema<ImageSource | import("../index.js").RemoteSource<import("./image.js").ImageMetadata>>;
46
48
  }>;
47
49
  }>>(options?: O | undefined) => RichTextSchema<O, RichTextSource<O>>;
48
50
  export {};
@@ -1,2 +1,2 @@
1
- export declare const ValidationFix: readonly ["image:change-extension", "image:add-metadata", "image:check-metadata", "file:change-extension", "file:add-metadata", "file:check-metadata", "keyof:check-keys"];
1
+ export declare const ValidationFix: readonly ["image:change-extension", "image:add-metadata", "image:check-metadata", "image:upload-remote", "image:download-remote", "image:check-remote", "file:change-extension", "file:add-metadata", "file:check-metadata", "file:upload-remote", "file:download-remote", "file:check-remote", "keyof:check-keys"];
2
2
  export type ValidationFix = (typeof ValidationFix)[number];
@@ -14,10 +14,11 @@ import { AllRichTextOptions, RichTextSource } from "../source/richtext.js";
14
14
  import { ImageSelector } from "./image.js";
15
15
  import { RichTextSelector } from "./richtext.js";
16
16
  import { ImageSource } from "../source/image.js";
17
+ import { RemoteSource } from "../source/remote.js";
17
18
  export type Selector<T extends Source> = Source extends T ? GenericSelector<T> : T extends ImageSource ? ImageSelector : T extends FileSource<infer M> ? FileSelector<M> : T extends RichTextSource<infer O> ? RichTextSelector<O> : T extends SourceObject ? ObjectSelector<T> : T extends SourceArray ? ArraySelector<T> : T extends string ? StringSelector<T> : T extends number ? NumberSelector<T> : T extends boolean ? BooleanSelector<T> : T extends null ? PrimitiveSelector<null> : never;
18
19
  export type SelectorSource = SourcePrimitive | undefined | readonly SelectorSource[] | {
19
20
  [key: string]: SelectorSource;
20
- } | FileSource | RichTextSource<AllRichTextOptions> | GenericSelector<Source>;
21
+ } | FileSource | RemoteSource | RichTextSource<AllRichTextOptions> | GenericSelector<Source>;
21
22
  /**
22
23
  * @internal
23
24
  */
@@ -4,7 +4,7 @@ import { Json } from "../Json.js";
4
4
  export declare const FILE_REF_PROP: "_ref";
5
5
  export declare const FILE_REF_SUBTYPE_TAG: "_tag";
6
6
  export type FileMetadata = {
7
- readonly [key: string]: Json;
7
+ mimeType?: string;
8
8
  };
9
9
  /**
10
10
  * A file source represents the path to a (local) file.
@@ -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/${string}/${string}`, metadata: Metadata): FileSource<Metadata>;
26
- (ref: `/public/${string}/${string}`, metadata?: undefined): FileSource<undefined>;
25
+ }>(ref: `/public/val/${string}`, metadata: Metadata): FileSource<Metadata>;
26
+ (ref: `/public/val/${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/${string}/${string}`, metadata: ImageMetadata): ImageSource<ImageMetadata>;
18
- (ref: `/public/${string}/${string}`, metadata?: undefined): ImageSource<undefined>;
17
+ (ref: `/public/val/${string}`, metadata: ImageMetadata): ImageSource<ImageMetadata>;
18
+ (ref: `/public/val/${string}`, metadata?: undefined): ImageSource<undefined>;
19
19
  };
@@ -1,8 +1,7 @@
1
1
  import { FileSource } from "./file.js";
2
- import { I18nSource, I18nCompatibleSource } from "./future/i18n.js";
3
- import { RemoteSource, RemoteCompatibleSource } from "./future/remote.js";
2
+ import { RemoteSource } from "./remote.js";
4
3
  import { RichTextOptions, RichTextSource } from "./richtext.js";
5
- export type Source = SourcePrimitive | SourceObject | SourceArray | I18nSource<string[], I18nCompatibleSource> | RemoteSource<RemoteCompatibleSource> | FileSource | RichTextSource<RichTextOptions>;
4
+ export type Source = SourcePrimitive | SourceObject | SourceArray | RemoteSource | FileSource | RichTextSource<RichTextOptions>;
6
5
  export type SourceObject = {
7
6
  [key in string]: Source;
8
7
  } & {
@@ -24,7 +23,7 @@ export type SourceObject = {
24
23
  export type SourceArray = readonly Source[];
25
24
  export type SourcePrimitive = string | number | boolean | null;
26
25
  export declare const VAL_EXTENSION: "_type";
27
- export declare function getValExtension(source: Source): false | "" | 0 | "file" | "remote" | "i18n" | null | undefined;
26
+ export declare function getValExtension(source: Source): false | "" | 0 | "file" | "remote" | null | undefined;
28
27
  /**
29
28
  * A phantom type parameter is one that doesn't show up at runtime, but is checked statically (and only) at compile time.
30
29
  *
@@ -0,0 +1,23 @@
1
+ import { VAL_EXTENSION } from "./index.js";
2
+ import { ValConfig } from "../initVal.js";
3
+ import { ImageMetadata } from "../schema/image.js";
4
+ import { FILE_REF_PROP, FileMetadata } from "./file.js";
5
+ /**
6
+ * A remote source represents data that is not stored locally.
7
+ */
8
+ export type RemoteSource<Metadata extends FileMetadata | undefined = FileMetadata | undefined> = {
9
+ readonly [FILE_REF_PROP]: string;
10
+ readonly [VAL_EXTENSION]: "remote";
11
+ readonly metadata?: Metadata;
12
+ readonly patch_id?: string;
13
+ };
14
+ export declare const initRemote: (config?: ValConfig) => <Metadata extends ImageMetadata | FileMetadata>(ref: RemoteRef, metadata: Metadata) => RemoteSource<Metadata>;
15
+ export type RemoteRef = `${string}/file/p/${string}/v/${string}/h/${string}/f/${string}/p/public/val/${string}`;
16
+ export declare function createRemoteRef(remoteHost: string, { publicProjectId, coreVersion, validationHash, fileHash, filePath, bucket, }: {
17
+ publicProjectId: string;
18
+ coreVersion: string;
19
+ validationHash: string;
20
+ fileHash: string;
21
+ filePath: `public/val/${string}`;
22
+ bucket: string;
23
+ }): RemoteRef;
@@ -1,4 +1,7 @@
1
+ import { ImageMetadata, ImageSchema, SerializedImageSchema } from "../schema/image.js";
2
+ import { FileSource } from "./file.js";
1
3
  import { ImageSource } from "./image.js";
4
+ import { RemoteSource } from "./remote.js";
2
5
  export type RichTextOptions = Partial<{
3
6
  style: Partial<{
4
7
  bold: boolean;
@@ -17,7 +20,28 @@ export type RichTextOptions = Partial<{
17
20
  }>;
18
21
  inline: Partial<{
19
22
  a: boolean;
20
- img: boolean;
23
+ img: boolean | ImageSchema<ImageSource | RemoteSource<ImageMetadata>>;
24
+ }>;
25
+ }>;
26
+ export type SerializedRichTextOptions = Partial<{
27
+ style: Partial<{
28
+ bold: boolean;
29
+ italic: boolean;
30
+ lineThrough: boolean;
31
+ }>;
32
+ block: Partial<{
33
+ h1: boolean;
34
+ h2: boolean;
35
+ h3: boolean;
36
+ h4: boolean;
37
+ h5: boolean;
38
+ h6: boolean;
39
+ ul: boolean;
40
+ ol: boolean;
41
+ }>;
42
+ inline: Partial<{
43
+ a: boolean;
44
+ img: boolean | SerializedImageSchema;
21
45
  }>;
22
46
  }>;
23
47
  export type AllRichTextOptions = {
@@ -66,8 +90,11 @@ export type SpanNode<O extends RichTextOptions> = {
66
90
  };
67
91
  export type ImageNode<O extends RichTextOptions> = NonNullable<O["inline"]>["img"] extends true ? {
68
92
  tag: "img";
69
- src: ImageSource;
70
- } : never;
93
+ src: ImageSource | RemoteSource<ImageMetadata>;
94
+ } : NonNullable<O["inline"]>["img"] extends ImageSchema<infer Src> ? Src extends RemoteSource | FileSource ? {
95
+ tag: "img";
96
+ src: Src;
97
+ } : never : never;
71
98
  type LinkTagNode<O extends RichTextOptions> = {
72
99
  tag: "a";
73
100
  href: string;
@@ -4,15 +4,16 @@ import { Val as ArrayVal } from "./array.js";
4
4
  import { Val as PrimitiveVal } from "./primitive.js";
5
5
  import { Json, JsonArray, JsonObject, JsonPrimitive } from "../Json.js";
6
6
  import { Path, Selector } from "../selector/index.js";
7
- import { I18nSource } from "../source/future/i18n.js";
8
- import { RemoteSource } from "../source/future/remote.js";
7
+ import { RemoteSource } from "../source/remote.js";
9
8
  import { FileSource } from "../source/file.js";
10
9
  export type SerializedVal = {
11
10
  val: SerializedVal | Json;
12
11
  valPath: SourcePath | undefined;
13
12
  };
14
13
  export declare function isSerializedVal(val: unknown): val is SerializedVal;
15
- export type JsonOfSource<T extends Source> = Json extends T ? Json : T extends I18nSource<readonly string[], infer U> ? JsonOfSource<U> : T extends RemoteSource<infer U> ? JsonOfSource<U> : T extends FileSource ? {
14
+ export type JsonOfSource<T extends Source> = Json extends T ? Json : T extends RemoteSource ? {
15
+ url: string;
16
+ } : T extends FileSource ? {
16
17
  url: string;
17
18
  } : T extends SourceObject ? {
18
19
  [key in keyof T]: JsonOfSource<T[key]>;