@etainabl/nodejs-sdk 1.2.50 → 1.2.52

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/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as axios from 'axios';
2
2
  import { CreateAxiosDefaults, AxiosInstance, AxiosRequestConfig } from 'axios';
3
+ import { ObjectId, Db } from 'mongodb';
3
4
  import winston from 'winston';
4
- import { Db } from 'mongodb';
5
5
  import moment from 'moment';
6
6
 
7
7
  interface Portal {
@@ -9,7 +9,7 @@ interface Portal {
9
9
  password?: string;
10
10
  scraperEnabled?: boolean;
11
11
  url?: string;
12
- scraperId?: string;
12
+ scraperId?: ObjectId | string;
13
13
  scraperStartDate?: Date;
14
14
  }
15
15
 
@@ -19,6 +19,8 @@ interface StatusHistory {
19
19
  notes?: string;
20
20
  }
21
21
 
22
+ type UtilityType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';
23
+
22
24
  interface PortalAccountSchema extends Portal {
23
25
  invoiceFilenames: any[];
24
26
  }
@@ -28,6 +30,7 @@ interface RateSchema {
28
30
  description: string;
29
31
  }
30
32
  interface ContractSchema {
33
+ _id: ObjectId | string;
31
34
  startDate: Date;
32
35
  endDate: Date;
33
36
  terminationDate?: Date;
@@ -44,12 +47,13 @@ interface ContractSchema {
44
47
  s3Key?: string;
45
48
  rateTypeMapping?: object;
46
49
  batchId?: string;
47
- supplierId?: string;
50
+ supplierId?: ObjectId | string;
48
51
  status: 'active' | 'inactive';
49
52
  userSub?: string;
50
53
  deletedOn?: Date;
51
54
  }
52
55
  interface CreditNoteSchema {
56
+ _id: ObjectId | string;
53
57
  name: string;
54
58
  type: string;
55
59
  amount: number;
@@ -62,8 +66,8 @@ interface CreditNoteSchema {
62
66
  fileName: string;
63
67
  invoiceData: object;
64
68
  userSub: string;
65
- readingIds: any[];
66
- supplierId: string;
69
+ readingIds: ObjectId[] | string[];
70
+ supplierId: ObjectId | string;
67
71
  totalUnits: number;
68
72
  endDate: Date;
69
73
  startDate: Date;
@@ -74,11 +78,11 @@ interface CreditNoteSchema {
74
78
  totalWasteCost: number;
75
79
  }
76
80
  interface Account {
77
- _id: string;
81
+ _id: ObjectId | string;
78
82
  name: string;
79
83
  modifiedBy?: string;
80
84
  siteCode?: string;
81
- type: 'gas' | 'electricity' | 'water' | 'waste' | 'solar';
85
+ type: UtilityType;
82
86
  supplierRef?: string;
83
87
  financialCode?: string;
84
88
  propertyCode?: string;
@@ -96,7 +100,7 @@ interface Account {
96
100
  meterOperatorType?: 'lease' | 'purchase';
97
101
  meterOperatorExpiryDate?: Date;
98
102
  dataCollector?: string;
99
- parentAccountId?: string;
103
+ parentAccountId?: ObjectId | string;
100
104
  processingInvoices?: object[];
101
105
  contracts?: ContractSchema[];
102
106
  creditNotes?: CreditNoteSchema[];
@@ -119,13 +123,13 @@ interface Account {
119
123
  error?: string;
120
124
  uploaded?: boolean;
121
125
  };
122
- automationIds?: string[];
126
+ automationIds?: ObjectId[] | string[];
123
127
  customIntegrations?: object;
124
- supplierId?: string;
128
+ supplierId?: ObjectId | string;
125
129
  batchId?: string;
126
- assetId: string;
127
- entityId: string;
128
- companyId: string;
130
+ assetId: ObjectId | string;
131
+ entityId: ObjectId | string;
132
+ companyId: ObjectId | string;
129
133
  userSub: string;
130
134
  }
131
135
 
@@ -194,7 +198,7 @@ interface Document {
194
198
  providerData?: object;
195
199
  certificate?: object;
196
200
  createdAt: Date;
197
- accountIds?: string[];
201
+ accountIds?: ObjectId[] | string[];
198
202
  }
199
203
  interface TimelineEvent {
200
204
  date: Date;
@@ -202,11 +206,11 @@ interface TimelineEvent {
202
206
  status: string;
203
207
  content?: string;
204
208
  icon?: string;
205
- accountIds?: string[];
209
+ accountIds?: ObjectId[] | string[];
206
210
  }
207
211
  interface AssetRecommendation {
208
- recommendationId: string;
209
- documentIds?: string[];
212
+ recommendationId: ObjectId | string;
213
+ documentIds?: ObjectId[] | string[];
210
214
  }
211
215
  interface AssetSettings {
212
216
  consumptionSources: {
@@ -217,7 +221,7 @@ interface AssetSettings {
217
221
  };
218
222
  }
219
223
  interface Asset {
220
- _id: string;
224
+ _id: ObjectId | string;
221
225
  siteName: string;
222
226
  address: Address;
223
227
  assetType: string;
@@ -254,14 +258,15 @@ interface Asset {
254
258
  lastPopulated?: Date;
255
259
  deletedOn?: Date;
256
260
  batchId?: string;
257
- companyId: string;
258
- entityId: string;
259
- assetGroupIds: string[];
261
+ companyId: ObjectId | string;
262
+ entityId: ObjectId | string;
263
+ assetGroupIds: ObjectId[] | string[];
260
264
  userSub: string;
261
265
  gresbId?: string;
262
266
  }
263
267
 
264
268
  interface Log$1 {
269
+ _id: ObjectId | string;
265
270
  message: string;
266
271
  timestamp: Date;
267
272
  batchId?: string;
@@ -276,7 +281,7 @@ interface LastCollection {
276
281
  }
277
282
  type FrequencyType = 'never' | 'trigger' | 'hourly' | 'daily' | 'weekly' | 'monthly';
278
283
  interface Automation {
279
- _id: string;
284
+ _id: ObjectId | string;
280
285
  description?: string;
281
286
  service: string;
282
287
  source: string;
@@ -288,14 +293,14 @@ interface Automation {
288
293
  data: Record<string, any>;
289
294
  sourceData: Record<string, any>;
290
295
  frequency?: FrequencyType;
291
- accountIds?: string[];
292
- assetIds?: string[];
296
+ accountIds?: ObjectId[] | string[];
297
+ assetIds?: ObjectId[] | string[];
293
298
  userSub: string;
294
- companyId: string;
299
+ companyId: ObjectId | string;
295
300
  }
296
301
 
297
302
  interface SupplierPortals {
298
- supplierId: string;
303
+ supplierId: ObjectId | string;
299
304
  portal: Portal;
300
305
  }
301
306
  interface CustomIntegrations {
@@ -324,7 +329,7 @@ interface CompanySettings {
324
329
  scraperCounter?: number;
325
330
  }
326
331
  interface Company {
327
- _id: string;
332
+ _id: ObjectId | string;
328
333
  name: string;
329
334
  address?: Address;
330
335
  invoiceEmail?: string;
@@ -335,23 +340,23 @@ interface Company {
335
340
  }
336
341
 
337
342
  interface CreateScraperRunParams {
338
- supplierId: string;
339
- accountId: string;
340
- companyId: string;
343
+ supplierId: ObjectId | string;
344
+ accountId: ObjectId | string;
345
+ companyId: ObjectId | string;
341
346
  }
342
347
  interface ScraperRun {
343
- _id: string;
348
+ _id: ObjectId | string;
344
349
  logs?: {}[];
345
- supplierId: string;
346
- accountId: string;
347
- companyId: string;
350
+ supplierId: ObjectId | string;
351
+ accountId: ObjectId | string;
352
+ companyId: ObjectId | string;
348
353
  invoiceData?: [];
349
354
  status: string[];
350
355
  error?: string;
351
356
  }
352
357
 
353
358
  interface DataIngest {
354
- _id: string;
359
+ _id: ObjectId | string;
355
360
  messageId: string;
356
361
  status: 'started' | 'processing' | 'importing' | 'completed' | 'failed' | 'dlq';
357
362
  context: any;
@@ -361,15 +366,15 @@ interface DataIngest {
361
366
 
362
367
  type EntityType = 'fund' | 'company' | 'charity' | 'school/university' | 'council' | 'other';
363
368
  interface Entity {
364
- _id: string;
369
+ _id: ObjectId | string;
365
370
  legalName: string;
366
371
  type: EntityType;
367
372
  companyNumber?: string;
368
373
  companyLogo?: string;
369
374
  billingAddress: Address;
370
- parentEntityId?: string;
371
- ultimateParentEntityId?: string;
372
- companyId: string;
375
+ parentEntityId?: ObjectId | string;
376
+ ultimateParentEntityId?: ObjectId | string;
377
+ companyId: ObjectId | string;
373
378
  batchId?: string;
374
379
  userSub: string;
375
380
  }
@@ -379,7 +384,7 @@ interface Attachment {
379
384
  s3Key: string;
380
385
  }
381
386
  interface Email {
382
- _id: string;
387
+ _id: ObjectId | string;
383
388
  destinations: string[];
384
389
  service: string;
385
390
  subject: string;
@@ -389,10 +394,10 @@ interface Email {
389
394
  sesMessageId: string;
390
395
  s3Key: string;
391
396
  userSub?: string;
392
- companyId?: string;
397
+ companyId?: ObjectId | string;
393
398
  }
394
399
 
395
- interface Values {
400
+ interface InvoiceValues {
396
401
  friendlyInvoiceNumber?: string;
397
402
  friendlySupplierRef?: string;
398
403
  friendlyStartDate?: string;
@@ -452,7 +457,8 @@ interface Values {
452
457
  startRead?: string;
453
458
  endRead?: string;
454
459
  }
455
- interface Rate {
460
+ interface InvoiceRate {
461
+ id: string;
456
462
  consumption?: string;
457
463
  cost?: string;
458
464
  endDate?: Date | null;
@@ -462,14 +468,14 @@ interface Rate {
462
468
  startDate?: Date | null;
463
469
  startRead?: string | null;
464
470
  startReadType?: string | null;
465
- type: RateType | null;
471
+ type: InvoiceRateType;
466
472
  unitRate?: string | null;
467
473
  }
468
474
  type InvoiceStatus = 'processing' | 'pending' | 'uploading' | 'queued' | 'captured' | 'error' | 'completed';
469
475
  type FinancialStatus = 'approved' | 'new' | 'not-approved' | 'paid' | 'sent-for-payment';
470
- type RateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
476
+ type InvoiceRateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
471
477
  interface Invoice {
472
- _id: string;
478
+ _id: ObjectId | string;
473
479
  jobId?: string | null;
474
480
  startTime?: Date;
475
481
  endTime?: Date | null;
@@ -483,8 +489,8 @@ interface Invoice {
483
489
  type?: string | null;
484
490
  tags?: string[];
485
491
  manualResults?: Record<string, any>;
486
- values?: Values;
487
- rates?: Rate[];
492
+ values?: InvoiceValues;
493
+ rates?: InvoiceRate[];
488
494
  detailedResults?: Record<string, any>;
489
495
  templateVersion?: string | null;
490
496
  error?: Record<string, any>;
@@ -501,24 +507,24 @@ interface Invoice {
501
507
  confirmedAt?: Date | null;
502
508
  confirmedBy?: string | null;
503
509
  supplierId?: string | null;
504
- sisterId?: string | null;
505
- batchId?: string | null;
506
- accountId?: string | null;
507
- entityId?: string;
510
+ sisterId?: ObjectId | string | null;
511
+ batchId?: ObjectId | string | null;
512
+ accountId?: ObjectId | string | null;
513
+ entityId?: ObjectId | string;
508
514
  companyId: string;
509
515
  userSub: string;
510
516
  validation?: any[];
511
517
  }
512
518
 
513
519
  interface Log {
514
- _id: string;
520
+ _id: ObjectId | string;
515
521
  message: string;
516
522
  context?: {};
517
- linkedId?: string;
523
+ linkedId?: ObjectId | string;
518
524
  linkedType?: string;
519
525
  type: string;
520
526
  userSub?: string;
521
- companyId?: string;
527
+ companyId?: ObjectId | string;
522
528
  }
523
529
 
524
530
  interface Reading {
@@ -528,20 +534,20 @@ interface Reading {
528
534
  type?: string;
529
535
  invoiceStartRead?: number;
530
536
  source: string;
531
- invoiceId?: string;
532
- rateId?: string;
537
+ invoiceId?: ObjectId | string;
538
+ rateId?: ObjectId | string;
533
539
  contractRateType?: string;
534
540
  invoiceBatchId?: string;
535
541
  batchId?: string;
536
- accountId: string;
537
- entityId: string;
538
- companyId: string;
542
+ accountId: ObjectId | string;
543
+ entityId: ObjectId | string;
544
+ companyId: ObjectId | string;
539
545
  userSub?: string;
540
546
  }
541
547
 
542
548
  type ReportSource = 'assetGroup' | 'asset' | 'account' | 'accountsByRegister';
543
549
  interface ReportSourceIdItem {
544
- _id: string;
550
+ _id: ObjectId | string;
545
551
  type: ReportSource;
546
552
  }
547
553
  interface ReportMetadata {
@@ -559,9 +565,16 @@ interface ReportMetadata {
559
565
  consumptionSource?: 'reading' | 'invoice' | 'combined' | 'hh' | 'reading-hh';
560
566
  showSimulated?: boolean;
561
567
  chartOptions?: any;
568
+ filters: Record<string, any>;
569
+ readingSource: Reading['source'];
570
+ dateField: 'startDateEndDate' | 'startDate' | 'endDate' | 'confirmedAt';
571
+ includeSubMeters: boolean;
572
+ utilityType: UtilityType;
573
+ accountTag: string;
574
+ activityType: string;
562
575
  }
563
576
  interface Report {
564
- _id: string;
577
+ _id: ObjectId | string;
565
578
  type: 'dynamic' | 'spreadsheet' | 'table' | 'pdf';
566
579
  subType?: string;
567
580
  fileFormat: 'pdf' | 'xlsx' | 'csv' | 'json' | 'png' | 'jpg' | 'chart';
@@ -575,10 +588,10 @@ interface Report {
575
588
  availableAt?: Date;
576
589
  s3Key: string | null;
577
590
  batchId?: string;
578
- scheduledReportId?: string;
579
- reportTemplateId?: string;
580
- entityId: string;
581
- companyId: string;
591
+ scheduledReportId?: ObjectId | string;
592
+ reportTemplateId?: ObjectId | string;
593
+ entityId: ObjectId | string;
594
+ companyId: ObjectId | string;
582
595
  userSub?: string;
583
596
  }
584
597
 
@@ -592,7 +605,7 @@ interface InvoiceOptionsSchema {
592
605
  stampPositionY?: number;
593
606
  }
594
607
  interface Supplier {
595
- _id: string;
608
+ _id: ObjectId | string;
596
609
  name: string;
597
610
  logoUrl?: string;
598
611
  websiteUrl?: string;
@@ -615,6 +628,14 @@ interface ETNPagedResponse$1<T = any> {
615
628
  limit: number;
616
629
  skip: number;
617
630
  }
631
+ type ToAPIType<T> = T extends (ObjectId | string) ? string : T extends Array<infer U> ? Array<ToAPIType<U>> : T extends object ? {
632
+ [K in keyof T]: ToAPIType<T[K]>;
633
+ } : T;
634
+ type ToMongoType<T> = T extends (ObjectId | string) ? ObjectId : T extends Array<infer U> ? Array<ToMongoType<U>> : T extends object ? {
635
+ [K in keyof T]: ToMongoType<T[K]>;
636
+ } : T;
637
+ type APIResponse<T> = ToAPIType<T>;
638
+ type DBResponse<T> = ToMongoType<T>;
618
639
 
619
640
  interface ETNPagedResponse<T = any> {
620
641
  data: T[];
@@ -800,4 +821,4 @@ declare namespace reporting {
800
821
  export { reporting_getScheduledReportRunTimes as getScheduledReportRunTimes };
801
822
  }
802
823
 
803
- 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 ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
824
+ export { type APIResponse, type Account, type Asset, type Automation, type Company, type CreateScraperRunParams, type DBResponse, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceRate, type InvoiceRateType, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type ToAPIType, type ToMongoType, type UtilityType, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as axios from 'axios';
2
2
  import { CreateAxiosDefaults, AxiosInstance, AxiosRequestConfig } from 'axios';
3
+ import { ObjectId, Db } from 'mongodb';
3
4
  import winston from 'winston';
4
- import { Db } from 'mongodb';
5
5
  import moment from 'moment';
6
6
 
7
7
  interface Portal {
@@ -9,7 +9,7 @@ interface Portal {
9
9
  password?: string;
10
10
  scraperEnabled?: boolean;
11
11
  url?: string;
12
- scraperId?: string;
12
+ scraperId?: ObjectId | string;
13
13
  scraperStartDate?: Date;
14
14
  }
15
15
 
@@ -19,6 +19,8 @@ interface StatusHistory {
19
19
  notes?: string;
20
20
  }
21
21
 
22
+ type UtilityType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';
23
+
22
24
  interface PortalAccountSchema extends Portal {
23
25
  invoiceFilenames: any[];
24
26
  }
@@ -28,6 +30,7 @@ interface RateSchema {
28
30
  description: string;
29
31
  }
30
32
  interface ContractSchema {
33
+ _id: ObjectId | string;
31
34
  startDate: Date;
32
35
  endDate: Date;
33
36
  terminationDate?: Date;
@@ -44,12 +47,13 @@ interface ContractSchema {
44
47
  s3Key?: string;
45
48
  rateTypeMapping?: object;
46
49
  batchId?: string;
47
- supplierId?: string;
50
+ supplierId?: ObjectId | string;
48
51
  status: 'active' | 'inactive';
49
52
  userSub?: string;
50
53
  deletedOn?: Date;
51
54
  }
52
55
  interface CreditNoteSchema {
56
+ _id: ObjectId | string;
53
57
  name: string;
54
58
  type: string;
55
59
  amount: number;
@@ -62,8 +66,8 @@ interface CreditNoteSchema {
62
66
  fileName: string;
63
67
  invoiceData: object;
64
68
  userSub: string;
65
- readingIds: any[];
66
- supplierId: string;
69
+ readingIds: ObjectId[] | string[];
70
+ supplierId: ObjectId | string;
67
71
  totalUnits: number;
68
72
  endDate: Date;
69
73
  startDate: Date;
@@ -74,11 +78,11 @@ interface CreditNoteSchema {
74
78
  totalWasteCost: number;
75
79
  }
76
80
  interface Account {
77
- _id: string;
81
+ _id: ObjectId | string;
78
82
  name: string;
79
83
  modifiedBy?: string;
80
84
  siteCode?: string;
81
- type: 'gas' | 'electricity' | 'water' | 'waste' | 'solar';
85
+ type: UtilityType;
82
86
  supplierRef?: string;
83
87
  financialCode?: string;
84
88
  propertyCode?: string;
@@ -96,7 +100,7 @@ interface Account {
96
100
  meterOperatorType?: 'lease' | 'purchase';
97
101
  meterOperatorExpiryDate?: Date;
98
102
  dataCollector?: string;
99
- parentAccountId?: string;
103
+ parentAccountId?: ObjectId | string;
100
104
  processingInvoices?: object[];
101
105
  contracts?: ContractSchema[];
102
106
  creditNotes?: CreditNoteSchema[];
@@ -119,13 +123,13 @@ interface Account {
119
123
  error?: string;
120
124
  uploaded?: boolean;
121
125
  };
122
- automationIds?: string[];
126
+ automationIds?: ObjectId[] | string[];
123
127
  customIntegrations?: object;
124
- supplierId?: string;
128
+ supplierId?: ObjectId | string;
125
129
  batchId?: string;
126
- assetId: string;
127
- entityId: string;
128
- companyId: string;
130
+ assetId: ObjectId | string;
131
+ entityId: ObjectId | string;
132
+ companyId: ObjectId | string;
129
133
  userSub: string;
130
134
  }
131
135
 
@@ -194,7 +198,7 @@ interface Document {
194
198
  providerData?: object;
195
199
  certificate?: object;
196
200
  createdAt: Date;
197
- accountIds?: string[];
201
+ accountIds?: ObjectId[] | string[];
198
202
  }
199
203
  interface TimelineEvent {
200
204
  date: Date;
@@ -202,11 +206,11 @@ interface TimelineEvent {
202
206
  status: string;
203
207
  content?: string;
204
208
  icon?: string;
205
- accountIds?: string[];
209
+ accountIds?: ObjectId[] | string[];
206
210
  }
207
211
  interface AssetRecommendation {
208
- recommendationId: string;
209
- documentIds?: string[];
212
+ recommendationId: ObjectId | string;
213
+ documentIds?: ObjectId[] | string[];
210
214
  }
211
215
  interface AssetSettings {
212
216
  consumptionSources: {
@@ -217,7 +221,7 @@ interface AssetSettings {
217
221
  };
218
222
  }
219
223
  interface Asset {
220
- _id: string;
224
+ _id: ObjectId | string;
221
225
  siteName: string;
222
226
  address: Address;
223
227
  assetType: string;
@@ -254,14 +258,15 @@ interface Asset {
254
258
  lastPopulated?: Date;
255
259
  deletedOn?: Date;
256
260
  batchId?: string;
257
- companyId: string;
258
- entityId: string;
259
- assetGroupIds: string[];
261
+ companyId: ObjectId | string;
262
+ entityId: ObjectId | string;
263
+ assetGroupIds: ObjectId[] | string[];
260
264
  userSub: string;
261
265
  gresbId?: string;
262
266
  }
263
267
 
264
268
  interface Log$1 {
269
+ _id: ObjectId | string;
265
270
  message: string;
266
271
  timestamp: Date;
267
272
  batchId?: string;
@@ -276,7 +281,7 @@ interface LastCollection {
276
281
  }
277
282
  type FrequencyType = 'never' | 'trigger' | 'hourly' | 'daily' | 'weekly' | 'monthly';
278
283
  interface Automation {
279
- _id: string;
284
+ _id: ObjectId | string;
280
285
  description?: string;
281
286
  service: string;
282
287
  source: string;
@@ -288,14 +293,14 @@ interface Automation {
288
293
  data: Record<string, any>;
289
294
  sourceData: Record<string, any>;
290
295
  frequency?: FrequencyType;
291
- accountIds?: string[];
292
- assetIds?: string[];
296
+ accountIds?: ObjectId[] | string[];
297
+ assetIds?: ObjectId[] | string[];
293
298
  userSub: string;
294
- companyId: string;
299
+ companyId: ObjectId | string;
295
300
  }
296
301
 
297
302
  interface SupplierPortals {
298
- supplierId: string;
303
+ supplierId: ObjectId | string;
299
304
  portal: Portal;
300
305
  }
301
306
  interface CustomIntegrations {
@@ -324,7 +329,7 @@ interface CompanySettings {
324
329
  scraperCounter?: number;
325
330
  }
326
331
  interface Company {
327
- _id: string;
332
+ _id: ObjectId | string;
328
333
  name: string;
329
334
  address?: Address;
330
335
  invoiceEmail?: string;
@@ -335,23 +340,23 @@ interface Company {
335
340
  }
336
341
 
337
342
  interface CreateScraperRunParams {
338
- supplierId: string;
339
- accountId: string;
340
- companyId: string;
343
+ supplierId: ObjectId | string;
344
+ accountId: ObjectId | string;
345
+ companyId: ObjectId | string;
341
346
  }
342
347
  interface ScraperRun {
343
- _id: string;
348
+ _id: ObjectId | string;
344
349
  logs?: {}[];
345
- supplierId: string;
346
- accountId: string;
347
- companyId: string;
350
+ supplierId: ObjectId | string;
351
+ accountId: ObjectId | string;
352
+ companyId: ObjectId | string;
348
353
  invoiceData?: [];
349
354
  status: string[];
350
355
  error?: string;
351
356
  }
352
357
 
353
358
  interface DataIngest {
354
- _id: string;
359
+ _id: ObjectId | string;
355
360
  messageId: string;
356
361
  status: 'started' | 'processing' | 'importing' | 'completed' | 'failed' | 'dlq';
357
362
  context: any;
@@ -361,15 +366,15 @@ interface DataIngest {
361
366
 
362
367
  type EntityType = 'fund' | 'company' | 'charity' | 'school/university' | 'council' | 'other';
363
368
  interface Entity {
364
- _id: string;
369
+ _id: ObjectId | string;
365
370
  legalName: string;
366
371
  type: EntityType;
367
372
  companyNumber?: string;
368
373
  companyLogo?: string;
369
374
  billingAddress: Address;
370
- parentEntityId?: string;
371
- ultimateParentEntityId?: string;
372
- companyId: string;
375
+ parentEntityId?: ObjectId | string;
376
+ ultimateParentEntityId?: ObjectId | string;
377
+ companyId: ObjectId | string;
373
378
  batchId?: string;
374
379
  userSub: string;
375
380
  }
@@ -379,7 +384,7 @@ interface Attachment {
379
384
  s3Key: string;
380
385
  }
381
386
  interface Email {
382
- _id: string;
387
+ _id: ObjectId | string;
383
388
  destinations: string[];
384
389
  service: string;
385
390
  subject: string;
@@ -389,10 +394,10 @@ interface Email {
389
394
  sesMessageId: string;
390
395
  s3Key: string;
391
396
  userSub?: string;
392
- companyId?: string;
397
+ companyId?: ObjectId | string;
393
398
  }
394
399
 
395
- interface Values {
400
+ interface InvoiceValues {
396
401
  friendlyInvoiceNumber?: string;
397
402
  friendlySupplierRef?: string;
398
403
  friendlyStartDate?: string;
@@ -452,7 +457,8 @@ interface Values {
452
457
  startRead?: string;
453
458
  endRead?: string;
454
459
  }
455
- interface Rate {
460
+ interface InvoiceRate {
461
+ id: string;
456
462
  consumption?: string;
457
463
  cost?: string;
458
464
  endDate?: Date | null;
@@ -462,14 +468,14 @@ interface Rate {
462
468
  startDate?: Date | null;
463
469
  startRead?: string | null;
464
470
  startReadType?: string | null;
465
- type: RateType | null;
471
+ type: InvoiceRateType;
466
472
  unitRate?: string | null;
467
473
  }
468
474
  type InvoiceStatus = 'processing' | 'pending' | 'uploading' | 'queued' | 'captured' | 'error' | 'completed';
469
475
  type FinancialStatus = 'approved' | 'new' | 'not-approved' | 'paid' | 'sent-for-payment';
470
- type RateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
476
+ type InvoiceRateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
471
477
  interface Invoice {
472
- _id: string;
478
+ _id: ObjectId | string;
473
479
  jobId?: string | null;
474
480
  startTime?: Date;
475
481
  endTime?: Date | null;
@@ -483,8 +489,8 @@ interface Invoice {
483
489
  type?: string | null;
484
490
  tags?: string[];
485
491
  manualResults?: Record<string, any>;
486
- values?: Values;
487
- rates?: Rate[];
492
+ values?: InvoiceValues;
493
+ rates?: InvoiceRate[];
488
494
  detailedResults?: Record<string, any>;
489
495
  templateVersion?: string | null;
490
496
  error?: Record<string, any>;
@@ -501,24 +507,24 @@ interface Invoice {
501
507
  confirmedAt?: Date | null;
502
508
  confirmedBy?: string | null;
503
509
  supplierId?: string | null;
504
- sisterId?: string | null;
505
- batchId?: string | null;
506
- accountId?: string | null;
507
- entityId?: string;
510
+ sisterId?: ObjectId | string | null;
511
+ batchId?: ObjectId | string | null;
512
+ accountId?: ObjectId | string | null;
513
+ entityId?: ObjectId | string;
508
514
  companyId: string;
509
515
  userSub: string;
510
516
  validation?: any[];
511
517
  }
512
518
 
513
519
  interface Log {
514
- _id: string;
520
+ _id: ObjectId | string;
515
521
  message: string;
516
522
  context?: {};
517
- linkedId?: string;
523
+ linkedId?: ObjectId | string;
518
524
  linkedType?: string;
519
525
  type: string;
520
526
  userSub?: string;
521
- companyId?: string;
527
+ companyId?: ObjectId | string;
522
528
  }
523
529
 
524
530
  interface Reading {
@@ -528,20 +534,20 @@ interface Reading {
528
534
  type?: string;
529
535
  invoiceStartRead?: number;
530
536
  source: string;
531
- invoiceId?: string;
532
- rateId?: string;
537
+ invoiceId?: ObjectId | string;
538
+ rateId?: ObjectId | string;
533
539
  contractRateType?: string;
534
540
  invoiceBatchId?: string;
535
541
  batchId?: string;
536
- accountId: string;
537
- entityId: string;
538
- companyId: string;
542
+ accountId: ObjectId | string;
543
+ entityId: ObjectId | string;
544
+ companyId: ObjectId | string;
539
545
  userSub?: string;
540
546
  }
541
547
 
542
548
  type ReportSource = 'assetGroup' | 'asset' | 'account' | 'accountsByRegister';
543
549
  interface ReportSourceIdItem {
544
- _id: string;
550
+ _id: ObjectId | string;
545
551
  type: ReportSource;
546
552
  }
547
553
  interface ReportMetadata {
@@ -559,9 +565,16 @@ interface ReportMetadata {
559
565
  consumptionSource?: 'reading' | 'invoice' | 'combined' | 'hh' | 'reading-hh';
560
566
  showSimulated?: boolean;
561
567
  chartOptions?: any;
568
+ filters: Record<string, any>;
569
+ readingSource: Reading['source'];
570
+ dateField: 'startDateEndDate' | 'startDate' | 'endDate' | 'confirmedAt';
571
+ includeSubMeters: boolean;
572
+ utilityType: UtilityType;
573
+ accountTag: string;
574
+ activityType: string;
562
575
  }
563
576
  interface Report {
564
- _id: string;
577
+ _id: ObjectId | string;
565
578
  type: 'dynamic' | 'spreadsheet' | 'table' | 'pdf';
566
579
  subType?: string;
567
580
  fileFormat: 'pdf' | 'xlsx' | 'csv' | 'json' | 'png' | 'jpg' | 'chart';
@@ -575,10 +588,10 @@ interface Report {
575
588
  availableAt?: Date;
576
589
  s3Key: string | null;
577
590
  batchId?: string;
578
- scheduledReportId?: string;
579
- reportTemplateId?: string;
580
- entityId: string;
581
- companyId: string;
591
+ scheduledReportId?: ObjectId | string;
592
+ reportTemplateId?: ObjectId | string;
593
+ entityId: ObjectId | string;
594
+ companyId: ObjectId | string;
582
595
  userSub?: string;
583
596
  }
584
597
 
@@ -592,7 +605,7 @@ interface InvoiceOptionsSchema {
592
605
  stampPositionY?: number;
593
606
  }
594
607
  interface Supplier {
595
- _id: string;
608
+ _id: ObjectId | string;
596
609
  name: string;
597
610
  logoUrl?: string;
598
611
  websiteUrl?: string;
@@ -615,6 +628,14 @@ interface ETNPagedResponse$1<T = any> {
615
628
  limit: number;
616
629
  skip: number;
617
630
  }
631
+ type ToAPIType<T> = T extends (ObjectId | string) ? string : T extends Array<infer U> ? Array<ToAPIType<U>> : T extends object ? {
632
+ [K in keyof T]: ToAPIType<T[K]>;
633
+ } : T;
634
+ type ToMongoType<T> = T extends (ObjectId | string) ? ObjectId : T extends Array<infer U> ? Array<ToMongoType<U>> : T extends object ? {
635
+ [K in keyof T]: ToMongoType<T[K]>;
636
+ } : T;
637
+ type APIResponse<T> = ToAPIType<T>;
638
+ type DBResponse<T> = ToMongoType<T>;
618
639
 
619
640
  interface ETNPagedResponse<T = any> {
620
641
  data: T[];
@@ -800,4 +821,4 @@ declare namespace reporting {
800
821
  export { reporting_getScheduledReportRunTimes as getScheduledReportRunTimes };
801
822
  }
802
823
 
803
- 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 ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
824
+ export { type APIResponse, type Account, type Asset, type Automation, type Company, type CreateScraperRunParams, type DBResponse, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceRate, type InvoiceRateType, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type ToAPIType, type ToMongoType, type UtilityType, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etainabl/nodejs-sdk",
3
- "version": "1.2.50",
3
+ "version": "1.2.52",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",