@rebasepro/server-postgresql 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.
Files changed (169) hide show
  1. package/dist/{server-postgresql/src/PostgresAdapter.d.ts → PostgresAdapter.d.ts} +1 -1
  2. package/dist/{server-postgresql/src/PostgresBackendDriver.d.ts → PostgresBackendDriver.d.ts} +2 -2
  3. package/dist/{server-postgresql/src/PostgresBootstrapper.d.ts → PostgresBootstrapper.d.ts} +11 -1
  4. package/dist/{server-postgresql/src/collections → collections}/PostgresCollectionRegistry.d.ts +4 -0
  5. package/dist/index.es.js +10207 -11145
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/{server-postgresql/src/services → services}/EntityPersistService.d.ts +0 -14
  8. package/dist/utils/pg-array-null-patch.d.ts +16 -0
  9. package/dist/utils/pg-error-utils.d.ts +55 -0
  10. package/package.json +24 -21
  11. package/src/PostgresAdapter.ts +9 -10
  12. package/src/PostgresBackendDriver.ts +134 -121
  13. package/src/PostgresBootstrapper.ts +100 -30
  14. package/src/auth/ensure-tables.ts +28 -5
  15. package/src/auth/services.ts +28 -18
  16. package/src/cli.ts +99 -96
  17. package/src/collections/PostgresCollectionRegistry.ts +7 -0
  18. package/src/connection.ts +11 -6
  19. package/src/data-transformer.ts +25 -15
  20. package/src/databasePoolManager.ts +3 -2
  21. package/src/history/HistoryService.ts +3 -2
  22. package/src/history/ensure-history-table.ts +5 -4
  23. package/src/schema/auth-schema.ts +1 -2
  24. package/src/schema/doctor-cli.ts +2 -1
  25. package/src/schema/doctor.ts +40 -37
  26. package/src/schema/generate-drizzle-schema-logic.ts +56 -18
  27. package/src/schema/generate-drizzle-schema.ts +11 -11
  28. package/src/schema/introspect-db-inference.ts +25 -25
  29. package/src/schema/introspect-db-logic.ts +38 -38
  30. package/src/schema/introspect-db.ts +28 -27
  31. package/src/services/BranchService.ts +14 -0
  32. package/src/services/EntityFetchService.ts +28 -25
  33. package/src/services/EntityPersistService.ts +19 -149
  34. package/src/services/RelationService.ts +57 -37
  35. package/src/services/entity-helpers.ts +6 -2
  36. package/src/services/realtimeService.ts +45 -32
  37. package/src/utils/drizzle-conditions.ts +31 -15
  38. package/src/utils/pg-array-null-patch.ts +42 -0
  39. package/src/utils/pg-error-utils.ts +211 -0
  40. package/src/websocket.ts +15 -12
  41. package/test/array-null-safety.test.ts +335 -0
  42. package/test/auth-services.test.ts +36 -19
  43. package/test/batch-many-to-many-regression.test.ts +119 -39
  44. package/test/data-transformer-hardening.test.ts +67 -33
  45. package/test/data-transformer.test.ts +57 -4
  46. package/test/doctor.test.ts +10 -5
  47. package/test/drizzle-conditions.test.ts +59 -6
  48. package/test/generate-drizzle-schema.test.ts +65 -40
  49. package/test/introspect-db-generation.test.ts +179 -81
  50. package/test/introspect-db-utils.test.ts +92 -37
  51. package/test/mocks/chalk.cjs +7 -0
  52. package/test/pg-array-null-patch.test.ts +65 -0
  53. package/test/pg-error-utils.test.ts +221 -0
  54. package/test/postgresDataDriver.test.ts +14 -5
  55. package/test/property-ordering.test.ts +126 -79
  56. package/test/realtimeService.test.ts +6 -2
  57. package/test/relation-pipeline-gaps.test.ts +84 -36
  58. package/test/relations.test.ts +247 -0
  59. package/test/unmapped-tables-safety.test.ts +14 -6
  60. package/test/websocket.test.ts +1 -1
  61. package/tsconfig.json +5 -0
  62. package/tsconfig.prod.json +3 -0
  63. package/vite.config.ts +12 -10
  64. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  65. package/dist/common/src/collections/default-collections.d.ts +0 -9
  66. package/dist/common/src/collections/index.d.ts +0 -2
  67. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  68. package/dist/common/src/data/query_builder.d.ts +0 -55
  69. package/dist/common/src/index.d.ts +0 -4
  70. package/dist/common/src/util/builders.d.ts +0 -57
  71. package/dist/common/src/util/callbacks.d.ts +0 -6
  72. package/dist/common/src/util/collections.d.ts +0 -11
  73. package/dist/common/src/util/common.d.ts +0 -2
  74. package/dist/common/src/util/conditions.d.ts +0 -26
  75. package/dist/common/src/util/entities.d.ts +0 -58
  76. package/dist/common/src/util/enums.d.ts +0 -3
  77. package/dist/common/src/util/index.d.ts +0 -16
  78. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  79. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  80. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  81. package/dist/common/src/util/paths.d.ts +0 -14
  82. package/dist/common/src/util/permissions.d.ts +0 -14
  83. package/dist/common/src/util/references.d.ts +0 -2
  84. package/dist/common/src/util/relations.d.ts +0 -22
  85. package/dist/common/src/util/resolutions.d.ts +0 -72
  86. package/dist/common/src/util/storage.d.ts +0 -24
  87. package/dist/index.umd.js +0 -11749
  88. package/dist/index.umd.js.map +0 -1
  89. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  90. package/dist/types/src/controllers/auth.d.ts +0 -104
  91. package/dist/types/src/controllers/client.d.ts +0 -168
  92. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  93. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  94. package/dist/types/src/controllers/data.d.ts +0 -207
  95. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  96. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  97. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  98. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  99. package/dist/types/src/controllers/email.d.ts +0 -36
  100. package/dist/types/src/controllers/index.d.ts +0 -18
  101. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  102. package/dist/types/src/controllers/navigation.d.ts +0 -225
  103. package/dist/types/src/controllers/registry.d.ts +0 -63
  104. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  105. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  106. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  107. package/dist/types/src/controllers/storage.d.ts +0 -171
  108. package/dist/types/src/index.d.ts +0 -4
  109. package/dist/types/src/rebase_context.d.ts +0 -122
  110. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  111. package/dist/types/src/types/backend.d.ts +0 -571
  112. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  113. package/dist/types/src/types/builders.d.ts +0 -15
  114. package/dist/types/src/types/chips.d.ts +0 -5
  115. package/dist/types/src/types/collections.d.ts +0 -961
  116. package/dist/types/src/types/component_ref.d.ts +0 -47
  117. package/dist/types/src/types/cron.d.ts +0 -102
  118. package/dist/types/src/types/data_source.d.ts +0 -64
  119. package/dist/types/src/types/database_adapter.d.ts +0 -94
  120. package/dist/types/src/types/entities.d.ts +0 -145
  121. package/dist/types/src/types/entity_actions.d.ts +0 -104
  122. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  123. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  124. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  125. package/dist/types/src/types/entity_views.d.ts +0 -87
  126. package/dist/types/src/types/export_import.d.ts +0 -21
  127. package/dist/types/src/types/formex.d.ts +0 -40
  128. package/dist/types/src/types/index.d.ts +0 -28
  129. package/dist/types/src/types/locales.d.ts +0 -4
  130. package/dist/types/src/types/modify_collections.d.ts +0 -5
  131. package/dist/types/src/types/plugins.d.ts +0 -282
  132. package/dist/types/src/types/properties.d.ts +0 -1173
  133. package/dist/types/src/types/property_config.d.ts +0 -74
  134. package/dist/types/src/types/relations.d.ts +0 -336
  135. package/dist/types/src/types/slots.d.ts +0 -262
  136. package/dist/types/src/types/translations.d.ts +0 -900
  137. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  138. package/dist/types/src/types/websockets.d.ts +0 -78
  139. package/dist/types/src/users/index.d.ts +0 -1
  140. package/dist/types/src/users/user.d.ts +0 -50
  141. /package/dist/{server-postgresql/src/auth → auth}/ensure-tables.d.ts +0 -0
  142. /package/dist/{server-postgresql/src/auth → auth}/services.d.ts +0 -0
  143. /package/dist/{server-postgresql/src/cli.d.ts → cli.d.ts} +0 -0
  144. /package/dist/{server-postgresql/src/connection.d.ts → connection.d.ts} +0 -0
  145. /package/dist/{server-postgresql/src/data-transformer.d.ts → data-transformer.d.ts} +0 -0
  146. /package/dist/{server-postgresql/src/databasePoolManager.d.ts → databasePoolManager.d.ts} +0 -0
  147. /package/dist/{server-postgresql/src/history → history}/HistoryService.d.ts +0 -0
  148. /package/dist/{server-postgresql/src/history → history}/ensure-history-table.d.ts +0 -0
  149. /package/dist/{server-postgresql/src/index.d.ts → index.d.ts} +0 -0
  150. /package/dist/{server-postgresql/src/interfaces.d.ts → interfaces.d.ts} +0 -0
  151. /package/dist/{server-postgresql/src/schema → schema}/auth-schema.d.ts +0 -0
  152. /package/dist/{server-postgresql/src/schema → schema}/doctor-cli.d.ts +0 -0
  153. /package/dist/{server-postgresql/src/schema → schema}/doctor.d.ts +0 -0
  154. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema-logic.d.ts +0 -0
  155. /package/dist/{server-postgresql/src/schema → schema}/generate-drizzle-schema.d.ts +0 -0
  156. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-inference.d.ts +0 -0
  157. /package/dist/{server-postgresql/src/schema → schema}/introspect-db-logic.d.ts +0 -0
  158. /package/dist/{server-postgresql/src/schema → schema}/introspect-db.d.ts +0 -0
  159. /package/dist/{server-postgresql/src/schema → schema}/test-schema.d.ts +0 -0
  160. /package/dist/{server-postgresql/src/services → services}/BranchService.d.ts +0 -0
  161. /package/dist/{server-postgresql/src/services → services}/EntityFetchService.d.ts +0 -0
  162. /package/dist/{server-postgresql/src/services → services}/RelationService.d.ts +0 -0
  163. /package/dist/{server-postgresql/src/services → services}/entity-helpers.d.ts +0 -0
  164. /package/dist/{server-postgresql/src/services → services}/entityService.d.ts +0 -0
  165. /package/dist/{server-postgresql/src/services → services}/index.d.ts +0 -0
  166. /package/dist/{server-postgresql/src/services → services}/realtimeService.d.ts +0 -0
  167. /package/dist/{server-postgresql/src/types.d.ts → types.d.ts} +0 -0
  168. /package/dist/{server-postgresql/src/utils → utils}/drizzle-conditions.d.ts +0 -0
  169. /package/dist/{server-postgresql/src/websocket.d.ts → websocket.d.ts} +0 -0
