@firestone-hs/reference-data 0.1.245 → 0.1.246

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.
@@ -20,9 +20,18 @@ async function httpWithRetries(request, retriesLeft = 1, timeBetweenRetries = 10
20
20
  console.error('could not load cards', request);
21
21
  return null;
22
22
  }
23
- const result = await http(request);
24
- if (!result) {
23
+ let result = null;
24
+ try {
25
+ result = await http(request);
26
+ console.log('loaded cards', result === null || result === void 0 ? void 0 : result.length);
27
+ }
28
+ catch (e) {
29
+ console.warn('Exception while getting cards', e);
30
+ }
31
+ if (!result || result.startsWith('<')) {
32
+ console.log('no result, sleeping');
25
33
  await sleep(timeBetweenRetries);
34
+ console.log('retrying');
26
35
  return httpWithRetries(request, retriesLeft - 1);
27
36
  }
28
37
  return result;
@@ -34,7 +43,8 @@ async function http(request) {
34
43
  .then((response) => {
35
44
  return response.text();
36
45
  }, (error) => {
37
- console.warn('could not load cards', error, error.message);
46
+ console.warn('could not load cards', error, error.message, JSON.stringify(error));
47
+ return null;
38
48
  })
39
49
  .then((body) => {
40
50
  resolve(body);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/services/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAEhC,SAAS,cAAc,CAAI,KAAmB,EAAE,aAAqB;IACpE,MAAM,WAAW,GAAQ,CAAC,GAAG,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,OAAO,WAAW,CAAC,MAAM,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAwCQ,wCAAc;AAtCvB,KAAK,UAAU,eAAe,CAAC,OAAe,EAAE,WAAW,GAAG,CAAC,EAAE,kBAAkB,GAAG,IAAI;IACzF,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAC5E,IAAI,WAAW,IAAI,CAAC,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;KACZ;IAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE;QACZ,MAAM,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAChC,OAAO,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,CAAC,CAAC,CAAC;KACjD;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAyB8B,0CAAe;AAvB9C,KAAK,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,qBAAK,CAAC,OAAO,CAAC;aACZ,IAAI,CACJ,CAAC,QAAQ,EAAE,EAAE;YAEZ,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACT,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5D,CAAC,CACD;aACA,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAEd,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACJ,CAAC;AAMwB,oBAAI;AAJ7B,KAAK,UAAU,KAAK,CAAC,EAAE;IACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAE+C,sBAAK","sourcesContent":["import fetch from 'cross-fetch';\r\n\r\nfunction partitionArray<T>(array: readonly T[], partitionSize: number): readonly T[][] {\r\n\tconst workingCopy: T[] = [...array];\r\n\tconst result: T[][] = [];\r\n\twhile (workingCopy.length) {\r\n\t\tresult.push(workingCopy.splice(0, partitionSize));\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nasync function httpWithRetries(request: string, retriesLeft = 1, timeBetweenRetries = 1000): Promise<any> {\r\n\tconsole.log('fetch with retries', request, retriesLeft, timeBetweenRetries);\r\n\tif (retriesLeft <= 0) {\r\n\t\tconsole.error('could not load cards', request);\r\n\t\treturn null;\r\n\t}\r\n\r\n\tconst result = await http(request);\r\n\tif (!result) {\r\n\t\tawait sleep(timeBetweenRetries);\r\n\t\treturn httpWithRetries(request, retriesLeft - 1);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nasync function http(request: string): Promise<any> {\r\n\treturn new Promise((resolve) => {\r\n\t\tfetch(request)\r\n\t\t\t.then(\r\n\t\t\t\t(response) => {\r\n\t\t\t\t\t// console.log('received response, reading text body');\r\n\t\t\t\t\treturn response.text();\r\n\t\t\t\t},\r\n\t\t\t\t(error) => {\r\n\t\t\t\t\tconsole.warn('could not load cards', error, error.message);\r\n\t\t\t\t},\r\n\t\t\t)\r\n\t\t\t.then((body) => {\r\n\t\t\t\t// console.log('sending back body', body && body.length);\r\n\t\t\t\tresolve(body);\r\n\t\t\t});\r\n\t});\r\n}\r\n\r\nasync function sleep(ms) {\r\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\r\n}\r\n\r\nexport { partitionArray, http, httpWithRetries, sleep };\r\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/services/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAEhC,SAAS,cAAc,CAAI,KAAmB,EAAE,aAAqB;IACpE,MAAM,WAAW,GAAQ,CAAC,GAAG,KAAK,CAAC,CAAC;IACpC,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,OAAO,WAAW,CAAC,MAAM,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EA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CAAC;QACxB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACT,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YAClF,OAAO,IAAI,CAAC;QACb,CAAC,CACD;aACA,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAEd,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACJ,CAAC;AAMwB,oBAAI;AAJ7B,KAAK,UAAU,KAAK,CAAC,EAAE;IACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAE+C,sBAAK","sourcesContent":["import fetch from 'cross-fetch';\r\n\r\nfunction partitionArray<T>(array: readonly T[], partitionSize: number): readonly T[][] {\r\n\tconst workingCopy: T[] = [...array];\r\n\tconst result: T[][] = [];\r\n\twhile (workingCopy.length) {\r\n\t\tresult.push(workingCopy.splice(0, partitionSize));\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nasync function httpWithRetries(request: string, retriesLeft = 1, timeBetweenRetries = 1000): Promise<any> {\r\n\tconsole.log('fetch with retries', request, retriesLeft, timeBetweenRetries);\r\n\tif (retriesLeft <= 0) {\r\n\t\tconsole.error('could not load cards', request);\r\n\t\treturn null;\r\n\t}\r\n\r\n\tlet result = null;\r\n\ttry {\r\n\t\tresult = await http(request);\r\n\t\tconsole.log('loaded cards', result?.length);\r\n\t} catch (e) {\r\n\t\tconsole.warn('Exception while getting cards', e);\r\n\t}\r\n\tif (!result || result.startsWith('<')) {\r\n\t\tconsole.log('no result, sleeping');\r\n\t\tawait sleep(timeBetweenRetries);\r\n\t\tconsole.log('retrying');\r\n\t\treturn httpWithRetries(request, retriesLeft - 1);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nasync function http(request: string): Promise<any> {\r\n\treturn new Promise((resolve) => {\r\n\t\tfetch(request)\r\n\t\t\t.then(\r\n\t\t\t\t(response) => {\r\n\t\t\t\t\t// console.log('received response, reading text body');\r\n\t\t\t\t\treturn response.text();\r\n\t\t\t\t},\r\n\t\t\t\t(error) => {\r\n\t\t\t\t\tconsole.warn('could not load cards', error, error.message, JSON.stringify(error));\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t},\r\n\t\t\t)\r\n\t\t\t.then((body) => {\r\n\t\t\t\t// console.log('sending back body', body && body.length);\r\n\t\t\t\tresolve(body);\r\n\t\t\t});\r\n\t});\r\n}\r\n\r\nasync function sleep(ms) {\r\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\r\n}\r\n\r\nexport { partitionArray, http, httpWithRetries, sleep };\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestone-hs/reference-data",
3
- "version": "0.1.245",
3
+ "version": "0.1.246",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "lint": "eslint --color --fix --ext .ts .",