@hestia-earth/api 0.9.34 → 0.9.35-2

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,4 +1,5 @@
1
1
  import { SchemaType, NodeType } from '@hestia-earth/schema';
2
+ export declare const blankNodeTypes: SchemaType[];
2
3
  export declare enum DataState {
3
4
  original = "original",
4
5
  recalculated = "recalculated",
@@ -30,10 +30,11 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
30
30
  };
31
31
  var _a;
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.groupLogsByModel = exports.parseLogMissingLookups = exports.paramToNodeType = exports.nodeTypeToParam = exports.pathWithState = exports.allowedDataStates = exports.dataStatesTypeMapping = exports.DataState = void 0;
33
+ exports.groupLogsByModel = exports.parseLogMissingLookups = exports.paramToNodeType = exports.nodeTypeToParam = exports.pathWithState = exports.allowedDataStates = exports.dataStatesTypeMapping = exports.DataState = exports.blankNodeTypes = void 0;
34
34
  var schema_1 = require("@hestia-earth/schema");
35
35
  var utils_1 = require("@hestia-earth/utils");
36
36
  var model_1 = require("../../files/model/model");
37
+ exports.blankNodeTypes = Object.values(schema_1.SchemaType).filter(function (t) { return !schema_1.isTypeNode(t); });
37
38
  var DataState;
