@rebasepro/types 0.0.1-canary.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.
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/components/EntityFormActionsProps.d.ts +17 -0
- package/dist/components/EntityFormProps.d.ts +46 -0
- package/dist/components/PropertyPreviewProps.d.ts +50 -0
- package/dist/components/formex.d.ts +40 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/controllers/analytics_controller.d.ts +7 -0
- package/dist/controllers/auth.d.ts +73 -0
- package/dist/controllers/customization_controller.d.ts +50 -0
- package/dist/controllers/datasource.d.ts +179 -0
- package/dist/controllers/dialogs_controller.d.ts +36 -0
- package/dist/controllers/index.d.ts +11 -0
- package/dist/controllers/local_config_persistence.d.ts +20 -0
- package/dist/controllers/navigation.d.ts +262 -0
- package/dist/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/controllers/side_entity_controller.d.ts +90 -0
- package/dist/controllers/snackbar.d.ts +24 -0
- package/dist/controllers/storage.d.ts +173 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +113 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +117 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/rebase_context.d.ts +91 -0
- package/dist/types/backend.d.ts +254 -0
- package/dist/types/chips.d.ts +5 -0
- package/dist/types/collections.d.ts +887 -0
- package/dist/types/entities.d.ts +140 -0
- package/dist/types/entity_actions.d.ts +98 -0
- package/dist/types/entity_callbacks.d.ts +173 -0
- package/dist/types/entity_link_builder.d.ts +7 -0
- package/dist/types/entity_overrides.d.ts +5 -0
- package/dist/types/export_import.d.ts +21 -0
- package/dist/types/fields.d.ts +221 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/locales.d.ts +4 -0
- package/dist/types/modify_collections.d.ts +5 -0
- package/dist/types/plugins.d.ts +276 -0
- package/dist/types/properties.d.ts +1103 -0
- package/dist/types/property_config.d.ts +68 -0
- package/dist/types/rebase.d.ts +180 -0
- package/dist/types/relations.d.ts +336 -0
- package/dist/types/user_management_delegate.d.ts +78 -0
- package/dist/types/websockets.d.ts +33 -0
- package/dist/users/index.d.ts +2 -0
- package/dist/users/roles.d.ts +22 -0
- package/dist/users/user.d.ts +42 -0
- package/package.json +137 -0
- package/src/components/EntityFormActionsProps.tsx +18 -0
- package/src/components/EntityFormProps.tsx +52 -0
- package/src/components/PropertyPreviewProps.tsx +61 -0
- package/src/components/formex.tsx +46 -0
- package/src/components/index.ts +3 -0
- package/src/controllers/analytics_controller.tsx +57 -0
- package/src/controllers/auth.tsx +94 -0
- package/src/controllers/customization_controller.tsx +61 -0
- package/src/controllers/datasource.ts +218 -0
- package/src/controllers/dialogs_controller.tsx +37 -0
- package/src/controllers/index.ts +11 -0
- package/src/controllers/local_config_persistence.tsx +22 -0
- package/src/controllers/navigation.ts +317 -0
- package/src/controllers/side_dialogs_controller.tsx +82 -0
- package/src/controllers/side_entity_controller.tsx +104 -0
- package/src/controllers/snackbar.ts +29 -0
- package/src/controllers/storage.ts +196 -0
- package/src/index.ts +5 -0
- package/src/rebase_context.tsx +122 -0
- package/src/types/backend.ts +385 -0
- package/src/types/chips.ts +46 -0
- package/src/types/collections.ts +1013 -0
- package/src/types/entities.ts +207 -0
- package/src/types/entity_actions.tsx +118 -0
- package/src/types/entity_callbacks.ts +217 -0
- package/src/types/entity_link_builder.ts +8 -0
- package/src/types/entity_overrides.tsx +6 -0
- package/src/types/export_import.ts +26 -0
- package/src/types/fields.tsx +298 -0
- package/src/types/index.ts +20 -0
- package/src/types/locales.ts +81 -0
- package/src/types/modify_collections.tsx +6 -0
- package/src/types/plugins.tsx +328 -0
- package/src/types/properties.ts +1270 -0
- package/src/types/property_config.tsx +93 -0
- package/src/types/rebase.tsx +211 -0
- package/src/types/relations.ts +351 -0
- package/src/types/user_management_delegate.ts +98 -0
- package/src/types/websockets.ts +37 -0
- package/src/users/index.ts +2 -0
- package/src/users/roles.ts +33 -0
- package/src/users/user.ts +46 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { Entity, EntityCollection, FilterValues, WhereFilterOp } from "./index";
|
|
2
|
+
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// DATABASE CONNECTION INTERFACES
|
|
5
|
+
// =============================================================================
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Abstract database connection interface.
|
|
9
|
+
* Represents a connection to any database system.
|
|
10
|
+
*/
|
|
11
|
+
export interface DatabaseConnection {
|
|
12
|
+
/**
|
|
13
|
+
* Type identifier for this database (e.g., 'postgres', 'mongodb', 'mysql')
|
|
14
|
+
*/
|
|
15
|
+
readonly type: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether the connection is currently active
|
|
19
|
+
*/
|
|
20
|
+
readonly isConnected?: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Close the database connection
|
|
24
|
+
*/
|
|
25
|
+
close?(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// QUERY BUILDING INTERFACES
|
|
30
|
+
// =============================================================================
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A single filter condition for database queries
|
|
34
|
+
*/
|
|
35
|
+
export interface QueryFilter {
|
|
36
|
+
field: string;
|
|
37
|
+
operator: WhereFilterOp;
|
|
38
|
+
value: unknown;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Options for fetching a collection of entities
|
|
43
|
+
*/
|
|
44
|
+
export interface FetchCollectionOptions<M extends Record<string, any> = any> {
|
|
45
|
+
filter?: FilterValues<Extract<keyof M, string>>;
|
|
46
|
+
orderBy?: string;
|
|
47
|
+
order?: "desc" | "asc";
|
|
48
|
+
limit?: number;
|
|
49
|
+
startAfter?: unknown;
|
|
50
|
+
searchString?: string;
|
|
51
|
+
databaseId?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Options for searching entities
|
|
56
|
+
*/
|
|
57
|
+
export interface SearchOptions<M extends Record<string, any> = any> {
|
|
58
|
+
filter?: FilterValues<Extract<keyof M, string>>;
|
|
59
|
+
orderBy?: string;
|
|
60
|
+
order?: "desc" | "asc";
|
|
61
|
+
limit?: number;
|
|
62
|
+
databaseId?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Options for counting entities
|
|
67
|
+
*/
|
|
68
|
+
export interface CountOptions<M extends Record<string, any> = any> {
|
|
69
|
+
filter?: FilterValues<Extract<keyof M, string>>;
|
|
70
|
+
databaseId?: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Abstract condition builder interface.
|
|
75
|
+
* Implementations translate Rebase filter conditions to database-specific queries.
|
|
76
|
+
*
|
|
77
|
+
* Note: This interface can be implemented as instance methods or as a class with static methods.
|
|
78
|
+
* For static implementations (like DrizzleConditionBuilder), use the ConditionBuilderStatic type.
|
|
79
|
+
*
|
|
80
|
+
* @template T The type of condition returned by the builder (e.g., SQL for PostgreSQL, Filter<Document> for MongoDB)
|
|
81
|
+
*/
|
|
82
|
+
export interface ConditionBuilder<T = any> {
|
|
83
|
+
/**
|
|
84
|
+
* Build filter conditions from Rebase FilterValues
|
|
85
|
+
*/
|
|
86
|
+
buildFilterConditions<M extends Record<string, any>>(
|
|
87
|
+
filter: FilterValues<Extract<keyof M, string>>,
|
|
88
|
+
collectionPath: string,
|
|
89
|
+
...args: unknown[]
|
|
90
|
+
): T[];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Build search conditions for text search
|
|
94
|
+
*/
|
|
95
|
+
buildSearchConditions(
|
|
96
|
+
searchString: string,
|
|
97
|
+
properties: Record<string, unknown>,
|
|
98
|
+
...args: unknown[]
|
|
99
|
+
): T[];
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Combine multiple conditions with AND operator
|
|
103
|
+
*/
|
|
104
|
+
combineConditionsWithAnd(conditions: T[]): T | undefined;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Combine multiple conditions with OR operator
|
|
108
|
+
*/
|
|
109
|
+
combineConditionsWithOr(conditions: T[]): T | undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Static condition builder type for implementations using static methods.
|
|
114
|
+
* Use this type when the class provides static methods rather than instance methods.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* // DrizzleConditionBuilder satisfies this type
|
|
118
|
+
* const builder: ConditionBuilderStatic<SQL> = DrizzleConditionBuilder;
|
|
119
|
+
*/
|
|
120
|
+
export type ConditionBuilderStatic<T = any> = {
|
|
121
|
+
buildFilterConditions<M extends Record<string, any>>(
|
|
122
|
+
filter: FilterValues<Extract<keyof M, string>>,
|
|
123
|
+
...args: unknown[]
|
|
124
|
+
): T[];
|
|
125
|
+
buildSearchConditions(
|
|
126
|
+
searchString: string,
|
|
127
|
+
properties: Record<string, unknown>,
|
|
128
|
+
...args: unknown[]
|
|
129
|
+
): T[];
|
|
130
|
+
combineConditionsWithAnd(conditions: T[]): T | undefined;
|
|
131
|
+
combineConditionsWithOr(conditions: T[]): T | undefined;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// =============================================================================
|
|
135
|
+
// ENTITY REPOSITORY INTERFACES
|
|
136
|
+
// =============================================================================
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Abstract entity repository interface.
|
|
140
|
+
* Handles all CRUD operations for entities in the database.
|
|
141
|
+
*
|
|
142
|
+
* Implementations should handle:
|
|
143
|
+
* - Entity serialization/deserialization
|
|
144
|
+
* - Relation resolution
|
|
145
|
+
* - ID generation and conversion
|
|
146
|
+
*/
|
|
147
|
+
export interface EntityRepository {
|
|
148
|
+
/**
|
|
149
|
+
* Fetch a single entity by ID
|
|
150
|
+
*/
|
|
151
|
+
fetchEntity<M extends Record<string, any>>(
|
|
152
|
+
collectionPath: string,
|
|
153
|
+
entityId: string | number,
|
|
154
|
+
databaseId?: string
|
|
155
|
+
): Promise<Entity<M> | undefined>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Fetch a collection of entities with optional filtering, ordering, and pagination
|
|
159
|
+
*/
|
|
160
|
+
fetchCollection<M extends Record<string, any>>(
|
|
161
|
+
collectionPath: string,
|
|
162
|
+
options?: FetchCollectionOptions<M>
|
|
163
|
+
): Promise<Entity<M>[]>;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Search entities by text
|
|
167
|
+
*/
|
|
168
|
+
searchEntities<M extends Record<string, any>>(
|
|
169
|
+
collectionPath: string,
|
|
170
|
+
searchString: string,
|
|
171
|
+
options?: SearchOptions<M>
|
|
172
|
+
): Promise<Entity<M>[]>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Count entities in a collection
|
|
176
|
+
*/
|
|
177
|
+
countEntities<M extends Record<string, any>>(
|
|
178
|
+
collectionPath: string,
|
|
179
|
+
options?: CountOptions<M>
|
|
180
|
+
): Promise<number>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Save an entity (create or update)
|
|
184
|
+
*/
|
|
185
|
+
saveEntity<M extends Record<string, any>>(
|
|
186
|
+
collectionPath: string,
|
|
187
|
+
values: Partial<M>,
|
|
188
|
+
entityId?: string | number,
|
|
189
|
+
databaseId?: string
|
|
190
|
+
): Promise<Entity<M>>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Delete an entity by ID
|
|
194
|
+
*/
|
|
195
|
+
deleteEntity(
|
|
196
|
+
collectionPath: string,
|
|
197
|
+
entityId: string | number,
|
|
198
|
+
databaseId?: string
|
|
199
|
+
): Promise<void>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Check if a field value is unique in a collection
|
|
203
|
+
*/
|
|
204
|
+
checkUniqueField(
|
|
205
|
+
collectionPath: string,
|
|
206
|
+
fieldName: string,
|
|
207
|
+
value: unknown,
|
|
208
|
+
excludeEntityId?: string,
|
|
209
|
+
databaseId?: string
|
|
210
|
+
): Promise<boolean>;
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// =============================================================================
|
|
215
|
+
// REALTIME INTERFACES
|
|
216
|
+
// =============================================================================
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Configuration for subscribing to a collection
|
|
220
|
+
*/
|
|
221
|
+
export interface CollectionSubscriptionConfig {
|
|
222
|
+
clientId: string;
|
|
223
|
+
path: string;
|
|
224
|
+
filter?: unknown;
|
|
225
|
+
orderBy?: string;
|
|
226
|
+
order?: "desc" | "asc";
|
|
227
|
+
limit?: number;
|
|
228
|
+
startAfter?: unknown;
|
|
229
|
+
databaseId?: string;
|
|
230
|
+
searchString?: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Configuration for subscribing to a single entity
|
|
235
|
+
*/
|
|
236
|
+
export interface EntitySubscriptionConfig {
|
|
237
|
+
clientId: string;
|
|
238
|
+
path: string;
|
|
239
|
+
entityId: string | number;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Abstract realtime provider interface.
|
|
244
|
+
* Handles real-time subscriptions and notifications for entity changes.
|
|
245
|
+
*/
|
|
246
|
+
export interface RealtimeProvider {
|
|
247
|
+
/**
|
|
248
|
+
* Subscribe to collection changes
|
|
249
|
+
*/
|
|
250
|
+
subscribeToCollection(
|
|
251
|
+
subscriptionId: string,
|
|
252
|
+
config: CollectionSubscriptionConfig,
|
|
253
|
+
callback?: (entities: Entity[]) => void
|
|
254
|
+
): void;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Subscribe to single entity changes
|
|
258
|
+
*/
|
|
259
|
+
subscribeToEntity(
|
|
260
|
+
subscriptionId: string,
|
|
261
|
+
config: EntitySubscriptionConfig,
|
|
262
|
+
callback?: (entity: Entity | null) => void
|
|
263
|
+
): void;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Unsubscribe from a subscription
|
|
267
|
+
*/
|
|
268
|
+
unsubscribe(subscriptionId: string): void;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Notify all relevant subscribers of an entity update
|
|
272
|
+
*/
|
|
273
|
+
notifyEntityUpdate(
|
|
274
|
+
path: string,
|
|
275
|
+
entityId: string,
|
|
276
|
+
entity: Entity | null,
|
|
277
|
+
databaseId?: string
|
|
278
|
+
): Promise<void>;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// =============================================================================
|
|
282
|
+
// COLLECTION REGISTRY INTERFACES
|
|
283
|
+
// =============================================================================
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Abstract collection registry interface.
|
|
287
|
+
* Manages registration and lookup of entity collections.
|
|
288
|
+
*/
|
|
289
|
+
export interface CollectionRegistryInterface {
|
|
290
|
+
/**
|
|
291
|
+
* Register a collection
|
|
292
|
+
*/
|
|
293
|
+
register(collection: EntityCollection): void;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Get a collection by its path
|
|
297
|
+
*/
|
|
298
|
+
getCollectionByPath(path: string): EntityCollection | undefined;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Get all registered collections
|
|
302
|
+
*/
|
|
303
|
+
getCollections(): EntityCollection[];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// =============================================================================
|
|
307
|
+
// DATA TRANSFORMER INTERFACES
|
|
308
|
+
// =============================================================================
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Abstract data transformer interface.
|
|
312
|
+
* Handles serialization/deserialization between frontend and database formats.
|
|
313
|
+
*/
|
|
314
|
+
export interface DataTransformer {
|
|
315
|
+
/**
|
|
316
|
+
* Transform entity data for storage in the database
|
|
317
|
+
*/
|
|
318
|
+
serializeToDatabase<M extends Record<string, any>>(
|
|
319
|
+
entity: M,
|
|
320
|
+
collection: EntityCollection
|
|
321
|
+
): Record<string, any>;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Transform database data back to entity format
|
|
325
|
+
*/
|
|
326
|
+
deserializeFromDatabase<M extends Record<string, any>>(
|
|
327
|
+
data: Record<string, any>,
|
|
328
|
+
collection: EntityCollection
|
|
329
|
+
): Promise<M>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// =============================================================================
|
|
333
|
+
// BACKEND FACTORY INTERFACES
|
|
334
|
+
// =============================================================================
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Configuration for creating a database backend
|
|
338
|
+
*/
|
|
339
|
+
export interface BackendConfig {
|
|
340
|
+
/**
|
|
341
|
+
* Type of database backend
|
|
342
|
+
*/
|
|
343
|
+
type: string;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Database connection (implementation-specific)
|
|
347
|
+
*/
|
|
348
|
+
connection: unknown;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Schema definition (implementation-specific, e.g., Drizzle schema for PostgreSQL)
|
|
352
|
+
*/
|
|
353
|
+
schema?: unknown;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* A complete backend instance with all required services
|
|
358
|
+
*/
|
|
359
|
+
export interface BackendInstance {
|
|
360
|
+
/**
|
|
361
|
+
* Entity repository for CRUD operations
|
|
362
|
+
*/
|
|
363
|
+
entityRepository: EntityRepository;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Realtime provider for subscriptions
|
|
367
|
+
*/
|
|
368
|
+
realtimeProvider: RealtimeProvider;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Collection registry
|
|
372
|
+
*/
|
|
373
|
+
collectionRegistry: CollectionRegistryInterface;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* The underlying database connection
|
|
377
|
+
*/
|
|
378
|
+
connection: DatabaseConnection;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Factory function type for creating backend instances
|
|
383
|
+
*/
|
|
384
|
+
export type BackendFactory<TConfig extends BackendConfig = BackendConfig> =
|
|
385
|
+
(config: TConfig) => BackendInstance;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type ColorScheme = {
|
|
2
|
+
color: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type ColorKey =
|
|
7
|
+
| "blueLighter"
|
|
8
|
+
| "cyanLighter"
|
|
9
|
+
| "tealLighter"
|
|
10
|
+
| "greenLighter"
|
|
11
|
+
| "yellowLighter"
|
|
12
|
+
| "orangeLighter"
|
|
13
|
+
| "redLighter"
|
|
14
|
+
| "pinkLighter"
|
|
15
|
+
| "purpleLighter"
|
|
16
|
+
| "grayLighter"
|
|
17
|
+
| "blueLight"
|
|
18
|
+
| "cyanLight"
|
|
19
|
+
| "tealLight"
|
|
20
|
+
| "greenLight"
|
|
21
|
+
| "yellowLight"
|
|
22
|
+
| "orangeLight"
|
|
23
|
+
| "redLight"
|
|
24
|
+
| "pinkLight"
|
|
25
|
+
| "purpleLight"
|
|
26
|
+
| "grayLight"
|
|
27
|
+
| "blueDark"
|
|
28
|
+
| "cyanDark"
|
|
29
|
+
| "tealDark"
|
|
30
|
+
| "greenDark"
|
|
31
|
+
| "yellowDark"
|
|
32
|
+
| "orangeDark"
|
|
33
|
+
| "redDark"
|
|
34
|
+
| "pinkDark"
|
|
35
|
+
| "purpleDark"
|
|
36
|
+
| "grayDark"
|
|
37
|
+
| "blueDarker"
|
|
38
|
+
| "cyanDarker"
|
|
39
|
+
| "tealDarker"
|
|
40
|
+
| "greenDarker"
|
|
41
|
+
| "yellowDarker"
|
|
42
|
+
| "orangeDarker"
|
|
43
|
+
| "redDarker"
|
|
44
|
+
| "pinkDarker"
|
|
45
|
+
| "purpleDarker"
|
|
46
|
+
| "grayDarker";
|