@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.
Files changed (110) hide show
  1. package/dist/cjs/api.d.ts +111 -0
  2. package/dist/cjs/api.js +318 -0
  3. package/dist/cjs/consumption.d.ts +14 -0
  4. package/dist/cjs/consumption.js +32 -0
  5. package/dist/cjs/db.d.ts +6 -0
  6. package/dist/cjs/db.js +69 -0
  7. package/dist/cjs/etainabl.d.ts +10 -0
  8. package/dist/cjs/etainabl.js +2 -0
  9. package/dist/cjs/index.d.ts +10 -0
  10. package/dist/cjs/logger.d.ts +3 -0
  11. package/dist/cjs/logger.js +14 -0
  12. package/dist/cjs/monitoring.d.ts +1 -0
  13. package/dist/cjs/monitoring.js +31 -0
  14. package/dist/cjs/package.json +3 -0
  15. package/dist/cjs/reporting.d.ts +2 -0
  16. package/dist/cjs/reporting.js +69 -0
  17. package/dist/cjs/slack.d.ts +4 -0
  18. package/dist/cjs/slack.js +28 -0
  19. package/dist/cjs/types/account.d.ts +112 -0
  20. package/dist/cjs/types/account.js +2 -0
  21. package/dist/cjs/types/address.d.ts +11 -0
  22. package/dist/cjs/types/address.js +2 -0
  23. package/dist/cjs/types/asset.d.ts +122 -0
  24. package/dist/cjs/types/asset.js +3 -0
  25. package/dist/cjs/types/automation.d.ts +33 -0
  26. package/dist/cjs/types/automation.js +2 -0
  27. package/dist/cjs/types/company.d.ts +42 -0
  28. package/dist/cjs/types/company.js +2 -0
  29. package/dist/cjs/types/dataIngest.d.ts +8 -0
  30. package/dist/cjs/types/dataIngest.js +2 -0
  31. package/dist/cjs/types/email.d.ts +18 -0
  32. package/dist/cjs/types/email.js +2 -0
  33. package/dist/cjs/types/entity.d.ts +16 -0
  34. package/dist/cjs/types/entity.js +2 -0
  35. package/dist/cjs/types/index.d.ts +19 -0
  36. package/dist/cjs/types/index.js +2 -0
  37. package/dist/cjs/types/invoice.d.ts +118 -0
  38. package/dist/cjs/types/invoice.js +2 -0
  39. package/dist/cjs/types/log.d.ts +10 -0
  40. package/dist/cjs/types/log.js +2 -0
  41. package/dist/cjs/types/portal.d.ts +8 -0
  42. package/dist/cjs/types/portal.js +2 -0
  43. package/dist/cjs/types/reading.d.ts +17 -0
  44. package/dist/cjs/types/reading.js +2 -0
  45. package/dist/cjs/types/report.d.ts +21 -0
  46. package/dist/cjs/types/report.js +2 -0
  47. package/dist/cjs/types/scraperRun.d.ts +15 -0
  48. package/dist/cjs/types/scraperRun.js +2 -0
  49. package/dist/cjs/types/statusHistory.d.ts +5 -0
  50. package/dist/cjs/types/statusHistory.js +2 -0
  51. package/dist/cjs/types/supplier.d.ts +28 -0
  52. package/dist/cjs/types/supplier.js +3 -0
  53. package/dist/cjs/units.d.ts +22 -0
  54. package/dist/cjs/units.js +94 -0
  55. package/dist/mjs/api.d.ts +111 -0
  56. package/dist/mjs/api.js +308 -0
  57. package/dist/mjs/consumption.d.ts +14 -0
  58. package/dist/mjs/consumption.js +22 -0
  59. package/dist/mjs/db.d.ts +6 -0
  60. package/dist/mjs/db.js +53 -0
  61. package/dist/mjs/etainabl.d.ts +10 -0
  62. package/dist/mjs/etainabl.js +1 -0
  63. package/dist/mjs/index.d.ts +10 -0
  64. package/dist/mjs/index.js +10 -0
  65. package/dist/mjs/logger.d.ts +3 -0
  66. package/dist/mjs/logger.js +9 -0
  67. package/dist/mjs/monitoring.d.ts +1 -0
  68. package/dist/mjs/monitoring.js +15 -0
  69. package/dist/mjs/package.json +3 -0
  70. package/dist/mjs/reporting.d.ts +2 -0
  71. package/dist/mjs/reporting.js +62 -0
  72. package/dist/mjs/slack.d.ts +4 -0
  73. package/dist/mjs/slack.js +14 -0
  74. package/dist/mjs/types/account.d.ts +112 -0
  75. package/dist/mjs/types/account.js +1 -0
  76. package/dist/mjs/types/address.d.ts +11 -0
  77. package/dist/mjs/types/address.js +1 -0
  78. package/dist/mjs/types/asset.d.ts +122 -0
  79. package/dist/mjs/types/asset.js +2 -0
  80. package/dist/mjs/types/automation.d.ts +33 -0
  81. package/dist/mjs/types/automation.js +1 -0
  82. package/dist/mjs/types/company.d.ts +42 -0
  83. package/dist/mjs/types/company.js +1 -0
  84. package/dist/mjs/types/dataIngest.d.ts +8 -0
  85. package/dist/mjs/types/dataIngest.js +1 -0
  86. package/dist/mjs/types/email.d.ts +18 -0
  87. package/dist/mjs/types/email.js +1 -0
  88. package/dist/mjs/types/entity.d.ts +16 -0
  89. package/dist/mjs/types/entity.js +1 -0
  90. package/dist/mjs/types/index.d.ts +19 -0
  91. package/dist/mjs/types/index.js +1 -0
  92. package/dist/mjs/types/invoice.d.ts +118 -0
  93. package/dist/mjs/types/invoice.js +1 -0
  94. package/dist/mjs/types/log.d.ts +10 -0
  95. package/dist/mjs/types/log.js +1 -0
  96. package/dist/mjs/types/portal.d.ts +8 -0
  97. package/dist/mjs/types/portal.js +1 -0
  98. package/dist/mjs/types/reading.d.ts +17 -0
  99. package/dist/mjs/types/reading.js +1 -0
  100. package/dist/mjs/types/report.d.ts +21 -0
  101. package/dist/mjs/types/report.js +1 -0
  102. package/dist/mjs/types/scraperRun.d.ts +15 -0
  103. package/dist/mjs/types/scraperRun.js +1 -0
  104. package/dist/mjs/types/statusHistory.d.ts +5 -0
  105. package/dist/mjs/types/statusHistory.js +1 -0
  106. package/dist/mjs/types/supplier.d.ts +28 -0
  107. package/dist/mjs/types/supplier.js +2 -0
  108. package/dist/mjs/units.d.ts +22 -0
  109. package/dist/mjs/units.js +89 -0
  110. package/package.json +9 -4
