@etainabl/nodejs-sdk 1.2.16 → 1.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/api.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults } from 'axios';
2
- export interface ETNPagedResponse {
3
- data: any[];
2
+ import type { Account, Asset, Company, Invoice, Log, Reading, Supplier } from '../types/index.js';
3
+ export interface ETNPagedResponse<T = any> {
4
+ data: T[];
4
5
  total: number;
5
6
  limit: number;
6
7
  skip: number;
@@ -15,84 +16,87 @@ interface AuthOptions {
15
16
  }
16
17
  declare const _default: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
17
18
  instance: AxiosInstance;
18
- getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
19
- listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
19
+ getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account>;
20
+ listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Account>>;
20
21
  updateAccount: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
21
22
  createAccount: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
22
23
  removeAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
23
24
  getAccountSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
24
- getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
25
- listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
25
+ getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset>;
26
+ listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Asset>>;
26
27
  updateAsset: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
27
28
  createAsset: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
28
29
  removeAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
29
30
  getAssetSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
30
31
  getAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
31
- listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
32
+ listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
32
33
  updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
33
34
  createAssetGroup: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
34
35
  removeAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
35
36
  getAssetGroupAssets: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
36
37
  getAssetGroupSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
37
- getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
38
- listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
38
+ getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation>;
39
+ listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Automation>>;
39
40
  updateAutomation: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
40
41
  createAutomation: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
41
42
  removeAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
42
43
  createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
43
44
  updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
44
45
  removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig<any>) => Promise<any>;
45
- getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
46
+ getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<Company>;
46
47
  getConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
47
- listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
48
+ listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
48
49
  updateConsumption: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
49
50
  createConsumption: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
50
51
  removeConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
51
52
  getConsumptionSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
52
53
  getEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
53
- listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
54
+ listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
54
55
  updateEmail: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
55
56
  createEmail: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
56
57
  removeEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
57
58
  getEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
58
- listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
59
+ listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
59
60
  updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
60
61
  createEmissionFactor: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
61
62
  removeEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
62
- getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
63
- listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
63
+ getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log>;
64
+ listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Log>>;
64
65
  updateLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
65
66
  createLog: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
66
67
  removeLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
67
- getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
68
- listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
68
+ getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading>;
69
+ listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Reading>>;
69
70
  updateReading: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
70
71
  createReading: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
71
72
  removeReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
72
73
  getReadingSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
73
74
  getReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
74
- listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
75
+ listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
75
76
  updateReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
76
77
  createReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
77
78
  removeReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
78
79
  sendReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
79
80
  getReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
80
- listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
81
+ listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
81
82
  updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
82
83
  createReportTemplate: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
83
84
  removeReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
84
85
  getScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
85
- listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
86
+ listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
86
87
  updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
87
88
  createScheduledReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
88
89
  removeScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
89
90
  sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
90
- getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
91
- listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
91
+ getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice>;
92
+ listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Invoice>>;
92
93
  updateInvoice: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
93
94
  createInvoice: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
94
95
  removeInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
95
96
  getInvoiceSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
96
- getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
97
+ getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<Supplier>;
98
+ updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
99
+ createDataIngest: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
100
+ listDataIngest: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<DataIngest>>;
97
101
  };
98
102
  export default _default;
