import EcomClient from '..'; import { Query, CollectionReference, DocumentReference, QuerySnapshot } from './reference'; import { DocumentSnapshot, QueryDocumentSnapshot } from './document'; import { Role } from './types'; export interface UserDocumentData { uid: string priceListID: string role: Role, email: string, firstname: string, lastname: string, created: Date modified: Date } interface NewUser { email: string password: string firstname: string lastname: string } export class UserCollectionReference extends CollectionReference { constructor(client: EcomClient, parent: DocumentReference | null) { super(client, parent); } doc(id: string) : UserDocumentReference { return new UserDocumentReference(this._ecom, id, this); } async add(user: NewUser): Promise { console.log(user); return new UserDocumentReference(this._ecom, '12345', this); } async get() : Promise { return new UserQuerySnapshot(this, []); } } export class UserDocumentReference extends DocumentReference { async set(user: NewUser): Promise { console.log(user); } async get(): Promise { const exampleData: UserDocumentData = { uid: 'some-uid', priceListID: 'some-uuid', role: Role.Customer, email: 'user@example.com', firstname: 'John', lastname: 'Doe', created: new Date(), modified: new Date() }; return new UserDocumentSnapshot(this, exampleData); } async delete(): Promise {} } export class UserDocumentSnapshot extends DocumentSnapshot { } export class UserQuerySnapshot extends QuerySnapshot { constructor(query: Query, docs: Array) { super(query, docs); } }