@@ -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
- }
@@ -1,168 +0,0 @@
1
- import type { User } from "../users";
2
- import type { RebaseData } from "./data";
3
- import type { 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 type { 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
- metadata?: Record<string, any>;
56
- createdAt: string;
57
- updatedAt: string;
58
- }
59
- /**
60
- * Client-side Admin API interface.
61
- * Provides user management operations.
62
- * @group Admin
63
- */
64
- export interface AdminAPI {
65
- listUsers(): Promise<{
66
- users: AdminUser[];
67
- }>;
68
- listUsersPaginated(options?: {
69
- search?: string;
70
- limit?: number;
71
- offset?: number;
72
- orderBy?: string;
73
- orderDir?: "asc" | "desc";
74
- }): Promise<{
75
- users: AdminUser[];
76
- total: number;
77
- limit: number;
78
- offset: number;
79
- }>;
80
- getUser(userId: string): Promise<{
81
- user: AdminUser;
82
- }>;
83
- createUser(data: {
84
- email: string;
85
- displayName?: string;
86
- password?: string;
87
- roles?: string[];
88
- metadata?: Record<string, any>;
89
- }): Promise<{
90
- user: AdminUser;
91
- }>;
92
- updateUser(userId: string, data: {
93
- email?: string;
94
- displayName?: string;
95
- password?: string;
96
- roles?: string[];
97
- metadata?: Record<string, any>;
98
- }): Promise<{
99
- user: AdminUser;
100
- }>;
101
- deleteUser(userId: string): Promise<{
102
- success: boolean;
103
- }>;
104
- bootstrap(): Promise<{
105
- success: boolean;
106
- message: string;
107
- user: {
108
- uid: string;
109
- roles: string[];
110
- };
111
- }>;
112
- }
113
- /**
114
- * Overarching abstraction that unites Data, Auth, Storage, and Email.
115
- * Adapters for Supabase or Firebase simply need to implement this interface.
116
- */
117
- export interface RebaseClient<DB = unknown> {
118
- /** Unified Data access layer */
119
- data: RebaseData;
120
- /** Unified Authentication layer */
121
- auth: AuthClient;
122
- /** Unified Storage layer */
123
- storage?: StorageSource;
124
- /**
125
- * Server-side email service.
126
- *
127
- * Available when SMTP (or a custom `sendEmail` function) is configured
128
- * in the backend auth config. `undefined` when email is not configured.
129
- *
130
- * > **Note:** This is only available on the server-side `rebase` singleton.
131
- * > The client-side SDK does not include an email service.
132
- */
133
- email?: EmailService;
134
- /** Admin API for user management */
135
- admin?: AdminAPI;
136
- /**
137
- * The base HTTP URL of the backend server.
138
- * Exposed by the SDK client (`@rebasepro/client`) and used to auto-derive
139
- * the `ApiConfigProvider` URL.
140
- */
141
- baseUrl?: string;
142
- /**
143
- * WebSocket client for realtime subscriptions and admin capabilities.
144
- * Exposed by the SDK client (`@rebasepro/client`). The shape is intentionally
145
- * left as `unknown` in the base interface — callers should narrow via feature
146
- * detection (e.g. `typeof ws.executeSql === "function"`).
147
- */
148
- ws?: unknown;
149
- /**
150
- * Execute raw SQL against the database.
151
- *
152
- * Only available server-side when the backend uses a SQL database
153
- * (PostgreSQL, MySQL, etc.). `undefined` for document databases
154
- * (MongoDB, Firestore) and on the client-side SDK.
155
- *
156
- * @example
157
- * ```typescript
158
- * // In a cron job or custom function:
159
- * if (ctx.client.sql) {
160
- * const rows = await ctx.client.sql("SELECT count(*) FROM orders");
161
- * }
162
- * ```
163
- */
164
- sql?(query: string, options?: {
165
- database?: string;
166
- role?: string;
167
- }): Promise<Record<string, unknown>[]>;
168
- }
@@ -1,46 +0,0 @@
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> = {
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
- getParentCollectionSlugs: (path: string) => string[];
40
- getParentEntityIds: (path: string) => string[];
41
- /**
42
- * Resolve paths from a list of ids
43
- * @param ids
44
- */
45
- convertIdsToPaths: (ids: string[]) => string[];
46
- };
@@ -1,60 +0,0 @@
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
- };
@@ -1,207 +0,0 @@
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] | [WhereFilterOpShort, any][];
20
- export type WhereValue<T> = T | T[] | null;
21
- export interface LogicalCondition {
22
- type: "and" | "or";
23
- conditions: (FilterCondition | LogicalCondition)[];
24
- }
25
- export interface FilterCondition {
26
- column: string;
27
- operator: FilterOperator;
28
- value: unknown;
29
- }
30
- /** Short operator strings accepted in the tuple syntax. */
31
- export type WhereFilterOpShort = "==" | "!=" | ">" | ">=" | "<" | "<=" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "not-in" | "array-contains" | "array-contains-any" | "cs" | "csa";
32
- export interface FindParams {
33
- /** Maximum number of items to return (default: 20) */
34
- limit?: number;
35
- /** Number of items to skip */
36
- offset?: number;
37
- /** Page number (1-indexed), alternative to offset */
38
- page?: number;
39
- /**
40
- * Filter object. Supports multiple syntaxes per field:
41
- *
42
- * **Equality shorthand** — raw JS values (null, string, number, boolean):
43
- * ```ts
44
- * { company_profile_id: null }
45
- * { status: "active" }
46
- * { age: 18 }
47
- * ```
48
- *
49
- * **Tuple syntax** — `[operator, value]`:
50
- * ```ts
51
- * { age: [">=", 18] }
52
- * { role: ["in", ["admin", "editor"]] }
53
- * { deleted_at: ["!=", null] }
54
- * ```
55
- *
56
- * **PostgREST string syntax** (original format):
57
- * ```ts
58
- * { status: "eq.published" }
59
- * { age: "gte.18" }
60
- * { role: "in.(admin,editor)" }
61
- * ```
62
- */
63
- where?: Record<string, WhereFieldValue>;
64
- /** Logical grouping conditions (AND/OR) */
65
- logical?: LogicalCondition;
66
- /**
67
- * Sort order. Format: "field:direction".
68
- * @example "created_at:desc", "name:asc"
69
- */
70
- orderBy?: string;
71
- /** Relations to include in the response */
72
- include?: string[];
73
- /** Full-text search string */
74
- searchString?: string;
75
- }
76
- /**
77
- * Paginated response from a collection query.
78
- * @group Data
79
- */
80
- export interface FindResponse<M extends Record<string, unknown> = Record<string, unknown>> {
81
- /** Array of entities matching the query */
82
- data: Entity<M>[];
83
- /** Pagination metadata */
84
- meta: {
85
- total: number;
86
- limit: number;
87
- offset: number;
88
- hasMore: boolean;
89
- };
90
- }
91
- export type FilterOperator = WhereFilterOpShort;
92
- /**
93
- * Fluent Query Builder Interface supported on both client and server accessors.
94
- * @group Data
95
- */
96
- export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
97
- where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): this;
98
- where(logicalCondition: LogicalCondition): this;
99
- orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
100
- limit(count: number): this;
101
- offset(count: number): this;
102
- search(searchString: string): this;
103
- include(...relations: string[]): this;
104
- find(): Promise<FindResponse<M>>;
105
- listen(onUpdate: (data: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
106
- }
107
- /**
108
- * A single collection's CRUD accessor.
109
- *
110
- * This is the unified API surface used in both:
111
- * - The generated SDK (`client.data.products.create(...)`)
112
- * - Framework callbacks (`context.data.products.create(...)`)
113
- *
114
- * @group Data
115
- */
116
- export interface CollectionAccessor<M extends Record<string, unknown> = Record<string, unknown>> {
117
- /**
118
- * Find multiple records with optional filtering, pagination, and sorting.
119
- */
120
- find(params?: FindParams): Promise<FindResponse<M>>;
121
- /**
122
- * Find a single record by its ID.
123
- */
124
- findById(id: string | number): Promise<Entity<M> | undefined>;
125
- /**
126
- * Create a new record.
127
- * @param data The entity data to create.
128
- * @param id Optional specific ID to use for the new record.
129
- * @returns The created entity
130
- */
131
- create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
132
- /**
133
- * Update an existing record by ID.
134
- * @returns The updated entity
135
- */
136
- update(id: string | number, data: Partial<EntityValues<M>>): Promise<Entity<M>>;
137
- /**
138
- * Delete a record by ID.
139
- */
140
- delete(id: string | number): Promise<void>;
141
- /**
142
- * Delete all records in this collection.
143
- */
144
- deleteAll?(): Promise<void>;
145
- /**
146
- * Subscribe to a collection for real-time updates.
147
- * Optional method, may not be supported by all implementations (like stateless HTTP clients).
148
- */
149
- listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
150
- /**
151
- * Subscribe to a single record for real-time updates.
152
- * Optional method.
153
- */
154
- listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void): () => void;
155
- /**
156
- * Count the number of records matching the given filter.
157
- */
158
- count?(params?: FindParams): Promise<number>;
159
- where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): QueryBuilderInterface<M>;
160
- where(logicalCondition: LogicalCondition): QueryBuilderInterface<M>;
161
- orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilderInterface<M>;
162
- limit(count: number): QueryBuilderInterface<M>;
163
- offset(count: number): QueryBuilderInterface<M>;
164
- search(searchString: string): QueryBuilderInterface<M>;
165
- include(...relations: string[]): QueryBuilderInterface<M>;
166
- }
167
- /**
168
- * The unified data access object.
169
- *
170
- * Access collections as dynamic properties: `data.products.find(...)`.
171
- * In the SDK this is backed by HTTP transport (typed, generated per-project).
172
- * In the framework this is backed by a Proxy + in-process database driver (dynamic).
173
- *
174
- * @example
175
- * // SDK
176
- * const client = createRebaseClient({ baseUrl: "..." });
177
- * await client.data.products.create({ name: "Camera", price: 299 });
178
- *
179
- * // Framework callback
180
- * callbacks: {
181
- * afterSave({ context }) {
182
- * await context.data.logs.create({ action: "saved", timestamp: new Date() });
183
- * }
184
- * }
185
- *
186
- * @group Data
187
- */
188
- export interface RebaseData {
189
- /**
190
- * Get a collection accessor by slug.
191
- * Alternative to dynamic property access for cases where
192
- * the collection name is a variable.
193
- *
194
- * @example
195
- * const accessor = data.collection("products");
196
- * await accessor.find({ limit: 10 });
197
- */
198
- collection(slug: string): CollectionAccessor;
199
- /**
200
- * Dynamic collection accessor.
201
- * Access any collection by its slug as a property.
202
- *
203
- * @example
204
- * data.products.find({ where: { status: "eq.published" } })
205
- */
206
- [collectionSlug: string]: CollectionAccessor | ((slug: string) => CollectionAccessor);
207
- }