package/dist/cjs/api.js CHANGED
@@ -38,7 +38,7 @@ const factory = {
38
38
  method: 'GET',
39
39
  url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`
40
40
  };
41
- log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);
41
+ log.info(`API Request: ${req.method} ${process.env.ETAsINABL_API_URL}/${req.url}`);
42
42
  let res;
43
43
  try {
44
44
  res = yield etainablApi.get(req.url, options);
@@ -293,7 +293,11 @@ exports.default = (auth, instanceOptions = {}) => {
293
293
  removeInvoice: factory.remove(etainablApi, 'invoices'),
294
294
  getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),
295
295
  //suppliers
296
- getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema')
296
+ getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),
297
+ //data imports
298
+ updateDataIngest: factory.update(etainablApi, 'data-ingests'),
299
+ createDataIngest: factory.create(etainablApi, 'data-ingests'),
300
+ listDataIngest: factory.list(etainablApi, 'data-ingests'),
297
301
  };
298
302
  }
299
303
  catch (e) {
@@ -6,4 +6,6 @@ import * as units from './units.js';
6
6
  import * as consumption from './consumption.js';
7
7
  import * as monitoring from './monitoring.js';
8
8
  import * as reporting from './reporting.js';
9
+ import type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Supplier } from '../types/index.d.js';
9
10
  export { api, logger, consumption, monitoring, db, slack, units, reporting };
11
+ export type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Supplier };
package/dist/mjs/api.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults } from 'axios';
2
- export interface ETNPagedResponse {
3
- data: any[];
2
+ import type { Account, Asset, Company, Invoice, Log, Reading, Supplier } from '../types/index.js';
3
+ export interface ETNPagedResponse<T = any> {
4
+ data: T[];
4
5
  total: number;
5
6
  limit: number;
6
7
  skip: number;
@@ -15,84 +16,87 @@ interface AuthOptions {
15
16
  }
16
17
  declare const _default: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
17
18
  instance: AxiosInstance;
18
- getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
19
- listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
19
+ getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account>;
20
+ listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Account>>;
20
21
  updateAccount: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
21
22
  createAccount: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
22
23
  removeAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
23
24
  getAccountSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
24
- getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
25
- listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
25
+ getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset>;
26
+ listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Asset>>;
26
27
  updateAsset: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
27
28
  createAsset: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
28
29
  removeAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
29
30
  getAssetSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
30
31
  getAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
31
- listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
32
+ listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
32
33
  updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
33
34
  createAssetGroup: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
34
35
  removeAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
35
36
  getAssetGroupAssets: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
36
37
  getAssetGroupSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
37
- getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
38
- listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
38
+ getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation>;
39
+ listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Automation>>;
39
40
  updateAutomation: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
40
41
  createAutomation: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
41
42
  removeAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
42
43
  createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
43
44
  updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
44
45
  removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig<any>) => Promise<any>;
45
- getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
46
+ getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<Company>;
46
47
  getConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
47
- listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
48
+ listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
48
49
  updateConsumption: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
49
50
  createConsumption: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
50
51
  removeConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
51
52
  getConsumptionSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
52
53
  getEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
53
- listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
54
+ listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
54
55
  updateEmail: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
55
56
  createEmail: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
56
57
  removeEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
57
58
  getEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
58
- listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
59
+ listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
59
60
  updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
60
61
  createEmissionFactor: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
61
62
  removeEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
62
- getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
63
- listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
63
+ getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log>;
64
+ listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Log>>;
64
65
  updateLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
65
66
  createLog: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
66
67
  removeLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
67
- getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
68
- listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
68
+ getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading>;
69
+ listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Reading>>;
69
70
  updateReading: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
70
71
  createReading: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
71
72
  removeReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
72
73
  getReadingSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
73
74
  getReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
74
- listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
75
+ listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
75
76
  updateReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
76
77
  createReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
77
78
  removeReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
78
79
  sendReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
79
80
  getReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
80
- listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
81
+ listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
81
82
  updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
82
83
  createReportTemplate: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
83
84
  removeReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
84
85
  getScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
85
- listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
86
+ listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
86
87
  updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
87
88
  createScheduledReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
88
89
  removeScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
89
90
  sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
90
- getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
91
- listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse>;
91
+ getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice>;
92
+ listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Invoice>>;
92
93
  updateInvoice: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
93
94
  createInvoice: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
94
95
  removeInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
95
96
  getInvoiceSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
96
- getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
97
+ getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<Supplier>;
98
+ updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
99
+ createDataIngest: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
100
+ listDataIngest: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<DataIngest>>;
97
101
  };
98
102
  export default _default;
package/dist/mjs/api.js CHANGED
@@ -23,7 +23,7 @@ const factory = {
23
23
  method: 'GET',
24
24
  url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`
25
25
  };
26
- log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);
26
+ log.info(`API Request: ${req.method} ${process.env.ETAsINABL_API_URL}/${req.url}`);
27
27
  let res;
28
28
  try {
29
29
  res = await etainablApi.get(req.url, options);
@@ -283,7 +283,11 @@ export default (auth, instanceOptions = {}) => {
283
283
  removeInvoice: factory.remove(etainablApi, 'invoices'),
284
284
  getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),
285
285
  //suppliers
286
- getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema')
286
+ getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),
287
+ //data imports
288
+ updateDataIngest: factory.update(etainablApi, 'data-ingests'),
289
+ createDataIngest: factory.create(etainablApi, 'data-ingests'),
290
+ listDataIngest: factory.list(etainablApi, 'data-ingests'),
287
291
  };
288
292
  }
289
293
  catch (e) {
@@ -6,4 +6,6 @@ import * as units from './units.js';
6
6
  import * as consumption from './consumption.js';
7
7
  import * as monitoring from './monitoring.js';
8
8
  import * as reporting from './reporting.js';
9
+ import type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Supplier } from '../types/index.d.js';
9
10
  export { api, logger, consumption, monitoring, db, slack, units, reporting };
11
+ export type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Supplier };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etainabl/nodejs-sdk",
3
- "version": "1.2.16",
3
+ "version": "1.2.18",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/mjs/index.js",
6
6
  "author": "Jonathan Lambert <jonathan@etainabl.com>",
package/src/api.ts CHANGED
@@ -4,10 +4,12 @@ import https from 'https';
4
4
 
