@hestia-earth/api 0.9.32 → 0.9.35-0

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.
@@ -0,0 +1,2 @@
1
+ import { Product } from '@hestia-earth/schema';
2
+ export declare const getPrimaryProduct: (products?: Product[]) => Product;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrimaryProduct = void 0;
4
+ exports.getPrimaryProduct = function (products) { return (products || []).find(function (product) { return product.primary === true; }); };
@@ -1,5 +1,6 @@
1
1
  import { BaseModel } from '../../db/model.base';
2
2
  import { User } from '../../users/model/model';
3
+ export declare const mb = 1048576;
3
4
  export declare const MAX_SIZE = 2;
4
5
  export declare const MAX_SIZE_MB: number;
5
6
  export declare const sizeInMb: (size: number) => number;
@@ -20,12 +20,12 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
20
20
  return r;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.isDraft = exports.isValidated = exports.isFolderUpload = exports.isAggregation = exports.aggregationFolder = exports.isGlossary = exports.glossaryFolder = exports.filenameFromPath = exports.rootFolderFromPath = exports.folderFromPath = exports.replaceInvalidChars = exports.validPathChars = exports.fileToExt = exports.filepathSearch = exports.filenameSearch = exports.File = exports.FilePipelineError = exports.FilePipelineProgress = exports.FilePipelineStatus = exports.FileError = exports.FileStatus = exports.FileProgress = exports.HestiaExtensions = exports.SupportedExtensions = exports.sizeInMb = exports.MAX_SIZE_MB = exports.MAX_SIZE = void 0;
23
+ exports.isDraft = exports.isValidated = exports.isFolderUpload = exports.isAggregation = exports.aggregationFolder = exports.isGlossary = exports.glossaryFolder = exports.filenameFromPath = exports.rootFolderFromPath = exports.folderFromPath = exports.replaceInvalidChars = exports.validPathChars = exports.fileToExt = exports.filepathSearch = exports.filenameSearch = exports.File = exports.FilePipelineError = exports.FilePipelineProgress = exports.FilePipelineStatus = exports.FileError = exports.FileStatus = exports.FileProgress = exports.HestiaExtensions = exports.SupportedExtensions = exports.sizeInMb = exports.MAX_SIZE_MB = exports.MAX_SIZE = exports.mb = void 0;
24
24
  var model_base_1 = require("../../db/model.base");
25
- var mb = 1048576;
25
+ exports.mb = 1048576;
26
26
  exports.MAX_SIZE = 2;
27
- exports.MAX_SIZE_MB = 2 * mb;
28
- exports.sizeInMb = function (size) { return Math.round((size / mb) * 1000) / 1000; };
27
+ exports.MAX_SIZE_MB = 2 * exports.mb;
28
+ exports.sizeInMb = function (size) { return Math.round((size / exports.mb) * 1000) / 1000; };
29
29
  var SupportedExtensions;
