@etainabl/nodejs-sdk 1.2.42 → 1.2.44
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/cjs/api.d.ts +111 -0
- package/dist/cjs/api.js +318 -0
- package/dist/cjs/consumption.d.ts +14 -0
- package/dist/cjs/consumption.js +32 -0
- package/dist/cjs/db.d.ts +6 -0
- package/dist/cjs/db.js +69 -0
- package/dist/cjs/etainabl.d.ts +10 -0
- package/dist/cjs/etainabl.js +2 -0
- package/dist/cjs/index.d.ts +10 -0
- package/dist/cjs/logger.d.ts +3 -0
- package/dist/cjs/logger.js +14 -0
- package/dist/cjs/monitoring.d.ts +1 -0
- package/dist/cjs/monitoring.js +31 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/reporting.d.ts +2 -0
- package/dist/cjs/reporting.js +69 -0
- package/dist/cjs/slack.d.ts +4 -0
- package/dist/cjs/slack.js +28 -0
- package/dist/cjs/types/account.d.ts +112 -0
- package/dist/cjs/types/account.js +2 -0
- package/dist/cjs/types/address.d.ts +11 -0
- package/dist/cjs/types/address.js +2 -0
- package/dist/cjs/types/asset.d.ts +122 -0
- package/dist/cjs/types/asset.js +3 -0
- package/dist/cjs/types/automation.d.ts +33 -0
- package/dist/cjs/types/automation.js +2 -0
- package/dist/cjs/types/company.d.ts +42 -0
- package/dist/cjs/types/company.js +2 -0
- package/dist/cjs/types/dataIngest.d.ts +8 -0
- package/dist/cjs/types/dataIngest.js +2 -0
- package/dist/cjs/types/email.d.ts +18 -0
- package/dist/cjs/types/email.js +2 -0
- package/dist/cjs/types/entity.d.ts +16 -0
- package/dist/cjs/types/entity.js +2 -0
- package/dist/cjs/types/index.d.ts +19 -0
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/types/invoice.d.ts +118 -0
- package/dist/cjs/types/invoice.js +2 -0
- package/dist/cjs/types/log.d.ts +10 -0
- package/dist/cjs/types/log.js +2 -0
- package/dist/cjs/types/portal.d.ts +8 -0
- package/dist/cjs/types/portal.js +2 -0
- package/dist/cjs/types/reading.d.ts +17 -0
- package/dist/cjs/types/reading.js +2 -0
- package/dist/cjs/types/report.d.ts +21 -0
- package/dist/cjs/types/report.js +2 -0
- package/dist/cjs/types/scraperRun.d.ts +15 -0
- package/dist/cjs/types/scraperRun.js +2 -0
- package/dist/cjs/types/statusHistory.d.ts +5 -0
- package/dist/cjs/types/statusHistory.js +2 -0
- package/dist/cjs/types/supplier.d.ts +28 -0
- package/dist/cjs/types/supplier.js +3 -0
- package/dist/cjs/units.d.ts +22 -0
- package/dist/cjs/units.js +94 -0
- package/dist/mjs/api.d.ts +111 -0
- package/dist/mjs/api.js +308 -0
- package/dist/mjs/consumption.d.ts +14 -0
- package/dist/mjs/consumption.js +22 -0
- package/dist/mjs/db.d.ts +6 -0
- package/dist/mjs/db.js +53 -0
- package/dist/mjs/etainabl.d.ts +10 -0
- package/dist/mjs/etainabl.js +1 -0
- package/dist/mjs/index.d.ts +10 -0
- package/dist/mjs/index.js +10 -0
- package/dist/mjs/logger.d.ts +3 -0
- package/dist/mjs/logger.js +9 -0
- package/dist/mjs/monitoring.d.ts +1 -0
- package/dist/mjs/monitoring.js +15 -0
- package/dist/mjs/package.json +3 -0
- package/dist/mjs/reporting.d.ts +2 -0
- package/dist/mjs/reporting.js +62 -0
- package/dist/mjs/slack.d.ts +4 -0
- package/dist/mjs/slack.js +14 -0
- package/dist/mjs/types/account.d.ts +112 -0
- package/dist/mjs/types/account.js +1 -0
- package/dist/mjs/types/address.d.ts +11 -0
- package/dist/mjs/types/address.js +1 -0
- package/dist/mjs/types/asset.d.ts +122 -0
- package/dist/mjs/types/asset.js +2 -0
- package/dist/mjs/types/automation.d.ts +33 -0
- package/dist/mjs/types/automation.js +1 -0
- package/dist/mjs/types/company.d.ts +42 -0
- package/dist/mjs/types/company.js +1 -0
- package/dist/mjs/types/dataIngest.d.ts +8 -0
- package/dist/mjs/types/dataIngest.js +1 -0
- package/dist/mjs/types/email.d.ts +18 -0
- package/dist/mjs/types/email.js +1 -0
- package/dist/mjs/types/entity.d.ts +16 -0
- package/dist/mjs/types/entity.js +1 -0
- package/dist/mjs/types/index.d.ts +19 -0
- package/dist/mjs/types/index.js +1 -0
- package/dist/mjs/types/invoice.d.ts +118 -0
- package/dist/mjs/types/invoice.js +1 -0
- package/dist/mjs/types/log.d.ts +10 -0
- package/dist/mjs/types/log.js +1 -0
- package/dist/mjs/types/portal.d.ts +8 -0
- package/dist/mjs/types/portal.js +1 -0
- package/dist/mjs/types/reading.d.ts +17 -0
- package/dist/mjs/types/reading.js +1 -0
- package/dist/mjs/types/report.d.ts +21 -0
- package/dist/mjs/types/report.js +1 -0
- package/dist/mjs/types/scraperRun.d.ts +15 -0
- package/dist/mjs/types/scraperRun.js +1 -0
- package/dist/mjs/types/statusHistory.d.ts +5 -0
- package/dist/mjs/types/statusHistory.js +1 -0
- package/dist/mjs/types/supplier.d.ts +28 -0
- package/dist/mjs/types/supplier.js +2 -0
- package/dist/mjs/units.d.ts +22 -0
- package/dist/mjs/units.js +89 -0
- package/package.json +9 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getScheduledReportRunTimes = void 0;
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
|
+
moment_1.default.locale('en', {
|
|
9
|
+
week: {
|
|
10
|
+
dow: 1
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const getNextRunTime = (startDate, schedule, taskTime) => {
|
|
14
|
+
const [num, freq] = schedule.frequency.split('|');
|
|
15
|
+
const targetDate = (0, moment_1.default)(startDate).add(num, freq);
|
|
16
|
+
if (schedule.frequencyPeriod === 'first') {
|
|
17
|
+
targetDate.startOf(freq);
|
|
18
|
+
}
|
|
19
|
+
else if (schedule.frequencyPeriod === 'last') {
|
|
20
|
+
targetDate.endOf(freq);
|
|
21
|
+
}
|
|
22
|
+
const isWeekday = targetDate.isoWeekday() > 0 && targetDate.isoWeekday() < 6;
|
|
23
|
+
const isSaturday = targetDate.isoWeekday() === 6;
|
|
24
|
+
// The weekday or weekend chosen should be within the same month as the target date
|
|
25
|
+
if (schedule.frequencyDay === 'weekdays' && !isWeekday) {
|
|
26
|
+
if ((targetDate.date() / 7) < 2) {
|
|
27
|
+
targetDate.add(isSaturday ? 2 : 1, 'days');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
targetDate.subtract(isSaturday ? 1 : 2, 'days');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (schedule.frequencyDay === 'weekends' && isWeekday) {
|
|
34
|
+
if ((targetDate.date() / 7) < 2) {
|
|
35
|
+
targetDate.isoWeekday(6);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
targetDate.isoWeekday(0);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (taskTime.isAfter(targetDate, 'minute')) {
|
|
42
|
+
return getNextRunTime(targetDate, schedule, taskTime);
|
|
43
|
+
}
|
|
44
|
+
return targetDate;
|
|
45
|
+
};
|
|
46
|
+
const getScheduledReportRunTimes = (schedule, limit = 1, taskTime = (0, moment_1.default)()) => {
|
|
47
|
+
if (!schedule.startDate || !schedule.enabled)
|
|
48
|
+
return [];
|
|
49
|
+
const originalStartDate = moment_1.default.utc(schedule.startDate);
|
|
50
|
+
let startDate = originalStartDate;
|
|
51
|
+
const includeStartDate = taskTime.isSameOrBefore(originalStartDate, 'minute');
|
|
52
|
+
let runTimes = [];
|
|
53
|
+
if (includeStartDate) {
|
|
54
|
+
runTimes = [originalStartDate];
|
|
55
|
+
}
|
|
56
|
+
const [, freq] = schedule.frequency.split('|');
|
|
57
|
+
if (freq === 'once') {
|
|
58
|
+
const nextRunTime = runTimes[0];
|
|
59
|
+
// If this is now beyond the start date, return an empty array
|
|
60
|
+
return taskTime.isAfter(nextRunTime, 'minute') ? [] : runTimes;
|
|
61
|
+
}
|
|
62
|
+
const scheduleRunTimes = Array.from(Array(includeStartDate ? limit - 1 : limit).keys()).map(() => {
|
|
63
|
+
const nextRunTime = getNextRunTime(startDate, schedule, taskTime);
|
|
64
|
+
startDate = nextRunTime.hour(originalStartDate.hour()).minute(originalStartDate.minute());
|
|
65
|
+
return nextRunTime;
|
|
66
|
+
});
|
|
67
|
+
return [...runTimes, ...scheduleRunTimes];
|
|
68
|
+
};
|
|
69
|
+
exports.getScheduledReportRunTimes = getScheduledReportRunTimes;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const postMessage = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const url = 'https://hooks.slack.com/services/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';
|
|
18
|
+
const data = {
|
|
19
|
+
text: `[${(process.env.ENV || '').toUpperCase()}][${process.env.AWS_LAMBDA_FUNCTION_NAME}] ${message}`
|
|
20
|
+
};
|
|
21
|
+
const headers = {
|
|
22
|
+
'Content-Type': 'application/json'
|
|
23
|
+
};
|
|
24
|
+
return axios_1.default.post(url, data, { headers });
|
|
25
|
+
});
|
|
26
|
+
exports.default = {
|
|
27
|
+
postMessage
|
|
28
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Portal } from './portal.js';
|
|
2
|
+
import type { StatusHistory } from './statusHistory.js';
|
|
3
|
+
interface PortalAccountSchema extends Portal {
|
|
4
|
+
invoiceFilenames: any[];
|
|
5
|
+
}
|
|
6
|
+
interface RateSchema {
|
|
7
|
+
type: string;
|
|
8
|
+
value: number;
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
interface ContractSchema {
|
|
12
|
+
startDate: Date;
|
|
13
|
+
endDate: Date;
|
|
14
|
+
terminationDate?: Date;
|
|
15
|
+
paymentTerms?: string;
|
|
16
|
+
duration?: string;
|
|
17
|
+
tariffName?: string;
|
|
18
|
+
contractConsumption?: number;
|
|
19
|
+
volumeTolerance?: any[];
|
|
20
|
+
renewablePercentage?: number;
|
|
21
|
+
marketBasedEmissionFactor?: number;
|
|
22
|
+
chargeableCclPercentage?: number;
|
|
23
|
+
commissionRates?: number;
|
|
24
|
+
rates: any[];
|
|
25
|
+
s3Key?: string;
|
|
26
|
+
rateTypeMapping?: object;
|
|
27
|
+
batchId?: string;
|
|
28
|
+
supplierId?: string;
|
|
29
|
+
status: 'active' | 'inactive';
|
|
30
|
+
userSub?: string;
|
|
31
|
+
deletedOn?: Date;
|
|
32
|
+
}
|
|
33
|
+
interface CreditNoteSchema {
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
amount: number;
|
|
37
|
+
netAmount: number;
|
|
38
|
+
taxAmount: number;
|
|
39
|
+
date: Date;
|
|
40
|
+
isPaid: boolean;
|
|
41
|
+
s3Key: string;
|
|
42
|
+
stampedS3Key: string;
|
|
43
|
+
fileName: string;
|
|
44
|
+
invoiceData: object;
|
|
45
|
+
userSub: string;
|
|
46
|
+
readingIds: any[];
|
|
47
|
+
supplierId: string;
|
|
48
|
+
totalUnits: number;
|
|
49
|
+
endDate: Date;
|
|
50
|
+
startDate: Date;
|
|
51
|
+
stampDate: Date;
|
|
52
|
+
totalWaterVolume: number;
|
|
53
|
+
totalWasteVolume: number;
|
|
54
|
+
totalWaterCost: number;
|
|
55
|
+
totalWasteCost: number;
|
|
56
|
+
}
|
|
57
|
+
export interface Account {
|
|
58
|
+
_id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
modifiedBy?: string;
|
|
61
|
+
siteCode?: string;
|
|
62
|
+
type: 'gas' | 'electricity' | 'water' | 'waste' | 'solar';
|
|
63
|
+
supplierRef?: string;
|
|
64
|
+
financialCode?: string;
|
|
65
|
+
propertyCode?: string;
|
|
66
|
+
meterPointNumber?: string;
|
|
67
|
+
meterSerialNumber?: string;
|
|
68
|
+
meterPointNumber2?: string;
|
|
69
|
+
meterUnits: 'kwh' | 'm3' | 'ft3';
|
|
70
|
+
automaticMeterRead?: boolean;
|
|
71
|
+
status?: 'active' | 'inactive';
|
|
72
|
+
statusHistory?: StatusHistory[];
|
|
73
|
+
rates?: RateSchema[];
|
|
74
|
+
capacity?: string;
|
|
75
|
+
meterOperator?: string;
|
|
76
|
+
meterLocation?: string;
|
|
77
|
+
meterOperatorType?: 'lease' | 'purchase';
|
|
78
|
+
meterOperatorExpiryDate?: Date;
|
|
79
|
+
dataCollector?: string;
|
|
80
|
+
parentAccountId?: string;
|
|
81
|
+
processingInvoices?: object[];
|
|
82
|
+
contracts?: ContractSchema[];
|
|
83
|
+
creditNotes?: CreditNoteSchema[];
|
|
84
|
+
meterUser?: string;
|
|
85
|
+
isTrc?: boolean;
|
|
86
|
+
floorArea?: string;
|
|
87
|
+
floorAreaUnit?: 'metric' | 'imperial';
|
|
88
|
+
reportingType?: string;
|
|
89
|
+
solarType?: 'generation' | 'export';
|
|
90
|
+
consumptionSource?: 'primary' | 'sub' | 'primary-sub';
|
|
91
|
+
esec?: 'a' | 'b' | 'c' | 'd' | 'e' | 'g' | 'h' | 'j' | 'k' | 'l' | 'm' | 'n' | 'p' | 'q' | 'r' | 's' | 't' | 'u';
|
|
92
|
+
portal?: PortalAccountSchema;
|
|
93
|
+
deviceId?: string;
|
|
94
|
+
gridfetchLoa?: {
|
|
95
|
+
s3Key?: string;
|
|
96
|
+
name?: string;
|
|
97
|
+
uploadedBy?: string;
|
|
98
|
+
uploadedAt?: Date;
|
|
99
|
+
expiryDate?: Date;
|
|
100
|
+
error?: string;
|
|
101
|
+
uploaded?: boolean;
|
|
102
|
+
};
|
|
103
|
+
automationIds?: string[];
|
|
104
|
+
customIntegrations?: object;
|
|
105
|
+
supplierId?: string;
|
|
106
|
+
batchId?: string;
|
|
107
|
+
assetId: string;
|
|
108
|
+
entityId: string;
|
|
109
|
+
companyId: string;
|
|
110
|
+
userSub: string;
|
|
111
|
+
}
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Address } from './address.js';
|
|
2
|
+
import type { StatusHistory } from './statusHistory.js';
|
|
3
|
+
interface Image {
|
|
4
|
+
url?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
isHidden?: boolean;
|
|
8
|
+
isPrimary?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface FloodRisk {
|
|
11
|
+
url?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
latitude?: number;
|
|
15
|
+
longitude?: number;
|
|
16
|
+
fetchedAt?: Date;
|
|
17
|
+
}
|
|
18
|
+
interface Crime {
|
|
19
|
+
category?: string;
|
|
20
|
+
month?: string;
|
|
21
|
+
crimeId?: string;
|
|
22
|
+
outcomeCategory?: string;
|
|
23
|
+
outcomeDate?: string;
|
|
24
|
+
location?: {
|
|
25
|
+
latitude: string;
|
|
26
|
+
longitude: string;
|
|
27
|
+
street: string;
|
|
28
|
+
};
|
|
29
|
+
fetchedAt?: Date;
|
|
30
|
+
}
|
|
31
|
+
interface AirQuality {
|
|
32
|
+
index?: number;
|
|
33
|
+
indexColour?: string;
|
|
34
|
+
indexRating?: string;
|
|
35
|
+
details?: object;
|
|
36
|
+
location?: object;
|
|
37
|
+
lastMeasured?: Date;
|
|
38
|
+
fetchedAt?: Date;
|
|
39
|
+
}
|
|
40
|
+
interface Benchmark {
|
|
41
|
+
benchmarkId: string;
|
|
42
|
+
fieldCode: string;
|
|
43
|
+
fieldValue: string;
|
|
44
|
+
}
|
|
45
|
+
interface Document {
|
|
46
|
+
s3Key?: string;
|
|
47
|
+
name: string;
|
|
48
|
+
extension?: string;
|
|
49
|
+
type: string;
|
|
50
|
+
status: string;
|
|
51
|
+
score?: string;
|
|
52
|
+
providerId?: string;
|
|
53
|
+
providerData?: object;
|
|
54
|
+
certificate?: object;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
accountIds?: string[];
|
|
57
|
+
}
|
|
58
|
+
interface TimelineEvent {
|
|
59
|
+
date: Date;
|
|
60
|
+
title: string;
|
|
61
|
+
status: string;
|
|
62
|
+
content?: string;
|
|
63
|
+
icon?: string;
|
|
64
|
+
accountIds?: string[];
|
|
65
|
+
}
|
|
66
|
+
interface AssetRecommendation {
|
|
67
|
+
recommendationId: string;
|
|
68
|
+
documentIds?: string[];
|
|
69
|
+
}
|
|
70
|
+
interface AssetSettings {
|
|
71
|
+
consumptionSources: {
|
|
72
|
+
electricity: string;
|
|
73
|
+
solar: string;
|
|
74
|
+
gas: string;
|
|
75
|
+
water: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface Asset {
|
|
79
|
+
_id: string;
|
|
80
|
+
siteName: string;
|
|
81
|
+
address: Address;
|
|
82
|
+
assetType: string;
|
|
83
|
+
floorArea: number;
|
|
84
|
+
floorAreaUnit: 'metric' | 'imperial';
|
|
85
|
+
noOfFloors?: number;
|
|
86
|
+
energyRating: string;
|
|
87
|
+
gav: string;
|
|
88
|
+
gavCurrency: string;
|
|
89
|
+
currency: string;
|
|
90
|
+
occupationStatus: 'occupied' | 'vacant' | 'other' | 'n/a';
|
|
91
|
+
type: 'new construction' | 'major renovation' | 'standing investment' | 'n/a';
|
|
92
|
+
vacancyRate?: number;
|
|
93
|
+
constructionYear?: number;
|
|
94
|
+
ownedSince?: Date;
|
|
95
|
+
disposalDate?: Date;
|
|
96
|
+
tenure: 'freehold' | 'leasehold';
|
|
97
|
+
tenantControlledPercent?: number;
|
|
98
|
+
landlordControlledPercent?: number;
|
|
99
|
+
occupancyLevel?: number;
|
|
100
|
+
images: Image[];
|
|
101
|
+
pricePaid?: number;
|
|
102
|
+
floodRisks: FloodRisk[];
|
|
103
|
+
recentCrimes: Crime[];
|
|
104
|
+
recentAirQuality: AirQuality;
|
|
105
|
+
documents?: Document[];
|
|
106
|
+
epbCertificates: any[];
|
|
107
|
+
status?: string;
|
|
108
|
+
settings: AssetSettings;
|
|
109
|
+
recommendations?: AssetRecommendation[];
|
|
110
|
+
statusHistory: StatusHistory[];
|
|
111
|
+
timelineEvents: TimelineEvent[];
|
|
112
|
+
benchmarks: Benchmark[];
|
|
113
|
+
lastPopulated?: Date;
|
|
114
|
+
deletedOn?: Date;
|
|
115
|
+
batchId?: string;
|
|
116
|
+
companyId: string;
|
|
117
|
+
entityId: string;
|
|
118
|
+
assetGroupIds: string[];
|
|
119
|
+
userSub: string;
|
|
120
|
+
gresbId?: string;
|
|
121
|
+
}
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface Log {
|
|
2
|
+
message: string;
|
|
3
|
+
timestamp: Date;
|
|
4
|
+
batchId?: string;
|
|
5
|
+
source?: string;
|
|
6
|
+
}
|
|
7
|
+
interface LastCollection {
|
|
8
|
+
collectedAt: Date | null;
|
|
9
|
+
data: Record<string, any> | null;
|
|
10
|
+
error: Record<string, any> | null;
|
|
11
|
+
status: 'success' | 'error' | 'pending';
|
|
12
|
+
source: Record<string, any> | null;
|
|
13
|
+
}
|
|
14
|
+
type FrequencyType = 'never' | 'trigger' | 'hourly' | 'daily' | 'weekly' | 'monthly';
|
|
15
|
+
export interface Automation {
|
|
16
|
+
_id: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
service: string;
|
|
19
|
+
source: string;
|
|
20
|
+
category: string;
|
|
21
|
+
active: boolean;
|
|
22
|
+
status?: 'running' | 'pending';
|
|
23
|
+
lastCollection: LastCollection;
|
|
24
|
+
logs: Log[];
|
|
25
|
+
data: Record<string, any>;
|
|
26
|
+
sourceData: Record<string, any>;
|
|
27
|
+
frequency?: FrequencyType;
|
|
28
|
+
accountIds?: string[];
|
|
29
|
+
assetIds?: string[];
|
|
30
|
+
userSub: string;
|
|
31
|
+
companyId: string;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Address } from './address.js';
|
|
2
|
+
import { Portal } from './portal.js';
|
|
3
|
+
interface SupplierPortals {
|
|
4
|
+
supplierId: string;
|
|
5
|
+
portal: Portal;
|
|
6
|
+
}
|
|
7
|
+
interface CustomIntegrations {
|
|
8
|
+
account: any[];
|
|
9
|
+
asset: any[];
|
|
10
|
+
entity: any[];
|
|
11
|
+
}
|
|
12
|
+
interface DefaultSources {
|
|
13
|
+
electricity: 'invoice' | 'consumption' | 'reading';
|
|
14
|
+
solar: 'invoice' | 'consumption' | 'reading';
|
|
15
|
+
gas: 'invoice' | 'consumption' | 'reading';
|
|
16
|
+
water: 'invoice' | 'consumption' | 'reading';
|
|
17
|
+
}
|
|
18
|
+
interface CompanySettings {
|
|
19
|
+
showLogo?: boolean;
|
|
20
|
+
invoiceCategories?: any[];
|
|
21
|
+
miscInvoiceCategories?: any[];
|
|
22
|
+
messageCategories?: any[];
|
|
23
|
+
documentCategories?: any[];
|
|
24
|
+
assetDataSchemas?: any[];
|
|
25
|
+
hideCostData?: boolean;
|
|
26
|
+
calendarPeriod?: string;
|
|
27
|
+
customIntegrations?: CustomIntegrations;
|
|
28
|
+
supplierPortals?: SupplierPortals[];
|
|
29
|
+
defaultSources?: DefaultSources;
|
|
30
|
+
scraperCounter?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface Company {
|
|
33
|
+
_id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
address?: Address;
|
|
36
|
+
invoiceEmail?: string;
|
|
37
|
+
users?: string[];
|
|
38
|
+
settings: CompanySettings;
|
|
39
|
+
logoS3Key: string;
|
|
40
|
+
logoUrl?: string;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface Attachment {
|
|
2
|
+
filename: string;
|
|
3
|
+
s3Key: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Email {
|
|
6
|
+
_id: string;
|
|
7
|
+
destinations: string[];
|
|
8
|
+
service: string;
|
|
9
|
+
subject: string;
|
|
10
|
+
body: string;
|
|
11
|
+
from: string;
|
|
12
|
+
attachments?: Attachment[];
|
|
13
|
+
sesMessageId: string;
|
|
14
|
+
s3Key: string;
|
|
15
|
+
userSub?: string;
|
|
16
|
+
companyId?: string;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Address } from './address.js';
|
|
2
|
+
type EntityType = 'fund' | 'company' | 'charity' | 'school/university' | 'council' | 'other';
|
|
3
|
+
export interface Entity {
|
|
4
|
+
_id: string;
|
|
5
|
+
legalName: string;
|
|
6
|
+
type: EntityType;
|
|
7
|
+
companyNumber?: string;
|
|
8
|
+
companyLogo?: string;
|
|
9
|
+
billingAddress: Address;
|
|
10
|
+
parentEntityId?: string;
|
|
11
|
+
ultimateParentEntityId?: string;
|
|
12
|
+
companyId: string;
|
|
13
|
+
batchId?: string;
|
|
14
|
+
userSub: string;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { Account } from './account.js';
|
|
2
|
+
export type { Asset } from './asset.js';
|
|
3
|
+
export type { Automation } from './automation.js';
|
|
4
|
+
export type { Company } from './company.js';
|
|
5
|
+
export type { CreateScraperRunParams, ScraperRun } from './scraperRun.js';
|
|
6
|
+
export type { DataIngest } from './dataIngest.js';
|
|
7
|
+
export type { Entity } from './entity.js';
|
|
8
|
+
export type { Email } from './email.js';
|
|
9
|
+
export type { Invoice } from './invoice.js';
|
|
10
|
+
export type { Log } from './log.js';
|
|
11
|
+
export type { Reading } from './reading.js';
|
|
12
|
+
export type { Report } from './report.js';
|
|
13
|
+
export type { Supplier } from './supplier.js';
|
|
14
|
+
export interface ETNPagedResponse<T = any> {
|
|
15
|
+
data: T[];
|
|
16
|
+
total: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
skip: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
interface Values {
|
|
2
|
+
friendlyInvoiceNumber?: string;
|
|
3
|
+
friendlySupplierRef?: string;
|
|
4
|
+
friendlyStartDate?: string;
|
|
5
|
+
friendlyEndDate?: string;
|
|
6
|
+
friendlyInvoiceDate?: string;
|
|
7
|
+
friendlyMeterPointNumber?: string;
|
|
8
|
+
friendlyMeterPointNumber2?: string;
|
|
9
|
+
friendlyMeterSerialNumber?: string;
|
|
10
|
+
friendlyPipeSize?: string;
|
|
11
|
+
friendlyTotalUnitCost?: number;
|
|
12
|
+
friendlyTotalWaterCost?: number;
|
|
13
|
+
friendlyTotalWasteCost?: number;
|
|
14
|
+
friendlyTotalDaily?: number;
|
|
15
|
+
friendlyTotalLevy?: number;
|
|
16
|
+
friendlyTotalKva?: number;
|
|
17
|
+
friendlyTotalUnits?: number;
|
|
18
|
+
friendlyTotalWaterVolume?: number;
|
|
19
|
+
friendlyTotalWasteVolume?: number;
|
|
20
|
+
friendlyNetTotalCost?: number;
|
|
21
|
+
friendlyTotalTax?: number;
|
|
22
|
+
friendlyTotalCost?: number;
|
|
23
|
+
friendlyMeteredConsumption?: string;
|
|
24
|
+
friendlyCorrectedConsumption?: string;
|
|
25
|
+
friendlyCorrectionFactor?: string;
|
|
26
|
+
friendlyCalorificValue?: string;
|
|
27
|
+
friendlyReadFactor?: string;
|
|
28
|
+
friendlyType?: string;
|
|
29
|
+
friendlyStartRead?: string;
|
|
30
|
+
friendlyEndRead?: string;
|
|
31
|
+
invoiceNumber?: string;
|
|
32
|
+
supplierRef?: string;
|
|
33
|
+
startDate?: Date;
|
|
34
|
+
endDate?: Date;
|
|
35
|
+
invoiceDate?: Date;
|
|
36
|
+
meterPointNumber?: string;
|
|
37
|
+
meterPointNumber2?: string;
|
|
38
|
+
meterSerialNumber?: string;
|
|
39
|
+
pipeSize?: string;
|
|
40
|
+
totalUnitCost?: number;
|
|
41
|
+
totalWaterCost?: number;
|
|
42
|
+
totalWasteCost?: number;
|
|
43
|
+
totalDaily?: number;
|
|
44
|
+
totalLevy?: number;
|
|
45
|
+
totalKva?: number;
|
|
46
|
+
totalUnits?: number;
|
|
47
|
+
totalWaterVolume?: number;
|
|
48
|
+
totalWasteVolume?: number;
|
|
49
|
+
netTotalCost?: number;
|
|
50
|
+
totalTax?: number;
|
|
51
|
+
totalCost?: number;
|
|
52
|
+
meteredConsumption?: string;
|
|
53
|
+
correctedConsumption?: string;
|
|
54
|
+
correctionFactor?: string;
|
|
55
|
+
calorificValue?: string;
|
|
56
|
+
readFactor?: string;
|
|
57
|
+
type?: string;
|
|
58
|
+
startRead?: string;
|
|
59
|
+
endRead?: string;
|
|
60
|
+
}
|
|
61
|
+
interface Rate {
|
|
62
|
+
consumption?: string;
|
|
63
|
+
cost?: string;
|
|
64
|
+
endDate?: Date | null;
|
|
65
|
+
endRead?: string | null;
|
|
66
|
+
endReadType?: string | null;
|
|
67
|
+
rateName?: string | null;
|
|
68
|
+
startDate?: Date | null;
|
|
69
|
+
startRead?: string | null;
|
|
70
|
+
startReadType?: string | null;
|
|
71
|
+
type: RateType | null;
|
|
72
|
+
unitRate?: string | null;
|
|
73
|
+
}
|
|
74
|
+
type InvoiceStatus = 'processing' | 'pending' | 'uploading' | 'queued' | 'captured' | 'error' | 'completed';
|
|
75
|
+
type FinancialStatus = 'approved' | 'new' | 'not-approved' | 'paid' | 'sent-for-payment';
|
|
76
|
+
type RateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
|
|
77
|
+
export interface Invoice {
|
|
78
|
+
_id: string;
|
|
79
|
+
jobId?: string | null;
|
|
80
|
+
startTime?: Date;
|
|
81
|
+
endTime?: Date | null;
|
|
82
|
+
s3Key: string;
|
|
83
|
+
s3TextractKey?: string | null;
|
|
84
|
+
stampedS3Key: string | null;
|
|
85
|
+
fileName?: string | null;
|
|
86
|
+
status: InvoiceStatus;
|
|
87
|
+
financialStatus: FinancialStatus;
|
|
88
|
+
completed?: boolean;
|
|
89
|
+
type?: string | null;
|
|
90
|
+
tags?: string[];
|
|
91
|
+
manualResults?: Record<string, any>;
|
|
92
|
+
values?: Values;
|
|
93
|
+
rates?: Rate[];
|
|
94
|
+
detailedResults?: Record<string, any>;
|
|
95
|
+
templateVersion?: string | null;
|
|
96
|
+
error?: Record<string, any>;
|
|
97
|
+
isPaid?: boolean;
|
|
98
|
+
isCreditNote?: boolean;
|
|
99
|
+
isConvertedCreditNote?: boolean;
|
|
100
|
+
isManual?: boolean;
|
|
101
|
+
uploaderStatus?: string;
|
|
102
|
+
simulated?: boolean;
|
|
103
|
+
notes?: string | null;
|
|
104
|
+
assignedTo?: string;
|
|
105
|
+
noScrape?: boolean;
|
|
106
|
+
scraperInvoiceId?: string;
|
|
107
|
+
confirmedAt?: Date | null;
|
|
108
|
+
confirmedBy?: string | null;
|
|
109
|
+
supplierId?: string | null;
|
|
110
|
+
sisterId?: string | null;
|
|
111
|
+
batchId?: string | null;
|
|
112
|
+
accountId?: string | null;
|
|
113
|
+
entityId?: string;
|
|
114
|
+
companyId: string;
|
|
115
|
+
userSub: string;
|
|
116
|
+
validation?: any[];
|
|
117
|
+
}
|
|
118
|
+
export {};
|