@sparted/shared-library 1.9.2 → 1.9.4

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.
@@ -49,6 +49,7 @@ export type BaseCampaignCardDetails = {
49
49
  utcStartDate: string;
50
50
  utcEndDate: string;
51
51
  contentCount: number;
52
+ contentStars?: number;
52
53
  sessionContentDistribution: number[];
53
54
  isRandom: boolean;
54
55
  playableDays?: Date[];
@@ -56,6 +57,7 @@ export type BaseCampaignCardDetails = {
56
57
  export type WikiCardDetails = BaseCampaignCardDetails;
57
58
  export type WikiCardPlayerInteraction = {
58
59
  contentPlayedIds: number[];
60
+ contentPlayerStars: number;
59
61
  favorite: boolean;
60
62
  };
61
63
  export type WikiCard = {
@@ -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 { LiveCampaignPoints, 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 sessionContentDistribution: 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 playedSessions: number[];\n playedSessionsCount: number;\n lastSessionPlayed: number;\n lastPlayedAt: string | null;\n stars: Stars;\n points: LiveCampaignPoints;\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 /** @deprecated to avoid breaking changes */\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":";;;;AAyJO,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
+ {"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 { LiveCampaignPoints, 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 contentStars?: number;\n sessionContentDistribution: number[];\n isRandom: boolean;\n playableDays?: Date[];\n};\n\nexport type WikiCardDetails = BaseCampaignCardDetails;\n\nexport type WikiCardPlayerInteraction = {\n contentPlayedIds: number[];\n contentPlayerStars: 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 playedSessions: number[];\n playedSessionsCount: number;\n lastSessionPlayed: number;\n lastPlayedAt: string | null;\n stars: Stars;\n points: LiveCampaignPoints;\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 /** @deprecated to avoid breaking changes */\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":";;;;AA2JO,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;;;;;;"}
@@ -35,7 +35,7 @@ const extractExplanation = (content) => {
35
35
  return extractGameExplanation(content.game);
36
36
  };
37
37
  const extractImages = (game) => {
38
- var _a, _b, _c, _d;
38
+ var _a, _b, _c, _d, _e;
39
39
  if (isGameOrderingCards(game)) {
40
40
  return [];
41
41
  }
@@ -44,7 +44,7 @@ const extractImages = (game) => {
44
44
  if ((_a = game.firstMedia.image) === null || _a === void 0 ? void 0 : _a.url) {
45
45
  images.push(game.firstMedia.image.url);
46
46
  }
47
- if ((_b = game.secondMedia.image) === null || _b === void 0 ? void 0 : _b.url) {
47
+ if ((_c = (_b = game.secondMedia) === null || _b === void 0 ? void 0 : _b.image) === null || _c === void 0 ? void 0 : _c.url) {
48
48
  images.push(game.secondMedia.image.url);
49
49
  }
50
50
  return images;
@@ -62,10 +62,10 @@ const extractImages = (game) => {
62
62
  }, []);
63
63
  }
64
64
  const images = [];
65
- if ((_c = game.gameMedia.image) === null || _c === void 0 ? void 0 : _c.url) {
65
+ if ((_d = game.gameMedia.image) === null || _d === void 0 ? void 0 : _d.url) {
66
66
  images.push(game.gameMedia.image.url);
67
67
  }
68
- if ((_d = game.explanationMedia.image) === null || _d === void 0 ? void 0 : _d.url) {
68
+ if ((_e = game.explanationMedia.image) === null || _e === void 0 ? void 0 : _e.url) {
69
69
  images.push(game.explanationMedia.image.url);
70
70
  }
71
71
  return images;
@@ -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 | 'translation-unvalidated'\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;AAChC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,aAAa,EAAE,eAAe;EAC9B;AAyCW,MAAA,4BAA4B,GAAG,CAAC,IAAU,KAAqC,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,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAW,CAAC,GAAG,EAAE,IAAI,KAAI;;AAC/C,YAAA,IAAI,MAAA,IAAI,CAAC,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,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 | 'translation-unvalidated'\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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AAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC9C,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparted/shared-library",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
4
4
  "repository": "git@github.com:Sparted/shared-library.git",
5
5
  "author": {
6
6
  "name": "Sparted",
@@ -14,55 +14,12 @@
14
14
  "**/*",
15
15
  "**/**"
16
16
  ],
17
- "scripts": {
18
- "test": "jest",
19
- "lint": "eslint .",
20
- "clean": "rm -rf ./dist",
21
- "build": "yarn clean && rollup --config rollup.config.ts --configPlugin typescript2 && cp package.json ./dist/package.json",
22
- "build-and-publish": "yarn test && yarn build && (cd ./dist && yarn publish)"
23
- },
24
- "devDependencies": {
25
- "@types/crypto-js": "^4.2.2",
26
- "@types/glob": "^8.0.0",
27
- "@types/jest": "^29.0.3",
28
- "@types/ungap__structured-clone": "^0.3.0",
29
- "@typescript-eslint/eslint-plugin": "^6.0.0",
30
- "@typescript-eslint/parser": "^6.0.0",
31
- "eslint": "^7.32.0",
32
- "eslint-config-prettier": "^8.8.0",
33
- "eslint-plugin-import": "^2.27.5",
34
- "eslint-plugin-prettier": "^4.2.1",
35
- "glob": "^8.0.3",
36
- "jest": "^29.6.1",
37
- "jest-environment-jsdom": "^29.0.3",
38
- "jest-extended": "^3.1.0",
39
- "jest-fetch-mock": "^3.0.3",
40
- "prettier": "2",
41
- "rollup": "^2.79.1",
42
- "rollup-plugin-typescript2": "^0.34.0",
43
- "ts-jest": "^29.0.2",
44
- "tslib": "^2.4.0",
45
- "typescript": "^4.8.3"
46
- },
47
- "jest": {
48
- "moduleFileExtensions": [
49
- "js",
50
- "ts"
51
- ],
52
- "setupFilesAfterEnv": [
53
- "jest-extended/all"
54
- ],
55
- "rootDir": ".",
56
- "testRegex": [
57
- ".*\\.test\\.ts$"
58
- ],
59
- "transform": {
60
- "^.+\\.(t|j)s$": "ts-jest"
61
- }
62
- },
63
17
  "dependencies": {
64
18
  "@ungap/structured-clone": "^1.2.0",
65
19
  "crypto-js": "^4.2.0",
66
20
  "ts-essentials": "^9.4.1"
21
+ },
22
+ "publishConfig": {
23
+ "registry": "https://registry.npmjs.org/"
67
24
  }
68
- }
25
+ }