@rebasepro/client 0.0.1-canary.eae7889 → 0.0.1-canary.eb08332
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/LICENSE +21 -6
- package/README.md +164 -0
- package/dist/admin.d.ts +14 -41
- package/dist/api-keys.d.ts +66 -0
- package/dist/auth.d.ts +64 -39
- package/dist/backups.d.ts +13 -0
- package/dist/collection.d.ts +11 -13
- package/dist/collection.test.d.ts +1 -0
- package/dist/data-proxy.test.d.ts +1 -0
- package/dist/errors.d.ts +9 -0
- package/dist/functions.d.ts +49 -0
- package/dist/index.d.ts +64 -22
- package/dist/index.es.js +2438 -2249
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2511 -2277
- package/dist/index.umd.js.map +1 -1
- package/dist/query_builder.d.ts +1 -53
- package/dist/sdk_query_builder.d.ts +63 -0
- package/dist/storage-registry.d.ts +42 -0
- package/dist/storage.d.ts +9 -1
- package/dist/transport.d.ts +2 -6
- package/dist/websocket.d.ts +39 -26
- package/package.json +15 -15
- package/src/admin.ts +17 -46
- package/src/api-keys.ts +110 -0
- package/src/auth.ts +299 -66
- package/src/backups.ts +40 -0
- package/src/collection.test.ts +253 -0
- package/src/collection.ts +139 -168
- package/src/data-proxy.test.ts +167 -0
- package/src/errors.ts +9 -0
- package/src/functions.ts +80 -0
- package/src/index.ts +301 -38
- package/src/query_builder.ts +1 -125
- package/src/reviver.ts +2 -2
- package/src/sdk_query_builder.ts +138 -0
- package/src/storage-registry.ts +102 -0
- package/src/storage.ts +92 -50
- package/src/transport.ts +53 -85
- package/src/websocket.ts +323 -164
package/dist/index.d.ts
CHANGED
|
@@ -2,23 +2,67 @@ 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 { createBackups } from "./backups";
|
|
6
|
+
import { createApiKeys, CreateApiKeysOptions } from "./api-keys";
|
|
5
7
|
import { CollectionClient } from "./collection";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
8
|
+
import { createFunctionsClient } from "./functions";
|
|
9
|
+
import { RebaseWebSocketClient } from "./websocket";
|
|
10
|
+
import { InsertOf, RebaseClient, RebaseSdkData, RowOf, StorageSource, StorageSourceDefinition, StorageSourceRegistry, UpdateOf } from "@rebasepro/types";
|
|
11
|
+
export { RebaseApiError } from "./transport";
|
|
12
|
+
export { RebaseClientError } from "./errors";
|
|
13
|
+
export type { RebaseClientConfig, FindParams, FindResponse } from "./transport";
|
|
14
|
+
export type { CollectionClient } from "./collection";
|
|
15
|
+
export type { FindResult, SDKCollectionClient, SDKQueryBuilderInterface, PaginationMeta } from "@rebasepro/types";
|
|
16
|
+
export { QueryBuilder, or, and, cond } from "@rebasepro/common";
|
|
17
|
+
export { createCookieStorage, createMemoryStorage } from "./auth";
|
|
18
|
+
export type { AuthConfig, AuthStorage, CookieStorageOptions, CreateAuthOptions } from "./auth";
|
|
19
|
+
export type { RebaseSession, AuthTokens, AuthChangeEvent, DeviceSession } from "@rebasepro/types";
|
|
20
|
+
/** @deprecated Import `User` / `AuthTokens` from `@rebasepro/types` instead. */
|
|
21
|
+
export type { RebaseUser, RebaseTokens } from "./auth";
|
|
22
|
+
export type { CreateAdminOptions } from "./admin";
|
|
23
|
+
export type { AdminUser } from "./admin";
|
|
24
|
+
export type { CreateCronOptions } from "./cron";
|
|
25
|
+
export { createBackups } from "./backups";
|
|
26
|
+
export type { CreateBackupsOptions } from "./backups";
|
|
27
|
+
export type { ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, CreateApiKeysOptions, UpdateApiKeyRequest } from "./api-keys";
|
|
28
|
+
export type { FunctionInvokeOptions, FunctionsClient } from "./functions";
|
|
29
|
+
export { RebaseWebSocketClient } from "./websocket";
|
|
14
30
|
export interface CreateRebaseClientOptions extends RebaseClientConfig {
|
|
15
31
|
auth?: CreateAuthOptions;
|
|
16
32
|
admin?: CreateAdminOptions;
|
|
17
33
|
cron?: CreateCronOptions;
|
|
34
|
+
apiKeys?: CreateApiKeysOptions;
|
|
35
|
+
/**
|
|
36
|
+
* Declared storage sources for multi-backend support. Server-transport
|
|
37
|
+
* entries are auto-wired into `client.storageRegistry`; `direct` sources
|
|
38
|
+
* are registered app-side (e.g. via a Firebase Storage hook). The default
|
|
39
|
+
* source (`storage`) is always registered under
|
|
40
|
+
* {@link DEFAULT_STORAGE_SOURCE_KEY}.
|
|
41
|
+
*/
|
|
42
|
+
storageSources?: StorageSourceDefinition[];
|
|
43
|
+
/**
|
|
44
|
+
* Maps camelCase property names / safe identifiers to the actual
|
|
45
|
+
* collection slugs on the server (e.g. `{ companyMembers: "company-members" }`).
|
|
46
|
+
* If provided, the data layer proxy will resolve property accessors to their
|
|
47
|
+
* correct slugs via this map before falling back to automatic snake_casing.
|
|
48
|
+
*/
|
|
49
|
+
collections?: Record<string, string>;
|
|
18
50
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
51
|
+
type KebabToCamelCase<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamelCase<U>>}` : S;
|
|
52
|
+
type DBEntry<DB, S extends string> = KebabToCamelCase<S> extends keyof DB ? DB[KebabToCamelCase<S>] : unknown;
|
|
53
|
+
type TypedDataLayer<DB> = {
|
|
54
|
+
collection<S extends string>(slug: S): CollectionClient<RowOf<DBEntry<DB, S>>, InsertOf<DBEntry<DB, S>>, UpdateOf<DBEntry<DB, S>>>;
|
|
55
|
+
} & {
|
|
56
|
+
[K in keyof DB]: CollectionClient<RowOf<DB[K]>, InsertOf<DB[K]>, UpdateOf<DB[K]>>;
|
|
57
|
+
} & RebaseSdkData;
|
|
58
|
+
/**
|
|
59
|
+
* The return type of `createRebaseClient<DB>()`.
|
|
60
|
+
*
|
|
61
|
+
* This is `RebaseClient` (from `@rebasepro/types`) with all optional
|
|
62
|
+
* capabilities populated and the `data` layer narrowed to provide
|
|
63
|
+
* typed collection accessors when a `DB` schema generic is supplied.
|
|
64
|
+
*/
|
|
65
|
+
export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<RebaseClient<DB>, "data" | "email"> & {
|
|
22
66
|
setToken: (token: string | null) => void;
|
|
23
67
|
setAuthTokenGetter: (getter: () => Promise<string | null>) => void;
|
|
24
68
|
setOnUnauthorized: (handler: () => Promise<boolean>) => void;
|
|
@@ -26,17 +70,15 @@ export type RebaseClient<DB = Record<string, unknown>> = BaseRebaseClient<DB> &
|
|
|
26
70
|
auth: ReturnType<typeof createAuth>;
|
|
27
71
|
admin: ReturnType<typeof createAdmin>;
|
|
28
72
|
cron: ReturnType<typeof createCron>;
|
|
73
|
+
backups: ReturnType<typeof createBackups>;
|
|
74
|
+
apiKeys: ReturnType<typeof createApiKeys>;
|
|
75
|
+
functions: ReturnType<typeof createFunctionsClient>;
|
|
29
76
|
ws?: RebaseWebSocketClient;
|
|
30
|
-
storage
|
|
77
|
+
storage: StorageSource;
|
|
78
|
+
storageRegistry: StorageSourceRegistry;
|
|
79
|
+
createStorageSource: (storageId: string) => StorageSource;
|
|
80
|
+
fetchStorageSources: () => Promise<StorageSourceDefinition[]>;
|
|
31
81
|
call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
|
|
32
|
-
data:
|
|
33
|
-
collection<K extends keyof DB>(slug: Extract<K, string>): CollectionClient<DB[K] extends {
|
|
34
|
-
Row: infer R extends Record<string, unknown>;
|
|
35
|
-
} ? R : Record<string, unknown>>;
|
|
36
|
-
} & {
|
|
37
|
-
[K in keyof DB]: CollectionClient<DB[K] extends {
|
|
38
|
-
Row: infer R extends Record<string, unknown>;
|
|
39
|
-
} ? R : Record<string, unknown>>;
|
|
40
|
-
};
|
|
82
|
+
data: TypedDataLayer<DB>;
|
|
41
83
|
};
|
|
42
|
-
export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions):
|
|
84
|
+
export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions): CreateRebaseClientResult<DB>;
|