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

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.
@@ -31,3 +31,17 @@ export interface BgsCompCardTip {
31
31
  readonly language: string;
32
32
  readonly tip: string;
33
33
  }
34
+ export interface ArenaHeroStrategies {
35
+ readonly heroes: ArenaHeroAdvice[];
36
+ }
37
+ export interface ArenaHeroAdvice {
38
+ readonly heroClass: string;
39
+ tips: ArenaHeroTip[];
40
+ }
41
+ export interface ArenaHeroTip {
42
+ author: string;
43
+ language: string;
44
+ patchNumber: number;
45
+ date: string;
46
+ tip: string;
47
+ }
@@ -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 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"]}
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: '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\r\nexport interface ArenaHeroStrategies {\r\n\treadonly heroes: ArenaHeroAdvice[];\r\n}\r\n\r\nexport interface ArenaHeroAdvice {\r\n\treadonly heroClass: string;\r\n\ttips: ArenaHeroTip[];\r\n}\r\nexport interface ArenaHeroTip {\r\n\tauthor: string;\r\n\tlanguage: string;\r\n\tpatchNumber: number;\r\n\tdate: string;\r\n\ttip: string;\r\n}"]}
@@ -0,0 +1,11 @@
1
+ export interface InputArena {
2
+ readonly type: 'arena-heroes';
3
+ readonly author: string;
4
+ readonly data: readonly InputArenaHero[];
5
+ }
6
+ export interface InputArenaHero {
7
+ readonly heroClass: string;
8
+ readonly patchNumber: number;
9
+ readonly date: string;
10
+ readonly tip: string;
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=input-arena-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-arena-model.js","sourceRoot":"","sources":["../src/input-arena-model.ts"],"names":[],"mappings":"","sourcesContent":["export interface InputArena {\r\n\treadonly type: 'arena-heroes';\r\n\treadonly author: string;\r\n\treadonly data: readonly InputArenaHero[];\r\n}\r\n\r\nexport interface InputArenaHero {\r\n\treadonly heroClass: string;\r\n\treadonly patchNumber: number;\r\n\treadonly date: string;\r\n\treadonly tip: string;\r\n}"]}
@@ -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 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"]}
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: '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"]}
@@ -0,0 +1,2 @@
1
+ declare const _default: (event: any, context: any) => Promise<any>;
2
+ export default _default;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const aws_lambda_utils_1 = require("@firestone-hs/aws-lambda-utils");
4
+ const arena_heroes_1 = require("./types/arena-heroes");
5
+ exports.default = async (event, context) => {
6
+ const events = event.Records
7
+ .map((event) => JSON.parse(event.body))
8
+ .reduce((a, b) => a.concat(b), []);
9
+ const arenaPatch = await (0, aws_lambda_utils_1.getLastArenaPatch)();
10
+ console.log('arena patch', arenaPatch);
11
+ for (const input of events) {
12
+ await processInput(input, arenaPatch);
13
+ }
14
+ const response = {
15
+ statusCode: 200,
16
+ isBase64Encoded: false,
17
+ body: null,
18
+ };
19
+ return response;
20
+ };
21
+ const processInput = async (input, arenaPatch) => {
22
+ console.log('processing input', input.type, input.author);
23
+ switch (input.type) {
24
+ case 'arena-heroes':
25
+ return (0, arena_heroes_1.processArenaHeroes)(input, arenaPatch);
26
+ }
27
+ };
28
+ //# sourceMappingURL=process-save-arena-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-save-arena-input.js","sourceRoot":"","sources":["../src/process-save-arena-input.ts"],"names":[],"mappings":";;AACA,qEAA8E;AAE9E,uDAA0D;AAG1D,kBAAe,KAAK,EAAE,KAAK,EAAE,OAAO,EAAgB,EAAE;IACrD,MAAM,MAAM,GAA2B,KAAK,CAAC,OAAiB;SAC5D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEpC,MAAM,UAAU,GAAG,MAAM,IAAA,oCAAiB,GAAE,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACvC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC3B,MAAM,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;KACtC;IAED,MAAM,QAAQ,GAAG;QAChB,UAAU,EAAE,GAAG;QACf,eAAe,EAAE,KAAK;QACtB,IAAI,EAAE,IAAI;KACV,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,KAAK,EAAE,KAAiB,EAAE,UAAqB,EAAE,EAAE;IACvE,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1D,QAAQ,KAAK,CAAC,IAAI,EAAE;QACnB,KAAK,cAAc;YAClB,OAAO,IAAA,iCAAkB,EAAC,KAAK,EAAE,UAAU,CAAC,CAAC;KAC9C;AACF,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\r\nimport { getLastArenaPatch, PatchInfo } from '@firestone-hs/aws-lambda-utils';\r\nimport { InputArena } from './input-arena-model';\r\nimport { processArenaHeroes } from './types/arena-heroes';\r\n\r\n\r\nexport default async (event, context): Promise<any> => {\r\n\tconst events: readonly InputArena[] = (event.Records as any[])\r\n\t\t.map((event) => JSON.parse(event.body))\r\n\t\t.reduce((a, b) => a.concat(b), []);\r\n\r\n\tconst arenaPatch = await getLastArenaPatch();\r\n\tconsole.log('arena patch', arenaPatch);\r\n\tfor (const input of events) {\r\n\t\tawait processInput(input, arenaPatch);\r\n\t}\r\n\r\n\tconst response = {\r\n\t\tstatusCode: 200,\r\n\t\tisBase64Encoded: false,\r\n\t\tbody: null,\r\n\t};\r\n\treturn response;\r\n};\r\n\r\nconst processInput = async (input: InputArena, arenaPatch: PatchInfo) => {\r\n\tconsole.log('processing input', input.type, input.author);\r\n\tswitch (input.type) {\r\n\t\tcase 'arena-heroes':\r\n\t\t\treturn processArenaHeroes(input, arenaPatch);\r\n\t}\r\n};\r\n"]}
@@ -0,0 +1,2 @@
1
+ declare const _default: (event: any) => Promise<any>;
2
+ export default _default;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const aws_lambda_utils_1 = require("@firestone-hs/aws-lambda-utils");
4
+ const sqs = new aws_lambda_utils_1.Sqs();
5
+ exports.default = async (event) => {
6
+ const headers = {
7
+ 'Access-Control-Allow-Headers': 'Accept,Accept-Language,Content-Language,Content-Type,Authorization,x-correlation-id,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token',
8
+ 'Access-Control-Expose-Headers': 'x-my-header-out',
9
+ 'Access-Control-Allow-Methods': 'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT',
10
+ 'Access-Control-Allow-Origin': event.headers?.Origin || event.headers?.origin || '*',
11
+ };
12
+ if (!event.body) {
13
+ const response = {
14
+ statusCode: 200,
15
+ body: null,
16
+ headers: headers,
17
+ };
18
+ return response;
19
+ }
20
+ const input = JSON.parse(event.body);
21
+ console.debug('received event', input);
22
+ await sqs.sendMessageToQueue(input, process.env.SQS_ARENA_URL);
23
+ return {
24
+ statusCode: 200,
25
+ headers: headers,
26
+ body: '',
27
+ };
28
+ };
29
+ //# sourceMappingURL=start-save-arena-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-save-arena-input.js","sourceRoot":"","sources":["../src/start-save-arena-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,GAAU,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IACvC,MAAM,GAAG,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC/D,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 { Input } 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: Input = JSON.parse(event.body);\r\n\tconsole.debug('received event', input);\r\n\tawait sqs.sendMessageToQueue(input, process.env.SQS_ARENA_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"]}
@@ -0,0 +1,3 @@
1
+ import { PatchInfo } from '@firestone-hs/aws-lambda-utils';
2
+ import { InputArena } from '../input-arena-model';
3
+ export declare const processArenaHeroes: (input: InputArena, arenaPatch: PatchInfo) => Promise<void>;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processArenaHeroes = void 0;
4
+ const aws_lambda_utils_1 = require("@firestone-hs/aws-lambda-utils");
5
+ const zlib_1 = require("zlib");
6
+ const utils_1 = require("../utils");
7
+ const bucket = 'static.zerotoheroes.com';
8
+ const fileKey = 'hearthstone/data/arena/strategies/hero-strategies.gz.json';
9
+ const processArenaHeroes = async (input, arenaPatch) => {
10
+ const author = input.author;
11
+ console.debug('processing', input);
12
+ const existing = await loadExistingInfo();
13
+ const existingHeroes = existing.heroes;
14
+ console.debug('loaded existing info', existing);
15
+ console.debug('iterating', input.data);
16
+ for (const heroTip of input.data) {
17
+ console.debug('processing hero', heroTip);
18
+ let existingCardTip = existingHeroes.find((t) => t.heroClass === heroTip.heroClass);
19
+ console.debug('existing hero', existingCardTip);
20
+ if (!existingCardTip) {
21
+ existingCardTip = {
22
+ heroClass: heroTip.heroClass,
23
+ tips: [],
24
+ };
25
+ existingHeroes.push(existingCardTip);
26
+ }
27
+ if (!!heroTip.tip?.trim()?.length) {
28
+ console.debug('processing tip', heroTip.tip);
29
+ let existingTip = existingCardTip.tips.find((t) => t.author === author);
30
+ console.debug('existing tip', existingTip);
31
+ if (!existingTip) {
32
+ existingTip = {
33
+ author: author,
34
+ };
35
+ existingCardTip.tips.push(existingTip);
36
+ }
37
+ if (!(0, utils_1.deepEqual)(existingTip.tip, heroTip.tip) ||
38
+ (heroTip.patchNumber && existingTip.patchNumber !== heroTip.patchNumber) ||
39
+ (heroTip.date && existingTip.date !== heroTip.date)) {
40
+ console.debug('updating tip', heroTip.tip);
41
+ existingTip.tip = heroTip.tip;
42
+ existingTip.date = heroTip.date;
43
+ existingTip.patchNumber = heroTip.patchNumber;
44
+ }
45
+ }
46
+ else {
47
+ console.debug('removing tip', author);
48
+ existingCardTip.tips = existingCardTip.tips.filter((t) => t.author !== author);
49
+ }
50
+ }
51
+ console.debug('built aggregated tips', existingHeroes);
52
+ await saveInfo({
53
+ heroes: existingHeroes,
54
+ });
55
+ console.debug('saved aggregated tips');
56
+ };
57
+ exports.processArenaHeroes = processArenaHeroes;
58
+ const loadExistingInfo = async () => {
59
+ const s3 = new aws_lambda_utils_1.S3();
60
+ try {
61
+ const asString = await s3.readGzipContent(bucket, fileKey, 5);
62
+ if (!asString) {
63
+ return { heroes: [] };
64
+ }
65
+ return JSON.parse(asString);
66
+ }
67
+ catch (e) {
68
+ console.error('error loading existing info', e);
69
+ return { heroes: [] };
70
+ }
71
+ };
72
+ const saveInfo = async (info) => {
73
+ const s3 = new aws_lambda_utils_1.S3();
74
+ await s3.writeFile((0, zlib_1.gzipSync)(JSON.stringify(info)), bucket, fileKey, 'application/json', 'gzip');
75
+ };
76
+ //# sourceMappingURL=arena-heroes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arena-heroes.js","sourceRoot":"","sources":["../../src/types/arena-heroes.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAC/D,+BAAgC;AAGhC,oCAAqC;AAErC,MAAM,MAAM,GAAG,yBAAyB,CAAC;AACzC,MAAM,OAAO,GAAG,2DAA2D,CAAC;AAErE,MAAM,kBAAkB,GAAG,KAAK,EAAE,KAAiB,EAAE,UAAqB,EAAE,EAAE;IACpF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAwB,MAAM,gBAAgB,EAAE,CAAC;IAC/D,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC;IACvC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;IAChD,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IACtC,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;QACjC,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAC1C,IAAI,eAAe,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;QACpF,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QAChD,IAAI,CAAC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firestone-hs/aws-lambda-utils';\r\nimport { gzipSync } from 'zlib';\r\nimport { ArenaHeroStrategies, ArenaHeroTip } from '../data-model';\r\nimport { InputArena } from '../input-arena-model';\r\nimport { deepEqual } from '../utils';\r\n\r\nconst bucket = 'static.zerotoheroes.com';\r\nconst fileKey = 'hearthstone/data/arena/strategies/hero-strategies.gz.json';\r\n\r\nexport const processArenaHeroes = async (input: InputArena, arenaPatch: PatchInfo) => {\r\n\tconst author = input.author;\r\n\tconsole.debug('processing', input);\r\n\tconst existing: ArenaHeroStrategies = await loadExistingInfo();\r\n\tconst existingHeroes = existing.heroes;\r\n\tconsole.debug('loaded existing info', existing);\r\n\tconsole.debug('iterating', input.data)\r\n\tfor (const heroTip of input.data) {\r\n\t\tconsole.debug('processing hero', heroTip);\r\n\t\tlet existingCardTip = existingHeroes.find((t) => t.heroClass === heroTip.heroClass);\r\n\t\tconsole.debug('existing hero', existingCardTip);\r\n\t\tif (!existingCardTip) {\r\n\t\t\texistingCardTip = {\r\n\t\t\t\theroClass: heroTip.heroClass,\r\n\t\t\t\ttips: [],\r\n\t\t\t};\r\n\t\t\texistingHeroes.push(existingCardTip);\r\n\t\t}\r\n\t\tif (!!heroTip.tip?.trim()?.length) {\r\n\t\t\tconsole.debug('processing tip', heroTip.tip);\r\n\t\t\tlet existingTip = existingCardTip.tips.find((t) => t.author === author);\r\n\t\t\tconsole.debug('existing tip', existingTip);\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} as ArenaHeroTip;\r\n\t\t\t\texistingCardTip.tips.push(existingTip);\r\n\t\t\t}\r\n\t\t\t// existingTip.language = 'enUS';\r\n\t\t\tif (\r\n\t\t\t\t!deepEqual(existingTip.tip, heroTip.tip) ||\r\n\t\t\t\t(heroTip.patchNumber && existingTip.patchNumber !== heroTip.patchNumber) ||\r\n\t\t\t\t(heroTip.date && existingTip.date !== heroTip.date)\r\n\t\t\t) {\r\n\t\t\t\tconsole.debug('updating tip', heroTip.tip);\r\n\t\t\t\texistingTip.tip = heroTip.tip;\r\n\t\t\t\texistingTip.date = heroTip.date;\r\n\t\t\t\texistingTip.patchNumber = heroTip.patchNumber;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tconsole.debug('removing tip', author);\r\n\t\t\texistingCardTip.tips = existingCardTip.tips.filter((t) => t.author !== author);\r\n\t\t}\r\n\t}\r\n\tconsole.debug('built aggregated tips', existingHeroes);\r\n\tawait saveInfo({\r\n\t\theroes: existingHeroes,\r\n\t});\r\n\tconsole.debug('saved aggregated tips');\r\n};\r\n\r\nconst loadExistingInfo = async (): Promise<ArenaHeroStrategies> => {\r\n\tconst s3 = new S3();\r\n\t// console.debug('created s3');\r\n\ttry {\r\n\r\n\t\tconst asString = await s3.readGzipContent(bucket, fileKey, 5);\r\n\t\t// console.debug('loaded existing info', asString?.length);\r\n\t\tif (!asString) {\r\n\t\t\treturn { heroes: [] };\r\n\t\t}\r\n\t\treturn JSON.parse(asString);\r\n\t} catch (e) {\r\n\t\tconsole.error('error loading existing info', e);\r\n\t\treturn { heroes: [] };\r\n\t}\r\n};\r\n\r\nconst saveInfo = async (info: ArenaHeroStrategies) => {\r\n\tconst s3 = new S3();\r\n\tawait s3.writeFile(gzipSync(JSON.stringify(info)), bucket, fileKey, 'application/json', 'gzip');\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/content-craetor-input",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",