@rebasepro/client 0.6.1 → 0.8.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/admin.d.ts +13 -0
- package/dist/api-keys.d.ts +66 -0
- package/dist/auth.d.ts +10 -0
- package/dist/collection.d.ts +3 -3
- package/dist/index.d.ts +24 -1
- package/dist/index.es.js +218 -167
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +222 -169
- package/dist/index.umd.js.map +1 -1
- package/dist/storage-registry.d.ts +42 -0
- package/dist/storage.d.ts +9 -1
- package/package.json +5 -4
- package/src/admin.ts +19 -0
- package/src/api-keys.ts +110 -0
- package/src/auth.ts +30 -0
- package/src/collection.test.ts +2 -2
- package/src/collection.ts +41 -119
- package/src/index.ts +83 -2
- package/src/storage-registry.ts +102 -0
- package/src/storage.ts +30 -20
- package/src/transport.ts +8 -82
package/dist/admin.d.ts
CHANGED
|
@@ -42,6 +42,19 @@ export declare function createAdmin(transport: Transport, options?: CreateAdminO
|
|
|
42
42
|
deleteUser: (userId: string) => Promise<{
|
|
43
43
|
success: boolean;
|
|
44
44
|
}>;
|
|
45
|
+
resetPassword: (userId: string, options?: {
|
|
46
|
+
password?: string;
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
user: AdminUser;
|
|
49
|
+
temporaryPassword?: string;
|
|
50
|
+
invitationSent?: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
listRoles: () => Promise<{
|
|
53
|
+
roles: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
}>;
|
|
57
|
+
}>;
|
|
45
58
|
bootstrap: () => Promise<{
|
|
46
59
|
success: boolean;
|
|
47
60
|
message: string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Transport } from "./transport";
|
|
2
|
+
/** A single permission entry scoping an API key to a collection and its allowed operations. */
|
|
3
|
+
export interface ApiKeyPermission {
|
|
4
|
+
collection: string;
|
|
5
|
+
operations: ("read" | "write" | "delete")[];
|
|
6
|
+
}
|
|
7
|
+
/** An API key with the secret portion masked (returned by list / get / update). */
|
|
8
|
+
export interface ApiKeyMasked {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
key_prefix: string;
|
|
12
|
+
permissions: ApiKeyPermission[];
|
|
13
|
+
admin: boolean;
|
|
14
|
+
rate_limit: number | null;
|
|
15
|
+
created_by: string;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
last_used_at: string | null;
|
|
19
|
+
expires_at: string | null;
|
|
20
|
+
revoked_at: string | null;
|
|
21
|
+
}
|
|
22
|
+
/** An API key including the full secret (returned only on creation). */
|
|
23
|
+
export interface ApiKeyWithSecret extends ApiKeyMasked {
|
|
24
|
+
key: string;
|
|
25
|
+
}
|
|
26
|
+
/** Payload for creating a new API key. */
|
|
27
|
+
export interface CreateApiKeyRequest {
|
|
28
|
+
name: string;
|
|
29
|
+
permissions: ApiKeyPermission[];
|
|
30
|
+
rate_limit?: number | null;
|
|
31
|
+
expires_at?: string | null;
|
|
32
|
+
}
|
|
33
|
+
/** Payload for updating an existing API key. */
|
|
34
|
+
export interface UpdateApiKeyRequest {
|
|
35
|
+
name?: string;
|
|
36
|
+
permissions?: ApiKeyPermission[];
|
|
37
|
+
rate_limit?: number | null;
|
|
38
|
+
expires_at?: string | null;
|
|
39
|
+
}
|
|
40
|
+
/** Options for the `createApiKeys` factory. */
|
|
41
|
+
export interface CreateApiKeysOptions {
|
|
42
|
+
apiKeysPath?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a client for managing API keys via the admin routes.
|
|
46
|
+
*
|
|
47
|
+
* @param transport - The shared HTTP transport created by `createTransport`.
|
|
48
|
+
* @param options - Optional overrides (e.g. a custom base path).
|
|
49
|
+
*/
|
|
50
|
+
export declare function createApiKeys(transport: Transport, options?: CreateApiKeysOptions): {
|
|
51
|
+
listKeys: () => Promise<{
|
|
52
|
+
keys: ApiKeyMasked[];
|
|
53
|
+
}>;
|
|
54
|
+
getKey: (id: string) => Promise<{
|
|
55
|
+
key: ApiKeyMasked;
|
|
56
|
+
}>;
|
|
57
|
+
createKey: (data: CreateApiKeyRequest) => Promise<{
|
|
58
|
+
key: ApiKeyWithSecret;
|
|
59
|
+
}>;
|
|
60
|
+
updateKey: (id: string, data: UpdateApiKeyRequest) => Promise<{
|
|
61
|
+
key: ApiKeyMasked;
|
|
62
|
+
}>;
|
|
63
|
+
revokeKey: (id: string) => Promise<{
|
|
64
|
+
success: boolean;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
package/dist/auth.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface AuthConfig {
|
|
|
28
28
|
emailServiceEnabled?: boolean;
|
|
29
29
|
passwordReset?: boolean;
|
|
30
30
|
emailVerification?: boolean;
|
|
31
|
+
magicLink?: boolean;
|
|
31
32
|
enabledProviders: string[];
|
|
32
33
|
}
|
|
33
34
|
export interface AuthStorage {
|
|
@@ -158,6 +159,15 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
|
|
|
158
159
|
success: boolean;
|
|
159
160
|
message: string;
|
|
160
161
|
}>;
|
|
162
|
+
sendMagicLink: (email: string) => Promise<{
|
|
163
|
+
success: boolean;
|
|
164
|
+
message: string;
|
|
165
|
+
}>;
|
|
166
|
+
verifyMagicLink: (token: string) => Promise<{
|
|
167
|
+
user: RebaseUser;
|
|
168
|
+
accessToken: string;
|
|
169
|
+
refreshToken: string;
|
|
170
|
+
}>;
|
|
161
171
|
getSessions: () => Promise<Record<string, unknown>[]>;
|
|
162
172
|
revokeSession: (sessionId: string) => Promise<{
|
|
163
173
|
success: boolean;
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FindParams, Transport } from "./transport";
|
|
2
2
|
import { RebaseWebSocketClient } from "./websocket";
|
|
3
|
-
import { CollectionAccessor,
|
|
3
|
+
import { CollectionAccessor, LogicalCondition, WhereFilterOp, WhereValue } from "@rebasepro/types";
|
|
4
4
|
import { QueryBuilder } from "./query_builder";
|
|
5
5
|
/**
|
|
6
6
|
* CollectionClient extends `CollectionAccessor` from `@rebasepro/types` so that
|
|
@@ -9,9 +9,9 @@ import { QueryBuilder } from "./query_builder";
|
|
|
9
9
|
* Additionally it exposes fluent query builder methods like `.where()`, `.orderBy()`.
|
|
10
10
|
*/
|
|
11
11
|
export interface CollectionClient<M extends Record<string, unknown> = Record<string, unknown>> extends CollectionAccessor<M> {
|
|
12
|
-
where<K extends keyof M & string>(column: K, operator:
|
|
12
|
+
where<K extends keyof M & string>(column: K, operator: WhereFilterOp, value: WhereValue<M[K]>): QueryBuilder<M>;
|
|
13
13
|
where(logicalCondition: LogicalCondition): QueryBuilder<M>;
|
|
14
|
-
orderBy(column: keyof M & string,
|
|
14
|
+
orderBy(column: keyof M & string, direction?: "asc" | "desc"): QueryBuilder<M>;
|
|
15
15
|
limit(count: number): QueryBuilder<M>;
|
|
16
16
|
offset(count: number): QueryBuilder<M>;
|
|
17
17
|
search(searchString: string): QueryBuilder<M>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,18 +2,21 @@ import { RebaseClientConfig } from "./transport";
|
|
|
2
2
|
import { createAuth, CreateAuthOptions } from "./auth";
|
|
3
3
|
import { createAdmin, CreateAdminOptions } from "./admin";
|
|
4
4
|
import { createCron, CreateCronOptions } from "./cron";
|
|
5
|
+
import { createApiKeys, CreateApiKeysOptions } from "./api-keys";
|
|
5
6
|
import { CollectionClient } from "./collection";
|
|
6
7
|
import { createFunctionsClient } from "./functions";
|
|
7
8
|
import { RebaseWebSocketClient } from "./websocket";
|
|
8
|
-
import { RebaseClient, RebaseData, StorageSource } from "@rebasepro/types";
|
|
9
|
+
import { RebaseClient, RebaseData, StorageSource, StorageSourceDefinition, StorageSourceRegistry } from "@rebasepro/types";
|
|
9
10
|
export * from "./transport";
|
|
10
11
|
export * from "./auth";
|
|
11
12
|
export * from "./admin";
|
|
12
13
|
export * from "./cron";
|
|
14
|
+
export * from "./api-keys";
|
|
13
15
|
export * from "./collection";
|
|
14
16
|
export * from "./query_builder";
|
|
15
17
|
export * from "./websocket";
|
|
16
18
|
export * from "./storage";
|
|
19
|
+
export * from "./storage-registry";
|
|
17
20
|
export * from "./reviver";
|
|
18
21
|
export * from "./functions";
|
|
19
22
|
export type { Entity, FindResponse } from "@rebasepro/types";
|
|
@@ -21,6 +24,22 @@ export interface CreateRebaseClientOptions extends RebaseClientConfig {
|
|
|
21
24
|
auth?: CreateAuthOptions;
|
|
22
25
|
admin?: CreateAdminOptions;
|
|
23
26
|
cron?: CreateCronOptions;
|
|
27
|
+
apiKeys?: CreateApiKeysOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Declared storage sources for multi-backend support. Server-transport
|
|
30
|
+
* entries are auto-wired into `client.storageRegistry`; `direct` sources
|
|
31
|
+
* are registered app-side (e.g. via a Firebase Storage hook). The default
|
|
32
|
+
* source (`storage`) is always registered under
|
|
33
|
+
* {@link DEFAULT_STORAGE_SOURCE_KEY}.
|
|
34
|
+
*/
|
|
35
|
+
storageSources?: StorageSourceDefinition[];
|
|
36
|
+
/**
|
|
37
|
+
* Maps camelCase property names / safe identifiers to the actual
|
|
38
|
+
* collection slugs on the server (e.g. `{ companyMembers: "company-members" }`).
|
|
39
|
+
* If provided, the data layer proxy will resolve property accessors to their
|
|
40
|
+
* correct slugs via this map before falling back to automatic snake_casing.
|
|
41
|
+
*/
|
|
42
|
+
collections?: Record<string, string>;
|
|
24
43
|
}
|
|
25
44
|
type KebabToCamelCase<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamelCase<U>>}` : S;
|
|
26
45
|
type TypedDataLayer<DB> = {
|
|
@@ -47,9 +66,13 @@ export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<Rebase
|
|
|
47
66
|
auth: ReturnType<typeof createAuth>;
|
|
48
67
|
admin: ReturnType<typeof createAdmin>;
|
|
49
68
|
cron: ReturnType<typeof createCron>;
|
|
69
|
+
apiKeys: ReturnType<typeof createApiKeys>;
|
|
50
70
|
functions: ReturnType<typeof createFunctionsClient>;
|
|
51
71
|
ws?: RebaseWebSocketClient;
|
|
52
72
|
storage: StorageSource;
|
|
73
|
+
storageRegistry: StorageSourceRegistry;
|
|
74
|
+
createStorageSource: (storageId: string) => StorageSource;
|
|
75
|
+
fetchStorageSources: () => Promise<StorageSourceDefinition[]>;
|
|
53
76
|
call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
|
|
54
77
|
data: TypedDataLayer<DB>;
|
|
55
78
|
};
|