@rebasepro/client-postgresql 0.4.0 → 0.6.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.
Files changed (75) hide show
  1. package/README.md +51 -83
  2. package/dist/index.es.js +117 -163
  3. package/dist/index.es.js.map +1 -1
  4. package/dist/index.umd.js +121 -166
  5. package/dist/index.umd.js.map +1 -1
  6. package/package.json +12 -10
  7. package/test/usePostgresClientDriver.test.tsx +101 -0
  8. package/tsconfig.json +2 -0
  9. package/tsconfig.prod.json +4 -1
  10. package/vite.config.ts +0 -1
  11. package/dist/client/src/admin.d.ts +0 -61
  12. package/dist/client/src/auth.d.ts +0 -178
  13. package/dist/client/src/collection.d.ts +0 -21
  14. package/dist/client/src/cron.d.ts +0 -25
  15. package/dist/client/src/functions.d.ts +0 -49
  16. package/dist/client/src/index.d.ts +0 -48
  17. package/dist/client/src/query_builder.d.ts +0 -1
  18. package/dist/client/src/reviver.d.ts +0 -1
  19. package/dist/client/src/storage.d.ts +0 -3
  20. package/dist/client/src/transport.d.ts +0 -33
  21. package/dist/client/src/websocket.d.ts +0 -105
  22. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  23. package/dist/types/src/controllers/auth.d.ts +0 -104
  24. package/dist/types/src/controllers/client.d.ts +0 -168
  25. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  26. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  27. package/dist/types/src/controllers/data.d.ts +0 -207
  28. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  29. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  30. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  31. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  32. package/dist/types/src/controllers/email.d.ts +0 -36
  33. package/dist/types/src/controllers/index.d.ts +0 -18
  34. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  35. package/dist/types/src/controllers/navigation.d.ts +0 -225
  36. package/dist/types/src/controllers/registry.d.ts +0 -63
  37. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  38. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  39. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  40. package/dist/types/src/controllers/storage.d.ts +0 -171
  41. package/dist/types/src/index.d.ts +0 -4
  42. package/dist/types/src/rebase_context.d.ts +0 -122
  43. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  44. package/dist/types/src/types/backend.d.ts +0 -536
  45. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  46. package/dist/types/src/types/builders.d.ts +0 -15
  47. package/dist/types/src/types/chips.d.ts +0 -5
  48. package/dist/types/src/types/collections.d.ts +0 -941
  49. package/dist/types/src/types/component_ref.d.ts +0 -47
  50. package/dist/types/src/types/cron.d.ts +0 -102
  51. package/dist/types/src/types/data_source.d.ts +0 -64
  52. package/dist/types/src/types/database_adapter.d.ts +0 -94
  53. package/dist/types/src/types/entities.d.ts +0 -145
  54. package/dist/types/src/types/entity_actions.d.ts +0 -104
  55. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  56. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  57. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  58. package/dist/types/src/types/entity_views.d.ts +0 -87
  59. package/dist/types/src/types/export_import.d.ts +0 -21
  60. package/dist/types/src/types/formex.d.ts +0 -40
  61. package/dist/types/src/types/index.d.ts +0 -28
  62. package/dist/types/src/types/locales.d.ts +0 -4
  63. package/dist/types/src/types/modify_collections.d.ts +0 -5
  64. package/dist/types/src/types/plugins.d.ts +0 -282
  65. package/dist/types/src/types/properties.d.ts +0 -1181
  66. package/dist/types/src/types/property_config.d.ts +0 -74
  67. package/dist/types/src/types/relations.d.ts +0 -336
  68. package/dist/types/src/types/slots.d.ts +0 -262
  69. package/dist/types/src/types/translations.d.ts +0 -900
  70. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  71. package/dist/types/src/types/websockets.d.ts +0 -78
  72. package/dist/types/src/users/index.d.ts +0 -1
  73. package/dist/types/src/users/user.d.ts +0 -50
  74. /package/dist/{client-postgresql/src/index.d.ts → index.d.ts} +0 -0
  75. /package/dist/{client-postgresql/src/usePostgresClientDriver.d.ts → usePostgresClientDriver.d.ts} +0 -0
