@rebasepro/types 0.23.0 → 0.24.1-canary.g56af4a4
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 +107 -23
- package/dist/controllers/collection_registry.d.ts +17 -0
- package/dist/controllers/data.d.ts +570 -122
- 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 +73 -13
- package/dist/errors.d.ts +15 -1
- package/dist/index.es.js +1227 -43
- 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 +97 -2
- package/dist/types/backend.d.ts +291 -6
- package/dist/types/backup.d.ts +102 -0
- package/dist/types/collection_patch.d.ts +74 -0
- package/dist/types/collections.d.ts +23 -0
- package/dist/types/cron.d.ts +58 -7
- package/dist/types/database_adapter.d.ts +2 -2
- package/dist/types/entities.d.ts +11 -0
- package/dist/types/history.d.ts +15 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/project_manifest.d.ts +73 -1
- package/dist/types/properties.d.ts +39 -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/schema_editing.d.ts +39 -13
- package/dist/types/scopes.d.ts +272 -0
- package/dist/types/storage_authorize.d.ts +10 -1
- package/dist/types/websockets.d.ts +32 -1
- package/dist/users/user.d.ts +7 -0
- package/package.json +1 -1
package/dist/types/backend.d.ts
CHANGED
|
@@ -246,6 +246,42 @@ export interface RealtimeChannelsConfig {
|
|
|
246
246
|
* Defaults to `{ type: "memory" }` — i.e. they don't.
|
|
247
247
|
*/
|
|
248
248
|
bus?: ChannelBusSetting;
|
|
249
|
+
/**
|
|
250
|
+
* How many subscriptions one socket may hold; the next is refused with
|
|
251
|
+
* `TOO_MANY_SUBSCRIPTIONS`. A positive whole number, checked at boot.
|
|
252
|
+
* Defaults to 1000. `REALTIME_MAX_SUBSCRIPTIONS_PER_SOCKET` wins over it.
|
|
253
|
+
*/
|
|
254
|
+
maxSubscriptionsPerSocket?: number;
|
|
255
|
+
/**
|
|
256
|
+
* How many sockets one user (one identity: a signed-in user, an API key's
|
|
257
|
+
* user, an impersonated user) may hold open on one server instance. The
|
|
258
|
+
* next one's `AUTHENTICATE` is refused with `TOO_MANY_SOCKETS` and the
|
|
259
|
+
* socket closed with 4002; the SDK keeps retrying with backoff, so it gets
|
|
260
|
+
* in once another closes. A positive whole number, checked at boot.
|
|
261
|
+
* Unset (the default) is no ceiling. `REALTIME_MAX_SOCKETS_PER_USER` wins
|
|
262
|
+
* over it.
|
|
263
|
+
*/
|
|
264
|
+
maxSocketsPerUser?: number;
|
|
265
|
+
/**
|
|
266
|
+
* The longest a change waits for the refetch that delivers it, in ms. A
|
|
267
|
+
* refetch waits for 300 ms without a change, and at most this long under a
|
|
268
|
+
* steady stream of writes. Defaults to 1000. A positive whole number,
|
|
269
|
+
* checked at boot. `REALTIME_REFETCH_MAX_WAIT_MS` wins over it.
|
|
270
|
+
*/
|
|
271
|
+
refetchMaxWaitMs?: number;
|
|
272
|
+
/**
|
|
273
|
+
* How long a big list subscription's total may be reused before it is
|
|
274
|
+
* counted again, in ms. Unset (the default), every frame counts. Frames
|
|
275
|
+
* that reuse it carry `meta.totalAsOf`. `REALTIME_RECOUNT_INTERVAL_MS`
|
|
276
|
+
* wins over it.
|
|
277
|
+
*/
|
|
278
|
+
recountIntervalMs?: number;
|
|
279
|
+
/**
|
|
280
|
+
* The smallest last total at which {@link recountIntervalMs} applies;
|
|
281
|
+
* smaller lists are counted on every frame. Defaults to 100 000.
|
|
282
|
+
* `REALTIME_RECOUNT_MIN_ROWS` wins over it.
|
|
283
|
+
*/
|
|
284
|
+
recountMinRows?: number;
|
|
249
285
|
}
|
|
250
286
|
/**
|
|
251
287
|
* Abstract realtime provider interface.
|
|
@@ -293,6 +329,25 @@ export interface RealtimeProvider {
|
|
|
293
329
|
* Called during graceful shutdown before closing database connections.
|
|
294
330
|
*/
|
|
295
331
|
stopListening?(): Promise<void>;
|
|
332
|
+
/**
|
|
333
|
+
* The long-lived connections realtime depends on, for `/health`. A change
|
|
334
|
+
* feed that has gone quiet — a half-open LISTEN connection — loses every
|
|
335
|
+
* external and cross-instance change while writes through this instance
|
|
336
|
+
* still look live, so it is reported rather than inferred.
|
|
337
|
+
*/
|
|
338
|
+
health?(): RealtimeListenerHealth[];
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* One long-lived realtime connection, as `/health` reports it.
|
|
342
|
+
* @group Backend
|
|
343
|
+
*/
|
|
344
|
+
export interface RealtimeListenerHealth {
|
|
345
|
+
/** What it carries — `"cdc"`, `"cross-instance"`, `"channel-bus"`. */
|
|
346
|
+
name: string;
|
|
347
|
+
/** Listening on a connection that answered its last heartbeat. */
|
|
348
|
+
connected: boolean;
|
|
349
|
+
/** When (epoch ms) it went down, while it is down. */
|
|
350
|
+
downSince?: number;
|
|
296
351
|
}
|
|
297
352
|
/**
|
|
298
353
|
* Abstract collection registry interface.
|
|
@@ -341,6 +396,124 @@ export interface DataTransformer {
|
|
|
341
396
|
*/
|
|
342
397
|
deserializeFromDatabase<M extends Record<string, unknown>>(data: Record<string, unknown>, collection: CollectionConfig): Promise<M>;
|
|
343
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* The table column a value of a {@link SqlScriptResult} was read from, as the
|
|
401
|
+
* database itself reported it — not as the query's text suggests.
|
|
402
|
+
*
|
|
403
|
+
* @group Admin
|
|
404
|
+
*/
|
|
405
|
+
export interface SqlScriptColumnSource {
|
|
406
|
+
schema: string;
|
|
407
|
+
table: string;
|
|
408
|
+
column: string;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* One column of a {@link SqlScriptResult}, in result order.
|
|
412
|
+
*
|
|
413
|
+
* @group Admin
|
|
414
|
+
*/
|
|
415
|
+
export interface SqlScriptColumn {
|
|
416
|
+
/** The name the result gives it. Two columns of one result may share it. */
|
|
417
|
+
name: string;
|
|
418
|
+
/** Its type, as the database names it: `integer`, `text[]`, `timestamp with time zone`. */
|
|
419
|
+
type?: string;
|
|
420
|
+
/**
|
|
421
|
+
* Where the database says the value came from: a plain reference to a
|
|
422
|
+
* column of a table or view, through any number of subqueries.
|
|
423
|
+
*
|
|
424
|
+
* Absent for everything no stored row holds — an expression, a cast that
|
|
425
|
+
* changes the type, a literal, an aggregate, a function's output, a
|
|
426
|
+
* `UNION`.
|
|
427
|
+
*/
|
|
428
|
+
source?: SqlScriptColumnSource;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* A table or view some column of a {@link SqlScriptResult} came from.
|
|
432
|
+
*
|
|
433
|
+
* @group Admin
|
|
434
|
+
*/
|
|
435
|
+
export interface SqlScriptTable {
|
|
436
|
+
schema: string;
|
|
437
|
+
table: string;
|
|
438
|
+
/** What the relation is. Only a `table` or a `partitioned table` holds rows that can be updated by key. */
|
|
439
|
+
kind: "table" | "partitioned table" | "view" | "materialized view" | "foreign table" | "other";
|
|
440
|
+
/** Its primary key columns, in key order. Empty when it has none. */
|
|
441
|
+
primaryKey: string[];
|
|
442
|
+
/**
|
|
443
|
+
* Other tables inherit this one (by `INHERITS`, not as partitions). A row
|
|
444
|
+
* read from it may live in one of them, and a primary key is not unique
|
|
445
|
+
* across them.
|
|
446
|
+
*/
|
|
447
|
+
hasInheritors: boolean;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Something the database said while a script ran: `there is no transaction in
|
|
451
|
+
* progress` for a ROLLBACK with nothing to end, a `RAISE NOTICE`.
|
|
452
|
+
*
|
|
453
|
+
* @group Admin
|
|
454
|
+
*/
|
|
455
|
+
export interface SqlScriptNotice {
|
|
456
|
+
severity: string;
|
|
457
|
+
message: string;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* What a SQL script a person wrote returned. See {@link SQLAdmin.runSqlScript}.
|
|
461
|
+
*
|
|
462
|
+
* @group Admin
|
|
463
|
+
*/
|
|
464
|
+
export interface SqlScriptResult {
|
|
465
|
+
/**
|
|
466
|
+
* The last statement's rows, every value as the text the database wrote
|
|
467
|
+
* for it and `null` for SQL NULL — so a value written back is the value
|
|
468
|
+
* that was read, whatever its type. Keyed by column name: of two columns
|
|
469
|
+
* that share a name, the row holds the last.
|
|
470
|
+
*/
|
|
471
|
+
rows: Record<string, string | null>[];
|
|
472
|
+
/** The last statement's columns, in order. */
|
|
473
|
+
columns: SqlScriptColumn[];
|
|
474
|
+
/** The tables and views {@link SqlScriptColumn.source} names. */
|
|
475
|
+
tables: SqlScriptTable[];
|
|
476
|
+
/** The last statement's command: `SELECT`, `UPDATE`, `CREATE TABLE` … */
|
|
477
|
+
command?: string;
|
|
478
|
+
/**
|
|
479
|
+
* How many rows the last statement returned or changed, when its command
|
|
480
|
+
* reports a count — or, for a {@link truncated} result, how many it
|
|
481
|
+
* returned, of which {@link rows} holds the first.
|
|
482
|
+
*/
|
|
483
|
+
rowCount?: number;
|
|
484
|
+
/**
|
|
485
|
+
* The last statement returned more than a run keeps, and {@link rows}
|
|
486
|
+
* holds only its first rows. The Studio console's door keeps at most
|
|
487
|
+
* 10,000 rows, or 32 Mi characters of values, of one result: a run that
|
|
488
|
+
* held every row of a million-row table took the server down with it.
|
|
489
|
+
*/
|
|
490
|
+
truncated?: boolean;
|
|
491
|
+
/** What the database said while the script ran, in order. */
|
|
492
|
+
notices: SqlScriptNotice[];
|
|
493
|
+
/**
|
|
494
|
+
* The database role the script ran as, when it asked for one — said by
|
|
495
|
+
* the transport that ran it. The role asked for, unless the server has
|
|
496
|
+
* role switching turned off (`DISABLE_DB_ROLE_SWITCHING`) and runs every
|
|
497
|
+
* statement as the connection owner, who is named here instead.
|
|
498
|
+
*/
|
|
499
|
+
effectiveRole?: string;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* A query's result being read a batch at a time — see `SQLAdmin.openSqlCursor`.
|
|
503
|
+
*
|
|
504
|
+
* @group Admin
|
|
505
|
+
*/
|
|
506
|
+
export interface SqlCursor {
|
|
507
|
+
/** The result's column names, in order. */
|
|
508
|
+
readonly columns: string[];
|
|
509
|
+
/**
|
|
510
|
+
* The next rows, each value the text the database wrote for it and `null`
|
|
511
|
+
* for NULL — `null` once there are none left.
|
|
512
|
+
*/
|
|
513
|
+
read(): Promise<(string | null)[][] | null>;
|
|
514
|
+
/** End the read and give the session back. Safe to call more than once. */
|
|
515
|
+
close(): Promise<void>;
|
|
516
|
+
}
|
|
344
517
|
/**
|
|
345
518
|
* Administrative operations for SQL-based databases (PostgreSQL, MySQL, etc.).
|
|
346
519
|
* Used by the SQL Editor, RLS Editor, and schema browser.
|
|
@@ -356,13 +529,60 @@ export interface SQLAdmin {
|
|
|
356
529
|
* before it is reused. For SQL a person wrote (the Studio editor), which
|
|
357
530
|
* may `SET ROLE` and must not leave that on a pooled connection the
|
|
358
531
|
* server's own queries use next.
|
|
532
|
+
*
|
|
533
|
+
* `maxResultBytes` refuses a result whose rows take more than that many
|
|
534
|
+
* bytes, with an error whose `code` is `RESULT_TOO_LARGE`, rather than
|
|
535
|
+
* return it — never a part of it. On a session of its own the read stops
|
|
536
|
+
* there; elsewhere the rows are measured once read. The WebSocket
|
|
537
|
+
* `EXECUTE_SQL` door sets it for every caller.
|
|
359
538
|
*/
|
|
360
539
|
executeSql(sql: string, options?: {
|
|
361
540
|
database?: string;
|
|
362
541
|
role?: string;
|
|
363
542
|
params?: unknown[];
|
|
364
543
|
isolateSession?: boolean;
|
|
544
|
+
maxResultBytes?: number;
|
|
365
545
|
}): Promise<Record<string, unknown>[]>;
|
|
546
|
+
/**
|
|
547
|
+
* Run a script a person wrote — the Studio SQL console — and describe what
|
|
548
|
+
* it returned.
|
|
549
|
+
*
|
|
550
|
+
* On a session of its own, reset afterwards, as `role` for every statement
|
|
551
|
+
* of it. Values come back as the database's text, and each column says
|
|
552
|
+
* which table column it was read from, when the database says so: what
|
|
553
|
+
* the console needs to write a cell back to the row it came from and to
|
|
554
|
+
* no other. A script that leaves a transaction open is refused, and the
|
|
555
|
+
* transaction rolled back: nothing outlives the run to be committed or
|
|
556
|
+
* rolled back by a later one.
|
|
557
|
+
*
|
|
558
|
+
* Aborting `signal` cancels the run: the statement in progress is stopped
|
|
559
|
+
* (`pg_cancel_backend` on a Postgres server; the in-process development
|
|
560
|
+
* database cannot be interrupted, and the run ends on its own), and the
|
|
561
|
+
* promise rejects.
|
|
562
|
+
*/
|
|
563
|
+
runSqlScript?(sql: string, options?: {
|
|
564
|
+
database?: string;
|
|
565
|
+
role?: string;
|
|
566
|
+
signal?: AbortSignal;
|
|
567
|
+
}): Promise<SqlScriptResult>;
|
|
568
|
+
/**
|
|
569
|
+
* Read the whole result of ONE query a person wrote, a batch at a time —
|
|
570
|
+
* the Studio SQL console's "Download full result as CSV", which the
|
|
571
|
+
* console's 10,000-row cap would otherwise leave no way to get.
|
|
572
|
+
*
|
|
573
|
+
* Through a server-side cursor, in a read-only transaction, on a session
|
|
574
|
+
* of its own, as `role`: a write is refused by the database, and a second
|
|
575
|
+
* statement by the protocol. Each batch is read when the previous one has
|
|
576
|
+
* been consumed, so memory holds one batch whatever the result's size;
|
|
577
|
+
* every read runs under the session's `statement_timeout`. The session is
|
|
578
|
+
* reset and returned when the cursor is closed — which the caller must do,
|
|
579
|
+
* on success, failure or a reader that went away.
|
|
580
|
+
*/
|
|
581
|
+
openSqlCursor?(sql: string, options?: {
|
|
582
|
+
database?: string;
|
|
583
|
+
role?: string;
|
|
584
|
+
batchSize?: number;
|
|
585
|
+
}): Promise<SqlCursor>;
|
|
366
586
|
/**
|
|
367
587
|
* Fetch the available databases on the server.
|
|
368
588
|
*/
|
|
@@ -388,6 +608,21 @@ export interface SQLAdmin {
|
|
|
388
608
|
* Fetch the current database name.
|
|
389
609
|
*/
|
|
390
610
|
fetchCurrentDatabase?(): Promise<string | undefined>;
|
|
611
|
+
/**
|
|
612
|
+
* Hold a `LISTEN` on `channel`, on a connection of its own that stays open
|
|
613
|
+
* and comes back after a drop, and call `onNotify` with each payload — what
|
|
614
|
+
* wakes the job worker when another process enqueues, instead of a poll
|
|
615
|
+
* every two seconds.
|
|
616
|
+
*
|
|
617
|
+
* Resolves once listening, with the stop. Rejects when no such connection
|
|
618
|
+
* can be had — an in-process database, a first connect that fails — so the
|
|
619
|
+
* caller can fall back to polling. `onReconnect` is called each time a
|
|
620
|
+
* dropped connection is listening again: whatever was sent meanwhile is
|
|
621
|
+
* lost. `channel` must be a plain identifier.
|
|
622
|
+
*/
|
|
623
|
+
listen?(channel: string, onNotify: (payload: string) => void, options?: {
|
|
624
|
+
onReconnect?: () => void;
|
|
625
|
+
}): Promise<() => Promise<void>>;
|
|
391
626
|
}
|
|
392
627
|
/**
|
|
393
628
|
* Administrative operations for document-based databases (MongoDB, Firestore, etc.).
|
|
@@ -433,6 +668,12 @@ export interface SchemaAdmin {
|
|
|
433
668
|
export interface BranchInfo {
|
|
434
669
|
/** Branch name (without prefix). */
|
|
435
670
|
name: string;
|
|
671
|
+
/**
|
|
672
|
+
* The PostgreSQL database the branch is — what to connect to, and what to
|
|
673
|
+
* name as the source when copying it. As the branch's record says, never
|
|
674
|
+
* derived from `name` again.
|
|
675
|
+
*/
|
|
676
|
+
database: string;
|
|
436
677
|
/** The database this branch was created from. */
|
|
437
678
|
parentDatabase: string;
|
|
438
679
|
/** When the branch was created. */
|
|
@@ -598,6 +839,15 @@ export interface DataRateLimitCaller {
|
|
|
598
839
|
* the caller by address at the anonymous allowance.
|
|
599
840
|
*/
|
|
600
841
|
uid?: string;
|
|
842
|
+
/**
|
|
843
|
+
* The API key the connection authenticated with. Its frames count in the
|
|
844
|
+
* key's own bucket at the key's own `rate_limit`, the bucket its HTTP
|
|
845
|
+
* requests count in, rather than as `uid`.
|
|
846
|
+
*/
|
|
847
|
+
apiKey?: {
|
|
848
|
+
id: string;
|
|
849
|
+
rate_limit: number | null;
|
|
850
|
+
};
|
|
601
851
|
/**
|
|
602
852
|
* A header of the request that opened the connection, by lower-case name:
|
|
603
853
|
* the proxy headers an address is read from when proxies are declared.
|
|
@@ -607,11 +857,30 @@ export interface DataRateLimitCaller {
|
|
|
607
857
|
socketAddress?: string;
|
|
608
858
|
}
|
|
609
859
|
/**
|
|
610
|
-
*
|
|
611
|
-
*
|
|
860
|
+
* What the realtime socket shares with the HTTP data API: its request limits,
|
|
861
|
+
* so a frame carries the ones an HTTP request to the same rows does, and its
|
|
862
|
+
* API-key verification, so a key means the same thing on both.
|
|
612
863
|
* @group Backend
|
|
613
864
|
*/
|
|
614
|
-
export interface
|
|
865
|
+
export interface RealtimeSocketOptions {
|
|
866
|
+
/**
|
|
867
|
+
* Verify an `rk_` API key presented to `AUTHENTICATE`: the identity it acts
|
|
868
|
+
* as and the scopes it holds, or why it does not authenticate. Absent when
|
|
869
|
+
* the deployment has no API-key store, and then keys cannot authenticate
|
|
870
|
+
* the socket.
|
|
871
|
+
*/
|
|
872
|
+
resolveApiKey?: (token: string) => Promise<{
|
|
873
|
+
uid: string;
|
|
874
|
+
roles: string[];
|
|
875
|
+
scopes: string[];
|
|
876
|
+
/** The key itself: its id and `rate_limit` decide which rate-limit bucket its frames count in. */
|
|
877
|
+
apiKey?: {
|
|
878
|
+
id: string;
|
|
879
|
+
rate_limit: number | null;
|
|
880
|
+
};
|
|
881
|
+
} | {
|
|
882
|
+
message: string;
|
|
883
|
+
}>;
|
|
615
884
|
/**
|
|
616
885
|
* The largest frame accepted, in bytes — the data API's body limit. `0` or
|
|
617
886
|
* less for none. Defaults to the server's default body limit.
|
|
@@ -626,6 +895,24 @@ export interface RealtimeSocketLimits {
|
|
|
626
895
|
allowed: boolean;
|
|
627
896
|
retryAfterMs: number;
|
|
628
897
|
} | null>;
|
|
898
|
+
/**
|
|
899
|
+
* How often a socket that only listens has its identity re-read, in ms
|
|
900
|
+
* (default 30 000). A socket that sends frames is re-checked before each
|
|
901
|
+
* one; this bounds how long a subscription keeps receiving rows as an
|
|
902
|
+
* identity that has since signed out, been revoked, demoted or deleted.
|
|
903
|
+
*/
|
|
904
|
+
identityRecheckIntervalMs?: number;
|
|
905
|
+
/**
|
|
906
|
+
* How often a socket that asked for heartbeats (`?rebase_caps=heartbeat`)
|
|
907
|
+
* is sent one, in ms (default 30 000). The SDK redials after two missed.
|
|
908
|
+
*/
|
|
909
|
+
heartbeatIntervalMs?: number;
|
|
910
|
+
/**
|
|
911
|
+
* How many sockets one identity may hold open on this server; the next
|
|
912
|
+
* one's `AUTHENTICATE` is refused with `TOO_MANY_SOCKETS` and the socket
|
|
913
|
+
* closed (4002). Unset for no ceiling. See `realtime.maxSocketsPerUser`.
|
|
914
|
+
*/
|
|
915
|
+
maxSocketsPerUser?: number;
|
|
629
916
|
}
|
|
630
917
|
/**
|
|
631
918
|
* A `BackendBootstrapper` encapsulates all driver-specific initialization logic.
|
|
@@ -832,7 +1119,7 @@ export interface BackendBootstrapper {
|
|
|
832
1119
|
/**
|
|
833
1120
|
* Initialize WebSocket server for realtime operations.
|
|
834
1121
|
*/
|
|
835
|
-
initializeWebsockets?(server: unknown, realtimeService: RealtimeProvider, driver: import("../controllers/data_driver.js").DataDriver, config?: unknown, authAdapter?: AuthAdapter, limits?:
|
|
1122
|
+
initializeWebsockets?(server: unknown, realtimeService: RealtimeProvider, driver: import("../controllers/data_driver.js").DataDriver, config?: unknown, authAdapter?: AuthAdapter, limits?: RealtimeSocketOptions): Promise<void> | void;
|
|
836
1123
|
}
|
|
837
1124
|
/**
|
|
838
1125
|
* Result of `BackendBootstrapper.initializeDriver()`.
|
|
@@ -868,8 +1155,6 @@ export interface InitializedDriver {
|
|
|
868
1155
|
export interface BootstrappedAuth {
|
|
869
1156
|
/** User management service. */
|
|
870
1157
|
userService: unknown;
|
|
871
|
-
/** Role management service (optional, roles are now simple strings). */
|
|
872
|
-
roleService?: unknown;
|
|
873
1158
|
/** Email service (optional). */
|
|
874
1159
|
emailService?: unknown;
|
|
875
1160
|
/** Combined Auth Repository for unified token and user management. */
|
package/dist/types/backup.d.ts
CHANGED
|
@@ -25,3 +25,105 @@ export interface BackupInfo {
|
|
|
25
25
|
*/
|
|
26
26
|
globalsKey?: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* How one run of the scheduled backup went, read from the cron's run history.
|
|
30
|
+
*/
|
|
31
|
+
export interface BackupRunOutcome {
|
|
32
|
+
/** ISO timestamp the run started. */
|
|
33
|
+
startedAt: string;
|
|
34
|
+
/** ISO timestamp the run ended. */
|
|
35
|
+
finishedAt: string;
|
|
36
|
+
/** Whether the run produced a backup. */
|
|
37
|
+
success: boolean;
|
|
38
|
+
/** Why it did not, when it failed — e.g. `Could not find the 'pg_dump' binary.` */
|
|
39
|
+
error?: string;
|
|
40
|
+
/** True when someone triggered the run by hand rather than the schedule. */
|
|
41
|
+
manual: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The deployment's scheduled backup job — the cron that default-exports
|
|
45
|
+
* `createBackupCron` — and the outcome of its last run.
|
|
46
|
+
*
|
|
47
|
+
* Shown by the Backups panel so a backup that fails every night is visible
|
|
48
|
+
* where the backups are listed, rather than only in the cron history.
|
|
49
|
+
*/
|
|
50
|
+
export interface BackupScheduleStatus {
|
|
51
|
+
/** The cron job's id, which is its file's name. */
|
|
52
|
+
jobId: string;
|
|
53
|
+
/** The job's display name. */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Its cron expression. */
|
|
56
|
+
schedule: string;
|
|
57
|
+
/** False when the job is paused (or declared `enabled: false`), or refused. */
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* True when the job is off because its own definition says
|
|
61
|
+
* `enabled: false` — the documented backup cron file exports it that way
|
|
62
|
+
* while `BACKUP_SCHEDULE` is unset — and not because someone paused it.
|
|
63
|
+
* Resuming it in Cron Jobs would run that definition as written.
|
|
64
|
+
*/
|
|
65
|
+
disabledInCode?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Why the scheduler refused the job — an invalid schedule, timezone or
|
|
68
|
+
* timeout. A refused job is not registered and never runs; the cron file
|
|
69
|
+
* has to change.
|
|
70
|
+
*/
|
|
71
|
+
refused?: string;
|
|
72
|
+
/** ISO timestamp of the next scheduled run, when one is armed. */
|
|
73
|
+
nextRunAt?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The most recent scheduled run, absent when the schedule has never run
|
|
76
|
+
* it — or when its run history could not be read, which
|
|
77
|
+
* {@link historyError} says. A run someone started by hand is not one:
|
|
78
|
+
* see {@link lastManualRun}.
|
|
79
|
+
*/
|
|
80
|
+
lastRun?: BackupRunOutcome;
|
|
81
|
+
/** A run started by hand ("Run Now") since {@link lastRun}, when there is one. */
|
|
82
|
+
lastManualRun?: BackupRunOutcome;
|
|
83
|
+
/**
|
|
84
|
+
* Why the job's run history could not be read. Whether it ran, and how it
|
|
85
|
+
* went, is then unknown: `lastRun` is absent for that reason, not because
|
|
86
|
+
* the job never ran.
|
|
87
|
+
*/
|
|
88
|
+
historyError?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A short-lived link to one backup's bytes, from `POST /admin/backups/download-url`.
|
|
92
|
+
*
|
|
93
|
+
* The URL needs no `Authorization` header — the token in it stands in for one,
|
|
94
|
+
* for this backup only — so a browser can be sent to it and stream the dump to
|
|
95
|
+
* disk instead of holding it in the page.
|
|
96
|
+
*/
|
|
97
|
+
export interface BackupDownloadLink {
|
|
98
|
+
/**
|
|
99
|
+
* `…/admin/backups/download?key=…&token=…`. The server answers it as a
|
|
100
|
+
* path on itself; the SDK's `downloadUrl()` answers it absolute, on the
|
|
101
|
+
* client's own base URL.
|
|
102
|
+
*/
|
|
103
|
+
url: string;
|
|
104
|
+
/** The token in {@link url}, on its own. */
|
|
105
|
+
token: string;
|
|
106
|
+
/** Seconds until the link stops working (60). */
|
|
107
|
+
expiresIn: number;
|
|
108
|
+
}
|
|
109
|
+
/** What the backup listing (`GET /admin/backups`) answers. */
|
|
110
|
+
export interface BackupListing {
|
|
111
|
+
/** Backups at the destination, newest first. */
|
|
112
|
+
backups: BackupInfo[];
|
|
113
|
+
/** The kind of destination they were read from. */
|
|
114
|
+
destinationKind: BackupDestinationKind;
|
|
115
|
+
/** False when `BACKUP_DESTINATION` is unset. */
|
|
116
|
+
configured: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The scheduled backup job, or `null` when the deployment registers none.
|
|
119
|
+
* Absent from a server that predates the field.
|
|
120
|
+
*/
|
|
121
|
+
schedule?: BackupScheduleStatus | null;
|
|
122
|
+
/**
|
|
123
|
+
* True when the destination is a local path and the scheduled backup runs
|
|
124
|
+
* in another process (the worker of a split deployment). The backups
|
|
125
|
+
* listed are the ones on this process's disk; the scheduled runs write to
|
|
126
|
+
* theirs, which is the same directory only when both mount it.
|
|
127
|
+
*/
|
|
128
|
+
localDiskOfThisProcess?: boolean;
|
|
129
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** One change to a collection. `path` is a list of object keys. */
|
|
2
|
+
export type CollectionPatchOp = {
|
|
3
|
+
op: "set";
|
|
4
|
+
path: string[];
|
|
5
|
+
value: unknown;
|
|
6
|
+
} | {
|
|
7
|
+
op: "remove";
|
|
8
|
+
path: string[];
|
|
9
|
+
};
|
|
10
|
+
/** @group Models */
|
|
11
|
+
export type CollectionPatch = CollectionPatchOp[];
|
|
12
|
+
/**
|
|
13
|
+
* Keys the runtime adds to a collection that must never be written into its
|
|
14
|
+
* source. `resolvedRelation` is the registry's resolved form of a relation; a
|
|
15
|
+
* file holding one does not type-check (`target` is missing from it).
|
|
16
|
+
*/
|
|
17
|
+
export declare const RUNTIME_ONLY_COLLECTION_KEYS: readonly string[];
|
|
18
|
+
/** A JSON value as JSON would carry it: functions, `undefined` and symbols dropped. */
|
|
19
|
+
export declare function toCollectionJson(value: unknown): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* The operations that take `before` to `after`, both JSON values.
|
|
22
|
+
*
|
|
23
|
+
* Objects are compared key by key; anything else that differs — a primitive,
|
|
24
|
+
* an array, a change of kind — is set whole.
|
|
25
|
+
*/
|
|
26
|
+
export declare function diffJsonValues(before: unknown, after: unknown, path?: string[]): CollectionPatch;
|
|
27
|
+
/**
|
|
28
|
+
* The patch, with every flat presentation key moved into its `admin` block.
|
|
29
|
+
*
|
|
30
|
+
* The panel edits a flat view model — `icon` beside `name`, a property's
|
|
31
|
+
* `readOnly` beside its `type` — while the file keeps them under `admin`. The
|
|
32
|
+
* difference is taken on the flat model, because that is where a cleared field
|
|
33
|
+
* shows up as a removed key (the `admin` copy the model was loaded with still
|
|
34
|
+
* holds the old value), and moved here.
|
|
35
|
+
*
|
|
36
|
+
* The flat value wins over the `admin` copy, as in {@link nestAdminKeysOf}:
|
|
37
|
+
* operations that were already under `admin` are ordered first, so the flat
|
|
38
|
+
* one — what the form just wrote — is applied last.
|
|
39
|
+
*/
|
|
40
|
+
export declare function nestCollectionPatchPaths(patch: CollectionPatch): CollectionPatch;
|
|
41
|
+
/**
|
|
42
|
+
* The patch that takes the collection the editor loaded to the one it is
|
|
43
|
+
* saving, in the authoring shape. Empty when nothing changed.
|
|
44
|
+
*
|
|
45
|
+
* Both sides go through JSON first, so whatever JSON cannot carry — a
|
|
46
|
+
* function, a value it drops — is equally absent from both and never appears
|
|
47
|
+
* as a change.
|
|
48
|
+
*/
|
|
49
|
+
export declare function diffCollections(loaded: unknown, saving: unknown): CollectionPatch;
|
|
50
|
+
/**
|
|
51
|
+
* Why a patch may not be applied, or an empty list.
|
|
52
|
+
*
|
|
53
|
+
* Checked by every door that accepts one: a path is a list of non-empty object
|
|
54
|
+
* keys that cannot reach a prototype, and no runtime-only key may be written.
|
|
55
|
+
*/
|
|
56
|
+
export declare function collectionPatchProblems(patch: unknown): string[];
|
|
57
|
+
/**
|
|
58
|
+
* The first runtime-only key (see {@link RUNTIME_ONLY_COLLECTION_KEYS}) found
|
|
59
|
+
* anywhere in a value, or `undefined`. For the doors that take a whole
|
|
60
|
+
* collection rather than a patch.
|
|
61
|
+
*/
|
|
62
|
+
export declare function runtimeOnlyKeyIn(value: unknown): string | undefined;
|
|
63
|
+
/** A patch every door may apply: {@link collectionPatchProblems} found nothing. */
|
|
64
|
+
export declare function isCollectionPatch(patch: unknown): patch is CollectionPatch;
|
|
65
|
+
/**
|
|
66
|
+
* `target` with the patch applied, copying only what it changes.
|
|
67
|
+
*
|
|
68
|
+
* Everything the patch does not reach is shared with `target` by reference —
|
|
69
|
+
* functions, thunks and all — which is what lets a planner see a relation's
|
|
70
|
+
* `target()` on the patched collection exactly as it was. Intermediate objects
|
|
71
|
+
* a `set` needs are created; a `remove` of a key that is not there is nothing
|
|
72
|
+
* to do.
|
|
73
|
+
*/
|
|
74
|
+
export declare function applyCollectionPatch<T>(target: T, patch: CollectionPatch): T;
|
|
@@ -4,6 +4,7 @@ import type { User } from "../users/index.js";
|
|
|
4
4
|
import type { EmailSendResult } from "../controllers/email.js";
|
|
5
5
|
import type { Relation } from "./relations.js";
|
|
6
6
|
import type { SecurityRule } from "./security_rules.js";
|
|
7
|
+
import type { RoleDefinition, ScopeDefinition } from "./scopes.js";
|
|
7
8
|
import type { SearchConfig } from "./search.js";
|
|
8
9
|
import type { CollectionIndex } from "./indexes.js";
|
|
9
10
|
import type { CollectionTenantConfig } from "./tenancy.js";
|
|
@@ -614,6 +615,28 @@ export type InferCollectionConfigType<S extends CollectionConfig> = S extends Co
|
|
|
614
615
|
export interface AuthCollectionConfig {
|
|
615
616
|
/** Set to true to mark this collection as the authentication collection. */
|
|
616
617
|
enabled: boolean;
|
|
618
|
+
/**
|
|
619
|
+
* The app's roles and the admin-plane scopes each holds.
|
|
620
|
+
*
|
|
621
|
+
* `admin` is built in — it holds every scope — and cannot be declared. A
|
|
622
|
+
* role used only by RLS policies needs no entry here. See
|
|
623
|
+
* {@link RoleDefinition}.
|
|
624
|
+
*/
|
|
625
|
+
roles?: Record<string, RoleDefinition>;
|
|
626
|
+
/**
|
|
627
|
+
* Scopes the app defines for its own operations, named `resource:action`
|
|
628
|
+
* like the built-in ones and checked with `requireScope` in a function.
|
|
629
|
+
* Every signed-in person holds them; they exist so a key can be narrowed
|
|
630
|
+
* to one action. See {@link ScopeDefinition}.
|
|
631
|
+
*/
|
|
632
|
+
scopes?: Record<string, ScopeDefinition>;
|
|
633
|
+
/**
|
|
634
|
+
* Let every signed-in account mint personal API keys at
|
|
635
|
+
* `/api/auth/keys`. A personal key acts as its owner and can never hold
|
|
636
|
+
* a scope its owner does not. Off by default: each one is a long-lived
|
|
637
|
+
* credential for the account, and an app opts into handing those out.
|
|
638
|
+
*/
|
|
639
|
+
personalKeys?: boolean;
|
|
617
640
|
/**
|
|
618
641
|
* Called when an admin creates a user, through the collection REST API or
|
|
619
642
|
* `POST /admin/users`.
|