@rebasepro/sdk-generator 0.0.1-canary.09e5ec5

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 (86) hide show
  1. package/LICENSE +6 -0
  2. package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
  3. package/dist/common/src/collections/index.d.ts +1 -0
  4. package/dist/common/src/data/buildRebaseData.d.ts +14 -0
  5. package/dist/common/src/index.d.ts +3 -0
  6. package/dist/common/src/util/builders.d.ts +57 -0
  7. package/dist/common/src/util/callbacks.d.ts +6 -0
  8. package/dist/common/src/util/collections.d.ts +11 -0
  9. package/dist/common/src/util/common.d.ts +2 -0
  10. package/dist/common/src/util/conditions.d.ts +26 -0
  11. package/dist/common/src/util/entities.d.ts +58 -0
  12. package/dist/common/src/util/enums.d.ts +3 -0
  13. package/dist/common/src/util/index.d.ts +16 -0
  14. package/dist/common/src/util/navigation_from_path.d.ts +34 -0
  15. package/dist/common/src/util/navigation_utils.d.ts +20 -0
  16. package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
  17. package/dist/common/src/util/paths.d.ts +14 -0
  18. package/dist/common/src/util/permissions.d.ts +5 -0
  19. package/dist/common/src/util/references.d.ts +2 -0
  20. package/dist/common/src/util/relations.d.ts +22 -0
  21. package/dist/common/src/util/resolutions.d.ts +72 -0
  22. package/dist/common/src/util/storage.d.ts +24 -0
  23. package/dist/index.cjs +232 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.es.js +229 -0
  26. package/dist/index.es.js.map +1 -0
  27. package/dist/sdk-generator/src/generate-types.d.ts +2 -0
  28. package/dist/sdk-generator/src/index.d.ts +19 -0
  29. package/dist/sdk-generator/src/utils.d.ts +22 -0
  30. package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
  31. package/dist/types/src/controllers/auth.d.ts +119 -0
  32. package/dist/types/src/controllers/client.d.ts +170 -0
  33. package/dist/types/src/controllers/collection_registry.d.ts +45 -0
  34. package/dist/types/src/controllers/customization_controller.d.ts +60 -0
  35. package/dist/types/src/controllers/data.d.ts +168 -0
  36. package/dist/types/src/controllers/data_driver.d.ts +160 -0
  37. package/dist/types/src/controllers/database_admin.d.ts +11 -0
  38. package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
  39. package/dist/types/src/controllers/effective_role.d.ts +4 -0
  40. package/dist/types/src/controllers/email.d.ts +34 -0
  41. package/dist/types/src/controllers/index.d.ts +18 -0
  42. package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
  43. package/dist/types/src/controllers/navigation.d.ts +213 -0
  44. package/dist/types/src/controllers/registry.d.ts +54 -0
  45. package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
  46. package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
  47. package/dist/types/src/controllers/snackbar.d.ts +24 -0
  48. package/dist/types/src/controllers/storage.d.ts +171 -0
  49. package/dist/types/src/index.d.ts +4 -0
  50. package/dist/types/src/rebase_context.d.ts +105 -0
  51. package/dist/types/src/types/backend.d.ts +536 -0
  52. package/dist/types/src/types/builders.d.ts +15 -0
  53. package/dist/types/src/types/chips.d.ts +5 -0
  54. package/dist/types/src/types/collections.d.ts +856 -0
  55. package/dist/types/src/types/cron.d.ts +102 -0
  56. package/dist/types/src/types/data_source.d.ts +64 -0
  57. package/dist/types/src/types/entities.d.ts +145 -0
  58. package/dist/types/src/types/entity_actions.d.ts +98 -0
  59. package/dist/types/src/types/entity_callbacks.d.ts +173 -0
  60. package/dist/types/src/types/entity_link_builder.d.ts +7 -0
  61. package/dist/types/src/types/entity_overrides.d.ts +10 -0
  62. package/dist/types/src/types/entity_views.d.ts +61 -0
  63. package/dist/types/src/types/export_import.d.ts +21 -0
  64. package/dist/types/src/types/index.d.ts +23 -0
  65. package/dist/types/src/types/locales.d.ts +4 -0
  66. package/dist/types/src/types/modify_collections.d.ts +5 -0
  67. package/dist/types/src/types/plugins.d.ts +279 -0
  68. package/dist/types/src/types/properties.d.ts +1176 -0
  69. package/dist/types/src/types/property_config.d.ts +70 -0
  70. package/dist/types/src/types/relations.d.ts +336 -0
  71. package/dist/types/src/types/slots.d.ts +252 -0
  72. package/dist/types/src/types/translations.d.ts +870 -0
  73. package/dist/types/src/types/user_management_delegate.d.ts +121 -0
  74. package/dist/types/src/types/websockets.d.ts +78 -0
  75. package/dist/types/src/users/index.d.ts +2 -0
  76. package/dist/types/src/users/roles.d.ts +22 -0
  77. package/dist/types/src/users/user.d.ts +46 -0
  78. package/jest.config.cjs +13 -0
  79. package/package.json +51 -0
  80. package/src/generate-types.ts +199 -0
  81. package/src/index.ts +71 -0
  82. package/src/json-logic-js.d.ts +8 -0
  83. package/src/utils.ts +42 -0
  84. package/test/sdk-generator.test.ts +88 -0
  85. package/tsconfig.json +26 -0
  86. package/vite.config.ts +49 -0
