@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/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
- export * from "./transport";
7
- export * from "./auth";
8
- export * from "./admin";
9
- export * from "./cron";
10
- export * from "./collection";
11
- export * from "./websocket";
12
- export * from "./storage";
13
- export * from "./reviver";
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
- import { RebaseWebSocketClient } from "./websocket";
20
- import { RebaseClient as BaseRebaseClient, RebaseData, StorageSource } from "@rebasepro/types";
21
- export type RebaseClient<DB = Record<string, unknown>> = BaseRebaseClient<DB> & {
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?: StorageSource;
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: RebaseData & {
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): RebaseClient<DB>;
84
+ export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions): CreateRebaseClientResult<DB>;