@etainabl/nodejs-sdk 1.2.51 → 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
 
@@ -30,6 +30,7 @@ interface RateSchema {
30
30
  description: string;
31
31
  }
32
32
  interface ContractSchema {
33
+ _id: ObjectId | string;
33
34
  startDate: Date;
34
35
  endDate: Date;
35
36
  terminationDate?: Date;
@@ -46,12 +47,13 @@ interface ContractSchema {
46
47
  s3Key?: string;
47
48
  rateTypeMapping?: object;
48
49
  batchId?: string;
49
- supplierId?: string;
50
+ supplierId?: ObjectId | string;
50
51
  status: 'active' | 'inactive';
51
52
  userSub?: string;
52
53
  deletedOn?: Date;
53
54
  }
54
55
  interface CreditNoteSchema {
56
+ _id: ObjectId | string;
55
57
  name: string;
56
58
  type: string;
57
59
  amount: number;
@@ -64,8 +66,8 @@ interface CreditNoteSchema {
64
66
  fileName: string;
65
67
  invoiceData: object;
66
68
  userSub: string;
67
- readingIds: any[];
68
- supplierId: string;
69
+ readingIds: ObjectId[] | string[];
70
+ supplierId: ObjectId | string;
69
71
  totalUnits: number;
70
72
  endDate: Date;
71
73
  startDate: Date;
@@ -76,7 +78,7 @@ interface CreditNoteSchema {
76
78
  totalWasteCost: number;
77
79
  }
78
80
  interface Account {
79
- _id: string;
81
+ _id: ObjectId | string;
80
82
  name: string;
81
83
  modifiedBy?: string;
82
84
  siteCode?: string;
@@ -98,7 +100,7 @@ interface Account {
98
100
  meterOperatorType?: 'lease' | 'purchase';
99
101
  meterOperatorExpiryDate?: Date;
100
102
  dataCollector?: string;
101
- parentAccountId?: string;
103
+ parentAccountId?: ObjectId | string;
102
104
  processingInvoices?: object[];
103
105
  contracts?: ContractSchema[];
104
106
  creditNotes?: CreditNoteSchema[];
@@ -121,13 +123,13 @@ interface Account {
121
123
  error?: string;
122
124
  uploaded?: boolean;
123
125
  };
124
- automationIds?: string[];
126
+ automationIds?: ObjectId[] | string[];
125
127
  customIntegrations?: object;
126
- supplierId?: string;
128
+ supplierId?: ObjectId | string;
127
129
  batchId?: string;
128
- assetId: string;
129
- entityId: string;
130
- companyId: string;
130
+ assetId: ObjectId | string;
131
+ entityId: ObjectId | string;
132
+ companyId: ObjectId | string;
131
133
  userSub: string;
132
134
  }
133
135
 
@@ -196,7 +198,7 @@ interface Document {
196
198
  providerData?: object;
197
199
  certificate?: object;
198
200
  createdAt: Date;
199
- accountIds?: string[];
201
+ accountIds?: ObjectId[] | string[];
200
202
  }
201
203
  interface TimelineEvent {
202
204
  date: Date;
@@ -204,11 +206,11 @@ interface TimelineEvent {
204
206
  status: string;
205
207
  content?: string;
206
208
  icon?: string;
207
- accountIds?: string[];
209
+ accountIds?: ObjectId[] | string[];
208
210
  }
209
211
  interface AssetRecommendation {
210
- recommendationId: string;
211
- documentIds?: string[];
212
+ recommendationId: ObjectId | string;
213
+ documentIds?: ObjectId[] | string[];
212
214
  }
213
215
  interface AssetSettings {
214
216
  consumptionSources: {
@@ -219,7 +221,7 @@ interface AssetSettings {
219
221
  };
220
222
  }
221
223
  interface Asset {
222
- _id: string;
224
+ _id: ObjectId | string;
223
225
  siteName: string;
224
226
  address: Address;
225
227
  assetType: string;
@@ -256,14 +258,15 @@ interface Asset {
256
258
  lastPopulated?: Date;
257
259
  deletedOn?: Date;
258
260
  batchId?: string;
259
- companyId: string;
260
- entityId: string;
261
- assetGroupIds: string[];
261
+ companyId: ObjectId | string;
262
+ entityId: ObjectId | string;
263
+ assetGroupIds: ObjectId[] | string[];
262
264
  userSub: string;
263
265
  gresbId?: string;
264
266
  }
265
267
 
266
268
  interface Log$1 {
269
+ _id: ObjectId | string;
267
270
  message: string;
268
271
  timestamp: Date;
269
272
  batchId?: string;
@@ -278,7 +281,7 @@ interface LastCollection {
278
281
  }
279
282
  type FrequencyType = 'never' | 'trigger' | 'hourly' | 'daily' | 'weekly' | 'monthly';
280
283
  interface Automation {
281
- _id: string;
284
+ _id: ObjectId | string;
282
285
  description?: string;
283
286
  service: string;
284
287
  source: string;
@@ -290,14 +293,14 @@ interface Automation {
290
293
  data: Record<string, any>;
291
294
  sourceData: Record<string, any>;
292
295
  frequency?: FrequencyType;
293
- accountIds?: string[];
294
- assetIds?: string[];
296
+ accountIds?: ObjectId[] | string[];
297
+ assetIds?: ObjectId[] | string[];
295
298
  userSub: string;
296
- companyId: string;
299
+ companyId: ObjectId | string;
297
300
  }
298
301
 
299
302
  interface SupplierPortals {
300
- supplierId: string;
303
+ supplierId: ObjectId | string;
301
304
  portal: Portal;
302
305
  }
303
306
  interface CustomIntegrations {
@@ -326,7 +329,7 @@ interface CompanySettings {
326
329
  scraperCounter?: number;
327
330
  }
328
331
  interface Company {
329
- _id: string;
332
+ _id: ObjectId | string;
330
333
  name: string;
331
334
  address?: Address;
332
335
  invoiceEmail?: string;
@@ -337,23 +340,23 @@ interface Company {
337
340
  }
338
341
 
339
342
  interface CreateScraperRunParams {
340
- supplierId: string;
341
- accountId: string;
342
- companyId: string;
343
+ supplierId: ObjectId | string;
344
+ accountId: ObjectId | string;
345
+ companyId: ObjectId | string;
343
346
  }
344
347
  interface ScraperRun {
345
- _id: string;
348
+ _id: ObjectId | string;
346
349
  logs?: {}[];
347
- supplierId: string;
348
- accountId: string;
349
- companyId: string;
350
+ supplierId: ObjectId | string;
351
+ accountId: ObjectId | string;
352
+ companyId: ObjectId | string;
350
353
  invoiceData?: [];
351
354
  status: string[];
352
355
  error?: string;
353
356
  }
354
357
 
355
358
  interface DataIngest {
356
- _id: string;
359
+ _id: ObjectId | string;
357
360
  messageId: string;
358
361
  status: 'started' | 'processing' | 'importing' | 'completed' | 'failed' | 'dlq';
359
362
  context: any;
@@ -363,15 +366,15 @@ interface DataIngest {
363
366
 
364
367
  type EntityType = 'fund' | 'company' | 'charity' | 'school/university' | 'council' | 'other';
365
368
  interface Entity {
366
- _id: string;
369
+ _id: ObjectId | string;
367
370
  legalName: string;
368
371
  type: EntityType;
369
372
  companyNumber?: string;
370
373
  companyLogo?: string;
371
374
  billingAddress: Address;
372
- parentEntityId?: string;
373
- ultimateParentEntityId?: string;
374
- companyId: string;
375
+ parentEntityId?: ObjectId | string;
376
+ ultimateParentEntityId?: ObjectId | string;
377
+ companyId: ObjectId | string;
375
378
  batchId?: string;
376
379
  userSub: string;
377
380
  }
@@ -381,7 +384,7 @@ interface Attachment {
381
384
  s3Key: string;
382
385
  }
383
386
  interface Email {
384
- _id: string;
387
+ _id: ObjectId | string;
385
388
  destinations: string[];
386
389
  service: string;
387
390
  subject: string;
@@ -391,10 +394,10 @@ interface Email {
391
394
  sesMessageId: string;
392
395
  s3Key: string;
393
396
  userSub?: string;
394
- companyId?: string;
397
+ companyId?: ObjectId | string;
395
398
  }
396
399
 
397
- interface Values {
400
+ interface InvoiceValues {
398
401
  friendlyInvoiceNumber?: string;
399
402
  friendlySupplierRef?: string;
400
403
  friendlyStartDate?: string;
@@ -454,7 +457,8 @@ interface Values {
454
457
  startRead?: string;
455
458
  endRead?: string;
456
459
  }
457
- interface Rate {
460
+ interface InvoiceRate {
461
+ id: string;
458
462
  consumption?: string;
459
463
  cost?: string;
460
464
  endDate?: Date | null;
@@ -464,14 +468,14 @@ interface Rate {
464
468
  startDate?: Date | null;
465
469
  startRead?: string | null;
466
470
  startReadType?: string | null;
467
- type: RateType | null;
471
+ type: InvoiceRateType;
468
472
  unitRate?: string | null;
469
473
  }
470
474
  type InvoiceStatus = 'processing' | 'pending' | 'uploading' | 'queued' | 'captured' | 'error' | 'completed';
471
475
  type FinancialStatus = 'approved' | 'new' | 'not-approved' | 'paid' | 'sent-for-payment';
472
- type RateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
476
+ type InvoiceRateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
473
477
  interface Invoice {
474
- _id: string;
478
+ _id: ObjectId | string;
475
479
  jobId?: string | null;
476
480
  startTime?: Date;
477
481
  endTime?: Date | null;
@@ -485,8 +489,8 @@ interface Invoice {
485
489
  type?: string | null;
486
490
  tags?: string[];
487
491
  manualResults?: Record<string, any>;
488
- values?: Values;
489
- rates?: Rate[];
492
+ values?: InvoiceValues;
493
+ rates?: InvoiceRate[];
490
494
  detailedResults?: Record<string, any>;
491
495
  templateVersion?: string | null;
492
496
  error?: Record<string, any>;
@@ -503,24 +507,24 @@ interface Invoice {
503
507
  confirmedAt?: Date | null;
504
508
  confirmedBy?: string | null;
505
509
  supplierId?: string | null;
506
- sisterId?: string | null;
507
- batchId?: string | null;
508
- accountId?: string | null;
509
- entityId?: string;
510
+ sisterId?: ObjectId | string | null;
511
+ batchId?: ObjectId | string | null;
512
+ accountId?: ObjectId | string | null;
513
+ entityId?: ObjectId | string;
510
514
  companyId: string;
511
515
  userSub: string;
512
516
  validation?: any[];
513
517
  }
514
518
 
515
519
  interface Log {
516
- _id: string;
520
+ _id: ObjectId | string;
517
521
  message: string;
518
522
  context?: {};
519
- linkedId?: string;
523
+ linkedId?: ObjectId | string;
520
524
  linkedType?: string;
521
525
  type: string;
522
526
  userSub?: string;
523
- companyId?: string;
527
+ companyId?: ObjectId | string;
524
528
  }
525
529
 
526
530
  interface Reading {
@@ -530,20 +534,20 @@ interface Reading {
530
534
  type?: string;
531
535
  invoiceStartRead?: number;
532
536
  source: string;
533
- invoiceId?: string;
534
- rateId?: string;
537
+ invoiceId?: ObjectId | string;
538
+ rateId?: ObjectId | string;
535
539
  contractRateType?: string;
536
540
  invoiceBatchId?: string;
537
541
  batchId?: string;
538
- accountId: string;
539
- entityId: string;
540
- companyId: string;
542
+ accountId: ObjectId | string;
543
+ entityId: ObjectId | string;
544
+ companyId: ObjectId | string;
541
545
  userSub?: string;
542
546
  }
543
547
 
544
548
  type ReportSource = 'assetGroup' | 'asset' | 'account' | 'accountsByRegister';
545
549
  interface ReportSourceIdItem {
546
- _id: string;
550
+ _id: ObjectId | string;
547
551
  type: ReportSource;
548
552
  }
549
553
  interface ReportMetadata {
@@ -570,7 +574,7 @@ interface ReportMetadata {
570
574
  activityType: string;
571
575
  }
572
576
  interface Report {
573
- _id: string;
577
+ _id: ObjectId | string;
574
578
  type: 'dynamic' | 'spreadsheet' | 'table' | 'pdf';
575
579
  subType?: string;
576
580
  fileFormat: 'pdf' | 'xlsx' | 'csv' | 'json' | 'png' | 'jpg' | 'chart';
@@ -584,10 +588,10 @@ interface Report {
584
588
  availableAt?: Date;
585
589
  s3Key: string | null;
586
590
  batchId?: string;
587
- scheduledReportId?: string;
588
- reportTemplateId?: string;
589
- entityId: string;
590
- companyId: string;
591
+ scheduledReportId?: ObjectId | string;
592
+ reportTemplateId?: ObjectId | string;
593
+ entityId: ObjectId | string;
594
+ companyId: ObjectId | string;
591
595
  userSub?: string;
592
596
  }
593
597
 
@@ -601,7 +605,7 @@ interface InvoiceOptionsSchema {
601
605
  stampPositionY?: number;
602
606
  }
603
607
  interface Supplier {
604
- _id: string;
608
+ _id: ObjectId | string;
605
609
  name: string;
606
610
  logoUrl?: string;
607
611
  websiteUrl?: string;
@@ -624,6 +628,14 @@ interface ETNPagedResponse$1<T = any> {
624
628
  limit: number;
625
629
  skip: number;
626
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>;
627
639
 
628
640
  interface ETNPagedResponse<T = any> {
629
641
  data: T[];
@@ -809,4 +821,4 @@ declare namespace reporting {
809
821
  export { reporting_getScheduledReportRunTimes as getScheduledReportRunTimes };
810
822
  }
811
823
 
812
- 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, type UtilityType, _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
 
@@ -30,6 +30,7 @@ interface RateSchema {
30
30
  description: string;
31
31
  }
32
32
  interface ContractSchema {
33
+ _id: ObjectId | string;
33
34
  startDate: Date;
34
35
  endDate: Date;
35
36
  terminationDate?: Date;
@@ -46,12 +47,13 @@ interface ContractSchema {
46
47
  s3Key?: string;
47
48
  rateTypeMapping?: object;
48
49
  batchId?: string;
49
- supplierId?: string;
50
+ supplierId?: ObjectId | string;
50
51
  status: 'active' | 'inactive';
51
52
  userSub?: string;
52
53
  deletedOn?: Date;
53
54
  }
54
55
  interface CreditNoteSchema {
56
+ _id: ObjectId | string;
55
57
  name: string;
56
58
  type: string;
57
59
  amount: number;
@@ -64,8 +66,8 @@ interface CreditNoteSchema {
64
66
  fileName: string;
65
67
  invoiceData: object;
66
68
  userSub: string;
67
- readingIds: any[];
68
- supplierId: string;
69
+ readingIds: ObjectId[] | string[];
70
+ supplierId: ObjectId | string;
69
71
  totalUnits: number;
70
72
  endDate: Date;
71
73
  startDate: Date;
@@ -76,7 +78,7 @@ interface CreditNoteSchema {
76
78
  totalWasteCost: number;
77
79
  }
78
80
  interface Account {
79
- _id: string;
81
+ _id: ObjectId | string;
80
82
  name: string;
81
83
  modifiedBy?: string;
82
84
  siteCode?: string;
@@ -98,7 +100,7 @@ interface Account {
98
100
  meterOperatorType?: 'lease' | 'purchase';
99
101
  meterOperatorExpiryDate?: Date;
100
102
  dataCollector?: string;
101
- parentAccountId?: string;
103
+ parentAccountId?: ObjectId | string;
102
104
  processingInvoices?: object[];
103
105
  contracts?: ContractSchema[];
104
106
  creditNotes?: CreditNoteSchema[];
@@ -121,13 +123,13 @@ interface Account {
121
123
  error?: string;
122
124
  uploaded?: boolean;
123
125
  };
124
- automationIds?: string[];
126
+ automationIds?: ObjectId[] | string[];
125
127
  customIntegrations?: object;
126
- supplierId?: string;
128
+ supplierId?: ObjectId | string;
127
129
  batchId?: string;
128
- assetId: string;
129
- entityId: string;
130
- companyId: string;
130
+ assetId: ObjectId | string;
131
+ entityId: ObjectId | string;
132
+ companyId: ObjectId | string;
131
133
  userSub: string;
132
134
  }
133
135
 
@@ -196,7 +198,7 @@ interface Document {
196
198
  providerData?: object;
197
199
  certificate?: object;
198
200
  createdAt: Date;
199
- accountIds?: string[];
201
+ accountIds?: ObjectId[] | string[];
200
202
  }
201
203
  interface TimelineEvent {
202
204
  date: Date;
@@ -204,11 +206,11 @@ interface TimelineEvent {
204
206
  status: string;
205
207
  content?: string;
206
208
  icon?: string;
207
- accountIds?: string[];
209
+ accountIds?: ObjectId[] | string[];
208
210
  }
209
211
  interface AssetRecommendation {
210
- recommendationId: string;
211
- documentIds?: string[];
212
+ recommendationId: ObjectId | string;
213
+ documentIds?: ObjectId[] | string[];
212
214
  }
213
215
  interface AssetSettings {
214
216
  consumptionSources: {
@@ -219,7 +221,7 @@ interface AssetSettings {
219
221
  };
220
222
  }
221
223
  interface Asset {
222
- _id: string;
224
+ _id: ObjectId | string;
223
225
  siteName: string;
224
226
  address: Address;
225
227
  assetType: string;
@@ -256,14 +258,15 @@ interface Asset {
256
258
  lastPopulated?: Date;
257
259
  deletedOn?: Date;
258
260
  batchId?: string;
259
- companyId: string;
260
- entityId: string;
261
- assetGroupIds: string[];
261
+ companyId: ObjectId | string;
262
+ entityId: ObjectId | string;
263
+ assetGroupIds: ObjectId[] | string[];
262
264
  userSub: string;
263
265
  gresbId?: string;
264
266
  }
265
267
 
266
268
  interface Log$1 {
269
+ _id: ObjectId | string;
267
270
  message: string;
268
271
  timestamp: Date;
269
272
  batchId?: string;
@@ -278,7 +281,7 @@ interface LastCollection {
278
281
  }
279
282
  type FrequencyType = 'never' | 'trigger' | 'hourly' | 'daily' | 'weekly' | 'monthly';
280
283
  interface Automation {
281
- _id: string;
284
+ _id: ObjectId | string;
282
285
  description?: string;
283
286
  service: string;
284
287
  source: string;
@@ -290,14 +293,14 @@ interface Automation {
290
293
  data: Record<string, any>;
291
294
  sourceData: Record<string, any>;
292
295
  frequency?: FrequencyType;
293
- accountIds?: string[];
294
- assetIds?: string[];
296
+ accountIds?: ObjectId[] | string[];
297
+ assetIds?: ObjectId[] | string[];
295
298
  userSub: string;
296
- companyId: string;
299
+ companyId: ObjectId | string;
297
300
  }
298
301
 
299
302
  interface SupplierPortals {
300
- supplierId: string;
303
+ supplierId: ObjectId | string;
301
304
  portal: Portal;
302
305
  }
303
306
  interface CustomIntegrations {
@@ -326,7 +329,7 @@ interface CompanySettings {
326
329
  scraperCounter?: number;
327
330
  }
328
331
  interface Company {
329
- _id: string;
332
+ _id: ObjectId | string;
330
333
  name: string;
331
334
  address?: Address;
332
335
  invoiceEmail?: string;
@@ -337,23 +340,23 @@ interface Company {
337
340
  }
338
341
 
339
342
  interface CreateScraperRunParams {
340
- supplierId: string;
341
- accountId: string;
342
- companyId: string;
343
+ supplierId: ObjectId | string;
344
+ accountId: ObjectId | string;
345
+ companyId: ObjectId | string;
343
346
  }
344
347
  interface ScraperRun {
345
- _id: string;
348
+ _id: ObjectId | string;
346
349
  logs?: {}[];
347
- supplierId: string;
348
- accountId: string;
349
- companyId: string;
350
+ supplierId: ObjectId | string;
351
+ accountId: ObjectId | string;
352
+ companyId: ObjectId | string;
350
353
  invoiceData?: [];
351
354
  status: string[];
352
355
  error?: string;
353
356
  }
354
357
 
355
358
  interface DataIngest {
356
- _id: string;
359
+ _id: ObjectId | string;
357
360
  messageId: string;
358
361
  status: 'started' | 'processing' | 'importing' | 'completed' | 'failed' | 'dlq';
359
362
  context: any;
@@ -363,15 +366,15 @@ interface DataIngest {
363
366
 
364
367
  type EntityType = 'fund' | 'company' | 'charity' | 'school/university' | 'council' | 'other';
365
368
  interface Entity {
366
- _id: string;
369
+ _id: ObjectId | string;
367
370
  legalName: string;
368
371
  type: EntityType;
369
372
  companyNumber?: string;
370
373
  companyLogo?: string;
371
374
  billingAddress: Address;
372
- parentEntityId?: string;
373
- ultimateParentEntityId?: string;
374
- companyId: string;
375
+ parentEntityId?: ObjectId | string;
376
+ ultimateParentEntityId?: ObjectId | string;
377
+ companyId: ObjectId | string;
375
378
  batchId?: string;
376
379
  userSub: string;
377
380
  }
@@ -381,7 +384,7 @@ interface Attachment {
381
384
  s3Key: string;
382
385
  }
383
386
  interface Email {
384
- _id: string;
387
+ _id: ObjectId | string;
385
388
  destinations: string[];
386
389
  service: string;
387
390
  subject: string;
@@ -391,10 +394,10 @@ interface Email {
391
394
  sesMessageId: string;
392
395
  s3Key: string;
393
396
  userSub?: string;
394
- companyId?: string;
397
+ companyId?: ObjectId | string;
395
398
  }
396
399
 
397
- interface Values {
400
+ interface InvoiceValues {
398
401
  friendlyInvoiceNumber?: string;
399
402
  friendlySupplierRef?: string;
400
403
  friendlyStartDate?: string;
@@ -454,7 +457,8 @@ interface Values {
454
457
  startRead?: string;
455
458
  endRead?: string;
456
459
  }
457
- interface Rate {
460
+ interface InvoiceRate {
461
+ id: string;
458
462
  consumption?: string;
459
463
  cost?: string;
460
464
  endDate?: Date | null;
@@ -464,14 +468,14 @@ interface Rate {
464
468
  startDate?: Date | null;
465
469
  startRead?: string | null;
466
470
  startReadType?: string | null;
467
- type: RateType | null;
471
+ type: InvoiceRateType;
468
472
  unitRate?: string | null;
469
473
  }
470
474
  type InvoiceStatus = 'processing' | 'pending' | 'uploading' | 'queued' | 'captured' | 'error' | 'completed';
471
475
  type FinancialStatus = 'approved' | 'new' | 'not-approved' | 'paid' | 'sent-for-payment';
472
- type RateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
476
+ type InvoiceRateType = 'unitRate' | 'daily' | 'levy' | 'tax' | 'kva' | 'waterRate' | 'wasteRate' | 'discount';
473
477
  interface Invoice {
474
- _id: string;
478
+ _id: ObjectId | string;
475
479
  jobId?: string | null;
476
480
  startTime?: Date;
477
481
  endTime?: Date | null;
@@ -485,8 +489,8 @@ interface Invoice {
485
489
  type?: string | null;
486
490
  tags?: string[];
487
491
  manualResults?: Record<string, any>;
488
- values?: Values;
489
- rates?: Rate[];
492
+ values?: InvoiceValues;
493
+ rates?: InvoiceRate[];
490
494
  detailedResults?: Record<string, any>;
491
495
  templateVersion?: string | null;
492
496
  error?: Record<string, any>;
@@ -503,24 +507,24 @@ interface Invoice {
503
507
  confirmedAt?: Date | null;
504
508
  confirmedBy?: string | null;
505
509
  supplierId?: string | null;
506
- sisterId?: string | null;
507
- batchId?: string | null;
508
- accountId?: string | null;
509
- entityId?: string;
510
+ sisterId?: ObjectId | string | null;
511
+ batchId?: ObjectId | string | null;
512
+ accountId?: ObjectId | string | null;
513
+ entityId?: ObjectId | string;
510
514
  companyId: string;
511
515
  userSub: string;
512
516
  validation?: any[];
513
517
  }
514
518
 
515
519
  interface Log {
516
- _id: string;
520
+ _id: ObjectId | string;
517
521
  message: string;
518
522
  context?: {};
519
- linkedId?: string;
523
+ linkedId?: ObjectId | string;
520
524
  linkedType?: string;
521
525
  type: string;
522
526
  userSub?: string;
523
- companyId?: string;
527
+ companyId?: ObjectId | string;
524
528
  }
525
529
 
526
530
  interface Reading {
@@ -530,20 +534,20 @@ interface Reading {
530
534
  type?: string;
531
535
  invoiceStartRead?: number;
532
536
  source: string;
533
- invoiceId?: string;
534
- rateId?: string;
537
+ invoiceId?: ObjectId | string;
538
+ rateId?: ObjectId | string;
535
539
  contractRateType?: string;
536
540
  invoiceBatchId?: string;
537
541
  batchId?: string;
538
- accountId: string;
539
- entityId: string;
540
- companyId: string;
542
+ accountId: ObjectId | string;
543
+ entityId: ObjectId | string;
544
+ companyId: ObjectId | string;
541
545
  userSub?: string;
542
546
  }
543
547
 
544
548
  type ReportSource = 'assetGroup' | 'asset' | 'account' | 'accountsByRegister';
545
549
  interface ReportSourceIdItem {
546
- _id: string;
550
+ _id: ObjectId | string;
547
551
  type: ReportSource;
548
552
  }
549
553
  interface ReportMetadata {
@@ -570,7 +574,7 @@ interface ReportMetadata {
570
574
  activityType: string;
571
575
  }
572
576
  interface Report {
573
- _id: string;
577
+ _id: ObjectId | string;
574
578
  type: 'dynamic' | 'spreadsheet' | 'table' | 'pdf';
575
579
  subType?: string;
576
580
  fileFormat: 'pdf' | 'xlsx' | 'csv' | 'json' | 'png' | 'jpg' | 'chart';
@@ -584,10 +588,10 @@ interface Report {
584
588
  availableAt?: Date;
585
589
  s3Key: string | null;
586
590
  batchId?: string;
587
- scheduledReportId?: string;
588
- reportTemplateId?: string;
589
- entityId: string;
590
- companyId: string;
591
+ scheduledReportId?: ObjectId | string;
592
+ reportTemplateId?: ObjectId | string;
593
+ entityId: ObjectId | string;
594
+ companyId: ObjectId | string;
591
595
  userSub?: string;
592
596
  }
593
597
 
@@ -601,7 +605,7 @@ interface InvoiceOptionsSchema {
601
605
  stampPositionY?: number;
602
606
  }
603
607
  interface Supplier {
604
- _id: string;
608
+ _id: ObjectId | string;
605
609
  name: string;
606
610
  logoUrl?: string;
607
611
  websiteUrl?: string;
@@ -624,6 +628,14 @@ interface ETNPagedResponse$1<T = any> {
624
628
  limit: number;
625
629
  skip: number;
626
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>;
627
639
 
628
640
  interface ETNPagedResponse<T = any> {
629
641
  data: T[];
@@ -809,4 +821,4 @@ declare namespace reporting {
809
821
  export { reporting_getScheduledReportRunTimes as getScheduledReportRunTimes };
810
822
  }
811
823
 
812
- 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, type UtilityType, _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.51",
3
+ "version": "1.2.52",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",