@valbuild/core 0.121.0 → 0.125.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/CHANGELOG.md +110 -0
- package/dist/declarations/src/getSourcePathFromRoute.d.ts +12 -3
- package/dist/declarations/src/index.d.ts +13 -3
- package/dist/declarations/src/initVal.d.ts +2 -0
- package/dist/declarations/src/module.d.ts +18 -1
- package/dist/declarations/src/router.d.ts +45 -0
- package/dist/declarations/src/schema/files.d.ts +2 -5
- package/dist/declarations/src/schema/hasRemoteFileSchema.d.ts +21 -3
- package/dist/declarations/src/schema/images.d.ts +1 -6
- package/dist/declarations/src/schema/record.d.ts +79 -3
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
- package/dist/declarations/src/selector/index.d.ts +3 -2
- package/dist/declarations/src/source/external.d.ts +91 -0
- package/dist/declarations/src/source/externalRef.d.ts +46 -0
- package/dist/declarations/src/source/index.d.ts +3 -2
- package/dist/{index-5fe6fb98.esm.js → index-915dd675.esm.js} +644 -50
- package/dist/{index-61237991.cjs.prod.js → index-a3846321.cjs.prod.js} +649 -49
- package/dist/{index-9860179f.cjs.dev.js → index-daa122af.cjs.dev.js} +649 -49
- package/dist/valbuild-core.cjs.dev.js +7 -1
- package/dist/valbuild-core.cjs.prod.js +7 -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,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reference stored for a file whose bytes live behind an external adapter.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately the same shape of idea as a remote ref (`remote/splitRemoteRef`):
|
|
5
|
+
* a URL-ish string that **ends with the file's virtual path**, so the file's
|
|
6
|
+
* logical identity survives wherever its bytes happen to be.
|
|
7
|
+
*
|
|
8
|
+
* /api/val/external/documents/f/{fileHash}/p/public/val/documents/report_a1b2c.pdf
|
|
9
|
+
* \__________________________/ \________/ \_______________________________/
|
|
10
|
+
* route + label content the path a LOCAL file
|
|
11
|
+
* address would have had
|
|
12
|
+
*
|
|
13
|
+
* Three things follow from that shape, and each is load-bearing:
|
|
14
|
+
*
|
|
15
|
+
* - **`media.ts` needs no change.** `isRemote` is `!path.startsWith("/public")`,
|
|
16
|
+
* and this does not, so `Internal.mediaUrl` returns the ref as-is and Val's
|
|
17
|
+
* route serves it. The media rule that has been got wrong repeatedly is left
|
|
18
|
+
* exactly alone.
|
|
19
|
+
* - **Moving between storage modes is mechanical.** External → local reads the
|
|
20
|
+
* `public/…` suffix back out, fetches the bytes and writes them there; local →
|
|
21
|
+
* external uploads the file already at that path. Nothing is renamed.
|
|
22
|
+
* - **The filename is Val's, not the adapter's**, produced by the same
|
|
23
|
+
* `createFilename` a local or remote file uses — so the same bytes get the
|
|
24
|
+
* same name under all three storage modes.
|
|
25
|
+
*/
|
|
26
|
+
export type ExternalFileRefParts = {
|
|
27
|
+
/** The `.external(label)` of the record the file belongs to. */
|
|
28
|
+
label: string;
|
|
29
|
+
/** SHA-256 of the bytes. Content-addressed, so a retried publish re-uses. */
|
|
30
|
+
fileHash: string;
|
|
31
|
+
/** The virtual path, WITHOUT a leading slash: `public/val/...`. */
|
|
32
|
+
filePath: `public/${string}`;
|
|
33
|
+
};
|
|
34
|
+
export declare function createExternalFileRef({ label, fileHash, filePath, }: {
|
|
35
|
+
label: string;
|
|
36
|
+
fileHash: string;
|
|
37
|
+
/** Accepts the path as it is written in a module: `/public/val/...`. */
|
|
38
|
+
filePath: string;
|
|
39
|
+
}): string;
|
|
40
|
+
export declare function splitExternalFileRef(ref: string): ({
|
|
41
|
+
status: "success";
|
|
42
|
+
} & ExternalFileRefParts) | {
|
|
43
|
+
status: "error";
|
|
44
|
+
error: string;
|
|
45
|
+
};
|
|
46
|
+
export declare function isExternalFileRef(ref: string): boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { ExternalRecordSrc } from "./external.js";
|
|
1
2
|
import { JsonSource } from "./json.js";
|
|
2
3
|
import { MediaSource } from "./media.js";
|
|
3
4
|
import { RichTextOptions, RichTextSource } from "./richtext.js";
|
|
4
5
|
import { SettingsSource } from "./settings.js";
|
|
5
|
-
export type Source = SourcePrimitive | SourceObject | SourceArray | MediaSource | JsonSource | SettingsSource | RichTextSource<RichTextOptions>;
|
|
6
|
+
export type Source = SourcePrimitive | SourceObject | SourceArray | MediaSource | JsonSource | ExternalRecordSrc | SettingsSource | RichTextSource<RichTextOptions>;
|
|
6
7
|
export type SourceObject = {
|
|
7
8
|
[key in string]: Source;
|
|
8
9
|
} & {
|
|
@@ -22,7 +23,7 @@ export type SourceObject = {
|
|
|
22
23
|
export type SourceArray = readonly Source[];
|
|
23
24
|
export type SourcePrimitive = string | number | boolean | null;
|
|
24
25
|
export declare const VAL_EXTENSION: "_type";
|
|
25
|
-
export declare function getValExtension(source: Source): false | "" | 0 | "json" | null | undefined;
|
|
26
|
+
export declare function getValExtension(source: Source): false | "" | 0 | "json" | "external" | null | undefined;
|
|
26
27
|
/**
|
|
27
28
|
* A phantom type parameter is one that doesn't show up at runtime, but is checked statically (and only) at compile time.
|
|
28
29
|
*
|