@sparted/shared-library 1.7.58 → 1.7.60
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BreakingNewsActivity } from './breaking-news';
|
|
2
2
|
import type { Campaign } from './campaign';
|
|
3
|
-
import
|
|
3
|
+
import { Media } from './media';
|
|
4
|
+
import type { LanguageCode, MultilingualLabel } from './multilingual';
|
|
4
5
|
type Segment = {
|
|
5
6
|
id: number;
|
|
6
7
|
label: string;
|
|
@@ -23,6 +24,37 @@ export type SharedActivityMetadata = {
|
|
|
23
24
|
};
|
|
24
25
|
export type CampaignActivity = SharedActivityMetadata & Campaign;
|
|
25
26
|
export type Activity = CampaignActivity | BreakingNewsActivity;
|
|
27
|
+
export type BoActivityCardDetails = {
|
|
28
|
+
identifier: string;
|
|
29
|
+
cover: Media;
|
|
30
|
+
title: MultilingualLabel;
|
|
31
|
+
utcStartDate: string;
|
|
32
|
+
utcEndDate?: string;
|
|
33
|
+
};
|
|
34
|
+
export type BoActivityCardEvents = {
|
|
35
|
+
viewCount: number;
|
|
36
|
+
likeCount: number;
|
|
37
|
+
};
|
|
38
|
+
export type BoActivityCardAudience = {
|
|
39
|
+
type: 'all';
|
|
40
|
+
} | {
|
|
41
|
+
type: 'segmentation';
|
|
42
|
+
segments: Segment[];
|
|
43
|
+
} | {
|
|
44
|
+
type: 'magic-code';
|
|
45
|
+
code: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'email-list';
|
|
48
|
+
};
|
|
49
|
+
export type BoActivityCard = {
|
|
50
|
+
id: number;
|
|
51
|
+
type: 'campaign' | 'breaking-news';
|
|
52
|
+
status: ActivityStatus;
|
|
53
|
+
details: BoActivityCardDetails;
|
|
54
|
+
language: LanguageCode[];
|
|
55
|
+
events: BoActivityCardEvents;
|
|
56
|
+
audience: BoActivityCardAudience;
|
|
57
|
+
};
|
|
26
58
|
export declare const ACTIVITY_STATUS: readonly ["draft", "inactive", "archived", "upcoming", "live", "celebration", "finished"];
|
|
27
59
|
export declare const isActivityCampaign: (activity: unknown) => activity is CampaignActivity;
|
|
28
60
|
export declare const isActivityBreakingNews: (activity: CampaignActivity | BreakingNewsActivity) => activity is BreakingNewsActivity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.js","sources":["../../../src/business/types/activity.ts"],"sourcesContent":["import { BreakingNewsActivity } from './breaking-news';\nimport type { Campaign } from './campaign';\nimport type { LanguageCode } from './multilingual';\n\ntype Segment = {\n id: number;\n label: string;\n dimensionId: number;\n};\n\nexport type ActivityAudience = {\n groupId: number;\n type: 'all' | 'segmentation' | 'magic-code' | 'email-list';\n segments: Segment[];\n};\n\nexport type ActivityStatus = (typeof ACTIVITY_STATUS)[number];\n\nexport type SharedActivityMetadata = {\n status: ActivityStatus;\n languages?: LanguageCode[];\n audiences?: ActivityAudience[];\n userEngagement?: {\n viewCount?: number;\n likeCount?: number;\n };\n};\n\nexport type CampaignActivity = SharedActivityMetadata & Campaign;\n\nexport type Activity = CampaignActivity | BreakingNewsActivity;\n\nexport const ACTIVITY_STATUS = [\n 'draft',\n 'inactive',\n 'archived',\n 'upcoming',\n 'live',\n 'celebration',\n 'finished',\n] as const;\n\nexport const isActivityCampaign = (activity: unknown): activity is CampaignActivity =>\n typeof activity === 'object' && activity !== null && 'type' in activity && activity.type === 'campaign';\n\nexport const isActivityBreakingNews = (\n activity: CampaignActivity | BreakingNewsActivity,\n): activity is BreakingNewsActivity => activity.type === 'breaking-news';\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"activity.js","sources":["../../../src/business/types/activity.ts"],"sourcesContent":["import { BreakingNewsActivity } from './breaking-news';\nimport type { Campaign } from './campaign';\nimport { Media } from './media';\nimport type { LanguageCode, MultilingualLabel } from './multilingual';\n\ntype Segment = {\n id: number;\n label: string;\n dimensionId: number;\n};\n\nexport type ActivityAudience = {\n groupId: number;\n type: 'all' | 'segmentation' | 'magic-code' | 'email-list';\n segments: Segment[];\n};\n\nexport type ActivityStatus = (typeof ACTIVITY_STATUS)[number];\n\nexport type SharedActivityMetadata = {\n status: ActivityStatus;\n languages?: LanguageCode[];\n audiences?: ActivityAudience[];\n userEngagement?: {\n viewCount?: number;\n likeCount?: number;\n };\n};\n\nexport type CampaignActivity = SharedActivityMetadata & Campaign;\n\nexport type Activity = CampaignActivity | BreakingNewsActivity;\n\nexport type BoActivityCardDetails = {\n identifier: string;\n cover: Media;\n title: MultilingualLabel;\n utcStartDate: string;\n utcEndDate?: string;\n};\n\nexport type BoActivityCardEvents = {\n viewCount: number;\n likeCount: number;\n};\n\nexport type BoActivityCardAudience =\n | {\n type: 'all';\n }\n | {\n type: 'segmentation';\n segments: Segment[];\n }\n | {\n type: 'magic-code';\n code: string;\n }\n | {\n type: 'email-list';\n };\n\nexport type BoActivityCard = {\n id: number;\n type: 'campaign' | 'breaking-news';\n status: ActivityStatus;\n details: BoActivityCardDetails;\n language: LanguageCode[];\n events: BoActivityCardEvents;\n audience: BoActivityCardAudience;\n};\n\nexport const ACTIVITY_STATUS = [\n 'draft',\n 'inactive',\n 'archived',\n 'upcoming',\n 'live',\n 'celebration',\n 'finished',\n] as const;\n\nexport const isActivityCampaign = (activity: unknown): activity is CampaignActivity =>\n typeof activity === 'object' && activity !== null && 'type' in activity && activity.type === 'campaign';\n\nexport const isActivityBreakingNews = (\n activity: CampaignActivity | BreakingNewsActivity,\n): activity is BreakingNewsActivity => activity.type === 'breaking-news';\n"],"names":[],"mappings":";;;;AAwEa,MAAA,eAAe,GAAG;IAC7B,OAAO;IACP,UAAU;IACV,UAAU;IACV,UAAU;IACV,MAAM;IACN,aAAa;IACb,UAAU;EACD;AAEE,MAAA,kBAAkB,GAAG,CAAC,QAAiB,KAClD,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,IAAI,MAAM,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW;AAEnG,MAAM,sBAAsB,GAAG,CACpC,QAAiD,KACZ,QAAQ,CAAC,IAAI,KAAK;;;;;;"}
|
|
@@ -106,7 +106,7 @@ export type ContentMetadata = {
|
|
|
106
106
|
thematic: Thematic;
|
|
107
107
|
type: GameType;
|
|
108
108
|
};
|
|
109
|
-
export type ContributionType = 'validated' | 'created' | 'edited' | 'deleted' | 'translation-requested' | 'translation-validated' | 'validation-requested';
|
|
109
|
+
export type ContributionType = 'validated' | 'created' | 'edited' | 'deleted' | 'translation-requested' | 'translation-validated' | 'validation-requested' | 'archived' | 'unarchived';
|
|
110
110
|
export type ContentContribution = {
|
|
111
111
|
id: number;
|
|
112
112
|
contributor: PlayerProfile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sources":["../../../src/business/types/content.ts"],"sourcesContent":["import { DeepPartial } from 'ts-essentials';\n\nimport { Image, Media } from './media';\nimport { LanguageCode, MultilingualLabel } from './multilingual';\nimport { Thematic } from './thematic';\nimport { PlayerProfile } from './player';\n\nexport type ContentStatuses = Partial<{\n [languageCode in LanguageCode]: 'draft' | 'validated' | 'waiting-translation' | 'waiting-validation';\n}>;\n\nexport type BOContentCard = {\n id: number;\n customId: string;\n coverImage?: Image;\n title: MultilingualLabel;\n statuses: ContentStatuses;\n};\n\nexport type ErrorText = {\n id: number;\n type: 'error-text';\n gameMedia: Media;\n wrongText: MultilingualLabel;\n correctText: MultilingualLabel;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type ChoiceQuestion = {\n text: MultilingualLabel;\n correct: boolean;\n};\n\nexport type MultipleChoiceQuestion = {\n id: number;\n type: 'mcq';\n gameMedia: Media;\n question: MultilingualLabel;\n choices: ChoiceQuestion[];\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type NoInteraction = {\n id: number;\n type: 'no-interaction';\n firstMedia: Media;\n title: MultilingualLabel;\n text: MultilingualLabel;\n secondMedia: Media;\n};\n\nexport type OpenQuestion = {\n id: number;\n type: 'open-question';\n gameMedia: Media;\n question: MultilingualLabel;\n answer: MultilingualLabel;\n levenshteinDistance: number;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type OrderingCards = {\n id: number;\n type: 'ordering-cards';\n question: MultilingualLabel;\n topLabel: MultilingualLabel;\n cards: MultilingualLabel[];\n bottomLabel: MultilingualLabel;\n explanation: MultilingualLabel;\n};\n\nexport type Spot = {\n id: number;\n x: number;\n y: number;\n r: number;\n question: MultilingualLabel;\n description: MultilingualLabel;\n};\n\nexport type PictureSpot = {\n id: number;\n type: 'picture-spot';\n image: Image;\n items: Spot[];\n explanation: MultilingualLabel;\n};\n\nexport type SwipingCardPosition = 'left' | 'right' | 'top' | 'bottom';\n\nexport type SwipingCardZone = {\n position: SwipingCardPosition;\n text: MultilingualLabel;\n};\n\nexport type SwipingCard = {\n image?: Image;\n text?: MultilingualLabel;\n answer: SwipingCardPosition;\n};\n\nexport type SwipingCards = {\n id: number;\n type: 'swiping-cards';\n question: MultilingualLabel;\n zones: SwipingCardZone[];\n cards: SwipingCard[];\n explanation: MultilingualLabel;\n};\n\nexport type Game =\n | ErrorText\n | MultipleChoiceQuestion\n | NoInteraction\n | OpenQuestion\n | OrderingCards\n | PictureSpot\n | SwipingCards;\n\nexport type GameType =\n | 'error-text'\n | 'mcq'\n | 'open-question'\n | 'no-interaction'\n | 'picture-spot'\n | 'swiping-cards'\n | 'ordering-cards';\n\nexport const GAME_TYPE: Record<string, GameType> = {\n MCQ: 'mcq',\n ERROR_TEXT: 'error-text',\n OPEN_QUESTION: 'open-question',\n NO_INTERACTION: 'no-interaction',\n PICTURE_SPOT: 'picture-spot',\n ORDERING_CARDS: 'ordering-cards',\n SWIPING_CARDS: 'swiping-cards',\n};\n\nexport type ContentMetadata = {\n identifier: string;\n coverImage?: Image;\n name: MultilingualLabel;\n knowMore: MultilingualLabel;\n thematic: Thematic;\n type: GameType;\n};\n\nexport type ContributionType =\n | 'validated'\n | 'created'\n | 'edited'\n | 'deleted'\n | 'translation-requested'\n | 'translation-validated'\n | 'validation-requested';\n\nexport type ContentContribution = {\n id: number;\n contributor: PlayerProfile;\n type: ContributionType;\n date: Date;\n};\n\nexport type Content = {\n id: number;\n legacyKnowledgeId: number;\n legacyContentIds: number[];\n metadata: ContentMetadata;\n game?: Game;\n statuses: ContentStatuses;\n contributions: ContentContribution[];\n archived: boolean;\n};\n\nexport const isGameMultipleChoiceQuestion = (game: Game): game is MultipleChoiceQuestion => game.type === GAME_TYPE.MCQ;\nexport const isGameErrorText = (game: Game): game is ErrorText => game.type === GAME_TYPE.ERROR_TEXT;\nexport const isGameOpenQuestion = (game: Game): game is OpenQuestion => game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isGameNoInteraction = (game: Game): game is NoInteraction => game.type === GAME_TYPE.NO_INTERACTION;\nexport const isGamePictureSpot = (game: Game): game is PictureSpot => game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isGameOrderingCards = (game: Game): game is OrderingCards => game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isGameSwipingCards = (game: Game): game is SwipingCards => game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const isPartialGameMultipleChoiceQuestion = (\n game: DeepPartial<Game>,\n): game is DeepPartial<MultipleChoiceQuestion> => game.type === GAME_TYPE.MCQ;\nexport const isPartialGameErrorText = (game: DeepPartial<Game>): game is DeepPartial<ErrorText> =>\n game.type === GAME_TYPE.ERROR_TEXT;\nexport const isPartialGameOpenQuestion = (game: DeepPartial<Game>): game is DeepPartial<OpenQuestion> =>\n game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isPartialGameNoInteraction = (game: DeepPartial<Game>): game is DeepPartial<NoInteraction> =>\n game.type === GAME_TYPE.NO_INTERACTION;\nexport const isPartialGamePictureSpot = (game: DeepPartial<Game>): game is DeepPartial<PictureSpot> =>\n game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isPartialGameOrderingCards = (game: DeepPartial<Game>): game is DeepPartial<OrderingCards> =>\n game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isPartialGameSwipingCards = (game: DeepPartial<Game>): game is DeepPartial<SwipingCards> =>\n game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const extractGameExplanation = (game?: Game) => {\n if (!game || game.type === 'no-interaction') {\n return undefined;\n }\n\n return game.explanation;\n};\n\nexport const extractExplanation = (content: Content) => {\n return extractGameExplanation(content.game);\n};\n\nexport const extractImages = (game: Game) => {\n if (isGameOrderingCards(game)) {\n return [];\n }\n\n if (isGameNoInteraction(game)) {\n const images = [];\n\n if (game.firstMedia.image?.url) {\n images.push(game.firstMedia.image.url);\n }\n\n if (game.secondMedia.image?.url) {\n images.push(game.secondMedia.image.url);\n }\n\n return images;\n }\n\n if (isGamePictureSpot(game)) {\n return [game.image.url];\n }\n\n if (isGameSwipingCards(game)) {\n return game.cards.reduce<string[]>((acc, card) => {\n if (card.image?.url) {\n acc.push(card.image.url);\n }\n\n return acc;\n }, []);\n }\n\n const images = [];\n\n if (game.gameMedia.image?.url) {\n images.push(game.gameMedia.image.url);\n }\n\n if (game.explanationMedia.image?.url) {\n images.push(game.explanationMedia.image.url);\n }\n\n return images;\n};\n"],"names":[],"mappings":";;;;AAmIa,MAAA,SAAS,GAA6B;AACjD,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,aAAa,EAAE,eAAe;EAC9B;AAsCW,MAAA,4BAA4B,GAAG,CAAC,IAAU,KAAqC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;AAC3G,MAAA,eAAe,GAAG,CAAC,IAAU,KAAwB,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,WAAW;AACxF,MAAA,kBAAkB,GAAG,CAAC,IAAU,KAA2B,IAAI,CAAC,IAAI,K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E,GAAG,EAAE;gBACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1B,aAAA;AAED,YAAA,OAAO,GAAG,CAAC;SACZ,EAAE,EAAE,CAAC,CAAC;AACR,KAAA;IAED,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,IAAI,CAAA,EAAA,GAAA,IAAI,CAAC,SAAS,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,GAAG,EAAE;QAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACvC,KAAA;IAED,IAAI,CAAA,EAAA,GAAA,IAAI,CAAC,gBAAgB,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,GAAG,EAAE;QACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC9C,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"content.js","sources":["../../../src/business/types/content.ts"],"sourcesContent":["import { DeepPartial } from 'ts-essentials';\n\nimport { Image, Media } from './media';\nimport { LanguageCode, MultilingualLabel } from './multilingual';\nimport { Thematic } from './thematic';\nimport { PlayerProfile } from './player';\n\nexport type ContentStatuses = Partial<{\n [languageCode in LanguageCode]: 'draft' | 'validated' | 'waiting-translation' | 'waiting-validation';\n}>;\n\nexport type BOContentCard = {\n id: number;\n customId: string;\n coverImage?: Image;\n title: MultilingualLabel;\n statuses: ContentStatuses;\n};\n\nexport type ErrorText = {\n id: number;\n type: 'error-text';\n gameMedia: Media;\n wrongText: MultilingualLabel;\n correctText: MultilingualLabel;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type ChoiceQuestion = {\n text: MultilingualLabel;\n correct: boolean;\n};\n\nexport type MultipleChoiceQuestion = {\n id: number;\n type: 'mcq';\n gameMedia: Media;\n question: MultilingualLabel;\n choices: ChoiceQuestion[];\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type NoInteraction = {\n id: number;\n type: 'no-interaction';\n firstMedia: Media;\n title: MultilingualLabel;\n text: MultilingualLabel;\n secondMedia: Media;\n};\n\nexport type OpenQuestion = {\n id: number;\n type: 'open-question';\n gameMedia: Media;\n question: MultilingualLabel;\n answer: MultilingualLabel;\n levenshteinDistance: number;\n explanationMedia: Media;\n explanation: MultilingualLabel;\n};\n\nexport type OrderingCards = {\n id: number;\n type: 'ordering-cards';\n question: MultilingualLabel;\n topLabel: MultilingualLabel;\n cards: MultilingualLabel[];\n bottomLabel: MultilingualLabel;\n explanation: MultilingualLabel;\n};\n\nexport type Spot = {\n id: number;\n x: number;\n y: number;\n r: number;\n question: MultilingualLabel;\n description: MultilingualLabel;\n};\n\nexport type PictureSpot = {\n id: number;\n type: 'picture-spot';\n image: Image;\n items: Spot[];\n explanation: MultilingualLabel;\n};\n\nexport type SwipingCardPosition = 'left' | 'right' | 'top' | 'bottom';\n\nexport type SwipingCardZone = {\n position: SwipingCardPosition;\n text: MultilingualLabel;\n};\n\nexport type SwipingCard = {\n image?: Image;\n text?: MultilingualLabel;\n answer: SwipingCardPosition;\n};\n\nexport type SwipingCards = {\n id: number;\n type: 'swiping-cards';\n question: MultilingualLabel;\n zones: SwipingCardZone[];\n cards: SwipingCard[];\n explanation: MultilingualLabel;\n};\n\nexport type Game =\n | ErrorText\n | MultipleChoiceQuestion\n | NoInteraction\n | OpenQuestion\n | OrderingCards\n | PictureSpot\n | SwipingCards;\n\nexport type GameType =\n | 'error-text'\n | 'mcq'\n | 'open-question'\n | 'no-interaction'\n | 'picture-spot'\n | 'swiping-cards'\n | 'ordering-cards';\n\nexport const GAME_TYPE: Record<string, GameType> = {\n MCQ: 'mcq',\n ERROR_TEXT: 'error-text',\n OPEN_QUESTION: 'open-question',\n NO_INTERACTION: 'no-interaction',\n PICTURE_SPOT: 'picture-spot',\n ORDERING_CARDS: 'ordering-cards',\n SWIPING_CARDS: 'swiping-cards',\n};\n\nexport type ContentMetadata = {\n identifier: string;\n coverImage?: Image;\n name: MultilingualLabel;\n knowMore: MultilingualLabel;\n thematic: Thematic;\n type: GameType;\n};\n\nexport type ContributionType =\n | 'validated'\n | 'created'\n | 'edited'\n | 'deleted'\n | 'translation-requested'\n | 'translation-validated'\n | 'validation-requested'\n | 'archived'\n | 'unarchived';\n\nexport type ContentContribution = {\n id: number;\n contributor: PlayerProfile;\n type: ContributionType;\n date: Date;\n};\n\nexport type Content = {\n id: number;\n legacyKnowledgeId: number;\n legacyContentIds: number[];\n metadata: ContentMetadata;\n game?: Game;\n statuses: ContentStatuses;\n contributions: ContentContribution[];\n archived: boolean;\n};\n\nexport const isGameMultipleChoiceQuestion = (game: Game): game is MultipleChoiceQuestion => game.type === GAME_TYPE.MCQ;\nexport const isGameErrorText = (game: Game): game is ErrorText => game.type === GAME_TYPE.ERROR_TEXT;\nexport const isGameOpenQuestion = (game: Game): game is OpenQuestion => game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isGameNoInteraction = (game: Game): game is NoInteraction => game.type === GAME_TYPE.NO_INTERACTION;\nexport const isGamePictureSpot = (game: Game): game is PictureSpot => game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isGameOrderingCards = (game: Game): game is OrderingCards => game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isGameSwipingCards = (game: Game): game is SwipingCards => game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const isPartialGameMultipleChoiceQuestion = (\n game: DeepPartial<Game>,\n): game is DeepPartial<MultipleChoiceQuestion> => game.type === GAME_TYPE.MCQ;\nexport const isPartialGameErrorText = (game: DeepPartial<Game>): game is DeepPartial<ErrorText> =>\n game.type === GAME_TYPE.ERROR_TEXT;\nexport const isPartialGameOpenQuestion = (game: DeepPartial<Game>): game is DeepPartial<OpenQuestion> =>\n game.type === GAME_TYPE.OPEN_QUESTION;\nexport const isPartialGameNoInteraction = (game: DeepPartial<Game>): game is DeepPartial<NoInteraction> =>\n game.type === GAME_TYPE.NO_INTERACTION;\nexport const isPartialGamePictureSpot = (game: DeepPartial<Game>): game is DeepPartial<PictureSpot> =>\n game.type === GAME_TYPE.PICTURE_SPOT;\nexport const isPartialGameOrderingCards = (game: DeepPartial<Game>): game is DeepPartial<OrderingCards> =>\n game.type === GAME_TYPE.ORDERING_CARDS;\nexport const isPartialGameSwipingCards = (game: DeepPartial<Game>): game is DeepPartial<SwipingCards> =>\n game.type === GAME_TYPE.SWIPING_CARDS;\n\nexport const extractGameExplanation = (game?: Game) => {\n if (!game || game.type === 'no-interaction') {\n return undefined;\n }\n\n return game.explanation;\n};\n\nexport const extractExplanation = (content: Content) => {\n return extractGameExplanation(content.game);\n};\n\nexport const extractImages = (game: Game) => {\n if (isGameOrderingCards(game)) {\n return [];\n }\n\n if (isGameNoInteraction(game)) {\n const images = [];\n\n if (game.firstMedia.image?.url) {\n images.push(game.firstMedia.image.url);\n }\n\n if (game.secondMedia.image?.url) {\n images.push(game.secondMedia.image.url);\n }\n\n return images;\n }\n\n if (isGamePictureSpot(game)) {\n return [game.image.url];\n }\n\n if (isGameSwipingCards(game)) {\n return game.cards.reduce<string[]>((acc, card) => {\n if (card.image?.url) {\n acc.push(card.image.url);\n }\n\n return acc;\n }, []);\n }\n\n const images = [];\n\n if (game.gameMedia.image?.url) {\n images.push(game.gameMedia.image.url);\n }\n\n if (game.explanationMedia.image?.url) {\n images.push(game.explanationMedia.image.url);\n }\n\n return images;\n};\n"],"names":[],"mappings":";;;;AAmIa,MAAA,SAAS,GAA6B;AACjD,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,cAAc,EAAE,gBAAgB;AACh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