@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
|
@@ -49,7 +49,7 @@ export type AdminCollectionKey = typeof ADMIN_COLLECTION_KEYS[number];
|
|
|
49
49
|
*
|
|
50
50
|
* @group Models
|
|
51
51
|
*/
|
|
52
|
-
export declare const ADMIN_PROPERTY_KEYS: readonly ["canAddElements", "clearable", "columnWidth", "customProps", "disabled", "expanded", "Field", "Filter", "filterOperators", "fixedFilter", "format", "hideFromCollection", "includeEntityLink", "includeId", "markdown", "minimalistView", "multiline", "Preview", "previewAsTag", "previewProperties", "readOnly", "renderInForm", "sortable", "span", "spreadChildren", "urlPreview", "widget"];
|
|
52
|
+
export declare const ADMIN_PROPERTY_KEYS: readonly ["canAddElements", "clearable", "columnWidth", "customProps", "disabled", "expanded", "Field", "filledByServer", "Filter", "filterOperators", "fixedFilter", "format", "hideFromCollection", "includeEntityLink", "includeId", "markdown", "minimalistView", "multiline", "Preview", "previewAsTag", "previewProperties", "readOnly", "renderInForm", "sortable", "span", "spreadChildren", "urlPreview", "widget"];
|
|
53
53
|
/** A key of a property's `admin` block. @group Models */
|
|
54
54
|
export type AdminPropertyKey = typeof ADMIN_PROPERTY_KEYS[number];
|
|
55
55
|
/**
|
package/dist/types/api_keys.d.ts
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* API keys — long-lived bearer credentials for scripts, CI, agents and
|
|
3
|
+
* third-party integrations.
|
|
4
4
|
*
|
|
5
|
-
* The wire contract lives here because all three sides need it
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* The wire contract lives here because all three sides need it:
|
|
6
|
+
* `@rebasepro/server` implements the routes, `@rebasepro/client` calls them,
|
|
7
|
+
* and {@link ApiKeysAPI} types the SDK surface. The database row itself
|
|
8
|
+
* (which carries `key_hash`) stays in the server package: nothing off the
|
|
9
|
+
* server may see it.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
* server package: nothing off the server may see it.
|
|
11
|
+
* What a key may do is a list of scopes — see `scopes.ts`.
|
|
12
12
|
*/
|
|
13
|
+
import type { ScopeSummary } from "./scopes.js";
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
* operations.
|
|
15
|
+
* Who a key acts as.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* - `"service"` — the project's own machine identity, `api-key:<id>`. It is no
|
|
18
|
+
* person: it runs as the RLS roles it was given (`service` always, plus any
|
|
19
|
+
* in {@link ApiKeyMasked.roles}). Managed by holders of `keys:write`.
|
|
20
|
+
* - `"personal"` — its owner. It runs as the owner's account, with the owner's
|
|
21
|
+
* roles as they are *now*, and can never hold a scope the owner does not.
|
|
22
|
+
* Managed by the owner, when the app enables `auth.personalKeys`.
|
|
21
23
|
*
|
|
22
24
|
* @group Models
|
|
23
25
|
*/
|
|
24
|
-
export
|
|
25
|
-
/** Collection slug, `"functions"`/`"functions/<name>"`, or `"*"` for everything. */
|
|
26
|
-
collection: string;
|
|
27
|
-
/** Allowed operations on the collection. */
|
|
28
|
-
operations: ("read" | "write" | "delete")[];
|
|
29
|
-
}
|
|
26
|
+
export type ApiKeyKind = "service" | "personal";
|
|
30
27
|
/**
|
|
31
|
-
* An API key with the secret
|
|
28
|
+
* An API key with the secret masked — what list / get / update return.
|
|
32
29
|
* @group Models
|
|
33
30
|
*/
|
|
34
31
|
export interface ApiKeyMasked {
|
|
35
32
|
id: string;
|
|
36
33
|
name: string;
|
|
34
|
+
kind: ApiKeyKind;
|
|
37
35
|
/** First 12 characters of the plaintext key, for display only. */
|
|
38
36
|
key_prefix: string;
|
|
39
|
-
permissions: ApiKeyPermission[];
|
|
40
37
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
* What the key may do, as `resource:action[:target]` scope strings —
|
|
39
|
+
* `data:read:posts`, `functions:invoke`, `logs:read`.
|
|
40
|
+
*/
|
|
41
|
+
scopes: string[];
|
|
42
|
+
/**
|
|
43
|
+
* The RLS roles a service key runs as, beside `service`. `["admin"]` reads
|
|
44
|
+
* every row through the default admin policies. Always empty on a personal
|
|
45
|
+
* key, which runs as its owner's live roles.
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
roles: string[];
|
|
48
|
+
/** The account a personal key acts as. Null on a service key. */
|
|
49
|
+
owner_uid: string | null;
|
|
47
50
|
/**
|
|
48
51
|
* Requests per 15-minute window. `null` means "no per-key override" — the
|
|
49
52
|
* data rate limiter then applies its default API-key limit (1000/window
|
|
@@ -67,32 +70,44 @@ export interface ApiKeyWithSecret extends ApiKeyMasked {
|
|
|
67
70
|
key: string;
|
|
68
71
|
}
|
|
69
72
|
/**
|
|
70
|
-
* Payload for creating a
|
|
73
|
+
* Payload for creating a service key.
|
|
71
74
|
* @group Models
|
|
72
75
|
*/
|
|
73
76
|
export interface CreateApiKeyRequest {
|
|
74
77
|
name: string;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
admin
|
|
78
|
+
/** At least one. `keys:*` is refused, and so is any scope the creator does not hold. */
|
|
79
|
+
scopes: string[];
|
|
80
|
+
/** RLS roles beside `service`. A creator may only give roles they hold, unless they are an admin. */
|
|
81
|
+
roles?: string[];
|
|
78
82
|
/** Requests per 15-minute window. Omit or `null` for the server default. */
|
|
79
83
|
rate_limit?: number | null;
|
|
80
84
|
/** ISO-8601 expiration timestamp. Omit for no expiration. */
|
|
81
85
|
expires_at?: string | null;
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
84
|
-
* Payload for updating
|
|
88
|
+
* Payload for updating a service key. Only the fields provided change.
|
|
85
89
|
* @group Models
|
|
86
90
|
*/
|
|
87
91
|
export interface UpdateApiKeyRequest {
|
|
88
92
|
name?: string;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
admin?: boolean;
|
|
93
|
+
scopes?: string[];
|
|
94
|
+
roles?: string[];
|
|
92
95
|
rate_limit?: number | null;
|
|
93
96
|
expires_at?: string | null;
|
|
94
97
|
}
|
|
95
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Payload for creating a personal key. It acts as the caller, so it carries no
|
|
100
|
+
* roles and no rate-limit override.
|
|
101
|
+
* @group Models
|
|
102
|
+
*/
|
|
103
|
+
export interface CreatePersonalKeyRequest {
|
|
104
|
+
name: string;
|
|
105
|
+
/** At least one, and none the caller does not hold. `keys:*` is refused. */
|
|
106
|
+
scopes: string[];
|
|
107
|
+
/** ISO-8601 expiration timestamp. Omit for no expiration. */
|
|
108
|
+
expires_at?: string | null;
|
|
109
|
+
}
|
|
110
|
+
/** The project's service keys. Requires `keys:read` / `keys:write`. @group Models */
|
|
96
111
|
export interface ApiKeysAPI {
|
|
97
112
|
listKeys(): Promise<{
|
|
98
113
|
keys: ApiKeyMasked[];
|
|
@@ -110,3 +125,20 @@ export interface ApiKeysAPI {
|
|
|
110
125
|
success: boolean;
|
|
111
126
|
}>;
|
|
112
127
|
}
|
|
128
|
+
/** The signed-in person's own keys, when the app enables them. @group Models */
|
|
129
|
+
export interface PersonalKeysAPI {
|
|
130
|
+
listKeys(): Promise<{
|
|
131
|
+
keys: ApiKeyMasked[];
|
|
132
|
+
}>;
|
|
133
|
+
createKey(data: CreatePersonalKeyRequest): Promise<{
|
|
134
|
+
key: ApiKeyWithSecret;
|
|
135
|
+
}>;
|
|
136
|
+
revokeKey(id: string): Promise<{
|
|
137
|
+
success: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
/** Every scope the backend knows, described, and the ones the caller holds. */
|
|
140
|
+
listScopes(): Promise<{
|
|
141
|
+
scopes: ScopeSummary[];
|
|
142
|
+
held: string[];
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
@@ -53,6 +53,18 @@ export interface MountableRouter {
|
|
|
53
53
|
/** The routes the sub-app declares. Only its presence is contractual. */
|
|
54
54
|
routes: readonly unknown[];
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The request header that asks for a data-plane request to run as another
|
|
58
|
+
* user, named by uid.
|
|
59
|
+
*
|
|
60
|
+
* The server honours it only on a signed-in administrator's own session —
|
|
61
|
+
* never on an API key or the service key — and only through an adapter that
|
|
62
|
+
* implements {@link AuthAdapter.resolveUser}. Everywhere else a request that
|
|
63
|
+
* carries it is refused, never run as its caller.
|
|
64
|
+
*
|
|
65
|
+
* @group Auth
|
|
66
|
+
*/
|
|
67
|
+
export declare const IMPERSONATE_HEADER = "x-rebase-impersonate";
|
|
56
68
|
/**
|
|
57
69
|
* The normalized user object returned by `AuthAdapter.verifyRequest()`.
|
|
58
70
|
*
|
|
@@ -72,7 +84,11 @@ export interface AuthenticatedUser {
|
|
|
72
84
|
photoUrl?: string | null;
|
|
73
85
|
/** Role identifiers the user holds. */
|
|
74
86
|
roles: string[];
|
|
75
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Whether `roles` includes `admin`. Informational — every authorization
|
|
89
|
+
* decision reads `roles` and the scopes they hold, so an adapter that
|
|
90
|
+
* wants a user treated as an administrator gives them the `admin` role.
|
|
91
|
+
*/
|
|
76
92
|
isAdmin: boolean;
|
|
77
93
|
/**
|
|
78
94
|
* Whether this session is a GUEST — anonymous sign-in rather than an
|
|
@@ -90,6 +106,12 @@ export interface AuthenticatedUser {
|
|
|
90
106
|
rawToken?: string;
|
|
91
107
|
/** Extra claims/metadata from the auth provider. */
|
|
92
108
|
claims?: Record<string, unknown>;
|
|
109
|
+
/**
|
|
110
|
+
* What this credential may do, when it is narrower than its person — set
|
|
111
|
+
* for an API key. Absent means everything the user's roles hold
|
|
112
|
+
* (`scopesForRoles`).
|
|
113
|
+
*/
|
|
114
|
+
scopes?: string[];
|
|
93
115
|
}
|
|
94
116
|
/**
|
|
95
117
|
* Feature flags advertised by an auth adapter.
|
|
@@ -171,6 +193,26 @@ export interface AuthAdapterCapabilities {
|
|
|
171
193
|
*/
|
|
172
194
|
needsSetup?: boolean;
|
|
173
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* What `GET /api/auth/config` answers: the auth adapter's capabilities, plus
|
|
198
|
+
* the optional features of the backend around it.
|
|
199
|
+
*
|
|
200
|
+
* The admin panel reads this document before anything else, so it is where
|
|
201
|
+
* the panel learns that a feature is off, without first asking for that
|
|
202
|
+
* feature and getting a refusal.
|
|
203
|
+
*
|
|
204
|
+
* @group Auth
|
|
205
|
+
*/
|
|
206
|
+
export interface AuthConfigDocument extends AuthAdapterCapabilities {
|
|
207
|
+
/**
|
|
208
|
+
* Whether this backend serves file storage. When it is `false`, no storage
|
|
209
|
+
* backend is configured: `GET /storage/sources` lists nothing and every
|
|
210
|
+
* other `/storage` route answers 501 `STORAGE_NOT_CONFIGURED`. Absent from
|
|
211
|
+
* a backend that predates the field, so a client must ask
|
|
212
|
+
* `GET /storage/sources` there.
|
|
213
|
+
*/
|
|
214
|
+
storage?: boolean;
|
|
215
|
+
}
|
|
174
216
|
/**
|
|
175
217
|
* Options for paginated user listing.
|
|
176
218
|
* @group Auth
|
|
@@ -217,6 +259,11 @@ export interface AuthCreateUserData {
|
|
|
217
259
|
displayName?: string;
|
|
218
260
|
photoUrl?: string;
|
|
219
261
|
metadata?: Record<string, unknown>;
|
|
262
|
+
/**
|
|
263
|
+
* Store the address as verified: whoever creates the account named it
|
|
264
|
+
* (an operator, an administrator), so nobody needs to prove it.
|
|
265
|
+
*/
|
|
266
|
+
emailVerified?: boolean;
|
|
220
267
|
}
|
|
221
268
|
/**
|
|
222
269
|
* User management operations for the admin panel.
|
|
@@ -256,6 +303,23 @@ export interface UserCreationPrepareResult {
|
|
|
256
303
|
/** Whether an invitation was sent (only relevant when hookHandledEmail is true). */
|
|
257
304
|
invitationSent: boolean;
|
|
258
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* What the door creating a user knows about its caller, for
|
|
308
|
+
* `AuthAdapter.prepareUserCreation()`.
|
|
309
|
+
*
|
|
310
|
+
* @group Auth
|
|
311
|
+
*/
|
|
312
|
+
export interface UserCreationOptions {
|
|
313
|
+
/**
|
|
314
|
+
* Whether the caller may waive the password policy with
|
|
315
|
+
* `skipPasswordPolicy: true` in the body. The doors set it for an
|
|
316
|
+
* administrator (the service key signs in as one) and for nobody else, so
|
|
317
|
+
* an adapter that reads the flag is taking an administrator at their word —
|
|
318
|
+
* an import of accounts whose passwords were set under another system's
|
|
319
|
+
* rules. Absent, the flag waives nothing.
|
|
320
|
+
*/
|
|
321
|
+
mayWaivePasswordPolicy?: boolean;
|
|
322
|
+
}
|
|
259
323
|
/**
|
|
260
324
|
* What a create body for an auth collection may name beyond the collection's
|
|
261
325
|
* own declared fields — see `AuthAdapter.describeUserCreationContract()`.
|
|
@@ -275,6 +339,16 @@ export interface UserCreationWriteContract {
|
|
|
275
339
|
* deletes it before the row is ever built.
|
|
276
340
|
*/
|
|
277
341
|
extraFields: string[];
|
|
342
|
+
/**
|
|
343
|
+
* Each body's `prepareUserCreation` touches nothing but its own result —
|
|
344
|
+
* no hook, no email, no write — so a bulk create may prepare several at
|
|
345
|
+
* once. The built-in adapter's path with no `onCreateUser`, no
|
|
346
|
+
* `onAdminCreateUser` and the default `hashPassword` is: it hashes a
|
|
347
|
+
* password and normalizes an email, and a 1,000-row bulk spent half a
|
|
348
|
+
* minute hashing one password at a time. Leave it unset when a hook runs:
|
|
349
|
+
* preparations then run one at a time, in the order the rows were given.
|
|
350
|
+
*/
|
|
351
|
+
independent?: boolean;
|
|
278
352
|
}
|
|
279
353
|
/**
|
|
280
354
|
* Result of `AuthAdapter.finalizeUserCreation()`.
|
|
@@ -390,6 +464,23 @@ export interface AuthAdapter {
|
|
|
390
464
|
* @returns The authenticated user, or `null` if the token is invalid.
|
|
391
465
|
*/
|
|
392
466
|
verifyToken?(token: string): Promise<AuthenticatedUser | null>;
|
|
467
|
+
/**
|
|
468
|
+
* The identity a verified request from this account would carry right
|
|
469
|
+
* now, with no credential involved: its uid, its roles as they are now,
|
|
470
|
+
* its guest flag, and the custom claims a token minted for it now would
|
|
471
|
+
* hold. `null` when no active account has this uid — none at all, or one
|
|
472
|
+
* that is disabled.
|
|
473
|
+
*
|
|
474
|
+
* This is what lets an administrator run a request as another user (the
|
|
475
|
+
* {@link IMPERSONATE_HEADER} header). The server calls it only after it
|
|
476
|
+
* has decided the caller may do that, and it calls it for the caller too,
|
|
477
|
+
* so the decision rests on the caller's roles as they are now rather than
|
|
478
|
+
* on the ones their token claims.
|
|
479
|
+
*
|
|
480
|
+
* Optional. An adapter without it cannot be impersonated through, and a
|
|
481
|
+
* request carrying the header is refused rather than run as its caller.
|
|
482
|
+
*/
|
|
483
|
+
resolveUser?(uid: string): Promise<AuthenticatedUser | null>;
|
|
393
484
|
/**
|
|
394
485
|
* User CRUD for the admin panel's user management UI.
|
|
395
486
|
* Optional — if not provided, user management UI is hidden.
|
|
@@ -441,11 +532,15 @@ export interface AuthAdapter {
|
|
|
441
532
|
*
|
|
442
533
|
* If not implemented, the collection saves values as-is (no password hashing).
|
|
443
534
|
*
|
|
535
|
+
* A chosen `password` is held to the password policy unless the body says
|
|
536
|
+
* `skipPasswordPolicy: true` and `options.mayWaivePasswordPolicy` is set.
|
|
537
|
+
*
|
|
444
538
|
* @param values - Raw request body from the client.
|
|
445
539
|
* @param collectionAuth - The parsed `AuthCollectionConfig` from the collection (if `auth` is an object).
|
|
540
|
+
* @param options - What the door knows about its caller.
|
|
446
541
|
* @returns Processed values ready for `driver.save()`, plus metadata for the post-save step.
|
|
447
542
|
*/
|
|
448
|
-
prepareUserCreation?(values: Record<string, unknown>, collectionAuth?: unknown): Promise<UserCreationPrepareResult>;
|
|
543
|
+
prepareUserCreation?(values: Record<string, unknown>, collectionAuth?: unknown, options?: UserCreationOptions): Promise<UserCreationPrepareResult>;
|
|
449
544
|
/**
|
|
450
545
|
* Describe what a create body for this auth collection is allowed to name,
|
|
451
546
|
* so unknown-field validation can run on it.
|