import { initializeMufasa, Num, Str } from "./mufasa/Mufasa"; import { capacitorPersister } from "./mufasa/Plugins/Capacitor"; import { firebasePersister } from "./mufasa/Plugins/Firebase"; import { solidPersister } from "./mufasa/Plugins/SolidJs"; import { initializeApp } from "firebase/app"; import { getFirestore } from "firebase/firestore"; import { getFunctions } from "firebase/functions"; // import { getStorage } from "firebase/storage"; export const firebase = initializeApp({ apiKey: "AIzaSyAHTHxlqG9K2iJ_BunHwKurXNGLIqpIZp0", authDomain: "notos-c6a0b.firebaseapp.com", projectId: "notos-c6a0b", storageBucket: "notos-c6a0b.firebasestorage.app", messagingSenderId: "413234551633", appId: "1:413234551633:web:4d8c9af3841b5d052e5170", measurementId: "G-9DJTTJY3NY", }); export const firestore = getFirestore(firebase); export const firebaseFunctions = getFunctions(firebase, `us-west2`); // export const firebaseStorage = getStorage(firebase); export const mfs = initializeMufasa({ cloud: firebasePersister({ firestore, firebaseFunctions }), storage: capacitorPersister(), reactivity: solidPersister(), }); export type Game = typeof Game.TsType; export const Game = mfs .table({ dbPath: `games`, shouldCacheOffline: true }) .schema((self: () => Game) => ({ name: Str, get players(): Player[] { return Player.allDocs.filter((player) => player.game?.id === self().id); }, })); export type Player = typeof Player.TsType; export const Player = mfs .table({ dbPath: `players`, shouldCacheOffline: true }) .schema((self: () => Player) => ({ name: Str, game: Game, // swapGame(newGame: Game) { // self().game = newGame; // }, // set settableGame(newGame: Game) { // self().game = newGame; // }, })); export const sayHi = mfs .cloudFunction({ path: `sayHi`, }) .implement(() => { return `Hello World!`; }); // export type Product = typeof Product.TsType; // export const Product = mfs // .table({ dbPath: `products` }) // .schema((self: () => Product) => ({ // name: Str.default(``), // rate: Num.default(0), // sortPos: Num, // get bName() { // return `b${self().name}`; // }, // logName() { // console.log(`Product name: ${self().name}`); // }, // })); // export type SubDelivery = typeof SubDelivery.TsType; // export const SubDelivery = mfs // .table({ dbPath: `subDeliveries` }) // .schema((self: () => SubDelivery) => ({ // product: Product, // quantity: Num, // get description() { // return `${self().quantity} of ${self().product?.name}`; // }, // })); // const product = Product.create({ // rate: 0, // sortPos: 0, // });