@rebasepro/types 0.21.0 → 0.21.1
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/README.md +16 -19
- package/dist/controllers/data_driver.d.ts +10 -1
- package/dist/index.es.js +55 -1
- package/dist/index.es.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +11 -1
- package/dist/types/backend.d.ts +11 -4
- package/dist/types/backup.d.ts +7 -0
- package/dist/types/collections.d.ts +17 -3
- package/dist/types/env_boolean.d.ts +35 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/websockets.d.ts +5 -0
- package/package.json +1 -1
|
@@ -247,7 +247,11 @@ export interface UserCreationPrepareResult {
|
|
|
247
247
|
values: Record<string, unknown>;
|
|
248
248
|
/** Cleartext password for post-save processing (email or admin display). */
|
|
249
249
|
clearPassword?: string;
|
|
250
|
-
/**
|
|
250
|
+
/**
|
|
251
|
+
* Whether the hook already handled the invitation (email, etc.). When
|
|
252
|
+
* `true`, `finalizeUserCreation` is skipped and `clearPassword` is returned
|
|
253
|
+
* to the admin as the temporary password.
|
|
254
|
+
*/
|
|
251
255
|
hookHandledEmail: boolean;
|
|
252
256
|
/** Whether an invitation was sent (only relevant when hookHandledEmail is true). */
|
|
253
257
|
invitationSent: boolean;
|
|
@@ -472,6 +476,12 @@ export interface AuthAdapter {
|
|
|
472
476
|
* Handles post-save work: sending invitation emails, generating
|
|
473
477
|
* password-reset tokens, or falling back to returning a temporary password.
|
|
474
478
|
*
|
|
479
|
+
* Not called when `prepareUserCreation` reported `hookHandledEmail`. A
|
|
480
|
+
* create hook then owns delivery, and the response carries the
|
|
481
|
+
* `invitationSent` and `clearPassword` the prepare step returned. This
|
|
482
|
+
* holds for both ways of creating a user: a `POST` to the auth collection
|
|
483
|
+
* and `POST /admin/users`.
|
|
484
|
+
*
|
|
475
485
|
* @param entity - The persisted entity (id + values).
|
|
476
486
|
* @param clearPassword - The cleartext password from the prepare step (if any).
|
|
477
487
|
* @returns Metadata for the API response (temporary password, invitation status).
|
package/dist/types/backend.d.ts
CHANGED
|
@@ -245,13 +245,20 @@ export interface RealtimeChannelsConfig {
|
|
|
245
245
|
*/
|
|
246
246
|
export interface RealtimeProvider {
|
|
247
247
|
/**
|
|
248
|
-
* Subscribe to collection changes
|
|
248
|
+
* Subscribe to collection changes.
|
|
249
|
+
*
|
|
250
|
+
* `onError` is called when a fetch behind the subscription fails, a
|
|
251
|
+
* refetch after a change included, with the error as it was thrown. It is
|
|
252
|
+
* not called for a fetch that newer rows have already overtaken, or after
|
|
253
|
+
* the subscription is gone. Without it, a subscriber whose fetch failed
|
|
254
|
+
* was told nothing and kept waiting for rows.
|
|
249
255
|
*/
|
|
250
|
-
subscribeToCollection(subscriptionId: string, config: CollectionSubscriptionConfig, callback?: (rows: Record<string, unknown>[]) => void): void;
|
|
256
|
+
subscribeToCollection(subscriptionId: string, config: CollectionSubscriptionConfig, callback?: (rows: Record<string, unknown>[]) => void, onError?: (error: unknown) => void): void;
|
|
251
257
|
/**
|
|
252
|
-
* Subscribe to single entity changes
|
|
258
|
+
* Subscribe to single entity changes. `onError` as for
|
|
259
|
+
* {@link RealtimeProvider.subscribeToCollection}.
|
|
253
260
|
*/
|
|
254
|
-
subscribeToOne(subscriptionId: string, config: SingleSubscriptionConfig, callback?: (row: Record<string, unknown> | null) => void): void;
|
|
261
|
+
subscribeToOne(subscriptionId: string, config: SingleSubscriptionConfig, callback?: (row: Record<string, unknown> | null) => void, onError?: (error: unknown) => void): void;
|
|
255
262
|
/**
|
|
256
263
|
* Unsubscribe from a subscription
|
|
257
264
|
*/
|
package/dist/types/backup.d.ts
CHANGED
|
@@ -17,4 +17,11 @@ export interface BackupInfo {
|
|
|
17
17
|
createdAt?: string;
|
|
18
18
|
/** The kind of destination this backup was read from. */
|
|
19
19
|
destinationKind: BackupDestinationKind;
|
|
20
|
+
/**
|
|
21
|
+
* Key of the `.globals.sql` sidecar written beside this dump, when there is
|
|
22
|
+
* one. It holds the database roles the dump's GRANTs and RLS policies name,
|
|
23
|
+
* and `rebase db restore` looks for it next to the `.dump` — so a copy of the
|
|
24
|
+
* backup needs both files. Absent when the dump was taken without it.
|
|
25
|
+
*/
|
|
26
|
+
globalsKey?: string;
|
|
20
27
|
}
|
|
@@ -615,12 +615,16 @@ export interface AuthCollectionConfig {
|
|
|
615
615
|
/** Set to true to mark this collection as the authentication collection. */
|
|
616
616
|
enabled: boolean;
|
|
617
617
|
/**
|
|
618
|
-
* Called when an admin creates a user
|
|
618
|
+
* Called when an admin creates a user, through the collection REST API or
|
|
619
|
+
* `POST /admin/users`.
|
|
619
620
|
*
|
|
620
621
|
* Default: generate password → hash → normalize email → save →
|
|
621
622
|
* send invitation email (or return temp password if no email configured).
|
|
622
623
|
*
|
|
623
|
-
* Override to implement custom invitation flows, LDAP sync, etc.
|
|
624
|
+
* Override to implement custom invitation flows, LDAP sync, etc. The hook
|
|
625
|
+
* then owns delivery: Rebase sends no invitation of its own, and the
|
|
626
|
+
* response reports the hook's `invitationSent` and shows its
|
|
627
|
+
* `temporaryPassword` to the admin.
|
|
624
628
|
*/
|
|
625
629
|
onCreateUser?: (values: Record<string, unknown>, ctx: AuthCollectionContext) => Promise<AuthCollectionCreateResult>;
|
|
626
630
|
/**
|
|
@@ -628,6 +632,12 @@ export interface AuthCollectionConfig {
|
|
|
628
632
|
*
|
|
629
633
|
* Default: generate reset token → send email (or generate + return temp password).
|
|
630
634
|
* Override for custom reset flows.
|
|
635
|
+
*
|
|
636
|
+
* Return a `temporaryPassword` to set one: Rebase hashes it with the
|
|
637
|
+
* configured algorithm, saves it as the account's password and shows it to
|
|
638
|
+
* the admin. The hook does not write it — its context has no way to. Return
|
|
639
|
+
* none when the hook sends its own link instead. Either way, the account's
|
|
640
|
+
* existing sessions are signed out.
|
|
631
641
|
*/
|
|
632
642
|
onResetPassword?: (uid: string, ctx: AuthCollectionContext) => Promise<AuthCollectionResetResult>;
|
|
633
643
|
/**
|
|
@@ -696,7 +706,11 @@ export interface AuthCollectionCreateResult {
|
|
|
696
706
|
* @group Models
|
|
697
707
|
*/
|
|
698
708
|
export interface AuthCollectionResetResult {
|
|
699
|
-
/**
|
|
709
|
+
/**
|
|
710
|
+
* The account's new password. Rebase hashes and saves it, then shows it to
|
|
711
|
+
* the admin; leave it unset when the account keeps its password for now
|
|
712
|
+
* (for example, because the hook emailed a link).
|
|
713
|
+
*/
|
|
700
714
|
temporaryPassword?: string;
|
|
701
715
|
/** Whether a reset email was sent. */
|
|
702
716
|
invitationSent?: boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a boolean environment variable — one spelling rule for every reader.
|
|
3
|
+
*
|
|
4
|
+
* `true`, `1`, `yes` and `on` are true; `false`, `0`, `no` and `off` are
|
|
5
|
+
* false. Case and surrounding whitespace are ignored. Anything else — unset,
|
|
6
|
+
* blank, or a value that spells neither — is `undefined`, so the caller's
|
|
7
|
+
* default decides and a typo lands on the side the caller chose:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* parseEnvBoolean(env.FORCE_LOCAL_STORAGE) === true // off unless said
|
|
11
|
+
* parseEnvBoolean(env.REBASE_MCP_OPEN_REGISTRATION) !== false // on unless said
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* It exists because every reader used to spell this itself, and they
|
|
15
|
+
* disagreed. The reader that mattered tested the raw string for truthiness —
|
|
16
|
+
* `!process.env.FORCE_LOCAL_STORAGE` — and every non-empty string is truthy,
|
|
17
|
+
* so `FORCE_LOCAL_STORAGE=false`, written to say "there is no durable volume
|
|
18
|
+
* here", switched the production storage guard off and sent uploads to a
|
|
19
|
+
* container filesystem the next redeploy erased. Beside it, `=== "true"` made
|
|
20
|
+
* `DISABLE_DB_ROLE_SWITCHING=1` do nothing and `!== "false"` made
|
|
21
|
+
* `REBASE_MCP_OPEN_REGISTRATION=0` leave registration open.
|
|
22
|
+
*
|
|
23
|
+
* The boot schemas in `@rebasepro/server` (`loadEnv`, `loadBootEnv`) accept a
|
|
24
|
+
* strict subset — `true`, `false` and blank — and refuse any other value
|
|
25
|
+
* before the server starts. On that subset they read exactly what this reads,
|
|
26
|
+
* so a variable a schema declares and something else reads lazily cannot mean
|
|
27
|
+
* two different things.
|
|
28
|
+
*
|
|
29
|
+
* It lives in this package, with no dependencies, for the reason
|
|
30
|
+
* {@link storageEnvSuffix} does: the runtime, its drivers and the CLI all read
|
|
31
|
+
* these variables, and a second parser is a second chance to disagree.
|
|
32
|
+
*
|
|
33
|
+
* @group Models
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseEnvBoolean(value: string | undefined): boolean | undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./data_source.js";
|
|
|
20
20
|
export * from "./resources.js";
|
|
21
21
|
export * from "./resource_kinds.js";
|
|
22
22
|
export * from "./storage_source.js";
|
|
23
|
+
export * from "./env_boolean.js";
|
|
23
24
|
export * from "./cron.js";
|
|
24
25
|
export * from "./backup.js";
|
|
25
26
|
export * from "./component_ref.js";
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export interface WebSocketErrorPayload {
|
|
2
|
+
/**
|
|
3
|
+
* `details` is what the REST envelope carries under the same name — for a
|
|
4
|
+
* collection-callback refusal, `{ stage, path }` naming the hook.
|
|
5
|
+
*/
|
|
2
6
|
error?: string | {
|
|
3
7
|
message: string;
|
|
4
8
|
code?: string;
|
|
9
|
+
details?: unknown;
|
|
5
10
|
};
|
|
6
11
|
message?: string;
|
|
7
12
|
code?: string;
|