@rebasepro/firebase 0.12.1-canary.g389e9b2 → 0.12.1-canary.g4e7bcbf
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.
|
@@ -53,5 +53,5 @@ export declare function useFirestoreDriver({ firebaseApp, textSearchControllerBu
|
|
|
53
53
|
* @param data
|
|
54
54
|
* @group Firestore
|
|
55
55
|
*/
|
|
56
|
-
export declare function
|
|
57
|
-
export declare function
|
|
56
|
+
export declare function firestoreToRebaseModel(data: unknown): unknown;
|
|
57
|
+
export declare function rebaseToFirestoreModel(data: unknown, firestore: Firestore, inArray?: boolean): unknown;
|
package/dist/index.es.js
CHANGED
|
@@ -980,7 +980,7 @@ function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestor
|
|
|
980
980
|
return;
|
|
981
981
|
}
|
|
982
982
|
if (op === "like" || op === "ilike" || op === "not-like" || op === "not-ilike") throw new Error(`Firestore does not support the "${op}" operator (SQL pattern matching). Use a full-text search index or the collection's searchString instead.`);
|
|
983
|
-
queryParams.push(where(key, op,
|
|
983
|
+
queryParams.push(where(key, op, rebaseToFirestoreModel(value, firestore)));
|
|
984
984
|
});
|
|
985
985
|
if (orderBy$1 && order) queryParams.push(orderBy(orderBy$1, order));
|
|
986
986
|
if (startAfter$1) queryParams.push(startAfter(startAfter$1));
|
|
@@ -1168,7 +1168,7 @@ function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestor
|
|
|
1168
1168
|
values: valuesProp,
|
|
1169
1169
|
collection: collection$1
|
|
1170
1170
|
});
|
|
1171
|
-
const values =
|
|
1171
|
+
const values = rebaseToFirestoreModel(valuesProp, getFirestore(firebaseApp));
|
|
1172
1172
|
console.debug("2", {
|
|
1173
1173
|
path,
|
|
1174
1174
|
id,
|
|
@@ -1188,7 +1188,7 @@ function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestor
|
|
|
1188
1188
|
else documentReference = doc(collectionReference);
|
|
1189
1189
|
return setDoc(documentReference, values, { merge: true }).then(() => {
|
|
1190
1190
|
return {
|
|
1191
|
-
...
|
|
1191
|
+
...firestoreToRebaseModel(values),
|
|
1192
1192
|
id: documentReference.id
|
|
1193
1193
|
};
|
|
1194
1194
|
}).catch((error) => {
|
|
@@ -1222,7 +1222,7 @@ function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestor
|
|
|
1222
1222
|
const databaseId = collection$2?.databaseId;
|
|
1223
1223
|
const firestore = databaseId ? getFirestore(firebaseApp, databaseId) : getFirestore(firebaseApp);
|
|
1224
1224
|
if (value === void 0 || value === null) return Promise.resolve(true);
|
|
1225
|
-
return (await getDocs(query(collection(firestore, path), where(name, "==",
|
|
1225
|
+
return (await getDocs(query(collection(firestore, path), where(name, "==", rebaseToFirestoreModel(value, firestore))))).docs.filter((doc) => doc.id !== id).length === 0;
|
|
1226
1226
|
}, [firebaseApp]);
|
|
1227
1227
|
const count = useCallback(async ({ path, filter, order, orderBy, collection }) => {
|
|
1228
1228
|
if (!firebaseApp) throw Error("useFirestoreDriver Firebase not initialised");
|
|
@@ -1276,7 +1276,7 @@ function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestor
|
|
|
1276
1276
|
}
|
|
1277
1277
|
var createRowFromDocument = (docSnap) => {
|
|
1278
1278
|
return {
|
|
1279
|
-
...
|
|
1279
|
+
...firestoreToRebaseModel(docSnap.data()),
|
|
1280
1280
|
id: docSnap.id
|
|
1281
1281
|
};
|
|
1282
1282
|
};
|
|
@@ -1290,7 +1290,7 @@ var createRowFromDocument = (docSnap) => {
|
|
|
1290
1290
|
* @param data
|
|
1291
1291
|
* @group Firestore
|
|
1292
1292
|
*/
|
|
1293
|
-
function
|
|
1293
|
+
function firestoreToRebaseModel(data) {
|
|
1294
1294
|
if (data === null || data === void 0) return null;
|
|
1295
1295
|
if (typeof data === "object" && data !== null && "isEqual" in data && typeof data.isEqual === "function" && deleteField().isEqual(data)) return;
|
|
1296
1296
|
if (typeof data === "object" && data !== null && "isEqual" in data && typeof data.isEqual === "function" && serverTimestamp().isEqual(data)) return null;
|
|
@@ -1310,11 +1310,11 @@ function firestoreToCMSModel(data) {
|
|
|
1310
1310
|
databaseId
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
|
-
if (Array.isArray(data)) return data.map(
|
|
1313
|
+
if (Array.isArray(data)) return data.map(firestoreToRebaseModel).filter((v) => v !== void 0);
|
|
1314
1314
|
if (typeof data === "object") {
|
|
1315
1315
|
const result = {};
|
|
1316
1316
|
for (const key of Object.keys(data)) {
|
|
1317
|
-
const childValue =
|
|
1317
|
+
const childValue = firestoreToRebaseModel(data[key]);
|
|
1318
1318
|
if (childValue !== void 0) result[key] = childValue;
|
|
1319
1319
|
}
|
|
1320
1320
|
return result;
|
|
@@ -1330,10 +1330,10 @@ function getCMSPathFromFirestorePath(fsPath) {
|
|
|
1330
1330
|
to = to === -1 ? fsPath.length : to;
|
|
1331
1331
|
return fsPath.substring(0, to);
|
|
1332
1332
|
}
|
|
1333
|
-
function
|
|
1333
|
+
function rebaseToFirestoreModel(data, firestore, inArray = false) {
|
|
1334
1334
|
if (data === void 0) return deleteField();
|
|
1335
1335
|
else if (data === null) return null;
|
|
1336
|
-
else if (Array.isArray(data)) return data.filter((v) => v !== void 0).map((v) =>
|
|
1336
|
+
else if (Array.isArray(data)) return data.filter((v) => v !== void 0).map((v) => rebaseToFirestoreModel(v, firestore, true));
|
|
1337
1337
|
else if (typeof data === "object" && data !== null && "isEntityReference" in data && typeof data.isEntityReference === "function" && data.isEntityReference()) {
|
|
1338
1338
|
const entityRef = data;
|
|
1339
1339
|
return doc(entityRef.databaseId ? getFirestore(firestore.app, entityRef.databaseId) : firestore, entityRef.path, entityRef.id);
|
|
@@ -1344,7 +1344,7 @@ function cmsToFirestoreModel(data, firestore, inArray = false) {
|
|
|
1344
1344
|
else if (data instanceof Date) return Timestamp.fromDate(data);
|
|
1345
1345
|
else if (data && typeof data === "object" && "__type__" in data && data.__type__ === "__vector__") return vector(data.value || []);
|
|
1346
1346
|
else if (data && typeof data === "object") return Object.entries(data).map(([key, v]) => {
|
|
1347
|
-
const firestoreModel =
|
|
1347
|
+
const firestoreModel = rebaseToFirestoreModel(v, firestore);
|
|
1348
1348
|
if (firestoreModel !== void 0) return { [key]: firestoreModel };
|
|
1349
1349
|
else return {};
|
|
1350
1350
|
}).reduce((a, b) => ({
|
|
@@ -2649,6 +2649,6 @@ function RebaseFirebaseApp({ name, logo, logoDark, accessGate, collections, view
|
|
|
2649
2649
|
}) });
|
|
2650
2650
|
}
|
|
2651
2651
|
//#endregion
|
|
2652
|
-
export { FirebaseLoginView, LoginButton, RECAPTCHA_CONTAINER_ID, RebaseFirebaseApp, buildCollectionId, buildExternalSearchController, buildPineconeSearchController, buildRebaseSearchController,
|
|
2652
|
+
export { FirebaseLoginView, LoginButton, RECAPTCHA_CONTAINER_ID, RebaseFirebaseApp, buildCollectionId, buildExternalSearchController, buildPineconeSearchController, buildRebaseSearchController, docToCollection, docsToCollectionTree, firestoreToRebaseModel, getFirestoreDataInPath, localSearchControllerBuilder, performAlgoliaTextSearch, performPineconeTextSearch, rebaseToFirestoreModel, useAppCheck, useBuildUserManagement, useFirebaseAccessGate, useFirebaseAuthController, useFirebaseRTDBDelegate, useFirebaseStorageSource, useFirestoreDriver, useInitialiseFirebase, useRecaptcha };
|
|
2653
2653
|
|
|
2654
2654
|
//# sourceMappingURL=index.es.js.map
|