@firestone-hs/content-craetor-input 0.0.2 → 0.0.3

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,2 +1 @@
1
1
  export * from './data-model';
2
- export * from './input-model';
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./data-model"), exports);
18
- __exportStar(require("./input-model"), exports);
19
18
  //# sourceMappingURL=_public-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_public-api.js","sourceRoot":"","sources":["../src/_public-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,gDAA8B","sourcesContent":["export * from './data-model';\r\nexport * from './input-model';\r\n"]}
1
+ {"version":3,"file":"_public-api.js","sourceRoot":"","sources":["../src/_public-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B","sourcesContent":["export * from './data-model';\r\n"]}
@@ -1,4 +1,3 @@
1
- import { TribeList } from './input-model';
2
1
  export interface BgsCompAdvice {
3
2
  readonly compId: string;
4
3
  readonly name?: string;
@@ -29,3 +28,4 @@ export interface BgsCompCardTip {
29
28
  readonly language: string;
30
29
  readonly tip: string;
31
30
  }
31
+ export type TribeList = readonly string[];
@@ -1 +1 @@
1
- {"version":3,"file":"data-model.js","sourceRoot":"","sources":["../src/data-model.ts"],"names":[],"mappings":"","sourcesContent":["import { TribeList } from './input-model';\r\n\r\nexport interface BgsCompAdvice {\r\n\treadonly compId: string;\r\n\treadonly name?: string;\r\n\treadonly needAnyTribeCombinaisonInLobby: readonly TribeList[];\r\n\treadonly difficulty: 'EASY' | 'MEDIUM' | 'HARD';\r\n\treadonly powerLevel: 'LOW' | 'MEDIUM' | 'HIGH';\r\n\treadonly cards: BgsCompCardAdvice[];\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: 'CORE' | 'ADDON';\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":["export interface BgsCompAdvice {\r\n\treadonly compId: string;\r\n\treadonly name?: string;\r\n\treadonly needAnyTribeCombinaisonInLobby: readonly TribeList[];\r\n\treadonly difficulty: 'EASY' | 'MEDIUM' | 'HARD';\r\n\treadonly powerLevel: 'LOW' | 'MEDIUM' | 'HIGH';\r\n\treadonly cards: BgsCompCardAdvice[];\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: 'CORE' | 'ADDON';\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\nexport type TribeList = readonly string[];\r\n"]}
@@ -11,26 +11,27 @@ export interface InputCard {
11
11
  }
12
12
  export interface BgsCompsInput {
13
13
  readonly author: string;
14
- readonly compositions: readonly BgsCompInput[];
14
+ readonly compsData: readonly BgsCompsDataRow[];
15
+ readonly cardsData: readonly BgsCompsCardDataRow[];
15
16
  }
16
- export interface BgsCompInput {
17
+ export interface BgsCompsDataRow {
17
18
  readonly compId: string;
18
19
  readonly name: string;
19
- readonly tribes: readonly TribeList[];
20
+ readonly tribes: string;
20
21
  readonly difficulty: 'EASY' | 'MEDIUM' | 'HARD';
21
22
  readonly powerLevel: 'LOW' | 'MEDIUM' | 'HIGH';
22
23
  readonly patchNumber: number;
23
24
  readonly date: string;
24
25
  readonly tip: string;
25
26
  readonly whenToCommit: string;
26
- readonly cards: readonly BgsCompCardInput[];
27
27
  }
28
- export type TribeList = readonly string[];
29
- export interface BgsCompCardInput {
28
+ export interface BgsCompsCardDataRow {
29
+ readonly compId: string;
30
30
  readonly cardId: string;
31
+ readonly compName: string;
31
32
  readonly cardName: string;
33
+ readonly status: 'CORE' | 'ADDON';
32
34
  readonly patchNumber: number;
33
35
  readonly date: string;
34
- readonly status: 'CORE' | 'ADDON';
35
36
  readonly tip: string;
36
37
  }
@@ -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 compositions: readonly BgsCompInput[];\r\n}\r\n\r\nexport 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\nexport type TribeList = readonly string[];\r\n\r\nexport 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 tribes: string;\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}\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: 'CORE' | 'ADDON';\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 +1 @@
1
- {"version":3,"file":"start-save-bgs-comp-input.js","sourceRoot":"","sources":["../src/start-save-bgs-comp-input.ts"],"names":[],"mappings":";;AAAA,qEAAqD;AAGrD,MAAM,GAAG,GAAG,IAAI,sBAAG,EAAE,CAAC;AAEtB,kBAAe,KAAK,EAAE,KAAK,EAAgB,EAAE;IAC5C,MAAM,OAAO,GAAG;QACf,8BAA8B,EAC7B,6IAA6I;QAC9I,+BAA+B,EAAE,iBAAiB;QAClD,8BAA8B,EAAE,wCAAwC;QACxE,6BAA6B,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG;KACpF,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAChB,MAAM,QAAQ,GAAG;YAChB,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,OAAO;SAChB,CAAC;QACF,OAAO,QAAQ,CAAC;KAChB;IAED,MAAM,KAAK,GAAiB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IACvC,MAAM,GAAG,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClE,OAAO;QACN,UAAU,EAAE,GAAG;QACf,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,EAAE;KACR,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Sqs } from '@firestone-hs/aws-lambda-utils';\r\nimport { BgsCompInput } from './input-model';\r\n\r\nconst sqs = new Sqs();\r\n\r\nexport default async (event): Promise<any> => {\r\n\tconst headers = {\r\n\t\t'Access-Control-Allow-Headers':\r\n\t\t\t'Accept,Accept-Language,Content-Language,Content-Type,Authorization,x-correlation-id,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token',\r\n\t\t'Access-Control-Expose-Headers': 'x-my-header-out',\r\n\t\t'Access-Control-Allow-Methods': 'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT',\r\n\t\t'Access-Control-Allow-Origin': event.headers?.Origin || event.headers?.origin || '*',\r\n\t};\r\n\t// Preflight\r\n\tif (!event.body) {\r\n\t\tconst response = {\r\n\t\t\tstatusCode: 200,\r\n\t\t\tbody: null,\r\n\t\t\theaders: headers,\r\n\t\t};\r\n\t\treturn response;\r\n\t}\r\n\r\n\tconst input: BgsCompInput = JSON.parse(event.body);\r\n\tconsole.debug('received event', input);\r\n\tawait sqs.sendMessageToQueue(input, process.env.SQS_BGS_COMP_URL);\r\n\treturn {\r\n\t\tstatusCode: 200,\r\n\t\theaders: headers,\r\n\t\tbody: '',\r\n\t};\r\n};\r\n"]}
1
+ {"version":3,"file":"start-save-bgs-comp-input.js","sourceRoot":"","sources":["../src/start-save-bgs-comp-input.ts"],"names":[],"mappings":";;AAAA,qEAAqD;AAErD,MAAM,GAAG,GAAG,IAAI,sBAAG,EAAE,CAAC;AAEtB,kBAAe,KAAK,EAAE,KAAK,EAAgB,EAAE;IAC5C,MAAM,OAAO,GAAG;QACf,8BAA8B,EAC7B,6IAA6I;QAC9I,+BAA+B,EAAE,iBAAiB;QAClD,8BAA8B,EAAE,wCAAwC;QACxE,6BAA6B,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG;KACpF,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAChB,MAAM,QAAQ,GAAG;YAChB,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,OAAO;SAChB,CAAC;QACF,OAAO,QAAQ,CAAC;KAChB;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IACvC,MAAM,GAAG,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClE,OAAO;QACN,UAAU,EAAE,GAAG;QACf,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,EAAE;KACR,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Sqs } from '@firestone-hs/aws-lambda-utils';\r\n\r\nconst sqs = new Sqs();\r\n\r\nexport default async (event): Promise<any> => {\r\n\tconst headers = {\r\n\t\t'Access-Control-Allow-Headers':\r\n\t\t\t'Accept,Accept-Language,Content-Language,Content-Type,Authorization,x-correlation-id,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token',\r\n\t\t'Access-Control-Expose-Headers': 'x-my-header-out',\r\n\t\t'Access-Control-Allow-Methods': 'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT',\r\n\t\t'Access-Control-Allow-Origin': event.headers?.Origin || event.headers?.origin || '*',\r\n\t};\r\n\t// Preflight\r\n\tif (!event.body) {\r\n\t\tconst response = {\r\n\t\t\tstatusCode: 200,\r\n\t\t\tbody: null,\r\n\t\t\theaders: headers,\r\n\t\t};\r\n\t\treturn response;\r\n\t}\r\n\r\n\tconst input = JSON.parse(event.body);\r\n\tconsole.debug('received event', input);\r\n\tawait sqs.sendMessageToQueue(input, process.env.SQS_BGS_COMP_URL);\r\n\treturn {\r\n\t\tstatusCode: 200,\r\n\t\theaders: headers,\r\n\t\tbody: '',\r\n\t};\r\n};\r\n"]}
@@ -8,12 +8,13 @@ const bucket = 'static.zerotoheroes.com';
8
8
  const fileKey = 'hearthstone/data/battlegrounds-strategies/bgs-comps-strategies.gz.json';
9
9
  const processBgsComps = async (input, bgPatch, allCards) => {
10
10
  const author = input.author;
11
- console.debug('processing', author);
11
+ console.debug('processing', author, input);
12
12
  const result = await loadExistingInfo();
13
- for (const inputComp of input.compositions) {
14
- const comp = updateComp(inputComp, result, author);
15
- for (const card of inputComp.cards) {
16
- updateCompCard(card, comp, author);
13
+ for (const inputComp of input.compsData) {
14
+ const comp = updateComp(inputComp, result, author, bgPatch);
15
+ const cardsData = input.cardsData.filter((card) => card.compId === inputComp.compId);
16
+ for (const card of cardsData) {
17
+ updateCompCard(card, comp, author, bgPatch);
17
18
  }
18
19
  }
19
20
  console.debug('built aggregated tips', result);
@@ -21,7 +22,8 @@ const processBgsComps = async (input, bgPatch, allCards) => {
21
22
  console.debug('saved aggregated tips');
22
23
  };
23
24
  exports.processBgsComps = processBgsComps;
24
- const updateCompCard = (inputCard, comp, author) => {
25
+ const updateCompCard = (inputCard, comp, author, bgPatch) => {
26
+ console.debug('updating card', comp.compId, inputCard.cardId, inputCard.tip, inputCard);
25
27
  let existingCard = comp.cards.find((t) => t.cardId === inputCard.cardId);
26
28
  if (!existingCard) {
27
29
  existingCard = {
@@ -39,18 +41,19 @@ const updateCompCard = (inputCard, comp, author) => {
39
41
  author: author,
40
42
  language: 'enUS',
41
43
  };
44
+ existingCard.tips.push(existingTip);
42
45
  }
43
46
  if (!(0, utils_1.deepEqual)(existingTip.tip, inputCard.tip)) {
44
47
  existingTip.tip = inputCard.tip;
45
48
  existingTip.date = new Date().toISOString().substring(0, 10);
46
- existingTip.patchNumber = inputCard.patchNumber;
49
+ existingTip.patchNumber = bgPatch.number;
47
50
  }
48
51
  }
49
52
  else {
50
53
  existingCard.tips = existingCard.tips.filter((t) => t.author !== author);
51
54
  }
52
55
  };
53
- const updateComp = (inputComp, result, author) => {
56
+ const updateComp = (inputComp, result, author, bgPatch) => {
54
57
  let existingComp = result.find((t) => t.compId === inputComp.compId);
55
58
  if (!existingComp) {
56
59
  existingComp = {
@@ -59,7 +62,7 @@ const updateComp = (inputComp, result, author) => {
59
62
  cards: [],
60
63
  difficulty: inputComp.difficulty,
61
64
  powerLevel: inputComp.powerLevel,
62
- needAnyTribeCombinaisonInLobby: inputComp.tribes,
65
+ needAnyTribeCombinaisonInLobby: buildTribes(inputComp.tribes),
63
66
  tips: [],
64
67
  };
65
68
  result.push(existingComp);
@@ -73,12 +76,12 @@ const updateComp = (inputComp, result, author) => {
73
76
  };
74
77
  existingComp.tips.push(existingTip);
75
78
  }
76
- if (!(0, utils_1.deepEqual)(existingTip.tip, inputComp.tip) &&
79
+ if (!(0, utils_1.deepEqual)(existingTip.tip, inputComp.tip) ||
77
80
  !(0, utils_1.deepEqual)(existingTip.whenToCommit, inputComp.whenToCommit)) {
78
81
  existingTip.tip = inputComp.tip;
79
82
  existingTip.whenToCommit = inputComp.whenToCommit;
80
83
  existingTip.date = new Date().toISOString().substring(0, 10);
81
- existingTip.patchNumber = inputComp.patchNumber;
84
+ existingTip.patchNumber = bgPatch.number;
82
85
  }
83
86
  }
84
87
  else {
@@ -86,6 +89,13 @@ const updateComp = (inputComp, result, author) => {
86
89
  }
87
90
  return existingComp;
88
91
  };
92
+ const buildTribes = (tribes) => {
93
+ if (!tribes?.length) {
94
+ return [];
95
+ }
96
+ const tribeGroups = tribes.split('|');
97
+ return tribeGroups.map((group) => group.split('+'));
98
+ };
89
99
  const loadExistingInfo = async () => {
90
100
  const s3 = new aws_lambda_utils_1.S3();
91
101
  const asString = await s3.readGzipContent(bucket, fileKey, 5);
@@ -1 +1 @@
1
- {"version":3,"file":"bgs-comps.js","sourceRoot":"","sources":["../../src/types/bgs-comps.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAE/D,+BAAgC;AAGhC,oCAA8C;AAE9C,MAAM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AAE,GAAG,IAAI,qBAAE,EAAE,CAAC;IAEpB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAE9D,IAAI,CAAC,QAAQ,EAAE;QACd,OAAO,EAAE,CAAC;KACV;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,KAAK,EAAE,IAA8B,EAAE,EAAE;IACzD,MAAM,EAAE,GAAG,IAAI,qBAAE,EAAE,CAAC;IACpB,MAAM,EAAE,CAAC,SAAS,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,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 } from '@firestone-hs/reference-data';\r\nimport { gzipSync } from 'zlib';\r\nimport { BgsCompAdvice, BgsCompCardAdvice, BgsCompCardTip, BgsCompTip } from '../data-model';\r\nimport { BgsCompCardInput, BgsCompInput, 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);\r\n\tconst result = await loadExistingInfo();\r\n\r\n\tfor (const inputComp of input.compositions) {\r\n\t\tconst comp = updateComp(inputComp, result, author);\r\n\t\tfor (const card of inputComp.cards) {\r\n\t\t\tupdateCompCard(card, comp, author);\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 = (inputCard: BgsCompCardInput, comp: MutableBgsCompAdvice, author: string): void => {\r\n\tlet existingCard: Mutable<BgsCompCardAdvice> = comp.cards.find((t) => t.cardId === inputCard.cardId);\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 (!!inputCard.tip?.length) {\r\n\t\tlet existingTip: Mutable<BgsCompCardTip> = existingCard.tips.find((t) => t.author === author);\r\n\t\tif (!existingTip) {\r\n\t\t\texistingTip = {\r\n\t\t\t\tauthor: author,\r\n\t\t\t\tlanguage: 'enUS',\r\n\t\t\t} as BgsCompTip;\r\n\t\t}\r\n\t\tif (!deepEqual(existingTip.tip, inputCard.tip)) {\r\n\t\t\texistingTip.tip = inputCard.tip;\r\n\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\texistingTip.patchNumber = inputCard.patchNumber;\r\n\t\t}\r\n\t} else {\r\n\t\texistingCard.tips = existingCard.tips.filter((t) => t.author !== author);\r\n\t}\r\n};\r\n\r\nconst updateComp = (inputComp: BgsCompInput, result: MutableBgsCompAdvice[], author: string): MutableBgsCompAdvice => {\r\n\tlet existingComp = result.find((t) => t.compId === inputComp.compId);\r\n\tif (!existingComp) {\r\n\t\texistingComp = {\r\n\t\t\tcompId: inputComp.compId,\r\n\t\t\tname: inputComp.name,\r\n\t\t\tcards: [],\r\n\t\t\tdifficulty: inputComp.difficulty,\r\n\t\t\tpowerLevel: inputComp.powerLevel,\r\n\t\t\tneedAnyTribeCombinaisonInLobby: inputComp.tribes,\r\n\t\t\ttips: [],\r\n\t\t};\r\n\t\tresult.push(existingComp);\r\n\t}\r\n\r\n\tif (!!inputComp.tip?.length) {\r\n\t\tlet existingTip: Mutable<BgsCompTip> = existingComp.tips.find((t) => t.author === author);\r\n\t\tif (!existingTip) {\r\n\t\t\texistingTip = {\r\n\t\t\t\tauthor: author,\r\n\t\t\t\tlanguage: 'enUS',\r\n\t\t\t} as BgsCompTip;\r\n\t\t\texistingComp.tips.push(existingTip);\r\n\t\t}\r\n\t\tif (\r\n\t\t\t!deepEqual(existingTip.tip, inputComp.tip) &&\r\n\t\t\t!deepEqual(existingTip.whenToCommit, inputComp.whenToCommit)\r\n\t\t) {\r\n\t\t\texistingTip.tip = inputComp.tip;\r\n\t\t\texistingTip.whenToCommit = inputComp.whenToCommit;\r\n\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\texistingTip.patchNumber = inputComp.patchNumber;\r\n\t\t}\r\n\t} else {\r\n\t\texistingComp.tips = existingComp.tips.filter((t) => t.author !== author);\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\treturn JSON.parse(asString);\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;AAE/D,+BAAgC;AAGhC,oCAA8C;AAE9C,MAAM,MAAM,GAAG,yBAAyB,CAAC;AACzC,MAAM,OAAO,GAAG,wEAAwE,CAAC;AAElF,MAAM,eAAe,GAAG,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PatchInfo, S3 } from '@firestone-hs/aws-lambda-utils';\r\nimport { AllCardsService } from '@firestone-hs/reference-data';\r\nimport { gzipSync } from 'zlib';\r\nimport { BgsCompAdvice, BgsCompCardAdvice, BgsCompCardTip, BgsCompTip, TribeList } 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\tconst result = await loadExistingInfo();\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((card) => card.compId === inputComp.compId);\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\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((t) => t.cardId === inputCard.cardId);\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 (!!inputCard.tip?.length) {\r\n\t\tlet existingTip: Mutable<BgsCompCardTip> = existingCard.tips.find((t) => t.author === author);\r\n\t\tif (!existingTip) {\r\n\t\t\texistingTip = {\r\n\t\t\t\tauthor: author,\r\n\t\t\t\tlanguage: 'enUS',\r\n\t\t\t} as BgsCompTip;\r\n\t\t\texistingCard.tips.push(existingTip);\r\n\t\t}\r\n\t\tif (!deepEqual(existingTip.tip, inputCard.tip)) {\r\n\t\t\texistingTip.tip = inputCard.tip;\r\n\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\texistingTip.patchNumber = bgPatch.number;\r\n\t\t}\r\n\t} else {\r\n\t\texistingCard.tips = existingCard.tips.filter((t) => t.author !== author);\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 === inputComp.compId);\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,\r\n\t\t\tname: inputComp.name,\r\n\t\t\tcards: [],\r\n\t\t\tdifficulty: inputComp.difficulty,\r\n\t\t\tpowerLevel: inputComp.powerLevel,\r\n\t\t\tneedAnyTribeCombinaisonInLobby: buildTribes(inputComp.tribes),\r\n\t\t\ttips: [],\r\n\t\t};\r\n\t\tresult.push(existingComp);\r\n\t}\r\n\r\n\tif (!!inputComp.tip?.length) {\r\n\t\tlet existingTip: Mutable<BgsCompTip> = existingComp.tips.find((t) => t.author === author);\r\n\t\tif (!existingTip) {\r\n\t\t\texistingTip = {\r\n\t\t\t\tauthor: author,\r\n\t\t\t\tlanguage: 'enUS',\r\n\t\t\t} as BgsCompTip;\r\n\t\t\texistingComp.tips.push(existingTip);\r\n\t\t}\r\n\t\tif (\r\n\t\t\t!deepEqual(existingTip.tip, inputComp.tip) ||\r\n\t\t\t!deepEqual(existingTip.whenToCommit, inputComp.whenToCommit)\r\n\t\t) {\r\n\t\t\texistingTip.tip = inputComp.tip;\r\n\t\t\texistingTip.whenToCommit = inputComp.whenToCommit;\r\n\t\t\texistingTip.date = new Date().toISOString().substring(0, 10);\r\n\t\t\texistingTip.patchNumber = bgPatch.number;\r\n\t\t}\r\n\t} else {\r\n\t\texistingComp.tips = existingComp.tips.filter((t) => t.author !== author);\r\n\t}\r\n\treturn existingComp;\r\n};\r\n\r\nconst buildTribes = (tribes: string): readonly TribeList[] => {\r\n\tif (!tribes?.length) {\r\n\t\treturn [];\r\n\t}\r\n\r\n\tconst tribeGroups = tribes.split('|');\r\n\treturn tribeGroups.map((group) => group.split('+'));\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\treturn JSON.parse(asString);\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.2",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",