5
5
  import logger from './logger.js';
6
6
 
7
+ import type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Supplier } from '../types/index.js'
8
+
7
9
  const log = logger('etainablApi');
8
10
 
9
- export interface ETNPagedResponse {
10
- data: any[];
11
+ export interface ETNPagedResponse<T = any> {
12
+ data: T[];
11
13
  total: number;
12
14
  limit: number;
13
15
  skip: number;
@@ -39,13 +41,13 @@ function _handleResponse(req: ETNReq, res: AxiosResponse, isPaged = false) {
39
41
  }
40
42
 
41
43
  const factory = {
42
- getWithId: (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, options: AxiosRequestConfig = {}) => {
44
+ getWithId: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {
43
45
  const req = {
44
46
  method: 'GET',
45
47
  url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`
46
48
  };
47
49
 
48
- log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);
50
+ log.info(`API Request: ${req.method} ${process.env.ETAsINABL_API_URL}/${req.url}`);
49
51
 
50
52
  let res: AxiosResponse;
51
53
 
@@ -62,7 +64,7 @@ const factory = {
62
64
 
63
65
  return res.data;
64
66
  },
65
- get: (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}) => {
67
+ get: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}): Promise<T> => {
66
68
  const req = {
67
69
  method: 'GET',
68
70
  url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`
@@ -84,7 +86,7 @@ const factory = {
84
86
 
85
87
  return res.data;
86
88
  },
87
- list: (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}): Promise<ETNPagedResponse> => {
89
+ list: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}): Promise<ETNPagedResponse<T>> => {
88
90
  const req = {
89
91
  method: 'GET',
90
92
  url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`
@@ -196,7 +198,6 @@ const factory = {
196
198
 
197
199
  // ETN Sub Endpoints
198
200
  // e.g. /assets/:id/documents/:documentId
199
-
200
201
  const subFactory = {
201
202
  // e.g. POST /assets/:id/documents
202
203
  create: (etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) => async (id: string, data: any, options: AxiosRequestConfig = {}) => {
@@ -246,20 +247,20 @@ export default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) =>
246
247
  instance: etainablApi,
247
248
 
248
249
  // accounts
249
- getAccount: factory.getWithId(etainablApi, 'accounts'),
250
- listAccounts: factory.list(etainablApi, 'accounts'),
250
+ getAccount: factory.getWithId<Account>(etainablApi, 'accounts'),
251
+ listAccounts: factory.list<Account>(etainablApi, 'accounts'),
251
252
  updateAccount: factory.update(etainablApi, 'accounts'),
252
253
  createAccount: factory.create(etainablApi, 'accounts'),
253
254
  removeAccount: factory.remove(etainablApi, 'accounts'),
254
255
  getAccountSchema: factory.get(etainablApi, 'accounts', 'schema'),
255
-
256
+
256
257
  // assets
257
- getAsset: factory.getWithId(etainablApi, 'assets'),
258
- listAssets: factory.list(etainablApi, 'assets'),
258
+ getAsset: factory.getWithId<Asset>(etainablApi, 'assets'),
259
+ listAssets: factory.list<Asset>(etainablApi, 'assets'),
259
260
  updateAsset: factory.update(etainablApi, 'assets'),
260
261
  createAsset: factory.create(etainablApi, 'assets'),
261
262
  removeAsset: factory.remove(etainablApi, 'assets'),
262
- getAssetSchema: factory.get(etainablApi, 'assets', 'schema'),
263
+ getAssetSchema: factory.get(etainablApi, 'assets', 'schema'),
263
264
 
264
265
  // assetGroups
265
266
  getAssetGroup: factory.getWithId(etainablApi, 'asset-groups'),
@@ -271,8 +272,8 @@ export default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) =>
271
272
  getAssetGroupSchema: factory.get(etainablApi, 'asset-groups', 'schema'),
272
273
 
273
274
  // automation
274
- getAutomation: factory.getWithId(etainablApi, 'automation'),
275
- listAutomations: factory.list(etainablApi, 'automation'),
275
+ getAutomation: factory.getWithId<Automation>(etainablApi, 'automation'),
276
+ listAutomations: factory.list<Automation>(etainablApi, 'automation'),
276
277
  updateAutomation: factory.update(etainablApi, 'automation'),
277
278
  createAutomation: factory.create(etainablApi, 'automation'),
278
279
  removeAutomation: factory.remove(etainablApi, 'automation'),
@@ -281,7 +282,7 @@ export default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) =>
281
282
  removeAutomationLog: subFactory.remove(etainablApi, 'automation', 'logs'),
282
283
 
283
284
  // company
284
- getCompany: factory.getWithId(etainablApi, 'companies'),
285
+ getCompany: factory.getWithId<Company>(etainablApi, 'companies'),
285
286
 
286
287
  // consumption
287
288
  getConsumption: factory.getWithId(etainablApi, 'consumptions'),
@@ -306,15 +307,15 @@ export default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) =>
306
307
  removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),
307
308
 
308
309
  // logs
309
- getLog: factory.getWithId(etainablApi, 'logs'),
310
- listLogs: factory.list(etainablApi, 'logs'),
310
+ getLog: factory.getWithId<Log>(etainablApi, 'logs'),
311
+ listLogs: factory.list<Log>(etainablApi, 'logs'),
311
312
  updateLog: factory.update(etainablApi, 'logs'),
312
313
  createLog: factory.create(etainablApi, 'logs'),
313
314
  removeLog: factory.remove(etainablApi, 'logs'),
314
315
 
315
316
  // readings
316
- getReading: factory.getWithId(etainablApi, 'readings'),
317
- listReadings: factory.list(etainablApi, 'readings'),
317
+ getReading: factory.getWithId<Reading>(etainablApi, 'readings'),
318
+ listReadings: factory.list<Reading>(etainablApi, 'readings'),
318
319
  updateReading: factory.update(etainablApi, 'readings'),
319
320
  createReading: factory.create(etainablApi, 'readings'),
320
321
  removeReading: factory.remove(etainablApi, 'readings'),
@@ -344,15 +345,20 @@ export default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) =>
344
345
  sendScheduledReport: factory.customWithId(etainablApi, 'post', 'scheduled-reports', 'send'),
345
346
 
346
347
  // invoices
347
- getInvoice: factory.getWithId(etainablApi, 'invoices'),
348
- listInvoices: factory.list(etainablApi, 'invoices'),
348
+ getInvoice: factory.getWithId<Invoice>(etainablApi, 'invoices'),
349
+ listInvoices: factory.list<Invoice>(etainablApi, 'invoices'),
349
350
  updateInvoice: factory.update(etainablApi, 'invoices'),
350
351
  createInvoice: factory.create(etainablApi, 'invoices'),
351
352
  removeInvoice: factory.remove(etainablApi, 'invoices'),
352
- getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),
353
+ getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),
353
354
 
354
355
  //suppliers
355
- getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema')
356
+ getSupplierSchema: factory.get<Supplier>(etainablApi, 'suppliers', 'schema'),
357
+
358
+ //data imports
359
+ updateDataIngest: factory.update(etainablApi, 'data-ingests'),
360
+ createDataIngest: factory.create(etainablApi, 'data-ingests'),
361
+ listDataIngest: factory.list<DataIngest>(etainablApi, 'data-ingests'),
356
362
 
357
363
  }
358
364
  } catch (e) {
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ import * as units from './units.js';
6
6
  import * as consumption from './consumption.js';
7
7
  import * as monitoring from './monitoring.js';
8
8
  import * as reporting from './reporting.js';
9
+ import type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Supplier } from '../types/index.d.js';
9
10
 
10
11
  export {
11
12
  api,
@@ -16,4 +17,6 @@ export {
16
17
  slack,
17
18
  units,
18
19
  reporting
19
- }
20
+ }
21
+
22
+ export type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Supplier };
@@ -0,0 +1,116 @@
1
+ import type { Portal } from './portal.ts';
2
+ import type { StatusHistory } from './statusHistory.ts'
3
+
4
+ interface PortalAccountSchema extends Portal{
5
+ invoiceFilenames: any[];
6
+ }
7
+
8
+ interface RateSchema {
9
+ type: string;
10
+ value: number;
11
+ description: string;
12
+ }
13
+
14
+ interface ContractSchema {
15
+ startDate: Date;
16
+ endDate: Date;
17
+ terminationDate?: Date;
18
+ paymentTerms?: string;
19
+ duration?: string;
20
+ tariffName?: string;
21
+ contractConsumption?: number;
22
+ volumeTolerance?: any[];
23
+ renewablePercentage?: number;
24
+ marketBasedEmissionFactor?: number;
25
+ chargeableCclPercentage?: number;
26
+ commissionRates?: number;
27
+ rates: any[];
28
+ s3Key?: string;
29
+ rateTypeMapping?: object;
30
+ batchId?: string;
31
+ supplierId?: string;
32
+ status: 'active' | 'inactive';
33
+ userSub?: string;
34
+ deletedOn?: Date;
35
+ }
36
+
37
+ interface CreditNoteSchema {
38
+ name: string;
39
+ type: string;
40
+ amount: number;
41
+ netAmount: number;
42
+ taxAmount: number;
43
+ date: Date;
44
+ isPaid: boolean;
45
+ s3Key: string;
46
+ stampedS3Key: string;
47
+ fileName: string;
48
+ invoiceData: object;
49
+ userSub: string;
50
+ readingIds: any[];
51
+ supplierId: string;
52
+ totalUnits: number;
53
+ endDate: Date;
54
+ startDate: Date;
55
+ stampDate: Date;
56
+ totalWaterVolume: number;
57
+ totalWasteVolume: number;
58
+ totalWaterCost: number;
59
+ totalWasteCost: number;
60
+ }
61
+
62
+ export interface Account {
63
+ _id: string,
64
+ name: string;
65
+ modifiedBy?: string;
66
+ siteCode?: string;
67
+ type: 'gas' | 'electricity' | 'water' | 'waste' | 'solar';
68
+ supplierRef?: string;
69
+ financialCode?: string;
70
+ propertyCode?: string;
71
+ meterPointNumber?: string;
72
+ meterSerialNumber?: string;
73
+ meterPointNumber2?: string;
74
+ meterUnits: 'kwh' | 'm3' | 'ft3';
75
+ automaticMeterRead?: boolean;
76
+ status?: 'active' | 'inactive';
77
+ statusHistory?: StatusHistory[]; // Referenced from another file
78
+ rates?: RateSchema[];
79
+ capacity?: string;
80
+ meterOperator?: string;
81
+ meterLocation?: string;
82
+ meterOperatorType?: 'lease' | 'purchase';
83
+ meterOperatorExpiryDate?: Date;
84
+ dataCollector?: string;
85
+ parentAccountId?: string;
86
+ processingInvoices?: object[];
87
+ contracts?: ContractSchema[];
88
+ creditNotes?: CreditNoteSchema[];
89
+ meterUser?: string;
90
+ isTrc?: boolean;
91
+ floorArea?: string;
92
+ floorAreaUnit?: 'metric' | 'imperial';
93
+ reportingType?: string;
94
+ solarType?: 'generation' | 'export';
95
+ consumptionSource?: 'primary' | 'sub' | 'primary-sub';
96
+ esec?: 'a' | 'b' | 'c' | 'd' | 'e' | 'g' | 'h' | 'j' | 'k' | 'l' | 'm' | 'n' | 'p' | 'q' | 'r' | 's' | 't' | 'u';
97
+ portal?: PortalAccountSchema;
98
+ deviceId?: string;
99
+ gridfetchLoa?: {
100
+ s3Key?: string;
101
+ name?: string;
102
+ uploadedBy?: string;
103
+ uploadedAt?: Date;
104
+ expiryDate?: Date;
105
+ error?: string;
106
+ uploaded?: boolean;
107
+ };
108
+ automationIds?: string[];
109
+ customIntegrations?: object;
110
+ supplierId?: string;
111
+ batchId?: string;
112
+ assetId: string;
113
+ entityId: string;
114
+ companyId: string;
115
+ userSub: string;
116
+ }
@@ -0,0 +1,12 @@
1
+ export interface Address {
2
+ streetAddress: string;
3
+ locality?: string;
4
+ region?: string;
5
+ postCode: string;
6
+ province?: string;
7
+ countryCode?: string;
8
+ jurisdictionCode?: string;
9
+ latitude?: string;
10
+ longitude?: string;
11
+ }
12
+
@@ -0,0 +1,142 @@
1
+ import type { Address } from './address.js'
2
+ import type { StatusHistory } from './statusHistory.ts'
3
+
4
+ // Define the Image Schema
5
+ interface Image {
6
+ url?: string;
7
+ label?: string;
8
+ type?: string;
9
+ isHidden?: boolean;
10
+ isPrimary?: boolean;
11
+ }
12
+
13
+ // Define the Flood Risk Schema
14
+ interface FloodRisk {
15
+ url?: string;
16
+ description?: string;
17
+ label?: string;
18
+ latitude?: number;
19
+ longitude?: number;
20
+ fetchedAt?: Date;
21
+ }
22
+
23
+ // Define the Crime Schema
24
+ interface Crime {
25
+ category?: string;
26
+ month?: string;
27
+ crimeId?: string;
28
+ outcomeCategory?: string;
29
+ outcomeDate?: string;
30
+ location?: {
31
+ latitude: string;
32
+ longitude: string;
33
+ street: string;
34
+ };
35
+ fetchedAt?: Date;
36
+ }
37
+
38
+ // Define the Air Quality Schema
39
+ interface AirQuality {
40
+ index?: number;
41
+ indexColour?: string;
42
+ indexRating?: string;
43
+ details?: object;
44
+ location?: object;
45
+ lastMeasured?: Date;
46
+ fetchedAt?: Date;
47
+ }
48
+
49
+ // Define the Benchmark Schema
50
+ interface Benchmark {
51
+ benchmarkId: string
52
+ fieldCode: string;
53
+ fieldValue: string;
54
+ }
55
+
56
+ // Define the Document Schema
57
+ interface Document {
58
+ s3Key?: string;
59
+ name: string;
60
+ extension?: string;
61
+ type: string;
62
+ status: string;
63
+ score?: string;
64
+ providerId?: string;
65
+ providerData?: object;
66
+ certificate?: object;
67
+ createdAt: Date;
68
+ accountIds?: string[];
69
+ }
70
+
71
+ // Define the Timeline Event Schema
72
+ interface TimelineEvent {
73
+ date: Date;
74
+ title: string;
75
+ status: string;
76
+ content?: string;
77
+ icon?: string;
78
+ accountIds?: string[];
79
+ }
80
+
81
+ // Define the Asset Recommendation Schema
82
+ interface AssetRecommendation {
83
+ recommendationId: string
84
+ documentIds?: string[];
85
+ }
86
+
87
+ // Define the Asset Settings Schema
88
+ interface AssetSettings {
89
+ consumptionSources: {
90
+ electricity: string;
91
+ solar: string;
92
+ gas: string;
93
+ water: string;
94
+ };
95
+ }
96
+
97
+ // Main export, mirroring the main object in your code
98
+ export interface Asset {
99
+ _id: string
100
+ siteName: string;
101
+ address: Address;
102
+ assetType: string;
103
+ floorArea: number;
104
+ floorAreaUnit: 'metric' | 'imperial';
105
+ noOfFloors?: number;
106
+ energyRating: string;
107
+ gav: string;
108
+ gavCurrency: string;
109
+ currency: string;
110
+ occupationStatus: 'occupied' | 'vacant' | 'other' | 'n/a';
111
+ type: 'new construction' | 'major renovation' | 'standing investment' | 'n/a';
112
+ vacancyRate?: number;
113
+ constructionYear?: number;
114
+ ownedSince?: Date;
115
+ disposalDate?: Date;
116
+ tenure: 'freehold' | 'leasehold';
117
+ tenantControlledPercent?: number;
118
+ landlordControlledPercent?: number;
119
+ occupancyLevel?: number;
120
+ images: Image[];
121
+ pricePaid?: number;
122
+ floodRisks: FloodRisk[];
123
+ recentCrimes: Crime[];
124
+ recentAirQuality: AirQuality;
125
+ documents?: Document[];
126
+ epbCertificates: any[];
127
+ status?: string;
128
+ settings: AssetSettings;
129
+ recommendations?: AssetRecommendation[];
130
+ statusHistory: StatusHistory[];
131
+ timelineEvents: TimelineEvent[];
132
+ benchmarks: Benchmark[];
133
+ lastPopulated?: Date;
134
+ deletedOn?: Date;
135
+ batchId?: string;
136
+ companyId: string;
137
+ entityId: string;
138
+ assetGroupIds: string[];
139
+ userSub: string;
140
+ gresbId?: string;
141
+ };
142
+
@@ -0,0 +1,36 @@
1
+ import { Types } from 'mongoose';
2
+
3
+ interface Log {
4
+ message: string;
5
+ timestamp: Date;
6
+ batchId?: string;
7
+ source?: string;
8
+ }
9
+
10
+ interface LastCollection {
11
+ collectedAt: Date | null;
12
+ data: Record<string, any> | null;
13
+ error: Record<string, any> | null;
14
+ status: 'success' | 'error' | 'pending';
15
+ source: Record<string, any> | null;
16
+ }
17
+
18
+ type FrequencyType = 'never' | 'trigger' | 'hourly' | 'daily' | 'weekly' | 'monthly';
19
+
20
+ export interface Automation {
21
+ description?: string;
22
+ service: string;
23
+ source: string;
24
+ category: string;
25
+ active: boolean;
26
+ status?: 'running' | 'pending';
27
+ lastCollection: LastCollection;
28
+ logs: Log[];
29
+ data: Record<string, any>;
30
+ sourceData: Record<string, any>;
31
+ frequency?: FrequencyType;
32
+ accountIds?: Types.ObjectId[];
33
+ assetIds?: Types.ObjectId[];
34
+ userSub: string;
35
+ companyId: Types.ObjectId;
36
+ }
@@ -0,0 +1,47 @@
1
+
2
+ import { Address } from './address.js'
3
+ import { Portal } from './portal.ts'
4
+
5
+ interface SupplierPortals {
6
+ supplierId: string;
7
+ portal: Portal;
8
+ }
9
+
10
+ interface CustomIntegrations {
11
+ account: any[];
12
+ asset: any[];
13
+ entity: any[];
14
+ }
15
+
16
+ interface DefaultSources {
17
+ electricity: 'invoice' | 'consumption' | 'reading';
18
+ solar: 'invoice' | 'consumption' | 'reading';
19
+ gas: 'invoice' | 'consumption' | 'reading';
20
+ water: 'invoice' | 'consumption' | 'reading';
21
+ }
22
+
23
+ interface CompanySettings {
24
+ showLogo?: boolean;
25
+ invoiceCategories?: any[];
26
+ miscInvoiceCategories?: any[];
27
+ messageCategories?: any[];
28
+ documentCategories?: any[];
29
+ assetDataSchemas?: any[];
30
+ hideCostData?: boolean;
31
+ calendarPeriod?: string;
32
+ customIntegrations?: CustomIntegrations;
33
+ supplierPortals?: SupplierPortals[];
34
+ defaultSources?: DefaultSources;
35
+ scraperCounter?: number;
36
+ }
37
+
38
+ export interface Company {
39
+ _id: string
40
+ name: string;
41
+ address?: Address;
42
+ invoiceEmail?: string;
43
+ users?: string[];
44
+ settings: CompanySettings;
45
+ logoS3Key: string;
46
+ logoUrl?: string;
47
+ }
@@ -0,0 +1,8 @@
1
+ export interface DataImport {
2
+ messageId: string;
3
+ status: 'started' | 'processing' | 'importing' | 'completed' | 'failed' | 'dlq'
4
+ context: string
5
+ startTime: string;
6
+ remainingTime: number;
7
+ context: {}
8
+ }
@@ -0,0 +1,17 @@
1
+ interface Attachment {
2
+ filename: string;
3
+ s3Key: string;
4
+ }
5
+
6
+ export interface Email {
7
+ destinations: string[];
8
+ service: string;
9
+ subject: string;
10
+ body: string;
11
+ from: string;
12
+ attachments?: Attachment[];
13
+ sesMessageId: string;
14
+ s3Key: string;
15
+ userSub?: string;
16
+ companyId?: string
17
+ }
@@ -0,0 +1,32 @@
1
+ import type { Account } from './account.d.ts'
2
+ import type { Asset } from './asset.d.ts'
3
+ import type { Company } from './company.d.ts'
4
+ import type { CreateScraperRunParams, ScraperRun } from './scraperRun.d.ts';
5
+ import type { DataIngest } from './dataIngest.js'
6
+ import type { Email } from './email.d.ts';
7
+ import type { Invoice } from './invoice.d.ts';
8
+ import type { Log } from './log.d.ts';
9
+ import type { Reading } from './reading.d.ts'
10
+ import type { Supplier } from './supplier.d.ts'
11
+
12
+ export type {
13
+ Account,
14
+ Asset,
15
+ Automation,
16
+ Company,
17
+ CreateScraperRunParams,
18
+ DataIngest,
19
+ Email,
20
+ Invoice,
21
+ Log,
22
+ Reading,
23
+ ScraperRun,
24
+ Supplier
25
+ };
26
+
27
+ export interface ETNPagedResponse<T = any> {
28
+ data: T[];
29
+ total: number;
30
+ limit: number;
31
+ skip: number;
32
+ }
@@ -0,0 +1,106 @@
1
+ import { Types } from 'mongoose';
2
+
3
+ interface Values {
4
+ friendlyInvoiceNumber?: string;
5
+ friendlySupplierRef?: string;
6
+ friendlyStartDate?: string;
7
+ friendlyEndDate?: string;
8
+ friendlyInvoiceDate?: string;
9
+ friendlyMeterPointNumber?: string;
10
+ friendlyMeterPointNumber2?: string;
11
+ friendlyMeterSerialNumber?: string;
12
+ friendlyPipeSize?: string;
13
+ friendlyTotalUnitCost?: number;
14
+ friendlyTotalWaterCost?: number;
15
+ friendlyTotalWasteCost?: number;
16
+ friendlyTotalDaily?: number;
17
+ friendlyTotalLevy?: number;
18
+ friendlyTotalKva?: number;
19
+ friendlyTotalUnits?: number;
20
+ friendlyTotalWaterVolume?: number;
21
+ friendlyTotalWasteVolume?: number;
22
+ friendlyNetTotalCost?: number;
23
+ friendlyTotalTax?: number;
24
+ friendlyTotalCost?: number;
25
+ friendlyMeteredConsumption?: string;
26
+ friendlyCorrectedConsumption?: string;
27
+ friendlyCorrectionFactor?: string;
28
+ friendlyCalorificValue?: string;
29
+ friendlyReadFactor?: string;
30
+ friendlyType?: string;
31
+ friendlyStartRead?: string;
32
+ friendlyEndRead?: string;
33
+ invoiceNumber?: string;
34
+ supplierRef?: string;
35
+ startDate?: Date;
36
+ endDate?: Date;
37
+ invoiceDate?: Date;
38
+ meterPointNumber?: string;
39
+ meterPointNumber2?: string;
40
+ meterSerialNumber?: string;
41
+ pipeSize?: string;
42
+ totalUnitCost?: number;
43
+ totalWaterCost?: number;
44
+ totalWasteCost?: number;
45
+ totalDaily?: number;
46
+ totalLevy?: number;
47
+ totalKva?: number;
48
+ totalUnits?: number;
49
+ totalWaterVolume?: number;
50
+ totalWasteVolume?: number;
51
+ netTotalCost?: number;
52
+ totalTax?: number;
53
+ totalCost?: number;
54
+ meteredConsumption?: string;
55
+ correctedConsumption?: string;
56
+ correctionFactor?: string;
57
+ calorificValue?: string;
58
+ readFactor?: string;
59
+ type?: string;
60
+ startRead?: string;
61
+ endRead?: string;
62
+ }
63
+
64
+ type InvoiceStatus = 'processing' | 'pending' | 'uploading' | 'queued' | 'captured' | 'error' | 'completed';
65
+ type FinancialStatus = 'approved' | 'new' | 'not-approved' | 'paid' | 'sent-for-payment';
66
+
67
+ export interface Invoice {
68
+ jobId?: string | null;
69
+ startTime?: Date;
70
+ endTime?: Date | null;
71
+ s3Key: string;
72
+ s3TextractKey?: string | null;
73
+ stampedS3Key: string;
74
+ fileName?: string | null;
75
+ status: InvoiceStatus;
76
+ financialStatus: FinancialStatus;
77
+ completed?: boolean;
78
+ type?: string | null;
79
+ tags?: string[];
80
+ manualResults?: Record<string, any>;
81
+ values?: Values;
82
+ rates?: any[];
83
+ detailedResults?: Record<string, any>;
84
+ templateVersion?: string | null;
85
+ error?: Record<string, any>;
86
+ isPaid?: boolean;
87
+ isCreditNote?: boolean;
88
+ isConvertedCreditNote?: boolean;
89
+ isManual?: boolean;
90
+ uploaderStatus?: string;
91
+ simulated?: boolean;
92
+ notes?: string | null;
93
+ assignedTo?: string;
94
+ noScrape?: boolean;
95
+ scraperInvoiceId?: string;
96
+ confirmedAt?: Date | null;
97
+ confirmedBy?: string | null;
98
+ supplierId?: Types.ObjectId | null;
99
+ sisterId?: string | null;
100
+ batchId?: string | null;
101
+ accountId?: Types.ObjectId | null;
102
+ entityId?: Types.ObjectId;
103
+ companyId: Types.ObjectId;
104
+ userSub: string;
105
+ validation?: any[];
106
+ }
package/types/log.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export interface Log {
2
+ message: string
3
+ context?: {}
4
+ linkedId?: string
5
+ linkedType?: string
6
+ type: string
7
+ userSub?: string
8
+ companyId?: string
9
+ }
@@ -0,0 +1,9 @@
1
+ export interface Portal {
2
+ username?: string;
3
+ password?: string;
4
+ scraperEnabled?: boolean;
5
+ url?: string;
6
+ scraperId?: string;
7
+ scraperStartDate?: Date;
8
+ }
9
+
@@ -0,0 +1,16 @@
1
+ export interface Reading {
2
+ submittedAt: Date;
3
+ value: number;
4
+ type?: string;
5
+ invoiceStartRead?: number;
6
+ source: string;
7
+ invoiceId?: string;
8
+ rateId?: string;
9
+ contractRateType?: string;
10
+ invoiceBatchId?: string;
11
+ batchId?: string;
12
+ accountId: string;
13
+ entityId: string;
14
+ companyId: string;
15
+ userSub?: string;
16
+ }
@@ -0,0 +1,15 @@
1
+ export interface CreateScraperRunParams {
2
+ supplierId: string;
3
+ accountId: string;
4
+ companyId: string;
5
+ }
6
+ export interface ScraperRun {
7
+ _id: string;
8
+ logs?: {}[];
9
+ supplierId: string;
10
+ accountId: string;
11
+ companyId: string;
12
+ invoiceData?: [];
13
+ status: string[];
14
+ error?: string;
15
+ }
@@ -0,0 +1,5 @@
1
+ export interface StatusHistory {
2
+ date: Date;
3
+ value: 'active' | 'inactive';
4
+ notes?: string;
5
+ }
@@ -0,0 +1,31 @@
1
+ import { Portal } from './portal.js'
2
+
3
+ interface PortalSupplierSchema extends Portal {
4
+ concurrent: boolean;
5
+ checkInvoiceFilenames: boolean;
6
+ supplierRefRequired: boolean;
7
+ }
8
+
9
+ interface InvoiceOptionsSchema {
10
+ stampPositionX?: number;
11
+ stampPositionY?: number;
12
+ }
13
+
14
+ export interface Supplier {
15
+ _id: string
16
+ name: string;
17
+ logoUrl?: string;
18
+ websiteUrl?: string;
19
+ portalUrl?: string;
20
+ identifier?: string;
21
+ type: 'supplier' | 'distributor';
22
+ region?: string;
23
+ countryCode: string;
24
+ defaultScraper?: string;
25
+ active: boolean;
26
+ transferSupplier: boolean;
27
+ transferSupplierId?: string;
28
+ portal: PortalSupplierSchema;
29
+ invoiceOptions?: InvoiceOptionsSchema;
30
+ };
31
+