@rebasepro/types 0.23.0 → 0.24.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/dist/controllers/client.d.ts +48 -17
- package/dist/controllers/collection_registry.d.ts +17 -0
- package/dist/controllers/data.d.ts +161 -49
- package/dist/controllers/storage.d.ts +132 -13
- package/dist/errors.d.ts +15 -1
- package/dist/index.es.js +1094 -37
- package/dist/index.es.js.map +1 -1
- package/dist/types/admin_block.d.ts +1 -1
- package/dist/types/api_keys.d.ts +68 -36
- package/dist/types/auth_adapter.d.ts +65 -1
- package/dist/types/backend.d.ts +177 -6
- package/dist/types/backup.d.ts +83 -0
- package/dist/types/collection_patch.d.ts +74 -0
- package/dist/types/collections.d.ts +23 -0
- package/dist/types/cron.d.ts +39 -3
- package/dist/types/database_adapter.d.ts +2 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/project_manifest.d.ts +65 -1
- package/dist/types/properties.d.ts +11 -0
- package/dist/types/schema_editing.d.ts +39 -13
- package/dist/types/scopes.d.ts +272 -0
- package/dist/types/storage_authorize.d.ts +5 -1
- package/dist/users/user.d.ts +7 -0
- package/package.json +1 -1
|
@@ -8,13 +8,135 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const PUBLIC_STORAGE_PREFIX = "public/";
|
|
10
10
|
/**
|
|
11
|
-
* True when a storage key
|
|
12
|
-
* {@link PUBLIC_STORAGE_PREFIX}
|
|
13
|
-
*
|
|
11
|
+
* True when a storage **key** is public: it lies under
|
|
12
|
+
* {@link PUBLIC_STORAGE_PREFIX}.
|
|
13
|
+
*
|
|
14
|
+
* The key is read exactly as it is — the canonical key within its bucket, the
|
|
15
|
+
* one the server stores, serves, and hands a `storageAuthorize` hook as
|
|
16
|
+
* `key` — and nothing is parsed out of it. That is the difference from
|
|
17
|
+
* {@link isPublicStoragePath}, which reads a client-side *path* and so strips
|
|
18
|
+
* a `scheme://` and a leading `default/` bucket segment first. On a key both are
|
|
19
|
+
* wrong: `default/public/x` is a key in a folder called `default`, and a
|
|
20
|
+
* request path `notes://public/x` names the key `notes:/public/x`. Neither is
|
|
21
|
+
* public, and the server decides on this function so that it never says they
|
|
22
|
+
* are.
|
|
23
|
+
*
|
|
24
|
+
* @group Models
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPublicStorageKey(key: string | null | undefined): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* True when a storage key or client-side path points at a public object
|
|
29
|
+
* (lives under {@link PUBLIC_STORAGE_PREFIX}).
|
|
30
|
+
*
|
|
31
|
+
* For a path as a client holds it: a `scheme://` prefix and a single leading
|
|
32
|
+
* `default/` bucket segment are stripped first. The server and a
|
|
33
|
+
* `storageAuthorize` hook, which hold the canonical key, use
|
|
34
|
+
* {@link isPublicStorageKey}.
|
|
14
35
|
*
|
|
15
36
|
* @group Models
|
|
16
37
|
*/
|
|
17
38
|
export declare function isPublicStoragePath(path: string | null | undefined): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The path the storage routes address an object by, from a key or from the
|
|
41
|
+
* `storageUrl` an upload returned (`<scheme>://<bucket>/<key>`, which is what a
|
|
42
|
+
* property with `includeBucketUrl: true` keeps in its column).
|
|
43
|
+
*
|
|
44
|
+
* The routes address a source's objects by key. On S3 and GCS the bucket in a
|
|
45
|
+
* `storageUrl` is always the source's own — the server refuses any other — so
|
|
46
|
+
* it is dropped: sent along, `s3://acme-media/products/a.png` reached the
|
|
47
|
+
* server as the key `acme-media/products/a.png`, the preview found nothing and
|
|
48
|
+
* a delete reported success while the object stayed. It worked on local disk
|
|
49
|
+
* only, because `local://default/<key>` happens to carry the one bucket
|
|
50
|
+
* segment the routes recognise — which is kept, as is any other local bucket.
|
|
51
|
+
*
|
|
52
|
+
* A bare key whose first folder is `default` is sent behind that bucket
|
|
53
|
+
* segment. The routes read one leading `default/` (in any case) as the bucket,
|
|
54
|
+
* so the key `default/photo.png` sent as it is names the root `photo.png`:
|
|
55
|
+
* {@link defaultBucketPath} is the spelling that names the key itself.
|
|
56
|
+
*
|
|
57
|
+
* Shared by every storage source that talks to those routes — the SDK's and
|
|
58
|
+
* the admin panel's `useBackendStorageSource` — so they address an object alike.
|
|
59
|
+
*
|
|
60
|
+
* @group Models
|
|
61
|
+
*/
|
|
62
|
+
export declare function storageObjectPath(keyOrUrl: string, bucket?: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* The scheme of a **storage reference**: a stored object named inside text.
|
|
65
|
+
*
|
|
66
|
+
* Text that embeds a file — a markdown body above all — cannot hold a private
|
|
67
|
+
* object's URL: that URL carries a download token which expires in minutes,
|
|
68
|
+
* after which every reader of the text gets a 401 for an image that is still in
|
|
69
|
+
* the bucket. It holds a reference instead,
|
|
70
|
+
* `rebase-storage:posts/cover.png` (`?storageId=media` for a named source),
|
|
71
|
+
* and whoever renders the text exchanges each reference for a fresh URL with
|
|
72
|
+
* {@link resolveStorageReferences} — `resolveStorageReferences(text, client)`
|
|
73
|
+
* from `@rebasepro/client` on a site.
|
|
74
|
+
*
|
|
75
|
+
* @group Models
|
|
76
|
+
*/
|
|
77
|
+
export declare const STORAGE_REFERENCE_SCHEME = "rebase-storage:";
|
|
78
|
+
/**
|
|
79
|
+
* The object a storage reference names.
|
|
80
|
+
*
|
|
81
|
+
* @group Models
|
|
82
|
+
*/
|
|
83
|
+
export interface StorageReferenceTarget {
|
|
84
|
+
/** The object's key in its storage source. */
|
|
85
|
+
key: string;
|
|
86
|
+
/** The named storage source holding it. Absent for the default source. */
|
|
87
|
+
storageId?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The reference for an object — what text stores in place of its URL.
|
|
91
|
+
*
|
|
92
|
+
* Every part is percent-encoded, so the reference contains no space,
|
|
93
|
+
* parenthesis or quote and survives as one markdown link destination whatever
|
|
94
|
+
* the file was called.
|
|
95
|
+
*
|
|
96
|
+
* @group Models
|
|
97
|
+
*/
|
|
98
|
+
export declare function storageReference(key: string, storageId?: string | null): string;
|
|
99
|
+
/**
|
|
100
|
+
* Whether a string — an image's `src`, a link's `href` — is a storage reference.
|
|
101
|
+
*
|
|
102
|
+
* @group Models
|
|
103
|
+
*/
|
|
104
|
+
export declare function isStorageReference(value: string | null | undefined): value is string;
|
|
105
|
+
/**
|
|
106
|
+
* The object a storage reference names, or `null` for anything else — a URL, a
|
|
107
|
+
* bare key, or a reference whose key would climb out of its prefix.
|
|
108
|
+
*
|
|
109
|
+
* @group Models
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseStorageReference(value: string | null | undefined): StorageReferenceTarget | null;
|
|
112
|
+
/**
|
|
113
|
+
* Where {@link resolveStorageReferences} gets URLs from: a function that
|
|
114
|
+
* answers one, or anything shaped like a Rebase client — its `storage` for the
|
|
115
|
+
* default source and `createStorageSource(id)` for a named one.
|
|
116
|
+
*
|
|
117
|
+
* @group Models
|
|
118
|
+
*/
|
|
119
|
+
export type StorageReferenceResolver = ((target: StorageReferenceTarget) => Promise<string | null | undefined>) | {
|
|
120
|
+
storage?: StorageSource;
|
|
121
|
+
createStorageSource?(storageId: string): StorageSource;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Exchange every storage reference in `text` for a URL, at the moment the text
|
|
125
|
+
* is rendered.
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* const html = markdown.render(await resolveStorageReferences(post.body, client));
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* Each distinct object is asked for once — `getSignedUrl(key)` on its source —
|
|
132
|
+
* so a private object gets a freshly minted download URL every time the text is
|
|
133
|
+
* rendered. A reference that cannot be resolved (no such object, an unknown
|
|
134
|
+
* source) is left as it was, so a missing object reads as a missing image
|
|
135
|
+
* rather than as a failed render.
|
|
136
|
+
*
|
|
137
|
+
* @group Models
|
|
138
|
+
*/
|
|
139
|
+
export declare function resolveStorageReferences(text: string, from: StorageReferenceResolver): Promise<string>;
|
|
18
140
|
/**
|
|
19
141
|
* @group Models
|
|
20
142
|
*/
|
|
@@ -35,18 +157,15 @@ export interface UploadFileProps {
|
|
|
35
157
|
* and the property path within it (`coverImage`, `meta.avatar`,
|
|
36
158
|
* `gallery` for an array of files).
|
|
37
159
|
*
|
|
38
|
-
* The server
|
|
39
|
-
* `storage.acceptedFiles
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
160
|
+
* The server holds the upload to that property's own `storage.maxSize`
|
|
161
|
+
* and `storage.acceptedFiles`. It holds every upload to the limits of the
|
|
162
|
+
* properties whose `storagePath` its key falls in anyway, named or not;
|
|
163
|
+
* naming the property adds that property's rule, which matters for a
|
|
164
|
+
* property whose `storagePath` is a function the server cannot read.
|
|
43
165
|
*
|
|
44
166
|
* Advisory in one direction only. The rules are resolved from the server's
|
|
45
|
-
* own registry by slug, so naming a property can make an upload *stricter
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* Omitted, the upload is checked against the deployment's global
|
|
49
|
-
* `maxFileSize` exactly as before.
|
|
167
|
+
* own registry by slug, so naming a property can make an upload *stricter*;
|
|
168
|
+
* it can never widen anything.
|
|
50
169
|
*/
|
|
51
170
|
context?: UploadPropertyContext;
|
|
52
171
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -23,7 +23,21 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @group Errors
|
|
25
25
|
*/
|
|
26
|
-
export type RebaseErrorCode = "BAD_REQUEST" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "INTERNAL_ERROR" | "SERVICE_UNAVAILABLE" | "NETWORK_ERROR" | "OFFLINE" | "DB_PERMISSION_DENIED" | "SCHEMA_DRIFT"
|
|
26
|
+
export type RebaseErrorCode = "BAD_REQUEST" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "INTERNAL_ERROR" | "SERVICE_UNAVAILABLE" | "NETWORK_ERROR" | "OFFLINE" | "DB_PERMISSION_DENIED" | "SCHEMA_DRIFT"
|
|
27
|
+
/**
|
|
28
|
+
* Realtime: the socket closed after a request was written and before the
|
|
29
|
+
* server answered — the request may or may not have run, and it is never
|
|
30
|
+
* re-sent. On a live subscription's `onError`: the connection has been
|
|
31
|
+
* down longer than a blip; the subscription is kept and resumes, with a
|
|
32
|
+
* fresh `onUpdate`, when the socket is back.
|
|
33
|
+
*/
|
|
34
|
+
| "CONNECTION_LOST"
|
|
35
|
+
/**
|
|
36
|
+
* Realtime: no answer within the request timeout of the call — either it
|
|
37
|
+
* waited for a socket the whole time and was never sent, or it was written
|
|
38
|
+
* and never answered.
|
|
39
|
+
*/
|
|
40
|
+
| "REQUEST_TIMEOUT" | (string & {});
|
|
27
41
|
/**
|
|
28
42
|
* Structured initializer for {@link RebaseApiError}.
|
|
29
43
|
*
|