@rebasepro/types 0.24.0 → 0.24.1-canary.gcb918fc
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/call_context.d.ts +8 -4
- package/dist/controllers/client.d.ts +68 -10
- package/dist/controllers/data.d.ts +412 -76
- package/dist/controllers/data_driver.d.ts +85 -1
- package/dist/controllers/index.d.ts +1 -0
- package/dist/controllers/storage-references.d.ts +114 -0
- package/dist/controllers/storage.d.ts +20 -79
- package/dist/index.es.js +140 -12
- package/dist/index.es.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +32 -1
- package/dist/types/backend.d.ts +168 -4
- package/dist/types/backup.d.ts +19 -0
- package/dist/types/cron.d.ts +22 -7
- package/dist/types/database_adapter.d.ts +32 -6
- package/dist/types/entities.d.ts +11 -0
- package/dist/types/history.d.ts +15 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/project_manifest.d.ts +8 -0
- package/dist/types/properties.d.ts +28 -2
- package/dist/types/register.d.ts +43 -0
- package/dist/types/relations.d.ts +37 -1
- package/dist/types/resource_kinds.d.ts +7 -1
- package/dist/types/storage_authorize.d.ts +5 -0
- package/dist/types/websockets.d.ts +32 -1
- package/package.json +1 -1
package/dist/call_context.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { StorageSource } from "./controllers/storage.js";
|
|
|
3
3
|
import type { RebaseClient } from "./controllers/client.js";
|
|
4
4
|
import type { RebaseSdkData } from "./controllers/data.js";
|
|
5
5
|
import type { User } from "./users/index.js";
|
|
6
|
+
import type { RegisteredDatabase } from "./types/register.js";
|
|
6
7
|
/**
|
|
7
8
|
* The client a collection callback is handed as `context.client`: the Rebase
|
|
8
9
|
* client **without `data`**.
|
|
@@ -21,7 +22,7 @@ import type { User } from "./users/index.js";
|
|
|
21
22
|
*
|
|
22
23
|
* @group Hooks and utilities
|
|
23
24
|
*/
|
|
24
|
-
export type RebaseCallbackClient<DB =
|
|
25
|
+
export type RebaseCallbackClient<DB = RegisteredDatabase> = Omit<RebaseClient<DB>, "data">;
|
|
25
26
|
/**
|
|
26
27
|
* Context that is provided to entity callbacks (hooks).
|
|
27
28
|
* It contains only the dependencies that are available in both the frontend and the backend.
|
|
@@ -54,7 +55,7 @@ export type RebaseCallbackClient<DB = unknown> = Omit<RebaseClient<DB>, "data">;
|
|
|
54
55
|
*
|
|
55
56
|
* @group Hooks and utilities
|
|
56
57
|
*/
|
|
57
|
-
export type RebaseCallContext<USER extends User = User> = {
|
|
58
|
+
export type RebaseCallContext<USER extends User = User, DB = RegisteredDatabase> = {
|
|
58
59
|
/**
|
|
59
60
|
* The Rebase client instance.
|
|
60
61
|
* Available in all entity callbacks (beforeSave, afterSave, afterRead,
|
|
@@ -81,7 +82,7 @@ export type RebaseCallContext<USER extends User = User> = {
|
|
|
81
82
|
* const { client } = props.context;
|
|
82
83
|
* const result = await client.functions.invoke('extract-job', { url });
|
|
83
84
|
*/
|
|
84
|
-
client: RebaseCallbackClient
|
|
85
|
+
client: RebaseCallbackClient<DB>;
|
|
85
86
|
/**
|
|
86
87
|
* Unified data access — `context.data.products.create(...)`.
|
|
87
88
|
* Access any collection as a dynamic property.
|
|
@@ -119,8 +120,11 @@ export type RebaseCallContext<USER extends User = User> = {
|
|
|
119
120
|
* frontend SDK client — so `context.data` in a backend callback and
|
|
120
121
|
* `client.data` in the frontend are accessed the same way (`row.title`,
|
|
121
122
|
* never `row.values.title`). Shape only: privilege differs as above.
|
|
123
|
+
*
|
|
124
|
+
* Untyped until the project registers its generated `Database` on
|
|
125
|
+
* {@link Register}; typed from it from then on.
|
|
122
126
|
*/
|
|
123
|
-
data: RebaseSdkData
|
|
127
|
+
data: RebaseSdkData<DB>;
|
|
124
128
|
/**
|
|
125
129
|
* The driver executing the operation this callback is attached to.
|
|
126
130
|
*
|
|
@@ -3,11 +3,12 @@ import type { ResourceRef } from "../types/resources.js";
|
|
|
3
3
|
import type { RebaseSdkData } from "./data.js";
|
|
4
4
|
import type { EmailService } from "./email.js";
|
|
5
5
|
import type { StorageSource } from "./storage.js";
|
|
6
|
-
import type { CronJobStatus, CronJobLogEntry, CronJobListing } from "../types/cron.js";
|
|
7
|
-
import type { BackupListing } from "../types/backup.js";
|
|
6
|
+
import type { CronJobStatus, CronJobLogEntry, CronJobListing, CronJobStarted } from "../types/cron.js";
|
|
7
|
+
import type { BackupDownloadLink, BackupListing } from "../types/backup.js";
|
|
8
8
|
import type { ApiKeysAPI, PersonalKeysAPI } from "../types/api_keys.js";
|
|
9
9
|
import type { RoleSummary } from "../types/scopes.js";
|
|
10
10
|
import type { StorageSourceDefinition } from "../types/storage_source.js";
|
|
11
|
+
import type { RegisteredDatabase } from "../types/register.js";
|
|
11
12
|
/**
|
|
12
13
|
* Event type for authentication state changes
|
|
13
14
|
*/
|
|
@@ -148,6 +149,18 @@ export interface AdminUser {
|
|
|
148
149
|
createdAt: string;
|
|
149
150
|
updatedAt: string;
|
|
150
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* A user as the user picker sees one (`GET /admin/users/pick`): who the person
|
|
154
|
+
* is, and nothing about their account — no roles, no status, no timestamps.
|
|
155
|
+
*
|
|
156
|
+
* @group Admin
|
|
157
|
+
*/
|
|
158
|
+
export interface PickedUser {
|
|
159
|
+
uid: string;
|
|
160
|
+
email: string;
|
|
161
|
+
displayName: string | null;
|
|
162
|
+
photoURL: string | null;
|
|
163
|
+
}
|
|
151
164
|
/**
|
|
152
165
|
* Client-side Admin API interface.
|
|
153
166
|
* Provides user management operations.
|
|
@@ -180,6 +193,9 @@ export interface AdminAPI {
|
|
|
180
193
|
metadata?: Record<string, any>;
|
|
181
194
|
}): Promise<{
|
|
182
195
|
user: AdminUser;
|
|
196
|
+
temporaryPassword?: string;
|
|
197
|
+
invitationSent?: boolean;
|
|
198
|
+
emailDeliveryFailed?: boolean;
|
|
183
199
|
}>;
|
|
184
200
|
updateUser(uid: string, data: {
|
|
185
201
|
email?: string;
|
|
@@ -224,10 +240,25 @@ export interface CronAPI {
|
|
|
224
240
|
getJob(jobId: string): Promise<{
|
|
225
241
|
job: CronJobStatus;
|
|
226
242
|
}>;
|
|
227
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Run a job now and wait for it to finish. A proxy in front of the server
|
|
245
|
+
* may cut a long run's answer short while the run carries on; pass
|
|
246
|
+
* `{ async: true }` for those.
|
|
247
|
+
*/
|
|
248
|
+
triggerJob(jobId: string, options?: {
|
|
249
|
+
async?: false;
|
|
250
|
+
}): Promise<{
|
|
228
251
|
log: CronJobLogEntry;
|
|
229
252
|
job: CronJobStatus;
|
|
230
253
|
}>;
|
|
254
|
+
/**
|
|
255
|
+
* Start a job now and answer as soon as it has started. Read its outcome
|
|
256
|
+
* from {@link CronAPI.getJobLogs}: the entry with `manual: true` and the
|
|
257
|
+
* returned `startedAt`.
|
|
258
|
+
*/
|
|
259
|
+
triggerJob(jobId: string, options: {
|
|
260
|
+
async: true;
|
|
261
|
+
}): Promise<CronJobStarted>;
|
|
231
262
|
getJobLogs(jobId: string, options?: {
|
|
232
263
|
limit?: number;
|
|
233
264
|
}): Promise<{
|
|
@@ -247,8 +278,20 @@ export interface BackupsAPI {
|
|
|
247
278
|
* the scheduled backup job's last run.
|
|
248
279
|
*/
|
|
249
280
|
list(): Promise<BackupListing>;
|
|
250
|
-
/**
|
|
251
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Save a backup in the browser: the browser is sent to a
|
|
283
|
+
* {@link downloadUrl} link and streams the dump to disk; the page never
|
|
284
|
+
* holds it. Browser only — elsewhere use {@link stream} or {@link downloadUrl}.
|
|
285
|
+
*/
|
|
286
|
+
download(key: string): Promise<void>;
|
|
287
|
+
/** A link to one backup's bytes, good for 60 seconds, that needs no `Authorization` header. */
|
|
288
|
+
downloadUrl(key: string): Promise<BackupDownloadLink>;
|
|
289
|
+
/** A backup's bytes as a stream, read as consumed — to write one to a file outside a browser. */
|
|
290
|
+
stream(key: string): Promise<{
|
|
291
|
+
stream: ReadableStream<Uint8Array>;
|
|
292
|
+
size?: number;
|
|
293
|
+
name: string;
|
|
294
|
+
}>;
|
|
252
295
|
}
|
|
253
296
|
/**
|
|
254
297
|
* Options for invoking a custom backend function.
|
|
@@ -261,6 +304,15 @@ export interface FunctionInvokeOptions {
|
|
|
261
304
|
path?: string;
|
|
262
305
|
/** Extra headers merged into the request. */
|
|
263
306
|
headers?: Record<string, string>;
|
|
307
|
+
/**
|
|
308
|
+
* How to read the function's answer — defaults to `"json"`.
|
|
309
|
+
*
|
|
310
|
+
* A function is a Hono route, so it may answer `c.text(csv)` or
|
|
311
|
+
* `c.body(pdf)`: ask for `"text"` (a string), `"blob"` (a `Blob`) or
|
|
312
|
+
* `"response"` (the `Response` itself, body unread, for streaming or
|
|
313
|
+
* headers). An error status is thrown as a `RebaseApiError` in every mode.
|
|
314
|
+
*/
|
|
315
|
+
responseType?: "json" | "text" | "blob" | "response";
|
|
264
316
|
}
|
|
265
317
|
/**
|
|
266
318
|
* Client interface for invoking custom backend functions.
|
|
@@ -316,7 +368,12 @@ export interface RebaseWebSocket {
|
|
|
316
368
|
disconnect(): void;
|
|
317
369
|
/** Send an authentication token to the server. */
|
|
318
370
|
authenticate(token: string): Promise<void>;
|
|
319
|
-
/**
|
|
371
|
+
/**
|
|
372
|
+
* Set a function that lazily resolves the auth token for auto-authentication.
|
|
373
|
+
*
|
|
374
|
+
* @deprecated Use `client.setAuthTokenGetter()` instead, which authenticates
|
|
375
|
+
* HTTP requests and this socket together. Will be removed in a future release.
|
|
376
|
+
*/
|
|
320
377
|
setAuthTokenGetter(getter: () => Promise<string | null>): void;
|
|
321
378
|
/** Listen for connection lifecycle events. */
|
|
322
379
|
on(event: "connect" | "disconnect" | "reconnect" | "error", cb: (...args: unknown[]) => void): () => void;
|
|
@@ -488,7 +545,7 @@ export interface RebaseClient<DB = unknown> {
|
|
|
488
545
|
* connection, no policies. For user-scoped queries inside a request handler use
|
|
489
546
|
* the request-scoped driver (`c.var.driver`) instead — never `dataAsAdmin`.
|
|
490
547
|
*/
|
|
491
|
-
export interface RebaseServerClient<DB =
|
|
548
|
+
export interface RebaseServerClient<DB = RegisteredDatabase> extends Omit<RebaseClient<DB>, "data"> {
|
|
492
549
|
/**
|
|
493
550
|
* Admin-scoped data accessor (RLS is evaluated as the service identity, not
|
|
494
551
|
* skipped). Always present server-side. See {@link RebaseClient.dataAsAdmin}
|
|
@@ -561,10 +618,11 @@ export interface StorageSourceRegistry {
|
|
|
561
618
|
*/
|
|
562
619
|
getDefault(): StorageSource;
|
|
563
620
|
/**
|
|
564
|
-
* Get a storage source by key,
|
|
621
|
+
* Get a storage source by key, or the default one for no key.
|
|
565
622
|
* @param key - Storage source key, or undefined/null for default
|
|
566
|
-
* @returns The StorageSource
|
|
567
|
-
* @throws Error if
|
|
623
|
+
* @returns The StorageSource registered under `key` (the default for no key)
|
|
624
|
+
* @throws Error if `key` names no registered source — never the default in
|
|
625
|
+
* its place — or no key is given and no default is registered
|
|
568
626
|
*/
|
|
569
627
|
getOrDefault(key: string | undefined | null): StorageSource;
|
|
570
628
|
/** Check if a storage source with the given key exists */
|