38
39
  (function (DataState) {
39
40
  DataState["original"] = "original";
@@ -96,46 +97,69 @@ exports.parseLogMissingLookups = function (data) {
96
97
  var messages = lines.map(parseMessage).filter(function (v) { return Object.keys(v).length > 1; });
97
98
  return utils_1.unique(messages.map(parseLookup));
98
99
  };
100
+ var schemaTypesLowerCase = Object.values(schema_1.SchemaType).map(function (v) { return v.toLowerCase(); });
101
+ var blankNodeTypesLowerCase = exports.blankNodeTypes.map(function (v) { return v.toLowerCase(); });
102
+ var omitLogKeys = function (log) {
103
+ return Object.fromEntries(Object.entries(log).filter(function (_a) {
104
+ var key = _a[0];
105
+ return !schemaTypesLowerCase.includes(key);
106
+ }));
107
+ };
108
+ var includeBlankNodes = function (logs, log) {
109
+ return Object
110
+ .keys(log)
111
+ .filter(function (key) { return blankNodeTypesLowerCase.includes(key); })
112
+ .reduce(function (prev, key) {
113
+ var _a;
114
+ return (__assign(__assign({}, prev), (_a = {}, _a[key] = utils_1.unique(__spreadArrays(((typeof prev[key] === 'string' ? [prev[key]] : prev[key]) || []), [
115
+ log[key]
116
+ ])), _a)));
117
+ }, logs);
118
+ };
119
+ var groupLog = function (group, _a) {
120
+ var logger = _a.logger, term = _a.term, model = _a.model, key = _a.key, should_run = _a.should_run, log = __rest(_a, ["logger", "term", "model", "key", "should_run"]);
121
+ var isOrchestrator = logger.includes('orchestrator');
122
+ var modelKey = isOrchestrator ? model : key || model;
123
+ var isKey = !isOrchestrator && !!key;
124
+ group[term] = group[term] || {};
125
+ group[term][modelKey] = group[term][modelKey] || __assign({ isKey: isKey }, (isKey ? { model: model } : {}));
126
+ group[term][modelKey] = includeBlankNodes(group[term][modelKey], log);
127
+ if (typeof should_run !== 'undefined') {
128
+ var shouldRun = should_run === 'True';
129
+ group[term][modelKey] = isOrchestrator ? __assign(__assign({}, group[term][modelKey]), { shouldRunOrchestrator: shouldRun }) : __assign(__assign(__assign({}, group[term][modelKey]), omitLogKeys(log)), { shouldRun: shouldRun });
130
+ }
131
+ else if ('requirements' in log) {
132
+ var requirements = log.requirements, logData = __rest(log, ["requirements"]);
133
+ group[term][modelKey].requirements = __assign(__assign({}, (group[term][modelKey].requirements || {})), logData);
134
+ }
135
+ else if (missingLookupPrefix in log) {
136
+ group[term][modelKey].missingLookups = utils_1.unique(__spreadArrays((group[term][modelKey].missingLookups || []), [
137
+ parseLookup(log)
138
+ ]));
139
+ }
140
+ else if (!isOrchestrator) {
141
+ group[term][modelKey].logs = __assign(__assign({}, (group[term][modelKey].logs || {})), omitLogKeys(log));
142
+ }
143
+ return group;
144
+ };
145
+ var groupLogTransformation = function (group, log) {
146
+ var id = log.transformation;
147
+ group[id] = groupLog(group[id] || {}, log);
148
+ Object.entries(group[id]).map(function (_a) {
149
+ var term = _a[0], models = _a[1];
150
+ return Object.keys(models).map(function (model) {
151
+ if (group[term][model]) {
152
+ group[term][model].transformation = utils_1.unique(__spreadArrays((group[term][model].transformation || []), [
153
+ id
154
+ ]));
155
+ }
156
+ });
157
+ });
158
+ return group;
159
+ };
99
160
  exports.groupLogsByModel = function (data) {
100
161
  return data.split('\n')
101
162
  .map(parseMessage)
102
163
  .filter(function (v) { return !!(v === null || v === void 0 ? void 0 : v.term) && !!(v === null || v === void 0 ? void 0 : v.model); })
103
- .reduce(function (group, _a) {
104
- 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"]);
105
- var isOrchestrator = logger.includes('orchestrator');
106
- var modelKey = isOrchestrator ? model : key || model;
107
- var isKey = !isOrchestrator && !!key;
108
- group[term] = group[term] || {};
109
- group[term][modelKey] = group[term][modelKey] || __assign({ isKey: isKey }, (isKey ? { model: model } : {}));
110
- if (typeof input !== 'undefined') {
111
- group[term][modelKey].input = utils_1.unique(__spreadArrays((group[term][modelKey].input || []), [
112
- input
113
- ]));
114
- }
115
- if (typeof property !== 'undefined') {
116
- group[term][modelKey].property = utils_1.unique(__spreadArrays((group[term][modelKey].property || []), [
117
- property
118
- ]));
119
- }
120
- if (typeof should_run !== 'undefined') {
121
- var shouldRun = should_run === 'True';
122
- group[term][modelKey] = isOrchestrator ?
123
- {
124
- shouldRunOrchestrator: shouldRun
125
- } : __assign(__assign(__assign({}, group[term][modelKey]), log), { shouldRun: shouldRun });
126
- }
127
- else if ('requirements' in log) {
128
- var requirements = log.requirements, logData = __rest(log, ["requirements"]);
129
- group[term][modelKey].requirements = __assign(__assign({}, (group[term][modelKey].requirements || {})), logData);
130
- }
131
- else if (missingLookupPrefix in log) {
132
- group[term][modelKey].missingLookups = utils_1.unique(__spreadArrays((group[term][modelKey].missingLookups || []), [
133
- parseLookup(log)
134
- ]));
135
- }
136
- else if (!isOrchestrator) {
137
- group[term][modelKey].logs = __assign(__assign({}, (group[term][modelKey].logs || {})), log);
138
- }
139
- return group;
140
- }, {});
164
+ .reduce(function (group, log) { return 'transformation' in log ? groupLogTransformation(group, log) : groupLog(group, log); }, {});
141
165
  };
@@ -10,5 +10,8 @@ export declare class Reconciliation extends BaseModel {
10
10
  name: string;
11
11
  level?: ReconciliationLevel;
12
12
  details?: any;
13
- error?: string;
13
+ error?: {
14
+ message: string;
15
+ subMessages: string[];
16
+ };
14
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/api",
3
- "version": "0.9.34",
3
+ "version": "0.9.35-2",
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",