@etainabl/nodejs-sdk 1.3.2 → 1.3.8
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/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +128 -93
- package/dist/index.d.ts +128 -93
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -294,6 +294,13 @@ var api_default = (auth, instanceOptions = {}) => {
|
|
|
294
294
|
createInvoice: factory.create(etainablApi, "invoices"),
|
|
295
295
|
removeInvoice: factory.remove(etainablApi, "invoices"),
|
|
296
296
|
getInvoiceSchema: factory.get(etainablApi, "invoices", "schema"),
|
|
297
|
+
// invoice capture
|
|
298
|
+
getInvoiceCapture: factory.getWithId(etainablApi, "invoice-capture"),
|
|
299
|
+
listInvoicesCapture: factory.list(etainablApi, "invoice-capture"),
|
|
300
|
+
updateInvoiceCapture: factory.update(etainablApi, "invoice-capture"),
|
|
301
|
+
createInvoiceCapture: factory.create(etainablApi, "invoice-capture"),
|
|
302
|
+
removeInvoiceCapture: factory.remove(etainablApi, "invoice-capture"),
|
|
303
|
+
getInvoiceCaptureSchema: factory.get(etainablApi, "invoice-capture", "schema"),
|
|
297
304
|
//suppliers
|
|
298
305
|
listSuppliers: factory.list(etainablApi, "suppliers"),
|
|
299
306
|
getSupplierSchema: factory.get(etainablApi, "suppliers", "schema"),
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api.ts","../../src/logger.ts","../../src/db.ts","../../src/slack.ts","../../src/units.ts","../../src/consumption.ts","../../src/monitoring.ts","../../src/reporting.ts","../../src/types/index.ts"],"sourcesContent":["import axios from 'axios';\nimport type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults, AxiosResponse } from 'axios';\nimport https from 'https';\n\nimport logger from './logger.js';\n\nimport type { Account, Asset, Automation, Entity, Company, DataIngest, Invoice, Log, Reading, Report, Supplier } from './types/index.js'\n\nconst log = logger('etainablApi');\n\nexport interface ETNPagedResponse<T = any> {\n data: T[];\n total: number;\n limit: number;\n skip: number;\n}\n\nexport interface ETNReq {\n method: string;\n url: string;\n}\n\nfunction _handleResponse(req: ETNReq, res: AxiosResponse, isPaged = false) {\n if (!res) {\n throw new Error(`No response from API (${req.method} ${req.url})`);\n }\n\n if (res.status !== 200) {\n throw new Error(`${res.status} ${res.statusText} response from API (${req.method} ${req.url})`);\n }\n\n if (!res.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n if (isPaged && !res.data.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n return res;\n}\n\nconst factory = {\n getWithId: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAsINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n _handleResponse(req, res)\n\n return res.data;\n },\n get: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res)\n\n return res.data;\n },\n list: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}): Promise<ETNPagedResponse<T>> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n \n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res, true)\n\n return res.data;\n },\n update: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'PATCH',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n \n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.patch(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res)\n\n return res.data;\n },\n create: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'POST',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.post(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res)\n\n return res.data;\n },\n remove: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'DELETE',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n let res: AxiosResponse;\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n try {\n res = await etainablApi.delete(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n customWithId: <T = any> (etainablApi: AxiosInstance, method: string, endpoint: string, postEndpoint?: string) => async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: method,\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`,\n data,\n ...options\n };\n \n log.info(`API Request (Custom): ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.request(req);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res)\n\n return res.data;\n }\n};\n\n// ETN Sub Endpoints\n// e.g. /assets/:id/documents/:documentId\nconst subFactory = {\n // e.g. POST /assets/:id/documents\n create: <T = any> (etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) => async (id: string, data: any, options: AxiosRequestConfig = {}) => { \n const subUrl = `${id}/${subEndpoint}`;\n return factory.create<T>(etainablApi, endpoint, subUrl)(data, options);\n },\n // e.g. PATCH /assets/:id/documents/:documentId\n update: <T = any> (etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) => async (id: string, subId: string, data: any, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n \n return factory.update<T>(etainablApi, endpoint, subUrl)(id, data, options);\n },\n // e.g. DELETE /assets/:id/documents/:documentId\n remove: <T = any> (etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) => async (id: string, subId: string, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n \n return factory.remove<T>(etainablApi, endpoint, subUrl)(id, options);\n }\n}\n\ninterface AuthOptions {\n key?: string;\n token?: string;\n}\n\nexport default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) => {\n try {\n const headers: any = {};\n\n if (auth.key) {\n headers['x-key'] = auth.key;\n } else if (auth.token) {\n headers['Authorization'] = auth.token;\n } else {\n headers['x-key'] = process.env.ETAINABL_API_KEY;\n }\n \n const etainablApi = axios.create({\n baseURL: process.env.ETAINABL_API_URL,\n timeout: 300000,\n httpsAgent: new https.Agent({ keepAlive: true }),\n headers,\n ...instanceOptions\n });\n \n return {\n instance: etainablApi,\n \n // accounts\n getAccount: factory.getWithId<Account<string>>(etainablApi, 'accounts'),\n listAccounts: factory.list<Account<string>>(etainablApi, 'accounts'),\n updateAccount: factory.update<Account<string>>(etainablApi, 'accounts'),\n createAccount: factory.create<Account<string>>(etainablApi, 'accounts'),\n removeAccount: factory.remove<Account<string>>(etainablApi, 'accounts'),\n getAccountSchema: factory.get(etainablApi, 'accounts', 'schema'),\n invalidateAccountCache: factory.customWithId(etainablApi, 'put', 'accounts', 'invalidate-cache'),\n\n // assets\n getAsset: factory.getWithId<Asset<string>>(etainablApi, 'assets'),\n listAssets: factory.list<Asset<string>>(etainablApi, 'assets'),\n updateAsset: factory.update<Asset<string>>(etainablApi, 'assets'),\n createAsset: factory.create<Asset<string>>(etainablApi, 'assets'),\n removeAsset: factory.remove<Asset<string>>(etainablApi, 'assets'),\n getAssetSchema: factory.get(etainablApi, 'assets', 'schema'),\n \n // assetGroups\n getAssetGroup: factory.getWithId(etainablApi, 'asset-groups'),\n listAssetGroups: factory.list(etainablApi, 'asset-groups'),\n updateAssetGroup: factory.update(etainablApi, 'asset-groups'),\n createAssetGroup: factory.create(etainablApi, 'asset-groups'),\n removeAssetGroup: factory.remove(etainablApi, 'asset-groups'),\n getAssetGroupAssets: factory.getWithId(etainablApi, 'asset-groups', 'assets'),\n getAssetGroupSchema: factory.get(etainablApi, 'asset-groups', 'schema'),\n \n // automation\n getAutomation: factory.getWithId<Automation<string>>(etainablApi, 'automation'),\n listAutomations: factory.list<Automation<string>>(etainablApi, 'automation'),\n updateAutomation: factory.update<Automation<string>>(etainablApi, 'automation'),\n createAutomation: factory.create<Automation<string>>(etainablApi, 'automation'),\n removeAutomation: factory.remove<Automation<string>>(etainablApi, 'automation'),\n createAutomationLog: subFactory.create(etainablApi, 'automation', 'logs'),\n updateAutomationLog: subFactory.update(etainablApi, 'automation', 'logs'),\n removeAutomationLog: subFactory.remove(etainablApi, 'automation', 'logs'),\n \n // company\n getCompany: factory.getWithId<Company<string>>(etainablApi, 'companies'),\n \n // consumption\n getConsumption: factory.getWithId(etainablApi, 'consumptions'),\n listConsumptions: factory.list(etainablApi, 'consumptions'),\n updateConsumption: factory.update(etainablApi, 'consumptions'),\n createConsumption: factory.create(etainablApi, 'consumptions'),\n removeConsumption: factory.remove(etainablApi, 'consumptions'),\n getConsumptionSchema: factory.get(etainablApi, 'consumptions', 'schema'),\n \n // emails\n getEmail: factory.getWithId(etainablApi, 'emails'),\n listEmails: factory.list(etainablApi, 'emails'),\n updateEmail: factory.update(etainablApi, 'emails'),\n createEmail: factory.create(etainablApi, 'emails'),\n removeEmail: factory.remove(etainablApi, 'emails'),\n \n // emission factors\n getEmissionFactor: factory.getWithId(etainablApi, 'emission-factors'),\n listEmissionFactors: factory.list(etainablApi, 'emission-factors'),\n updateEmissionFactor: factory.update(etainablApi, 'emission-factors'),\n createEmissionFactor: factory.create(etainablApi, 'emission-factors'),\n removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),\n\n // entity\n getEntity: factory.getWithId<Entity<string>>(etainablApi, 'entities'),\n listEntities: factory.list<Entity<string>>(etainablApi, 'entities'),\n updateEntity: factory.update<Entity<string>>(etainablApi, 'entities'),\n createEntity: factory.create<Entity<string>>(etainablApi, 'entities'),\n removeEntity: factory.remove<Entity<string>>(etainablApi, 'entities'),\n getEntitiesSchema: factory.get(etainablApi, 'entities', 'schema'),\n \n \n // logs\n getLog: factory.getWithId<Log<string>>(etainablApi, 'logs'),\n listLogs: factory.list<Log<string>>(etainablApi, 'logs'),\n updateLog: factory.update<Log<string>>(etainablApi, 'logs'),\n createLog: factory.create<Log<string>>(etainablApi, 'logs'),\n removeLog: factory.remove<Log<string>>(etainablApi, 'logs'),\n \n // readings\n getReading: factory.getWithId<Reading<string>>(etainablApi, 'readings'),\n listReadings: factory.list<Reading<string>>(etainablApi, 'readings'),\n updateReading: factory.update<Reading<string>>(etainablApi, 'readings'),\n createReading: factory.create<Reading<string>>(etainablApi, 'readings'),\n removeReading: factory.remove<Reading<string>>(etainablApi, 'readings'),\n getReadingSchema: factory.get(etainablApi, 'readings', 'schema'),\n \n // reports\n getReport: factory.getWithId<Report<string>>(etainablApi, 'reports'),\n listReports: factory.list<Report<string>>(etainablApi, 'reports'),\n updateReport: factory.update<Report<string>>(etainablApi, 'reports'),\n createReport: factory.create<Report<string>>(etainablApi, 'reports'),\n removeReport: factory.remove<Report<string>>(etainablApi, 'reports'),\n sendReport: factory.customWithId(etainablApi, 'post', 'reports', 'send'),\n \n // report templates\n getReportTemplate: factory.getWithId(etainablApi, 'report-templates'),\n listReportTemplates: factory.list(etainablApi, 'report-templates'),\n updateReportTemplate: factory.update(etainablApi, 'report-templates'),\n createReportTemplate: factory.create(etainablApi, 'report-templates'),\n removeReportTemplate: factory.remove(etainablApi, 'report-templates'),\n \n // scheduled reports\n getScheduledReport: factory.getWithId(etainablApi, 'scheduled-reports'),\n listScheduledReports: factory.list(etainablApi, 'scheduled-reports'),\n updateScheduledReport: factory.update(etainablApi, 'scheduled-reports'),\n createScheduledReport: factory.create(etainablApi, 'scheduled-reports'),\n removeScheduledReport: factory.remove(etainablApi, 'scheduled-reports'),\n sendScheduledReport: factory.customWithId(etainablApi, 'post', 'scheduled-reports', 'send'),\n \n // invoices\n getInvoice: factory.getWithId<Invoice<string>>(etainablApi, 'invoices'),\n listInvoices: factory.list<Invoice<string>>(etainablApi, 'invoices'),\n updateInvoice: factory.update<Invoice<string>>(etainablApi, 'invoices'),\n createInvoice: factory.create<Invoice<string>>(etainablApi, 'invoices'),\n removeInvoice: factory.remove<Invoice<string>>(etainablApi, 'invoices'),\n getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),\n\n //suppliers\n listSuppliers: factory.list<Supplier<string>>(etainablApi, 'suppliers'),\n getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),\n\n // import templates\n getImportTemplate: factory.getWithId(etainablApi, 'import-templates'),\n\n //data imports\n listDataIngest: factory.list<DataIngest<string>>(etainablApi, 'data-ingests'),\n updateDataIngest: factory.update<DataIngest<string>>(etainablApi, 'data-ingests'),\n createDataIngest: factory.create<DataIngest<string>>(etainablApi, 'data-ingests')\n\n }\n } catch (e) {\n log.error(e);\n throw e;\n }\n};\n","import winston from 'winston';\n\nexport default (namespace: string) => winston.createLogger({\n level: 'debug',\n format: winston.format.combine(\n winston.format.timestamp(),\n winston.format.json()\n ),\n defaultMeta: { service: process.env.AWS_LAMBDA_FUNCTION_NAME, script: namespace },\n transports: [\n new winston.transports.Console()\n ]\n});\n","import { MongoClient, Db } from 'mongodb';\nimport logger from './logger.js';\n\nconst log = logger('dbHelpers');\n\nlet cachedDb: Db;\n\nasync function connectToDatabase(retryAttempt: number = 1): Promise<Db> {\n if (!process.env.ETAINABL_DB_URL) throw new Error(\"ETAINABL_DB_URL is not set\");\n if (!process.env.AWS_ACCESS_KEY_ID) throw new Error(\"AWS_ACCESS_KEY_ID is not set\");\n if (!process.env.AWS_SECRET_ACCESS_KEY) throw new Error(\"AWS_SECRET_ACCESS_KEY is not set\");\n\n if (cachedDb) {\n log.debug('Using cached MongoDB connection.');\n return Promise.resolve(cachedDb);\n }\n \n const uri = `mongodb+srv://${process.env.ETAINABL_DB_URL}`;\n \n try {\n if (process.env.DB_BASIC_AUTH === 'true') {\n log.debug('Connecting to MongoDB server... (Auth: Basic)');\n\n const client = new MongoClient(uri);\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: Basic)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n }\n\n log.debug('Connecting to MongoDB server... (Auth: AWS)');\n\n const client = new MongoClient(uri, {\n auth: {\n username: process.env.AWS_ACCESS_KEY_ID,\n password: process.env.AWS_SECRET_ACCESS_KEY\n },\n authSource: '$external',\n authMechanism: 'MONGODB-AWS'\n });\n\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: AWS)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n\n } catch (e: any) {\n // Retry\n if (retryAttempt > 5) {\n console.log(`Error connecting to MongoDB server after 5 attempts...`);\n throw e;\n }\n\n console.log(`MongoDB Connection error: ${e.message}`);\n\n console.log(`Error connecting to MongoDB server... Retrying in 3 seconds... (Attempt ${retryAttempt})`);\n return connectToDatabase(retryAttempt + 1);\n }\n}\n\nexport default {\n connectToDatabase\n};","import axios from 'axios';\n\nconst postMessage = async (message: string) => {\n const url = 'https://hooks.slack.com/services/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';\n const data = {\n text: `[${(process.env.ENV || '').toUpperCase()}][${process.env.AWS_LAMBDA_FUNCTION_NAME}] ${message}`\n };\n const headers = {\n 'Content-Type': 'application/json'\n };\n return axios.post(url, data, { headers });\n};\n\nexport default {\n postMessage\n}","interface Item {\n units?: string | null;\n unit?: string | null;\n factor?: number | null;\n value: number;\n [key: string]: any; \n}\n\nexport type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';\nexport type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';\nexport type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';\nexport const accountTypeMap: { [key: string]: BaseUnit } = {\n electricity: 'kwh',\n gas: 'kwh',\n water: 'm3',\n waste: 'kg',\n solar: 'kwh',\n heating: 'kwh',\n flow: 'm3/h',\n cooling: 'kwh',\n temperature: 'C',\n oil: 'l'\n};\n\nconst unitConversionFactors: { [key: string]: any } = {\n kwh: {\n kwh: 1,\n mwh: 1000,\n wh: 0.001,\n m3: (39 * 1.02264) / 3.6,\n ft3: (0.0283 * 39 * 1.02264) / 3.6,\n hcf: (2.83 * 39 * 1.02264) / 3.6\n },\n m3: {\n m3: 1,\n l: 0.001\n },\n C: {\n C: 1\n },\n kg: {\n kg: 1,\n lbs: 0.45359237,\n tonnes: 1000\n },\n 'm3/h': {\n 'm3/h': 1\n }\n};\n\nexport const accountTypeUnitMap: { [key: string]: ETNUnit[] } = {\n electricity: ['kwh', 'mwh', 'wh'],\n gas: ['kwh', 'm3', 'ft3', 'hcf'],\n water: ['m3', 'l'],\n waste: ['kg', 'lbs', 'tonnes'],\n solar: ['kwh', 'mwh', 'wh'],\n heating: ['kwh', 'mwh', 'wh'],\n flow: ['m3/h'],\n cooling: ['kwh', 'mwh', 'wh'],\n temperature: ['C'],\n oil: ['l']\n};\n\n// Convert units to base format\nexport const convertItems = (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined): any => {\n if (!type) throw new Error('Account type is required');\n\n const baseUnit = accountTypeMap[type];\n if (!baseUnit) throw new Error(`Account type ${type} is not supported`);\n\n const convertedItems = items.map(item => {\n const factor = item.factor || accountFactor || 1;\n const units = item.units || item.unit || defaultUnits || baseUnit;\n const convertedValue = item.value * _getConversionFactor(units, baseUnit) * factor;\n return { ...item, value: convertedValue, units: baseUnit };\n });\n\n return convertedItems;\n};\n\nconst _getConversionFactor = (fromUnit: string = 'kwh', toUnit: string) => {\n const conversionFactors = unitConversionFactors[toUnit];\n\n if (!conversionFactors) {\n throw new Error(`Conversion factor base unit ${toUnit} is not defined`);\n }\n\n if (!conversionFactors[fromUnit]) {\n throw new Error(`Conversion factor from unit ${fromUnit} is not defined`);\n }\n\n return conversionFactors[fromUnit];\n};\n\nexport const checkAccountTypeVsUnits = (type: string, unit: string, additionalLog: number | '' = '') => {\n if (!type) throw new Error('Account type is required');\n if (!unit) throw new Error('Unit is required');\n\n const parsedType = type.toLowerCase().trim();\n\n const accountTypeUnits = accountTypeUnitMap[parsedType];\n if (!accountTypeUnits) throw new Error(`Account type \"${parsedType}\" is not supported ${additionalLog}`);\n\n const parsedUnit = unit.toLowerCase().trim() as ETNUnit;\n\n if (!accountTypeUnits.includes(parsedUnit)) {\n throw new Error(`Account type \"${parsedType}\" does not support unit \"${parsedUnit}\" ${additionalLog}`);\n }\n\n return { type: parsedType as AccountType, unit: parsedUnit};\n};\n","import moment from 'moment';\n\ninterface ConsumptionData {\n date: Date;\n consumption: number;\n}\n\ninterface DayNightConsumption {\n dayConsumption: number,\n nightConsumption: number,\n consumption: number\n}\n\nexport const dayNightConsumption = (data: ConsumptionData[]) => data.reduce((acc: DayNightConsumption, item: ConsumptionData): DayNightConsumption => {\n const hour = moment.utc(item.date).hour(); // End Time of HH consumption period\n\n if (hour >= 0 && hour < 7) {\n acc.nightConsumption += item.consumption;\n } else {\n acc.dayConsumption += item.consumption;\n }\n\n acc.consumption += item.consumption;\n\n return acc;\n}, {\n dayConsumption: 0,\n nightConsumption: 0,\n consumption: 0\n});\n\nexport const calcMaxConsumptionValue = (data: ConsumptionData[]) => Math.max(...data.map((item: ConsumptionData) => item.consumption));\n\nexport const calcMaxDemand = (data: ConsumptionData[]) => calcMaxConsumptionValue(data) * 2;\n\nexport const calcPeakLoad = (consumption: number, maxDemand: number, startDate: string | moment.Moment, endDate: string | moment.Moment) => {\n const days = Math.ceil(moment(endDate).diff(moment(startDate), 'days', true));\n\n return maxDemand === 0 ? 0 : ((consumption / (maxDemand * 24 * days)) * 100);\n};","import axios from 'axios';\n\nimport logger from './logger.js';\n\nconst log = logger('monitoring');\n\nexport const sendHeartbeat = async () => {\n if (!process.env.HEARTBEAT_URL || process.env.HEARTBEAT_URL.endsWith('/')) return false;\n\n try {\n await axios.post(process.env.HEARTBEAT_URL);\n\n return true;\n } catch (e: any) {\n log.warn(`Failed to send heartbeat: ${e.message || e}`);\n return false;\n }\n}","import moment from 'moment';\n\nmoment.locale('en', {\n week: {\n dow: 1\n }\n});\n\nconst getNextRunTime = (startDate: moment.Moment, schedule: any, taskTime: moment.Moment): moment.Moment => {\n const [num, freq] = schedule.frequency.split('|');\n const targetDate = moment(startDate).add(num, freq as moment.unitOfTime.Base);\n\n if (schedule.frequencyPeriod === 'first') {\n targetDate.startOf(freq as moment.unitOfTime.StartOf);\n } else if (schedule.frequencyPeriod === 'last') {\n targetDate.endOf(freq as moment.unitOfTime.StartOf);\n }\n\n const isWeekday = targetDate.isoWeekday() > 0 && targetDate.isoWeekday() < 6;\n const isSaturday = targetDate.isoWeekday() === 6;\n\n // The weekday or weekend chosen should be within the same month as the target date\n if (schedule.frequencyDay === 'weekdays' && !isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.add(isSaturday ? 2 : 1, 'days');\n } else {\n targetDate.subtract(isSaturday ? 1 : 2, 'days');\n }\n } else if (schedule.frequencyDay === 'weekends' && isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.isoWeekday(6);\n } else {\n targetDate.isoWeekday(0);\n }\n }\n\n if (taskTime.isAfter(targetDate, 'minute')) {\n return getNextRunTime(targetDate, schedule, taskTime);\n }\n\n return targetDate;\n};\n\nexport const getScheduledReportRunTimes = (schedule: any, limit = 1, taskTime = moment()): moment.Moment[] => {\n if (!schedule.startDate || !schedule.enabled) return [];\n\n const originalStartDate = moment.utc(schedule.startDate);\n\n let startDate = originalStartDate;\n\n const includeStartDate = taskTime.isSameOrBefore(originalStartDate, 'minute');\n\n let runTimes = [] as moment.Moment[];\n\n if (includeStartDate) {\n runTimes = [originalStartDate];\n }\n\n const [, freq] = schedule.frequency.split('|');\n\n if (freq === 'once') {\n const nextRunTime = runTimes[0];\n\n // If this is now beyond the start date, return an empty array\n return taskTime.isAfter(nextRunTime, 'minute') ? [] : runTimes;\n }\n\n\n const scheduleRunTimes = Array.from(Array(includeStartDate ? limit - 1 : limit).keys()).map(() => {\n const nextRunTime = getNextRunTime(startDate, schedule, taskTime);\n\n startDate = nextRunTime.hour(originalStartDate.hour()).minute(originalStartDate.minute());\n\n return nextRunTime;\n });\n\n return [...runTimes, ...scheduleRunTimes];\n};\n","import { ObjectId } from 'mongodb';\n\ntype Primitive = string | number | boolean | null | undefined | symbol | bigint | Date | ObjectId; // Add ObjectId/Date here\n\nexport * from './account.js'\nexport * from './asset.js'\nexport * from './automation.js'\nexport * from './company.js'\nexport * from './scraperRun.js';\nexport * from './dataIngest.js'\nexport * from './entity.js'\nexport * from './email.js';\nexport * from './invoice.js';\nexport * from './log.js';\nexport * from './reading.js'\nexport * from './report.js'\nexport * from './supplier.js'\nexport * from './global.js'\nexport { ObjectId }\n\nexport interface ETNPagedResponse<T = any> {\n data: T[];\n total: number;\n limit: number;\n skip: number;\n}"],"mappings":";;;;;;;AAAA,OAAO,WAAW;AAElB,OAAO,WAAW;;;ACFlB,OAAO,aAAa;AAEpB,IAAO,iBAAQ,CAAC,cAAsB,QAAQ,aAAa;AAAA,EACzD,OAAO;AAAA,EACP,QAAQ,QAAQ,OAAO;AAAA,IACrB,QAAQ,OAAO,UAAU;AAAA,IACzB,QAAQ,OAAO,KAAK;AAAA,EACtB;AAAA,EACA,aAAa,EAAE,SAAS,QAAQ,IAAI,0BAA0B,QAAQ,UAAU;AAAA,EAChF,YAAY;AAAA,IACV,IAAI,QAAQ,WAAW,QAAQ;AAAA,EACjC;AACF,CAAC;;;ADJD,IAAM,MAAM,eAAO,aAAa;AAchC,SAAS,gBAAgB,KAAa,KAAoB,UAAU,OAAO;AACzE,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,mBAAmB,MAAM,KAAK,MAAM,mBAAmB,QAAQ,IAAI,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,MAAM;AAChG,UAAM,cAAc,eAAe,WAAW,UAAU,QAAQ;AAEhE,gBAAY,YAAY,KAAK,kBAAkB,KAAK,CAAC,EAAE,OAAO,kBAAkB,OAAO,CAAC;AAExF,WAAO;AAAA,EACT,CAAC;AAED,SAAO,CAAC,GAAG,UAAU,GAAG,gBAAgB;AAC1C;;;AC7EA,SAAS,gBAAgB;","names":["log","client","axios","axios","log","axios","moment"]}
|
|
1
|
+
{"version":3,"sources":["../../src/api.ts","../../src/logger.ts","../../src/db.ts","../../src/slack.ts","../../src/units.ts","../../src/consumption.ts","../../src/monitoring.ts","../../src/reporting.ts","../../src/types/index.ts"],"sourcesContent":["import axios from 'axios';\nimport type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults, AxiosResponse } from 'axios';\nimport https from 'https';\n\nimport logger from './logger.js';\n\nimport type {\n Account,\n Asset,\n Automation,\n Entity,\n Company,\n DataIngest,\n Invoice,\n InvoiceCapture,\n Log,\n Reading,\n Report,\n Supplier\n} from './types/index.js';\n\nconst log = logger('etainablApi');\n\nexport interface ETNPagedResponse<T = any> {\n data: T[];\n total: number;\n limit: number;\n skip: number;\n}\n\nexport interface ETNReq {\n method: string;\n url: string;\n}\n\nfunction _handleResponse(req: ETNReq, res: AxiosResponse, isPaged = false) {\n if (!res) {\n throw new Error(`No response from API (${req.method} ${req.url})`);\n }\n\n if (res.status !== 200) {\n throw new Error(`${res.status} ${res.statusText} response from API (${req.method} ${req.url})`);\n }\n\n if (!res.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n if (isPaged && !res.data.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n return res;\n}\n\nconst factory = {\n getWithId:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAsINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n _handleResponse(req, res);\n\n return res.data;\n },\n get:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res);\n\n return res.data;\n },\n list:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (options: AxiosRequestConfig = {}): Promise<ETNPagedResponse<T>> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res, true);\n\n return res.data;\n },\n update:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'PATCH',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.patch(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n create:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'POST',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.post(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n remove:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'DELETE',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n let res: AxiosResponse;\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n try {\n res = await etainablApi.delete(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n customWithId:\n <T = any>(etainablApi: AxiosInstance, method: string, endpoint: string, postEndpoint?: string) =>\n async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: method,\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`,\n data,\n ...options\n };\n\n log.info(`API Request (Custom): ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.request(req);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n }\n};\n\n// ETN Sub Endpoints\n// e.g. /assets/:id/documents/:documentId\nconst subFactory = {\n // e.g. POST /assets/:id/documents\n create:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) =>\n async (id: string, data: any, options: AxiosRequestConfig = {}) => {\n const subUrl = `${id}/${subEndpoint}`;\n return factory.create<T>(etainablApi, endpoint, subUrl)(data, options);\n },\n // e.g. PATCH /assets/:id/documents/:documentId\n update:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) =>\n async (id: string, subId: string, data: any, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n\n return factory.update<T>(etainablApi, endpoint, subUrl)(id, data, options);\n },\n // e.g. DELETE /assets/:id/documents/:documentId\n remove:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) =>\n async (id: string, subId: string, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n\n return factory.remove<T>(etainablApi, endpoint, subUrl)(id, options);\n }\n};\n\ninterface AuthOptions {\n key?: string;\n token?: string;\n}\n\nexport default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) => {\n try {\n const headers: any = {};\n\n if (auth.key) {\n headers['x-key'] = auth.key;\n } else if (auth.token) {\n headers['Authorization'] = auth.token;\n } else {\n headers['x-key'] = process.env.ETAINABL_API_KEY;\n }\n\n const etainablApi = axios.create({\n baseURL: process.env.ETAINABL_API_URL,\n timeout: 300000,\n httpsAgent: new https.Agent({ keepAlive: true }),\n headers,\n ...instanceOptions\n });\n\n return {\n instance: etainablApi,\n\n // accounts\n getAccount: factory.getWithId<Account<string>>(etainablApi, 'accounts'),\n listAccounts: factory.list<Account<string>>(etainablApi, 'accounts'),\n updateAccount: factory.update<Account<string>>(etainablApi, 'accounts'),\n createAccount: factory.create<Account<string>>(etainablApi, 'accounts'),\n removeAccount: factory.remove<Account<string>>(etainablApi, 'accounts'),\n getAccountSchema: factory.get(etainablApi, 'accounts', 'schema'),\n invalidateAccountCache: factory.customWithId(etainablApi, 'put', 'accounts', 'invalidate-cache'),\n\n // assets\n getAsset: factory.getWithId<Asset<string>>(etainablApi, 'assets'),\n listAssets: factory.list<Asset<string>>(etainablApi, 'assets'),\n updateAsset: factory.update<Asset<string>>(etainablApi, 'assets'),\n createAsset: factory.create<Asset<string>>(etainablApi, 'assets'),\n removeAsset: factory.remove<Asset<string>>(etainablApi, 'assets'),\n getAssetSchema: factory.get(etainablApi, 'assets', 'schema'),\n\n // assetGroups\n getAssetGroup: factory.getWithId(etainablApi, 'asset-groups'),\n listAssetGroups: factory.list(etainablApi, 'asset-groups'),\n updateAssetGroup: factory.update(etainablApi, 'asset-groups'),\n createAssetGroup: factory.create(etainablApi, 'asset-groups'),\n removeAssetGroup: factory.remove(etainablApi, 'asset-groups'),\n getAssetGroupAssets: factory.getWithId(etainablApi, 'asset-groups', 'assets'),\n getAssetGroupSchema: factory.get(etainablApi, 'asset-groups', 'schema'),\n\n // automation\n getAutomation: factory.getWithId<Automation<string>>(etainablApi, 'automation'),\n listAutomations: factory.list<Automation<string>>(etainablApi, 'automation'),\n updateAutomation: factory.update<Automation<string>>(etainablApi, 'automation'),\n createAutomation: factory.create<Automation<string>>(etainablApi, 'automation'),\n removeAutomation: factory.remove<Automation<string>>(etainablApi, 'automation'),\n createAutomationLog: subFactory.create(etainablApi, 'automation', 'logs'),\n updateAutomationLog: subFactory.update(etainablApi, 'automation', 'logs'),\n removeAutomationLog: subFactory.remove(etainablApi, 'automation', 'logs'),\n\n // company\n getCompany: factory.getWithId<Company<string>>(etainablApi, 'companies'),\n\n // consumption\n getConsumption: factory.getWithId(etainablApi, 'consumptions'),\n listConsumptions: factory.list(etainablApi, 'consumptions'),\n updateConsumption: factory.update(etainablApi, 'consumptions'),\n createConsumption: factory.create(etainablApi, 'consumptions'),\n removeConsumption: factory.remove(etainablApi, 'consumptions'),\n getConsumptionSchema: factory.get(etainablApi, 'consumptions', 'schema'),\n\n // emails\n getEmail: factory.getWithId(etainablApi, 'emails'),\n listEmails: factory.list(etainablApi, 'emails'),\n updateEmail: factory.update(etainablApi, 'emails'),\n createEmail: factory.create(etainablApi, 'emails'),\n removeEmail: factory.remove(etainablApi, 'emails'),\n\n // emission factors\n getEmissionFactor: factory.getWithId(etainablApi, 'emission-factors'),\n listEmissionFactors: factory.list(etainablApi, 'emission-factors'),\n updateEmissionFactor: factory.update(etainablApi, 'emission-factors'),\n createEmissionFactor: factory.create(etainablApi, 'emission-factors'),\n removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),\n\n // entity\n getEntity: factory.getWithId<Entity<string>>(etainablApi, 'entities'),\n listEntities: factory.list<Entity<string>>(etainablApi, 'entities'),\n updateEntity: factory.update<Entity<string>>(etainablApi, 'entities'),\n createEntity: factory.create<Entity<string>>(etainablApi, 'entities'),\n removeEntity: factory.remove<Entity<string>>(etainablApi, 'entities'),\n getEntitiesSchema: factory.get(etainablApi, 'entities', 'schema'),\n\n // logs\n getLog: factory.getWithId<Log<string>>(etainablApi, 'logs'),\n listLogs: factory.list<Log<string>>(etainablApi, 'logs'),\n updateLog: factory.update<Log<string>>(etainablApi, 'logs'),\n createLog: factory.create<Log<string>>(etainablApi, 'logs'),\n removeLog: factory.remove<Log<string>>(etainablApi, 'logs'),\n\n // readings\n getReading: factory.getWithId<Reading<string>>(etainablApi, 'readings'),\n listReadings: factory.list<Reading<string>>(etainablApi, 'readings'),\n updateReading: factory.update<Reading<string>>(etainablApi, 'readings'),\n createReading: factory.create<Reading<string>>(etainablApi, 'readings'),\n removeReading: factory.remove<Reading<string>>(etainablApi, 'readings'),\n getReadingSchema: factory.get(etainablApi, 'readings', 'schema'),\n\n // reports\n getReport: factory.getWithId<Report<string>>(etainablApi, 'reports'),\n listReports: factory.list<Report<string>>(etainablApi, 'reports'),\n updateReport: factory.update<Report<string>>(etainablApi, 'reports'),\n createReport: factory.create<Report<string>>(etainablApi, 'reports'),\n removeReport: factory.remove<Report<string>>(etainablApi, 'reports'),\n sendReport: factory.customWithId(etainablApi, 'post', 'reports', 'send'),\n\n // report templates\n getReportTemplate: factory.getWithId(etainablApi, 'report-templates'),\n listReportTemplates: factory.list(etainablApi, 'report-templates'),\n updateReportTemplate: factory.update(etainablApi, 'report-templates'),\n createReportTemplate: factory.create(etainablApi, 'report-templates'),\n removeReportTemplate: factory.remove(etainablApi, 'report-templates'),\n\n // scheduled reports\n getScheduledReport: factory.getWithId(etainablApi, 'scheduled-reports'),\n listScheduledReports: factory.list(etainablApi, 'scheduled-reports'),\n updateScheduledReport: factory.update(etainablApi, 'scheduled-reports'),\n createScheduledReport: factory.create(etainablApi, 'scheduled-reports'),\n removeScheduledReport: factory.remove(etainablApi, 'scheduled-reports'),\n sendScheduledReport: factory.customWithId(etainablApi, 'post', 'scheduled-reports', 'send'),\n\n // invoices\n getInvoice: factory.getWithId<Invoice<string>>(etainablApi, 'invoices'),\n listInvoices: factory.list<Invoice<string>>(etainablApi, 'invoices'),\n updateInvoice: factory.update<Invoice<string>>(etainablApi, 'invoices'),\n createInvoice: factory.create<Invoice<string>>(etainablApi, 'invoices'),\n removeInvoice: factory.remove<Invoice<string>>(etainablApi, 'invoices'),\n getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),\n\n // invoice capture\n getInvoiceCapture: factory.getWithId<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n listInvoicesCapture: factory.list<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n updateInvoiceCapture: factory.update<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n createInvoiceCapture: factory.create<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n removeInvoiceCapture: factory.remove<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n getInvoiceCaptureSchema: factory.get(etainablApi, 'invoice-capture', 'schema'),\n\n //suppliers\n listSuppliers: factory.list<Supplier<string>>(etainablApi, 'suppliers'),\n getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),\n\n // import templates\n getImportTemplate: factory.getWithId(etainablApi, 'import-templates'),\n\n //data imports\n listDataIngest: factory.list<DataIngest<string>>(etainablApi, 'data-ingests'),\n updateDataIngest: factory.update<DataIngest<string>>(etainablApi, 'data-ingests'),\n createDataIngest: factory.create<DataIngest<string>>(etainablApi, 'data-ingests')\n };\n } catch (e) {\n log.error(e);\n throw e;\n }\n};\n","import winston from 'winston';\n\nexport default (namespace: string) => winston.createLogger({\n level: 'debug',\n format: winston.format.combine(\n winston.format.timestamp(),\n winston.format.json()\n ),\n defaultMeta: { service: process.env.AWS_LAMBDA_FUNCTION_NAME, script: namespace },\n transports: [\n new winston.transports.Console()\n ]\n});\n","import { MongoClient, Db } from 'mongodb';\nimport logger from './logger.js';\n\nconst log = logger('dbHelpers');\n\nlet cachedDb: Db;\n\nasync function connectToDatabase(retryAttempt: number = 1): Promise<Db> {\n if (!process.env.ETAINABL_DB_URL) throw new Error(\"ETAINABL_DB_URL is not set\");\n if (!process.env.AWS_ACCESS_KEY_ID) throw new Error(\"AWS_ACCESS_KEY_ID is not set\");\n if (!process.env.AWS_SECRET_ACCESS_KEY) throw new Error(\"AWS_SECRET_ACCESS_KEY is not set\");\n\n if (cachedDb) {\n log.debug('Using cached MongoDB connection.');\n return Promise.resolve(cachedDb);\n }\n \n const uri = `mongodb+srv://${process.env.ETAINABL_DB_URL}`;\n \n try {\n if (process.env.DB_BASIC_AUTH === 'true') {\n log.debug('Connecting to MongoDB server... (Auth: Basic)');\n\n const client = new MongoClient(uri);\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: Basic)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n }\n\n log.debug('Connecting to MongoDB server... (Auth: AWS)');\n\n const client = new MongoClient(uri, {\n auth: {\n username: process.env.AWS_ACCESS_KEY_ID,\n password: process.env.AWS_SECRET_ACCESS_KEY\n },\n authSource: '$external',\n authMechanism: 'MONGODB-AWS'\n });\n\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: AWS)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n\n } catch (e: any) {\n // Retry\n if (retryAttempt > 5) {\n console.log(`Error connecting to MongoDB server after 5 attempts...`);\n throw e;\n }\n\n console.log(`MongoDB Connection error: ${e.message}`);\n\n console.log(`Error connecting to MongoDB server... Retrying in 3 seconds... (Attempt ${retryAttempt})`);\n return connectToDatabase(retryAttempt + 1);\n }\n}\n\nexport default {\n connectToDatabase\n};","import axios from 'axios';\n\nconst postMessage = async (message: string) => {\n const url = 'https://hooks.slack.com/services/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';\n const data = {\n text: `[${(process.env.ENV || '').toUpperCase()}][${process.env.AWS_LAMBDA_FUNCTION_NAME}] ${message}`\n };\n const headers = {\n 'Content-Type': 'application/json'\n };\n return axios.post(url, data, { headers });\n};\n\nexport default {\n postMessage\n}","interface Item {\n units?: string | null;\n unit?: string | null;\n factor?: number | null;\n value: number;\n [key: string]: any; \n}\n\nexport type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';\nexport type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';\nexport type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';\nexport const accountTypeMap: { [key: string]: BaseUnit } = {\n electricity: 'kwh',\n gas: 'kwh',\n water: 'm3',\n waste: 'kg',\n solar: 'kwh',\n heating: 'kwh',\n flow: 'm3/h',\n cooling: 'kwh',\n temperature: 'C',\n oil: 'l'\n};\n\nconst unitConversionFactors: { [key: string]: any } = {\n kwh: {\n kwh: 1,\n mwh: 1000,\n wh: 0.001,\n m3: (39 * 1.02264) / 3.6,\n ft3: (0.0283 * 39 * 1.02264) / 3.6,\n hcf: (2.83 * 39 * 1.02264) / 3.6\n },\n m3: {\n m3: 1,\n l: 0.001\n },\n C: {\n C: 1\n },\n kg: {\n kg: 1,\n lbs: 0.45359237,\n tonnes: 1000\n },\n 'm3/h': {\n 'm3/h': 1\n }\n};\n\nexport const accountTypeUnitMap: { [key: string]: ETNUnit[] } = {\n electricity: ['kwh', 'mwh', 'wh'],\n gas: ['kwh', 'm3', 'ft3', 'hcf'],\n water: ['m3', 'l'],\n waste: ['kg', 'lbs', 'tonnes'],\n solar: ['kwh', 'mwh', 'wh'],\n heating: ['kwh', 'mwh', 'wh'],\n flow: ['m3/h'],\n cooling: ['kwh', 'mwh', 'wh'],\n temperature: ['C'],\n oil: ['l']\n};\n\n// Convert units to base format\nexport const convertItems = (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined): any => {\n if (!type) throw new Error('Account type is required');\n\n const baseUnit = accountTypeMap[type];\n if (!baseUnit) throw new Error(`Account type ${type} is not supported`);\n\n const convertedItems = items.map(item => {\n const factor = item.factor || accountFactor || 1;\n const units = item.units || item.unit || defaultUnits || baseUnit;\n const convertedValue = item.value * _getConversionFactor(units, baseUnit) * factor;\n return { ...item, value: convertedValue, units: baseUnit };\n });\n\n return convertedItems;\n};\n\nconst _getConversionFactor = (fromUnit: string = 'kwh', toUnit: string) => {\n const conversionFactors = unitConversionFactors[toUnit];\n\n if (!conversionFactors) {\n throw new Error(`Conversion factor base unit ${toUnit} is not defined`);\n }\n\n if (!conversionFactors[fromUnit]) {\n throw new Error(`Conversion factor from unit ${fromUnit} is not defined`);\n }\n\n return conversionFactors[fromUnit];\n};\n\nexport const checkAccountTypeVsUnits = (type: string, unit: string, additionalLog: number | '' = '') => {\n if (!type) throw new Error('Account type is required');\n if (!unit) throw new Error('Unit is required');\n\n const parsedType = type.toLowerCase().trim();\n\n const accountTypeUnits = accountTypeUnitMap[parsedType];\n if (!accountTypeUnits) throw new Error(`Account type \"${parsedType}\" is not supported ${additionalLog}`);\n\n const parsedUnit = unit.toLowerCase().trim() as ETNUnit;\n\n if (!accountTypeUnits.includes(parsedUnit)) {\n throw new Error(`Account type \"${parsedType}\" does not support unit \"${parsedUnit}\" ${additionalLog}`);\n }\n\n return { type: parsedType as AccountType, unit: parsedUnit};\n};\n","import moment from 'moment';\n\ninterface ConsumptionData {\n date: Date;\n consumption: number;\n}\n\ninterface DayNightConsumption {\n dayConsumption: number,\n nightConsumption: number,\n consumption: number\n}\n\nexport const dayNightConsumption = (data: ConsumptionData[]) => data.reduce((acc: DayNightConsumption, item: ConsumptionData): DayNightConsumption => {\n const hour = moment.utc(item.date).hour(); // End Time of HH consumption period\n\n if (hour >= 0 && hour < 7) {\n acc.nightConsumption += item.consumption;\n } else {\n acc.dayConsumption += item.consumption;\n }\n\n acc.consumption += item.consumption;\n\n return acc;\n}, {\n dayConsumption: 0,\n nightConsumption: 0,\n consumption: 0\n});\n\nexport const calcMaxConsumptionValue = (data: ConsumptionData[]) => Math.max(...data.map((item: ConsumptionData) => item.consumption));\n\nexport const calcMaxDemand = (data: ConsumptionData[]) => calcMaxConsumptionValue(data) * 2;\n\nexport const calcPeakLoad = (consumption: number, maxDemand: number, startDate: string | moment.Moment, endDate: string | moment.Moment) => {\n const days = Math.ceil(moment(endDate).diff(moment(startDate), 'days', true));\n\n return maxDemand === 0 ? 0 : ((consumption / (maxDemand * 24 * days)) * 100);\n};","import axios from 'axios';\n\nimport logger from './logger.js';\n\nconst log = logger('monitoring');\n\nexport const sendHeartbeat = async () => {\n if (!process.env.HEARTBEAT_URL || process.env.HEARTBEAT_URL.endsWith('/')) return false;\n\n try {\n await axios.post(process.env.HEARTBEAT_URL);\n\n return true;\n } catch (e: any) {\n log.warn(`Failed to send heartbeat: ${e.message || e}`);\n return false;\n }\n}","import moment from 'moment';\n\nmoment.locale('en', {\n week: {\n dow: 1\n }\n});\n\nconst getNextRunTime = (startDate: moment.Moment, schedule: any, taskTime: moment.Moment): moment.Moment => {\n const [num, freq] = schedule.frequency.split('|');\n const targetDate = moment(startDate).add(num, freq as moment.unitOfTime.Base);\n\n if (schedule.frequencyPeriod === 'first') {\n targetDate.startOf(freq as moment.unitOfTime.StartOf);\n } else if (schedule.frequencyPeriod === 'last') {\n targetDate.endOf(freq as moment.unitOfTime.StartOf);\n }\n\n const isWeekday = targetDate.isoWeekday() > 0 && targetDate.isoWeekday() < 6;\n const isSaturday = targetDate.isoWeekday() === 6;\n\n // The weekday or weekend chosen should be within the same month as the target date\n if (schedule.frequencyDay === 'weekdays' && !isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.add(isSaturday ? 2 : 1, 'days');\n } else {\n targetDate.subtract(isSaturday ? 1 : 2, 'days');\n }\n } else if (schedule.frequencyDay === 'weekends' && isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.isoWeekday(6);\n } else {\n targetDate.isoWeekday(0);\n }\n }\n\n if (taskTime.isAfter(targetDate, 'minute')) {\n return getNextRunTime(targetDate, schedule, taskTime);\n }\n\n return targetDate;\n};\n\nexport const getScheduledReportRunTimes = (schedule: any, limit = 1, taskTime = moment()): moment.Moment[] => {\n if (!schedule.startDate || !schedule.enabled) return [];\n\n const originalStartDate = moment.utc(schedule.startDate);\n\n let startDate = originalStartDate;\n\n const includeStartDate = taskTime.isSameOrBefore(originalStartDate, 'minute');\n\n let runTimes = [] as moment.Moment[];\n\n if (includeStartDate) {\n runTimes = [originalStartDate];\n }\n\n const [, freq] = schedule.frequency.split('|');\n\n if (freq === 'once') {\n const nextRunTime = runTimes[0];\n\n // If this is now beyond the start date, return an empty array\n return taskTime.isAfter(nextRunTime, 'minute') ? [] : runTimes;\n }\n\n\n const scheduleRunTimes = Array.from(Array(includeStartDate ? limit - 1 : limit).keys()).map(() => {\n const nextRunTime = getNextRunTime(startDate, schedule, taskTime);\n\n startDate = nextRunTime.hour(originalStartDate.hour()).minute(originalStartDate.minute());\n\n return nextRunTime;\n });\n\n return [...runTimes, ...scheduleRunTimes];\n};\n","import { ObjectId } from 'mongodb';\n\nexport * from './account.js';\nexport * from './asset.js';\nexport * from './automation.js';\nexport * from './company.js';\nexport * from './scraperRun.js';\nexport * from './dataIngest.js';\nexport * from './entity.js';\nexport * from './email.js';\nexport * from './global.js';\nexport * from './invoice.js';\nexport * from './invoiceCapture.js';\nexport * from './log.js';\nexport * from './reading.js';\nexport * from './report.js';\nexport * from './supplier.js';\nexport { ObjectId };\n\nexport interface ETNPagedResponse<T = any> {\n data: T[];\n total: number;\n limit: number;\n skip: number;\n}\n"],"mappings":";;;;;;;AAAA,OAAO,WAAW;AAElB,OAAO,WAAW;;;ACFlB,OAAO,aAAa;AAEpB,IAAO,iBAAQ,CAAC,cAAsB,QAAQ,aAAa;AAAA,EACzD,OAAO;AAAA,EACP,QAAQ,QAAQ,OAAO;AAAA,IACrB,QAAQ,OAAO,UAAU;AAAA,IACzB,QAAQ,OAAO,KAAK;AAAA,EACtB;AAAA,EACA,aAAa,EAAE,SAAS,QAAQ,IAAI,0BAA0B,QAAQ,UAAU;AAAA,EAChF,YAAY;AAAA,IACV,IAAI,QAAQ,WAAW,QAAQ;AAAA,EACjC;AACF,CAAC;;;ADSD,IAAM,MAAM,eAAO,aAAa;AAchC,SAAS,gBAAgB,KAAa,KAAoB,UAAU,OAAO;AACvE,MAAI,CAAC,KAAK;AACN,UAAM,IAAI,MAAM,yBAAyB,IAAI,MAAM,IAAI,IAAI,GAAG,GAAG;AAAA,EACrE;AAEA,MAAI,IAAI,WAAW,KAAK;AACpB,UAAM,IAAI,MAAM,GAAG,IAAI,MAAM,IAAI,IAAI,UAAU,uBAAuB,IAAI,MAAM,I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G9B,WAAO,SAAS,QAAQ,aAAa,QAAQ,IAAI,CAAC,IAAI;AAAA,EACxD;AAGA,QAAM,mBAAmB,MAAM,KAAK,MAAM,mBAAmB,QAAQ,IAAI,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,MAAM;AAChG,UAAM,cAAc,eAAe,WAAW,UAAU,QAAQ;AAEhE,gBAAY,YAAY,KAAK,kBAAkB,KAAK,CAAC,EAAE,OAAO,kBAAkB,OAAO,CAAC;AAExF,WAAO;AAAA,EACT,CAAC;AAED,SAAO,CAAC,GAAG,UAAU,GAAG,gBAAgB;AAC1C;;;AC7EA,SAAS,gBAAgB;","names":["log","client","axios","axios","log","axios","moment"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -91,6 +91,7 @@ interface Account<IDType = ObjectId | string> {
|
|
|
91
91
|
meterSerialNumber?: string;
|
|
92
92
|
meterPointNumber2?: string;
|
|
93
93
|
meterUnits: 'kwh' | 'm3' | 'ft3';
|
|
94
|
+
factor?: number;
|
|
94
95
|
registerIds?: string[];
|
|
95
96
|
automaticMeterRead?: boolean;
|
|
96
97
|
status?: 'active' | 'inactive';
|
|
@@ -519,6 +520,34 @@ interface Invoice<IDType = ObjectId | string> {
|
|
|
519
520
|
validation?: any[];
|
|
520
521
|
}
|
|
521
522
|
|
|
523
|
+
interface InvoiceCaptureMetadata {
|
|
524
|
+
totalDmg: Number;
|
|
525
|
+
totalDuration: Number;
|
|
526
|
+
results: {
|
|
527
|
+
key: string;
|
|
528
|
+
params: any;
|
|
529
|
+
modelResponse: any;
|
|
530
|
+
dmg: number;
|
|
531
|
+
promptedAt: Date;
|
|
532
|
+
duration: number;
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
interface InvoiceCapture<IDType = ObjectId | string> {
|
|
536
|
+
_id: IDType;
|
|
537
|
+
jobId?: string | null;
|
|
538
|
+
startTime?: Date;
|
|
539
|
+
endTime?: Date | null;
|
|
540
|
+
s3Key: string;
|
|
541
|
+
metrics: {
|
|
542
|
+
startTime: Date;
|
|
543
|
+
endTime: Date;
|
|
544
|
+
};
|
|
545
|
+
metadata: InvoiceCaptureMetadata;
|
|
546
|
+
uploadFileName?: string | null;
|
|
547
|
+
companyId: string;
|
|
548
|
+
userSub: string;
|
|
549
|
+
}
|
|
550
|
+
|
|
522
551
|
interface Log<IDType = ObjectId | string> {
|
|
523
552
|
_id: IDType;
|
|
524
553
|
message: string;
|
|
@@ -646,97 +675,103 @@ interface AuthOptions {
|
|
|
646
675
|
}
|
|
647
676
|
declare const _default$3: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
|
|
648
677
|
instance: AxiosInstance;
|
|
649
|
-
getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
650
|
-
listAccounts: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Account<string>>>;
|
|
651
|
-
updateAccount: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
652
|
-
createAccount: (data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
653
|
-
removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
654
|
-
getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
655
|
-
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
656
|
-
getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
657
|
-
listAssets: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Asset<string>>>;
|
|
658
|
-
updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
659
|
-
createAsset: (data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
660
|
-
removeAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
661
|
-
getAssetSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
662
|
-
getAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
663
|
-
listAssetGroups: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
664
|
-
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
665
|
-
createAssetGroup: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
666
|
-
removeAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
667
|
-
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
668
|
-
getAssetGroupSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
669
|
-
getAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
670
|
-
listAutomations: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Automation<string>>>;
|
|
671
|
-
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
672
|
-
createAutomation: (data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
673
|
-
removeAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
674
|
-
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
675
|
-
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
676
|
-
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
677
|
-
getCompany: (id: string, options?: AxiosRequestConfig) => Promise<Company<string>>;
|
|
678
|
-
getConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
679
|
-
listConsumptions: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
680
|
-
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
681
|
-
createConsumption: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
682
|
-
removeConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
683
|
-
getConsumptionSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
684
|
-
getEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
685
|
-
listEmails: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
686
|
-
updateEmail: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
687
|
-
createEmail: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
688
|
-
removeEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
689
|
-
getEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
690
|
-
listEmissionFactors: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
691
|
-
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
692
|
-
createEmissionFactor: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
693
|
-
removeEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
694
|
-
getEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
695
|
-
listEntities: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Entity<string>>>;
|
|
696
|
-
updateEntity: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
697
|
-
createEntity: (data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
698
|
-
removeEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
699
|
-
getEntitiesSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
700
|
-
getLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
701
|
-
listLogs: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Log<string>>>;
|
|
702
|
-
updateLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
703
|
-
createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
704
|
-
removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
705
|
-
getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
706
|
-
listReadings: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Reading<string>>>;
|
|
707
|
-
updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
708
|
-
createReading: (data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
709
|
-
removeReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
710
|
-
getReadingSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
711
|
-
getReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
712
|
-
listReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Report<string>>>;
|
|
713
|
-
updateReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
714
|
-
createReport: (data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
715
|
-
removeReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
716
|
-
sendReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
717
|
-
getReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
718
|
-
listReportTemplates: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
719
|
-
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
720
|
-
createReportTemplate: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
721
|
-
removeReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
722
|
-
getScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
723
|
-
listScheduledReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
724
|
-
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
725
|
-
createScheduledReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
726
|
-
removeScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
727
|
-
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
728
|
-
getInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
729
|
-
listInvoices: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Invoice<string>>>;
|
|
730
|
-
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
731
|
-
createInvoice: (data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
732
|
-
removeInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
733
|
-
getInvoiceSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
678
|
+
getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
679
|
+
listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Account<string>>>;
|
|
680
|
+
updateAccount: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
681
|
+
createAccount: (data: any, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
682
|
+
removeAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
683
|
+
getAccountSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
684
|
+
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
685
|
+
getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
686
|
+
listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Asset<string>>>;
|
|
687
|
+
updateAsset: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
688
|
+
createAsset: (data: any, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
689
|
+
removeAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
690
|
+
getAssetSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
691
|
+
getAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
692
|
+
listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
693
|
+
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
694
|
+
createAssetGroup: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
695
|
+
removeAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
696
|
+
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
697
|
+
getAssetGroupSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
698
|
+
getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
699
|
+
listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Automation<string>>>;
|
|
700
|
+
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
701
|
+
createAutomation: (data: any, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
702
|
+
removeAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
703
|
+
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
704
|
+
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
705
|
+
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
706
|
+
getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<Company<string>>;
|
|
707
|
+
getConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
708
|
+
listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
709
|
+
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
710
|
+
createConsumption: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
711
|
+
removeConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
712
|
+
getConsumptionSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
713
|
+
getEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
714
|
+
listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
715
|
+
updateEmail: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
716
|
+
createEmail: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
717
|
+
removeEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
718
|
+
getEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
719
|
+
listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
720
|
+
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
721
|
+
createEmissionFactor: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
722
|
+
removeEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
723
|
+
getEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
724
|
+
listEntities: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Entity<string>>>;
|
|
725
|
+
updateEntity: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
726
|
+
createEntity: (data: any, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
727
|
+
removeEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
728
|
+
getEntitiesSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
729
|
+
getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
730
|
+
listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Log<string>>>;
|
|
731
|
+
updateLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
732
|
+
createLog: (data: any, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
733
|
+
removeLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
734
|
+
getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
735
|
+
listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Reading<string>>>;
|
|
736
|
+
updateReading: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
737
|
+
createReading: (data: any, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
738
|
+
removeReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
739
|
+
getReadingSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
740
|
+
getReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
741
|
+
listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Report<string>>>;
|
|
742
|
+
updateReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
743
|
+
createReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
744
|
+
removeReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
745
|
+
sendReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
746
|
+
getReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
747
|
+
listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
748
|
+
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
749
|
+
createReportTemplate: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
750
|
+
removeReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
751
|
+
getScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
752
|
+
listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
753
|
+
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
754
|
+
createScheduledReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
755
|
+
removeScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
756
|
+
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
757
|
+
getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
758
|
+
listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Invoice<string>>>;
|
|
759
|
+
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
760
|
+
createInvoice: (data: any, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
761
|
+
removeInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
762
|
+
getInvoiceSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
763
|
+
getInvoiceCapture: (id: string, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
764
|
+
listInvoicesCapture: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<InvoiceCapture<string>>>;
|
|
765
|
+
updateInvoiceCapture: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
766
|
+
createInvoiceCapture: (data: any, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
767
|
+
removeInvoiceCapture: (id: string, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
768
|
+
getInvoiceCaptureSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
769
|
+
listSuppliers: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Supplier<string>>>;
|
|
770
|
+
getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
771
|
+
getImportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
772
|
+
listDataIngest: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<DataIngest<string>>>;
|
|
773
|
+
updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<DataIngest<string>>;
|
|
774
|
+
createDataIngest: (data: any, options?: AxiosRequestConfig<any>) => Promise<DataIngest<string>>;
|
|
740
775
|
};
|
|
741
776
|
|
|
742
777
|
declare const _default$2: (namespace: string) => winston.Logger;
|
|
@@ -767,7 +802,7 @@ declare const accountTypeUnitMap: {
|
|
|
767
802
|
[key: string]: ETNUnit[];
|
|
768
803
|
};
|
|
769
804
|
declare const convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined) => any;
|
|
770
|
-
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number |
|
|
805
|
+
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | '') => {
|
|
771
806
|
type: AccountType;
|
|
772
807
|
unit: ETNUnit;
|
|
773
808
|
};
|
|
@@ -818,4 +853,4 @@ declare namespace reporting {
|
|
|
818
853
|
export { reporting_getScheduledReportRunTimes as getScheduledReportRunTimes };
|
|
819
854
|
}
|
|
820
855
|
|
|
821
|
-
export { type Account, type Asset, type Automation, type Company, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceRate, type InvoiceRateType, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type UtilityType, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
|
|
856
|
+
export { type Account, type Asset, type Automation, type Company, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceCapture, type InvoiceRate, type InvoiceRateType, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type UtilityType, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ interface Account<IDType = ObjectId | string> {
|
|
|
91
91
|
meterSerialNumber?: string;
|
|
92
92
|
meterPointNumber2?: string;
|
|
93
93
|
meterUnits: 'kwh' | 'm3' | 'ft3';
|
|
94
|
+
factor?: number;
|
|
94
95
|
registerIds?: string[];
|
|
95
96
|
automaticMeterRead?: boolean;
|
|
96
97
|
status?: 'active' | 'inactive';
|
|
@@ -519,6 +520,34 @@ interface Invoice<IDType = ObjectId | string> {
|
|
|
519
520
|
validation?: any[];
|
|
520
521
|
}
|
|
521
522
|
|
|
523
|
+
interface InvoiceCaptureMetadata {
|
|
524
|
+
totalDmg: Number;
|
|
525
|
+
totalDuration: Number;
|
|
526
|
+
results: {
|
|
527
|
+
key: string;
|
|
528
|
+
params: any;
|
|
529
|
+
modelResponse: any;
|
|
530
|
+
dmg: number;
|
|
531
|
+
promptedAt: Date;
|
|
532
|
+
duration: number;
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
interface InvoiceCapture<IDType = ObjectId | string> {
|
|
536
|
+
_id: IDType;
|
|
537
|
+
jobId?: string | null;
|
|
538
|
+
startTime?: Date;
|
|
539
|
+
endTime?: Date | null;
|
|
540
|
+
s3Key: string;
|
|
541
|
+
metrics: {
|
|
542
|
+
startTime: Date;
|
|
543
|
+
endTime: Date;
|
|
544
|
+
};
|
|
545
|
+
metadata: InvoiceCaptureMetadata;
|
|
546
|
+
uploadFileName?: string | null;
|
|
547
|
+
companyId: string;
|
|
548
|
+
userSub: string;
|
|
549
|
+
}
|
|
550
|
+
|
|
522
551
|
interface Log<IDType = ObjectId | string> {
|
|
523
552
|
_id: IDType;
|
|
524
553
|
message: string;
|
|
@@ -646,97 +675,103 @@ interface AuthOptions {
|
|
|
646
675
|
}
|
|
647
676
|
declare const _default$3: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
|
|
648
677
|
instance: AxiosInstance;
|
|
649
|
-
getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
650
|
-
listAccounts: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Account<string>>>;
|
|
651
|
-
updateAccount: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
652
|
-
createAccount: (data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
653
|
-
removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
654
|
-
getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
655
|
-
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
656
|
-
getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
657
|
-
listAssets: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Asset<string>>>;
|
|
658
|
-
updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
659
|
-
createAsset: (data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
660
|
-
removeAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
661
|
-
getAssetSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
662
|
-
getAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
663
|
-
listAssetGroups: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
664
|
-
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
665
|
-
createAssetGroup: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
666
|
-
removeAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
667
|
-
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
668
|
-
getAssetGroupSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
669
|
-
getAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
670
|
-
listAutomations: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Automation<string>>>;
|
|
671
|
-
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
672
|
-
createAutomation: (data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
673
|
-
removeAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
674
|
-
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
675
|
-
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
676
|
-
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
677
|
-
getCompany: (id: string, options?: AxiosRequestConfig) => Promise<Company<string>>;
|
|
678
|
-
getConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
679
|
-
listConsumptions: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
680
|
-
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
681
|
-
createConsumption: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
682
|
-
removeConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
683
|
-
getConsumptionSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
684
|
-
getEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
685
|
-
listEmails: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
686
|
-
updateEmail: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
687
|
-
createEmail: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
688
|
-
removeEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
689
|
-
getEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
690
|
-
listEmissionFactors: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
691
|
-
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
692
|
-
createEmissionFactor: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
693
|
-
removeEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
694
|
-
getEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
695
|
-
listEntities: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Entity<string>>>;
|
|
696
|
-
updateEntity: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
697
|
-
createEntity: (data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
698
|
-
removeEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
699
|
-
getEntitiesSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
700
|
-
getLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
701
|
-
listLogs: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Log<string>>>;
|
|
702
|
-
updateLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
703
|
-
createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
704
|
-
removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
705
|
-
getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
706
|
-
listReadings: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Reading<string>>>;
|
|
707
|
-
updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
708
|
-
createReading: (data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
709
|
-
removeReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
710
|
-
getReadingSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
711
|
-
getReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
712
|
-
listReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Report<string>>>;
|
|
713
|
-
updateReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
714
|
-
createReport: (data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
715
|
-
removeReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
716
|
-
sendReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
717
|
-
getReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
718
|
-
listReportTemplates: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
719
|
-
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
720
|
-
createReportTemplate: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
721
|
-
removeReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
722
|
-
getScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
723
|
-
listScheduledReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
724
|
-
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
725
|
-
createScheduledReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
726
|
-
removeScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
727
|
-
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
728
|
-
getInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
729
|
-
listInvoices: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Invoice<string>>>;
|
|
730
|
-
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
731
|
-
createInvoice: (data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
732
|
-
removeInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
733
|
-
getInvoiceSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
678
|
+
getAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
679
|
+
listAccounts: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Account<string>>>;
|
|
680
|
+
updateAccount: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
681
|
+
createAccount: (data: any, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
682
|
+
removeAccount: (id: string, options?: AxiosRequestConfig<any>) => Promise<Account<string>>;
|
|
683
|
+
getAccountSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
684
|
+
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
685
|
+
getAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
686
|
+
listAssets: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Asset<string>>>;
|
|
687
|
+
updateAsset: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
688
|
+
createAsset: (data: any, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
689
|
+
removeAsset: (id: string, options?: AxiosRequestConfig<any>) => Promise<Asset<string>>;
|
|
690
|
+
getAssetSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
691
|
+
getAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
692
|
+
listAssetGroups: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
693
|
+
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
694
|
+
createAssetGroup: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
695
|
+
removeAssetGroup: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
696
|
+
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
697
|
+
getAssetGroupSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
698
|
+
getAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
699
|
+
listAutomations: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Automation<string>>>;
|
|
700
|
+
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
701
|
+
createAutomation: (data: any, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
702
|
+
removeAutomation: (id: string, options?: AxiosRequestConfig<any>) => Promise<Automation<string>>;
|
|
703
|
+
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
704
|
+
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
705
|
+
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
706
|
+
getCompany: (id: string, options?: AxiosRequestConfig<any>) => Promise<Company<string>>;
|
|
707
|
+
getConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
708
|
+
listConsumptions: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
709
|
+
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
710
|
+
createConsumption: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
711
|
+
removeConsumption: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
712
|
+
getConsumptionSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
713
|
+
getEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
714
|
+
listEmails: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
715
|
+
updateEmail: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
716
|
+
createEmail: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
717
|
+
removeEmail: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
718
|
+
getEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
719
|
+
listEmissionFactors: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
720
|
+
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
721
|
+
createEmissionFactor: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
722
|
+
removeEmissionFactor: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
723
|
+
getEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
724
|
+
listEntities: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Entity<string>>>;
|
|
725
|
+
updateEntity: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
726
|
+
createEntity: (data: any, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
727
|
+
removeEntity: (id: string, options?: AxiosRequestConfig<any>) => Promise<Entity<string>>;
|
|
728
|
+
getEntitiesSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
729
|
+
getLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
730
|
+
listLogs: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Log<string>>>;
|
|
731
|
+
updateLog: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
732
|
+
createLog: (data: any, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
733
|
+
removeLog: (id: string, options?: AxiosRequestConfig<any>) => Promise<Log<string>>;
|
|
734
|
+
getReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
735
|
+
listReadings: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Reading<string>>>;
|
|
736
|
+
updateReading: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
737
|
+
createReading: (data: any, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
738
|
+
removeReading: (id: string, options?: AxiosRequestConfig<any>) => Promise<Reading<string>>;
|
|
739
|
+
getReadingSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
740
|
+
getReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
741
|
+
listReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Report<string>>>;
|
|
742
|
+
updateReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
743
|
+
createReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
744
|
+
removeReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<Report<string>>;
|
|
745
|
+
sendReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
746
|
+
getReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
747
|
+
listReportTemplates: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
748
|
+
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
749
|
+
createReportTemplate: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
750
|
+
removeReportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
751
|
+
getScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
752
|
+
listScheduledReports: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<any>>;
|
|
753
|
+
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
754
|
+
createScheduledReport: (data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
755
|
+
removeScheduledReport: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
756
|
+
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
757
|
+
getInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
758
|
+
listInvoices: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Invoice<string>>>;
|
|
759
|
+
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
760
|
+
createInvoice: (data: any, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
761
|
+
removeInvoice: (id: string, options?: AxiosRequestConfig<any>) => Promise<Invoice<string>>;
|
|
762
|
+
getInvoiceSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
763
|
+
getInvoiceCapture: (id: string, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
764
|
+
listInvoicesCapture: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<InvoiceCapture<string>>>;
|
|
765
|
+
updateInvoiceCapture: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
766
|
+
createInvoiceCapture: (data: any, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
767
|
+
removeInvoiceCapture: (id: string, options?: AxiosRequestConfig<any>) => Promise<InvoiceCapture<string>>;
|
|
768
|
+
getInvoiceCaptureSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
769
|
+
listSuppliers: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<Supplier<string>>>;
|
|
770
|
+
getSupplierSchema: (options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
771
|
+
getImportTemplate: (id: string, options?: AxiosRequestConfig<any>) => Promise<any>;
|
|
772
|
+
listDataIngest: (options?: AxiosRequestConfig<any>) => Promise<ETNPagedResponse<DataIngest<string>>>;
|
|
773
|
+
updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig<any>) => Promise<DataIngest<string>>;
|
|
774
|
+
createDataIngest: (data: any, options?: AxiosRequestConfig<any>) => Promise<DataIngest<string>>;
|
|
740
775
|
};
|
|
741
776
|
|
|
742
777
|
declare const _default$2: (namespace: string) => winston.Logger;
|
|
@@ -767,7 +802,7 @@ declare const accountTypeUnitMap: {
|
|
|
767
802
|
[key: string]: ETNUnit[];
|
|
768
803
|
};
|
|
769
804
|
declare const convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined) => any;
|
|
770
|
-
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number |
|
|
805
|
+
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | '') => {
|
|
771
806
|
type: AccountType;
|
|
772
807
|
unit: ETNUnit;
|
|
773
808
|
};
|
|
@@ -818,4 +853,4 @@ declare namespace reporting {
|
|
|
818
853
|
export { reporting_getScheduledReportRunTimes as getScheduledReportRunTimes };
|
|
819
854
|
}
|
|
820
855
|
|
|
821
|
-
export { type Account, type Asset, type Automation, type Company, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceRate, type InvoiceRateType, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type UtilityType, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
|
|
856
|
+
export { type Account, type Asset, type Automation, type Company, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceCapture, type InvoiceRate, type InvoiceRateType, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type UtilityType, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units };
|
package/dist/index.js
CHANGED
|
@@ -332,6 +332,13 @@ var api_default = (auth, instanceOptions = {}) => {
|
|
|
332
332
|
createInvoice: factory.create(etainablApi, "invoices"),
|
|
333
333
|
removeInvoice: factory.remove(etainablApi, "invoices"),
|
|
334
334
|
getInvoiceSchema: factory.get(etainablApi, "invoices", "schema"),
|
|
335
|
+
// invoice capture
|
|
336
|
+
getInvoiceCapture: factory.getWithId(etainablApi, "invoice-capture"),
|
|
337
|
+
listInvoicesCapture: factory.list(etainablApi, "invoice-capture"),
|
|
338
|
+
updateInvoiceCapture: factory.update(etainablApi, "invoice-capture"),
|
|
339
|
+
createInvoiceCapture: factory.create(etainablApi, "invoice-capture"),
|
|
340
|
+
removeInvoiceCapture: factory.remove(etainablApi, "invoice-capture"),
|
|
341
|
+
getInvoiceCaptureSchema: factory.get(etainablApi, "invoice-capture", "schema"),
|
|
335
342
|
//suppliers
|
|
336
343
|
listSuppliers: factory.list(etainablApi, "suppliers"),
|
|
337
344
|
getSupplierSchema: factory.get(etainablApi, "suppliers", "schema"),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/api.ts","../src/logger.ts","../src/db.ts","../src/slack.ts","../src/units.ts","../src/consumption.ts","../src/monitoring.ts","../src/reporting.ts","../src/types/index.ts"],"sourcesContent":["import api from './api.js';\nimport logger from './logger.js';\nimport db from './db.js';\nimport slack from './slack.js';\nimport * as units from './units.js';\nimport * as consumption from './consumption.js';\nimport * as monitoring from './monitoring.js';\nimport * as reporting from './reporting.js';\n\nexport {\n api,\n logger,\n consumption,\n monitoring,\n db,\n slack,\n units,\n reporting\n}\n\nexport * from './types/index.js';","import axios from 'axios';\nimport type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults, AxiosResponse } from 'axios';\nimport https from 'https';\n\nimport logger from './logger.js';\n\nimport type { Account, Asset, Automation, Entity, Company, DataIngest, Invoice, Log, Reading, Report, Supplier } from './types/index.js'\n\nconst log = logger('etainablApi');\n\nexport interface ETNPagedResponse<T = any> {\n data: T[];\n total: number;\n limit: number;\n skip: number;\n}\n\nexport interface ETNReq {\n method: string;\n url: string;\n}\n\nfunction _handleResponse(req: ETNReq, res: AxiosResponse, isPaged = false) {\n if (!res) {\n throw new Error(`No response from API (${req.method} ${req.url})`);\n }\n\n if (res.status !== 200) {\n throw new Error(`${res.status} ${res.statusText} response from API (${req.method} ${req.url})`);\n }\n\n if (!res.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n if (isPaged && !res.data.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n return res;\n}\n\nconst factory = {\n getWithId: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAsINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n _handleResponse(req, res)\n\n return res.data;\n },\n get: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res)\n\n return res.data;\n },\n list: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (options: AxiosRequestConfig = {}): Promise<ETNPagedResponse<T>> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n \n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res, true)\n\n return res.data;\n },\n update: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'PATCH',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n \n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.patch(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res)\n\n return res.data;\n },\n create: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'POST',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.post(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res)\n\n return res.data;\n },\n remove: <T = any> (etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) => async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'DELETE',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n let res: AxiosResponse;\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n try {\n res = await etainablApi.delete(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n customWithId: <T = any> (etainablApi: AxiosInstance, method: string, endpoint: string, postEndpoint?: string) => async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: method,\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`,\n data,\n ...options\n };\n \n log.info(`API Request (Custom): ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n \n try {\n res = await etainablApi.request(req);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res)\n\n return res.data;\n }\n};\n\n// ETN Sub Endpoints\n// e.g. /assets/:id/documents/:documentId\nconst subFactory = {\n // e.g. POST /assets/:id/documents\n create: <T = any> (etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) => async (id: string, data: any, options: AxiosRequestConfig = {}) => { \n const subUrl = `${id}/${subEndpoint}`;\n return factory.create<T>(etainablApi, endpoint, subUrl)(data, options);\n },\n // e.g. PATCH /assets/:id/documents/:documentId\n update: <T = any> (etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) => async (id: string, subId: string, data: any, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n \n return factory.update<T>(etainablApi, endpoint, subUrl)(id, data, options);\n },\n // e.g. DELETE /assets/:id/documents/:documentId\n remove: <T = any> (etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) => async (id: string, subId: string, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n \n return factory.remove<T>(etainablApi, endpoint, subUrl)(id, options);\n }\n}\n\ninterface AuthOptions {\n key?: string;\n token?: string;\n}\n\nexport default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) => {\n try {\n const headers: any = {};\n\n if (auth.key) {\n headers['x-key'] = auth.key;\n } else if (auth.token) {\n headers['Authorization'] = auth.token;\n } else {\n headers['x-key'] = process.env.ETAINABL_API_KEY;\n }\n \n const etainablApi = axios.create({\n baseURL: process.env.ETAINABL_API_URL,\n timeout: 300000,\n httpsAgent: new https.Agent({ keepAlive: true }),\n headers,\n ...instanceOptions\n });\n \n return {\n instance: etainablApi,\n \n // accounts\n getAccount: factory.getWithId<Account<string>>(etainablApi, 'accounts'),\n listAccounts: factory.list<Account<string>>(etainablApi, 'accounts'),\n updateAccount: factory.update<Account<string>>(etainablApi, 'accounts'),\n createAccount: factory.create<Account<string>>(etainablApi, 'accounts'),\n removeAccount: factory.remove<Account<string>>(etainablApi, 'accounts'),\n getAccountSchema: factory.get(etainablApi, 'accounts', 'schema'),\n invalidateAccountCache: factory.customWithId(etainablApi, 'put', 'accounts', 'invalidate-cache'),\n\n // assets\n getAsset: factory.getWithId<Asset<string>>(etainablApi, 'assets'),\n listAssets: factory.list<Asset<string>>(etainablApi, 'assets'),\n updateAsset: factory.update<Asset<string>>(etainablApi, 'assets'),\n createAsset: factory.create<Asset<string>>(etainablApi, 'assets'),\n removeAsset: factory.remove<Asset<string>>(etainablApi, 'assets'),\n getAssetSchema: factory.get(etainablApi, 'assets', 'schema'),\n \n // assetGroups\n getAssetGroup: factory.getWithId(etainablApi, 'asset-groups'),\n listAssetGroups: factory.list(etainablApi, 'asset-groups'),\n updateAssetGroup: factory.update(etainablApi, 'asset-groups'),\n createAssetGroup: factory.create(etainablApi, 'asset-groups'),\n removeAssetGroup: factory.remove(etainablApi, 'asset-groups'),\n getAssetGroupAssets: factory.getWithId(etainablApi, 'asset-groups', 'assets'),\n getAssetGroupSchema: factory.get(etainablApi, 'asset-groups', 'schema'),\n \n // automation\n getAutomation: factory.getWithId<Automation<string>>(etainablApi, 'automation'),\n listAutomations: factory.list<Automation<string>>(etainablApi, 'automation'),\n updateAutomation: factory.update<Automation<string>>(etainablApi, 'automation'),\n createAutomation: factory.create<Automation<string>>(etainablApi, 'automation'),\n removeAutomation: factory.remove<Automation<string>>(etainablApi, 'automation'),\n createAutomationLog: subFactory.create(etainablApi, 'automation', 'logs'),\n updateAutomationLog: subFactory.update(etainablApi, 'automation', 'logs'),\n removeAutomationLog: subFactory.remove(etainablApi, 'automation', 'logs'),\n \n // company\n getCompany: factory.getWithId<Company<string>>(etainablApi, 'companies'),\n \n // consumption\n getConsumption: factory.getWithId(etainablApi, 'consumptions'),\n listConsumptions: factory.list(etainablApi, 'consumptions'),\n updateConsumption: factory.update(etainablApi, 'consumptions'),\n createConsumption: factory.create(etainablApi, 'consumptions'),\n removeConsumption: factory.remove(etainablApi, 'consumptions'),\n getConsumptionSchema: factory.get(etainablApi, 'consumptions', 'schema'),\n \n // emails\n getEmail: factory.getWithId(etainablApi, 'emails'),\n listEmails: factory.list(etainablApi, 'emails'),\n updateEmail: factory.update(etainablApi, 'emails'),\n createEmail: factory.create(etainablApi, 'emails'),\n removeEmail: factory.remove(etainablApi, 'emails'),\n \n // emission factors\n getEmissionFactor: factory.getWithId(etainablApi, 'emission-factors'),\n listEmissionFactors: factory.list(etainablApi, 'emission-factors'),\n updateEmissionFactor: factory.update(etainablApi, 'emission-factors'),\n createEmissionFactor: factory.create(etainablApi, 'emission-factors'),\n removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),\n\n // entity\n getEntity: factory.getWithId<Entity<string>>(etainablApi, 'entities'),\n listEntities: factory.list<Entity<string>>(etainablApi, 'entities'),\n updateEntity: factory.update<Entity<string>>(etainablApi, 'entities'),\n createEntity: factory.create<Entity<string>>(etainablApi, 'entities'),\n removeEntity: factory.remove<Entity<string>>(etainablApi, 'entities'),\n getEntitiesSchema: factory.get(etainablApi, 'entities', 'schema'),\n \n \n // logs\n getLog: factory.getWithId<Log<string>>(etainablApi, 'logs'),\n listLogs: factory.list<Log<string>>(etainablApi, 'logs'),\n updateLog: factory.update<Log<string>>(etainablApi, 'logs'),\n createLog: factory.create<Log<string>>(etainablApi, 'logs'),\n removeLog: factory.remove<Log<string>>(etainablApi, 'logs'),\n \n // readings\n getReading: factory.getWithId<Reading<string>>(etainablApi, 'readings'),\n listReadings: factory.list<Reading<string>>(etainablApi, 'readings'),\n updateReading: factory.update<Reading<string>>(etainablApi, 'readings'),\n createReading: factory.create<Reading<string>>(etainablApi, 'readings'),\n removeReading: factory.remove<Reading<string>>(etainablApi, 'readings'),\n getReadingSchema: factory.get(etainablApi, 'readings', 'schema'),\n \n // reports\n getReport: factory.getWithId<Report<string>>(etainablApi, 'reports'),\n listReports: factory.list<Report<string>>(etainablApi, 'reports'),\n updateReport: factory.update<Report<string>>(etainablApi, 'reports'),\n createReport: factory.create<Report<string>>(etainablApi, 'reports'),\n removeReport: factory.remove<Report<string>>(etainablApi, 'reports'),\n sendReport: factory.customWithId(etainablApi, 'post', 'reports', 'send'),\n \n // report templates\n getReportTemplate: factory.getWithId(etainablApi, 'report-templates'),\n listReportTemplates: factory.list(etainablApi, 'report-templates'),\n updateReportTemplate: factory.update(etainablApi, 'report-templates'),\n createReportTemplate: factory.create(etainablApi, 'report-templates'),\n removeReportTemplate: factory.remove(etainablApi, 'report-templates'),\n \n // scheduled reports\n getScheduledReport: factory.getWithId(etainablApi, 'scheduled-reports'),\n listScheduledReports: factory.list(etainablApi, 'scheduled-reports'),\n updateScheduledReport: factory.update(etainablApi, 'scheduled-reports'),\n createScheduledReport: factory.create(etainablApi, 'scheduled-reports'),\n removeScheduledReport: factory.remove(etainablApi, 'scheduled-reports'),\n sendScheduledReport: factory.customWithId(etainablApi, 'post', 'scheduled-reports', 'send'),\n \n // invoices\n getInvoice: factory.getWithId<Invoice<string>>(etainablApi, 'invoices'),\n listInvoices: factory.list<Invoice<string>>(etainablApi, 'invoices'),\n updateInvoice: factory.update<Invoice<string>>(etainablApi, 'invoices'),\n createInvoice: factory.create<Invoice<string>>(etainablApi, 'invoices'),\n removeInvoice: factory.remove<Invoice<string>>(etainablApi, 'invoices'),\n getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),\n\n //suppliers\n listSuppliers: factory.list<Supplier<string>>(etainablApi, 'suppliers'),\n getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),\n\n // import templates\n getImportTemplate: factory.getWithId(etainablApi, 'import-templates'),\n\n //data imports\n listDataIngest: factory.list<DataIngest<string>>(etainablApi, 'data-ingests'),\n updateDataIngest: factory.update<DataIngest<string>>(etainablApi, 'data-ingests'),\n createDataIngest: factory.create<DataIngest<string>>(etainablApi, 'data-ingests')\n\n }\n } catch (e) {\n log.error(e);\n throw e;\n }\n};\n","import winston from 'winston';\n\nexport default (namespace: string) => winston.createLogger({\n level: 'debug',\n format: winston.format.combine(\n winston.format.timestamp(),\n winston.format.json()\n ),\n defaultMeta: { service: process.env.AWS_LAMBDA_FUNCTION_NAME, script: namespace },\n transports: [\n new winston.transports.Console()\n ]\n});\n","import { MongoClient, Db } from 'mongodb';\nimport logger from './logger.js';\n\nconst log = logger('dbHelpers');\n\nlet cachedDb: Db;\n\nasync function connectToDatabase(retryAttempt: number = 1): Promise<Db> {\n if (!process.env.ETAINABL_DB_URL) throw new Error(\"ETAINABL_DB_URL is not set\");\n if (!process.env.AWS_ACCESS_KEY_ID) throw new Error(\"AWS_ACCESS_KEY_ID is not set\");\n if (!process.env.AWS_SECRET_ACCESS_KEY) throw new Error(\"AWS_SECRET_ACCESS_KEY is not set\");\n\n if (cachedDb) {\n log.debug('Using cached MongoDB connection.');\n return Promise.resolve(cachedDb);\n }\n \n const uri = `mongodb+srv://${process.env.ETAINABL_DB_URL}`;\n \n try {\n if (process.env.DB_BASIC_AUTH === 'true') {\n log.debug('Connecting to MongoDB server... (Auth: Basic)');\n\n const client = new MongoClient(uri);\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: Basic)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n }\n\n log.debug('Connecting to MongoDB server... (Auth: AWS)');\n\n const client = new MongoClient(uri, {\n auth: {\n username: process.env.AWS_ACCESS_KEY_ID,\n password: process.env.AWS_SECRET_ACCESS_KEY\n },\n authSource: '$external',\n authMechanism: 'MONGODB-AWS'\n });\n\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: AWS)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n\n } catch (e: any) {\n // Retry\n if (retryAttempt > 5) {\n console.log(`Error connecting to MongoDB server after 5 attempts...`);\n throw e;\n }\n\n console.log(`MongoDB Connection error: ${e.message}`);\n\n console.log(`Error connecting to MongoDB server... Retrying in 3 seconds... (Attempt ${retryAttempt})`);\n return connectToDatabase(retryAttempt + 1);\n }\n}\n\nexport default {\n connectToDatabase\n};","import axios from 'axios';\n\nconst postMessage = async (message: string) => {\n const url = 'https://hooks.slack.com/services/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';\n const data = {\n text: `[${(process.env.ENV || '').toUpperCase()}][${process.env.AWS_LAMBDA_FUNCTION_NAME}] ${message}`\n };\n const headers = {\n 'Content-Type': 'application/json'\n };\n return axios.post(url, data, { headers });\n};\n\nexport default {\n postMessage\n}","interface Item {\n units?: string | null;\n unit?: string | null;\n factor?: number | null;\n value: number;\n [key: string]: any; \n}\n\nexport type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';\nexport type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';\nexport type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';\nexport const accountTypeMap: { [key: string]: BaseUnit } = {\n electricity: 'kwh',\n gas: 'kwh',\n water: 'm3',\n waste: 'kg',\n solar: 'kwh',\n heating: 'kwh',\n flow: 'm3/h',\n cooling: 'kwh',\n temperature: 'C',\n oil: 'l'\n};\n\nconst unitConversionFactors: { [key: string]: any } = {\n kwh: {\n kwh: 1,\n mwh: 1000,\n wh: 0.001,\n m3: (39 * 1.02264) / 3.6,\n ft3: (0.0283 * 39 * 1.02264) / 3.6,\n hcf: (2.83 * 39 * 1.02264) / 3.6\n },\n m3: {\n m3: 1,\n l: 0.001\n },\n C: {\n C: 1\n },\n kg: {\n kg: 1,\n lbs: 0.45359237,\n tonnes: 1000\n },\n 'm3/h': {\n 'm3/h': 1\n }\n};\n\nexport const accountTypeUnitMap: { [key: string]: ETNUnit[] } = {\n electricity: ['kwh', 'mwh', 'wh'],\n gas: ['kwh', 'm3', 'ft3', 'hcf'],\n water: ['m3', 'l'],\n waste: ['kg', 'lbs', 'tonnes'],\n solar: ['kwh', 'mwh', 'wh'],\n heating: ['kwh', 'mwh', 'wh'],\n flow: ['m3/h'],\n cooling: ['kwh', 'mwh', 'wh'],\n temperature: ['C'],\n oil: ['l']\n};\n\n// Convert units to base format\nexport const convertItems = (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined): any => {\n if (!type) throw new Error('Account type is required');\n\n const baseUnit = accountTypeMap[type];\n if (!baseUnit) throw new Error(`Account type ${type} is not supported`);\n\n const convertedItems = items.map(item => {\n const factor = item.factor || accountFactor || 1;\n const units = item.units || item.unit || defaultUnits || baseUnit;\n const convertedValue = item.value * _getConversionFactor(units, baseUnit) * factor;\n return { ...item, value: convertedValue, units: baseUnit };\n });\n\n return convertedItems;\n};\n\nconst _getConversionFactor = (fromUnit: string = 'kwh', toUnit: string) => {\n const conversionFactors = unitConversionFactors[toUnit];\n\n if (!conversionFactors) {\n throw new Error(`Conversion factor base unit ${toUnit} is not defined`);\n }\n\n if (!conversionFactors[fromUnit]) {\n throw new Error(`Conversion factor from unit ${fromUnit} is not defined`);\n }\n\n return conversionFactors[fromUnit];\n};\n\nexport const checkAccountTypeVsUnits = (type: string, unit: string, additionalLog: number | '' = '') => {\n if (!type) throw new Error('Account type is required');\n if (!unit) throw new Error('Unit is required');\n\n const parsedType = type.toLowerCase().trim();\n\n const accountTypeUnits = accountTypeUnitMap[parsedType];\n if (!accountTypeUnits) throw new Error(`Account type \"${parsedType}\" is not supported ${additionalLog}`);\n\n const parsedUnit = unit.toLowerCase().trim() as ETNUnit;\n\n if (!accountTypeUnits.includes(parsedUnit)) {\n throw new Error(`Account type \"${parsedType}\" does not support unit \"${parsedUnit}\" ${additionalLog}`);\n }\n\n return { type: parsedType as AccountType, unit: parsedUnit};\n};\n","import moment from 'moment';\n\ninterface ConsumptionData {\n date: Date;\n consumption: number;\n}\n\ninterface DayNightConsumption {\n dayConsumption: number,\n nightConsumption: number,\n consumption: number\n}\n\nexport const dayNightConsumption = (data: ConsumptionData[]) => data.reduce((acc: DayNightConsumption, item: ConsumptionData): DayNightConsumption => {\n const hour = moment.utc(item.date).hour(); // End Time of HH consumption period\n\n if (hour >= 0 && hour < 7) {\n acc.nightConsumption += item.consumption;\n } else {\n acc.dayConsumption += item.consumption;\n }\n\n acc.consumption += item.consumption;\n\n return acc;\n}, {\n dayConsumption: 0,\n nightConsumption: 0,\n consumption: 0\n});\n\nexport const calcMaxConsumptionValue = (data: ConsumptionData[]) => Math.max(...data.map((item: ConsumptionData) => item.consumption));\n\nexport const calcMaxDemand = (data: ConsumptionData[]) => calcMaxConsumptionValue(data) * 2;\n\nexport const calcPeakLoad = (consumption: number, maxDemand: number, startDate: string | moment.Moment, endDate: string | moment.Moment) => {\n const days = Math.ceil(moment(endDate).diff(moment(startDate), 'days', true));\n\n return maxDemand === 0 ? 0 : ((consumption / (maxDemand * 24 * days)) * 100);\n};","import axios from 'axios';\n\nimport logger from './logger.js';\n\nconst log = logger('monitoring');\n\nexport const sendHeartbeat = async () => {\n if (!process.env.HEARTBEAT_URL || process.env.HEARTBEAT_URL.endsWith('/')) return false;\n\n try {\n await axios.post(process.env.HEARTBEAT_URL);\n\n return true;\n } catch (e: any) {\n log.warn(`Failed to send heartbeat: ${e.message || e}`);\n return false;\n }\n}","import moment from 'moment';\n\nmoment.locale('en', {\n week: {\n dow: 1\n }\n});\n\nconst getNextRunTime = (startDate: moment.Moment, schedule: any, taskTime: moment.Moment): moment.Moment => {\n const [num, freq] = schedule.frequency.split('|');\n const targetDate = moment(startDate).add(num, freq as moment.unitOfTime.Base);\n\n if (schedule.frequencyPeriod === 'first') {\n targetDate.startOf(freq as moment.unitOfTime.StartOf);\n } else if (schedule.frequencyPeriod === 'last') {\n targetDate.endOf(freq as moment.unitOfTime.StartOf);\n }\n\n const isWeekday = targetDate.isoWeekday() > 0 && targetDate.isoWeekday() < 6;\n const isSaturday = targetDate.isoWeekday() === 6;\n\n // The weekday or weekend chosen should be within the same month as the target date\n if (schedule.frequencyDay === 'weekdays' && !isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.add(isSaturday ? 2 : 1, 'days');\n } else {\n targetDate.subtract(isSaturday ? 1 : 2, 'days');\n }\n } else if (schedule.frequencyDay === 'weekends' && isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.isoWeekday(6);\n } else {\n targetDate.isoWeekday(0);\n }\n }\n\n if (taskTime.isAfter(targetDate, 'minute')) {\n return getNextRunTime(targetDate, schedule, taskTime);\n }\n\n return targetDate;\n};\n\nexport const getScheduledReportRunTimes = (schedule: any, limit = 1, taskTime = moment()): moment.Moment[] => {\n if (!schedule.startDate || !schedule.enabled) return [];\n\n const originalStartDate = moment.utc(schedule.startDate);\n\n let startDate = originalStartDate;\n\n const includeStartDate = taskTime.isSameOrBefore(originalStartDate, 'minute');\n\n let runTimes = [] as moment.Moment[];\n\n if (includeStartDate) {\n runTimes = [originalStartDate];\n }\n\n const [, freq] = schedule.frequency.split('|');\n\n if (freq === 'once') {\n const nextRunTime = runTimes[0];\n\n // If this is now beyond the start date, return an empty array\n return taskTime.isAfter(nextRunTime, 'minute') ? [] : runTimes;\n }\n\n\n const scheduleRunTimes = Array.from(Array(includeStartDate ? limit - 1 : limit).keys()).map(() => {\n const nextRunTime = getNextRunTime(startDate, schedule, taskTime);\n\n startDate = nextRunTime.hour(originalStartDate.hour()).minute(originalStartDate.minute());\n\n return nextRunTime;\n });\n\n return [...runTimes, ...scheduleRunTimes];\n};\n","import { ObjectId } from 'mongodb';\n\ntype Primitive = string | number | boolean | null | undefined | symbol | bigint | Date | ObjectId; // Add ObjectId/Date here\n\nexport * from './account.js'\nexport * from './asset.js'\nexport * from './automation.js'\nexport * from './company.js'\nexport * from './scraperRun.js';\nexport * from './dataIngest.js'\nexport * from './entity.js'\nexport * from './email.js';\nexport * from './invoice.js';\nexport * from './log.js';\nexport * from './reading.js'\nexport * from './report.js'\nexport * from './supplier.js'\nexport * from './global.js'\nexport { ObjectId }\n\nexport interface ETNPagedResponse<T = any> {\n data: T[];\n total: number;\n limit: number;\n skip: number;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAElB,mBAAkB;;;ACFlB,q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C,UAAe,QAAQ,GAAG,eAAW,eAAAA,SAAO,MAAuB;AAC5G,MAAI,CAAC,SAAS,aAAa,CAAC,SAAS,QAAS,QAAO,CAAC;AAEtD,QAAM,oBAAoB,eAAAA,QAAO,IAAI,SAAS,SAAS;AAEvD,MAAI,YAAY;AAEhB,QAAM,mBAAmB,SAAS,eAAe,mBAAmB,QAAQ;AAE5E,MAAI,WAAW,CAAC;AAEhB,MAAI,kBAAkB;AACpB,eAAW,CAAC,iBAAiB;AAAA,EAC/B;AAEA,QAAM,CAAC,EAAE,IAAI,IAAI,SAAS,UAAU,MAAM,GAAG;AAE7C,MAAI,SAAS,QAAQ;AACnB,UAAM,cAAc,SAAS,CAAC;AAG9B,WAAO,SAAS,QAAQ,aAAa,QAAQ,IAAI,CAAC,IAAI;AAAA,EACxD;AAGA,QAAM,mBAAmB,MAAM,KAAK,MAAM,mBAAmB,QAAQ,IAAI,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,MAAM;AAChG,UAAM,cAAc,eAAe,WAAW,UAAU,QAAQ;AAEhE,gBAAY,YAAY,KAAK,kBAAkB,KAAK,CAAC,EAAE,OAAO,kBAAkB,OAAO,CAAC;AAExF,WAAO;AAAA,EACT,CAAC;AAED,SAAO,CAAC,GAAG,UAAU,GAAG,gBAAgB;AAC1C;;;AC7EA,IAAAC,kBAAyB;","names":["winston","axios","https","log","client","import_axios","axios","moment","import_axios","log","axios","import_moment","moment","import_mongodb"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/api.ts","../src/logger.ts","../src/db.ts","../src/slack.ts","../src/units.ts","../src/consumption.ts","../src/monitoring.ts","../src/reporting.ts","../src/types/index.ts"],"sourcesContent":["import api from './api.js';\nimport logger from './logger.js';\nimport db from './db.js';\nimport slack from './slack.js';\nimport * as units from './units.js';\nimport * as consumption from './consumption.js';\nimport * as monitoring from './monitoring.js';\nimport * as reporting from './reporting.js';\n\nexport {\n api,\n logger,\n consumption,\n monitoring,\n db,\n slack,\n units,\n reporting\n}\n\nexport * from './types/index.js';","import axios from 'axios';\nimport type { AxiosRequestConfig, AxiosInstance, CreateAxiosDefaults, AxiosResponse } from 'axios';\nimport https from 'https';\n\nimport logger from './logger.js';\n\nimport type {\n Account,\n Asset,\n Automation,\n Entity,\n Company,\n DataIngest,\n Invoice,\n InvoiceCapture,\n Log,\n Reading,\n Report,\n Supplier\n} from './types/index.js';\n\nconst log = logger('etainablApi');\n\nexport interface ETNPagedResponse<T = any> {\n data: T[];\n total: number;\n limit: number;\n skip: number;\n}\n\nexport interface ETNReq {\n method: string;\n url: string;\n}\n\nfunction _handleResponse(req: ETNReq, res: AxiosResponse, isPaged = false) {\n if (!res) {\n throw new Error(`No response from API (${req.method} ${req.url})`);\n }\n\n if (res.status !== 200) {\n throw new Error(`${res.status} ${res.statusText} response from API (${req.method} ${req.url})`);\n }\n\n if (!res.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n if (isPaged && !res.data.data) {\n throw new Error(`No data from API (${req.method} ${req.url})`);\n }\n\n return res;\n}\n\nconst factory = {\n getWithId:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAsINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n _handleResponse(req, res);\n\n return res.data;\n },\n get:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res);\n\n return res.data;\n },\n list:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (options: AxiosRequestConfig = {}): Promise<ETNPagedResponse<T>> => {\n const req = {\n method: 'GET',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.get(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n console.log(`API Response: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n _handleResponse(req, res, true);\n\n return res.data;\n },\n update:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'PATCH',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.patch(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n create:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'POST',\n url: `${endpoint}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.post(req.url, data, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n remove:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, postEndpoint?: string) =>\n async (id: string, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: 'DELETE',\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`\n };\n\n let res: AxiosResponse;\n\n log.info(`API Request: ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n try {\n res = await etainablApi.delete(req.url, options);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n },\n customWithId:\n <T = any>(etainablApi: AxiosInstance, method: string, endpoint: string, postEndpoint?: string) =>\n async (id: string, data: any, options: AxiosRequestConfig = {}): Promise<T> => {\n const req = {\n method: method,\n url: `${endpoint}/${id}${postEndpoint ? `/${postEndpoint}` : ''}`,\n data,\n ...options\n };\n\n log.info(`API Request (Custom): ${req.method} ${process.env.ETAINABL_API_URL}/${req.url}`);\n\n let res: AxiosResponse;\n\n try {\n res = await etainablApi.request(req);\n } catch (e: any) {\n if (e.response?.data) throw new Error(`API error response: ${JSON.stringify(e.response.data)}`);\n throw e;\n }\n\n _handleResponse(req, res);\n\n return res.data;\n }\n};\n\n// ETN Sub Endpoints\n// e.g. /assets/:id/documents/:documentId\nconst subFactory = {\n // e.g. POST /assets/:id/documents\n create:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) =>\n async (id: string, data: any, options: AxiosRequestConfig = {}) => {\n const subUrl = `${id}/${subEndpoint}`;\n return factory.create<T>(etainablApi, endpoint, subUrl)(data, options);\n },\n // e.g. PATCH /assets/:id/documents/:documentId\n update:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) =>\n async (id: string, subId: string, data: any, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n\n return factory.update<T>(etainablApi, endpoint, subUrl)(id, data, options);\n },\n // e.g. DELETE /assets/:id/documents/:documentId\n remove:\n <T = any>(etainablApi: AxiosInstance, endpoint: string, subEndpoint: string) =>\n async (id: string, subId: string, options: AxiosRequestConfig = {}) => {\n const subUrl = `${subEndpoint}/${subId}`;\n\n return factory.remove<T>(etainablApi, endpoint, subUrl)(id, options);\n }\n};\n\ninterface AuthOptions {\n key?: string;\n token?: string;\n}\n\nexport default (auth: AuthOptions, instanceOptions: CreateAxiosDefaults = {}) => {\n try {\n const headers: any = {};\n\n if (auth.key) {\n headers['x-key'] = auth.key;\n } else if (auth.token) {\n headers['Authorization'] = auth.token;\n } else {\n headers['x-key'] = process.env.ETAINABL_API_KEY;\n }\n\n const etainablApi = axios.create({\n baseURL: process.env.ETAINABL_API_URL,\n timeout: 300000,\n httpsAgent: new https.Agent({ keepAlive: true }),\n headers,\n ...instanceOptions\n });\n\n return {\n instance: etainablApi,\n\n // accounts\n getAccount: factory.getWithId<Account<string>>(etainablApi, 'accounts'),\n listAccounts: factory.list<Account<string>>(etainablApi, 'accounts'),\n updateAccount: factory.update<Account<string>>(etainablApi, 'accounts'),\n createAccount: factory.create<Account<string>>(etainablApi, 'accounts'),\n removeAccount: factory.remove<Account<string>>(etainablApi, 'accounts'),\n getAccountSchema: factory.get(etainablApi, 'accounts', 'schema'),\n invalidateAccountCache: factory.customWithId(etainablApi, 'put', 'accounts', 'invalidate-cache'),\n\n // assets\n getAsset: factory.getWithId<Asset<string>>(etainablApi, 'assets'),\n listAssets: factory.list<Asset<string>>(etainablApi, 'assets'),\n updateAsset: factory.update<Asset<string>>(etainablApi, 'assets'),\n createAsset: factory.create<Asset<string>>(etainablApi, 'assets'),\n removeAsset: factory.remove<Asset<string>>(etainablApi, 'assets'),\n getAssetSchema: factory.get(etainablApi, 'assets', 'schema'),\n\n // assetGroups\n getAssetGroup: factory.getWithId(etainablApi, 'asset-groups'),\n listAssetGroups: factory.list(etainablApi, 'asset-groups'),\n updateAssetGroup: factory.update(etainablApi, 'asset-groups'),\n createAssetGroup: factory.create(etainablApi, 'asset-groups'),\n removeAssetGroup: factory.remove(etainablApi, 'asset-groups'),\n getAssetGroupAssets: factory.getWithId(etainablApi, 'asset-groups', 'assets'),\n getAssetGroupSchema: factory.get(etainablApi, 'asset-groups', 'schema'),\n\n // automation\n getAutomation: factory.getWithId<Automation<string>>(etainablApi, 'automation'),\n listAutomations: factory.list<Automation<string>>(etainablApi, 'automation'),\n updateAutomation: factory.update<Automation<string>>(etainablApi, 'automation'),\n createAutomation: factory.create<Automation<string>>(etainablApi, 'automation'),\n removeAutomation: factory.remove<Automation<string>>(etainablApi, 'automation'),\n createAutomationLog: subFactory.create(etainablApi, 'automation', 'logs'),\n updateAutomationLog: subFactory.update(etainablApi, 'automation', 'logs'),\n removeAutomationLog: subFactory.remove(etainablApi, 'automation', 'logs'),\n\n // company\n getCompany: factory.getWithId<Company<string>>(etainablApi, 'companies'),\n\n // consumption\n getConsumption: factory.getWithId(etainablApi, 'consumptions'),\n listConsumptions: factory.list(etainablApi, 'consumptions'),\n updateConsumption: factory.update(etainablApi, 'consumptions'),\n createConsumption: factory.create(etainablApi, 'consumptions'),\n removeConsumption: factory.remove(etainablApi, 'consumptions'),\n getConsumptionSchema: factory.get(etainablApi, 'consumptions', 'schema'),\n\n // emails\n getEmail: factory.getWithId(etainablApi, 'emails'),\n listEmails: factory.list(etainablApi, 'emails'),\n updateEmail: factory.update(etainablApi, 'emails'),\n createEmail: factory.create(etainablApi, 'emails'),\n removeEmail: factory.remove(etainablApi, 'emails'),\n\n // emission factors\n getEmissionFactor: factory.getWithId(etainablApi, 'emission-factors'),\n listEmissionFactors: factory.list(etainablApi, 'emission-factors'),\n updateEmissionFactor: factory.update(etainablApi, 'emission-factors'),\n createEmissionFactor: factory.create(etainablApi, 'emission-factors'),\n removeEmissionFactor: factory.remove(etainablApi, 'emission-factors'),\n\n // entity\n getEntity: factory.getWithId<Entity<string>>(etainablApi, 'entities'),\n listEntities: factory.list<Entity<string>>(etainablApi, 'entities'),\n updateEntity: factory.update<Entity<string>>(etainablApi, 'entities'),\n createEntity: factory.create<Entity<string>>(etainablApi, 'entities'),\n removeEntity: factory.remove<Entity<string>>(etainablApi, 'entities'),\n getEntitiesSchema: factory.get(etainablApi, 'entities', 'schema'),\n\n // logs\n getLog: factory.getWithId<Log<string>>(etainablApi, 'logs'),\n listLogs: factory.list<Log<string>>(etainablApi, 'logs'),\n updateLog: factory.update<Log<string>>(etainablApi, 'logs'),\n createLog: factory.create<Log<string>>(etainablApi, 'logs'),\n removeLog: factory.remove<Log<string>>(etainablApi, 'logs'),\n\n // readings\n getReading: factory.getWithId<Reading<string>>(etainablApi, 'readings'),\n listReadings: factory.list<Reading<string>>(etainablApi, 'readings'),\n updateReading: factory.update<Reading<string>>(etainablApi, 'readings'),\n createReading: factory.create<Reading<string>>(etainablApi, 'readings'),\n removeReading: factory.remove<Reading<string>>(etainablApi, 'readings'),\n getReadingSchema: factory.get(etainablApi, 'readings', 'schema'),\n\n // reports\n getReport: factory.getWithId<Report<string>>(etainablApi, 'reports'),\n listReports: factory.list<Report<string>>(etainablApi, 'reports'),\n updateReport: factory.update<Report<string>>(etainablApi, 'reports'),\n createReport: factory.create<Report<string>>(etainablApi, 'reports'),\n removeReport: factory.remove<Report<string>>(etainablApi, 'reports'),\n sendReport: factory.customWithId(etainablApi, 'post', 'reports', 'send'),\n\n // report templates\n getReportTemplate: factory.getWithId(etainablApi, 'report-templates'),\n listReportTemplates: factory.list(etainablApi, 'report-templates'),\n updateReportTemplate: factory.update(etainablApi, 'report-templates'),\n createReportTemplate: factory.create(etainablApi, 'report-templates'),\n removeReportTemplate: factory.remove(etainablApi, 'report-templates'),\n\n // scheduled reports\n getScheduledReport: factory.getWithId(etainablApi, 'scheduled-reports'),\n listScheduledReports: factory.list(etainablApi, 'scheduled-reports'),\n updateScheduledReport: factory.update(etainablApi, 'scheduled-reports'),\n createScheduledReport: factory.create(etainablApi, 'scheduled-reports'),\n removeScheduledReport: factory.remove(etainablApi, 'scheduled-reports'),\n sendScheduledReport: factory.customWithId(etainablApi, 'post', 'scheduled-reports', 'send'),\n\n // invoices\n getInvoice: factory.getWithId<Invoice<string>>(etainablApi, 'invoices'),\n listInvoices: factory.list<Invoice<string>>(etainablApi, 'invoices'),\n updateInvoice: factory.update<Invoice<string>>(etainablApi, 'invoices'),\n createInvoice: factory.create<Invoice<string>>(etainablApi, 'invoices'),\n removeInvoice: factory.remove<Invoice<string>>(etainablApi, 'invoices'),\n getInvoiceSchema: factory.get(etainablApi, 'invoices', 'schema'),\n\n // invoice capture\n getInvoiceCapture: factory.getWithId<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n listInvoicesCapture: factory.list<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n updateInvoiceCapture: factory.update<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n createInvoiceCapture: factory.create<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n removeInvoiceCapture: factory.remove<InvoiceCapture<string>>(etainablApi, 'invoice-capture'),\n getInvoiceCaptureSchema: factory.get(etainablApi, 'invoice-capture', 'schema'),\n\n //suppliers\n listSuppliers: factory.list<Supplier<string>>(etainablApi, 'suppliers'),\n getSupplierSchema: factory.get(etainablApi, 'suppliers', 'schema'),\n\n // import templates\n getImportTemplate: factory.getWithId(etainablApi, 'import-templates'),\n\n //data imports\n listDataIngest: factory.list<DataIngest<string>>(etainablApi, 'data-ingests'),\n updateDataIngest: factory.update<DataIngest<string>>(etainablApi, 'data-ingests'),\n createDataIngest: factory.create<DataIngest<string>>(etainablApi, 'data-ingests')\n };\n } catch (e) {\n log.error(e);\n throw e;\n }\n};\n","import winston from 'winston';\n\nexport default (namespace: string) => winston.createLogger({\n level: 'debug',\n format: winston.format.combine(\n winston.format.timestamp(),\n winston.format.json()\n ),\n defaultMeta: { service: process.env.AWS_LAMBDA_FUNCTION_NAME, script: namespace },\n transports: [\n new winston.transports.Console()\n ]\n});\n","import { MongoClient, Db } from 'mongodb';\nimport logger from './logger.js';\n\nconst log = logger('dbHelpers');\n\nlet cachedDb: Db;\n\nasync function connectToDatabase(retryAttempt: number = 1): Promise<Db> {\n if (!process.env.ETAINABL_DB_URL) throw new Error(\"ETAINABL_DB_URL is not set\");\n if (!process.env.AWS_ACCESS_KEY_ID) throw new Error(\"AWS_ACCESS_KEY_ID is not set\");\n if (!process.env.AWS_SECRET_ACCESS_KEY) throw new Error(\"AWS_SECRET_ACCESS_KEY is not set\");\n\n if (cachedDb) {\n log.debug('Using cached MongoDB connection.');\n return Promise.resolve(cachedDb);\n }\n \n const uri = `mongodb+srv://${process.env.ETAINABL_DB_URL}`;\n \n try {\n if (process.env.DB_BASIC_AUTH === 'true') {\n log.debug('Connecting to MongoDB server... (Auth: Basic)');\n\n const client = new MongoClient(uri);\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: Basic)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n }\n\n log.debug('Connecting to MongoDB server... (Auth: AWS)');\n\n const client = new MongoClient(uri, {\n auth: {\n username: process.env.AWS_ACCESS_KEY_ID,\n password: process.env.AWS_SECRET_ACCESS_KEY\n },\n authSource: '$external',\n authMechanism: 'MONGODB-AWS'\n });\n\n await client.connect();\n\n log.debug('Connected successfully to MongoDB server! (Auth: AWS)');\n\n cachedDb = client.db('etainabl');\n\n return cachedDb;\n\n } catch (e: any) {\n // Retry\n if (retryAttempt > 5) {\n console.log(`Error connecting to MongoDB server after 5 attempts...`);\n throw e;\n }\n\n console.log(`MongoDB Connection error: ${e.message}`);\n\n console.log(`Error connecting to MongoDB server... Retrying in 3 seconds... (Attempt ${retryAttempt})`);\n return connectToDatabase(retryAttempt + 1);\n }\n}\n\nexport default {\n connectToDatabase\n};","import axios from 'axios';\n\nconst postMessage = async (message: string) => {\n const url = 'https://hooks.slack.com/services/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';\n const data = {\n text: `[${(process.env.ENV || '').toUpperCase()}][${process.env.AWS_LAMBDA_FUNCTION_NAME}] ${message}`\n };\n const headers = {\n 'Content-Type': 'application/json'\n };\n return axios.post(url, data, { headers });\n};\n\nexport default {\n postMessage\n}","interface Item {\n units?: string | null;\n unit?: string | null;\n factor?: number | null;\n value: number;\n [key: string]: any; \n}\n\nexport type AccountType = 'electricity' | 'gas' | 'water' | 'waste' | 'solar' | 'heating' | 'flow' | 'cooling' | 'temperature' | 'oil' | 'other';\nexport type ETNUnit = 'kwh' | 'kg' | 'm3' | 'lbs' | 'tonnes' | 'wh' | 'mwh' | 'ft3' | 'hcf' | 'm3/h' | 'qty' | 'l' | 'C' | 'mcuf' | 'hcuf' | 'tcuf' | 'ocuf' | 'hm3' | 'tm3' | 'nm3';\nexport type BaseUnit = 'kwh' | 'm3' | 'C' | 'kg' | 'm3/h' | 'l';\nexport const accountTypeMap: { [key: string]: BaseUnit } = {\n electricity: 'kwh',\n gas: 'kwh',\n water: 'm3',\n waste: 'kg',\n solar: 'kwh',\n heating: 'kwh',\n flow: 'm3/h',\n cooling: 'kwh',\n temperature: 'C',\n oil: 'l'\n};\n\nconst unitConversionFactors: { [key: string]: any } = {\n kwh: {\n kwh: 1,\n mwh: 1000,\n wh: 0.001,\n m3: (39 * 1.02264) / 3.6,\n ft3: (0.0283 * 39 * 1.02264) / 3.6,\n hcf: (2.83 * 39 * 1.02264) / 3.6\n },\n m3: {\n m3: 1,\n l: 0.001\n },\n C: {\n C: 1\n },\n kg: {\n kg: 1,\n lbs: 0.45359237,\n tonnes: 1000\n },\n 'm3/h': {\n 'm3/h': 1\n }\n};\n\nexport const accountTypeUnitMap: { [key: string]: ETNUnit[] } = {\n electricity: ['kwh', 'mwh', 'wh'],\n gas: ['kwh', 'm3', 'ft3', 'hcf'],\n water: ['m3', 'l'],\n waste: ['kg', 'lbs', 'tonnes'],\n solar: ['kwh', 'mwh', 'wh'],\n heating: ['kwh', 'mwh', 'wh'],\n flow: ['m3/h'],\n cooling: ['kwh', 'mwh', 'wh'],\n temperature: ['C'],\n oil: ['l']\n};\n\n// Convert units to base format\nexport const convertItems = (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined): any => {\n if (!type) throw new Error('Account type is required');\n\n const baseUnit = accountTypeMap[type];\n if (!baseUnit) throw new Error(`Account type ${type} is not supported`);\n\n const convertedItems = items.map(item => {\n const factor = item.factor || accountFactor || 1;\n const units = item.units || item.unit || defaultUnits || baseUnit;\n const convertedValue = item.value * _getConversionFactor(units, baseUnit) * factor;\n return { ...item, value: convertedValue, units: baseUnit };\n });\n\n return convertedItems;\n};\n\nconst _getConversionFactor = (fromUnit: string = 'kwh', toUnit: string) => {\n const conversionFactors = unitConversionFactors[toUnit];\n\n if (!conversionFactors) {\n throw new Error(`Conversion factor base unit ${toUnit} is not defined`);\n }\n\n if (!conversionFactors[fromUnit]) {\n throw new Error(`Conversion factor from unit ${fromUnit} is not defined`);\n }\n\n return conversionFactors[fromUnit];\n};\n\nexport const checkAccountTypeVsUnits = (type: string, unit: string, additionalLog: number | '' = '') => {\n if (!type) throw new Error('Account type is required');\n if (!unit) throw new Error('Unit is required');\n\n const parsedType = type.toLowerCase().trim();\n\n const accountTypeUnits = accountTypeUnitMap[parsedType];\n if (!accountTypeUnits) throw new Error(`Account type \"${parsedType}\" is not supported ${additionalLog}`);\n\n const parsedUnit = unit.toLowerCase().trim() as ETNUnit;\n\n if (!accountTypeUnits.includes(parsedUnit)) {\n throw new Error(`Account type \"${parsedType}\" does not support unit \"${parsedUnit}\" ${additionalLog}`);\n }\n\n return { type: parsedType as AccountType, unit: parsedUnit};\n};\n","import moment from 'moment';\n\ninterface ConsumptionData {\n date: Date;\n consumption: number;\n}\n\ninterface DayNightConsumption {\n dayConsumption: number,\n nightConsumption: number,\n consumption: number\n}\n\nexport const dayNightConsumption = (data: ConsumptionData[]) => data.reduce((acc: DayNightConsumption, item: ConsumptionData): DayNightConsumption => {\n const hour = moment.utc(item.date).hour(); // End Time of HH consumption period\n\n if (hour >= 0 && hour < 7) {\n acc.nightConsumption += item.consumption;\n } else {\n acc.dayConsumption += item.consumption;\n }\n\n acc.consumption += item.consumption;\n\n return acc;\n}, {\n dayConsumption: 0,\n nightConsumption: 0,\n consumption: 0\n});\n\nexport const calcMaxConsumptionValue = (data: ConsumptionData[]) => Math.max(...data.map((item: ConsumptionData) => item.consumption));\n\nexport const calcMaxDemand = (data: ConsumptionData[]) => calcMaxConsumptionValue(data) * 2;\n\nexport const calcPeakLoad = (consumption: number, maxDemand: number, startDate: string | moment.Moment, endDate: string | moment.Moment) => {\n const days = Math.ceil(moment(endDate).diff(moment(startDate), 'days', true));\n\n return maxDemand === 0 ? 0 : ((consumption / (maxDemand * 24 * days)) * 100);\n};","import axios from 'axios';\n\nimport logger from './logger.js';\n\nconst log = logger('monitoring');\n\nexport const sendHeartbeat = async () => {\n if (!process.env.HEARTBEAT_URL || process.env.HEARTBEAT_URL.endsWith('/')) return false;\n\n try {\n await axios.post(process.env.HEARTBEAT_URL);\n\n return true;\n } catch (e: any) {\n log.warn(`Failed to send heartbeat: ${e.message || e}`);\n return false;\n }\n}","import moment from 'moment';\n\nmoment.locale('en', {\n week: {\n dow: 1\n }\n});\n\nconst getNextRunTime = (startDate: moment.Moment, schedule: any, taskTime: moment.Moment): moment.Moment => {\n const [num, freq] = schedule.frequency.split('|');\n const targetDate = moment(startDate).add(num, freq as moment.unitOfTime.Base);\n\n if (schedule.frequencyPeriod === 'first') {\n targetDate.startOf(freq as moment.unitOfTime.StartOf);\n } else if (schedule.frequencyPeriod === 'last') {\n targetDate.endOf(freq as moment.unitOfTime.StartOf);\n }\n\n const isWeekday = targetDate.isoWeekday() > 0 && targetDate.isoWeekday() < 6;\n const isSaturday = targetDate.isoWeekday() === 6;\n\n // The weekday or weekend chosen should be within the same month as the target date\n if (schedule.frequencyDay === 'weekdays' && !isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.add(isSaturday ? 2 : 1, 'days');\n } else {\n targetDate.subtract(isSaturday ? 1 : 2, 'days');\n }\n } else if (schedule.frequencyDay === 'weekends' && isWeekday) {\n if ((targetDate.date() / 7) < 2) {\n targetDate.isoWeekday(6);\n } else {\n targetDate.isoWeekday(0);\n }\n }\n\n if (taskTime.isAfter(targetDate, 'minute')) {\n return getNextRunTime(targetDate, schedule, taskTime);\n }\n\n return targetDate;\n};\n\nexport const getScheduledReportRunTimes = (schedule: any, limit = 1, taskTime = moment()): moment.Moment[] => {\n if (!schedule.startDate || !schedule.enabled) return [];\n\n const originalStartDate = moment.utc(schedule.startDate);\n\n let startDate = originalStartDate;\n\n const includeStartDate = taskTime.isSameOrBefore(originalStartDate, 'minute');\n\n let runTimes = [] as moment.Moment[];\n\n if (includeStartDate) {\n runTimes = [originalStartDate];\n }\n\n const [, freq] = schedule.frequency.split('|');\n\n if (freq === 'once') {\n const nextRunTime = runTimes[0];\n\n // If this is now beyond the start date, return an empty array\n return taskTime.isAfter(nextRunTime, 'minute') ? [] : runTimes;\n }\n\n\n const scheduleRunTimes = Array.from(Array(includeStartDate ? limit - 1 : limit).keys()).map(() => {\n const nextRunTime = getNextRunTime(startDate, schedule, taskTime);\n\n startDate = nextRunTime.hour(originalStartDate.hour()).minute(originalStartDate.minute());\n\n return nextRunTime;\n });\n\n return [...runTimes, ...scheduleRunTimes];\n};\n","import { ObjectId } from 'mongodb';\n\nexport * from './account.js';\nexport * from './asset.js';\nexport * from './automation.js';\nexport * from './company.js';\nexport * from './scraperRun.js';\nexport * from './dataIngest.js';\nexport * from './entity.js';\nexport * from './email.js';\nexport * from './global.js';\nexport * from './invoice.js';\nexport * from './invoiceCapture.js';\nexport * from './log.js';\nexport * from './reading.js';\nexport * from './report.js';\nexport * from './supplier.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AAE,OAAO,kBAAkB,OAAO,CAAC;AAExF,WAAO;AAAA,EACT,CAAC;AAED,SAAO,CAAC,GAAG,UAAU,GAAG,gBAAgB;AAC1C;;;AC7EA,IAAAC,kBAAyB;","names":["winston","axios","https","log","client","import_axios","axios","moment","import_axios","log","axios","import_moment","moment","import_mongodb"]}
|