@firestone-hs/content-craetor-input 0.0.12 → 0.0.14

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.
@@ -12,7 +12,8 @@ export interface BgsCompAdvice {
12
12
  export interface BgsCompCardAdvice {
13
13
  readonly cardId: string;
14
14
  readonly name?: string;
15
- readonly status: 'MANDATORY' | 'CORE' | 'ADDON' | 'ENABLER' | 'CYCLE' | 'TRINKET';
15
+ readonly status: 'CORE' | 'ADDON' | 'RECOMMENDED' | 'ENABLER' | 'CYCLE' | 'TRINKET';
16
+ readonly finalBoardWeight: number;
16
17
  readonly tips: BgsCompCardTip[];
17
18
  }
18
19
  export interface BgsCompTip {
@@ -1 +1 @@
1
- {"version":3,"file":"data-model.js","sourceRoot":"","sources":["../src/data-model.ts"],"names":[],"mappings":"","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\n\r\nexport interface BgsCompAdvice {\r\n\treadonly compId: string;\r\n\treadonly name?: string;\r\n\treadonly difficulty: 'Easy' | 'Medium' | 'Hard';\r\n\treadonly powerLevel: 'D' | 'C' | 'B' | 'A' | 'S';\r\n\treadonly patchNumber: number;\r\n\treadonly cards: BgsCompCardAdvice[];\r\n\treadonly forcedTribes: readonly Race[];\r\n\treadonly tips: BgsCompTip[];\r\n}\r\nexport interface BgsCompCardAdvice {\r\n\treadonly cardId: string;\r\n\treadonly name?: string;\r\n\treadonly status: 'MANDATORY' | 'CORE' | 'ADDON' | 'ENABLER' | 'CYCLE' | 'TRINKET';\r\n\treadonly tips: BgsCompCardTip[];\r\n}\r\nexport interface BgsCompTip {\r\n\treadonly author: string;\r\n\treadonly date: string;\r\n\treadonly patchNumber: number;\r\n\treadonly language: string;\r\n\treadonly tip: string;\r\n\treadonly whenToCommit: string;\r\n}\r\nexport interface BgsCompCardTip {\r\n\treadonly author: string;\r\n\treadonly date: string;\r\n\treadonly patchNumber: number;\r\n\treadonly language: string;\r\n\treadonly tip: string;\r\n}\r\n"]}
1
+ {"version":3,"file":"data-model.js","sourceRoot":"","sources":["../src/data-model.ts"],"names":[],"mappings":"","sourcesContent":["import { Race } from '@firestone-hs/reference-data';\r\n\r\nexport interface BgsCompAdvice {\r\n\treadonly compId: string;\r\n\treadonly name?: string;\r\n\treadonly difficulty: 'Easy' | 'Medium' | 'Hard';\r\n\treadonly powerLevel: 'D' | 'C' | 'B' | 'A' | 'S';\r\n\treadonly patchNumber: number;\r\n\treadonly cards: BgsCompCardAdvice[];\r\n\treadonly forcedTribes: readonly Race[];\r\n\treadonly tips: BgsCompTip[];\r\n}\r\nexport interface BgsCompCardAdvice {\r\n\treadonly cardId: string;\r\n\treadonly name?: string;\r\n readonly status: 'CORE' | 'ADDON' | 'RECOMMENDED' | 'ENABLER' | 'CYCLE' | 'TRINKET';\r\n\treadonly finalBoardWeight: number;\r\n\treadonly tips: BgsCompCardTip[];\r\n}\r\nexport interface BgsCompTip {\r\n\treadonly author: string;\r\n\treadonly date: string;\r\n\treadonly patchNumber: number;\r\n\treadonly language: string;\r\n\treadonly tip: string;\r\n\treadonly whenToCommit: string;\r\n}\r\nexport interface BgsCompCardTip {\r\n\treadonly author: string;\r\n\treadonly date: string;\r\n\treadonly patchNumber: number;\r\n\treadonly language: string;\r\n\treadonly tip: string;\r\n}\r\n"]}
@@ -30,7 +30,8 @@ export interface BgsCompsCardDataRow {
30
30
  readonly cardId: string;
31
31
  readonly compName: string;
32
32
  readonly cardName: string;
33
- readonly status: 'MANDATORY' | 'CORE' | 'ADDON' | 'ENABLER' | 'CYCLE';
33
+ readonly status: 'CORE' | 'ADDON' | 'RECOMMENDED' | 'ENABLER' | 'CYCLE' | 'TRINKET';
34
+ readonly finalBoardWeight: number;
34
35
  readonly patchNumber: number;
35
36
  readonly date: string;
36
37
  readonly tip: string;
@@ -1 +1 @@
1
- {"version":3,"file":"input-model.js","sourceRoot":"","sources":["../src/input-model.ts"],"names":[],"mappings":"","sourcesContent":["export interface Input {\r\n\treadonly type: 'bgs-trinkets' | 'bgs-heroes';\r\n\treadonly author: string;\r\n\treadonly data: readonly InputCard[];\r\n}\r\n\r\nexport interface InputCard {\r\n\treadonly cardId: string;\r\n\treadonly patchNumber: number;\r\n\treadonly date: string;\r\n\treadonly tip: string;\r\n}\r\n\r\nexport interface BgsCompsInput {\r\n\treadonly author: string;\r\n\treadonly compsData: readonly BgsCompsDataRow[];\r\n\treadonly cardsData: readonly BgsCompsCardDataRow[];\r\n}\r\n\r\nexport interface BgsCompsDataRow {\r\n\treadonly compId: string;\r\n\treadonly name: string;\r\n\treadonly difficulty: 'Easy' | 'Medium' | 'Hard';\r\n\treadonly powerLevel: 'D' | 'C' | 'B' | 'A' | 'S';\r\n\treadonly forcedTribes: string;\r\n\treadonly patchNumber: number;\r\n\treadonly date: string;\r\n\treadonly tip: string;\r\n\treadonly whenToCommit: string;\r\n}\r\n\r\nexport interface BgsCompsCardDataRow {\r\n\treadonly compId: string;\r\n\treadonly cardId: string;\r\n\treadonly compName: string;\r\n\treadonly cardName: string;\r\n\treadonly status: 'MANDATORY' | 'CORE' | 'ADDON' | 'ENABLER' | 'CYCLE';\r\n\treadonly patchNumber: number;\r\n\treadonly date: string;\r\n\treadonly tip: string;\r\n}\r\n\r\n// export interface BgsCompInput {\r\n// \treadonly compId: string;\r\n// \treadonly name: string;\r\n// \treadonly tribes: readonly TribeList[];\r\n// \treadonly difficulty: 'EASY' | 'MEDIUM' | 'HARD';\r\n// \treadonly powerLevel: 'LOW' | 'MEDIUM' | 'HIGH';\r\n// \treadonly patchNumber: number;\r\n// \treadonly date: string;\r\n// \treadonly tip: string;\r\n// \treadonly whenToCommit: string;\r\n// \treadonly cards: readonly BgsCompCardInput[];\r\n// }\r\n\r\n// // Tribes that need to be together in the lobby for the comp to work\r\n// export type TribeList = readonly string[];\r\n\r\n// export interface BgsCompCardInput {\r\n// \treadonly cardId: string;\r\n// \treadonly cardName: string;\r\n// \treadonly patchNumber: number;\r\n// \treadonly date: string;\r\n// \treadonly status: 'CORE' | 'ADDON';\r\n// \treadonly tip: string;\r\n// }\r\n"]}
1
+ {"version":3,"file":"input-model.js","sourceRoot":"","sources":["../src/input-model.ts"],"names":[],"mappings":"","sourcesContent":["export interface Input {\r\n\treadonly type: 'bgs-trinkets' | 'bgs-heroes';\r\n\treadonly author: string;\r\n\treadonly data: readonly InputCard[];\r\n}\r\n\r\nexport interface InputCard {\r\n\treadonly cardId: string;\r\n\treadonly patchNumber: number;\r\n\treadonly date: string;\r\n\treadonly tip: string;\r\n}\r\n\r\nexport interface BgsCompsInput {\r\n\treadonly author: string;\r\n\treadonly compsData: readonly BgsCompsDataRow[];\r\n\treadonly cardsData: readonly BgsCompsCardDataRow[];\r\n}\r\n\r\nexport interface BgsCompsDataRow {\r\n\treadonly compId: string;\r\n\treadonly name: string;\r\n\treadonly difficulty: 'Easy' | 'Medium' | 'Hard';\r\n\treadonly powerLevel: 'D' | 'C' | 'B' | 'A' | 'S';\r\n\treadonly forcedTribes: string;\r\n\treadonly patchNumber: number;\r\n\treadonly date: string;\r\n\treadonly tip: string;\r\n\treadonly whenToCommit: string;\r\n}\r\n\r\nexport interface BgsCompsCardDataRow {\r\n\treadonly compId: string;\r\n\treadonly cardId: string;\r\n\treadonly compName: string;\r\n\treadonly cardName: string;\r\n readonly status: 'CORE' | 'ADDON' | 'RECOMMENDED' | 'ENABLER' | 'CYCLE' | 'TRINKET';\r\n\treadonly finalBoardWeight: number;\r\n\treadonly patchNumber: number;\r\n\treadonly date: string;\r\n\treadonly tip: string;\r\n}\r\n\r\n// export interface BgsCompInput {\r\n// \treadonly compId: string;\r\n// \treadonly name: string;\r\n// \treadonly tribes: readonly TribeList[];\r\n// \treadonly difficulty: 'EASY' | 'MEDIUM' | 'HARD';\r\n// \treadonly powerLevel: 'LOW' | 'MEDIUM' | 'HIGH';\r\n// \treadonly patchNumber: number;\r\n// \treadonly date: string;\r\n// \treadonly tip: string;\r\n// \treadonly whenToCommit: string;\r\n// \treadonly cards: readonly BgsCompCardInput[];\r\n// }\r\n\r\n// // Tribes that need to be together in the lobby for the comp to work\r\n// export type TribeList = readonly string[];\r\n\r\n// export interface BgsCompCardInput {\r\n// \treadonly cardId: string;\r\n// \treadonly cardName: string;\r\n// \treadonly patchNumber: number;\r\n// \treadonly date: string;\r\n// \treadonly status: 'CORE' | 'ADDON';\r\n// \treadonly tip: string;\r\n// }\r\n"]}
@@ -49,6 +49,7 @@ const updateCompCard = (inputCard, comp, author, bgPatch) => {
49
49
  comp.cards.push(existingCard);
50
50
  }
51
51
  existingCard.status = inputCard.status;
52
+ existingCard.finalBoardWeight = inputCard.finalBoardWeight || 1;
52
53
  if (!!author && author !== 'ref') {
53
54
  if (!!inputCard.tip?.length) {
54
55
  let existingTip = existingCard.tips.find((t) => t.author === author);
@@ -89,6 +90,7 @@ const updateComp = (inputComp, result, author, bgPatch) => {
89
90
  existingComp.name = inputComp.name;
90
91
  existingComp.difficulty = inputComp.difficulty;
91
92
  existingComp.powerLevel = inputComp.powerLevel;
93
+ existingComp.patchNumber = inputComp.patchNumber;
92
94
  if (!!author && author !== 'ref') {
93
95
  if (!!inputComp.tip?.length) {
94
96
  let existingTip = existingComp.tips.find((t) => t.author === author);
@@ -1 +1 @@
1
- {"version":3,"file":"bgs-comps.js","sourceRoot":"","sources":["../../src/types/bgs-comps.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAC/D,iEAAqE;AACrE,+BAAgC;AAGhC,oCAA8C;AAE9C,MAAM,MAAM,GAAG,yBAAyB,CAAC;AACzC,MAAM,OAAO,GAAG,wEAAwE,CAAC;AAElF,MAAM,eAAe,GAAG,KAAK,EAAE,KAAoB,EAAE,OAAkB,EAAE,QAAyB,EAAE,EAAE;IAC5G,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACtC,OAAO,C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C,CAAC;AACjG,CAAC,CAAC","sourcesContent":["/* eslint-disable no-extra-boolean-cast */\r\nimport { PatchInfo, S3 } from '@firestone-hs/aws-lambda-utils';\r\nimport { AllCardsService, Race } from '@firestone-hs/reference-data';\r\nimport { gzipSync } from 'zlib';\r\nimport { BgsCompAdvice, BgsCompCardAdvice, BgsCompCardTip, BgsCompTip } from '../data-model';\r\nimport { BgsCompsCardDataRow, BgsCompsDataRow, BgsCompsInput } from '../input-model';\r\nimport { deepEqual, Mutable } from '../utils';\r\n\r\nconst bucket = 'static.zerotoheroes.com';\r\nconst fileKey = 'hearthstone/data/battlegrounds-strategies/bgs-comps-strategies.gz.json';\r\n\r\nexport const processBgsComps = async (input: BgsCompsInput, bgPatch: PatchInfo, allCards: AllCardsService) => {\r\n\tconst author = input.author;\r\n\tconsole.debug('processing', author, input);\r\n\tlet result = await loadExistingInfo();\r\n\tconsole.debug('loaded existing info', result);\r\n\r\n\tfor (const inputComp of input.compsData) {\r\n\t\tconst comp = updateComp(inputComp, result, author, bgPatch);\r\n\t\tconst cardsData = input.cardsData.filter(\r\n\t\t\t(card) => card.compId.toLowerCase() === inputComp.compId.toLowerCase(),\r\n\t\t);\r\n\t\tif (author === 'ref') {\r\n\t\t\tcomp.patchNumber = inputComp.patchNumber;\r\n\t\t\tconst existingCards = [...comp.cards];\r\n\t\t\tfor (const existing of existingCards) {\r\n\t\t\t\tconst cardData = cardsData.find(\r\n\t\t\t\t\t(card) => card.cardId === existing.cardId && card.status === existing.status,\r\n\t\t\t\t);\r\n\t\t\t\tif (!cardData) {\r\n\t\t\t\t\t// Remove it\r\n\t\t\t\t\tcomp.cards = comp.cards.filter((card) => card !== existing);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const card of cardsData) {\r\n\t\t\tupdateCompCard(card, comp, author, bgPatch);\r\n\t\t}\r\n\t}\r\n\t// Remove old comps\r\n\tif (author === 'ref') {\r\n\t\tresult = result.filter((comp) =>\r\n\t\t\tinput.compsData.map((c) => c.compId.toLowerCase()).includes(comp.compId.toLowerCase()),\r\n\t\t);\r\n\t}\r\n\r\n\tconsole.debug('built aggregated tips', result);\r\n\tawait saveInfo(result);\r\n\tconsole.debug('saved aggregated tips');\r\n};\r\n\r\nconst updateCompCard = (\r\n\tinputCard: BgsCompsCardDataRow,\r\n\tcomp: MutableBgsCompAdvice,\r\n\tauthor: string,\r\n\tbgPatch: PatchInfo,\r\n): void => {\r\n\tconsole.debug('updating card', comp.compId, inputCard.cardId, inputCard.tip, inputCard);\r\n\tlet existingCard: Mutable<BgsCompCardAdvice> = comp.cards.find(\r\n\t\t(t) => t.cardId === inputCard.cardId && t.status === inputCard.status,\r\n\t);\r\n\tif (!existingCard) {\r\n\t\texistingCard = {\r\n\t\t\tcardId: inputCard.cardId,\r\n\t\t\tname: inputCard.cardName,\r\n\t\t\ttips: [],\r\n\t\t} as BgsCompCardAdvice;\r\n\t\tcomp.cards.push(existingCard);\r\n\t}\r\n\texistingCard.status = inputCard.status;\r\n\r\n\tif (!!author && author !== 'ref') {\r\n\t\tif (!!inputCard.tip?.length) {\r\n\t\t\tlet existingTip: Mutable<BgsCompCardTip> = existingCard.tips.find((t) => t.author === author);\r\n\t\t\tif (!existingTip) {\r\n\t\t\t\texistingTip = {\r\n\t\t\t\t\tauthor: author,\r\n\t\t\t\t\tlanguage: 'enUS',\r\n\t\t\t\t} as BgsCompTip;\r\n\t\t\t\texistingCard.tips.push(existingTip);\r\n\t\t\t}\r\n\t\t\tif (!deepEqual(existingTip.tip, inputCard.tip)) {\r\n\t\t\t\texistingTip.tip = inputCard.tip;\r\n\t\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\t\texistingTip.patchNumber = bgPatch.number;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\texistingCard.tips = existingCard.tips.filter((t) => t.author !== author);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst updateComp = (\r\n\tinputComp: BgsCompsDataRow,\r\n\tresult: MutableBgsCompAdvice[],\r\n\tauthor: string,\r\n\tbgPatch: PatchInfo,\r\n): MutableBgsCompAdvice => {\r\n\tlet existingComp = result.find((t) => t.compId.toLowerCase() === inputComp.compId.toLowerCase());\r\n\tif (!existingComp) {\r\n\t\t// This should maybe come from another process to handle the ref data\r\n\t\texistingComp = {\r\n\t\t\tcompId: inputComp.compId.toLowerCase(),\r\n\t\t\tname: inputComp.name,\r\n\t\t\tpatchNumber: inputComp.patchNumber,\r\n\t\t\tcards: [],\r\n\t\t\tdifficulty: inputComp.difficulty,\r\n\t\t\tpowerLevel: inputComp.powerLevel,\r\n\t\t\tforcedTribes: inputComp?.forcedTribes?.split(',').map((tribe) => Race[tribe.trim()]) ?? [],\r\n\t\t\ttips: [],\r\n\t\t};\r\n\t\tresult.push(existingComp);\r\n\t}\r\n\r\n\texistingComp.compId = existingComp.compId.toLowerCase();\r\n\texistingComp.name = inputComp.name;\r\n\texistingComp.difficulty = inputComp.difficulty;\r\n\texistingComp.powerLevel = inputComp.powerLevel;\r\n\r\n\tif (!!author && author !== 'ref') {\r\n\t\tif (!!inputComp.tip?.length) {\r\n\t\t\tlet existingTip: Mutable<BgsCompTip> = existingComp.tips.find((t) => t.author === author);\r\n\t\t\tif (!existingTip) {\r\n\t\t\t\texistingTip = {\r\n\t\t\t\t\tauthor: author,\r\n\t\t\t\t\tlanguage: 'enUS',\r\n\t\t\t\t} as BgsCompTip;\r\n\t\t\t\texistingComp.tips.push(existingTip);\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\t!deepEqual(existingTip.tip, inputComp.tip) ||\r\n\t\t\t\t!deepEqual(existingTip.whenToCommit, inputComp.whenToCommit)\r\n\t\t\t) {\r\n\t\t\t\texistingTip.tip = inputComp.tip;\r\n\t\t\t\texistingTip.whenToCommit = inputComp.whenToCommit;\r\n\t\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\t\texistingTip.patchNumber = bgPatch.number;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\texistingComp.tips = existingComp.tips.filter((t) => t.author !== author);\r\n\t\t}\r\n\t}\r\n\treturn existingComp;\r\n};\r\n\r\nconst loadExistingInfo = async (): Promise<MutableBgsCompAdvice[]> => {\r\n\tconst s3 = new S3();\r\n\t// console.debug('created s3');\r\n\tconst asString = await s3.readGzipContent(bucket, fileKey, 5);\r\n\t// console.debug('loaded existing info', asString?.length);\r\n\tif (!asString) {\r\n\t\treturn [];\r\n\t}\r\n\tconst result: MutableBgsCompAdvice[] = JSON.parse(asString);\r\n\t// Keep unique comps (by id)\r\n\treturn result.filter(\r\n\t\t(comp, index, self) => index === self.findIndex((t) => t.compId.toLowerCase() === comp.compId.toLowerCase()),\r\n\t);\r\n};\r\n\r\nconst saveInfo = async (info: readonly BgsCompAdvice[]) => {\r\n\tconst s3 = new S3();\r\n\tawait s3.writeFile(gzipSync(JSON.stringify(info)), bucket, fileKey, 'application/json', 'gzip');\r\n};\r\n\r\ntype MutableBgsCompAdvice = Mutable<BgsCompAdvice>;\r\n"]}
1
+ {"version":3,"file":"bgs-comps.js","sourceRoot":"","sources":["../../src/types/bgs-comps.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAC/D,iEAAqE;AACrE,+BAAgC;AAGhC,oCAA8C;AAE9C,MAAM,MAAM,GAAG,yBAAyB,CAAC;AACzC,MAAM,OAAO,GAAG,wEAAwE,CAAC;AAElF,MAAM,eAAe,GAAG,KAAK,EAAE,KAAoB,EAAE,OAAkB,EAAE,QAAyB,EAAE,EAAE;IAC5G,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACtC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;IAE9C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,SAAS,EAAE;Q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AkB,EAAE,MAAM,CAAC,CAAC;AACjG,CAAC,CAAC","sourcesContent":["/* eslint-disable no-extra-boolean-cast */\r\nimport { PatchInfo, S3 } from '@firestone-hs/aws-lambda-utils';\r\nimport { AllCardsService, Race } from '@firestone-hs/reference-data';\r\nimport { gzipSync } from 'zlib';\r\nimport { BgsCompAdvice, BgsCompCardAdvice, BgsCompCardTip, BgsCompTip } from '../data-model';\r\nimport { BgsCompsCardDataRow, BgsCompsDataRow, BgsCompsInput } from '../input-model';\r\nimport { deepEqual, Mutable } from '../utils';\r\n\r\nconst bucket = 'static.zerotoheroes.com';\r\nconst fileKey = 'hearthstone/data/battlegrounds-strategies/bgs-comps-strategies.gz.json';\r\n\r\nexport const processBgsComps = async (input: BgsCompsInput, bgPatch: PatchInfo, allCards: AllCardsService) => {\r\n\tconst author = input.author;\r\n\tconsole.debug('processing', author, input);\r\n\tlet result = await loadExistingInfo();\r\n\tconsole.debug('loaded existing info', result);\r\n\r\n\tfor (const inputComp of input.compsData) {\r\n\t\tconst comp = updateComp(inputComp, result, author, bgPatch);\r\n\t\tconst cardsData = input.cardsData.filter(\r\n\t\t\t(card) => card.compId.toLowerCase() === inputComp.compId.toLowerCase(),\r\n\t\t);\r\n\t\tif (author === 'ref') {\r\n\t\t\tcomp.patchNumber = inputComp.patchNumber;\r\n\t\t\tconst existingCards = [...comp.cards];\r\n\t\t\tfor (const existing of existingCards) {\r\n\t\t\t\tconst cardData = cardsData.find(\r\n\t\t\t\t\t(card) => card.cardId === existing.cardId && card.status === existing.status,\r\n\t\t\t\t);\r\n\t\t\t\tif (!cardData) {\r\n\t\t\t\t\t// Remove it\r\n\t\t\t\t\tcomp.cards = comp.cards.filter((card) => card !== existing);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (const card of cardsData) {\r\n\t\t\tupdateCompCard(card, comp, author, bgPatch);\r\n\t\t}\r\n\t}\r\n\t// Remove old comps\r\n\tif (author === 'ref') {\r\n\t\tresult = result.filter((comp) =>\r\n\t\t\tinput.compsData.map((c) => c.compId.toLowerCase()).includes(comp.compId.toLowerCase()),\r\n\t\t);\r\n\t}\r\n\r\n\tconsole.debug('built aggregated tips', result);\r\n\tawait saveInfo(result);\r\n\tconsole.debug('saved aggregated tips');\r\n};\r\n\r\nconst updateCompCard = (\r\n\tinputCard: BgsCompsCardDataRow,\r\n\tcomp: MutableBgsCompAdvice,\r\n\tauthor: string,\r\n\tbgPatch: PatchInfo,\r\n): void => {\r\n\tconsole.debug('updating card', comp.compId, inputCard.cardId, inputCard.tip, inputCard);\r\n\tlet existingCard: Mutable<BgsCompCardAdvice> = comp.cards.find(\r\n\t\t(t) => t.cardId === inputCard.cardId && t.status === inputCard.status,\r\n\t);\r\n\tif (!existingCard) {\r\n\t\texistingCard = {\r\n\t\t\tcardId: inputCard.cardId,\r\n\t\t\tname: inputCard.cardName,\r\n\t\t\ttips: [],\r\n\t\t} as BgsCompCardAdvice;\r\n\t\tcomp.cards.push(existingCard);\r\n\t}\r\n\texistingCard.status = inputCard.status;\r\n\texistingCard.finalBoardWeight = inputCard.finalBoardWeight || 1;\r\n\r\n\tif (!!author && author !== 'ref') {\r\n\t\tif (!!inputCard.tip?.length) {\r\n\t\t\tlet existingTip: Mutable<BgsCompCardTip> = existingCard.tips.find((t) => t.author === author);\r\n\t\t\tif (!existingTip) {\r\n\t\t\t\texistingTip = {\r\n\t\t\t\t\tauthor: author,\r\n\t\t\t\t\tlanguage: 'enUS',\r\n\t\t\t\t} as BgsCompTip;\r\n\t\t\t\texistingCard.tips.push(existingTip);\r\n\t\t\t}\r\n\t\t\tif (!deepEqual(existingTip.tip, inputCard.tip)) {\r\n\t\t\t\texistingTip.tip = inputCard.tip;\r\n\t\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\t\texistingTip.patchNumber = bgPatch.number;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\texistingCard.tips = existingCard.tips.filter((t) => t.author !== author);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nconst updateComp = (\r\n\tinputComp: BgsCompsDataRow,\r\n\tresult: MutableBgsCompAdvice[],\r\n\tauthor: string,\r\n\tbgPatch: PatchInfo,\r\n): MutableBgsCompAdvice => {\r\n\tlet existingComp = result.find((t) => t.compId.toLowerCase() === inputComp.compId.toLowerCase());\r\n\tif (!existingComp) {\r\n\t\t// This should maybe come from another process to handle the ref data\r\n\t\texistingComp = {\r\n\t\t\tcompId: inputComp.compId.toLowerCase(),\r\n\t\t\tname: inputComp.name,\r\n\t\t\tpatchNumber: inputComp.patchNumber,\r\n\t\t\tcards: [],\r\n\t\t\tdifficulty: inputComp.difficulty,\r\n\t\t\tpowerLevel: inputComp.powerLevel,\r\n\t\t\tforcedTribes: inputComp?.forcedTribes?.split(',').map((tribe) => Race[tribe.trim()]) ?? [],\r\n\t\t\ttips: [],\r\n\t\t};\r\n\t\tresult.push(existingComp);\r\n\t}\r\n\r\n\texistingComp.compId = existingComp.compId.toLowerCase();\r\n\texistingComp.name = inputComp.name;\r\n\texistingComp.difficulty = inputComp.difficulty;\r\n\texistingComp.powerLevel = inputComp.powerLevel;\r\n\texistingComp.patchNumber = inputComp.patchNumber;\r\n\r\n\tif (!!author && author !== 'ref') {\r\n\t\tif (!!inputComp.tip?.length) {\r\n\t\t\tlet existingTip: Mutable<BgsCompTip> = existingComp.tips.find((t) => t.author === author);\r\n\t\t\tif (!existingTip) {\r\n\t\t\t\texistingTip = {\r\n\t\t\t\t\tauthor: author,\r\n\t\t\t\t\tlanguage: 'enUS',\r\n\t\t\t\t} as BgsCompTip;\r\n\t\t\t\texistingComp.tips.push(existingTip);\r\n\t\t\t}\r\n\t\t\tif (\r\n\t\t\t\t!deepEqual(existingTip.tip, inputComp.tip) ||\r\n\t\t\t\t!deepEqual(existingTip.whenToCommit, inputComp.whenToCommit)\r\n\t\t\t) {\r\n\t\t\t\texistingTip.tip = inputComp.tip;\r\n\t\t\t\texistingTip.whenToCommit = inputComp.whenToCommit;\r\n\t\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\t\texistingTip.patchNumber = bgPatch.number;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\texistingComp.tips = existingComp.tips.filter((t) => t.author !== author);\r\n\t\t}\r\n\t}\r\n\treturn existingComp;\r\n};\r\n\r\nconst loadExistingInfo = async (): Promise<MutableBgsCompAdvice[]> => {\r\n\tconst s3 = new S3();\r\n\t// console.debug('created s3');\r\n\tconst asString = await s3.readGzipContent(bucket, fileKey, 5);\r\n\t// console.debug('loaded existing info', asString?.length);\r\n\tif (!asString) {\r\n\t\treturn [];\r\n\t}\r\n\tconst result: MutableBgsCompAdvice[] = JSON.parse(asString);\r\n\t// Keep unique comps (by id)\r\n\treturn result.filter(\r\n\t\t(comp, index, self) => index === self.findIndex((t) => t.compId.toLowerCase() === comp.compId.toLowerCase()),\r\n\t);\r\n};\r\n\r\nconst saveInfo = async (info: readonly BgsCompAdvice[]) => {\r\n\tconst s3 = new S3();\r\n\tawait s3.writeFile(gzipSync(JSON.stringify(info)), bucket, fileKey, 'application/json', 'gzip');\r\n};\r\n\r\ntype MutableBgsCompAdvice = Mutable<BgsCompAdvice>;\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/content-craetor-input",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",