@etainabl/nodejs-sdk 1.2.32 → 1.2.34

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,5 +1,5 @@
1
1
  import type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults } from 'axios';
2
- import type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Report } from './types/index.js';
2
+ import type { Account, Asset, Automation, Entity, Company, DataIngest, Invoice, Log, Reading, Report, Supplier } from './types/index.js';
3
3
  export interface ETNPagedResponse<T = any> {
4
4
  data: T[];
5
5
  total: number;
@@ -16,89 +16,96 @@ interface AuthOptions {
16
16
  }
17
17
  declare const _default: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
18
18
  instance: AxiosInstance;
19
- getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account>;
20
- listAccounts: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Account>>;
21
- updateAccount: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
22
- createAccount: (data: any, options?: AxiosRequestConfig) => Promise<any>;
23
- removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<any>;
24
- getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
25
- invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
26
- getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset>;
27
- listAssets: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Asset>>;
28
- updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
29
- createAsset: (data: any, options?: AxiosRequestConfig) => Promise<any>;
30
- removeAsset: (id: string, options?: AxiosRequestConfig) => Promise<any>;
31
- getAssetSchema: (options?: AxiosRequestConfig) => Promise<any>;
32
- getAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
33
- listAssetGroups: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
34
- updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
35
- createAssetGroup: (data: any, options?: AxiosRequestConfig) => Promise<any>;
36
- removeAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
37
- getAssetGroupAssets: (id: string, options?: AxiosRequestConfig) => Promise<any>;
38
- getAssetGroupSchema: (options?: AxiosRequestConfig) => Promise<any>;
39
- getAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation>;
40
- listAutomations: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Automation>>;
41
- updateAutomation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
42
- createAutomation: (data: any, options?: AxiosRequestConfig) => Promise<any>;
43
- removeAutomation: (id: string, options?: AxiosRequestConfig) => Promise<any>;
44
- createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
45
- updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
46
- removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig) => Promise<any>;
47
- getCompany: (id: string, options?: AxiosRequestConfig) => Promise<Company>;
48
- getConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
49
- listConsumptions: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
50
- updateConsumption: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
51
- createConsumption: (data: any, options?: AxiosRequestConfig) => Promise<any>;
52
- removeConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
53
- getConsumptionSchema: (options?: AxiosRequestConfig) => Promise<any>;
54
- getEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
55
- listEmails: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
56
- updateEmail: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
57
- createEmail: (data: any, options?: AxiosRequestConfig) => Promise<any>;
58
- removeEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
59
- getEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
60
- listEmissionFactors: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
61
- updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
62
- createEmissionFactor: (data: any, options?: AxiosRequestConfig) => Promise<any>;
63
- removeEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
64
- getLog: (id: string, options?: AxiosRequestConfig) => Promise<Log>;
65
- listLogs: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Log>>;
66
- updateLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
67
- createLog: (data: any, options?: AxiosRequestConfig) => Promise<any>;
68
- removeLog: (id: string, options?: AxiosRequestConfig) => Promise<any>;
69
- getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading>;
70
- listReadings: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Reading>>;
71
- updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
72
- createReading: (data: any, options?: AxiosRequestConfig) => Promise<any>;
73
- removeReading: (id: string, options?: AxiosRequestConfig) => Promise<any>;
74
- getReadingSchema: (options?: AxiosRequestConfig) => Promise<any>;
75
- getReport: (id: string, options?: AxiosRequestConfig) => Promise<Report>;
76
- listReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Report>>;
77
- updateReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
78
- createReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
79
- removeReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
80
- sendReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
81
- getReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
82
- listReportTemplates: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
83
- updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
84
- createReportTemplate: (data: any, options?: AxiosRequestConfig) => Promise<any>;
85
- removeReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
86
- getScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
87
- listScheduledReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
88
- updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
89
- createScheduledReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
90
- removeScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
91
- sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
92
- getInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice>;
93
- listInvoices: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Invoice>>;
94
- updateInvoice: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
95
- createInvoice: (data: any, options?: AxiosRequestConfig) => Promise<any>;
96
- removeInvoice: (id: string, options?: AxiosRequestConfig) => Promise<any>;
97
- getInvoiceSchema: (options?: AxiosRequestConfig) => Promise<any>;
98
- getSupplierSchema: (options?: AxiosRequestConfig) => Promise<any>;
99
- getImportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
100
- updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
101
- createDataIngest: (data: any, options?: AxiosRequestConfig) => Promise<any>;
102
- listDataIngest: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<DataIngest>>;
19
+ getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account>;
20
+ listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Account>>;
21
+ updateAccount: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
22
+ createAccount: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
23
+ removeAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
24
+ getAccountSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
25
+ invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
26
+ getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset>;
27
+ listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Asset>>;
28
+ updateAsset: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
29
+ createAsset: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
30
+ removeAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
31
+ getAssetSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
32
+ getAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
33
+ listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
34
+ updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
35
+ createAssetGroup: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
36
+ removeAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
37
+ getAssetGroupAssets: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
38
+ getAssetGroupSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
39
+ getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation>;
40
+ listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Automation>>;
41
+ updateAutomation: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
42
+ createAutomation: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
43
+ removeAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
44
+ createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
45
+ updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
46
+ removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig<any>) => Promise<any>;
47
+ getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<Company>;
48
+ getConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
49
+ listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
50
+ updateConsumption: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
51
+ createConsumption: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
52
+ removeConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
53
+ getConsumptionSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
54
+ getEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
55
+ listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
56
+ updateEmail: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
57
+ createEmail: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
58
+ removeEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
59
+ getEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
60
+ listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
61
+ updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
62
+ createEmissionFactor: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
63
+ removeEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
64
+ getEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<Entity>;
65
+ listEntities: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Entity>>;
66
+ updateEntity: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
67
+ createEntity: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
68
+ removeEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
69
+ getEntitiesSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
70
+ getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log>;
71
+ listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Log>>;
72
+ updateLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
73
+ createLog: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
74
+ removeLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
75
+ getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading>;
76
+ listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Reading>>;
77
+ updateReading: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
78
+ createReading: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
79
+ removeReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
80
+ getReadingSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
81
+ getReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<Report>;
82
+ listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Report>>;
83
+ updateReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
84
+ createReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
85
+ removeReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
86
+ sendReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
87
+ getReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
88
+ listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
89
+ updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
90
+ createReportTemplate: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
91
+ removeReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
92
+ getScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
93
+ listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
94
+ updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
95
+ createScheduledReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
96
+ removeScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
97
+ sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
98
+ getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice>;
99
+ listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Invoice>>;
100
+ updateInvoice: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
101
+ createInvoice: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
102
+ removeInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
103
+ getInvoiceSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
104
+ listSuppliers: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Supplier>>;
105
+ getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
106
+ getImportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
107
+ updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
108
+ createDataIngest: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
109
+ listDataIngest: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<DataIngest>>;
103
110
  };
