Skip to content

Commit

Permalink
feat(common-general): add models
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodigioacchino committed Jan 25, 2021
1 parent fcf0083 commit 89c4bb1
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/common/src/UpdatedAt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import fb from "firebase";

export interface UpdatedAt {
updatedAt: fb.firestore.Timestamp | fb.firestore.FieldValue;
}
1 change: 1 addition & 0 deletions packages/common/src/firebaseCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export enum FirebaseCollection {
Games = 'games',
Decks = 'decks',
Cards = 'cards',
RTDBInstances = 'rtdbInstances',
}
15 changes: 14 additions & 1 deletion packages/common/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,18 @@ export interface Game extends CreatedAt {
scenarioContent: string;
scenarioCardId: string | null;
deckId: string;
facilitator: ShortUser,
facilitator: ShortUser;
rtdbInstance: string | null;
cards: { [key: string]: CardState } | null;
boardDimensions: {x: number, y: number} | null;
}

export interface CardState {
parent: 'board'| 'panel';
position?: {
x: number,
y: number
};
lockedBy: string | null;
estimation: string;
}
8 changes: 7 additions & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import {GameRolesDoc} from "./gameRolesDoc";
import {Card, CardTypes, CardTags, CardEntity} from "./card";
import {Game} from "./game";
import {ShortUser} from "./user";
import {RTDBInstance} from "./rtdbInstance";
import {Status} from "./status";
import {RTDBPaths} from "./rtdbPaths";

export {
FirebaseCollection,
RTDBPaths,
FirebaseDoc,
CardTypes,
CardTags
Expand All @@ -19,6 +23,8 @@ export type {
CardEntity,
Card,
Game,
ShortUser
ShortUser,
RTDBInstance,
Status,
};

6 changes: 6 additions & 0 deletions packages/common/src/rtdbInstance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {CreatedAt} from "./CreatedAt";
import {ShortUser} from "./user";

export interface RTDBInstance extends CreatedAt {
onlineOnGameCount: number;
}
4 changes: 4 additions & 0 deletions packages/common/src/rtdbPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum RTDBPaths {
Games = 'games',
Statuses = 'statuses'
}
6 changes: 6 additions & 0 deletions packages/common/src/status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {UpdatedAt} from "./UpdatedAt";

export interface Status extends UpdatedAt {
state: 'offline' | 'online';
gameId: string | null;
}

0 comments on commit 89c4bb1

Please sign in to comment.