@sparted/shared-library 1.7.79 → 1.7.81
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/business/campaign/live-campaign.js +1 -1
- package/business/campaign/live-campaign.js.map +1 -1
- package/business/types/campaign.d.ts +9 -1
- package/business/types/campaign.js.map +1 -1
- package/business/types/score.d.ts +4 -0
- package/business/types/score.js.map +1 -1
- package/date/get-start-of-day.d.ts +1 -0
- package/date/get-start-of-day.js +12 -0
- package/date/get-start-of-day.js.map +1 -0
- package/date/index.d.ts +2 -0
- package/date/index.js +4 -0
- package/date/index.js.map +1 -1
- package/date/to-utc-date-string.d.ts +1 -0
- package/date/to-utc-date-string.js +10 -0
- package/date/to-utc-date-string.js.map +1 -0
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -41,7 +41,7 @@ const computeCurrentSession = (card, forceComputeCalendar) => {
|
|
|
41
41
|
if (currentSession === -1) {
|
|
42
42
|
throw new Error('Current session not found');
|
|
43
43
|
}
|
|
44
|
-
return currentSession + 1;
|
|
44
|
+
return Math.min(currentSession + 1, details.sessionCount);
|
|
45
45
|
};
|
|
46
46
|
const checkTodayPlayable = (card) => {
|
|
47
47
|
const today = new Date();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-campaign.js","sources":["../../../src/business/campaign/live-campaign.ts"],"sourcesContent":["import { addDays, isSameDate } from '../../date';\nimport { CampaignDetails, LiveCampaign } from '../types';\n\nexport const computeIntenseCalendar = (card: LiveCampaign): Date[] => {\n const { details } = card;\n\n const startDate = new Date(details.utcStartDate);\n const endDate = new Date(details.utcEndDate);\n\n const calculateIntenseCalendarAux = (date: Date, calendar: Date[]): Date[] => {\n if (date > endDate) {\n return calendar;\n }\n\n const jsDay = date.getDay();\n const day = jsDay === 0 ? 7 : jsDay;\n\n if (details.enabledWeekDays.includes(day) && !details.disabledDates.includes(date.toISOString().slice(0, 10))) {\n calendar.push(new Date(date));\n }\n\n date.setDate(date.getDate() + 1);\n\n return calculateIntenseCalendarAux(date, calendar);\n };\n\n return calculateIntenseCalendarAux(startDate, []);\n};\n\nexport const computeCurrentSession = (card: LiveCampaign, forceComputeCalendar?: boolean): number => {\n const { details, achievement } = card;\n\n if (details.type === 'flexible' && !forceComputeCalendar) {\n return Math.min(achievement.lastSessionPlayed + 1, details.sessionCount);\n }\n\n const today = new Date();\n\n if (today <= new Date(details.utcStartDate)) {\n return 1;\n }\n\n if (today >= new Date(details.utcEndDate)) {\n return details.sessionCount;\n }\n\n const calendar = computeIntenseCalendar(card);\n\n const todayDate = today.toISOString().slice(0, 10);\n const currentSession = calendar.findIndex((date) => date.toISOString().slice(0, 10) >= todayDate);\n\n if (currentSession === -1) {\n throw new Error('Current session not found');\n }\n\n return currentSession + 1;\n};\n\nexport const checkTodayPlayable = (card: LiveCampaign): boolean => {\n const today = new Date();\n\n const { details } = card;\n\n const startDate = new Date(details.utcStartDate);\n const endDate = new Date(details.utcEndDate);\n\n if (today < startDate || today > endDate) {\n return false;\n }\n\n const jsDay = today.getDay();\n const day = jsDay === 0 ? 7 : jsDay;\n\n if (!details.enabledWeekDays.includes(day)) {\n return false;\n }\n\n if (details.disabledDates.includes(today.toISOString().slice(0, 10))) {\n return false;\n }\n\n return true;\n};\n\nexport const findNextAvailableDate = (\n currentDate: Date,\n enabledWeekDays: number[],\n disabledDates: Date[],\n): Date | null => {\n if (enabledWeekDays.length === 0) return null;\n const dayofDate = currentDate.getDay();\n const isEnabledDay = enabledWeekDays.includes(dayofDate === 0 ? 7 : dayofDate);\n const isDisabledDate = disabledDates.some((d) => isSameDate(d, currentDate));\n\n if (isEnabledDay && !isDisabledDate) {\n return currentDate;\n }\n\n return findNextAvailableDate(addDays(currentDate, 1), enabledWeekDays, disabledDates);\n};\n\ntype GetCalendarSessionDatesFromCampaignProps = Pick<\n CampaignDetails,\n 'launchDate' | 'enabledWeekDays' | 'disabledDates' | 'nbSessions'\n> & {\n extraDays?: number;\n};\n\nexport const getCalendarSessionDatesFromCampaign = ({\n launchDate,\n enabledWeekDays,\n disabledDates,\n nbSessions,\n extraDays = 0,\n}: GetCalendarSessionDatesFromCampaignProps): Record<number, Date> => {\n const sessionCount = nbSessions + extraDays;\n\n const calendarDatesBySession = Array.from({ length: sessionCount }).reduce((acc: Record<number, Date>, _, index) => {\n const session = index + 1;\n const lastDate = session > 1 ? addDays(new Date(acc[session - 1]), 1) : new Date(launchDate);\n\n const nextSessionDate = findNextAvailableDate(lastDate, enabledWeekDays, disabledDates);\n\n if (!nextSessionDate) return acc;\n\n return {\n ...acc,\n [session]: nextSessionDate,\n };\n }, {});\n\n return calendarDatesBySession;\n};\n"],"names":["isSameDate","addDays"],"mappings":";;;;;;;AAGa,MAAA,sBAAsB,GAAG,CAAC,IAAkB,KAAY;AACnE,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE7C,IAAA,MAAM,2BAA2B,GAAG,CAAC,IAAU,EAAE,QAAgB,KAAY;QAC3E,IAAI,IAAI,GAAG,OAAO,EAAE;AAClB,YAAA,OAAO,QAAQ,CAAC;AACjB,SAAA;AAED,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAC5B,QAAA,MAAM,GAAG,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEpC,QAAA,IAAI,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;YAC7G,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,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K,CAAC,CAAC,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC9C,KAAA;
|
|
1
|
+
{"version":3,"file":"live-campaign.js","sources":["../../../src/business/campaign/live-campaign.ts"],"sourcesContent":["import { addDays, isSameDate } from '../../date';\nimport { CampaignDetails, LiveCampaign } from '../types';\n\nexport const computeIntenseCalendar = (card: LiveCampaign): Date[] => {\n const { details } = card;\n\n const startDate = new Date(details.utcStartDate);\n const endDate = new Date(details.utcEndDate);\n\n const calculateIntenseCalendarAux = (date: Date, calendar: Date[]): Date[] => {\n if (date > endDate) {\n return calendar;\n }\n\n const jsDay = date.getDay();\n const day = jsDay === 0 ? 7 : jsDay;\n\n if (details.enabledWeekDays.includes(day) && !details.disabledDates.includes(date.toISOString().slice(0, 10))) {\n calendar.push(new Date(date));\n }\n\n date.setDate(date.getDate() + 1);\n\n return calculateIntenseCalendarAux(date, calendar);\n };\n\n return calculateIntenseCalendarAux(startDate, []);\n};\n\nexport const computeCurrentSession = (card: LiveCampaign, forceComputeCalendar?: boolean): number => {\n const { details, achievement } = card;\n\n if (details.type === 'flexible' && !forceComputeCalendar) {\n return Math.min(achievement.lastSessionPlayed + 1, details.sessionCount);\n }\n\n const today = new Date();\n\n if (today <= new Date(details.utcStartDate)) {\n return 1;\n }\n\n if (today >= new Date(details.utcEndDate)) {\n return details.sessionCount;\n }\n\n const calendar = computeIntenseCalendar(card);\n\n const todayDate = today.toISOString().slice(0, 10);\n const currentSession = calendar.findIndex((date) => date.toISOString().slice(0, 10) >= todayDate);\n\n if (currentSession === -1) {\n throw new Error('Current session not found');\n }\n\n return Math.min(currentSession + 1, details.sessionCount);\n};\n\nexport const checkTodayPlayable = (card: LiveCampaign): boolean => {\n const today = new Date();\n\n const { details } = card;\n\n const startDate = new Date(details.utcStartDate);\n const endDate = new Date(details.utcEndDate);\n\n if (today < startDate || today > endDate) {\n return false;\n }\n\n const jsDay = today.getDay();\n const day = jsDay === 0 ? 7 : jsDay;\n\n if (!details.enabledWeekDays.includes(day)) {\n return false;\n }\n\n if (details.disabledDates.includes(today.toISOString().slice(0, 10))) {\n return false;\n }\n\n return true;\n};\n\nexport const findNextAvailableDate = (\n currentDate: Date,\n enabledWeekDays: number[],\n disabledDates: Date[],\n): Date | null => {\n if (enabledWeekDays.length === 0) return null;\n const dayofDate = currentDate.getDay();\n const isEnabledDay = enabledWeekDays.includes(dayofDate === 0 ? 7 : dayofDate);\n const isDisabledDate = disabledDates.some((d) => isSameDate(d, currentDate));\n\n if (isEnabledDay && !isDisabledDate) {\n return currentDate;\n }\n\n return findNextAvailableDate(addDays(currentDate, 1), enabledWeekDays, disabledDates);\n};\n\ntype GetCalendarSessionDatesFromCampaignProps = Pick<\n CampaignDetails,\n 'launchDate' | 'enabledWeekDays' | 'disabledDates' | 'nbSessions'\n> & {\n extraDays?: number;\n};\n\nexport const getCalendarSessionDatesFromCampaign = ({\n launchDate,\n enabledWeekDays,\n disabledDates,\n nbSessions,\n extraDays = 0,\n}: GetCalendarSessionDatesFromCampaignProps): Record<number, Date> => {\n const sessionCount = nbSessions + extraDays;\n\n const calendarDatesBySession = Array.from({ length: sessionCount }).reduce((acc: Record<number, Date>, _, index) => {\n const session = index + 1;\n const lastDate = session > 1 ? addDays(new Date(acc[session - 1]), 1) : new Date(launchDate);\n\n const nextSessionDate = findNextAvailableDate(lastDate, enabledWeekDays, disabledDates);\n\n if (!nextSessionDate) return acc;\n\n return {\n ...acc,\n [session]: nextSessionDate,\n };\n }, {});\n\n return calendarDatesBySession;\n};\n"],"names":["isSameDate","addDays"],"mappings":";;;;;;;AAGa,MAAA,sBAAsB,GAAG,CAAC,IAAkB,KAAY;AACnE,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU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CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAyB,EAAE,CAAC,EAAE,KAAK,KAAI;AACjH,QAAA,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC;AAC1B,QAAA,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,GAAGA,eAAO,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;QAE7F,MAAM,eAAe,GAAG,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;AAExF,QAAA,IAAI,CAAC,eAAe;AAAE,YAAA,OAAO,GAAG,CAAC;AAEjC,QAAA,OAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACK,GAAG,CACN,EAAA,EAAA,CAAC,OAAO,GAAG,eAAe,EAC1B,CAAA,CAAA;KACH,EAAE,EAAE,CAAC,CAAC;AAEP,IAAA,OAAO,sBAAsB,CAAC;AAChC;;;;;;;;"}
|
|
@@ -4,7 +4,7 @@ import type { Content, GameType } from './content';
|
|
|
4
4
|
import type { Image } from './media';
|
|
5
5
|
import type { MultilingualLabel } from './multilingual';
|
|
6
6
|
import type { PlayerProfile, PlayerWithParticipation } from './player';
|
|
7
|
-
import type { Points, Stars } from './score';
|
|
7
|
+
import type { Points, Stars, Streaks } from './score';
|
|
8
8
|
export type WithCampaignContentId<T> = T & {
|
|
9
9
|
campaignContentId: number;
|
|
10
10
|
};
|
|
@@ -50,6 +50,7 @@ export type BaseCampaignCardDetails = {
|
|
|
50
50
|
utcEndDate: string;
|
|
51
51
|
contentCount: number;
|
|
52
52
|
isRandom: boolean;
|
|
53
|
+
playableDays?: Date[];
|
|
53
54
|
};
|
|
54
55
|
export type WikiCardDetails = BaseCampaignCardDetails;
|
|
55
56
|
export type WikiCardPlayerInteraction = {
|
|
@@ -85,16 +86,23 @@ export type LiveCampaignAchievement = {
|
|
|
85
86
|
lastPlayedAt: string;
|
|
86
87
|
stars: Stars;
|
|
87
88
|
points: Points;
|
|
89
|
+
streaks: Streaks;
|
|
88
90
|
};
|
|
89
91
|
export type SessionInsight = {
|
|
90
92
|
sessionNumber: number;
|
|
91
93
|
gameTypes: GameType[];
|
|
92
94
|
};
|
|
95
|
+
export type StreakSession = {
|
|
96
|
+
day: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
97
|
+
status: CalendarStatus;
|
|
98
|
+
streakCount?: number;
|
|
99
|
+
};
|
|
93
100
|
export type LiveCampaign = {
|
|
94
101
|
details: LiveCampaignDetails;
|
|
95
102
|
achievement: LiveCampaignAchievement;
|
|
96
103
|
sessionInsights: SessionInsight[];
|
|
97
104
|
leaderPlayer?: PlayerProfile;
|
|
105
|
+
streakSessions: StreakSession[];
|
|
98
106
|
};
|
|
99
107
|
export type CalendarStatus = 'played' | 'playable' | 'pending' | 'missed';
|
|
100
108
|
export type Calendar = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"campaign.js","sources":["../../../src/business/types/campaign.ts"],"sourcesContent":["import type { CampaignStats } from './achievement';\nimport { ActivityStatus } from './activity';\nimport type { Content, GameType } from './content';\nimport type { Image } from './media';\nimport type { MultilingualLabel } from './multilingual';\nimport type { PlayerProfile, PlayerWithParticipation } from './player';\nimport type { Points, Stars } from './score';\n\nexport type WithCampaignContentId<T> = T & { campaignContentId: number };\n\nexport type CampaignInformations = {\n coverImage: Image;\n name: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n lastSave: Date;\n};\n\nexport type BaseCampaignScheduling = {\n type: 'flexible' | 'intense';\n launchDate: string;\n endDate?: string;\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n};\n\nexport type ManualCampaignScheduling = BaseCampaignScheduling & {\n mode: 'manual';\n orderedSessions: Content[][];\n};\n\nexport type RandomCampaignScheduling = BaseCampaignScheduling & {\n mode: 'random';\n nbSessions: number;\n contents: Content[];\n};\n\nexport type CampaignScheduling = ManualCampaignScheduling | RandomCampaignScheduling;\n\nexport type Campaign = {\n id: number;\n informations: CampaignInformations;\n scheduling: CampaignScheduling;\n type: 'campaign';\n};\n\nexport type BaseCampaignCardDetails = {\n id: number;\n status: ActivityStatus;\n cover: string;\n title: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n utcStartDate: string;\n utcEndDate: string;\n contentCount: number;\n isRandom: boolean;\n};\n\nexport type WikiCardDetails = BaseCampaignCardDetails;\n\nexport type WikiCardPlayerInteraction = {\n contentPlayedIds: number[];\n favorite: boolean;\n};\n\nexport type WikiCard = {\n details: WikiCardDetails;\n playerInteraction: WikiCardPlayerInteraction;\n};\n\nexport type WikiContentCardDetails = {\n id: number;\n campaignContentId: number;\n coverImage: string;\n title: MultilingualLabel;\n explanation?: MultilingualLabel;\n session: number;\n};\n\nexport type WikiContentCard = {\n contentDetails: WikiContentCardDetails;\n points: Points;\n};\n\nexport type LiveCampaignScheduling = {\n type: 'flexible' | 'intense';\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n sessionCount: number;\n};\n\nexport type LiveCampaignDetails = BaseCampaignCardDetails & LiveCampaignScheduling;\n\nexport type LiveCampaignAchievement = {\n lastSessionPlayed: number;\n lastPlayedAt: string;\n stars: Stars;\n points: Points;\n};\n\nexport type SessionInsight = {\n sessionNumber: number;\n gameTypes: GameType[];\n};\n\nexport type LiveCampaign = {\n details: LiveCampaignDetails;\n achievement: LiveCampaignAchievement;\n sessionInsights: SessionInsight[];\n leaderPlayer?: PlayerProfile;\n};\n\nexport type CalendarStatus = 'played' | 'playable' | 'pending' | 'missed';\n\nexport type Calendar = {\n order: number;\n status: CalendarStatus;\n date: Date;\n};\n\nexport type CampaignDetails = {\n id: number;\n coverImage?: Image;\n name: MultilingualLabel;\n mode: 'manual' | 'random';\n launchDate: string;\n endDate: string;\n enabledWeekDays: number[];\n disabledDates: Date[];\n lastNotificationDate: Date;\n nbPlayers: number;\n nbSessions: number;\n nbQuestions: number;\n players: PlayerWithParticipation[];\n stats: CampaignStats;\n};\n\nexport const isCampaignSchedulingRandom = (scheduling: CampaignScheduling): scheduling is RandomCampaignScheduling =>\n scheduling.mode === 'random';\n\nexport const isCampaignSchedulingManual = (scheduling: CampaignScheduling): scheduling is ManualCampaignScheduling =>\n scheduling.mode === 'manual';\n\nexport const isWikiCard = (item: unknown): item is WikiCard =>\n typeof item === 'object' && item !== null && 'details' in item && 'playerInteraction' in item;\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"campaign.js","sources":["../../../src/business/types/campaign.ts"],"sourcesContent":["import type { CampaignStats } from './achievement';\nimport { ActivityStatus } from './activity';\nimport type { Content, GameType } from './content';\nimport type { Image } from './media';\nimport type { MultilingualLabel } from './multilingual';\nimport type { PlayerProfile, PlayerWithParticipation } from './player';\nimport type { Points, Stars, Streaks } from './score';\n\nexport type WithCampaignContentId<T> = T & { campaignContentId: number };\n\nexport type CampaignInformations = {\n coverImage: Image;\n name: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n lastSave: Date;\n};\n\nexport type BaseCampaignScheduling = {\n type: 'flexible' | 'intense';\n launchDate: string;\n endDate?: string;\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n};\n\nexport type ManualCampaignScheduling = BaseCampaignScheduling & {\n mode: 'manual';\n orderedSessions: Content[][];\n};\n\nexport type RandomCampaignScheduling = BaseCampaignScheduling & {\n mode: 'random';\n nbSessions: number;\n contents: Content[];\n};\n\nexport type CampaignScheduling = ManualCampaignScheduling | RandomCampaignScheduling;\n\nexport type Campaign = {\n id: number;\n informations: CampaignInformations;\n scheduling: CampaignScheduling;\n type: 'campaign';\n};\n\nexport type BaseCampaignCardDetails = {\n id: number;\n status: ActivityStatus;\n cover: string;\n title: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n utcStartDate: string;\n utcEndDate: string;\n contentCount: number;\n isRandom: boolean;\n playableDays?: Date[];\n};\n\nexport type WikiCardDetails = BaseCampaignCardDetails;\n\nexport type WikiCardPlayerInteraction = {\n contentPlayedIds: number[];\n favorite: boolean;\n};\n\nexport type WikiCard = {\n details: WikiCardDetails;\n playerInteraction: WikiCardPlayerInteraction;\n};\n\nexport type WikiContentCardDetails = {\n id: number;\n campaignContentId: number;\n coverImage: string;\n title: MultilingualLabel;\n explanation?: MultilingualLabel;\n session: number;\n};\n\nexport type WikiContentCard = {\n contentDetails: WikiContentCardDetails;\n points: Points;\n};\n\nexport type LiveCampaignScheduling = {\n type: 'flexible' | 'intense';\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n sessionCount: number;\n};\n\nexport type LiveCampaignDetails = BaseCampaignCardDetails & LiveCampaignScheduling;\n\nexport type LiveCampaignAchievement = {\n lastSessionPlayed: number;\n lastPlayedAt: string;\n stars: Stars;\n points: Points;\n streaks: Streaks;\n};\n\nexport type SessionInsight = {\n sessionNumber: number;\n gameTypes: GameType[];\n};\n\nexport type StreakSession = {\n day: 1 | 2 | 3 | 4 | 5 | 6 | 7;\n status: CalendarStatus;\n streakCount?: number;\n};\n\nexport type LiveCampaign = {\n details: LiveCampaignDetails;\n achievement: LiveCampaignAchievement;\n sessionInsights: SessionInsight[];\n leaderPlayer?: PlayerProfile;\n streakSessions: StreakSession[];\n};\n\nexport type CalendarStatus = 'played' | 'playable' | 'pending' | 'missed';\n\nexport type Calendar = {\n order: number;\n status: CalendarStatus;\n date: Date;\n};\n\nexport type CampaignDetails = {\n id: number;\n coverImage?: Image;\n name: MultilingualLabel;\n mode: 'manual' | 'random';\n launchDate: string;\n endDate: string;\n enabledWeekDays: number[];\n disabledDates: Date[];\n lastNotificationDate: Date;\n nbPlayers: number;\n nbSessions: number;\n nbQuestions: number;\n players: PlayerWithParticipation[];\n stats: CampaignStats;\n};\n\nexport const isCampaignSchedulingRandom = (scheduling: CampaignScheduling): scheduling is RandomCampaignScheduling =>\n scheduling.mode === 'random';\n\nexport const isCampaignSchedulingManual = (scheduling: CampaignScheduling): scheduling is ManualCampaignScheduling =>\n scheduling.mode === 'manual';\n\nexport const isWikiCard = (item: unknown): item is WikiCard =>\n typeof item === 'object' && item !== null && 'details' in item && 'playerInteraction' in item;\n"],"names":[],"mappings":";;;;AAqJO,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAExB,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAElB,MAAA,UAAU,GAAG,CAAC,IAAa,KACtC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,mBAAmB,IAAI;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"score.js","sources":["../../../src/business/types/score.ts"],"sourcesContent":["export type Points = {\n question: number;\n chrono: number;\n bonus: number;\n};\n\nexport type Stars = {\n question: number;\n chrono: number;\n bonus: number;\n};\n\nexport type Timer = {\n timespent: number;\n timeout: boolean;\n};\n\nexport type BaseScore = {\n id?: number;\n playerId: number;\n contentId: number;\n points: Points;\n timer: Timer;\n createdAt: Date;\n};\n\nexport type CampaignScore = BaseScore & {\n campaignId: number;\n campaignContentId: number;\n sessionNumber?: number; // TODO: should be required after conversion\n};\n\nexport type WikiScore = BaseScore & {\n wikiId: number;\n campaignContentId: number;\n sessionNumber?: number;\n};\n\nexport type BattleScore = BaseScore & {\n battleId: number;\n};\n\nexport type Score = CampaignScore | WikiScore | BattleScore;\n\nexport const isCampaignScore = (score: Score): score is CampaignScore => 'campaignId' in score;\nexport const isWikiScore = (score: Score): score is WikiScore => 'wikiId' in score;\nexport const isBattleScore = (score: Score): score is BattleScore => 'battleId' in score;\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"score.js","sources":["../../../src/business/types/score.ts"],"sourcesContent":["export type Points = {\n question: number;\n chrono: number;\n bonus: number;\n};\n\nexport type Stars = {\n question: number;\n chrono: number;\n bonus: number;\n};\n\nexport type Streaks = {\n totalPoints: number;\n streaksCount: number;\n};\n\nexport type Timer = {\n timespent: number;\n timeout: boolean;\n};\n\nexport type BaseScore = {\n id?: number;\n playerId: number;\n contentId: number;\n points: Points;\n timer: Timer;\n createdAt: Date;\n};\n\nexport type CampaignScore = BaseScore & {\n campaignId: number;\n campaignContentId: number;\n sessionNumber?: number; // TODO: should be required after conversion\n};\n\nexport type WikiScore = BaseScore & {\n wikiId: number;\n campaignContentId: number;\n sessionNumber?: number;\n};\n\nexport type BattleScore = BaseScore & {\n battleId: number;\n};\n\nexport type Score = CampaignScore | WikiScore | BattleScore;\n\nexport const isCampaignScore = (score: Score): score is CampaignScore => 'campaignId' in score;\nexport const isWikiScore = (score: Score): score is WikiScore => 'wikiId' in score;\nexport const isBattleScore = (score: Score): score is BattleScore => 'battleId' in score;\n"],"names":[],"mappings":";;;;AAiDO,MAAM,eAAe,GAAG,CAAC,KAAY,KAA6B,YAAY,IAAI,MAAM;AACxF,MAAM,WAAW,GAAG,CAAC,KAAY,KAAyB,QAAQ,IAAI,MAAM;AAC5E,MAAM,aAAa,GAAG,CAAC,KAAY,KAA2B,UAAU,IAAI;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const startOfDay: (date: Date) => Date;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const startOfDay = (date) => {
|
|
6
|
+
const d = new Date(date);
|
|
7
|
+
d.setUTCHours(0, 0, 0, 0);
|
|
8
|
+
return d;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.startOfDay = startOfDay;
|
|
12
|
+
//# sourceMappingURL=get-start-of-day.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-start-of-day.js","sources":["../../src/date/get-start-of-day.ts"],"sourcesContent":["export const startOfDay = (date: Date) => {\n const d = new Date(date);\n d.setUTCHours(0, 0, 0, 0);\n return d;\n};\n"],"names":[],"mappings":";;;;AAAa,MAAA,UAAU,GAAG,CAAC,IAAU,KAAI;AACvC,IAAA,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,IAAA,OAAO,CAAC,CAAC;AACX;;;;"}
|
package/date/index.d.ts
CHANGED
package/date/index.js
CHANGED
|
@@ -9,6 +9,8 @@ var getRemainingTime = require('./get-remaining-time.js');
|
|
|
9
9
|
var shiftDateBy = require('./shift-date-by.js');
|
|
10
10
|
var differenceInDays = require('./difference-in-days.js');
|
|
11
11
|
var addDays = require('./add-days.js');
|
|
12
|
+
var getStartOfDay = require('./get-start-of-day.js');
|
|
13
|
+
var toUtcDateString = require('./to-utc-date-string.js');
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
|
|
@@ -20,4 +22,6 @@ exports.getRemainingTimeInMsFromDate = getRemainingTime.getRemainingTimeInMsFrom
|
|
|
20
22
|
exports.shiftDateBy = shiftDateBy.shiftDateBy;
|
|
21
23
|
exports.differenceInDays = differenceInDays.differenceInDays;
|
|
22
24
|
exports.addDays = addDays.addDays;
|
|
25
|
+
exports.startOfDay = getStartOfDay.startOfDay;
|
|
26
|
+
exports.toUTCDateString = toUtcDateString.toUTCDateString;
|
|
23
27
|
//# sourceMappingURL=index.js.map
|
package/date/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toUTCDateString: (date: Date) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const toUTCDateString = (date) => {
|
|
6
|
+
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())).toISOString().split('T')[0];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
exports.toUTCDateString = toUTCDateString;
|
|
10
|
+
//# sourceMappingURL=to-utc-date-string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-utc-date-string.js","sources":["../../src/date/to-utc-date-string.ts"],"sourcesContent":["export const toUTCDateString = (date: Date) => {\n return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())).toISOString().split('T')[0];\n};\n"],"names":[],"mappings":";;;;AAAa,MAAA,eAAe,GAAG,CAAC,IAAU,KAAI;AAC5C,IAAA,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7G;;;;"}
|
package/index.js
CHANGED
|
@@ -47,6 +47,8 @@ var getRemainingTime = require('./date/get-remaining-time.js');
|
|
|
47
47
|
var shiftDateBy = require('./date/shift-date-by.js');
|
|
48
48
|
var differenceInDays = require('./date/difference-in-days.js');
|
|
49
49
|
var addDays = require('./date/add-days.js');
|
|
50
|
+
var getStartOfDay = require('./date/get-start-of-day.js');
|
|
51
|
+
var toUtcDateString = require('./date/to-utc-date-string.js');
|
|
50
52
|
|
|
51
53
|
|
|
52
54
|
|
|
@@ -103,4 +105,6 @@ exports.getRemainingTimeInMsFromDate = getRemainingTime.getRemainingTimeInMsFrom
|
|
|
103
105
|
exports.shiftDateBy = shiftDateBy.shiftDateBy;
|
|
104
106
|
exports.differenceInDays = differenceInDays.differenceInDays;
|
|
105
107
|
exports.addDays = addDays.addDays;
|
|
108
|
+
exports.startOfDay = getStartOfDay.startOfDay;
|
|
109
|
+
exports.toUTCDateString = toUtcDateString.toUTCDateString;
|
|
106
110
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|