104
111
  export default _default;
package/dist/cjs/api.js CHANGED
@@ -32,7 +32,7 @@ function _handleResponse(req, res, isPaged = false) {
32
32
  return res;
33
33
  }
34
34
  const factory = {
35
- getWithId: (etainablApi, endpoint, postEndpoint) => (id_1, ...args_1) => __awaiter(void 0, [id_1, ...args_1], void 0, function* (id, options = {}) {
35
+ getWithId: (etainablApi, endpoint, postEndpoint) => (id, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
36
36
  var _a;
37
37
  const req = {
38
38
  method: 'GET',
@@ -52,8 +52,8 @@ const factory = {
52
52
  _handleResponse(req, res);
53
53
  return res.data;
54
54
  }),
55
- get: (etainablApi, endpoint, postEndpoint) => (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (options = {}) {
56
- var _a;
55
+ get: (etainablApi, endpoint, postEndpoint) => (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
56
+ var _b;
57
57
  const req = {
58
58
  method: 'GET',
59
59
  url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`
@@ -64,7 +64,7 @@ const factory = {
64
64
  res = yield etainablApi.get(req.url, options);
65
65
  }
66
66
  catch (e) {
67
- if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data)
67
+ if ((_b = e.response) === null || _b === void 0 ? void 0 : _b.data)
68
68
  throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);
69
69
  throw e;
70
70
  }
@@ -72,8 +72,8 @@ const factory = {
72
72
  _handleResponse(req, res);
73
73
  return res.data;
74
74
  }),
75
- list: (etainablApi, endpoint, postEndpoint) => (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (options = {}) {
76
- var _a;
75
+ list: (etainablApi, endpoint, postEndpoint) => (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
76
+ var _c;
77
77
  const req = {
78
78
  method: 'GET',
79
79
  url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`
@@ -84,7 +84,7 @@ const factory = {
84
84
  res = yield etainablApi.get(req.url, options);
85
85
  }
86
86
  catch (e) {
87
- if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data)
87
+ if ((_c = e.response) === null || _c === void 0 ? void 0 : _c.data)
88
88
  throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);
89
89
  throw e;
90
90
  }
@@ -92,8 +92,8 @@ const factory = {
92
92
  _handleResponse(req, res, true);
93
93
  return res.data;
94
94
  }),
95
- update: (etainablApi, endpoint, postEndpoint) => (id_1, data_1, ...args_1) => __awaiter(void 0, [id_1, data_1, ...args_1], void 0, function* (id, data, options = {}) {
96
- var _a;
95
+ update: (etainablApi, endpoint, postEndpoint) => (id, data, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
96
+ var _d;
97
97
  const req = {
98
98
  method: 'PATCH',
99
99
  url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`
@@ -104,15 +104,15 @@ const factory = {
104
104
  res = yield etainablApi.patch(req.url, data, options);
105
105
  }
106
106
  catch (e) {
107
- if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data)
107
+ if ((_d = e.response) === null || _d === void 0 ? void 0 : _d.data)
108
108
  throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);
109
109
  throw e;
110
110
  }
111
111
  _handleResponse(req, res);
112
112
  return res.data;
113
113
  }),
114
- create: (etainablApi, endpoint, postEndpoint) => (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, options = {}) {
115
- var _a;
114
+ create: (etainablApi, endpoint, postEndpoint) => (data, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
115
+ var _e;
116
116
  const req = {
117
117
  method: 'POST',
118
118
  url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`
@@ -123,15 +123,15 @@ const factory = {
123
123
  res = yield etainablApi.post(req.url, data, options);
124
124
  }
125
125
  catch (e) {
126
- if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data)
126
+ if ((_e = e.response) === null || _e === void 0 ? void 0 : _e.data)
127
127
  throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);
128
128
  throw e;
129
129
  }
130
130
  _handleResponse(req, res);
131
131
  return res.data;
132
132
  }),
133
- remove: (etainablApi, endpoint, postEndpoint) => (id_1, ...args_1) => __awaiter(void 0, [id_1, ...args_1], void 0, function* (id, options = {}) {
134
- var _a;
133
+ remove: (etainablApi, endpoint, postEndpoint) => (id, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
134
+ var _f;
135
135
  const req = {
136
136
  method: 'DELETE',
137
137
  url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`
@@ -142,15 +142,15 @@ const factory = {
142
142
  res = yield etainablApi.delete(req.url, options);
143
143
  }
144
144
  catch (e) {
145
- if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data)
145
+ if ((_f = e.response) === null || _f === void 0 ? void 0 : _f.data)
146
146
  throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);
147
147
  throw e;
148
148
  }
149
149
  _handleResponse(req, res);
150
150
  return res.data;
151
151
  }),
152
- customWithId: (etainablApi, method, endpoint, postEndpoint) => (id_1, data_1, ...args_1) => __awaiter(void 0, [id_1, data_1, ...args_1], void 0, function* (id, data, options = {}) {
153
- var _a;
152
+ customWithId: (etainablApi, method, endpoint, postEndpoint) => (id, data, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
153
+ var _g;
154
154
  const req = Object.assign({ method: method, url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`, data }, options);
155
155
  log.info(`API Request (Custom): ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);
156
156
  let res;
@@ -158,7 +158,7 @@ const factory = {
158
158
  res = yield etainablApi.request(req);
159
159
  }
160
160
  catch (e) {
161
- if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data)
161
+ if ((_g = e.response) === null || _g === void 0 ? void 0 : _g.data)
162
162
  throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);
163
163
  throw e;
164
164
  }
@@ -170,17 +170,17 @@ const factory = {
170
170
  // e.g. /assets/:id/documents/:documentId
171
171
  const subFactory = {
172
172
  // e.g. POST /assets/:id/documents
173
- create: (etainablApi, endpoint, subEndpoint) => (id_1, data_1, ...args_1) => __awaiter(void 0, [id_1, data_1, ...args_1], void 0, function* (id, data, options = {}) {
173
+ create: (etainablApi, endpoint, subEndpoint) => (id, data, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
174
174
  const subUrl = `${id}/${subEndpoint}`;
175
175
  return factory.create(etainablApi, endpoint, subUrl)(data, options);
176
176
  }),
177
177
  // e.g. PATCH /assets/:id/documents/:documentId
178
- update: (etainablApi, endpoint, subEndpoint) => (id_1, subId_1, data_1, ...args_1) => __awaiter(void 0, [id_1, subId_1, data_1, ...args_1], void 0, function* (id, subId, data, options = {}) {
178
+ update: (etainablApi, endpoint, subEndpoint) => (id, subId, data, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
179
179
  const subUrl = `${subEndpoint}/${subId}`;
180
180
  return factory.update(etainablApi, endpoint, subUrl)(id, data, options);
181
181
  }),
182
182
  // e.g. DELETE /assets/:id/documents/:documentId
183
- remove: (etainablApi, endpoint, subEndpoint) => (id_1, subId_1, ...args_1) => __awaiter(void 0, [id_1, subId_1, ...args_1], void 0, function* (id, subId, options = {}) {
183
+ remove: (etainablApi, endpoint, subEndpoint) => (id, subId, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
184
184
  const subUrl = `${subEndpoint}/${subId}`;
185
185
  return factory.remove(etainablApi, endpoint, subUrl)(id, options);
186
186
  })
@@ -253,6 +253,13 @@ exports.default = (auth, instanceOptions = {}) => {
253
253
  updateEmissionFactor: factory.update(etainablApi, 'emission-factors'),
254
254
  createEmissionFactor: factory.create(etainablApi, 'emission-factors'),
255
255
  removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),
256
+ // entity
257
+ getEntity: factory.getWithId(etainablApi, 'entities'),
258
+ listEntities: factory.list(etainablApi, 'entities'),
259
+ updateEntity: factory.update(etainablApi, 'entities'),
260
+ createEntity: factory.create(etainablApi, 'entities'),
261
+ removeEntity: factory.remove(etainablApi, 'entities'),
262
+ getEntitiesSchema: factory.get(etainablApi, 'entities', 'schema'),
256
263
  // logs
257
264
  getLog: factory.getWithId(etainablApi, 'logs'),
258
265
  listLogs: factory.list(etainablApi, 'logs'),
@@ -294,6 +301,7 @@ exports.default = (auth, instanceOptions = {}) => {
294
301
  removeInvoice: factory.remove(etainablApi, 'invoices'),
295
302
  getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),
296
303
  //suppliers
304
+ listSuppliers: factory.list(etainablApi, 'suppliers'),
297
305
  getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),
298
306
  // import templates
299
307
  getImportTemplate: factory.getWithId(etainablApi, 'import-templates'),
package/dist/cjs/db.js CHANGED
@@ -16,8 +16,8 @@ const mongodb_1 = require("mongodb");
16
16
  const logger_js_1 = __importDefault(require("./logger.js"));
17
17
  const log = (0, logger_js_1.default)('dbHelpers');
18
18
  let cachedDb;
19
- function connectToDatabase() {
20
- return __awaiter(this, arguments, void 0, function* (retryAttempt = 1) {
19
+ function connectToDatabase(retryAttempt = 1) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
21
  if (!process.env.ETAINABL_DB_URL)
22
22
  throw new Error("ETAINABL_DB_URL is not set");
23
23
  if (!process.env.AWS_ACCESS_KEY_ID)
package/dist/cjs/index.js CHANGED
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
35
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
27
  };
@@ -4,13 +4,14 @@ import type { Automation } from './automation.js';
4
4
  import type { Company } from './company.js';
5
5
  import type { CreateScraperRunParams, ScraperRun } from './scraperRun.js';
6
6
  import type { DataIngest } from './dataIngest.js';
7
+ import type { Entity } from './entity.js';
7
8
  import type { Email } from './email.js';
8
9
  import type { Invoice } from './invoice.js';
9
10
  import type { Log } from './log.js';
10
11
  import type { Reading } from './reading.js';
11
12
  import type { Report } from './report.js';
12
13
  import type { Supplier } from './supplier.js';
13
- export type { Account, Asset, Automation, Company, CreateScraperRunParams, DataIngest, Email, Invoice, Log, Reading, Report, ScraperRun, Supplier };
14
+ export type { Account, Asset, Automation, Company, CreateScraperRunParams, DataIngest, Email, Entity, Invoice, Log, Reading, Report, ScraperRun, Supplier };
14
15
  export interface ETNPagedResponse<T = any> {
15
16
  data: T[];
16
17
  total: number;
@@ -5,9 +5,9 @@ interface Item {
5
5
  value: number;
6
6
  [key: string]: any;
7
7
  }
8
- export type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';
9
- export type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';
10
- export type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';
8
+ export declare type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';
9
+ export declare type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';
10
+ export declare type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';
11
11
  export declare const accountTypeMap: {
12
12
  [key: string]: BaseUnit;
13
13
  };
@@ -15,7 +15,7 @@ export declare const accountTypeUnitMap: {
15
15
  [key: string]: ETNUnit[];
16
16
  };
17
17
  export declare const convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined) => any;
18
- export declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | "") => {
18
+ export declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | '') => {
19
19
  type: AccountType;
20
20
  unit: ETNUnit;
21
21
  };
package/dist/mjs/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults } from 'axios';
2
- import type { Account, Asset, Automation, Company, DataIngest, Invoice, Log, Reading, Report } from './types/index.js';
2
+ import type { Account, Asset, Automation, Entity, Company, DataIngest, Invoice, Log, Reading, Report, Supplier } from './types/index.js';
3
3
  export interface ETNPagedResponse<T = any> {
4
4
  data: T[];
5
5
  total: number;
@@ -16,89 +16,96 @@ interface AuthOptions {
16
16
  }
17
17
  declare const _default: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
18
18
  instance: AxiosInstance;
19
- getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account>;
20
- listAccounts: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Account>>;
21
- updateAccount: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
22
- createAccount: (data: any, options?: AxiosRequestConfig) => Promise<any>;
23
- removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<any>;
24
- getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
25
- invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
26
- getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset>;
27
- listAssets: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Asset>>;
28
- updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
29
- createAsset: (data: any, options?: AxiosRequestConfig) => Promise<any>;
30
- removeAsset: (id: string, options?: AxiosRequestConfig) => Promise<any>;
31
- getAssetSchema: (options?: AxiosRequestConfig) => Promise<any>;
32
- getAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
33
- listAssetGroups: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
34
- updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
35
- createAssetGroup: (data: any, options?: AxiosRequestConfig) => Promise<any>;
36
- removeAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
37
- getAssetGroupAssets: (id: string, options?: AxiosRequestConfig) => Promise<any>;
38
- getAssetGroupSchema: (options?: AxiosRequestConfig) => Promise<any>;
39
- getAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation>;
40
- listAutomations: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Automation>>;
41
- updateAutomation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
42
- createAutomation: (data: any, options?: AxiosRequestConfig) => Promise<any>;
43
- removeAutomation: (id: string, options?: AxiosRequestConfig) => Promise<any>;
44
- createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
45
- updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
46
- removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig) => Promise<any>;
47
- getCompany: (id: string, options?: AxiosRequestConfig) => Promise<Company>;
48
- getConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
49
- listConsumptions: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
50
- updateConsumption: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
51
- createConsumption: (data: any, options?: AxiosRequestConfig) => Promise<any>;
52
- removeConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
53
- getConsumptionSchema: (options?: AxiosRequestConfig) => Promise<any>;
54
- getEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
55
- listEmails: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
56
- updateEmail: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
57
- createEmail: (data: any, options?: AxiosRequestConfig) => Promise<any>;
58
- removeEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
59
- getEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
60
- listEmissionFactors: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
61
- updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
62
- createEmissionFactor: (data: any, options?: AxiosRequestConfig) => Promise<any>;
63
- removeEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
64
- getLog: (id: string, options?: AxiosRequestConfig) => Promise<Log>;
65
- listLogs: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Log>>;
66
- updateLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
67
- createLog: (data: any, options?: AxiosRequestConfig) => Promise<any>;
68
- removeLog: (id: string, options?: AxiosRequestConfig) => Promise<any>;
69
- getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading>;
70
- listReadings: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Reading>>;
71
- updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
72
- createReading: (data: any, options?: AxiosRequestConfig) => Promise<any>;
73
- removeReading: (id: string, options?: AxiosRequestConfig) => Promise<any>;
74
- getReadingSchema: (options?: AxiosRequestConfig) => Promise<any>;
75
- getReport: (id: string, options?: AxiosRequestConfig) => Promise<Report>;
76
- listReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Report>>;
77
- updateReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
78
- createReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
79
- removeReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
80
- sendReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
81
- getReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
82
- listReportTemplates: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
83
- updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
84
- createReportTemplate: (data: any, options?: AxiosRequestConfig) => Promise<any>;
85
- removeReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
86
- getScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
87
- listScheduledReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
88
- updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
89
- createScheduledReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
90
- removeScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
91
- sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
92
- getInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice>;
93
- listInvoices: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Invoice>>;
94
- updateInvoice: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
95
- createInvoice: (data: any, options?: AxiosRequestConfig) => Promise<any>;
96
- removeInvoice: (id: string, options?: AxiosRequestConfig) => Promise<any>;
97
- getInvoiceSchema: (options?: AxiosRequestConfig) => Promise<any>;
98
- getSupplierSchema: (options?: AxiosRequestConfig) => Promise<any>;
99
- getImportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
100
- updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
101
- createDataIngest: (data: any, options?: AxiosRequestConfig) => Promise<any>;
102
- listDataIngest: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<DataIngest>>;
19
+ getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account>;
20
+ listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Account>>;
21
+ updateAccount: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
22
+ createAccount: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
23
+ removeAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
24
+ getAccountSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
25
+ invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
26
+ getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset>;
27
+ listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Asset>>;
28
+ updateAsset: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
29
+ createAsset: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
30
+ removeAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
31
+ getAssetSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
32
+ getAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
33
+ listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
34
+ updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
35
+ createAssetGroup: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
36
+ removeAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
37
+ getAssetGroupAssets: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
38
+ getAssetGroupSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
39
+ getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation>;
40
+ listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Automation>>;
41
+ updateAutomation: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
42
+ createAutomation: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
43
+ removeAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
44
+ createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
45
+ updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
46
+ removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig<any>) => Promise<any>;
47
+ getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<Company>;
48
+ getConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
49
+ listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
50
+ updateConsumption: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
51
+ createConsumption: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
52
+ removeConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
53
+ getConsumptionSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
54
+ getEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
55
+ listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
56
+ updateEmail: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
57
+ createEmail: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
58
+ removeEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
59
+ getEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
60
+ listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
61
+ updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
62
+ createEmissionFactor: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
63
+ removeEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
64
+ getEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<Entity>;
65
+ listEntities: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Entity>>;
66
+ updateEntity: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
67
+ createEntity: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
68
+ removeEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
69
+ getEntitiesSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
70
+ getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log>;
71
+ listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Log>>;
72
+ updateLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
73
+ createLog: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
74
+ removeLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
75
+ getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading>;
76
+ listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Reading>>;
77
+ updateReading: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
78
+ createReading: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
79
+ removeReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
80
+ getReadingSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
81
+ getReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<Report>;
82
+ listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Report>>;
83
+ updateReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
84
+ createReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
85
+ removeReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
86
+ sendReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
87
+ getReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
88
+ listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
89
+ updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
90
+ createReportTemplate: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
91
+ removeReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
92
+ getScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
93
+ listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
94
+ updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
95
+ createScheduledReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
96
+ removeScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
97
+ sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
98
+ getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice>;
99
+ listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Invoice>>;
100
+ updateInvoice: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
101
+ createInvoice: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
102
+ removeInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
103
+ getInvoiceSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
104
+ listSuppliers: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Supplier>>;
105
+ getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
106
+ getImportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
107
+ updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
108
+ createDataIngest: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
109
+ listDataIngest: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<DataIngest>>;
103
110
  };
104
111
  export default _default;
package/dist/mjs/api.js CHANGED
@@ -243,6 +243,13 @@ export default (auth, instanceOptions = {}) => {
243
243
  updateEmissionFactor: factory.update(etainablApi, 'emission-factors'),
244
244
  createEmissionFactor: factory.create(etainablApi, 'emission-factors'),
245
245
  removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),
246
+ // entity
247
+ getEntity: factory.getWithId(etainablApi, 'entities'),
248
+ listEntities: factory.list(etainablApi, 'entities'),
249
+ updateEntity: factory.update(etainablApi, 'entities'),
250
+ createEntity: factory.create(etainablApi, 'entities'),
251
+ removeEntity: factory.remove(etainablApi, 'entities'),
252
+ getEntitiesSchema: factory.get(etainablApi, 'entities', 'schema'),
246
253
  // logs
247
254
  getLog: factory.getWithId(etainablApi, 'logs'),
248
255
  listLogs: factory.list(etainablApi, 'logs'),
@@ -284,6 +291,7 @@ export default (auth, instanceOptions = {}) => {
284
291
  removeInvoice: factory.remove(etainablApi, 'invoices'),
285
292
  getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),
286
293
  //suppliers
294
+ listSuppliers: factory.list(etainablApi, 'suppliers'),
287
295
  getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),
288
296
  // import templates
289
297
  getImportTemplate: factory.getWithId(etainablApi, 'import-templates'),
@@ -4,13 +4,14 @@ import type { Automation } from './automation.js';
4
4
  import type { Company } from './company.js';
5
5
  import type { CreateScraperRunParams, ScraperRun } from './scraperRun.js';
6
6
  import type { DataIngest } from './dataIngest.js';
7
+ import type { Entity } from './entity.js';
7
8
  import type { Email } from './email.js';
8
9
  import type { Invoice } from './invoice.js';
9
10
  import type { Log } from './log.js';
10
11
  import type { Reading } from './reading.js';
11
12
  import type { Report } from './report.js';
12
13
  import type { Supplier } from './supplier.js';
13
- export type { Account, Asset, Automation, Company, CreateScraperRunParams, DataIngest, Email, Invoice, Log, Reading, Report, ScraperRun, Supplier };
14
+ export type { Account, Asset, Automation, Company, CreateScraperRunParams, DataIngest, Email, Entity, Invoice, Log, Reading, Report, ScraperRun, Supplier };
14
15
  export interface ETNPagedResponse<T = any> {
15
16
  data: T[];
16
17
  total: number;
@@ -5,9 +5,9 @@ interface Item {
5
5
  value: number;
6
6
  [key: string]: any;
7
7
  }
8
- export type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';
9
- export type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';
10
- export type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';
8
+ export declare type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';
9
+ export declare type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';
10
+ export declare type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';
11
11
  export declare const accountTypeMap: {
12
12
  [key: string]: BaseUnit;
13
13
  };
@@ -15,7 +15,7 @@ export declare const accountTypeUnitMap: {
15
15
  [key: string]: ETNUnit[];
16
16
  };
17
17
  export declare const convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined) => any;
18
- export declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | "") => {
18
+ export declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | '') => {
19
19
  type: AccountType;
20
20
  unit: ETNUnit;
21
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etainabl/nodejs-sdk",
3
- "version": "1.2.32",
3
+ "version": "1.2.34",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/mjs/index.js",
6
6
  "types": "dist/mjs/index.d.ts",
package/src/api.ts CHANGED
@@ -4,7 +4,7 @@ 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, Report, Supplier } from './types/index.js'
7
+ import type { Account, Asset, Automation, Entity, Company, DataIngest, Invoice, Log, Reading, Report, Supplier } from './types/index.js'
8
8
 
9
9
  const log = logger('etainablApi');
10
10
 
@@ -306,6 +306,15 @@ export default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) =>
306
306
  updateEmissionFactor: factory.update(etainablApi, 'emission-factors'),
307
307
  createEmissionFactor: factory.create(etainablApi, 'emission-factors'),
308
308
  removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),
309
+
310
+ // entity
311
+ getEntity: factory.getWithId<Entity>(etainablApi, 'entities'),
312
+ listEntities: factory.list<Entity>(etainablApi, 'entities'),
313
+ updateEntity: factory.update(etainablApi, 'entities'),
314
+ createEntity: factory.create(etainablApi, 'entities'),
315
+ removeEntity: factory.remove(etainablApi, 'entities'),
316
+ getEntitiesSchema: factory.get(etainablApi, 'entities', 'schema'),
317
+
309
318
 
310
319
  // logs
311
320
  getLog: factory.getWithId<Log>(etainablApi, 'logs'),
@@ -354,6 +363,7 @@ export default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) =>
354
363
  getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),
355
364
 
356
365
  //suppliers
366
+ listSuppliers: factory.list<Supplier>(etainablApi, 'suppliers'),
357
367
  getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),
358
368
 
359
369
  // import templates
@@ -0,0 +1,18 @@
1
+ import { Types } from 'mongoose';
2
+ import { Address} from './address.ts';
3
+
4
+ type EntityType = 'fund' | 'company' | 'charity' | 'school/university' | 'council' | 'other';
5
+
6
+ export interface Entity {
7
+ _id?: Types.ObjectId;
8
+ legalName: string;
9
+ type: EntityType;
10
+ companyNumber?: string;
11
+ companyLogo?: string;
12
+ billingAddress: Address;
13
+ parentEntityId?: Types.ObjectId;
14
+ ultimateParentEntityId?: Types.ObjectId;
15
+ companyId: Types.ObjectId;
16
+ batchId?: string;
17
+ userSub: string;
18
+ }
@@ -4,6 +4,7 @@ import type { Automation } from './automation.js'
4
4
  import type { Company } from './company.js'
5
5
  import type { CreateScraperRunParams, ScraperRun } from './scraperRun.js';
6
6
  import type { DataIngest } from './dataIngest.js'
7
+ import type { Entity } from './entity.js'
7
8
  import type { Email } from './email.js';
8
9
  import type { Invoice } from './invoice.js';
9
10
  import type { Log } from './log.js';
@@ -19,6 +20,7 @@ export type {
19
20
  CreateScraperRunParams,
20
21
  DataIngest,
21
22
  Email,
23
+ Entity,
22
24
  Invoice,
23
25
  Log,
24
26
  Reading,