@rebasepro/types 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.
- package/README.md +83 -232
- package/dist/controllers/client.d.ts +79 -32
- package/dist/controllers/customization_controller.d.ts +10 -9
- package/dist/index.es.js +249 -197
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +294 -224
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +0 -16
- package/dist/types/auth_adapter.d.ts +59 -4
- package/dist/types/backend.d.ts +36 -1
- package/dist/types/backend_hooks.d.ts +0 -63
- package/dist/types/breadcrumbs.d.ts +26 -0
- package/dist/types/collections.d.ts +162 -1
- package/dist/types/component_overrides.d.ts +138 -0
- package/dist/types/entity_views.d.ts +9 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/plugins.d.ts +0 -5
- package/dist/types/properties.d.ts +0 -8
- package/dist/types/translations.d.ts +3 -0
- package/dist/types/user_management_delegate.d.ts +0 -70
- package/package.json +10 -10
- package/src/controllers/client.ts +85 -33
- package/src/controllers/customization_controller.tsx +11 -11
- package/src/rebase_context.tsx +0 -16
- package/src/types/auth_adapter.ts +70 -4
- package/src/types/backend.ts +39 -1
- package/src/types/backend_hooks.ts +0 -55
- package/src/types/breadcrumbs.ts +27 -0
- package/src/types/collections.ts +172 -2
- package/src/types/component_overrides.ts +177 -0
- package/src/types/database_adapter.ts +1 -1
- package/src/types/entity_views.tsx +10 -1
- package/src/types/index.ts +2 -0
- package/src/types/plugins.tsx +1 -5
- package/src/types/properties.ts +0 -9
- package/src/types/translations.ts +3 -0
- package/src/types/user_management_delegate.ts +0 -77
package/dist/index.es.js
CHANGED
|
@@ -1,222 +1,274 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
//#region src/types/entities.ts
|
|
2
|
+
/**
|
|
3
|
+
* Class used to create a reference to an entity in a different path.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Simple reference (most common case - single driver, single db)
|
|
7
|
+
* new EntityReference({ id: "123", path: "users" })
|
|
8
|
+
*
|
|
9
|
+
* // Reference to a different driver (e.g., Firestore)
|
|
10
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
11
|
+
*
|
|
12
|
+
* // Reference to a specific database within a driver
|
|
13
|
+
* new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
|
|
14
|
+
*/
|
|
15
|
+
var EntityReference = class {
|
|
16
|
+
__type = "reference";
|
|
17
|
+
/**
|
|
18
|
+
* ID of the entity
|
|
19
|
+
*/
|
|
20
|
+
id;
|
|
21
|
+
/**
|
|
22
|
+
* A string representing the path of the referenced document (relative
|
|
23
|
+
* to the root of the database).
|
|
24
|
+
*/
|
|
25
|
+
path;
|
|
26
|
+
/**
|
|
27
|
+
* Which driver (e.g., 'postgres', 'firestore').
|
|
28
|
+
* Defaults to "(default)" if not specified.
|
|
29
|
+
*/
|
|
30
|
+
driver;
|
|
31
|
+
/**
|
|
32
|
+
* Which database within the driver.
|
|
33
|
+
* Defaults to "(default)" if not specified.
|
|
34
|
+
*/
|
|
35
|
+
databaseId;
|
|
36
|
+
/**
|
|
37
|
+
* Create a reference to an entity.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Simple reference (most common case)
|
|
41
|
+
* new EntityReference({ id: "123", path: "users" })
|
|
42
|
+
*
|
|
43
|
+
* // With driver
|
|
44
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
45
|
+
*/
|
|
46
|
+
constructor(props) {
|
|
47
|
+
this.id = props.id;
|
|
48
|
+
this.path = props.path;
|
|
49
|
+
this.driver = props.driver;
|
|
50
|
+
this.databaseId = props.databaseId;
|
|
51
|
+
}
|
|
52
|
+
get pathWithId() {
|
|
53
|
+
return `${this.path}/${this.id}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the full path including driver and database prefixes if specified.
|
|
57
|
+
* For the common case (single driver, single db), this just returns pathWithId.
|
|
58
|
+
*/
|
|
59
|
+
get fullPath() {
|
|
60
|
+
const parts = [];
|
|
61
|
+
if (this.driver && this.driver !== "(default)") parts.push(this.driver);
|
|
62
|
+
if (this.databaseId && this.databaseId !== "(default)") parts.push(this.databaseId);
|
|
63
|
+
if (parts.length > 0) return `${parts.join(":")}:::${this.path}/${this.id}`;
|
|
64
|
+
return this.pathWithId;
|
|
65
|
+
}
|
|
66
|
+
isEntityReference() {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Class used to create a reference to an entity in a different path
|
|
72
|
+
*/
|
|
73
|
+
var EntityRelation = class {
|
|
74
|
+
__type = "relation";
|
|
75
|
+
/**
|
|
76
|
+
* ID of the entity
|
|
77
|
+
*/
|
|
78
|
+
id;
|
|
79
|
+
/**
|
|
80
|
+
* A string representing the path of the referenced document (relative
|
|
81
|
+
* to the root of the database).
|
|
82
|
+
*/
|
|
83
|
+
path;
|
|
84
|
+
/**
|
|
85
|
+
* Pre-fetched data payload to eliminate N+1 queries.
|
|
86
|
+
* When present, clients can use this directly instead of fetching.
|
|
87
|
+
*/
|
|
88
|
+
data;
|
|
89
|
+
constructor(id, path, data) {
|
|
90
|
+
this.id = id;
|
|
91
|
+
this.path = path;
|
|
92
|
+
this.data = data;
|
|
93
|
+
}
|
|
94
|
+
get pathWithId() {
|
|
95
|
+
return `${this.path}/${this.id}`;
|
|
96
|
+
}
|
|
97
|
+
isEntityReference() {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
isEntityRelation() {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var GeoPoint = class {
|
|
105
|
+
/**
|
|
106
|
+
* The latitude of this GeoPoint instance.
|
|
107
|
+
*/
|
|
108
|
+
latitude;
|
|
109
|
+
/**
|
|
110
|
+
* The longitude of this GeoPoint instance.
|
|
111
|
+
*/
|
|
112
|
+
longitude;
|
|
113
|
+
constructor(latitude, longitude) {
|
|
114
|
+
this.latitude = latitude;
|
|
115
|
+
this.longitude = longitude;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var Vector = class {
|
|
119
|
+
value;
|
|
120
|
+
constructor(value) {
|
|
121
|
+
this.value = value;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/types/collections.ts
|
|
126
|
+
/**
|
|
127
|
+
* Type guard for PostgreSQL collections.
|
|
128
|
+
* Returns true if the collection uses the Postgres driver (or the default driver).
|
|
129
|
+
* @group Models
|
|
130
|
+
*/
|
|
113
131
|
function isPostgresCollection(collection) {
|
|
114
|
-
|
|
132
|
+
return !collection.driver || collection.driver === "postgres";
|
|
115
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Type guard for Firebase / Firestore collections.
|
|
136
|
+
* @group Models
|
|
137
|
+
*/
|
|
116
138
|
function isFirebaseCollection(collection) {
|
|
117
|
-
|
|
139
|
+
return collection.driver === "firestore";
|
|
118
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Type guard for MongoDB collections.
|
|
143
|
+
* @group Models
|
|
144
|
+
*/
|
|
119
145
|
function isMongoDBCollection(collection) {
|
|
120
|
-
|
|
146
|
+
return collection.driver === "mongodb";
|
|
121
147
|
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/types/backend.ts
|
|
150
|
+
/**
|
|
151
|
+
* Type guard: does this admin support SQL operations?
|
|
152
|
+
* @group Admin
|
|
153
|
+
*/
|
|
122
154
|
function isSQLAdmin(admin) {
|
|
123
|
-
|
|
155
|
+
return !!admin && typeof admin.executeSql === "function";
|
|
124
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Type guard: does this admin support document operations?
|
|
159
|
+
* @group Admin
|
|
160
|
+
*/
|
|
125
161
|
function isDocumentAdmin(admin) {
|
|
126
|
-
|
|
162
|
+
return !!admin && (typeof admin.executeAggregate === "function" || typeof admin.fetchCollectionStats === "function");
|
|
127
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Type guard: does this admin support schema management?
|
|
166
|
+
* @group Admin
|
|
167
|
+
*/
|
|
128
168
|
function isSchemaAdmin(admin) {
|
|
129
|
-
|
|
169
|
+
return !!admin && (typeof admin.fetchUnmappedTables === "function" || typeof admin.fetchTableMetadata === "function");
|
|
130
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Type guard: does this admin support database branching?
|
|
173
|
+
* @group Admin
|
|
174
|
+
*/
|
|
131
175
|
function isBranchAdmin(admin) {
|
|
132
|
-
|
|
176
|
+
return !!admin && typeof admin.createBranch === "function";
|
|
133
177
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/types/data_source.ts
|
|
180
|
+
/** @group Models */
|
|
181
|
+
var POSTGRES_CAPABILITIES = {
|
|
182
|
+
key: "postgres",
|
|
183
|
+
label: "PostgreSQL",
|
|
184
|
+
supportsRelations: true,
|
|
185
|
+
supportsSubcollections: false,
|
|
186
|
+
supportsRLS: true,
|
|
187
|
+
supportsReferences: false,
|
|
188
|
+
supportsColumnTypes: true,
|
|
189
|
+
supportsRealtime: true,
|
|
190
|
+
supportsSQLAdmin: true,
|
|
191
|
+
supportsDocumentAdmin: false,
|
|
192
|
+
supportsSchemaAdmin: true
|
|
146
193
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
194
|
+
/** @group Models */
|
|
195
|
+
var FIREBASE_CAPABILITIES = {
|
|
196
|
+
key: "firestore",
|
|
197
|
+
label: "Firebase / Firestore",
|
|
198
|
+
supportsRelations: false,
|
|
199
|
+
supportsSubcollections: true,
|
|
200
|
+
supportsRLS: false,
|
|
201
|
+
supportsReferences: true,
|
|
202
|
+
supportsColumnTypes: false,
|
|
203
|
+
supportsRealtime: true,
|
|
204
|
+
supportsSQLAdmin: false,
|
|
205
|
+
supportsDocumentAdmin: false,
|
|
206
|
+
supportsSchemaAdmin: false
|
|
159
207
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
208
|
+
/** @group Models */
|
|
209
|
+
var MONGODB_CAPABILITIES = {
|
|
210
|
+
key: "mongodb",
|
|
211
|
+
label: "MongoDB",
|
|
212
|
+
supportsRelations: false,
|
|
213
|
+
supportsSubcollections: true,
|
|
214
|
+
supportsRLS: false,
|
|
215
|
+
supportsReferences: true,
|
|
216
|
+
supportsColumnTypes: false,
|
|
217
|
+
supportsRealtime: false,
|
|
218
|
+
supportsSQLAdmin: false,
|
|
219
|
+
supportsDocumentAdmin: true,
|
|
220
|
+
supportsSchemaAdmin: true
|
|
172
221
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Fallback capabilities when the driver is unknown.
|
|
224
|
+
* Enables everything so nothing is hidden unexpectedly.
|
|
225
|
+
* @group Models
|
|
226
|
+
*/
|
|
227
|
+
var DEFAULT_CAPABILITIES = {
|
|
228
|
+
key: "(default)",
|
|
229
|
+
label: "Default",
|
|
230
|
+
supportsRelations: true,
|
|
231
|
+
supportsSubcollections: true,
|
|
232
|
+
supportsRLS: true,
|
|
233
|
+
supportsReferences: true,
|
|
234
|
+
supportsColumnTypes: true,
|
|
235
|
+
supportsRealtime: true,
|
|
236
|
+
supportsSQLAdmin: true,
|
|
237
|
+
supportsDocumentAdmin: true,
|
|
238
|
+
supportsSchemaAdmin: true
|
|
185
239
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
240
|
+
var CAPABILITIES_REGISTRY = {
|
|
241
|
+
postgres: POSTGRES_CAPABILITIES,
|
|
242
|
+
firestore: FIREBASE_CAPABILITIES,
|
|
243
|
+
mongodb: MONGODB_CAPABILITIES,
|
|
244
|
+
"(default)": DEFAULT_CAPABILITIES
|
|
191
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Look up capabilities for a given driver key.
|
|
248
|
+
* If `driver` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
249
|
+
* @group Models
|
|
250
|
+
*/
|
|
192
251
|
function getDataSourceCapabilities(driver) {
|
|
193
|
-
|
|
194
|
-
|
|
252
|
+
if (!driver) return POSTGRES_CAPABILITIES;
|
|
253
|
+
return CAPABILITIES_REGISTRY[driver] ?? DEFAULT_CAPABILITIES;
|
|
195
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Register custom capabilities for a third-party driver.
|
|
257
|
+
* @group Models
|
|
258
|
+
*/
|
|
196
259
|
function registerDataSourceCapabilities(capabilities) {
|
|
197
|
-
|
|
260
|
+
CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
|
|
198
261
|
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/types/component_ref.ts
|
|
264
|
+
/**
|
|
265
|
+
* Type guard: checks if a value is a `LazyComponentRef` produced by the
|
|
266
|
+
* Vite transform plugin.
|
|
267
|
+
*/
|
|
199
268
|
function isLazyComponentRef(ref) {
|
|
200
|
-
|
|
269
|
+
return typeof ref === "object" && ref !== null && "__rebaseLazy" in ref && ref.__rebaseLazy === true;
|
|
201
270
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
FIREBASE_CAPABILITIES,
|
|
207
|
-
GeoPoint,
|
|
208
|
-
MONGODB_CAPABILITIES,
|
|
209
|
-
POSTGRES_CAPABILITIES,
|
|
210
|
-
Vector,
|
|
211
|
-
getDataSourceCapabilities,
|
|
212
|
-
isBranchAdmin,
|
|
213
|
-
isDocumentAdmin,
|
|
214
|
-
isFirebaseCollection,
|
|
215
|
-
isLazyComponentRef,
|
|
216
|
-
isMongoDBCollection,
|
|
217
|
-
isPostgresCollection,
|
|
218
|
-
isSQLAdmin,
|
|
219
|
-
isSchemaAdmin,
|
|
220
|
-
registerDataSourceCapabilities
|
|
221
|
-
};
|
|
222
|
-
//# sourceMappingURL=index.es.js.map
|
|
271
|
+
//#endregion
|
|
272
|
+
export { DEFAULT_CAPABILITIES, EntityReference, EntityRelation, FIREBASE_CAPABILITIES, GeoPoint, MONGODB_CAPABILITIES, POSTGRES_CAPABILITIES, Vector, getDataSourceCapabilities, isBranchAdmin, isDocumentAdmin, isFirebaseCollection, isLazyComponentRef, isMongoDBCollection, isPostgresCollection, isSQLAdmin, isSchemaAdmin, registerDataSourceCapabilities };
|
|
273
|
+
|
|
274
|
+
//# sourceMappingURL=index.es.js.map
|