@rebasepro/types 0.7.0 → 0.9.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/README.md +10 -10
- package/dist/controllers/auth.d.ts +1 -1
- package/dist/controllers/client.d.ts +237 -7
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +285 -81
- package/dist/controllers/data_driver.d.ts +50 -37
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +2 -2
- package/dist/controllers/registry.d.ts +17 -6
- package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
- package/dist/controllers/storage.d.ts +39 -0
- package/dist/errors.d.ts +64 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +290 -16
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +305 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +9 -6
- package/dist/types/backend.d.ts +30 -26
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +211 -136
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +10 -1
- package/dist/types/data_source.d.ts +18 -5
- package/dist/types/database_adapter.d.ts +4 -3
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +55 -43
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +153 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +191 -0
- package/dist/types/properties.d.ts +153 -43
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/storage_source.d.ts +83 -0
- package/dist/types/websockets.d.ts +12 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +1 -1
- package/src/controllers/auth.tsx +1 -1
- package/src/controllers/client.ts +275 -7
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +309 -97
- package/src/controllers/data_driver.ts +49 -40
- package/src/controllers/index.ts +1 -1
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +2 -2
- package/src/controllers/registry.ts +18 -6
- package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
- package/src/controllers/storage.ts +60 -1
- package/src/errors.ts +80 -0
- package/src/index.ts +1 -0
- package/src/rebase_context.tsx +8 -4
- package/src/types/auth_adapter.ts +9 -6
- package/src/types/backend.ts +41 -36
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +256 -172
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +10 -1
- package/src/types/data_source.ts +29 -7
- package/src/types/database_adapter.ts +4 -3
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +58 -47
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +240 -0
- package/src/types/index.ts +3 -2
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +229 -0
- package/src/types/properties.ts +164 -44
- package/src/types/property_config.tsx +0 -1
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/storage_source.ts +90 -0
- package/src/types/websockets.ts +12 -14
- package/src/users/user.ts +22 -9
- package/dist/types/backend_hooks.d.ts +0 -109
- package/dist/types/entity_overrides.d.ts +0 -10
- package/src/types/backend_hooks.ts +0 -114
- package/src/types/entity_overrides.tsx +0 -11
package/src/types/backend.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { EntityCollection, FilterValues, WhereFilterOp } from "./collections";
|
|
1
|
+
import type { CollectionConfig, FilterValues, WhereFilterOp } from "./collections";
|
|
3
2
|
import type { AuthAdapter } from "./auth_adapter";
|
|
3
|
+
import type { HistoryConfig } from "../controllers/client";
|
|
4
4
|
|
|
5
5
|
// =============================================================================
|
|
6
6
|
// DATABASE CONNECTION INTERFACES
|
|
@@ -52,7 +52,7 @@ export interface FetchCollectionOptions<M extends Record<string, unknown> = Reco
|
|
|
52
52
|
startAfter?: unknown;
|
|
53
53
|
searchString?: string;
|
|
54
54
|
databaseId?: string;
|
|
55
|
-
collection?:
|
|
55
|
+
collection?: CollectionConfig;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -64,7 +64,7 @@ export interface SearchOptions<M extends Record<string, unknown> = Record<string
|
|
|
64
64
|
order?: "desc" | "asc";
|
|
65
65
|
limit?: number;
|
|
66
66
|
databaseId?: string;
|
|
67
|
-
collection?:
|
|
67
|
+
collection?: CollectionConfig;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -150,15 +150,15 @@ export type ConditionBuilderStatic<T = unknown> = {
|
|
|
150
150
|
* - Relation resolution
|
|
151
151
|
* - ID generation and conversion
|
|
152
152
|
*/
|
|
153
|
-
export interface
|
|
153
|
+
export interface DataRepository {
|
|
154
154
|
/**
|
|
155
155
|
* Fetch a single entity by ID
|
|
156
156
|
*/
|
|
157
|
-
|
|
157
|
+
fetchOne<M extends Record<string, unknown>>(
|
|
158
158
|
collectionPath: string,
|
|
159
|
-
|
|
159
|
+
id: string | number,
|
|
160
160
|
databaseId?: string
|
|
161
|
-
): Promise<
|
|
161
|
+
): Promise<Record<string, unknown> | undefined>;
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
* Fetch a collection of entities with optional filtering, ordering, and pagination
|
|
@@ -166,41 +166,41 @@ export interface EntityRepository {
|
|
|
166
166
|
fetchCollection<M extends Record<string, unknown>>(
|
|
167
167
|
collectionPath: string,
|
|
168
168
|
options?: FetchCollectionOptions<M>
|
|
169
|
-
): Promise<
|
|
169
|
+
): Promise<Record<string, unknown>[]>;
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Search entities by text
|
|
173
173
|
*/
|
|
174
|
-
|
|
174
|
+
searchRows<M extends Record<string, unknown>>(
|
|
175
175
|
collectionPath: string,
|
|
176
176
|
searchString: string,
|
|
177
177
|
options?: SearchOptions<M>
|
|
178
|
-
): Promise<
|
|
178
|
+
): Promise<Record<string, unknown>[]>;
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* Count entities in a collection
|
|
182
182
|
*/
|
|
183
|
-
|
|
183
|
+
count<M extends Record<string, unknown>>(
|
|
184
184
|
collectionPath: string,
|
|
185
185
|
options?: CountOptions<M>
|
|
186
186
|
): Promise<number>;
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
|
-
* Save
|
|
189
|
+
* Save a entity (create or update)
|
|
190
190
|
*/
|
|
191
|
-
|
|
191
|
+
save<M extends Record<string, unknown>>(
|
|
192
192
|
collectionPath: string,
|
|
193
193
|
values: Partial<M>,
|
|
194
|
-
|
|
194
|
+
id?: string | number,
|
|
195
195
|
databaseId?: string
|
|
196
|
-
): Promise<
|
|
196
|
+
): Promise<Record<string, unknown>>;
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
* Delete
|
|
199
|
+
* Delete a entity by ID
|
|
200
200
|
*/
|
|
201
|
-
|
|
201
|
+
delete(
|
|
202
202
|
collectionPath: string,
|
|
203
|
-
|
|
203
|
+
id: string | number,
|
|
204
204
|
databaseId?: string
|
|
205
205
|
): Promise<void>;
|
|
206
206
|
|
|
@@ -239,10 +239,10 @@ export interface CollectionSubscriptionConfig {
|
|
|
239
239
|
/**
|
|
240
240
|
* Configuration for subscribing to a single entity
|
|
241
241
|
*/
|
|
242
|
-
export interface
|
|
242
|
+
export interface SingleSubscriptionConfig {
|
|
243
243
|
clientId: string;
|
|
244
244
|
path: string;
|
|
245
|
-
|
|
245
|
+
id: string | number;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
/**
|
|
@@ -256,16 +256,16 @@ export interface RealtimeProvider {
|
|
|
256
256
|
subscribeToCollection(
|
|
257
257
|
subscriptionId: string,
|
|
258
258
|
config: CollectionSubscriptionConfig,
|
|
259
|
-
callback?: (
|
|
259
|
+
callback?: (rows: Record<string, unknown>[]) => void
|
|
260
260
|
): void;
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
263
|
* Subscribe to single entity changes
|
|
264
264
|
*/
|
|
265
|
-
|
|
265
|
+
subscribeToOne(
|
|
266
266
|
subscriptionId: string,
|
|
267
|
-
config:
|
|
268
|
-
callback?: (
|
|
267
|
+
config: SingleSubscriptionConfig,
|
|
268
|
+
callback?: (row: Record<string, unknown> | null) => void
|
|
269
269
|
): void;
|
|
270
270
|
|
|
271
271
|
/**
|
|
@@ -274,12 +274,12 @@ export interface RealtimeProvider {
|
|
|
274
274
|
unsubscribe(subscriptionId: string): void;
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
* Notify all relevant subscribers of
|
|
277
|
+
* Notify all relevant subscribers of a entity update
|
|
278
278
|
*/
|
|
279
|
-
|
|
279
|
+
notifyUpdate(
|
|
280
280
|
path: string,
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
id: string,
|
|
282
|
+
row: Record<string, unknown> | null,
|
|
283
283
|
databaseId?: string
|
|
284
284
|
): Promise<void>;
|
|
285
285
|
|
|
@@ -314,17 +314,22 @@ export interface CollectionRegistryInterface {
|
|
|
314
314
|
/**
|
|
315
315
|
* Register a collection
|
|
316
316
|
*/
|
|
317
|
-
register(collection:
|
|
317
|
+
register(collection: CollectionConfig): void;
|
|
318
318
|
|
|
319
319
|
/**
|
|
320
320
|
* Get a collection by its path
|
|
321
321
|
*/
|
|
322
|
-
getCollectionByPath(path: string):
|
|
322
|
+
getCollectionByPath(path: string): CollectionConfig | undefined;
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
325
|
* Get all registered collections
|
|
326
326
|
*/
|
|
327
|
-
getCollections():
|
|
327
|
+
getCollections(): CollectionConfig[];
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Get the currently registered global callbacks, if any.
|
|
331
|
+
*/
|
|
332
|
+
getGlobalCallbacks(): any | undefined;
|
|
328
333
|
}
|
|
329
334
|
|
|
330
335
|
// =============================================================================
|
|
@@ -341,7 +346,7 @@ export interface DataTransformer {
|
|
|
341
346
|
*/
|
|
342
347
|
serializeToDatabase<M extends Record<string, unknown>>(
|
|
343
348
|
entity: M,
|
|
344
|
-
collection:
|
|
349
|
+
collection: CollectionConfig
|
|
345
350
|
): Record<string, unknown>;
|
|
346
351
|
|
|
347
352
|
/**
|
|
@@ -349,7 +354,7 @@ export interface DataTransformer {
|
|
|
349
354
|
*/
|
|
350
355
|
deserializeFromDatabase<M extends Record<string, unknown>>(
|
|
351
356
|
data: Record<string, unknown>,
|
|
352
|
-
collection:
|
|
357
|
+
collection: CollectionConfig
|
|
353
358
|
): Promise<M>;
|
|
354
359
|
}
|
|
355
360
|
|
|
@@ -584,7 +589,7 @@ export interface BackendInstance extends BackendLifecycle {
|
|
|
584
589
|
/**
|
|
585
590
|
* Entity repository for CRUD operations
|
|
586
591
|
*/
|
|
587
|
-
entityRepository:
|
|
592
|
+
entityRepository: DataRepository;
|
|
588
593
|
|
|
589
594
|
/**
|
|
590
595
|
* Realtime provider for subscriptions
|
|
@@ -692,7 +697,7 @@ export interface BackendBootstrapper {
|
|
|
692
697
|
* Initialize history tables / services if this driver supports them.
|
|
693
698
|
* Return undefined if history is not supported by this backend.
|
|
694
699
|
*/
|
|
695
|
-
initializeHistory?(config:
|
|
700
|
+
initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{ historyService: unknown } | undefined>;
|
|
696
701
|
|
|
697
702
|
/**
|
|
698
703
|
* Create a realtime provider for this driver.
|
package/src/types/builders.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AuthController } from "../controllers/auth";
|
|
2
2
|
import type { RebaseData } from "../controllers/data";
|
|
3
3
|
import type { User } from "../users";
|
|
4
|
-
import type {
|
|
4
|
+
import type { CollectionConfig } from "./collections";
|
|
5
5
|
import type { AppView } from "../controllers/navigation";
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type CollectionConfigsBuilder<EC extends CollectionConfig = CollectionConfig> = (params: {
|
|
8
8
|
user: User | null,
|
|
9
9
|
authController: AuthController,
|
|
10
10
|
data: RebaseData
|