@rebasepro/types 0.34.1 → 0.35.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 +23 -1
- package/dist/index.es.js +594 -5
- package/dist/index.es.js.map +1 -1
- package/dist/schema/column_options.d.ts +6 -0
- package/dist/schema/columns.d.ts +12 -1
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/rpc.d.ts +148 -0
- package/dist/types/backend.d.ts +118 -0
- package/dist/types/channel_bus.d.ts +5 -5
- package/dist/types/database_adapter.d.ts +7 -1
- package/dist/types/project_manifest.d.ts +198 -0
- package/dist/types/storage_authorize.d.ts +54 -0
- package/dist/users/import.d.ts +123 -0
- package/dist/users/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ export interface StorageAuthorizeUser {
|
|
|
14
14
|
uid: string;
|
|
15
15
|
email?: string;
|
|
16
16
|
roles?: string[];
|
|
17
|
+
claims?: Record<string, unknown>;
|
|
17
18
|
}
|
|
18
19
|
export interface StorageAuthorizeContext {
|
|
19
20
|
/** Object key, bucket prefix stripped and traversal already sanitized. */
|
|
@@ -81,3 +82,56 @@ export interface StorageAuthorizeData {
|
|
|
81
82
|
* Return false (or throw) to deny. Denials surface as 403.
|
|
82
83
|
*/
|
|
83
84
|
export type StorageAuthorize = (ctx: StorageAuthorizeContext) => boolean | Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* Who a {@link StorageRule} grants to — data only, so it can live in an
|
|
87
|
+
* environment variable and be edited in a console:
|
|
88
|
+
*
|
|
89
|
+
* - `"public"` — anyone, signed in or not
|
|
90
|
+
* - `"authenticated"` — any signed-in caller
|
|
91
|
+
* - `"owner"` — the signed-in caller whose uid is the key's `:uid` segment
|
|
92
|
+
* (the rule's `path` must capture one)
|
|
93
|
+
* - `{ roles: [...] }` — a signed-in caller holding any of these roles
|
|
94
|
+
*
|
|
95
|
+
* @group Storage
|
|
96
|
+
*/
|
|
97
|
+
export type StorageRuleAllow = "public" | "authenticated" | "owner" | {
|
|
98
|
+
roles: string[];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* One storage access rule, as data: the form `STORAGE_POLICIES` takes (a JSON
|
|
102
|
+
* array of these), for a deployment that runs no code of its own — the managed
|
|
103
|
+
* runtime, Rebase Cloud's console. The same deny-by-default list as
|
|
104
|
+
* `storagePolicies`: a key no rule matches is refused, and a rule that matched
|
|
105
|
+
* and did not grant is a denial.
|
|
106
|
+
*
|
|
107
|
+
* ```json
|
|
108
|
+
* [
|
|
109
|
+
* { "path": "public/**", "operations": ["read"], "allow": "public" },
|
|
110
|
+
* { "path": "users/:uid/**", "allow": "owner" },
|
|
111
|
+
* { "path": "**", "allow": { "roles": ["admin"] } }
|
|
112
|
+
* ]
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @group Storage
|
|
116
|
+
*/
|
|
117
|
+
export interface StorageRule {
|
|
118
|
+
/**
|
|
119
|
+
* A key pattern, matched segment by segment: a literal matches itself,
|
|
120
|
+
* `*` one segment, `:name` one segment and captures it, `**` the rest
|
|
121
|
+
* (final segment only).
|
|
122
|
+
*/
|
|
123
|
+
path: string;
|
|
124
|
+
/** Which operations it grants. Every one of them when omitted. */
|
|
125
|
+
operations?: StorageOperation[];
|
|
126
|
+
allow: StorageRuleAllow;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Where a project with no storage rules of its own starts — what Rebase
|
|
130
|
+
* Cloud gives a new project and what its console offers as "recommended":
|
|
131
|
+
* a `public/` folder anyone may read, a `users/<uid>/` folder only its user
|
|
132
|
+
* may touch, and every key to admins. Rules are deny-by-default, so this is
|
|
133
|
+
* also everything a caller may do.
|
|
134
|
+
*
|
|
135
|
+
* @group Storage
|
|
136
|
+
*/
|
|
137
|
+
export declare const RECOMMENDED_STORAGE_RULES: readonly StorageRule[];
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Importing accounts from another system: `POST /admin/users/import`,
|
|
3
|
+
* `client.admin.importUsers()` and `rebase users import`.
|
|
4
|
+
*
|
|
5
|
+
* An import keeps the ids the accounts had, so every row that points at a user
|
|
6
|
+
* still points at the same one. It carries no password and sends no email: an
|
|
7
|
+
* imported account signs in by magic link, an email code, a provider, or a
|
|
8
|
+
* password reset.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The most accounts one `POST /admin/users/import` takes. The CLI sends a
|
|
12
|
+
* longer file in requests of this size.
|
|
13
|
+
*
|
|
14
|
+
* @group Admin
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_USERS_PER_IMPORT = 100;
|
|
17
|
+
/**
|
|
18
|
+
* The longest id an imported account may keep.
|
|
19
|
+
*
|
|
20
|
+
* @group Admin
|
|
21
|
+
*/
|
|
22
|
+
export declare const MAX_IMPORTED_USER_ID_LENGTH = 128;
|
|
23
|
+
/**
|
|
24
|
+
* Why `id` cannot be kept as an imported account's id, or `undefined` when it
|
|
25
|
+
* can.
|
|
26
|
+
*
|
|
27
|
+
* A uuid is the common case (Supabase, Cognito). Other systems' ids fit too:
|
|
28
|
+
* letters, digits and `_ - . : |`, starting with a letter or a digit, at most
|
|
29
|
+
* {@link MAX_IMPORTED_USER_ID_LENGTH} characters (Firebase's 28-character
|
|
30
|
+
* uids, Auth0's `auth0|5f7c…`, Clerk's `user_2abc…`). Refused: what would read
|
|
31
|
+
* as something else on the way through a URL, a storage path or a CLI argument
|
|
32
|
+
* (`/`, `?`, `%`, whitespace, `@`, which the CLI reads as an email), and the
|
|
33
|
+
* ids that already name a caller who is not an account (`service`,
|
|
34
|
+
* `anonymous`).
|
|
35
|
+
*
|
|
36
|
+
* The users table's id column has the last word: a uuid column refuses an id
|
|
37
|
+
* that is not a uuid.
|
|
38
|
+
*
|
|
39
|
+
* @group Admin
|
|
40
|
+
*/
|
|
41
|
+
export declare function importedUserIdProblem(id: unknown): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* One account to import.
|
|
44
|
+
*
|
|
45
|
+
* @group Admin
|
|
46
|
+
*/
|
|
47
|
+
export interface ImportUserInput {
|
|
48
|
+
/**
|
|
49
|
+
* The id the account had in the system it comes from, kept as its id here.
|
|
50
|
+
* Omitted, the users table generates one. See {@link importedUserIdProblem}.
|
|
51
|
+
*/
|
|
52
|
+
id?: string;
|
|
53
|
+
email: string;
|
|
54
|
+
displayName?: string;
|
|
55
|
+
photoUrl?: string;
|
|
56
|
+
/** When the account was created in the system it comes from, as an ISO 8601 date. Omitted: now. */
|
|
57
|
+
createdAt?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Whether that system had confirmed the address. Omitted: `false`, and the
|
|
60
|
+
* first magic link or reset the account follows confirms it. An unconfirmed
|
|
61
|
+
* account cannot be signed into by a provider (Google, GitHub) until then.
|
|
62
|
+
*/
|
|
63
|
+
emailVerified?: boolean;
|
|
64
|
+
/** Role names, as `POST /admin/users` takes them. No caller may grant a role above its own. */
|
|
65
|
+
roles?: string[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The body of `POST /admin/users/import`.
|
|
69
|
+
*
|
|
70
|
+
* @group Admin
|
|
71
|
+
*/
|
|
72
|
+
export interface ImportUsersRequest {
|
|
73
|
+
/** At most {@link MAX_USERS_PER_IMPORT}. */
|
|
74
|
+
users: ImportUserInput[];
|
|
75
|
+
/** Check every account and report what would happen, writing nothing. */
|
|
76
|
+
dryRun?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* What happened to one account of an import. `index` is its place in the
|
|
80
|
+
* request's `users`.
|
|
81
|
+
*
|
|
82
|
+
* - `created`: the account exists now (with `dryRun`, it would be created).
|
|
83
|
+
* - `skipped`: an account already holds the id (`ID_EXISTS`) or the email
|
|
84
|
+
* (`EMAIL_EXISTS`), an earlier one in this request included. It is left as
|
|
85
|
+
* it is: an import never updates an account.
|
|
86
|
+
* - `failed`: the account was refused, and `code` and `message` say why.
|
|
87
|
+
*
|
|
88
|
+
* @group Admin
|
|
89
|
+
*/
|
|
90
|
+
export type ImportUserOutcome = {
|
|
91
|
+
index: number;
|
|
92
|
+
status: "created";
|
|
93
|
+
uid?: string;
|
|
94
|
+
email: string;
|
|
95
|
+
} | {
|
|
96
|
+
index: number;
|
|
97
|
+
status: "skipped";
|
|
98
|
+
uid?: string;
|
|
99
|
+
email: string;
|
|
100
|
+
code: "ID_EXISTS" | "EMAIL_EXISTS";
|
|
101
|
+
message: string;
|
|
102
|
+
} | {
|
|
103
|
+
index: number;
|
|
104
|
+
status: "failed";
|
|
105
|
+
uid?: string;
|
|
106
|
+
email?: string;
|
|
107
|
+
code: string;
|
|
108
|
+
message: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The answer of `POST /admin/users/import`: one outcome per account, in the
|
|
112
|
+
* order they were sent, and how many of each.
|
|
113
|
+
*
|
|
114
|
+
* @group Admin
|
|
115
|
+
*/
|
|
116
|
+
export interface ImportUsersResult {
|
|
117
|
+
/** Nothing was written: `created` counts the accounts that would be. */
|
|
118
|
+
dryRun: boolean;
|
|
119
|
+
created: number;
|
|
120
|
+
skipped: number;
|
|
121
|
+
failed: number;
|
|
122
|
+
results: ImportUserOutcome[];
|
|
123
|
+
}
|
package/dist/users/index.d.ts
CHANGED