30
30
  (function (SupportedExtensions) {
31
31
  SupportedExtensions["xlsx"] = "xlsx";
package/dist/models.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './migrations/model/model';
5
5
  export * from './nodes/model/model';
6
6
  export * from './reconciliations/model/model';
7
7
  export * from './users/model/model';
8
+ export * from './cycles/model/model';
package/dist/models.js CHANGED
@@ -17,3 +17,4 @@ __exportStar(require("./migrations/model/model"), exports);
17
17
  __exportStar(require("./nodes/model/model"), exports);
18
18
  __exportStar(require("./reconciliations/model/model"), exports);
19
19
  __exportStar(require("./users/model/model"), exports);
20
+ __exportStar(require("./cycles/model/model"), exports);
@@ -16,4 +16,4 @@ export declare const parseLogMissingLookups: (data: string) => {
16
16
  termId: any;
17
17
  column: any;
18
18
  }[];
19
- export declare const groupLogsByModel: (data: string) => any;
19
+ export declare const groupLogsByModel: (type: NodeType, data: string) => any;
@@ -65,12 +65,13 @@ exports.paramToNodeType = function (type) { return Object.values(schema_1.NodeTy
65
65
  var csvValue = function (value) { return (value || '').replace('[', '').replace(']', ''); };
66
66
  var parseMessage = function (message) {
67
67
  try {
68
- return JSON.parse(message).message.split(',').reduce(function (prev, parts) {
68
+ var data = JSON.parse(message);
69
+ return data.message.split(',').reduce(function (prev, parts) {
69
70
  var _a;
70
71
  var _b = parts.split('='), key = _b[0], value = _b[1];
71
72
  var val = csvValue(value);
72
73
  return __assign(__assign({}, prev), (key && val ? (_a = {}, _a[key.trim()] = val, _a) : {}));
73
- }, {});
74
+ }, { logger: data.logger });
74
75
  }
75
76
  catch (err) {
76
77
  return {};
@@ -95,15 +96,21 @@ exports.parseLogMissingLookups = function (data) {
95
96
  var messages = lines.map(parseMessage).filter(function (v) { return Object.keys(v).length > 1; });
96
97
  return utils_1.unique(messages.map(parseLookup));
97
98
  };
98
- exports.groupLogsByModel = function (data) {
99
+ var filterByType = function (expectedType, _a) {
100
+ var type = _a.type;
101
+ return !type ||
102
+ type === expectedType ||
103
+ Object.values(schema_1.SchemaType).filter(function (t) { return !schema_1.isTypeNode(t); }).includes(type);
104
+ };
105
+ exports.groupLogsByModel = function (type, data) {
99
106
  return data.split('\n')
100
- .filter(function (log) { return log.includes('hestia_earth.models'); })
101
107
  .map(parseMessage)
102
- .filter(function (v) { return !!(v === null || v === void 0 ? void 0 : v.term) && !!(v === null || v === void 0 ? void 0 : v.model); })
108
+ .filter(function (v) { return !!(v === null || v === void 0 ? void 0 : v.term) && !!(v === null || v === void 0 ? void 0 : v.model) && filterByType(type, v); })
103
109
  .reduce(function (group, _a) {
104
- var term = _a.term, model = _a.model, key = _a.key, should_run = _a.should_run, input = _a.input, property = _a.property, log = __rest(_a, ["term", "model", "key", "should_run", "input", "property"]);
105
- var modelKey = key || model;
106
- var isKey = !!key;
110
+ var logger = _a.logger, term = _a.term, model = _a.model, key = _a.key, should_run = _a.should_run, input = _a.input, property = _a.property, log = __rest(_a, ["logger", "term", "model", "key", "should_run", "input", "property"]);
111
+ var isOrchestrator = logger.includes('orchestrator');
112
+ var modelKey = isOrchestrator ? model : key || model;
113
+ var isKey = !isOrchestrator && !!key;
107
114
  group[term] = group[term] || {};
108
115
  group[term][modelKey] = group[term][modelKey] || __assign({ isKey: isKey }, (isKey ? { model: model } : {}));
109
116
  if (typeof input !== 'undefined') {
@@ -117,7 +124,11 @@ exports.groupLogsByModel = function (data) {
117
124
  ]));
118
125
  }
119
126
  if (typeof should_run !== 'undefined') {
120
- group[term][modelKey] = __assign(__assign(__assign({}, group[term][modelKey]), log), { shouldRun: should_run === 'True' });
127
+ var shouldRun = should_run === 'True';
128
+ group[term][modelKey] = isOrchestrator ?
129
+ {
130
+ shouldRunOrchestrator: shouldRun
131
+ } : __assign(__assign(__assign({}, group[term][modelKey]), log), { shouldRun: shouldRun });
121
132
  }
122
133
  else if ('requirements' in log) {
123
134
  var requirements = log.requirements, logData = __rest(log, ["requirements"]);
@@ -128,7 +139,7 @@ exports.groupLogsByModel = function (data) {
128
139
  parseLookup(log)
129
140
  ]));
130
141
  }
131
- else {
142
+ else if (!isOrchestrator) {
132
143
  group[term][modelKey].logs = __assign(__assign({}, (group[term][modelKey].logs || {})), log);
133
144
  }
134
145
  return group;
@@ -1,6 +1,17 @@
1
1
  import { BaseModel } from '../../db/model.base';
2
+ export declare enum ReconciliationLevel {
3
+ success = "success",
4
+ warning = "warning",
5
+ danger = "danger"
6
+ }
2
7
  export declare class Reconciliation extends BaseModel {
3
8
  idExpected: string;
4
9
  idRecalculated: string;
5
10
  name: string;
11
+ level?: ReconciliationLevel;
12
+ details?: any;
13
+ error?: {
14
+ message: string;
15
+ subMessages: string[];
16
+ };
6
17
  }
@@ -13,8 +13,14 @@ var __extends = (this && this.__extends) || (function () {
13
13
  };
14
14
  })();
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.Reconciliation = void 0;
16
+ exports.Reconciliation = exports.ReconciliationLevel = void 0;
17
17
  var model_base_1 = require("../../db/model.base");
18
+ var ReconciliationLevel;
19
+ (function (ReconciliationLevel) {
20
+ ReconciliationLevel["success"] = "success";
21
+ ReconciliationLevel["warning"] = "warning";
22
+ ReconciliationLevel["danger"] = "danger";
23
+ })(ReconciliationLevel = exports.ReconciliationLevel || (exports.ReconciliationLevel = {}));
18
24
  var Reconciliation = (function (_super) {
19
25
  __extends(Reconciliation, _super);
20
26
  function Reconciliation() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/api",
3
- "version": "0.9.32",
3
+ "version": "0.9.35-0",
4
4
  "description": "Hestia API definitions",
5
5
  "main": "dist/models.js",
6
6
  "typings": "dist/models.d.ts",
@@ -33,9 +33,10 @@
33
33
  "@hestia-earth/schema": "^7.6.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@commitlint/cli": "^12.1.4",
37
- "@commitlint/config-conventional": "^12.1.4",
36
+ "@commitlint/cli": "^16.2.4",
37
+ "@commitlint/config-conventional": "^16.2.4",
38
38
  "@elastic/elasticsearch": "7.13.0",
39
+ "@hestia-earth/eslint-config": "0.0.3",
39
40
  "@hestia-earth/json-schema": "^7.6.1",
40
41
  "@hestia-earth/schema-convert": "^7.6.1",
41
42
  "@hestia-earth/schema-validation": "^7.6.1",
@@ -62,8 +63,8 @@
62
63
  "@types/request": "^2.48.8",
63
64
  "@types/request-promise-native": "^1.0.18",
64
65
  "@types/winston": "^2.4.4",
65
- "@typescript-eslint/eslint-plugin": "^4.33.0",
66
- "@typescript-eslint/parser": "^4.33.0",
66
+ "@typescript-eslint/eslint-plugin": "^5.23.0",
67
+ "@typescript-eslint/parser": "^5.23.0",
67
68
  "aws-sdk": "^2.1092.0",
68
69
  "axios": "^0.21.4",
69
70
  "body-parser": "^1.19.2",