@hestia-earth/api 0.25.45 → 0.25.47
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.
- package/dist/aggregations/model/model.d.ts +8 -5
- package/dist/aggregations/model/model.js +30 -39
- package/dist/analyses/model/model.js +11 -24
- package/dist/api-calls/model/model.js +6 -23
- package/dist/cycles/model/model.js +1 -1
- package/dist/db/model.base.js +5 -5
- package/dist/earth-engine/model/model.js +2 -2
- package/dist/files/model/model.d.ts +1 -1
- package/dist/files/model/model.js +133 -174
- package/dist/migrations/model/model.js +6 -24
- package/dist/nodes/model/model.js +58 -94
- package/dist/reconciliations/model/model.js +13 -24
- package/dist/reconciliations/model/validations.js +51 -77
- package/dist/settings/model/model.js +7 -24
- package/dist/users/model/model.d.ts +4 -4
- package/dist/users/model/model.js +71 -77
- package/package.json +28 -19
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { BaseModel } from '../../db/model.base';
|
|
2
2
|
import { status, pipelineStatus } from '../../files/model/model';
|
|
3
|
+
export interface IAggregationMetadata {
|
|
4
|
+
slackThreadTs?: string;
|
|
5
|
+
totalIterations?: number;
|
|
6
|
+
currentIterations?: number;
|
|
7
|
+
missingIterations?: number[];
|
|
8
|
+
}
|
|
3
9
|
export declare class Aggregation extends BaseModel {
|
|
4
10
|
folder: string;
|
|
5
11
|
filename: string;
|
|
@@ -7,10 +13,7 @@ export declare class Aggregation extends BaseModel {
|
|
|
7
13
|
validatedAt?: Date;
|
|
8
14
|
status?: status;
|
|
9
15
|
pipelineStatus?: pipelineStatus;
|
|
10
|
-
metadata?:
|
|
11
|
-
totalIterations?: number;
|
|
12
|
-
currentIterations?: number;
|
|
13
|
-
};
|
|
16
|
+
metadata?: IAggregationMetadata;
|
|
14
17
|
readonly productId: string;
|
|
15
18
|
readonly countryId: string;
|
|
16
19
|
readonly startYear: number;
|
|
@@ -18,4 +21,4 @@ export declare class Aggregation extends BaseModel {
|
|
|
18
21
|
}
|
|
19
22
|
export declare const defaultAggregationPeriod = 20;
|
|
20
23
|
export declare const aggregationFolderFromFilename: (filename: string) => string;
|
|
21
|
-
export declare const parseAggregationValues: (value: string) => Pick<Aggregation,
|
|
24
|
+
export declare const parseAggregationValues: (value: string) => Pick<Aggregation, "productId" | "countryId" | "startYear" | "endYear">;
|
|
@@ -1,51 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.parseAggregationValues = exports.aggregationFolderFromFilename = exports.defaultAggregationPeriod = exports.Aggregation = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
const utils_1 = require("@hestia-earth/utils");
|
|
5
|
+
const model_base_1 = require("../../db/model.base");
|
|
6
|
+
const model_1 = require("../../files/model/model");
|
|
7
|
+
class Aggregation extends model_base_1.BaseModel {
|
|
8
|
+
folder;
|
|
9
|
+
filename;
|
|
10
|
+
filepath;
|
|
11
|
+
validatedAt;
|
|
12
|
+
status;
|
|
13
|
+
pipelineStatus;
|
|
14
|
+
metadata;
|
|
15
|
+
productId;
|
|
16
|
+
countryId;
|
|
17
|
+
startYear;
|
|
18
|
+
endYear;
|
|
19
|
+
}
|
|
29
20
|
exports.Aggregation = Aggregation;
|
|
30
21
|
exports.defaultAggregationPeriod = 20;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
const aggregationFolderFromFilename = (filename) => {
|
|
23
|
+
const name = (0, model_1.filenameWithoutExt)(filename);
|
|
24
|
+
const parts = name.split('-');
|
|
25
|
+
const timestamp = parts.pop();
|
|
35
26
|
return timestamp.length === 8 ? parts.join('-') : name;
|
|
36
27
|
};
|
|
37
28
|
exports.aggregationFolderFromFilename = aggregationFolderFromFilename;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
const parseAggregationValues = (value) => {
|
|
30
|
+
const [productId, ...parts] = (0, exports.aggregationFolderFromFilename)(value).split('-');
|
|
31
|
+
const countryId = parts.filter(v => !(0, utils_1.isNumber)(v)).join('-');
|
|
32
|
+
const endYear = +parts.pop();
|
|
33
|
+
const lastPart = parts.pop();
|
|
34
|
+
const startYear = (0, utils_1.isNumber)(lastPart) ? +lastPart : endYear - exports.defaultAggregationPeriod + 1;
|
|
44
35
|
return {
|
|
45
|
-
productId
|
|
46
|
-
countryId
|
|
47
|
-
startYear
|
|
48
|
-
endYear
|
|
36
|
+
productId,
|
|
37
|
+
countryId,
|
|
38
|
+
startYear,
|
|
39
|
+
endYear
|
|
49
40
|
};
|
|
50
41
|
};
|
|
51
42
|
exports.parseAggregationValues = parseAggregationValues;
|
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.Analysis = exports.AnalysisType = void 0;
|
|
19
|
-
|
|
4
|
+
const model_base_1 = require("../../db/model.base");
|
|
20
5
|
var AnalysisType;
|
|
21
6
|
(function (AnalysisType) {
|
|
22
7
|
AnalysisType["gapFilling"] = "gap-filling";
|
|
23
8
|
AnalysisType["quantity"] = "quantity";
|
|
24
9
|
AnalysisType["term"] = "term";
|
|
25
|
-
})(AnalysisType
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
10
|
+
})(AnalysisType || (exports.AnalysisType = AnalysisType = {}));
|
|
11
|
+
class Analysis extends model_base_1.BaseModel {
|
|
12
|
+
cycleId;
|
|
13
|
+
name;
|
|
14
|
+
indicators;
|
|
15
|
+
cycle;
|
|
16
|
+
impactAssessment;
|
|
17
|
+
quantity;
|
|
18
|
+
term;
|
|
19
|
+
}
|
|
33
20
|
exports.Analysis = Analysis;
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.ApiCall = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return ApiCall;
|
|
26
|
-
}(model_base_1.BaseModel));
|
|
4
|
+
const model_base_1 = require("../../db/model.base");
|
|
5
|
+
class ApiCall extends model_base_1.BaseModel {
|
|
6
|
+
url;
|
|
7
|
+
user;
|
|
8
|
+
duration;
|
|
9
|
+
}
|
|
27
10
|
exports.ApiCall = ApiCall;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPrimaryProduct = void 0;
|
|
4
|
-
|
|
4
|
+
const getPrimaryProduct = (products) => (products || []).find(product => product.primary === true);
|
|
5
5
|
exports.getPrimaryProduct = getPrimaryProduct;
|
package/dist/db/model.base.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseModel = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
4
|
+
class BaseModel {
|
|
5
|
+
id;
|
|
6
|
+
createdAt;
|
|
7
|
+
updatedAt;
|
|
8
|
+
}
|
|
9
9
|
exports.BaseModel = BaseModel;
|
|
@@ -6,9 +6,9 @@ var EarthEngineCallType;
|
|
|
6
6
|
EarthEngineCallType["boundary"] = "boundary";
|
|
7
7
|
EarthEngineCallType["coordinates"] = "coordinates";
|
|
8
8
|
EarthEngineCallType["gadm"] = "gadm";
|
|
9
|
-
})(EarthEngineCallType
|
|
9
|
+
})(EarthEngineCallType || (exports.EarthEngineCallType = EarthEngineCallType = {}));
|
|
10
10
|
var EarthEngineType;
|
|
11
11
|
(function (EarthEngineType) {
|
|
12
12
|
EarthEngineType["raster"] = "raster";
|
|
13
13
|
EarthEngineType["vector"] = "vector";
|
|
14
|
-
})(EarthEngineType
|
|
14
|
+
})(EarthEngineType || (exports.EarthEngineType = EarthEngineType = {}));
|
|
@@ -191,7 +191,7 @@ export declare const isAuthorized: ({ authorizedUsers }: Partial<File>, user: Us
|
|
|
191
191
|
export declare const isAssigned: ({ assignedUsers }: Partial<File>, user: User) => boolean;
|
|
192
192
|
export declare const canRemove: (file: Partial<File>, user: User) => boolean;
|
|
193
193
|
export declare const validatedStatuses: FileStatus[];
|
|
194
|
-
export declare const canValidate: ({ status, isPrivate, archived }: Partial<File>, user: Pick<User,
|
|
194
|
+
export declare const canValidate: ({ status, isPrivate, archived }: Partial<File>, user: Pick<User, "role">) => boolean;
|
|
195
195
|
export declare const isValidated: ({ validatedAt, status }: Partial<File>) => boolean;
|
|
196
196
|
export declare const canSubmit: (file: Partial<File>, user: User) => boolean;
|
|
197
197
|
export declare const isDraft: ({ filepath, filename }: Partial<File>) => boolean;
|