@protobase/schema 0.15.1 → 0.15.2
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/fields/file.js +4 -1
- package/dist/file-field.d.ts +6 -0
- package/dist/file-field.js +8 -0
- package/dist/files/file-options.d.ts +2 -0
- package/dist/model.d.ts +2 -0
- package/dist/resource-model.js +2 -1
- package/package.json +1 -1
package/dist/fields/file.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/fields/file.ts
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A file column holds `{provider}:{path}?name=…&size=…` as text, or an https URL with `.externalUrls()`; writes send a
|
|
5
|
+
* ticket from `:upload` instead.
|
|
6
|
+
*/
|
|
4
7
|
const file = {
|
|
5
8
|
type: "file",
|
|
6
9
|
constraints: [],
|
package/dist/file-field.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export declare class FileField<V> extends Field<V> {
|
|
|
27
27
|
* format: 'webp' } }`. `{ original }` stores that image instead of the upload. Other files get none.
|
|
28
28
|
*/
|
|
29
29
|
variants(variants: Record<string, ImageVariant>, options?: ImageVariantOptions): FileField<V>;
|
|
30
|
+
/**
|
|
31
|
+
* Also takes an https URL of a file elsewhere, such as `https://images.example.com/photos/42.jpg`, stored as it is:
|
|
32
|
+
* never uploaded, without variants, and drawn from that address. See
|
|
33
|
+
* [External URLs](website/src/content/docs/reference/files.mdx#external-urls).
|
|
34
|
+
*/
|
|
35
|
+
externalUrls(): FileField<V>;
|
|
30
36
|
/** The column is nullable: the field may hold no file. */
|
|
31
37
|
optional(): FileField<V | null>;
|
|
32
38
|
/** Never written through the API. */
|
package/dist/file-field.js
CHANGED
|
@@ -49,6 +49,14 @@ var FileField = class FileField extends Field {
|
|
|
49
49
|
...options.original && { original: checkedVariant("The original", options.original) }
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Also takes an https URL of a file elsewhere, such as `https://images.example.com/photos/42.jpg`, stored as it is:
|
|
54
|
+
* never uploaded, without variants, and drawn from that address. See
|
|
55
|
+
* [External URLs](website/src/content/docs/reference/files.mdx#external-urls).
|
|
56
|
+
*/
|
|
57
|
+
externalUrls() {
|
|
58
|
+
return this.withFile({ external: true });
|
|
59
|
+
}
|
|
52
60
|
/** The column is nullable: the field may hold no file. */
|
|
53
61
|
optional() {
|
|
54
62
|
return this.with({ nullable: true });
|
|
@@ -64,6 +64,8 @@ export type FileOptions = {
|
|
|
64
64
|
variants?: Record<string, ImageVariant>;
|
|
65
65
|
/** The image stored instead of the upload (`.variants()`' `original`). */
|
|
66
66
|
original?: ImageVariant;
|
|
67
|
+
/** Whether a value may also be an https URL of a file elsewhere (`.externalUrls()`). */
|
|
68
|
+
external?: true;
|
|
67
69
|
};
|
|
68
70
|
/** Bytes from a number or text such as `10 MB` (decimal units) or `5 MiB` (binary units). */
|
|
69
71
|
export declare const parseSize: (size: number | string) => number;
|
package/dist/model.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export type FileFieldModel = {
|
|
|
61
61
|
variants?: Record<string, ImageVariant>;
|
|
62
62
|
/** What is stored instead of an uploaded image, when the upload is not kept. */
|
|
63
63
|
original?: ImageVariant;
|
|
64
|
+
/** Whether a value may also be an https URL of a file elsewhere, drawn and linked as it is (`.externalUrls()`). */
|
|
65
|
+
external?: true;
|
|
64
66
|
};
|
|
65
67
|
/** `digitsEnd`: only the end of the value's digits, spaces, `+` and dashes ignored (phone numbers). */
|
|
66
68
|
export type SearchMatch = 'digitsEnd';
|
package/dist/resource-model.js
CHANGED
|
@@ -38,7 +38,8 @@ const fieldModel = (name, field) => {
|
|
|
38
38
|
...writtenFields(meta.file).length > 0 && { derive: writtenFields(meta.file) },
|
|
39
39
|
...meta.file.placeholder !== void 0 && { placeholder: meta.file.placeholder },
|
|
40
40
|
...meta.file.variants && Object.keys(meta.file.variants).length > 0 && { variants: structuredClone(meta.file.variants) },
|
|
41
|
-
...meta.file.original && { original: { ...meta.file.original } }
|
|
41
|
+
...meta.file.original && { original: { ...meta.file.original } },
|
|
42
|
+
...meta.file.external && { external: true }
|
|
42
43
|
} }
|
|
43
44
|
};
|
|
44
45
|
};
|