@hestia-earth/api 0.28.12 → 0.28.14
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/esm/files/model/llm-preset.js +2 -0
- package/esm/files/model/model.js +1 -0
- package/esm/models.js +1 -0
- package/esm/reports/model.js +23 -0
- package/esm/users/model/model.js +1 -0
- package/files/model/llm-preset.d.ts +2 -0
- package/files/model/llm-preset.js +2 -0
- package/files/model/model.d.ts +2 -0
- package/files/model/model.js +1 -0
- package/models.d.ts +1 -0
- package/models.js +1 -0
- package/package.json +1 -1
- package/reports/model.d.ts +40 -0
- package/reports/model.js +31 -0
- package/users/model/model.d.ts +2 -1
- package/users/model/model.js +1 -0
|
@@ -52,8 +52,10 @@ const validateConfig = (config) => {
|
|
|
52
52
|
isStringRecord(config) || invalid('config must be an object');
|
|
53
53
|
validateEngine('engine', config.engine);
|
|
54
54
|
validateEngine('fixEngine', config.fixEngine);
|
|
55
|
+
validateEngine('narrativeProvider', config.narrativeProvider);
|
|
55
56
|
validateOptionalString('model', config.model);
|
|
56
57
|
validateOptionalString('fixModel', config.fixModel);
|
|
58
|
+
validateOptionalString('narrativeModel', config.narrativeModel);
|
|
57
59
|
validateReviewerList('reviewers', config.reviewers);
|
|
58
60
|
validateReviewerList('pdfConversion', config.pdfConversion);
|
|
59
61
|
validateApiKeys(config.apiKeys);
|
package/esm/files/model/model.js
CHANGED
package/esm/models.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from './glossary/model/model.js';
|
|
|
11
11
|
export * from './migrations/model/model.js';
|
|
12
12
|
export * from './nodes/model/model.js';
|
|
13
13
|
export * from './reconciliations/model/model.js';
|
|
14
|
+
export * from './reports/model.js';
|
|
14
15
|
export * from './settings/model/model.js';
|
|
15
16
|
export * from './source-tracker/model/model.js';
|
|
16
17
|
export * from './url-shortener/model/model.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const reportOptionKeys = [
|
|
2
|
+
'product',
|
|
3
|
+
'limit',
|
|
4
|
+
'feedback',
|
|
5
|
+
'format',
|
|
6
|
+
'noNarrative',
|
|
7
|
+
'noBenchmark',
|
|
8
|
+
'noContributions',
|
|
9
|
+
'radar',
|
|
10
|
+
'refetch'
|
|
11
|
+
];
|
|
12
|
+
export const reportOptionsFromBody = (body = {}) => reportOptionKeys.reduce((acc, key) => (body[key] === undefined ? acc : { ...acc, [key]: body[key] }), {});
|
|
13
|
+
export const reportNarrativeFromPreset = ({ narrativeProvider, narrativeModel } = {}) => ({
|
|
14
|
+
...(narrativeProvider ? { narrativeProvider } : {}),
|
|
15
|
+
...(narrativeModel ? { narrativeModel } : {})
|
|
16
|
+
});
|
|
17
|
+
export const REPORT_FORMATS = ['pdf', 'docx', 'html'];
|
|
18
|
+
export const REPORT_SUPPLEMENTARY_FILENAME = 'report-supplementary.xlsx';
|
|
19
|
+
const reportMainRegExp = new RegExp(`^report\\.(${REPORT_FORMATS.join('|')})$`);
|
|
20
|
+
export const reportKeyPrefix = (subjectId) => `${subjectId}/`;
|
|
21
|
+
const reportFilename = (key) => key.split('/').pop() || '';
|
|
22
|
+
export const reportMainFormat = (key) => reportFilename(key).match(reportMainRegExp)?.[1];
|
|
23
|
+
export const isReportSupplementary = (key) => reportFilename(key) === REPORT_SUPPLEMENTARY_FILENAME;
|
package/esm/users/model/model.js
CHANGED
|
@@ -29,6 +29,7 @@ export var UserPermission;
|
|
|
29
29
|
UserPermission["reconciliationsUpdate"] = "reconciliations-update";
|
|
30
30
|
UserPermission["reconciliationsDelete"] = "reconciliations-delete";
|
|
31
31
|
UserPermission["filesPdfExtract"] = "files-pdf-extract";
|
|
32
|
+
UserPermission["generateReport"] = "generate-report";
|
|
32
33
|
})(UserPermission || (UserPermission = {}));
|
|
33
34
|
export var UserPermissionRequestStatus;
|
|
34
35
|
(function (UserPermissionRequestStatus) {
|
|
@@ -27,6 +27,8 @@ export interface LlmPresetConfig {
|
|
|
27
27
|
pdfConversion?: LlmReviewer[];
|
|
28
28
|
fixEngine?: LlmEngine;
|
|
29
29
|
fixModel?: string;
|
|
30
|
+
narrativeProvider?: LlmEngine;
|
|
31
|
+
narrativeModel?: string;
|
|
30
32
|
apiKeys?: Partial<Record<LlmApiKey, string>>;
|
|
31
33
|
}
|
|
32
34
|
export interface LlmPreset {
|
|
@@ -56,8 +56,10 @@ const validateConfig = (config) => {
|
|
|
56
56
|
isStringRecord(config) || invalid('config must be an object');
|
|
57
57
|
validateEngine('engine', config.engine);
|
|
58
58
|
validateEngine('fixEngine', config.fixEngine);
|
|
59
|
+
validateEngine('narrativeProvider', config.narrativeProvider);
|
|
59
60
|
validateOptionalString('model', config.model);
|
|
60
61
|
validateOptionalString('fixModel', config.fixModel);
|
|
62
|
+
validateOptionalString('narrativeModel', config.narrativeModel);
|
|
61
63
|
validateReviewerList('reviewers', config.reviewers);
|
|
62
64
|
validateReviewerList('pdfConversion', config.pdfConversion);
|
|
63
65
|
validateApiKeys(config.apiKeys);
|
package/files/model/model.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ISourceJSONLD, NodeType } from '@hestia-earth/schema';
|
|
2
2
|
import { BaseModel } from '../../db/model.base';
|
|
3
3
|
import { User, UserRole } from '../../users/model/model';
|
|
4
|
+
import { ReportFiles } from '../../reports/model';
|
|
4
5
|
export declare const mb = 1048576;
|
|
5
6
|
export declare const sizeInMb: (size: number) => number;
|
|
6
7
|
export declare const maxFileSizeMb = 100;
|
|
@@ -162,6 +163,7 @@ export declare class File extends BaseFile {
|
|
|
162
163
|
readonly nbCycles?: number;
|
|
163
164
|
readonly nbImpactAssessments?: number;
|
|
164
165
|
readonly hestiaDataPath?: string;
|
|
166
|
+
readonly report?: ReportFiles;
|
|
165
167
|
}
|
|
166
168
|
export declare const filenameSearch: (...parts: string[]) => {
|
|
167
169
|
[x: string]: {
|
package/files/model/model.js
CHANGED
package/models.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './glossary/model/model';
|
|
|
11
11
|
export * from './migrations/model/model';
|
|
12
12
|
export * from './nodes/model/model';
|
|
13
13
|
export * from './reconciliations/model/model';
|
|
14
|
+
export * from './reports/model';
|
|
14
15
|
export * from './settings/model/model';
|
|
15
16
|
export * from './source-tracker/model/model';
|
|
16
17
|
export * from './url-shortener/model/model';
|
package/models.js
CHANGED
|
@@ -27,6 +27,7 @@ __exportStar(require("./glossary/model/model"), exports);
|
|
|
27
27
|
__exportStar(require("./migrations/model/model"), exports);
|
|
28
28
|
__exportStar(require("./nodes/model/model"), exports);
|
|
29
29
|
__exportStar(require("./reconciliations/model/model"), exports);
|
|
30
|
+
__exportStar(require("./reports/model"), exports);
|
|
30
31
|
__exportStar(require("./settings/model/model"), exports);
|
|
31
32
|
__exportStar(require("./source-tracker/model/model"), exports);
|
|
32
33
|
__exportStar(require("./url-shortener/model/model"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NodeType } from '@hestia-earth/schema';
|
|
2
|
+
export interface ReportNode {
|
|
3
|
+
'@type': NodeType;
|
|
4
|
+
'@id': string;
|
|
5
|
+
}
|
|
6
|
+
export interface ReportOptions {
|
|
7
|
+
product?: string;
|
|
8
|
+
limit?: number;
|
|
9
|
+
feedback?: string;
|
|
10
|
+
format?: string | string[];
|
|
11
|
+
noNarrative?: boolean;
|
|
12
|
+
noBenchmark?: boolean;
|
|
13
|
+
noContributions?: boolean;
|
|
14
|
+
radar?: boolean;
|
|
15
|
+
refetch?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ReportNarrative {
|
|
18
|
+
narrativeProvider?: string;
|
|
19
|
+
narrativeModel?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ReportParams extends ReportOptions, ReportNarrative {
|
|
22
|
+
fileId?: string;
|
|
23
|
+
sourceId?: string;
|
|
24
|
+
nodes?: ReportNode[];
|
|
25
|
+
dataVersion?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const reportOptionsFromBody: (body?: ReportOptions) => ReportOptions;
|
|
28
|
+
export declare const reportNarrativeFromPreset: ({ narrativeProvider, narrativeModel }?: ReportNarrative) => ReportNarrative;
|
|
29
|
+
export declare const REPORT_FORMATS: readonly ["pdf", "docx", "html"];
|
|
30
|
+
export type ReportFormat = (typeof REPORT_FORMATS)[number];
|
|
31
|
+
export declare const REPORT_SUPPLEMENTARY_FILENAME = "report-supplementary.xlsx";
|
|
32
|
+
export declare const reportKeyPrefix: (subjectId: string) => string;
|
|
33
|
+
export declare const reportMainFormat: (key: string) => ReportFormat | undefined;
|
|
34
|
+
export declare const isReportSupplementary: (key: string) => boolean;
|
|
35
|
+
export interface ReportFiles {
|
|
36
|
+
reportPaths: {
|
|
37
|
+
[format in ReportFormat]?: string;
|
|
38
|
+
};
|
|
39
|
+
supplementaryPath?: string;
|
|
40
|
+
}
|
package/reports/model.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isReportSupplementary = exports.reportMainFormat = exports.reportKeyPrefix = exports.REPORT_SUPPLEMENTARY_FILENAME = exports.REPORT_FORMATS = exports.reportNarrativeFromPreset = exports.reportOptionsFromBody = void 0;
|
|
4
|
+
const reportOptionKeys = [
|
|
5
|
+
'product',
|
|
6
|
+
'limit',
|
|
7
|
+
'feedback',
|
|
8
|
+
'format',
|
|
9
|
+
'noNarrative',
|
|
10
|
+
'noBenchmark',
|
|
11
|
+
'noContributions',
|
|
12
|
+
'radar',
|
|
13
|
+
'refetch'
|
|
14
|
+
];
|
|
15
|
+
const reportOptionsFromBody = (body = {}) => reportOptionKeys.reduce((acc, key) => (body[key] === undefined ? acc : { ...acc, [key]: body[key] }), {});
|
|
16
|
+
exports.reportOptionsFromBody = reportOptionsFromBody;
|
|
17
|
+
const reportNarrativeFromPreset = ({ narrativeProvider, narrativeModel } = {}) => ({
|
|
18
|
+
...(narrativeProvider ? { narrativeProvider } : {}),
|
|
19
|
+
...(narrativeModel ? { narrativeModel } : {})
|
|
20
|
+
});
|
|
21
|
+
exports.reportNarrativeFromPreset = reportNarrativeFromPreset;
|
|
22
|
+
exports.REPORT_FORMATS = ['pdf', 'docx', 'html'];
|
|
23
|
+
exports.REPORT_SUPPLEMENTARY_FILENAME = 'report-supplementary.xlsx';
|
|
24
|
+
const reportMainRegExp = new RegExp(`^report\\.(${exports.REPORT_FORMATS.join('|')})$`);
|
|
25
|
+
const reportKeyPrefix = (subjectId) => `${subjectId}/`;
|
|
26
|
+
exports.reportKeyPrefix = reportKeyPrefix;
|
|
27
|
+
const reportFilename = (key) => key.split('/').pop() || '';
|
|
28
|
+
const reportMainFormat = (key) => reportFilename(key).match(reportMainRegExp)?.[1];
|
|
29
|
+
exports.reportMainFormat = reportMainFormat;
|
|
30
|
+
const isReportSupplementary = (key) => reportFilename(key) === exports.REPORT_SUPPLEMENTARY_FILENAME;
|
|
31
|
+
exports.isReportSupplementary = isReportSupplementary;
|
package/users/model/model.d.ts
CHANGED
|
@@ -24,7 +24,8 @@ export declare enum UserPermission {
|
|
|
24
24
|
reconciliationsRead = "reconciliations-view",
|
|
25
25
|
reconciliationsUpdate = "reconciliations-update",
|
|
26
26
|
reconciliationsDelete = "reconciliations-delete",
|
|
27
|
-
filesPdfExtract = "files-pdf-extract"
|
|
27
|
+
filesPdfExtract = "files-pdf-extract",
|
|
28
|
+
generateReport = "generate-report"
|
|
28
29
|
}
|
|
29
30
|
export declare enum UserPermissionRequestStatus {
|
|
30
31
|
Approved = "approved",
|
package/users/model/model.js
CHANGED
|
@@ -32,6 +32,7 @@ var UserPermission;
|
|
|
32
32
|
UserPermission["reconciliationsUpdate"] = "reconciliations-update";
|
|
33
33
|
UserPermission["reconciliationsDelete"] = "reconciliations-delete";
|
|
34
34
|
UserPermission["filesPdfExtract"] = "files-pdf-extract";
|
|
35
|
+
UserPermission["generateReport"] = "generate-report";
|
|
35
36
|
})(UserPermission || (exports.UserPermission = UserPermission = {}));
|
|
36
37
|
var UserPermissionRequestStatus;
|
|
37
38
|
(function (UserPermissionRequestStatus) {
|