@@ -1,178 +0,0 @@
1
- import { Transport } from "./transport";
2
- export interface RebaseUser {
3
- uid: string;
4
- email: string | null;
5
- displayName: string | null;
6
- photoURL: string | null;
7
- emailVerified?: boolean;
8
- roles?: string[];
9
- providerId: string;
10
- isAnonymous: boolean;
11
- }
12
- export interface RebaseTokens {
13
- accessToken: string;
14
- refreshToken: string;
15
- accessTokenExpiresAt: number;
16
- }
17
- export interface RebaseSession {
18
- accessToken: string;
19
- refreshToken: string;
20
- expiresAt: number;
21
- user: RebaseUser;
22
- }
23
- export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED";
24
- export interface AuthConfig {
25
- needsSetup: boolean;
26
- registrationEnabled: boolean;
27
- emailServiceEnabled?: boolean;
28
- passwordReset?: boolean;
29
- emailVerification?: boolean;
30
- enabledProviders: string[];
31
- }
32
- export interface AuthStorage {
33
- getItem: (key: string) => string | null;
34
- setItem: (key: string, value: string) => void;
35
- removeItem: (key: string) => void;
36
- }
37
- export declare function createMemoryStorage(): AuthStorage;
38
- export interface CreateAuthOptions {
39
- storage?: AuthStorage;
40
- authPath?: string;
41
- autoRefresh?: boolean;
42
- persistSession?: boolean;
43
- }
44
- export declare function createAuth(transport: Transport, options?: CreateAuthOptions): {
45
- signInWithEmail: (email: string, password: string) => Promise<{
46
- user: RebaseUser;
47
- accessToken: string;
48
- refreshToken: string;
49
- }>;
50
- signUp: (email: string, password: string, displayName?: string) => Promise<{
51
- user: RebaseUser;
52
- accessToken: string;
53
- refreshToken: string;
54
- }>;
55
- signInWithGoogle: (payload: {
56
- idToken: string;
57
- } | {
58
- accessToken: string;
59
- } | {
60
- code: string;
61
- redirectUri: string;
62
- }) => Promise<{
63
- user: RebaseUser;
64
- accessToken: string;
65
- refreshToken: string;
66
- }>;
67
- signInWithLinkedin: (code: string, redirectUri: string) => Promise<{
68
- user: RebaseUser;
69
- accessToken: string;
70
- refreshToken: string;
71
- }>;
72
- signInWithOAuth: (providerId: string, payload: Record<string, unknown>) => Promise<{
73
- user: RebaseUser;
74
- accessToken: string;
75
- refreshToken: string;
76
- }>;
77
- signInWithGitHub: (code: string, redirectUri: string) => Promise<{
78
- user: RebaseUser;
79
- accessToken: string;
80
- refreshToken: string;
81
- }>;
82
- signInWithMicrosoft: (code: string, redirectUri: string) => Promise<{
83
- user: RebaseUser;
84
- accessToken: string;
85
- refreshToken: string;
86
- }>;
87
- signInWithApple: (code: string, redirectUri: string, user?: {
88
- name?: {
89
- firstName?: string;
90
- lastName?: string;
91
- };
92
- email?: string;
93
- }) => Promise<{
94
- user: RebaseUser;
95
- accessToken: string;
96
- refreshToken: string;
97
- }>;
98
- signInWithFacebook: (code: string, redirectUri: string) => Promise<{
99
- user: RebaseUser;
100
- accessToken: string;
101
- refreshToken: string;
102
- }>;
103
- signInWithTwitter: (code: string, redirectUri: string, codeVerifier: string) => Promise<{
104
- user: RebaseUser;
105
- accessToken: string;
106
- refreshToken: string;
107
- }>;
108
- signInWithDiscord: (code: string, redirectUri: string) => Promise<{
109
- user: RebaseUser;
110
- accessToken: string;
111
- refreshToken: string;
112
- }>;
113
- signInWithGitLab: (code: string, redirectUri: string) => Promise<{
114
- user: RebaseUser;
115
- accessToken: string;
116
- refreshToken: string;
117
- }>;
118
- signInWithBitbucket: (code: string, redirectUri: string) => Promise<{
119
- user: RebaseUser;
120
- accessToken: string;
121
- refreshToken: string;
122
- }>;
123
- signInWithSlack: (code: string, redirectUri: string) => Promise<{
124
- user: RebaseUser;
125
- accessToken: string;
126
- refreshToken: string;
127
- }>;
128
- signInWithSpotify: (code: string, redirectUri: string) => Promise<{
129
- user: RebaseUser;
130
- accessToken: string;
131
- refreshToken: string;
132
- }>;
133
- signOut: () => Promise<void>;
134
- refreshSession: () => Promise<RebaseSession>;
135
- getUser: () => Promise<RebaseUser>;
136
- updateUser: (updates: {
137
- displayName?: string;
138
- photoURL?: string;
139
- }) => Promise<RebaseUser>;
140
- resetPasswordForEmail: (email: string) => Promise<{
141
- success: boolean;
142
- message: string;
143
- }>;
144
- resetPassword: (token: string, password: string) => Promise<{
145
- success: boolean;
146
- message: string;
147
- }>;
148
- changePassword: (oldPassword: string, newPassword: string) => Promise<{
149
- success: boolean;
150
- message: string;
151
- }>;
152
- sendVerificationEmail: () => Promise<{
153
- success: boolean;
154
- message: string;
155
- }>;
156
- verifyEmail: (token: string) => Promise<{
157
- success: boolean;
158
- message: string;
159
- }>;
160
- getSessions: () => Promise<Record<string, unknown>[]>;
161
- revokeSession: (sessionId: string) => Promise<{
162
- success: boolean;
163
- }>;
164
- revokeAllSessions: () => Promise<{
165
- success: boolean;
166
- }>;
167
- getAuthConfig: () => Promise<AuthConfig>;
168
- getSession: () => RebaseSession | null;
169
- onAuthStateChange: (callback: (event: AuthChangeEvent, session: RebaseSession | null) => void) => () => boolean;
170
- };
171
- export interface CookieStorageOptions {
172
- path?: string;
173
- domain?: string;
174
- secure?: boolean;
175
- sameSite?: "Lax" | "Strict" | "None";
176
- maxAge?: number;
177
- }
178
- export declare function createCookieStorage(options?: CookieStorageOptions): AuthStorage;
@@ -1,21 +0,0 @@
1
- import { FindParams, Transport } from "./transport";
2
- import { RebaseWebSocketClient } from "./websocket";
3
- import { CollectionAccessor, FilterOperator, LogicalCondition, WhereValue } from "@rebasepro/types";
4
- import { QueryBuilder } from "./query_builder";
5
- /**
6
- * CollectionClient extends `CollectionAccessor` from `@rebasepro/types` so that
7
- * `client.data` can be passed directly to the core Rebase component.
8
- *
9
- * Additionally it exposes fluent query builder methods like `.where()`, `.orderBy()`.
10
- */
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: FilterOperator, value: WhereValue<M[K]>): QueryBuilder<M>;
13
- where(logicalCondition: LogicalCondition): QueryBuilder<M>;
14
- orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilder<M>;
15
- limit(count: number): QueryBuilder<M>;
16
- offset(count: number): QueryBuilder<M>;
17
- search(searchString: string): QueryBuilder<M>;
18
- include(...relations: string[]): QueryBuilder<M>;
19
- count(params?: FindParams): Promise<number>;
20
- }
21
- export declare function createCollectionClient<M extends Record<string, unknown> = Record<string, unknown>>(transport: Transport, slug: string, ws?: RebaseWebSocketClient): CollectionClient<M>;
@@ -1,25 +0,0 @@
1
- import { Transport } from "./transport";
2
- import type { CronJobStatus, CronJobLogEntry } from "@rebasepro/types";
3
- export interface CreateCronOptions {
4
- cronPath?: string;
5
- }
6
- export declare function createCron(transport: Transport, options?: CreateCronOptions): {
7
- listJobs: () => Promise<{
8
- jobs: CronJobStatus[];
9
- }>;
10
- getJob: (jobId: string) => Promise<{
11
- job: CronJobStatus;
12
- }>;
13
- triggerJob: (jobId: string) => Promise<{
14
- log: CronJobLogEntry;
15
- job: CronJobStatus;
16
- }>;
17
- getJobLogs: (jobId: string, options?: {
18
- limit?: number;
19
- }) => Promise<{
20
- logs: CronJobLogEntry[];
21
- }>;
22
- toggleJob: (jobId: string, enabled: boolean) => Promise<{
23
- job: CronJobStatus;
24
- }>;
25
- };
@@ -1,49 +0,0 @@
1
- import type { Transport } from "./transport";
2
- /**
3
- * Client interface for invoking custom backend functions.
4
- *
5
- * Custom functions are Hono route files auto-mounted by the Rebase backend
6
- * at `/api/functions/{name}`. The `FunctionsClient` wraps the shared
7
- * transport so callers never need to manually construct URLs or inject
8
- * auth tokens.
9
- *
10
- * @example
11
- * ```ts
12
- * const result = await client.functions.invoke<{ job: Job }>('extract-job', {
13
- * url: 'https://example.com/posting',
14
- * html: htmlContent,
15
- * });
16
- * ```
17
- */
18
- export interface FunctionsClient {
19
- /**
20
- * Invoke a custom backend function by name.
21
- *
22
- * @typeParam T - Expected shape of the response payload.
23
- * @param name - Function name (the filename without extension, e.g. `"extract-job"`).
24
- * @param payload - Optional JSON-serialisable body sent as `POST`.
25
- * @param options - Optional overrides (HTTP method, sub-path, extra headers).
26
- * @returns The parsed JSON response from the function.
27
- */
28
- invoke<T = unknown>(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise<T>;
29
- }
30
- export interface FunctionInvokeOptions {
31
- /** HTTP method — defaults to `"POST"`. */
32
- method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
33
- /** Sub-path appended after the function name, e.g. `"status/123"`. */
34
- path?: string;
35
- /** Extra headers merged into the request (auth is still injected automatically). */
36
- headers?: Record<string, string>;
37
- }
38
- /**
39
- * Create a `FunctionsClient` backed by the given transport.
40
- *
41
- * The transport already handles:
42
- * - Base URL resolution
43
- * - JWT injection via `Authorization: Bearer`
44
- * - 401 retry / `onUnauthorized` flow
45
- * - Consistent error throwing via `RebaseApiError`
46
- *
47
- * @internal
48
- */
49
- export declare function createFunctionsClient(transport: Transport): FunctionsClient;
@@ -1,48 +0,0 @@
1
- import { RebaseClientConfig } from "./transport";
2
- import { createAuth, CreateAuthOptions } from "./auth";
3
- import { createAdmin, CreateAdminOptions } from "./admin";
4
- import { createCron, CreateCronOptions } from "./cron";
5
- import { CollectionClient } from "./collection";
6
- import type { FunctionsClient } from "./functions";
7
- export * from "./transport";
8
- export * from "./auth";
9
- export * from "./admin";
10
- export * from "./cron";
11
- export * from "./collection";
12
- export * from "./query_builder";
13
- export * from "./websocket";
14
- export * from "./storage";
15
- export * from "./reviver";
16
- export * from "./functions";
17
- export interface CreateRebaseClientOptions extends RebaseClientConfig {
18
- auth?: CreateAuthOptions;
19
- admin?: CreateAdminOptions;
20
- cron?: CreateCronOptions;
21
- }
22
- import { RebaseWebSocketClient } from "./websocket";
23
- import { RebaseClient as BaseRebaseClient, RebaseData, StorageSource } from "@rebasepro/types";
24
- export type { Entity, FindResponse } from "@rebasepro/types";
25
- type KebabToCamelCase<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamelCase<U>>}` : S;
26
- export type RebaseClient<DB = Record<string, unknown>> = Omit<BaseRebaseClient<DB>, "data"> & {
27
- setToken: (token: string | null) => void;
28
- setAuthTokenGetter: (getter: () => Promise<string | null>) => void;
29
- setOnUnauthorized: (handler: () => Promise<boolean>) => void;
30
- resolveToken: () => Promise<string | null>;
31
- auth: ReturnType<typeof createAuth>;
32
- admin: ReturnType<typeof createAdmin>;
33
- cron: ReturnType<typeof createCron>;
34
- functions: FunctionsClient;
35
- ws?: RebaseWebSocketClient;
36
- storage?: StorageSource;
37
- 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;
47
- };
48
- export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions): RebaseClient<DB>;
@@ -1 +0,0 @@
1
- export { QueryBuilder, or, and, cond } from "@rebasepro/common";
@@ -1 +0,0 @@
1
- export declare function rebaseReviver(_key: string, value: unknown): unknown;
@@ -1,3 +0,0 @@
1
- import { StorageSource } from "@rebasepro/types";
2
- import { Transport } from "./transport";
3
- export declare function createStorage(transport: Transport): StorageSource;
@@ -1,33 +0,0 @@
1
- import { FindParams as TypesFindParams, FindResponse as TypesFindResponse } from "@rebasepro/types";
2
- export interface RebaseClientConfig {
3
- baseUrl?: string;
4
- token?: string;
5
- apiPath?: string;
6
- fetch?: typeof globalThis.fetch;
7
- onUnauthorized?: () => Promise<boolean>;
8
- websocketUrl?: string;
9
- }
10
- /**
11
- * Re-export from `@rebasepro/types` for backward compatibility.
12
- */
13
- export type FindParams = TypesFindParams;
14
- export type FindResponse<T> = TypesFindResponse<T extends Record<string, unknown> ? T : Record<string, unknown>>;
15
- export declare class RebaseApiError extends Error {
16
- status: number;
17
- code?: string;
18
- details?: unknown;
19
- constructor(status: number, message: string, code?: string, details?: unknown);
20
- }
21
- export declare function buildQueryString(params?: FindParams): string;
22
- export interface Transport {
23
- request: <T = unknown>(path: string, init?: RequestInit) => Promise<T>;
24
- setToken: (newToken: string | null) => void;
25
- setAuthTokenGetter: (getter: () => Promise<string | null>) => void;
26
- setOnUnauthorized: (handler: () => Promise<boolean>) => void;
27
- readonly baseUrl: string;
28
- readonly apiPath: string;
29
- readonly fetchFn: typeof globalThis.fetch;
30
- getHeaders: (init?: RequestInit) => Record<string, string>;
31
- resolveToken: () => Promise<string | null>;
32
- }
33
- export declare function createTransport(config: RebaseClientConfig): Transport;
@@ -1,105 +0,0 @@
1
- import { DeleteEntityProps, Entity, EntityCollection, FetchCollectionProps, FetchEntityProps, SaveEntityProps, TableMetadata, BranchInfo } from "@rebasepro/types";
2
- export interface RebaseWebSocketConfig {
3
- websocketUrl: string;
4
- /** Optional auth token getter for WebSocket authentication */
5
- getAuthToken?: () => Promise<string>;
6
- /** Optional WebSocket constructor to override globalThis.WebSocket (e.g. for Node environments) */
7
- WebSocket?: typeof WebSocket;
8
- /** Callback to handle unauthorized requests or token expiration (refreshes auth session) */
9
- onUnauthorized?: () => Promise<boolean>;
10
- }
11
- export declare class ApiError extends Error {
12
- code?: string;
13
- error?: string;
14
- constructor(message: string, error?: string, code?: string);
15
- }
16
- export declare class RebaseWebSocketClient {
17
- private websocketUrl;
18
- private ws;
19
- getAuthToken?: () => Promise<string>;
20
- private subscriptions;
21
- private listeners;
22
- on(event: "connect" | "disconnect" | "reconnect" | "error", cb: (...args: unknown[]) => void): () => boolean;
23
- private emit;
24
- private collectionSubscriptions;
25
- private entitySubscriptions;
26
- private backendToCollectionKey;
27
- private backendToEntityKey;
28
- private pendingRequests;
29
- private reconnectAttempts;
30
- private maxReconnectAttempts;
31
- private isConnected;
32
- private messageQueue;
33
- private reconnectTimeout;
34
- private isAuthenticated;
35
- private authPromise;
36
- private WebSocketConstructor;
37
- onUnauthorized?: () => Promise<boolean>;
38
- private refreshInProgress;
39
- constructor(config: RebaseWebSocketConfig);
40
- /**
41
- * Authenticate the WebSocket connection
42
- */
43
- authenticate(token: string): Promise<void>;
44
- /**
45
- * Set the auth token getter function
46
- */
47
- setAuthTokenGetter(getAuthToken: () => Promise<string>): void;
48
- disconnect(): void;
49
- private initWebSocket;
50
- private processMessageQueue;
51
- private attemptReconnect;
52
- private isAuthError;
53
- private handleAuthFailure;
54
- private handleWebSocketMessage;
55
- private ensureAuthenticated;
56
- /**
57
- * Force re-authentication (call after token refresh)
58
- */
59
- reauthenticate(): Promise<void>;
60
- private sendMessage;
61
- private doSendMessage;
62
- fetchCollection<M extends Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<Entity<M>[]>;
63
- fetchEntity<M extends Record<string, unknown>>(props: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
64
- saveEntity<M extends Record<string, unknown>>(props: SaveEntityProps<M>): Promise<Entity<M>>;
65
- deleteEntity<M extends Record<string, unknown>>(props: DeleteEntityProps<M>): Promise<void>;
66
- executeSql(sql: string, options?: {
67
- database?: string;
68
- role?: string;
69
- }): Promise<Record<string, unknown>[]>;
70
- fetchAvailableDatabases(): Promise<string[]>;
71
- fetchAvailableRoles(): Promise<string[]>;
72
- fetchCurrentDatabase(): Promise<string | undefined>;
73
- checkUniqueField(path: string, name: string, value: unknown, entityId?: string, collection?: EntityCollection): Promise<boolean>;
74
- countEntities<M extends Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<number>;
75
- fetchUnmappedTables(mappedPaths?: string[]): Promise<string[]>;
76
- fetchTableMetadata(tableName: string): Promise<TableMetadata>;
77
- createBranch(name: string, options?: {
78
- source?: string;
79
- }): Promise<BranchInfo>;
80
- deleteBranch(name: string): Promise<void>;
81
- listBranches(): Promise<BranchInfo[]>;
82
- /**
83
- * Recursively compare two values for structural equality.
84
- * Handles primitives, null, undefined, Date, RegExp, arrays, and plain objects.
85
- */
86
- private deepEqual;
87
- private normalizeForComparison;
88
- /**
89
- * Merge incoming entities with cached data, preserving cached references
90
- * for entities whose values haven't changed. This avoids unnecessary
91
- * React re-renders when the server refetches all entities but most
92
- * haven't actually changed.
93
- */
94
- private mergeEntities;
95
- listenCollection<M extends Record<string, unknown>>(props: FetchCollectionProps<M>, onUpdate: (entities: Entity[]) => void, onError?: (error: Error) => void): () => void;
96
- listenEntity<M extends Record<string, unknown>>(props: FetchEntityProps<M>, onUpdate: (entity: Entity | null) => void, onError?: (error: Error) => void): () => void;
97
- /**
98
- * Re-send all active subscriptions to the backend after a reconnect.
99
- * The server wipes subscription state when a client disconnects, so
100
- * we need to re-register everything to resume receiving updates.
101
- */
102
- private resubscribeAll;
103
- private createCollectionSubscriptionKey;
104
- private createEntitySubscriptionKey;
105
- }
@@ -1,7 +0,0 @@
1
- export type AnalyticsController = {
2
- /**
3
- * Callback used to get analytics events from the CMS
4
- */
5
- onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
6
- };
7
- export type AnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "home_move_card" | "home_move_group" | "home_drop_new_group" | "collection_inline_editing" | "view_mode_changed" | "kanban_card_moved" | "kanban_column_reorder" | "kanban_property_changed" | "kanban_new_entity_in_column" | "kanban_backfill_order" | "card_view_entity_click" | "unmapped_event";
@@ -1,104 +0,0 @@
1
- import type { User } from "../users";
2
- /**
3
- * Capabilities advertised by an auth provider.
4
- * UI components use this to show/hide features dynamically
5
- * (e.g. password reset, registration, session management).
6
- * @group Hooks and utilities
7
- */
8
- export interface AuthCapabilities {
9
- emailPasswordLogin?: boolean;
10
- googleLogin?: boolean;
11
- registration?: boolean;
12
- passwordReset?: boolean;
13
- sessionManagement?: boolean;
14
- profileUpdate?: boolean;
15
- emailVerification?: boolean;
16
- /** List of enabled OAuth provider IDs (e.g. ["google", "github", "discord"]) */
17
- enabledProviders?: string[];
18
- }
19
- /**
20
- * Controller for retrieving the logged user or performing auth related operations.
21
- * Note that if you are implementing your AuthController, you probably will want
22
- * to do it as the result of a hook.
23
- * @group Hooks and utilities
24
- */
25
- export type AuthController<USER extends User = User, ExtraData = unknown> = {
26
- /**
27
- * The user currently logged in
28
- * The values can be: the user object, null if they skipped login
29
- */
30
- user: USER | null;
31
- /**
32
- * Initial loading flag. It is used not to display the login screen
33
- * when the app first loads, and it has not been checked whether the user
34
- * is logged in or not.
35
- */
36
- initialLoading?: boolean;
37
- /**
38
- * Loading flag. It is used to display a loading screen when the user is
39
- * logging in or out.
40
- */
41
- authLoading: boolean;
42
- /**
43
- * Sign out
44
- */
45
- signOut: () => Promise<void>;
46
- /**
47
- * Error initializing the authentication
48
- */
49
- authError?: unknown;
50
- /**
51
- * Error dispatched by the auth provider
52
- */
53
- authProviderError?: unknown;
54
- /**
55
- * You can use this method to retrieve the auth token for the current user.
56
- */
57
- getAuthToken: () => Promise<string>;
58
- /**
59
- * Has the user skipped the login process
60
- */
61
- loginSkipped: boolean;
62
- extra: ExtraData;
63
- setExtra: (extra: ExtraData) => void;
64
- setUser?(user: USER | null): void;
65
- setUserRoles?(roles: string[]): void;
66
- /**
67
- * Capabilities advertised by the auth provider.
68
- * UI components use this to feature-detect what the backend supports.
69
- */
70
- capabilities?: AuthCapabilities;
71
- };
72
- /**
73
- * Extended auth controller with common optional auth methods.
74
- * Backend implementations (Rebase backend, Firebase, Supabase, etc.)
75
- * extend this with their own backend-specific extras.
76
- * @group Hooks and utilities
77
- */
78
- export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
79
- /** Login with email and password */
80
- emailPasswordLogin?(email: string, password: string): Promise<void>;
81
- /** Login with Google — accepts an ID token, access token, or authorization code payload */
82
- googleLogin?: (payload: {
83
- idToken: string;
84
- } | {
85
- accessToken: string;
86
- } | {
87
- code: string;
88
- redirectUri: string;
89
- }) => Promise<void>;
90
- /** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
91
- oauthLogin?: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
92
- /** Register a new user */
93
- register?(email: string, password: string, displayName?: string): Promise<void>;
94
- /** Skip login (for anonymous access if enabled) */
95
- skipLogin?(): void;
96
- /** Request password reset email */
97
- forgotPassword?(email: string): Promise<void>;
98
- /** Reset password using a token */
99
- resetPassword?(token: string, password: string): Promise<void>;
100
- /** Change password for the authenticated user */
101
- changePassword?(oldPassword: string, newPassword: string): Promise<void>;
102
- /** Update user profile */
103
- updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
104
- }