@etainabl/nodejs-sdk 1.2.43 → 1.2.45
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/package.json +3 -0
- package/dist/esm/package.json +3 -0
- package/dist/index.d.cts +782 -0
- package/dist/index.d.ts +782 -0
- package/dist/index.js +626 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +588 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +27 -26
- package/.prettierrc +0 -11
- package/__tests__/reporting.test.ts +0 -88
- package/dist/cjs/index.js +0 -59
- package/eslint.config.js +0 -60
- package/fixup.sh +0 -11
- package/package-lock.json +0 -6327
- package/src/api.ts +0 -382
- package/src/consumption.ts +0 -40
- package/src/db.ts +0 -69
- package/src/etainabl.ts +0 -10
- package/src/index.ts +0 -21
- package/src/logger.ts +0 -13
- package/src/monitoring.ts +0 -18
- package/src/reporting.ts +0 -78
- package/src/slack.ts +0 -16
- package/src/types/account.ts +0 -116
- package/src/types/address.ts +0 -12
- package/src/types/asset.ts +0 -142
- package/src/types/automation.ts +0 -35
- package/src/types/company.ts +0 -47
- package/src/types/dataIngest.ts +0 -8
- package/src/types/email.ts +0 -18
- package/src/types/entity.ts +0 -17
- package/src/types/index.ts +0 -20
- package/src/types/invoice.ts +0 -119
- package/src/types/log.ts +0 -10
- package/src/types/portal.ts +0 -9
- package/src/types/reading.ts +0 -17
- package/src/types/report.ts +0 -21
- package/src/types/scraperRun.ts +0 -15
- package/src/types/statusHistory.ts +0 -5
- package/src/types/supplier.ts +0 -31
- package/src/units.ts +0 -111
- package/tsconfig.base.json +0 -31
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.json +0 -9
- package/tsconfig.test.json +0 -13
- package/vitest.config.js +0 -10
- package/vitest.workspace.js +0 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import * as axios from 'axios';
|
|
2
|
+
import { CreateAxiosDefaults, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
3
|
+
import winston from 'winston';
|
|
4
|
+
import { Db } from 'mongodb';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
|
|
7
|
+
interface Portal {
|
|
8
|
+
username?: string;
|
|
9
|
+
password?: string;
|
|
10
|
+
scraperEnabled?: boolean;
|
|
11
|
+
url?: string;
|
|
12
|
+
scraperId?: string;
|
|
13
|
+
scraperStartDate?: Date;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface StatusHistory {
|
|
17
|
+
date: Date;
|
|
18
|
+
value: 'active' | 'inactive';
|
|
19
|
+
notes?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface PortalAccountSchema extends Portal {
|
|
23
|
+
invoiceFilenames: any[];
|
|
24
|
+
}
|
|
25
|
+
interface RateSchema {
|
|
26
|
+
type: string;
|
|
27
|
+
value: number;
|
|
28
|
+
description: string;
|
|
29
|
+
}
|
|
30
|
+
interface ContractSchema {
|
|
31
|
+
startDate: Date;
|
|
32
|
+
endDate: Date;
|
|
33
|
+
terminationDate?: Date;
|
|
34
|
+
paymentTerms?: string;
|
|
35
|
+
duration?: string;
|
|
36
|
+
tariffName?: string;
|
|
37
|
+
contractConsumption?: number;
|
|
38
|
+
volumeTolerance?: any[];
|
|
39
|
+
renewablePercentage?: number;
|
|
40
|
+
marketBasedEmissionFactor?: number;
|
|
41
|
+
chargeableCclPercentage?: number;
|
|
42
|
+
commissionRates?: number;
|
|
43
|
+
rates: any[];
|
|
44
|
+
s3Key?: string;
|
|
45
|
+
rateTypeMapping?: object;
|
|
46
|
+
batchId?: string;
|
|
47
|
+
supplierId?: string;
|
|
48
|
+
status: 'active' | 'inactive';
|
|
49
|
+
userSub?: string;
|
|
50
|
+
deletedOn?: Date;
|
|
51
|
+
}
|
|
52
|
+
interface CreditNoteSchema {
|
|
53
|
+
name: string;
|
|
54
|
+
type: string;
|
|
55
|
+
amount: number;
|
|
56
|
+
netAmount: number;
|
|
57
|
+
taxAmount: number;
|
|
58
|
+
date: Date;
|
|
59
|
+
isPaid: boolean;
|
|
60
|
+
s3Key: string;
|
|
61
|
+
stampedS3Key: string;
|
|
62
|
+
fileName: string;
|
|
63
|
+
invoiceData: object;
|
|
64
|
+
userSub: string;
|
|
65
|
+
readingIds: any[];
|
|
66
|
+
supplierId: string;
|
|
67
|
+
totalUnits: number;
|
|
68
|
+
endDate: Date;
|
|
69
|
+
startDate: Date;
|
|
70
|
+
stampDate: Date;
|
|
71
|
+
totalWaterVolume: number;
|
|
72
|
+
totalWasteVolume: number;
|
|
73
|
+
totalWaterCost: number;
|
|
74
|
+
totalWasteCost: number;
|
|
75
|
+
}
|
|
76
|
+
interface Account {
|
|
77
|
+
_id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
modifiedBy?: string;
|
|
80
|
+
siteCode?: string;
|
|
81
|
+
type: 'gas' | 'electricity' | 'water' | 'waste' | 'solar';
|
|
82
|
+
supplierRef?: string;
|
|
83
|
+
financialCode?: string;
|
|
84
|
+
propertyCode?: string;
|
|
85
|
+
meterPointNumber?: string;
|
|
86
|
+
meterSerialNumber?: string;
|
|
87
|
+
meterPointNumber2?: string;
|
|
88
|
+
meterUnits: 'kwh' | 'm3' | 'ft3';
|
|
89
|
+
automaticMeterRead?: boolean;
|
|
90
|
+
status?: 'active' | 'inactive';
|
|
91
|
+
statusHistory?: StatusHistory[];
|
|
92
|
+
rates?: RateSchema[];
|
|
93
|
+
capacity?: string;
|
|
94
|
+
meterOperator?: string;
|
|
95
|
+
meterLocation?: string;
|
|
96
|
+
meterOperatorType?: 'lease' | 'purchase';
|
|
97
|
+
meterOperatorExpiryDate?: Date;
|
|
98
|
+
dataCollector?: string;
|
|
99
|
+
parentAccountId?: string;
|
|
100
|
+
processingInvoices?: object[];
|
|
101
|
+
contracts?: ContractSchema[];
|
|
102
|
+
creditNotes?: CreditNoteSchema[];
|
|
103
|
+
meterUser?: string;
|
|
104
|
+
isTrc?: boolean;
|
|
105
|
+
floorArea?: string;
|
|
106
|
+
floorAreaUnit?: 'metric' | 'imperial';
|
|
107
|
+
reportingType?: string;
|
|
108
|
+
solarType?: 'generation' | 'export';
|
|
109
|
+
consumptionSource?: 'primary' | 'sub' | 'primary-sub';
|
|
110
|
+
esec?: 'a' | 'b' | 'c' | 'd' | 'e' | 'g' | 'h' | 'j' | 'k' | 'l' | 'm' | 'n' | 'p' | 'q' | 'r' | 's' | 't' | 'u';
|
|
111
|
+
portal?: PortalAccountSchema;
|
|
112
|
+
deviceId?: string;
|
|
113
|
+
gridfetchLoa?: {
|
|
114
|
+
s3Key?: string;
|
|
115
|
+
name?: string;
|
|
116
|
+
uploadedBy?: string;
|
|
117
|
+
uploadedAt?: Date;
|
|
118
|
+
expiryDate?: Date;
|
|
119
|
+
error?: string;
|
|
120
|
+
uploaded?: boolean;
|
|
121
|
+
};
|
|
122
|
+
automationIds?: string[];
|
|
123
|
+
customIntegrations?: object;
|
|
124
|
+
supplierId?: string;
|
|
125
|
+
batchId?: string;
|
|
126
|
+
assetId: string;
|
|
127
|
+
entityId: string;
|
|
128
|
+
companyId: string;
|
|
129
|
+
userSub: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface Address {
|
|
133
|
+
streetAddress: string;
|
|
134
|
+
locality?: string;
|
|
135
|
+
region?: string;
|
|
136
|
+
postCode: string;
|
|
137
|
+
province?: string;
|
|
138
|
+
countryCode?: string;
|
|
139
|
+
jurisdictionCode?: string;
|
|
140
|
+
latitude?: string;
|
|
141
|
+
longitude?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface Image {
|
|
145
|
+
url?: string;
|
|
146
|
+
label?: string;
|
|
147
|
+
type?: string;
|
|
148
|
+
isHidden?: boolean;
|
|
149
|
+
isPrimary?: boolean;
|
|
150
|
+
}
|
|
151
|
+
interface FloodRisk {
|
|
152
|
+
url?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
label?: string;
|
|
155
|
+
latitude?: number;
|
|
156
|
+
longitude?: number;
|
|
157
|
+
fetchedAt?: Date;
|
|
158
|
+
}
|
|
159
|
+
interface Crime {
|
|
160
|
+
category?: string;
|
|
161
|
+
month?: string;
|
|
162
|
+
crimeId?: string;
|
|
163
|
+
outcomeCategory?: string;
|
|
164
|
+
outcomeDate?: string;
|
|
165
|
+
location?: {
|
|
166
|
+
latitude: string;
|
|
167
|
+
longitude: string;
|
|
168
|
+
street: string;
|
|
169
|
+
};
|
|
170
|
+
fetchedAt?: Date;
|
|
171
|
+
}
|
|
172
|
+
interface AirQuality {
|
|
173
|
+
index?: number;
|
|
174
|
+
indexColour?: string;
|
|
175
|
+
indexRating?: string;
|
|
176
|
+
details?: object;
|
|
177
|
+
location?: object;
|
|
178
|
+
lastMeasured?: Date;
|
|
179
|
+
fetchedAt?: Date;
|
|
180
|
+
}
|
|
181
|
+
interface Benchmark {
|
|
182
|
+
benchmarkId: string;
|
|
183
|
+
fieldCode: string;
|
|
184
|
+
fieldValue: string;
|
|
185
|
+
}
|
|
186
|
+
interface Document {
|
|
187
|
+
s3Key?: string;
|
|
188
|
+
name: string;
|
|
189
|
+
extension?: string;
|
|
190
|
+
type: string;
|
|
191
|
+
status: string;
|
|
192
|
+
score?: string;
|
|
193
|
+
providerId?: string;
|
|
194
|
+
providerData?: object;
|
|
195
|
+
certificate?: object;
|
|
196
|
+
createdAt: Date;
|
|
197
|
+
accountIds?: string[];
|
|
198
|
+
}
|
|
199
|
+
interface TimelineEvent {
|
|
200
|
+
date: Date;
|
|
201
|
+
title: string;
|
|
202
|
+
status: string;
|
|
203
|
+
content?: string;
|
|
204
|
+
icon?: string;
|
|
205
|
+
accountIds?: string[];
|
|
206
|
+
}
|
|
207
|
+
interface AssetRecommendation {
|
|
208
|
+
recommendationId: string;
|
|
209
|
+
documentIds?: string[];
|
|
210
|
+
}
|
|
211
|
+
interface AssetSettings {
|
|
212
|
+
consumptionSources: {
|
|
213
|
+
electricity: string;
|
|
214
|
+
solar: string;
|
|
215
|
+
gas: string;
|
|
216
|
+
water: string;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
interface Asset {
|
|
220
|
+
_id: string;
|
|
221
|
+
siteName: string;
|
|
222
|
+
address: Address;
|
|
223
|
+
assetType: string;
|
|
224
|
+
floorArea: number;
|
|
225
|
+
floorAreaUnit: 'metric' | 'imperial';
|
|
226
|
+
noOfFloors?: number;
|
|
227
|
+
energyRating: string;
|
|
228
|
+
gav: string;
|
|
229
|
+
gavCurrency: string;
|
|
230
|
+
currency: string;
|
|
231
|
+
occupationStatus: 'occupied' | 'vacant' | 'other' | 'n/a';
|
|
232
|
+
type: 'new construction' | 'major renovation' | 'standing investment' | 'n/a';
|
|
233
|
+
vacancyRate?: number;
|
|
234
|
+
constructionYear?: number;
|
|
235
|
+
ownedSince?: Date;
|
|
236
|
+
disposalDate?: Date;
|
|
237
|
+
tenure: 'freehold' | 'leasehold';
|
|
238
|
+
tenantControlledPercent?: number;
|
|
239
|
+
landlordControlledPercent?: number;
|
|
240
|
+
occupancyLevel?: number;
|
|
241
|
+
images: Image[];
|
|
242
|
+
pricePaid?: number;
|
|
243
|
+
floodRisks: FloodRisk[];
|
|
244
|
+
recentCrimes: Crime[];
|
|
245
|
+
recentAirQuality: AirQuality;
|
|
246
|
+
documents?: Document[];
|
|
247
|
+
epbCertificates: any[];
|
|
248
|
+
status?: string;
|
|
249
|
+
settings: AssetSettings;
|
|
250
|
+
recommendations?: AssetRecommendation[];
|
|
251
|
+
statusHistory: StatusHistory[];
|
|
252
|
+
timelineEvents: TimelineEvent[];
|
|
253
|
+
benchmarks: Benchmark[];
|
|
254
|
+
lastPopulated?: Date;
|
|
255
|
+
deletedOn?: Date;
|
|
256
|
+
batchId?: string;
|
|
257
|
+
companyId: string;
|
|
258
|
+
entityId: string;
|
|
259
|
+
assetGroupIds: string[];
|
|
260
|
+
userSub: string;
|
|
261
|
+
gresbId?: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
interface Log$1 {
|
|
265
|
+
message: string;
|
|
266
|
+
timestamp: Date;
|
|
267
|
+
batchId?: string;
|
|
268
|
+
source?: string;
|
|
269
|
+
}
|
|
270
|
+
interface LastCollection {
|
|
271
|
+
collectedAt: Date | null;
|
|
272
|
+
data: Record<string, any> | null;
|
|
273
|
+
error: Record<string, any> | null;
|
|
274
|
+
status: 'success' | 'error' | 'pending';
|
|
275
|
+
source: Record<string, any> | null;
|
|
276
|
+
}
|
|
277
|
+
type FrequencyType = 'never' | 'trigger' | 'hourly' | 'daily' | 'weekly' | 'monthly';
|
|
278
|
+
interface Automation {
|
|
279
|
+
_id: string;
|
|
280
|
+
description?: string;
|
|
281
|
+
service: string;
|
|
282
|
+
source: string;
|
|
283
|
+
category: string;
|
|
284
|
+
active: boolean;
|
|
285
|
+
status?: 'running' | 'pending';
|
|
286
|
+
lastCollection: LastCollection;
|
|
287
|
+
logs: Log$1[];
|
|
288
|
+
data: Record<string, any>;
|
|
289
|
+
sourceData: Record<string, any>;
|
|
290
|
+
frequency?: FrequencyType;
|
|
291
|
+
accountIds?: string[];
|
|
292
|
+
assetIds?: string[];
|
|
293
|
+
userSub: string;
|
|
294
|
+
companyId: string;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface SupplierPortals {
|
|
298
|
+
supplierId: string;
|
|
299
|
+
portal: Portal;
|
|
300
|
+
}
|
|
301
|
+
interface CustomIntegrations {
|
|
302
|
+
account: any[];
|
|
303
|
+
asset: any[];
|
|
304
|
+
entity: any[];
|
|
305
|
+
}
|
|
306
|
+
interface DefaultSources {
|
|
307
|
+
electricity: 'invoice' | 'consumption' | 'reading';
|
|
308
|
+
solar: 'invoice' | 'consumption' | 'reading';
|
|
309
|
+
gas: 'invoice' | 'consumption' | 'reading';
|
|
310
|
+
water: 'invoice' | 'consumption' | 'reading';
|
|
311
|
+
}
|
|
312
|
+
interface CompanySettings {
|
|
313
|
+
showLogo?: boolean;
|
|
314
|
+
invoiceCategories?: any[];
|
|
315
|
+
miscInvoiceCategories?: any[];
|
|
316
|
+
messageCategories?: any[];
|
|
317
|
+
documentCategories?: any[];
|
|
318
|
+
assetDataSchemas?: any[];
|
|
319
|
+
hideCostData?: boolean;
|
|
320
|
+
calendarPeriod?: string;
|
|
321
|
+
customIntegrations?: CustomIntegrations;
|
|
322
|
+
supplierPortals?: SupplierPortals[];
|
|
323
|
+
defaultSources?: DefaultSources;
|
|
324
|
+
scraperCounter?: number;
|
|
325
|
+
}
|
|
326
|
+
interface Company {
|
|
327
|
+
_id: string;
|
|
328
|
+
name: string;
|
|
329
|
+
address?: Address;
|
|
330
|
+
invoiceEmail?: string;
|
|
331
|
+
users?: string[];
|
|
332
|
+
settings: CompanySettings;
|
|
333
|
+
logoS3Key: string;
|
|
334
|
+
logoUrl?: string;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
interface CreateScraperRunParams {
|
|
338
|
+
supplierId: string;
|
|
339
|
+
accountId: string;
|
|
340
|
+
companyId: string;
|
|
341
|
+
}
|
|
342
|
+
interface ScraperRun {
|
|
343
|
+
_id: string;
|
|
344
|
+
logs?: {}[];
|
|
345
|
+
supplierId: string;
|
|
346
|
+
accountId: string;
|
|
347
|
+
companyId: string;
|
|
348
|
+
invoiceData?: [];
|
|
349
|
+
status: string[];
|
|
350
|
+
error?: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
interface DataIngest {
|
|
354
|
+
_id: string;
|
|
355
|
+
messageId: string;
|
|
356
|
+
status: 'started' | 'processing' | 'importing' | 'completed' | 'failed' | 'dlq';
|
|
357
|
+
context: any;
|
|
358
|
+
startTime: string;
|
|
359
|
+
remainingTime: number;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
type EntityType = 'fund' | 'company' | 'charity' | 'school/university' | 'council' | 'other';
|
|
363
|
+
interface Entity {
|
|
364
|
+
_id: string;
|
|
365
|
+
legalName: string;
|
|
366
|
+
type: EntityType;
|
|
367
|
+
companyNumber?: string;
|
|
368
|
+
companyLogo?: string;
|
|
369
|
+
billingAddress: Address;
|
|
370
|
+
parentEntityId?: string;
|
|
371
|
+
ultimateParentEntityId?: string;
|
|
372
|
+
companyId: string;
|
|
373
|
+
batchId?: string;
|
|
374
|
+
userSub: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
interface Attachment {
|
|
378
|
+
filename: string;
|
|
379
|
+
s3Key: string;
|
|
380
|
+
}
|
|
381
|
+
interface Email {
|
|
382
|
+
_id: string;
|
|
383
|
+
destinations: string[];
|
|
384
|
+
service: string;
|
|
385
|
+
subject: string;
|
|
386
|
+
body: string;
|
|
387
|
+
from: string;
|
|
388
|
+
attachments?: Attachment[];
|
|
389
|
+
sesMessageId: string;
|
|
390
|
+
s3Key: string;
|
|
391
|
+
userSub?: string;
|
|
392
|
+
companyId?: string;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
interface Values {
|
|
396
|
+
friendlyInvoiceNumber?: string;
|
|
397
|
+
friendlySupplierRef?: string;
|
|
398
|
+
friendlyStartDate?: string;
|
|
399
|
+
friendlyEndDate?: string;
|
|
400
|
+
friendlyInvoiceDate?: string;
|
|
401
|
+
friendlyMeterPointNumber?: string;
|
|
402
|
+
friendlyMeterPointNumber2?: string;
|
|
403
|
+
friendlyMeterSerialNumber?: string;
|
|
404
|
+
friendlyPipeSize?: string;
|
|
405
|
+
friendlyTotalUnitCost?: number;
|
|
406
|
+
friendlyTotalWaterCost?: number;
|
|
407
|
+
friendlyTotalWasteCost?: number;
|
|
408
|
+
friendlyTotalDaily?: number;
|
|
409
|
+
friendlyTotalLevy?: number;
|
|
410
|
+
friendlyTotalKva?: number;
|
|
411
|
+
friendlyTotalUnits?: number;
|
|
412
|
+
friendlyTotalWaterVolume?: number;
|
|
413
|
+
friendlyTotalWasteVolume?: number;
|
|
414
|
+
friendlyNetTotalCost?: number;
|
|
415
|
+
friendlyTotalTax?: number;
|
|
416
|
+
friendlyTotalCost?: number;
|
|
417
|
+
friendlyMeteredConsumption?: string;
|
|
418
|
+
friendlyCorrectedConsumption?: string;
|
|
419
|
+
friendlyCorrectionFactor?: string;
|
|
420
|
+
friendlyCalorificValue?: string;
|
|
421
|
+
friendlyReadFactor?: string;
|
|
422
|
+
friendlyType?: string;
|
|
423
|
+
friendlyStartRead?: string;
|
|
424
|
+
friendlyEndRead?: string;
|
|
425
|
+
invoiceNumber?: string;
|
|
426
|
+
supplierRef?: string;
|
|
427
|
+
startDate?: Date;
|
|
428
|
+
endDate?: Date;
|
|
429
|
+
invoiceDate?: Date;
|
|
430
|
+
meterPointNumber?: string;
|
|
431
|
+
meterPointNumber2?: string;
|
|
432
|
+
meterSerialNumber?: string;
|
|
433
|
+
pipeSize?: string;
|
|
434
|
+
totalUnitCost?: number;
|
|
435
|
+
totalWaterCost?: number;
|
|
436
|
+
totalWasteCost?: number;
|
|
437
|
+
totalDaily?: number;
|
|
438
|
+
totalLevy?: number;
|
|
439
|
+
totalKva?: number;
|
|
440
|
+
totalUnits?: number;
|
|
441
|
+
totalWaterVolume?: number;
|
|
442
|
+
totalWasteVolume?: number;
|
|
443
|
+
netTotalCost?: number;
|
|
444
|
+
totalTax?: number;
|
|
445
|
+
totalCost?: number;
|
|
446
|
+
meteredConsumption?: string;
|
|
447
|
+
correctedConsumption?: string;
|
|
448
|
+
correctionFactor?: string;
|
|
449
|
+
calorificValue?: string;
|
|
450
|
+
readFactor?: string;
|
|
451
|
+
type?: string;
|
|
452
|
+
startRead?: string;
|
|
453
|
+
endRead?: string;
|
|
454
|
+
}
|
|
455
|
+
interface Rate {
|
|
456
|
+
consumption?: string;
|
|
457
|
+
cost?: string;
|
|
458
|
+
endDate?: Date | null;
|
|
459
|
+
endRead?: string | null;
|
|
460
|
+
endReadType?: string | null;
|
|
461
|
+
rateName?: string | null;
|
|
462
|
+
startDate?: Date | null;
|
|
463
|
+
startRead?: string | null;
|
|
464
|
+
startReadType?: string | null;
|
|
465
|
+
type: RateType | null;
|
|
466
|
+
unitRate?: string | null;
|
|
467
|
+
}
|
|
468
|
+
type InvoiceStatus = 'processing' | 'pending' | 'uploading' | 'queued' | 'captured' | 'error' | 'completed';
|
|
469
|
+
type FinancialStatus = 'approved' | 'new' | 'not-approved' | 'paid' | 'sent-for-payment';
|
|
470
|
+
type RateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
|
|
471
|
+
interface Invoice {
|
|
472
|
+
_id: string;
|
|
473
|
+
jobId?: string | null;
|
|
474
|
+
startTime?: Date;
|
|
475
|
+
endTime?: Date | null;
|
|
476
|
+
s3Key: string;
|
|
477
|
+
s3TextractKey?: string | null;
|
|
478
|
+
stampedS3Key: string | null;
|
|
479
|
+
fileName?: string | null;
|
|
480
|
+
status: InvoiceStatus;
|
|
481
|
+
financialStatus: FinancialStatus;
|
|
482
|
+
completed?: boolean;
|
|
483
|
+
type?: string | null;
|
|
484
|
+
tags?: string[];
|
|
485
|
+
manualResults?: Record<string, any>;
|
|
486
|
+
values?: Values;
|
|
487
|
+
rates?: Rate[];
|
|
488
|
+
detailedResults?: Record<string, any>;
|
|
489
|
+
templateVersion?: string | null;
|
|
490
|
+
error?: Record<string, any>;
|
|
491
|
+
isPaid?: boolean;
|
|
492
|
+
isCreditNote?: boolean;
|
|
493
|
+
isConvertedCreditNote?: boolean;
|
|
494
|
+
isManual?: boolean;
|
|
495
|
+
uploaderStatus?: string;
|
|
496
|
+
simulated?: boolean;
|
|
497
|
+
notes?: string | null;
|
|
498
|
+
assignedTo?: string;
|
|
499
|
+
noScrape?: boolean;
|
|
500
|
+
scraperInvoiceId?: string;
|
|
501
|
+
confirmedAt?: Date | null;
|
|
502
|
+
confirmedBy?: string | null;
|
|
503
|
+
supplierId?: string | null;
|
|
504
|
+
sisterId?: string | null;
|
|
505
|
+
batchId?: string | null;
|
|
506
|
+
accountId?: string | null;
|
|
507
|
+
entityId?: string;
|
|
508
|
+
companyId: string;
|
|
509
|
+
userSub: string;
|
|
510
|
+
validation?: any[];
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
interface Log {
|
|
514
|
+
_id: string;
|
|
515
|
+
message: string;
|
|
516
|
+
context?: {};
|
|
517
|
+
linkedId?: string;
|
|
518
|
+
linkedType?: string;
|
|
519
|
+
type: string;
|
|
520
|
+
userSub?: string;
|
|
521
|
+
companyId?: string;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
interface Reading {
|
|
525
|
+
_id: string;
|
|
526
|
+
submittedAt: Date;
|
|
527
|
+
value: number;
|
|
528
|
+
type?: string;
|
|
529
|
+
invoiceStartRead?: number;
|
|
530
|
+
source: string;
|
|
531
|
+
invoiceId?: string;
|
|
532
|
+
rateId?: string;
|
|
533
|
+
contractRateType?: string;
|
|
534
|
+
invoiceBatchId?: string;
|
|
535
|
+
batchId?: string;
|
|
536
|
+
accountId: string;
|
|
537
|
+
entityId: string;
|
|
538
|
+
companyId: string;
|
|
539
|
+
userSub?: string;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
interface Report {
|
|
543
|
+
_id: string;
|
|
544
|
+
type: 'dynamic' | 'spreadsheet' | 'table' | 'pdf';
|
|
545
|
+
subType?: string;
|
|
546
|
+
fileFormat: 'pdf' | 'xlsx' | 'csv' | 'png' | 'jpg' | 'chart';
|
|
547
|
+
fileName?: string;
|
|
548
|
+
status: 'preparing' | 'ready';
|
|
549
|
+
scheduled?: boolean;
|
|
550
|
+
version?: number;
|
|
551
|
+
metadata?: Record<string, any>;
|
|
552
|
+
data?: Record<string, any>;
|
|
553
|
+
requestedAt: Date;
|
|
554
|
+
availableAt?: Date;
|
|
555
|
+
s3Key: string | null;
|
|
556
|
+
batchId?: string;
|
|
557
|
+
scheduledReportId?: string;
|
|
558
|
+
reportTemplateId?: string;
|
|
559
|
+
entityId: string;
|
|
560
|
+
companyId: string;
|
|
561
|
+
userSub?: string;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
interface PortalSupplierSchema extends Portal {
|
|
565
|
+
concurrent: boolean;
|
|
566
|
+
checkInvoiceFilenames: boolean;
|
|
567
|
+
supplierRefRequired: boolean;
|
|
568
|
+
}
|
|
569
|
+
interface InvoiceOptionsSchema {
|
|
570
|
+
stampPositionX?: number;
|
|
571
|
+
stampPositionY?: number;
|
|
572
|
+
}
|
|
573
|
+
interface Supplier {
|
|
574
|
+
_id: string;
|
|
575
|
+
name: string;
|
|
576
|
+
logoUrl?: string;
|
|
577
|
+
websiteUrl?: string;
|
|
578
|
+
portalUrl?: string;
|
|
579
|
+
identifier?: string;
|
|
580
|
+
type: 'supplier' | 'distributor';
|
|
581
|
+
region?: string;
|
|
582
|
+
countryCode: string;
|
|
583
|
+
defaultScraper?: string;
|
|
584
|
+
active: boolean;
|
|
585
|
+
transferSupplier: boolean;
|
|
586
|
+
transferSupplierId?: string;
|
|
587
|
+
portal: PortalSupplierSchema;
|
|
588
|
+
invoiceOptions?: InvoiceOptionsSchema;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
interface ETNPagedResponse$1<T = any> {
|
|
592
|
+
data: T[];
|
|
593
|
+
total: number;
|
|
594
|
+
limit: number;
|
|
595
|
+
skip: number;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
interface ETNPagedResponse<T = any> {
|
|
599
|
+
data: T[];
|
|
600
|
+
total: number;
|
|
601
|
+
limit: number;
|
|
602
|
+
skip: number;
|
|
603
|
+
}
|
|
604
|
+
interface AuthOptions {
|
|
605
|
+
key?: string;
|
|
606
|
+
token?: string;
|
|
607
|
+
}
|
|
608
|
+
declare const _default$3: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
|
|
609
|
+
instance: AxiosInstance;
|
|
610
|
+
getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account>;
|
|
611
|
+
listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Account>>;
|
|
612
|
+
updateAccount: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
613
|
+
createAccount: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
614
|
+
removeAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
615
|
+
getAccountSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
616
|
+
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
617
|
+
getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset>;
|
|
618
|
+
listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Asset>>;
|
|
619
|
+
updateAsset: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
620
|
+
createAsset: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
621
|
+
removeAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
622
|
+
getAssetSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
623
|
+
getAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
624
|
+
listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
625
|
+
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
626
|
+
createAssetGroup: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
627
|
+
removeAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
628
|
+
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
629
|
+
getAssetGroupSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
630
|
+
getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation>;
|
|
631
|
+
listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Automation>>;
|
|
632
|
+
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
633
|
+
createAutomation: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
634
|
+
removeAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
635
|
+
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
636
|
+
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
637
|
+
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
638
|
+
getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<Company>;
|
|
639
|
+
getConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
640
|
+
listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
641
|
+
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
642
|
+
createConsumption: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
643
|
+
removeConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
644
|
+
getConsumptionSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
645
|
+
getEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
646
|
+
listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
647
|
+
updateEmail: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
648
|
+
createEmail: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
649
|
+
removeEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
650
|
+
getEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
651
|
+
listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
652
|
+
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
653
|
+
createEmissionFactor: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
654
|
+
removeEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
655
|
+
getEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<Entity>;
|
|
656
|
+
listEntities: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Entity>>;
|
|
657
|
+
updateEntity: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
658
|
+
createEntity: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
659
|
+
removeEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
660
|
+
getEntitiesSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
661
|
+
getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log>;
|
|
662
|
+
listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Log>>;
|
|
663
|
+
updateLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
664
|
+
createLog: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
665
|
+
removeLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
666
|
+
getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading>;
|
|
667
|
+
listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Reading>>;
|
|
668
|
+
updateReading: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
669
|
+
createReading: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
670
|
+
removeReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
671
|
+
getReadingSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
672
|
+
getReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<Report>;
|
|
673
|
+
listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Report>>;
|
|
674
|
+
updateReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
675
|
+
createReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
676
|
+
removeReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
677
|
+
sendReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
678
|
+
getReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
679
|
+
listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
680
|
+
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
681
|
+
createReportTemplate: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
682
|
+
removeReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
683
|
+
getScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
684
|
+
listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
685
|
+
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
686
|
+
createScheduledReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
687
|
+
removeScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
688
|
+
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
689
|
+
getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice>;
|
|
690
|
+
listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Invoice>>;
|
|
691
|
+
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
692
|
+
createInvoice: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
693
|
+
removeInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
694
|
+
getInvoiceSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
695
|
+
listSuppliers: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Supplier>>;
|
|
696
|
+
getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
697
|
+
getImportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
698
|
+
updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
699
|
+
createDataIngest: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
700
|
+
listDataIngest: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<DataIngest>>;
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
declare const _default$2: (namespace: string) => winston.Logger;
|
|
704
|
+
|
|
705
|
+
declare function connectToDatabase(retryAttempt?: number): Promise<Db>;
|
|
706
|
+
declare const _default$1: {
|
|
707
|
+
connectToDatabase: typeof connectToDatabase;
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
declare const _default: {
|
|
711
|
+
postMessage: (message: string) => Promise<axios.AxiosResponse<any, any>>;
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
interface Item {
|
|
715
|
+
units?: string | null;
|
|
716
|
+
unit?: string | null;
|
|
717
|
+
factor?: number | null;
|
|
718
|
+
value: number;
|
|
719
|
+
[key: string]: any;
|
|
720
|
+
}
|
|
721
|
+
type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';
|
|
722
|
+
type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';
|
|
723
|
+
type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';
|
|
724
|
+
declare const accountTypeMap: {
|
|
725
|
+
[key: string]: BaseUnit;
|
|
726
|
+
};
|
|
727
|
+
declare const accountTypeUnitMap: {
|
|
728
|
+
[key: string]: ETNUnit[];
|
|
729
|
+
};
|
|
730
|
+
declare const convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined) => any;
|
|
731
|
+
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | '') => {
|
|
732
|
+
type: AccountType;
|
|
733
|
+
unit: ETNUnit;
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
type units_AccountType = AccountType;
|
|
737
|
+
type units_BaseUnit = BaseUnit;
|
|
738
|
+
type units_ETNUnit = ETNUnit;
|
|
739
|
+
declare const units_accountTypeMap: typeof accountTypeMap;
|
|
740
|
+
declare const units_accountTypeUnitMap: typeof accountTypeUnitMap;
|
|
741
|
+
declare const units_checkAccountTypeVsUnits: typeof checkAccountTypeVsUnits;
|
|
742
|
+
declare const units_convertItems: typeof convertItems;
|
|
743
|
+
declare namespace units {
|
|
744
|
+
export { type units_AccountType as AccountType, type units_BaseUnit as BaseUnit, type units_ETNUnit as ETNUnit, units_accountTypeMap as accountTypeMap, units_accountTypeUnitMap as accountTypeUnitMap, units_checkAccountTypeVsUnits as checkAccountTypeVsUnits, units_convertItems as convertItems };
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
interface ConsumptionData {
|
|
748
|
+
date: Date;
|
|
749
|
+
consumption: number;
|
|
750
|
+
}
|
|
751
|
+
declare const dayNightConsumption: (data: ConsumptionData[]) => {
|
|
752
|
+
dayConsumption: number;
|
|
753
|
+
nightConsumption: number;
|
|
754
|
+
consumption: number;
|
|
755
|
+
};
|
|
756
|
+
declare const calcMaxConsumptionValue: (data: ConsumptionData[]) => number;
|
|
757
|
+
declare const calcMaxDemand: (data: ConsumptionData[]) => number;
|
|
758
|
+
declare const calcPeakLoad: (consumption: number, maxDemand: number, startDate: string | moment.Moment, endDate: string | moment.Moment) => number;
|
|
759
|
+
|
|
760
|
+
declare const consumption_calcMaxConsumptionValue: typeof calcMaxConsumptionValue;
|
|
761
|
+
declare const consumption_calcMaxDemand: typeof calcMaxDemand;
|
|
762
|
+
declare const consumption_calcPeakLoad: typeof calcPeakLoad;
|
|
763
|
+
declare const consumption_dayNightConsumption: typeof dayNightConsumption;
|
|
764
|
+
declare namespace consumption {
|
|
765
|
+
export { consumption_calcMaxConsumptionValue as calcMaxConsumptionValue, consumption_calcMaxDemand as calcMaxDemand, consumption_calcPeakLoad as calcPeakLoad, consumption_dayNightConsumption as dayNightConsumption };
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
declare const sendHeartbeat: () => Promise<boolean>;
|
|
769
|
+
|
|
770
|
+
declare const monitoring_sendHeartbeat: typeof sendHeartbeat;
|
|
771
|
+
declare namespace monitoring {
|
|
772
|
+
export { monitoring_sendHeartbeat as sendHeartbeat };
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
declare const getScheduledReportRunTimes: (schedule: any, limit?: number, taskTime?: moment.Moment) => moment.Moment[];
|
|
776
|
+
|
|
777
|
+
declare const reporting_getScheduledReportRunTimes: typeof getScheduledReportRunTimes;
|
|
778
|
+
declare namespace reporting {
|
|
779
|
+
export { reporting_getScheduledReportRunTimes as getScheduledReportRunTimes };
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
export { type Account, type Asset, type Automation, type Company, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type Log, type Reading, type Report, type ScraperRun, type Supplier, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
|