@@ -0,0 +1,22 @@
1
+ import moment from 'moment';
2
+ export const dayNightConsumption = (data) => data.reduce((acc, item) => {
3
+ const hour = moment.utc(item.date).hour(); // End Time of HH consumption period
4
+ if (hour >= 0 && hour < 7) {
5
+ acc.nightConsumption += item.consumption;
6
+ }
7
+ else {
8
+ acc.dayConsumption += item.consumption;
9
+ }
10
+ acc.consumption += item.consumption;
11
+ return acc;
12
+ }, {
13
+ dayConsumption: 0,
14
+ nightConsumption: 0,
15
+ consumption: 0
16
+ });
17
+ export const calcMaxConsumptionValue = (data) => Math.max(...data.map((item) => item.consumption));
18
+ export const calcMaxDemand = (data) => calcMaxConsumptionValue(data) * 2;
19
+ export const calcPeakLoad = (consumption, maxDemand, startDate, endDate) => {
20
+ const days = Math.ceil(moment(endDate).diff(moment(startDate), 'days', true));
21
+ return maxDemand === 0 ? 0 : ((consumption / (maxDemand * 24 * days)) * 100);
22
+ };
@@ -0,0 +1,6 @@
1
+ import { Db } from 'mongodb';
2
+ declare function connectToDatabase(retryAttempt?: number): Promise<Db>;
3
+ declare const _default: {
4
+ connectToDatabase: typeof connectToDatabase;
5
+ };
6
+ export default _default;
package/dist/mjs/db.js ADDED
@@ -0,0 +1,53 @@
1
+ import { MongoClient } from 'mongodb';
2
+ import logger from './logger.js';
3
+ const log = logger('dbHelpers');
4
+ let cachedDb;
5
+ async function connectToDatabase(retryAttempt = 1) {
6
+ if (!process.env.ETAINABL_DB_URL)
7
+ throw new Error("ETAINABL_DB_URL is not set");
8
+ if (!process.env.AWS_ACCESS_KEY_ID)
9
+ throw new Error("AWS_ACCESS_KEY_ID is not set");
10
+ if (!process.env.AWS_SECRET_ACCESS_KEY)
11
+ throw new Error("AWS_SECRET_ACCESS_KEY is not set");
12
+ if (cachedDb) {
13
+ log.debug('Using cached MongoDB connection.');
14
+ return Promise.resolve(cachedDb);
15
+ }
16
+ const uri = `mongodb+srv://${process.env.ETAINABL_DB_URL}`;
17
+ try {
18
+ if (process.env.DB_BASIC_AUTH === 'true') {
19
+ log.debug('Connecting to MongoDB server... (Auth: Basic)');
20
+ const client = new MongoClient(uri);
21
+ await client.connect();
22
+ log.debug('Connected successfully to MongoDB server! (Auth: Basic)');
23
+ cachedDb = client.db('etainabl');
24
+ return cachedDb;
25
+ }
26
+ log.debug('Connecting to MongoDB server... (Auth: AWS)');
27
+ const client = new MongoClient(uri, {
28
+ auth: {
29
+ username: process.env.AWS_ACCESS_KEY_ID,
30
+ password: process.env.AWS_SECRET_ACCESS_KEY
31
+ },
32
+ authSource: '$external',
33
+ authMechanism: 'MONGODB-AWS'
34
+ });
35
+ await client.connect();
36
+ log.debug('Connected successfully to MongoDB server! (Auth: AWS)');
37
+ cachedDb = client.db('etainabl');
38
+ return cachedDb;
39
+ }
40
+ catch (e) {
41
+ // Retry
42
+ if (retryAttempt > 5) {
43
+ console.log(`Error connecting to MongoDB server after 5 attempts...`);
44
+ throw e;
45
+ }
46
+ console.log(`MongoDB Connection error: ${e.message}`);
47
+ console.log(`Error connecting to MongoDB server... Retrying in 3 seconds... (Attempt ${retryAttempt})`);
48
+ return connectToDatabase(retryAttempt + 1);
49
+ }
50
+ }
51
+ export default {
52
+ connectToDatabase
53
+ };
@@ -0,0 +1,10 @@
1
+ export interface AuthorizerContext {
2
+ companyId: string;
3
+ isAdmin: boolean;
4
+ isKiosk: boolean;
5
+ isPublicApiRequest: boolean;
6
+ isService: boolean;
7
+ scope: string;
8
+ sub: string;
9
+ token: string;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import api from './api.js';
2
+ import logger from './logger.js';
3
+ import db from './db.js';
4
+ import slack from './slack.js';
5
+ import * as units from './units.js';
6
+ import * as consumption from './consumption.js';
7
+ import * as monitoring from './monitoring.js';
8
+ import * as reporting from './reporting.js';
9
+ export { api, logger, consumption, monitoring, db, slack, units, reporting };
10
+ export * from './types/index.js';
@@ -0,0 +1,10 @@
1
+ import api from './api.js';
2
+ import logger from './logger.js';
3
+ import db from './db.js';
4
+ import slack from './slack.js';
5
+ import * as units from './units.js';
6
+ import * as consumption from './consumption.js';
7
+ import * as monitoring from './monitoring.js';
8
+ import * as reporting from './reporting.js';
9
+ export { api, logger, consumption, monitoring, db, slack, units, reporting };
10
+ export * from './types/index.js';
@@ -0,0 +1,3 @@
1
+ import winston from 'winston';
2
+ declare const _default: (namespace: string) => winston.Logger;
3
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import winston from 'winston';
2
+ export default (namespace) => winston.createLogger({
3
+ level: 'debug',
4
+ format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
5
+ defaultMeta: { service: process.env.AWS_LAMBDA_FUNCTION_NAME, script: namespace },
6
+ transports: [
7
+ new winston.transports.Console()
8
+ ]
9
+ });
@@ -0,0 +1 @@
1
+ export declare const sendHeartbeat: () => Promise<boolean>;
@@ -0,0 +1,15 @@
1
+ import axios from 'axios';
2
+ import logger from './logger.js';
3
+ const log = logger('monitoring');
4
+ export const sendHeartbeat = async () => {
5
+ if (!process.env.HEARTBEAT_URL || process.env.HEARTBEAT_URL.endsWith('/'))
6
+ return false;
7
+ try {
8
+ await axios.post(process.env.HEARTBEAT_URL);
9
+ return true;
10
+ }
11
+ catch (e) {
12
+ log.warn(`Failed to send heartbeat: ${e.message || e}`);
13
+ return false;
14
+ }
15
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,2 @@
1
+ import moment from 'moment';
2
+ export declare const getScheduledReportRunTimes: (schedule: any, limit?: number, taskTime?: moment.Moment) => moment.Moment[];
@@ -0,0 +1,62 @@
1
+ import moment from 'moment';
2
+ moment.locale('en', {
3
+ week: {
4
+ dow: 1
5
+ }
6
+ });
7
+ const getNextRunTime = (startDate, schedule, taskTime) => {
8
+ const [num, freq] = schedule.frequency.split('|');
9
+ const targetDate = moment(startDate).add(num, freq);
10
+ if (schedule.frequencyPeriod === 'first') {
11
+ targetDate.startOf(freq);
12
+ }
13
+ else if (schedule.frequencyPeriod === 'last') {
14
+ targetDate.endOf(freq);
15
+ }
16
+ const isWeekday = targetDate.isoWeekday() > 0 && targetDate.isoWeekday() < 6;
17
+ const isSaturday = targetDate.isoWeekday() === 6;
18
+ // The weekday or weekend chosen should be within the same month as the target date
19
+ if (schedule.frequencyDay === 'weekdays' && !isWeekday) {
20
+ if ((targetDate.date() / 7) < 2) {
21
+ targetDate.add(isSaturday ? 2 : 1, 'days');
22
+ }
23
+ else {
24
+ targetDate.subtract(isSaturday ? 1 : 2, 'days');
25
+ }
26
+ }
27
+ else if (schedule.frequencyDay === 'weekends' && isWeekday) {
28
+ if ((targetDate.date() / 7) < 2) {
29
+ targetDate.isoWeekday(6);
30
+ }
31
+ else {
32
+ targetDate.isoWeekday(0);
33
+ }
34
+ }
35
+ if (taskTime.isAfter(targetDate, 'minute')) {
36
+ return getNextRunTime(targetDate, schedule, taskTime);
37
+ }
38
+ return targetDate;
39
+ };
40
+ export const getScheduledReportRunTimes = (schedule, limit = 1, taskTime = moment()) => {
41
+ if (!schedule.startDate || !schedule.enabled)
42
+ return [];
43
+ const originalStartDate = moment.utc(schedule.startDate);
44
+ let startDate = originalStartDate;
45
+ const includeStartDate = taskTime.isSameOrBefore(originalStartDate, 'minute');
46
+ let runTimes = [];
47
+ if (includeStartDate) {
48
+ runTimes = [originalStartDate];
49
+ }
50
+ const [, freq] = schedule.frequency.split('|');
51
+ if (freq === 'once') {
52
+ const nextRunTime = runTimes[0];
53
+ // If this is now beyond the start date, return an empty array
54
+ return taskTime.isAfter(nextRunTime, 'minute') ? [] : runTimes;
55
+ }
56
+ const scheduleRunTimes = Array.from(Array(includeStartDate ? limit - 1 : limit).keys()).map(() => {
57
+ const nextRunTime = getNextRunTime(startDate, schedule, taskTime);
58
+ startDate = nextRunTime.hour(originalStartDate.hour()).minute(originalStartDate.minute());
59
+ return nextRunTime;
60
+ });
61
+ return [...runTimes, ...scheduleRunTimes];
62
+ };
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ postMessage: (message: string) => Promise<import("axios").AxiosResponse<any, any>>;
3
+ };
4
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import axios from 'axios';
2
+ const postMessage = async (message) => {
3
+ const url = 'https://hooks.slack.com/services/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';
4
+ const data = {
5
+ text: `[${(process.env.ENV || '').toUpperCase()}][${process.env.AWS_LAMBDA_FUNCTION_NAME}] ${message}`
6
+ };
7
+ const headers = {
8
+ 'Content-Type': 'application/json'
9
+ };
10
+ return axios.post(url, data, { headers });
11
+ };
12
+ export default {
13
+ postMessage
14
+ };
@@ -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 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export interface Address {
2
+ streetAddress: string;
3
+ locality?: string;
4
+ region?: string;
5
+ postCode: string;
6
+ province?: string;
7
+ countryCode?: string;
8
+ jurisdictionCode?: string;
9
+ latitude?: string;
10
+ longitude?: string;
11
+ }
@@ -0,0 +1 @@
1
+ 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,2 @@
1
+ ;
2
+ 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 @@
1
+ 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 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface DataIngest {
2
+ _id: string;
3
+ messageId: string;
4
+ status: 'started' | 'processing' | 'importing' | 'completed' | 'failed' | 'dlq';
5
+ context: any;
6
+ startTime: string;
7
+ remainingTime: number;
8
+ }
@@ -0,0 +1 @@
1
+ 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 @@
1
+ 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 @@
1
+ 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 @@
1
+ export {};