@@ -0,0 +1,119 @@
1
+ import { StorageSource } from "./storage";
2
+ import { Role, User } from "../users";
3
+ import { RebaseData } from "./data";
4
+ /**
5
+ * Capabilities advertised by an auth provider.
6
+ * UI components use this to show/hide features dynamically
7
+ * (e.g. password reset, registration, session management).
8
+ * @group Hooks and utilities
9
+ */
10
+ export interface AuthCapabilities {
11
+ emailPasswordLogin?: boolean;
12
+ googleLogin?: boolean;
13
+ registration?: boolean;
14
+ passwordReset?: boolean;
15
+ sessionManagement?: boolean;
16
+ profileUpdate?: boolean;
17
+ emailVerification?: boolean;
18
+ /** List of enabled OAuth provider IDs (e.g. ["google", "github", "discord"]) */
19
+ enabledProviders?: string[];
20
+ }
21
+ /**
22
+ * Controller for retrieving the logged user or performing auth related operations.
23
+ * Note that if you are implementing your AuthController, you probably will want
24
+ * to do it as the result of a hook.
25
+ * @group Hooks and utilities
26
+ */
27
+ export type AuthController<USER extends User = User, ExtraData = unknown> = {
28
+ /**
29
+ * The user currently logged in
30
+ * The values can be: the user object, null if they skipped login
31
+ */
32
+ user: USER | null;
33
+ /**
34
+ * Initial loading flag. It is used not to display the login screen
35
+ * when the app first loads, and it has not been checked whether the user
36
+ * is logged in or not.
37
+ */
38
+ initialLoading?: boolean;
39
+ /**
40
+ * Loading flag. It is used to display a loading screen when the user is
41
+ * logging in or out.
42
+ */
43
+ authLoading: boolean;
44
+ /**
45
+ * Sign out
46
+ */
47
+ signOut: () => Promise<void>;
48
+ /**
49
+ * Error initializing the authentication
50
+ */
51
+ authError?: unknown;
52
+ /**
53
+ * Error dispatched by the auth provider
54
+ */
55
+ authProviderError?: unknown;
56
+ /**
57
+ * You can use this method to retrieve the auth token for the current user.
58
+ */
59
+ getAuthToken: () => Promise<string>;
60
+ /**
61
+ * Has the user skipped the login process
62
+ */
63
+ loginSkipped: boolean;
64
+ extra: ExtraData;
65
+ setExtra: (extra: ExtraData) => void;
66
+ setUser?(user: USER | null): void;
67
+ setUserRoles?(roles: Role[]): void;
68
+ /**
69
+ * Capabilities advertised by the auth provider.
70
+ * UI components use this to feature-detect what the backend supports.
71
+ */
72
+ capabilities?: AuthCapabilities;
73
+ };
74
+ /**
75
+ * Extended auth controller with common optional auth methods.
76
+ * Backend implementations (Rebase backend, Firebase, Supabase, etc.)
77
+ * extend this with their own backend-specific extras.
78
+ * @group Hooks and utilities
79
+ */
80
+ export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
81
+ /** Login with email and password */
82
+ emailPasswordLogin?(email: string, password: string): Promise<void>;
83
+ /** Login with a Google ID token or trigger Google popup */
84
+ googleLogin?(idToken: string): Promise<void>;
85
+ /** Register a new user */
86
+ register?(email: string, password: string, displayName?: string): Promise<void>;
87
+ /** Skip login (for anonymous access if enabled) */
88
+ skipLogin?(): void;
89
+ /** Request password reset email */
90
+ forgotPassword?(email: string): Promise<void>;
91
+ /** Reset password using a token */
92
+ resetPassword?(token: string, password: string): Promise<void>;
93
+ /** Change password for the authenticated user */
94
+ changePassword?(oldPassword: string, newPassword: string): Promise<void>;
95
+ /** Update user profile */
96
+ updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
97
+ }
98
+ /**
99
+ * Implement this function to allow access to specific users.
100
+ * @group Hooks and utilities
101
+ */
102
+ export type Authenticator<USER extends User = User> = (props: {
103
+ /**
104
+ * Logged-in user or null
105
+ */
106
+ user: USER | null;
107
+ /**
108
+ * AuthController
109
+ */
110
+ authController: AuthController<USER>;
111
+ /**
112
+ * Unified data access API
113
+ */
114
+ data: RebaseData;
115
+ /**
116
+ * Used storage implementation
117
+ */
118
+ storageSource: StorageSource;
119
+ }) => boolean | Promise<boolean>;
@@ -0,0 +1,170 @@
1
+ import { User } from "../users";
2
+ import { RebaseData } from "./data";
3
+ import { EmailService } from "./email";
4
+ /**
5
+ * Event type for authentication state changes
6
+ */
7
+ export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED";
8
+ /**
9
+ * Standard session interface representing an authenticated state
10
+ */
11
+ export interface RebaseSession {
12
+ accessToken: string;
13
+ refreshToken: string;
14
+ expiresAt: number;
15
+ user: User;
16
+ }
17
+ import { StorageSource } from "./storage";
18
+ /**
19
+ * Unified Authentication Client Interface
20
+ * Pure functional SDK interface, decoupled from UI and React hooks
21
+ */
22
+ export interface AuthClient {
23
+ /**
24
+ * Get the current user from the server or cache
25
+ */
26
+ getUser(): Promise<User | null>;
27
+ /**
28
+ * Get the currently active session
29
+ */
30
+ getSession(): RebaseSession | null;
31
+ /**
32
+ * Sign out the current user and clear local session
33
+ */
34
+ signOut(): Promise<void>;
35
+ /**
36
+ * Subscribe to authentication state changes
37
+ */
38
+ onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
39
+ /**
40
+ * Manually refresh the session token
41
+ */
42
+ refreshSession(): Promise<RebaseSession>;
43
+ }
44
+ /**
45
+ * User record as returned by the Admin API.
46
+ * @group Admin
47
+ */
48
+ export interface AdminUser {
49
+ uid: string;
50
+ email: string;
51
+ displayName: string | null;
52
+ photoURL: string | null;
53
+ provider: string;
54
+ roles: string[];
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ }
58
+ /**
59
+ * Role record as returned by the Admin API.
60
+ * @group Admin
61
+ */
62
+ export interface AdminRole {
63
+ id: string;
64
+ name: string;
65
+ isAdmin: boolean;
66
+ defaultPermissions: Record<string, unknown> | null;
67
+ config: Record<string, unknown> | null;
68
+ }
69
+ /**
70
+ * Client-side Admin API interface.
71
+ * Provides user and role management operations.
72
+ * @group Admin
73
+ */
74
+ export interface AdminAPI {
75
+ listUsers(): Promise<{
76
+ users: AdminUser[];
77
+ }>;
78
+ listUsersPaginated(options?: {
79
+ search?: string;
80
+ limit?: number;
81
+ offset?: number;
82
+ orderBy?: string;
83
+ orderDir?: "asc" | "desc";
84
+ }): Promise<{
85
+ users: AdminUser[];
86
+ total: number;
87
+ limit: number;
88
+ offset: number;
89
+ }>;
90
+ getUser(userId: string): Promise<{
91
+ user: AdminUser;
92
+ }>;
93
+ createUser(data: {
94
+ email: string;
95
+ displayName?: string;
96
+ password?: string;
97
+ roles?: string[];
98
+ }): Promise<{
99
+ user: AdminUser;
100
+ }>;
101
+ updateUser(userId: string, data: {
102
+ email?: string;
103
+ displayName?: string;
104
+ password?: string;
105
+ roles?: string[];
106
+ }): Promise<{
107
+ user: AdminUser;
108
+ }>;
109
+ deleteUser(userId: string): Promise<{
110
+ success: boolean;
111
+ }>;
112
+ listRoles(): Promise<{
113
+ roles: AdminRole[];
114
+ }>;
115
+ getRole(roleId: string): Promise<{
116
+ role: AdminRole;
117
+ }>;
118
+ createRole(data: {
119
+ id: string;
120
+ name: string;
121
+ isAdmin?: boolean;
122
+ defaultPermissions?: Record<string, unknown>;
123
+ config?: Record<string, unknown>;
124
+ }): Promise<{
125
+ role: AdminRole;
126
+ }>;
127
+ updateRole(roleId: string, data: {
128
+ name?: string;
129
+ isAdmin?: boolean;
130
+ defaultPermissions?: Record<string, unknown>;
131
+ config?: Record<string, unknown>;
132
+ }): Promise<{
133
+ role: AdminRole;
134
+ }>;
135
+ deleteRole(roleId: string): Promise<{
136
+ success: boolean;
137
+ }>;
138
+ bootstrap(): Promise<{
139
+ success: boolean;
140
+ message: string;
141
+ user: {
142
+ uid: string;
143
+ roles: string[];
144
+ };
145
+ }>;
146
+ }
147
+ /**
148
+ * Overarching abstraction that unites Data, Auth, Storage, and Email.
149
+ * Adapters for Supabase or Firebase simply need to implement this interface.
150
+ */
151
+ export interface RebaseClient<DB = unknown> {
152
+ /** Unified Data access layer */
153
+ data: RebaseData;
154
+ /** Unified Authentication layer */
155
+ auth: AuthClient;
156
+ /** Unified Storage layer */
157
+ storage?: StorageSource;
158
+ /**
159
+ * Server-side email service.
160
+ *
161
+ * Available when SMTP (or a custom `sendEmail` function) is configured
162
+ * in the backend auth config. `undefined` when email is not configured.
163
+ *
164
+ * > **Note:** This is only available on the server-side `rebase` singleton.
165
+ * > The client-side SDK does not include an email service.
166
+ */
167
+ email?: EmailService;
168
+ /** Admin API for user and role management */
169
+ admin?: AdminAPI;
170
+ }
@@ -0,0 +1,45 @@
1
+ import type { EntityCollection } from "../types/collections";
2
+ import type { EntityReference } from "../types/entities";
3
+ /**
4
+ * Controller that provides access to the registered entity collections.
5
+ * @group Models
6
+ */
7
+ export type CollectionRegistryController<DB = Record<string, unknown>, EC extends EntityCollection = EntityCollection<any>> = {
8
+ /**
9
+ * List of the mapped collections in the CMS.
10
+ * Each entry relates to a collection in the root database.
11
+ * Each of the navigation entries in this field
12
+ * generates an entry in the main menu.
13
+ */
14
+ collections?: EntityCollection[];
15
+ /**
16
+ * Is the registry ready to be used
17
+ */
18
+ initialised: boolean;
19
+ /**
20
+ * Get the collection configuration for a given path.
21
+ * The collection is resolved from the given path or alias.
22
+ */
23
+ getCollection: <K extends keyof DB>(slugOrPath: Extract<K, string>, includeUserOverride?: boolean) => EC | undefined;
24
+ /**
25
+ * Get the raw, un-normalized collection configuration.
26
+ * This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
27
+ * This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
28
+ */
29
+ getRawCollection: (slugOrPath: string) => EC | undefined;
30
+ /**
31
+ * Retrieve all the related parent references for a given path
32
+ * @param path
33
+ */
34
+ getParentReferencesFromPath: (path: string) => EntityReference[];
35
+ /**
36
+ * Retrieve all the related parent collection ids for a given path
37
+ * @param path
38
+ */
39
+ getParentCollectionIds: (path: string) => string[];
40
+ /**
41
+ * Resolve paths from a list of ids
42
+ * @param ids
43
+ */
44
+ convertIdsToPaths: (ids: string[]) => string[];
45
+ };
@@ -0,0 +1,60 @@
1
+ import React from "react";
2
+ import type { EntityLinkBuilder } from "../types/entity_link_builder";
3
+ import type { Locale } from "../types/locales";
4
+ import type { EntityAction } from "../types/entity_actions";
5
+ import type { EntityCustomView } from "../types/entity_views";
6
+ import type { RebasePlugin } from "../types/plugins";
7
+ import type { PropertyConfig } from "../types/property_config";
8
+ import type { SlotContribution } from "../types/slots";
9
+ export type CustomizationController = {
10
+ /**
11
+ * Builder for generating utility links for entities
12
+ */
13
+ entityLinkBuilder?: EntityLinkBuilder;
14
+ /**
15
+ * Use plugins to modify the behaviour of the CMS.
16
+ */
17
+ plugins?: RebasePlugin[];
18
+ /**
19
+ * Pre-merged slots from plugins + direct slot contributions.
20
+ */
21
+ resolvedSlots: SlotContribution[];
22
+ /**
23
+ * List of additional custom views for entities.
24
+ * You can use the key to reference the custom view in
25
+ * the `entityViews` prop of a collection.
26
+ *
27
+ * You can also define an entity view from the UI.
28
+ */
29
+ entityViews?: EntityCustomView[];
30
+ /**
31
+ * List of actions that can be performed on entities.
32
+ * These actions are displayed in the entity view and in the collection view.
33
+ * You can later reuse these actions in the `entityActions` prop of a collection,
34
+ * by specifying the `key` of the action.
35
+ */
36
+ entityActions?: EntityAction[];
37
+ /**
38
+ * Format of the dates in the CMS.
39
+ * Defaults to 'MMMM dd, yyyy, HH:mm:ss'
40
+ */
41
+ dateTimeFormat?: string;
42
+ /**
43
+ * Locale of the CMS, currently only affecting dates
44
+ */
45
+ locale?: Locale;
46
+ /**
47
+ * Record of custom form fields to be used in the CMS.
48
+ * You can use the key to reference the custom field in
49
+ * the `propertyConfig` prop of a property in a collection.
50
+ */
51
+ propertyConfigs: Record<string, PropertyConfig>;
52
+ components?: {
53
+ /**
54
+ * Component to render when a reference is missing
55
+ */
56
+ missingReference?: React.ComponentType<{
57
+ path: string;
58
+ }>;
59
+ };
60
+ };
@@ -0,0 +1,168 @@
1
+ import { Entity, EntityValues } from "../types/entities";
2
+ /**
3
+ * Parameters for querying a collection.
4
+ * Uses PostgREST-style filter syntax for consistency between
5
+ * the SDK (HTTP) and framework (in-process) contexts.
6
+ *
7
+ * @group Data
8
+ */
9
+ /**
10
+ * A where-clause value for a single field.
11
+ *
12
+ * Supports three syntaxes:
13
+ * 1. **Equality shorthand**: raw JS values — `null`, `"active"`, `42`, `true`
14
+ * 2. **Tuple syntax**: `[operator, value]` — `[">", 18]`, `["in", ["a","b"]]`
15
+ * 3. **PostgREST string**: `"eq.published"`, `"gte.18"`, `"in.(a,b)"`
16
+ *
17
+ * @group Data
18
+ */
19
+ export type WhereFieldValue = string | number | boolean | null | [WhereFilterOpShort, any];
20
+ /** Short operator strings accepted in the tuple syntax. */
21
+ export type WhereFilterOpShort = "==" | "!=" | ">" | ">=" | "<" | "<=" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "not-in" | "array-contains" | "array-contains-any" | "cs" | "csa";
22
+ export interface FindParams {
23
+ /** Maximum number of items to return (default: 20) */
24
+ limit?: number;
25
+ /** Number of items to skip */
26
+ offset?: number;
27
+ /** Page number (1-indexed), alternative to offset */
28
+ page?: number;
29
+ /**
30
+ * Filter object. Supports multiple syntaxes per field:
31
+ *
32
+ * **Equality shorthand** — raw JS values (null, string, number, boolean):
33
+ * ```ts
34
+ * { company_profile_id: null }
35
+ * { status: "active" }
36
+ * { age: 18 }
37
+ * ```
38
+ *
39
+ * **Tuple syntax** — `[operator, value]`:
40
+ * ```ts
41
+ * { age: [">=", 18] }
42
+ * { role: ["in", ["admin", "editor"]] }
43
+ * { deleted_at: ["!=", null] }
44
+ * ```
45
+ *
46
+ * **PostgREST string syntax** (original format):
47
+ * ```ts
48
+ * { status: "eq.published" }
49
+ * { age: "gte.18" }
50
+ * { role: "in.(admin,editor)" }
51
+ * ```
52
+ */
53
+ where?: Record<string, WhereFieldValue>;
54
+ /**
55
+ * Sort order. Format: "field:direction".
56
+ * @example "created_at:desc", "name:asc"
57
+ */
58
+ orderBy?: string;
59
+ /** Relations to include in the response */
60
+ include?: string[];
61
+ /** Full-text search string */
62
+ searchString?: string;
63
+ }
64
+ /**
65
+ * Paginated response from a collection query.
66
+ * @group Data
67
+ */
68
+ export interface FindResponse<M extends Record<string, unknown> = Record<string, unknown>> {
69
+ /** Array of entities matching the query */
70
+ data: Entity<M>[];
71
+ /** Pagination metadata */
72
+ meta: {
73
+ total: number;
74
+ limit: number;
75
+ offset: number;
76
+ hasMore: boolean;
77
+ };
78
+ }
79
+ /**
80
+ * A single collection's CRUD accessor.
81
+ *
82
+ * This is the unified API surface used in both:
83
+ * - The generated SDK (`client.data.products.create(...)`)
84
+ * - Framework callbacks (`context.data.products.create(...)`)
85
+ *
86
+ * @group Data
87
+ */
88
+ export interface CollectionAccessor<M extends Record<string, unknown> = Record<string, unknown>> {
89
+ /**
90
+ * Find multiple records with optional filtering, pagination, and sorting.
91
+ */
92
+ find(params?: FindParams): Promise<FindResponse<M>>;
93
+ /**
94
+ * Find a single record by its ID.
95
+ */
96
+ findById(id: string | number): Promise<Entity<M> | undefined>;
97
+ /**
98
+ * Create a new record.
99
+ * @param data The entity data to create.
100
+ * @param id Optional specific ID to use for the new record.
101
+ * @returns The created entity
102
+ */
103
+ create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
104
+ /**
105
+ * Update an existing record by ID.
106
+ * @returns The updated entity
107
+ */
108
+ update(id: string | number, data: Partial<EntityValues<M>>): Promise<Entity<M>>;
109
+ /**
110
+ * Delete a record by ID.
111
+ */
112
+ delete(id: string | number): Promise<void>;
113
+ /**
114
+ * Subscribe to a collection for real-time updates.
115
+ * Optional method, may not be supported by all implementations (like stateless HTTP clients).
116
+ */
117
+ listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
118
+ /**
119
+ * Subscribe to a single record for real-time updates.
120
+ * Optional method.
121
+ */
122
+ listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void): () => void;
123
+ /**
124
+ * Count the number of records matching the given filter.
125
+ */
126
+ count?(params?: FindParams): Promise<number>;
127
+ }
128
+ /**
129
+ * The unified data access object.
130
+ *
131
+ * Access collections as dynamic properties: `data.products.find(...)`.
132
+ * In the SDK this is backed by HTTP transport (typed, generated per-project).
133
+ * In the framework this is backed by a Proxy + in-process database driver (dynamic).
134
+ *
135
+ * @example
136
+ * // SDK
137
+ * const client = createRebaseClient({ baseUrl: "..." });
138
+ * await client.data.products.create({ name: "Camera", price: 299 });
139
+ *
140
+ * // Framework callback
141
+ * callbacks: {
142
+ * afterSave({ context }) {
143
+ * await context.data.logs.create({ action: "saved", timestamp: new Date() });
144
+ * }
145
+ * }
146
+ *
147
+ * @group Data
148
+ */
149
+ export interface RebaseData {
150
+ /**
151
+ * Get a collection accessor by slug.
152
+ * Alternative to dynamic property access for cases where
153
+ * the collection name is a variable.
154
+ *
155
+ * @example
156
+ * const accessor = data.collection("products");
157
+ * await accessor.find({ limit: 10 });
158
+ */
159
+ collection(slug: string): CollectionAccessor;
160
+ /**
161
+ * Dynamic collection accessor.
162
+ * Access any collection by its slug as a property.
163
+ *
164
+ * @example
165
+ * data.products.find({ where: { status: "eq.published" } })
166
+ */
167
+ [collectionSlug: string]: CollectionAccessor | ((slug: string) => CollectionAccessor);
168
+ }