@rebasepro/client 0.5.0 → 0.6.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/dist/admin.d.ts +2 -10
- package/dist/auth.d.ts +2 -1
- package/dist/index.d.ts +25 -17
- package/dist/index.es.js +2079 -2378
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2160 -2426
- package/dist/index.umd.js.map +1 -1
- package/dist/websocket.d.ts +9 -6
- package/package.json +13 -13
- package/src/admin.ts +3 -10
- package/src/auth.ts +9 -4
- package/src/collection.test.ts +11 -6
- package/src/functions.ts +2 -2
- package/src/index.ts +34 -22
- package/src/transport.ts +2 -2
- package/src/websocket.ts +121 -90
package/dist/admin.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { Transport } from "./transport";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
email: string;
|
|
5
|
-
displayName: string | null;
|
|
6
|
-
photoURL: string | null;
|
|
7
|
-
provider: string;
|
|
8
|
-
roles: string[];
|
|
9
|
-
createdAt: string;
|
|
10
|
-
updatedAt: string;
|
|
11
|
-
}
|
|
2
|
+
import { AdminUser } from "@rebasepro/types";
|
|
3
|
+
export type { AdminUser };
|
|
12
4
|
export interface CreateAdminOptions {
|
|
13
5
|
adminPath?: string;
|
|
14
6
|
}
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Transport } from "./transport";
|
|
2
|
+
import { AuthChangeEvent } from "@rebasepro/types";
|
|
2
3
|
export interface RebaseUser {
|
|
3
4
|
uid: string;
|
|
4
5
|
email: string | null;
|
|
@@ -20,7 +21,7 @@ export interface RebaseSession {
|
|
|
20
21
|
expiresAt: number;
|
|
21
22
|
user: RebaseUser;
|
|
22
23
|
}
|
|
23
|
-
export type AuthChangeEvent
|
|
24
|
+
export type { AuthChangeEvent };
|
|
24
25
|
export interface AuthConfig {
|
|
25
26
|
needsSetup: boolean;
|
|
26
27
|
registrationEnabled: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { createAuth, CreateAuthOptions } from "./auth";
|
|
|
3
3
|
import { createAdmin, CreateAdminOptions } from "./admin";
|
|
4
4
|
import { createCron, CreateCronOptions } from "./cron";
|
|
5
5
|
import { CollectionClient } from "./collection";
|
|
6
|
-
import
|
|
6
|
+
import { createFunctionsClient } from "./functions";
|
|
7
|
+
import { RebaseWebSocketClient } from "./websocket";
|
|
8
|
+
import { RebaseClient, RebaseData, StorageSource } from "@rebasepro/types";
|
|
7
9
|
export * from "./transport";
|
|
8
10
|
export * from "./auth";
|
|
9
11
|
export * from "./admin";
|
|
@@ -14,16 +16,30 @@ export * from "./websocket";
|
|
|
14
16
|
export * from "./storage";
|
|
15
17
|
export * from "./reviver";
|
|
16
18
|
export * from "./functions";
|
|
19
|
+
export type { Entity, FindResponse } from "@rebasepro/types";
|
|
17
20
|
export interface CreateRebaseClientOptions extends RebaseClientConfig {
|
|
18
21
|
auth?: CreateAuthOptions;
|
|
19
22
|
admin?: CreateAdminOptions;
|
|
20
23
|
cron?: CreateCronOptions;
|
|
21
24
|
}
|
|
22
|
-
import { RebaseWebSocketClient } from "./websocket";
|
|
23
|
-
import { RebaseClient as BaseRebaseClient, RebaseData, StorageSource } from "@rebasepro/types";
|
|
24
|
-
export type { Entity, FindResponse } from "@rebasepro/types";
|
|
25
25
|
type KebabToCamelCase<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamelCase<U>>}` : S;
|
|
26
|
-
|
|
26
|
+
type TypedDataLayer<DB> = {
|
|
27
|
+
collection<S extends string>(slug: S): CollectionClient<KebabToCamelCase<S> extends keyof DB ? (DB[KebabToCamelCase<S>] extends {
|
|
28
|
+
Row: infer R extends Record<string, unknown>;
|
|
29
|
+
} ? R : Record<string, unknown>) : Record<string, unknown>>;
|
|
30
|
+
} & {
|
|
31
|
+
[K in keyof DB]: CollectionClient<DB[K] extends {
|
|
32
|
+
Row: infer R extends Record<string, unknown>;
|
|
33
|
+
} ? R : Record<string, unknown>>;
|
|
34
|
+
} & RebaseData;
|
|
35
|
+
/**
|
|
36
|
+
* The return type of `createRebaseClient<DB>()`.
|
|
37
|
+
*
|
|
38
|
+
* This is `RebaseClient` (from `@rebasepro/types`) with all optional
|
|
39
|
+
* capabilities populated and the `data` layer narrowed to provide
|
|
40
|
+
* typed collection accessors when a `DB` schema generic is supplied.
|
|
41
|
+
*/
|
|
42
|
+
export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<RebaseClient, "data"> & {
|
|
27
43
|
setToken: (token: string | null) => void;
|
|
28
44
|
setAuthTokenGetter: (getter: () => Promise<string | null>) => void;
|
|
29
45
|
setOnUnauthorized: (handler: () => Promise<boolean>) => void;
|
|
@@ -31,18 +47,10 @@ export type RebaseClient<DB = Record<string, unknown>> = Omit<BaseRebaseClient<D
|
|
|
31
47
|
auth: ReturnType<typeof createAuth>;
|
|
32
48
|
admin: ReturnType<typeof createAdmin>;
|
|
33
49
|
cron: ReturnType<typeof createCron>;
|
|
34
|
-
functions:
|
|
50
|
+
functions: ReturnType<typeof createFunctionsClient>;
|
|
35
51
|
ws?: RebaseWebSocketClient;
|
|
36
|
-
storage
|
|
52
|
+
storage: StorageSource;
|
|
37
53
|
call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
|
|
38
|
-
data:
|
|
39
|
-
collection<S extends string>(slug: S): CollectionClient<KebabToCamelCase<S> extends keyof DB ? (DB[KebabToCamelCase<S>] extends {
|
|
40
|
-
Row: infer R extends Record<string, unknown>;
|
|
41
|
-
} ? R : Record<string, unknown>) : Record<string, unknown>>;
|
|
42
|
-
} & {
|
|
43
|
-
[K in keyof DB]: CollectionClient<DB[K] extends {
|
|
44
|
-
Row: infer R extends Record<string, unknown>;
|
|
45
|
-
} ? R : Record<string, unknown>>;
|
|
46
|
-
} & RebaseData;
|
|
54
|
+
data: TypedDataLayer<DB>;
|
|
47
55
|
};
|
|
48
|
-
export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions):
|
|
56
|
+
export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions): CreateRebaseClientResult<DB>;
|