@etainabl/nodejs-sdk 1.3.37 → 1.3.38
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 +15 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +116 -108
- package/dist/index.d.ts +116 -108
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -599,7 +599,8 @@ var getScheduledReportRunTimes = (schedule, limit = 1, taskTime = moment2()) =>
|
|
|
599
599
|
var utils_exports = {};
|
|
600
600
|
__export(utils_exports, {
|
|
601
601
|
automationServices: () => automationServices,
|
|
602
|
-
automationSources: () => automationSources
|
|
602
|
+
automationSources: () => automationSources,
|
|
603
|
+
wasteCategories: () => wasteCategories
|
|
603
604
|
});
|
|
604
605
|
|
|
605
606
|
// src/utils/automation.ts
|
|
@@ -812,6 +813,19 @@ var automationServices = [
|
|
|
812
813
|
}
|
|
813
814
|
];
|
|
814
815
|
|
|
816
|
+
// src/utils/account.ts
|
|
817
|
+
var wasteCategories = [
|
|
818
|
+
{ name: "General Waste", type: "EfW" },
|
|
819
|
+
{ name: "Food", type: "Compost" },
|
|
820
|
+
{ name: "Mixed Recyclables", type: "Recyclable" },
|
|
821
|
+
{ name: "WEEE", type: "EfW" },
|
|
822
|
+
{ name: "Batteries", type: "Recyclable" },
|
|
823
|
+
{ name: "Confi. Shredding", type: "EfW" },
|
|
824
|
+
{ name: "General bulky", type: "EfW" },
|
|
825
|
+
{ name: "Glass", type: "Recyclable" },
|
|
826
|
+
{ name: "Other", type: "N/A" }
|
|
827
|
+
];
|
|
828
|
+
|
|
815
829
|
// src/types/index.ts
|
|
816
830
|
import { ObjectId } from "mongodb";
|
|
817
831
|
export {
|
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/utils/index.ts","../../src/utils/automation.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 CompanyInvoiceValidationRule,\n DataIngest,\n Invoice,\n InvoiceCapture,\n InvoiceValidation,\n Log,\n Reading,\n Report,\n Supplier\n} from './types/index.js';\nimport { start } from 'repl';\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 getCompanyInvoiceValidationRules: factory.getWithId<CompanyInvoiceValidationRule<string>[]>(\n etainablApi,\n 'companies',\n 'invoice-validation-rules'\n ),\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 // invoice validation\n getInvoiceValidation: factory.getWithId<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n listInvoicesValidation: factory.list<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n updateInvoiceValidation: factory.update<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n createInvoiceValidation: factory.create<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n removeInvoiceValidation: factory.remove<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n getInvoiceValidationSchema: factory.get(etainablApi, 'invoice-validation', '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}","import type { UtilityType } from 'types/global.js';\n\ninterface 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 = UtilityType;\nexport type ETNUnit =\n | 'kwh'\n | 'kg'\n | 'm3'\n | 'lbs'\n | 'tonnes'\n | 'wh'\n | 'mwh'\n | 'ft3'\n | 'hcf'\n | 'm3/h'\n | 'qty'\n | 'l'\n | 'C'\n | 'mcuf'\n | 'hcuf'\n | 'tcuf'\n | 'ocuf'\n | 'hm3'\n | 'tm3'\n | '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","export * from './automation.js';\n","import { AutomationSource, AutomationService, AutomationServiceCategory } from 'types/automation.js';\n\nexport const automationSources: AutomationSource[] = ['ftp', 'email', 's3'];\n\nexport const automationServices: { key: AutomationService, friendly: string, category: AutomationServiceCategory }[] = [\n {\n friendly: 'Account Status',\n key: 'accountStatus',\n category: 'system'\n },\n {\n friendly: 'Autometer',\n key: 'autometer',\n category: 'company'\n },\n {\n friendly: 'BACnet',\n key: 'bacnet',\n category: 'account'\n },\n {\n friendly: 'CarloGavazziVmuc',\n key: 'carlogavazzivmuc',\n category: 'company'\n },\n {\n friendly: 'Carlo Gavazzi UWP',\n key: 'carlogavazziuwp',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Column',\n key: 'cxgmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Single Column',\n key: 'etnsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Column',\n key: 'etnmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Time Column',\n key: 'etnmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Time Column',\n key: 'cxgmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Single Column',\n key: 'cxgsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'Deepki',\n key: 'deepki',\n category: 'company'\n },\n {\n friendly: 'Crown AMR',\n key: 'crownamr',\n category: 'company'\n },\n {\n friendly: 'eLogBooks',\n key: 'elogbooks',\n category: 'account'\n },\n {\n friendly: 'Elveco',\n key: 'elveco',\n category: 'company'\n },\n {\n friendly: 'Elveco 2108',\n key: 'elveco2108',\n category: 'company'\n },\n {\n friendly: 'Gridfetch',\n key: 'gridfetch',\n category: 'account'\n },\n {\n friendly: 'IMServ Data Vision',\n key: 'imserv',\n category: 'company'\n },\n {\n friendly: 'Meter.co.uk',\n key: 'meteruk',\n category: 'account'\n },\n {\n friendly: 'MJ Church',\n key: 'mjchurch',\n category: 'company'\n },\n {\n friendly: 'MSM Solutions',\n key: 'msmsolutions',\n category: 'company'\n },\n {\n friendly: 'Niagara N4',\n key: 'niagaran4',\n category: 'company'\n },\n {\n friendly: 'Octanise',\n key: 'octanise',\n category: 'company'\n },\n {\n friendly: 'Orsis',\n key: 'orsis',\n category: 'company'\n },\n {\n friendly: 'Schneider',\n key: 'schneider',\n category: 'company'\n },\n {\n friendly: 'Schneider EGX',\n key: 'schneideregx',\n category: 'company'\n },\n {\n friendly: 'Schneider Com X',\n key: 'schneidercomx',\n category: 'company'\n },\n {\n friendly: 'Sentinel',\n key: 'sentinel',\n category: 'company'\n },\n {\n friendly: 'Siemens',\n key: 'siemens',\n category: 'company'\n },\n {\n friendly: 'Siemens Tem',\n key: 'siemenstem',\n category: 'company'\n },\n {\n friendly: 'Smart Flow',\n key: 'smartflow',\n category: 'account'\n },\n {\n friendly: 'Smartvatten',\n key: 'smartvatten',\n category: 'account'\n },\n {\n friendly: 'SMS Energy',\n key: 'sms',\n category: 'company'\n },\n {\n friendly: 'SoClean',\n key: 'soclean',\n category: 'company'\n },\n {\n friendly: 'Solarman',\n key: 'solarman',\n category: 'account'\n },\n {\n friendly: 'Solis',\n key: 'solis',\n category: 'account'\n },\n {\n friendly: 'SSE Clarity',\n key: 'sse',\n category: 'company'\n },\n {\n friendly: 'Stark',\n key: 'stark',\n category: 'company'\n },\n {\n friendly: 'Synapsys',\n key: 'synapsys',\n category: 'company'\n },\n {\n friendly: 'Trendlogs',\n key: 'trendlogs',\n category: 'company'\n },\n {\n friendly: 'Trio',\n key: 'trio',\n category: 'company'\n }\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 './invoiceValidation.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;;;ADYD,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,IAAI,IAAI,GAAG,GAAG;AAAA,EAClG;AAEA,MAAI,CAAC,IAAI,MAAM;AACX,UAAM,IAAI,MAAM,qBAAqB,IAAI,MAAM,IAAI,IAAI,GAAG,GAAG;AAAA,EACjE;AAEA,M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B;","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/utils/index.ts","../../src/utils/automation.ts","../../src/utils/account.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 CompanyInvoiceValidationRule,\n DataIngest,\n Invoice,\n InvoiceCapture,\n InvoiceValidation,\n Log,\n Reading,\n Report,\n Supplier\n} from './types/index.js';\nimport { start } from 'repl';\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 getCompanyInvoiceValidationRules: factory.getWithId<CompanyInvoiceValidationRule<string>[]>(\n etainablApi,\n 'companies',\n 'invoice-validation-rules'\n ),\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 // invoice validation\n getInvoiceValidation: factory.getWithId<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n listInvoicesValidation: factory.list<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n updateInvoiceValidation: factory.update<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n createInvoiceValidation: factory.create<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n removeInvoiceValidation: factory.remove<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n getInvoiceValidationSchema: factory.get(etainablApi, 'invoice-validation', '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}","import type { UtilityType } from 'types/global.js';\n\ninterface 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 = UtilityType;\nexport type ETNUnit =\n | 'kwh'\n | 'kg'\n | 'm3'\n | 'lbs'\n | 'tonnes'\n | 'wh'\n | 'mwh'\n | 'ft3'\n | 'hcf'\n | 'm3/h'\n | 'qty'\n | 'l'\n | 'C'\n | 'mcuf'\n | 'hcuf'\n | 'tcuf'\n | 'ocuf'\n | 'hm3'\n | 'tm3'\n | '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","export * from './automation.js';\nexport * from './account.js';\n","import { AutomationSource, AutomationService, AutomationServiceCategory } from 'types/automation.js';\n\nexport const automationSources: AutomationSource[] = ['ftp', 'email', 's3'];\n\nexport const automationServices: { key: AutomationService, friendly: string, category: AutomationServiceCategory }[] = [\n {\n friendly: 'Account Status',\n key: 'accountStatus',\n category: 'system'\n },\n {\n friendly: 'Autometer',\n key: 'autometer',\n category: 'company'\n },\n {\n friendly: 'BACnet',\n key: 'bacnet',\n category: 'account'\n },\n {\n friendly: 'CarloGavazziVmuc',\n key: 'carlogavazzivmuc',\n category: 'company'\n },\n {\n friendly: 'Carlo Gavazzi UWP',\n key: 'carlogavazziuwp',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Column',\n key: 'cxgmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Single Column',\n key: 'etnsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Column',\n key: 'etnmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Time Column',\n key: 'etnmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Time Column',\n key: 'cxgmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Single Column',\n key: 'cxgsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'Deepki',\n key: 'deepki',\n category: 'company'\n },\n {\n friendly: 'Crown AMR',\n key: 'crownamr',\n category: 'company'\n },\n {\n friendly: 'eLogBooks',\n key: 'elogbooks',\n category: 'account'\n },\n {\n friendly: 'Elveco',\n key: 'elveco',\n category: 'company'\n },\n {\n friendly: 'Elveco 2108',\n key: 'elveco2108',\n category: 'company'\n },\n {\n friendly: 'Gridfetch',\n key: 'gridfetch',\n category: 'account'\n },\n {\n friendly: 'IMServ Data Vision',\n key: 'imserv',\n category: 'company'\n },\n {\n friendly: 'Meter.co.uk',\n key: 'meteruk',\n category: 'account'\n },\n {\n friendly: 'MJ Church',\n key: 'mjchurch',\n category: 'company'\n },\n {\n friendly: 'MSM Solutions',\n key: 'msmsolutions',\n category: 'company'\n },\n {\n friendly: 'Niagara N4',\n key: 'niagaran4',\n category: 'company'\n },\n {\n friendly: 'Octanise',\n key: 'octanise',\n category: 'company'\n },\n {\n friendly: 'Orsis',\n key: 'orsis',\n category: 'company'\n },\n {\n friendly: 'Schneider',\n key: 'schneider',\n category: 'company'\n },\n {\n friendly: 'Schneider EGX',\n key: 'schneideregx',\n category: 'company'\n },\n {\n friendly: 'Schneider Com X',\n key: 'schneidercomx',\n category: 'company'\n },\n {\n friendly: 'Sentinel',\n key: 'sentinel',\n category: 'company'\n },\n {\n friendly: 'Siemens',\n key: 'siemens',\n category: 'company'\n },\n {\n friendly: 'Siemens Tem',\n key: 'siemenstem',\n category: 'company'\n },\n {\n friendly: 'Smart Flow',\n key: 'smartflow',\n category: 'account'\n },\n {\n friendly: 'Smartvatten',\n key: 'smartvatten',\n category: 'account'\n },\n {\n friendly: 'SMS Energy',\n key: 'sms',\n category: 'company'\n },\n {\n friendly: 'SoClean',\n key: 'soclean',\n category: 'company'\n },\n {\n friendly: 'Solarman',\n key: 'solarman',\n category: 'account'\n },\n {\n friendly: 'Solis',\n key: 'solis',\n category: 'account'\n },\n {\n friendly: 'SSE Clarity',\n key: 'sse',\n category: 'company'\n },\n {\n friendly: 'Stark',\n key: 'stark',\n category: 'company'\n },\n {\n friendly: 'Synapsys',\n key: 'synapsys',\n category: 'company'\n },\n {\n friendly: 'Trendlogs',\n key: 'trendlogs',\n category: 'company'\n },\n {\n friendly: 'Trio',\n key: 'trio',\n category: 'company'\n }\n];\n","import { WasteCategories, WasteTypes } from 'types/account.js';\n\nexport const wasteCategories: { name: WasteCategories, type: WasteTypes }[] = [\n { name: 'General Waste', type: 'EfW' },\n { name: 'Food', type: 'Compost' },\n { name: 'Mixed Recyclables', type: 'Recyclable' },\n { name: 'WEEE', type: 'EfW' },\n { name: 'Batteries', type: 'Recyclable' },\n { name: 'Confi. Shredding', type: 'EfW' },\n { name: 'General bulky', type: 'EfW' },\n { name: 'Glass', type: 'Recyclable' },\n { name: 'Other', type: 'N/A' }\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 './invoiceValidation.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,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AA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AACJ;;;AChNO,IAAM,kBAAiE;AAAA,EAC1E,EAAE,MAAM,iBAAiB,MAAM,MAAM;AAAA,EACrC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,EAChC,EAAE,MAAM,qBAAqB,MAAM,aAAa;AAAA,EAChD,EAAE,MAAM,QAAQ,MAAM,MAAM;AAAA,EAC5B,EAAE,MAAM,aAAa,MAAM,aAAa;AAAA,EACxC,EAAE,MAAM,oBAAoB,MAAM,MAAM;AAAA,EACxC,EAAE,MAAM,iBAAiB,MAAM,MAAM;AAAA,EACrC,EAAE,MAAM,SAAS,MAAM,aAAa;AAAA,EACpC,EAAE,MAAM,SAAS,MAAM,MAAM;AACjC;;;ACZA,SAAS,gBAAgB;","names":["log","client","axios","axios","log","axios","moment"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -24,8 +24,8 @@ declare const accountTypeUnitMap: {
|
|
|
24
24
|
[key: string]: ETNUnit[];
|
|
25
25
|
};
|
|
26
26
|
declare const convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined) => any;
|
|
27
|
-
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number |
|
|
28
|
-
type:
|
|
27
|
+
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | "") => {
|
|
28
|
+
type: AccountType;
|
|
29
29
|
unit: ETNUnit;
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -55,6 +55,8 @@ interface StatusHistory {
|
|
|
55
55
|
notes?: string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
type WasteCategories = 'General Waste' | 'Food' | 'Mixed Recyclables' | 'WEEE' | 'Batteries' | 'Confi. Shredding' | 'General bulky' | 'Glass' | 'Other';
|
|
59
|
+
type WasteTypes = 'EfW' | 'Compost' | 'Recyclable' | 'N/A';
|
|
58
60
|
interface PortalAccountSchema extends Portal {
|
|
59
61
|
invoiceFilenames: any[];
|
|
60
62
|
}
|
|
@@ -765,110 +767,110 @@ interface AuthOptions {
|
|
|
765
767
|
}
|
|
766
768
|
declare const _default$3: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
|
|
767
769
|
instance: AxiosInstance;
|
|
768
|
-
getAccount: (id: string, options?: AxiosRequestConfig
|
|
769
|
-
listAccounts: (options?: AxiosRequestConfig
|
|
770
|
-
updateAccount: (id: string, data: any, options?: AxiosRequestConfig
|
|
771
|
-
createAccount: (data: any, options?: AxiosRequestConfig
|
|
772
|
-
removeAccount: (id: string, options?: AxiosRequestConfig
|
|
773
|
-
getAccountSchema: (options?: AxiosRequestConfig
|
|
774
|
-
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig
|
|
775
|
-
getAsset: (id: string, options?: AxiosRequestConfig
|
|
776
|
-
listAssets: (options?: AxiosRequestConfig
|
|
777
|
-
updateAsset: (id: string, data: any, options?: AxiosRequestConfig
|
|
778
|
-
createAsset: (data: any, options?: AxiosRequestConfig
|
|
779
|
-
removeAsset: (id: string, options?: AxiosRequestConfig
|
|
780
|
-
getAssetSchema: (options?: AxiosRequestConfig
|
|
781
|
-
getAssetGroup: (id: string, options?: AxiosRequestConfig
|
|
782
|
-
listAssetGroups: (options?: AxiosRequestConfig
|
|
783
|
-
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig
|
|
784
|
-
createAssetGroup: (data: any, options?: AxiosRequestConfig
|
|
785
|
-
removeAssetGroup: (id: string, options?: AxiosRequestConfig
|
|
786
|
-
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig
|
|
787
|
-
getAssetGroupSchema: (options?: AxiosRequestConfig
|
|
788
|
-
getAutomation: (id: string, options?: AxiosRequestConfig
|
|
789
|
-
listAutomations: (options?: AxiosRequestConfig
|
|
790
|
-
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig
|
|
791
|
-
createAutomation: (data: any, options?: AxiosRequestConfig
|
|
792
|
-
removeAutomation: (id: string, options?: AxiosRequestConfig
|
|
793
|
-
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig
|
|
794
|
-
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig
|
|
795
|
-
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig
|
|
796
|
-
getCompany: (id: string, options?: AxiosRequestConfig
|
|
797
|
-
getCompanyInvoiceValidationRules: (id: string, options?: AxiosRequestConfig
|
|
798
|
-
getConsumption: (id: string, options?: AxiosRequestConfig
|
|
799
|
-
listConsumptions: (options?: AxiosRequestConfig
|
|
800
|
-
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig
|
|
801
|
-
createConsumption: (data: any, options?: AxiosRequestConfig
|
|
802
|
-
removeConsumption: (id: string, options?: AxiosRequestConfig
|
|
803
|
-
getConsumptionSchema: (options?: AxiosRequestConfig
|
|
804
|
-
getEmail: (id: string, options?: AxiosRequestConfig
|
|
805
|
-
listEmails: (options?: AxiosRequestConfig
|
|
806
|
-
updateEmail: (id: string, data: any, options?: AxiosRequestConfig
|
|
807
|
-
createEmail: (data: any, options?: AxiosRequestConfig
|
|
808
|
-
removeEmail: (id: string, options?: AxiosRequestConfig
|
|
809
|
-
getEmissionFactor: (id: string, options?: AxiosRequestConfig
|
|
810
|
-
listEmissionFactors: (options?: AxiosRequestConfig
|
|
811
|
-
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig
|
|
812
|
-
createEmissionFactor: (data: any, options?: AxiosRequestConfig
|
|
813
|
-
removeEmissionFactor: (id: string, options?: AxiosRequestConfig
|
|
814
|
-
getEntity: (id: string, options?: AxiosRequestConfig
|
|
815
|
-
listEntities: (options?: AxiosRequestConfig
|
|
816
|
-
updateEntity: (id: string, data: any, options?: AxiosRequestConfig
|
|
817
|
-
createEntity: (data: any, options?: AxiosRequestConfig
|
|
818
|
-
removeEntity: (id: string, options?: AxiosRequestConfig
|
|
819
|
-
getEntitiesSchema: (options?: AxiosRequestConfig
|
|
820
|
-
getLog: (id: string, options?: AxiosRequestConfig
|
|
821
|
-
listLogs: (options?: AxiosRequestConfig
|
|
822
|
-
updateLog: (id: string, data: any, options?: AxiosRequestConfig
|
|
823
|
-
createLog: (data: any, options?: AxiosRequestConfig
|
|
824
|
-
removeLog: (id: string, options?: AxiosRequestConfig
|
|
825
|
-
getReading: (id: string, options?: AxiosRequestConfig
|
|
826
|
-
listReadings: (options?: AxiosRequestConfig
|
|
827
|
-
updateReading: (id: string, data: any, options?: AxiosRequestConfig
|
|
828
|
-
createReading: (data: any, options?: AxiosRequestConfig
|
|
829
|
-
removeReading: (id: string, options?: AxiosRequestConfig
|
|
830
|
-
getReadingSchema: (options?: AxiosRequestConfig
|
|
831
|
-
getReport: (id: string, options?: AxiosRequestConfig
|
|
832
|
-
listReports: (options?: AxiosRequestConfig
|
|
833
|
-
updateReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
834
|
-
createReport: (data: any, options?: AxiosRequestConfig
|
|
835
|
-
removeReport: (id: string, options?: AxiosRequestConfig
|
|
836
|
-
sendReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
837
|
-
getReportTemplate: (id: string, options?: AxiosRequestConfig
|
|
838
|
-
listReportTemplates: (options?: AxiosRequestConfig
|
|
839
|
-
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig
|
|
840
|
-
createReportTemplate: (data: any, options?: AxiosRequestConfig
|
|
841
|
-
removeReportTemplate: (id: string, options?: AxiosRequestConfig
|
|
842
|
-
getScheduledReport: (id: string, options?: AxiosRequestConfig
|
|
843
|
-
listScheduledReports: (options?: AxiosRequestConfig
|
|
844
|
-
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
845
|
-
createScheduledReport: (data: any, options?: AxiosRequestConfig
|
|
846
|
-
removeScheduledReport: (id: string, options?: AxiosRequestConfig
|
|
847
|
-
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
848
|
-
getInvoice: (id: string, options?: AxiosRequestConfig
|
|
849
|
-
listInvoices: (options?: AxiosRequestConfig
|
|
850
|
-
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig
|
|
851
|
-
createInvoice: (data: any, options?: AxiosRequestConfig
|
|
852
|
-
removeInvoice: (id: string, options?: AxiosRequestConfig
|
|
853
|
-
getInvoiceSchema: (options?: AxiosRequestConfig
|
|
854
|
-
getInvoiceCapture: (id: string, options?: AxiosRequestConfig
|
|
855
|
-
listInvoicesCapture: (options?: AxiosRequestConfig
|
|
856
|
-
updateInvoiceCapture: (id: string, data: any, options?: AxiosRequestConfig
|
|
857
|
-
createInvoiceCapture: (data: any, options?: AxiosRequestConfig
|
|
858
|
-
removeInvoiceCapture: (id: string, options?: AxiosRequestConfig
|
|
859
|
-
getInvoiceCaptureSchema: (options?: AxiosRequestConfig
|
|
860
|
-
getInvoiceValidation: (id: string, options?: AxiosRequestConfig
|
|
861
|
-
listInvoicesValidation: (options?: AxiosRequestConfig
|
|
862
|
-
updateInvoiceValidation: (id: string, data: any, options?: AxiosRequestConfig
|
|
863
|
-
createInvoiceValidation: (data: any, options?: AxiosRequestConfig
|
|
864
|
-
removeInvoiceValidation: (id: string, options?: AxiosRequestConfig
|
|
865
|
-
getInvoiceValidationSchema: (options?: AxiosRequestConfig
|
|
866
|
-
listSuppliers: (options?: AxiosRequestConfig
|
|
867
|
-
getSupplierSchema: (options?: AxiosRequestConfig
|
|
868
|
-
getImportTemplate: (id: string, options?: AxiosRequestConfig
|
|
869
|
-
listDataIngest: (options?: AxiosRequestConfig
|
|
870
|
-
updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig
|
|
871
|
-
createDataIngest: (data: any, options?: AxiosRequestConfig
|
|
770
|
+
getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
771
|
+
listAccounts: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Account<string>>>;
|
|
772
|
+
updateAccount: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
773
|
+
createAccount: (data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
774
|
+
removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
775
|
+
getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
776
|
+
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
777
|
+
getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
778
|
+
listAssets: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Asset<string>>>;
|
|
779
|
+
updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
780
|
+
createAsset: (data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
781
|
+
removeAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
782
|
+
getAssetSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
783
|
+
getAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
784
|
+
listAssetGroups: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
785
|
+
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
786
|
+
createAssetGroup: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
787
|
+
removeAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
788
|
+
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
789
|
+
getAssetGroupSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
790
|
+
getAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
791
|
+
listAutomations: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Automation<string>>>;
|
|
792
|
+
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
793
|
+
createAutomation: (data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
794
|
+
removeAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
795
|
+
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
796
|
+
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
797
|
+
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
798
|
+
getCompany: (id: string, options?: AxiosRequestConfig) => Promise<Company<string>>;
|
|
799
|
+
getCompanyInvoiceValidationRules: (id: string, options?: AxiosRequestConfig) => Promise<CompanyInvoiceValidationRule<string>[]>;
|
|
800
|
+
getConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
801
|
+
listConsumptions: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
802
|
+
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
803
|
+
createConsumption: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
804
|
+
removeConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
805
|
+
getConsumptionSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
806
|
+
getEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
807
|
+
listEmails: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
808
|
+
updateEmail: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
809
|
+
createEmail: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
810
|
+
removeEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
811
|
+
getEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
812
|
+
listEmissionFactors: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
813
|
+
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
814
|
+
createEmissionFactor: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
815
|
+
removeEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
816
|
+
getEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
817
|
+
listEntities: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Entity<string>>>;
|
|
818
|
+
updateEntity: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
819
|
+
createEntity: (data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
820
|
+
removeEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
821
|
+
getEntitiesSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
822
|
+
getLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
823
|
+
listLogs: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Log<string>>>;
|
|
824
|
+
updateLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
825
|
+
createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
826
|
+
removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
827
|
+
getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
828
|
+
listReadings: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Reading<string>>>;
|
|
829
|
+
updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
830
|
+
createReading: (data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
831
|
+
removeReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
832
|
+
getReadingSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
833
|
+
getReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
834
|
+
listReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Report<string>>>;
|
|
835
|
+
updateReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
836
|
+
createReport: (data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
837
|
+
removeReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
838
|
+
sendReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
839
|
+
getReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
840
|
+
listReportTemplates: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
841
|
+
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
842
|
+
createReportTemplate: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
843
|
+
removeReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
844
|
+
getScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
845
|
+
listScheduledReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
846
|
+
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
847
|
+
createScheduledReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
848
|
+
removeScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
849
|
+
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
850
|
+
getInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
851
|
+
listInvoices: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Invoice<string>>>;
|
|
852
|
+
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
853
|
+
createInvoice: (data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
854
|
+
removeInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
855
|
+
getInvoiceSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
856
|
+
getInvoiceCapture: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
857
|
+
listInvoicesCapture: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<InvoiceCapture<string>>>;
|
|
858
|
+
updateInvoiceCapture: (id: string, data: any, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
859
|
+
createInvoiceCapture: (data: any, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
860
|
+
removeInvoiceCapture: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
861
|
+
getInvoiceCaptureSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
862
|
+
getInvoiceValidation: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
863
|
+
listInvoicesValidation: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<InvoiceValidation<string>>>;
|
|
864
|
+
updateInvoiceValidation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
865
|
+
createInvoiceValidation: (data: any, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
866
|
+
removeInvoiceValidation: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
867
|
+
getInvoiceValidationSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
868
|
+
listSuppliers: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Supplier<string>>>;
|
|
869
|
+
getSupplierSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
870
|
+
getImportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
871
|
+
listDataIngest: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<DataIngest<string>>>;
|
|
872
|
+
updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig) => Promise<DataIngest<string>>;
|
|
873
|
+
createDataIngest: (data: any, options?: AxiosRequestConfig) => Promise<DataIngest<string>>;
|
|
872
874
|
};
|
|
873
875
|
|
|
874
876
|
declare const _default$2: (namespace: string) => winston.Logger;
|
|
@@ -924,10 +926,16 @@ declare const automationServices: {
|
|
|
924
926
|
category: AutomationServiceCategory;
|
|
925
927
|
}[];
|
|
926
928
|
|
|
929
|
+
declare const wasteCategories: {
|
|
930
|
+
name: WasteCategories;
|
|
931
|
+
type: WasteTypes;
|
|
932
|
+
}[];
|
|
933
|
+
|
|
927
934
|
declare const index_automationServices: typeof automationServices;
|
|
928
935
|
declare const index_automationSources: typeof automationSources;
|
|
936
|
+
declare const index_wasteCategories: typeof wasteCategories;
|
|
929
937
|
declare namespace index {
|
|
930
|
-
export { index_automationServices as automationServices, index_automationSources as automationSources };
|
|
938
|
+
export { index_automationServices as automationServices, index_automationSources as automationSources, index_wasteCategories as wasteCategories };
|
|
931
939
|
}
|
|
932
940
|
|
|
933
|
-
export { type Account, type Asset, type Automation, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationResults, type InvoiceValidationRule, 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, index as utils };
|
|
941
|
+
export { type Account, type Asset, type Automation, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationResults, type InvoiceValidationRule, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type UtilityType, type WasteCategories, type WasteTypes, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units, index as utils };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ declare const accountTypeUnitMap: {
|
|
|
24
24
|
[key: string]: ETNUnit[];
|
|
25
25
|
};
|
|
26
26
|
declare const convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined, accountFactor: number | undefined) => any;
|
|
27
|
-
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number |
|
|
28
|
-
type:
|
|
27
|
+
declare const checkAccountTypeVsUnits: (type: string, unit: string, additionalLog?: number | "") => {
|
|
28
|
+
type: AccountType;
|
|
29
29
|
unit: ETNUnit;
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -55,6 +55,8 @@ interface StatusHistory {
|
|
|
55
55
|
notes?: string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
type WasteCategories = 'General Waste' | 'Food' | 'Mixed Recyclables' | 'WEEE' | 'Batteries' | 'Confi. Shredding' | 'General bulky' | 'Glass' | 'Other';
|
|
59
|
+
type WasteTypes = 'EfW' | 'Compost' | 'Recyclable' | 'N/A';
|
|
58
60
|
interface PortalAccountSchema extends Portal {
|
|
59
61
|
invoiceFilenames: any[];
|
|
60
62
|
}
|
|
@@ -765,110 +767,110 @@ interface AuthOptions {
|
|
|
765
767
|
}
|
|
766
768
|
declare const _default$3: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
|
|
767
769
|
instance: AxiosInstance;
|
|
768
|
-
getAccount: (id: string, options?: AxiosRequestConfig
|
|
769
|
-
listAccounts: (options?: AxiosRequestConfig
|
|
770
|
-
updateAccount: (id: string, data: any, options?: AxiosRequestConfig
|
|
771
|
-
createAccount: (data: any, options?: AxiosRequestConfig
|
|
772
|
-
removeAccount: (id: string, options?: AxiosRequestConfig
|
|
773
|
-
getAccountSchema: (options?: AxiosRequestConfig
|
|
774
|
-
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig
|
|
775
|
-
getAsset: (id: string, options?: AxiosRequestConfig
|
|
776
|
-
listAssets: (options?: AxiosRequestConfig
|
|
777
|
-
updateAsset: (id: string, data: any, options?: AxiosRequestConfig
|
|
778
|
-
createAsset: (data: any, options?: AxiosRequestConfig
|
|
779
|
-
removeAsset: (id: string, options?: AxiosRequestConfig
|
|
780
|
-
getAssetSchema: (options?: AxiosRequestConfig
|
|
781
|
-
getAssetGroup: (id: string, options?: AxiosRequestConfig
|
|
782
|
-
listAssetGroups: (options?: AxiosRequestConfig
|
|
783
|
-
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig
|
|
784
|
-
createAssetGroup: (data: any, options?: AxiosRequestConfig
|
|
785
|
-
removeAssetGroup: (id: string, options?: AxiosRequestConfig
|
|
786
|
-
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig
|
|
787
|
-
getAssetGroupSchema: (options?: AxiosRequestConfig
|
|
788
|
-
getAutomation: (id: string, options?: AxiosRequestConfig
|
|
789
|
-
listAutomations: (options?: AxiosRequestConfig
|
|
790
|
-
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig
|
|
791
|
-
createAutomation: (data: any, options?: AxiosRequestConfig
|
|
792
|
-
removeAutomation: (id: string, options?: AxiosRequestConfig
|
|
793
|
-
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig
|
|
794
|
-
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig
|
|
795
|
-
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig
|
|
796
|
-
getCompany: (id: string, options?: AxiosRequestConfig
|
|
797
|
-
getCompanyInvoiceValidationRules: (id: string, options?: AxiosRequestConfig
|
|
798
|
-
getConsumption: (id: string, options?: AxiosRequestConfig
|
|
799
|
-
listConsumptions: (options?: AxiosRequestConfig
|
|
800
|
-
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig
|
|
801
|
-
createConsumption: (data: any, options?: AxiosRequestConfig
|
|
802
|
-
removeConsumption: (id: string, options?: AxiosRequestConfig
|
|
803
|
-
getConsumptionSchema: (options?: AxiosRequestConfig
|
|
804
|
-
getEmail: (id: string, options?: AxiosRequestConfig
|
|
805
|
-
listEmails: (options?: AxiosRequestConfig
|
|
806
|
-
updateEmail: (id: string, data: any, options?: AxiosRequestConfig
|
|
807
|
-
createEmail: (data: any, options?: AxiosRequestConfig
|
|
808
|
-
removeEmail: (id: string, options?: AxiosRequestConfig
|
|
809
|
-
getEmissionFactor: (id: string, options?: AxiosRequestConfig
|
|
810
|
-
listEmissionFactors: (options?: AxiosRequestConfig
|
|
811
|
-
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig
|
|
812
|
-
createEmissionFactor: (data: any, options?: AxiosRequestConfig
|
|
813
|
-
removeEmissionFactor: (id: string, options?: AxiosRequestConfig
|
|
814
|
-
getEntity: (id: string, options?: AxiosRequestConfig
|
|
815
|
-
listEntities: (options?: AxiosRequestConfig
|
|
816
|
-
updateEntity: (id: string, data: any, options?: AxiosRequestConfig
|
|
817
|
-
createEntity: (data: any, options?: AxiosRequestConfig
|
|
818
|
-
removeEntity: (id: string, options?: AxiosRequestConfig
|
|
819
|
-
getEntitiesSchema: (options?: AxiosRequestConfig
|
|
820
|
-
getLog: (id: string, options?: AxiosRequestConfig
|
|
821
|
-
listLogs: (options?: AxiosRequestConfig
|
|
822
|
-
updateLog: (id: string, data: any, options?: AxiosRequestConfig
|
|
823
|
-
createLog: (data: any, options?: AxiosRequestConfig
|
|
824
|
-
removeLog: (id: string, options?: AxiosRequestConfig
|
|
825
|
-
getReading: (id: string, options?: AxiosRequestConfig
|
|
826
|
-
listReadings: (options?: AxiosRequestConfig
|
|
827
|
-
updateReading: (id: string, data: any, options?: AxiosRequestConfig
|
|
828
|
-
createReading: (data: any, options?: AxiosRequestConfig
|
|
829
|
-
removeReading: (id: string, options?: AxiosRequestConfig
|
|
830
|
-
getReadingSchema: (options?: AxiosRequestConfig
|
|
831
|
-
getReport: (id: string, options?: AxiosRequestConfig
|
|
832
|
-
listReports: (options?: AxiosRequestConfig
|
|
833
|
-
updateReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
834
|
-
createReport: (data: any, options?: AxiosRequestConfig
|
|
835
|
-
removeReport: (id: string, options?: AxiosRequestConfig
|
|
836
|
-
sendReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
837
|
-
getReportTemplate: (id: string, options?: AxiosRequestConfig
|
|
838
|
-
listReportTemplates: (options?: AxiosRequestConfig
|
|
839
|
-
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig
|
|
840
|
-
createReportTemplate: (data: any, options?: AxiosRequestConfig
|
|
841
|
-
removeReportTemplate: (id: string, options?: AxiosRequestConfig
|
|
842
|
-
getScheduledReport: (id: string, options?: AxiosRequestConfig
|
|
843
|
-
listScheduledReports: (options?: AxiosRequestConfig
|
|
844
|
-
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
845
|
-
createScheduledReport: (data: any, options?: AxiosRequestConfig
|
|
846
|
-
removeScheduledReport: (id: string, options?: AxiosRequestConfig
|
|
847
|
-
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig
|
|
848
|
-
getInvoice: (id: string, options?: AxiosRequestConfig
|
|
849
|
-
listInvoices: (options?: AxiosRequestConfig
|
|
850
|
-
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig
|
|
851
|
-
createInvoice: (data: any, options?: AxiosRequestConfig
|
|
852
|
-
removeInvoice: (id: string, options?: AxiosRequestConfig
|
|
853
|
-
getInvoiceSchema: (options?: AxiosRequestConfig
|
|
854
|
-
getInvoiceCapture: (id: string, options?: AxiosRequestConfig
|
|
855
|
-
listInvoicesCapture: (options?: AxiosRequestConfig
|
|
856
|
-
updateInvoiceCapture: (id: string, data: any, options?: AxiosRequestConfig
|
|
857
|
-
createInvoiceCapture: (data: any, options?: AxiosRequestConfig
|
|
858
|
-
removeInvoiceCapture: (id: string, options?: AxiosRequestConfig
|
|
859
|
-
getInvoiceCaptureSchema: (options?: AxiosRequestConfig
|
|
860
|
-
getInvoiceValidation: (id: string, options?: AxiosRequestConfig
|
|
861
|
-
listInvoicesValidation: (options?: AxiosRequestConfig
|
|
862
|
-
updateInvoiceValidation: (id: string, data: any, options?: AxiosRequestConfig
|
|
863
|
-
createInvoiceValidation: (data: any, options?: AxiosRequestConfig
|
|
864
|
-
removeInvoiceValidation: (id: string, options?: AxiosRequestConfig
|
|
865
|
-
getInvoiceValidationSchema: (options?: AxiosRequestConfig
|
|
866
|
-
listSuppliers: (options?: AxiosRequestConfig
|
|
867
|
-
getSupplierSchema: (options?: AxiosRequestConfig
|
|
868
|
-
getImportTemplate: (id: string, options?: AxiosRequestConfig
|
|
869
|
-
listDataIngest: (options?: AxiosRequestConfig
|
|
870
|
-
updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig
|
|
871
|
-
createDataIngest: (data: any, options?: AxiosRequestConfig
|
|
770
|
+
getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
771
|
+
listAccounts: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Account<string>>>;
|
|
772
|
+
updateAccount: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
773
|
+
createAccount: (data: any, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
774
|
+
removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
775
|
+
getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
776
|
+
invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
777
|
+
getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
778
|
+
listAssets: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Asset<string>>>;
|
|
779
|
+
updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
780
|
+
createAsset: (data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
781
|
+
removeAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
|
|
782
|
+
getAssetSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
783
|
+
getAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
784
|
+
listAssetGroups: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
785
|
+
updateAssetGroup: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
786
|
+
createAssetGroup: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
787
|
+
removeAssetGroup: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
788
|
+
getAssetGroupAssets: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
789
|
+
getAssetGroupSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
790
|
+
getAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
791
|
+
listAutomations: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Automation<string>>>;
|
|
792
|
+
updateAutomation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
793
|
+
createAutomation: (data: any, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
794
|
+
removeAutomation: (id: string, options?: AxiosRequestConfig) => Promise<Automation<string>>;
|
|
795
|
+
createAutomationLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
796
|
+
updateAutomationLog: (id: string, subId: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
797
|
+
removeAutomationLog: (id: string, subId: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
798
|
+
getCompany: (id: string, options?: AxiosRequestConfig) => Promise<Company<string>>;
|
|
799
|
+
getCompanyInvoiceValidationRules: (id: string, options?: AxiosRequestConfig) => Promise<CompanyInvoiceValidationRule<string>[]>;
|
|
800
|
+
getConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
801
|
+
listConsumptions: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
802
|
+
updateConsumption: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
803
|
+
createConsumption: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
804
|
+
removeConsumption: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
805
|
+
getConsumptionSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
806
|
+
getEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
807
|
+
listEmails: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
808
|
+
updateEmail: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
809
|
+
createEmail: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
810
|
+
removeEmail: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
811
|
+
getEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
812
|
+
listEmissionFactors: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
813
|
+
updateEmissionFactor: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
814
|
+
createEmissionFactor: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
815
|
+
removeEmissionFactor: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
816
|
+
getEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
817
|
+
listEntities: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Entity<string>>>;
|
|
818
|
+
updateEntity: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
819
|
+
createEntity: (data: any, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
820
|
+
removeEntity: (id: string, options?: AxiosRequestConfig) => Promise<Entity<string>>;
|
|
821
|
+
getEntitiesSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
822
|
+
getLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
823
|
+
listLogs: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Log<string>>>;
|
|
824
|
+
updateLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
825
|
+
createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
826
|
+
removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
|
|
827
|
+
getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
828
|
+
listReadings: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Reading<string>>>;
|
|
829
|
+
updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
830
|
+
createReading: (data: any, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
831
|
+
removeReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string>>;
|
|
832
|
+
getReadingSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
833
|
+
getReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
834
|
+
listReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Report<string>>>;
|
|
835
|
+
updateReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
836
|
+
createReport: (data: any, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
837
|
+
removeReport: (id: string, options?: AxiosRequestConfig) => Promise<Report<string>>;
|
|
838
|
+
sendReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
839
|
+
getReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
840
|
+
listReportTemplates: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
841
|
+
updateReportTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
842
|
+
createReportTemplate: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
843
|
+
removeReportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
844
|
+
getScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
845
|
+
listScheduledReports: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<any>>;
|
|
846
|
+
updateScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
847
|
+
createScheduledReport: (data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
848
|
+
removeScheduledReport: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
849
|
+
sendScheduledReport: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
850
|
+
getInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
851
|
+
listInvoices: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Invoice<string>>>;
|
|
852
|
+
updateInvoice: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
853
|
+
createInvoice: (data: any, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
854
|
+
removeInvoice: (id: string, options?: AxiosRequestConfig) => Promise<Invoice<string>>;
|
|
855
|
+
getInvoiceSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
856
|
+
getInvoiceCapture: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
857
|
+
listInvoicesCapture: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<InvoiceCapture<string>>>;
|
|
858
|
+
updateInvoiceCapture: (id: string, data: any, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
859
|
+
createInvoiceCapture: (data: any, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
860
|
+
removeInvoiceCapture: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceCapture<string>>;
|
|
861
|
+
getInvoiceCaptureSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
862
|
+
getInvoiceValidation: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
863
|
+
listInvoicesValidation: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<InvoiceValidation<string>>>;
|
|
864
|
+
updateInvoiceValidation: (id: string, data: any, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
865
|
+
createInvoiceValidation: (data: any, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
866
|
+
removeInvoiceValidation: (id: string, options?: AxiosRequestConfig) => Promise<InvoiceValidation<string>>;
|
|
867
|
+
getInvoiceValidationSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
868
|
+
listSuppliers: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Supplier<string>>>;
|
|
869
|
+
getSupplierSchema: (options?: AxiosRequestConfig) => Promise<any>;
|
|
870
|
+
getImportTemplate: (id: string, options?: AxiosRequestConfig) => Promise<any>;
|
|
871
|
+
listDataIngest: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<DataIngest<string>>>;
|
|
872
|
+
updateDataIngest: (id: string, data: any, options?: AxiosRequestConfig) => Promise<DataIngest<string>>;
|
|
873
|
+
createDataIngest: (data: any, options?: AxiosRequestConfig) => Promise<DataIngest<string>>;
|
|
872
874
|
};
|
|
873
875
|
|
|
874
876
|
declare const _default$2: (namespace: string) => winston.Logger;
|
|
@@ -924,10 +926,16 @@ declare const automationServices: {
|
|
|
924
926
|
category: AutomationServiceCategory;
|
|
925
927
|
}[];
|
|
926
928
|
|
|
929
|
+
declare const wasteCategories: {
|
|
930
|
+
name: WasteCategories;
|
|
931
|
+
type: WasteTypes;
|
|
932
|
+
}[];
|
|
933
|
+
|
|
927
934
|
declare const index_automationServices: typeof automationServices;
|
|
928
935
|
declare const index_automationSources: typeof automationSources;
|
|
936
|
+
declare const index_wasteCategories: typeof wasteCategories;
|
|
929
937
|
declare namespace index {
|
|
930
|
-
export { index_automationServices as automationServices, index_automationSources as automationSources };
|
|
938
|
+
export { index_automationServices as automationServices, index_automationSources as automationSources, index_wasteCategories as wasteCategories };
|
|
931
939
|
}
|
|
932
940
|
|
|
933
|
-
export { type Account, type Asset, type Automation, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationResults, type InvoiceValidationRule, 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, index as utils };
|
|
941
|
+
export { type Account, type Asset, type Automation, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type CreateScraperRunParams, type DataIngest, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationResults, type InvoiceValidationRule, type InvoiceValues, type Log, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ScraperRun, type Supplier, type UtilityType, type WasteCategories, type WasteTypes, _default$3 as api, consumption, _default$1 as db, _default$2 as logger, monitoring, reporting, _default as slack, units, index as utils };
|
package/dist/index.js
CHANGED
|
@@ -638,7 +638,8 @@ var getScheduledReportRunTimes = (schedule, limit = 1, taskTime = (0, import_mom
|
|
|
638
638
|
var utils_exports = {};
|
|
639
639
|
__export(utils_exports, {
|
|
640
640
|
automationServices: () => automationServices,
|
|
641
|
-
automationSources: () => automationSources
|
|
641
|
+
automationSources: () => automationSources,
|
|
642
|
+
wasteCategories: () => wasteCategories
|
|
642
643
|
});
|
|
643
644
|
|
|
644
645
|
// src/utils/automation.ts
|
|
@@ -851,6 +852,19 @@ var automationServices = [
|
|
|
851
852
|
}
|
|
852
853
|
];
|
|
853
854
|
|
|
855
|
+
// src/utils/account.ts
|
|
856
|
+
var wasteCategories = [
|
|
857
|
+
{ name: "General Waste", type: "EfW" },
|
|
858
|
+
{ name: "Food", type: "Compost" },
|
|
859
|
+
{ name: "Mixed Recyclables", type: "Recyclable" },
|
|
860
|
+
{ name: "WEEE", type: "EfW" },
|
|
861
|
+
{ name: "Batteries", type: "Recyclable" },
|
|
862
|
+
{ name: "Confi. Shredding", type: "EfW" },
|
|
863
|
+
{ name: "General bulky", type: "EfW" },
|
|
864
|
+
{ name: "Glass", type: "Recyclable" },
|
|
865
|
+
{ name: "Other", type: "N/A" }
|
|
866
|
+
];
|
|
867
|
+
|
|
854
868
|
// src/types/index.ts
|
|
855
869
|
var import_mongodb2 = require("mongodb");
|
|
856
870
|
// Annotate the CommonJS export names for ESM import in node:
|
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/utils/index.ts","../src/utils/automation.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';\nimport * as utils from './utils/index.js';\n\nexport { api, logger, consumption, monitoring, db, slack, units, reporting, utils };\n\nexport * from './types/index.js';\n","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 CompanyInvoiceValidationRule,\n DataIngest,\n Invoice,\n InvoiceCapture,\n InvoiceValidation,\n Log,\n Reading,\n Report,\n Supplier\n} from './types/index.js';\nimport { start } from 'repl';\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 getCompanyInvoiceValidationRules: factory.getWithId<CompanyInvoiceValidationRule<string>[]>(\n etainablApi,\n 'companies',\n 'invoice-validation-rules'\n ),\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 // invoice validation\n getInvoiceValidation: factory.getWithId<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n listInvoicesValidation: factory.list<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n updateInvoiceValidation: factory.update<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n createInvoiceValidation: factory.create<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n removeInvoiceValidation: factory.remove<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n getInvoiceValidationSchema: factory.get(etainablApi, 'invoice-validation', '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}","import type { UtilityType } from 'types/global.js';\n\ninterface 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 = UtilityType;\nexport type ETNUnit =\n | 'kwh'\n | 'kg'\n | 'm3'\n | 'lbs'\n | 'tonnes'\n | 'wh'\n | 'mwh'\n | 'ft3'\n | 'hcf'\n | 'm3/h'\n | 'qty'\n | 'l'\n | 'C'\n | 'mcuf'\n | 'hcuf'\n | 'tcuf'\n | 'ocuf'\n | 'hm3'\n | 'tm3'\n | '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","export * from './automation.js';\n","import { AutomationSource, AutomationService, AutomationServiceCategory } from 'types/automation.js';\n\nexport const automationSources: AutomationSource[] = ['ftp', 'email', 's3'];\n\nexport const automationServices: { key: AutomationService, friendly: string, category: AutomationServiceCategory }[] = [\n {\n friendly: 'Account Status',\n key: 'accountStatus',\n category: 'system'\n },\n {\n friendly: 'Autometer',\n key: 'autometer',\n category: 'company'\n },\n {\n friendly: 'BACnet',\n key: 'bacnet',\n category: 'account'\n },\n {\n friendly: 'CarloGavazziVmuc',\n key: 'carlogavazzivmuc',\n category: 'company'\n },\n {\n friendly: 'Carlo Gavazzi UWP',\n key: 'carlogavazziuwp',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Column',\n key: 'cxgmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Single Column',\n key: 'etnsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Column',\n key: 'etnmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Time Column',\n key: 'etnmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Time Column',\n key: 'cxgmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Single Column',\n key: 'cxgsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'Deepki',\n key: 'deepki',\n category: 'company'\n },\n {\n friendly: 'Crown AMR',\n key: 'crownamr',\n category: 'company'\n },\n {\n friendly: 'eLogBooks',\n key: 'elogbooks',\n category: 'account'\n },\n {\n friendly: 'Elveco',\n key: 'elveco',\n category: 'company'\n },\n {\n friendly: 'Elveco 2108',\n key: 'elveco2108',\n category: 'company'\n },\n {\n friendly: 'Gridfetch',\n key: 'gridfetch',\n category: 'account'\n },\n {\n friendly: 'IMServ Data Vision',\n key: 'imserv',\n category: 'company'\n },\n {\n friendly: 'Meter.co.uk',\n key: 'meteruk',\n category: 'account'\n },\n {\n friendly: 'MJ Church',\n key: 'mjchurch',\n category: 'company'\n },\n {\n friendly: 'MSM Solutions',\n key: 'msmsolutions',\n category: 'company'\n },\n {\n friendly: 'Niagara N4',\n key: 'niagaran4',\n category: 'company'\n },\n {\n friendly: 'Octanise',\n key: 'octanise',\n category: 'company'\n },\n {\n friendly: 'Orsis',\n key: 'orsis',\n category: 'company'\n },\n {\n friendly: 'Schneider',\n key: 'schneider',\n category: 'company'\n },\n {\n friendly: 'Schneider EGX',\n key: 'schneideregx',\n category: 'company'\n },\n {\n friendly: 'Schneider Com X',\n key: 'schneidercomx',\n category: 'company'\n },\n {\n friendly: 'Sentinel',\n key: 'sentinel',\n category: 'company'\n },\n {\n friendly: 'Siemens',\n key: 'siemens',\n category: 'company'\n },\n {\n friendly: 'Siemens Tem',\n key: 'siemenstem',\n category: 'company'\n },\n {\n friendly: 'Smart Flow',\n key: 'smartflow',\n category: 'account'\n },\n {\n friendly: 'Smartvatten',\n key: 'smartvatten',\n category: 'account'\n },\n {\n friendly: 'SMS Energy',\n key: 'sms',\n category: 'company'\n },\n {\n friendly: 'SoClean',\n key: 'soclean',\n category: 'company'\n },\n {\n friendly: 'Solarman',\n key: 'solarman',\n category: 'account'\n },\n {\n friendly: 'Solis',\n key: 'solis',\n category: 'account'\n },\n {\n friendly: 'SSE Clarity',\n key: 'sse',\n category: 'company'\n },\n {\n friendly: 'Stark',\n key: 'stark',\n category: 'company'\n },\n {\n friendly: 'Synapsys',\n key: 'synapsys',\n category: 'company'\n },\n {\n friendly: 'Trendlogs',\n key: 'trendlogs',\n category: 'company'\n },\n {\n friendly: 'Trio',\n key: 'trio',\n category: 'company'\n }\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 './invoiceValidation.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAElB,mBAAkB;;;ACFlB,qBAAoB;AAEpB,IAAO,iBAAQ,CAAC,cAAsB,eAAAA,QAAQ,aAAa;AAAA,EACzD,OAAO;AAAA,EACP,QAAQ,eAAAA,QAAQ,OAAO;AAAA,IACrB,eAAAA,QAAQ,OAAO,UAAU;AAAA,IACzB,eAAAA,QAAQ,OAAO,KAAK;AAAA,EACtB;AAAA,EACA,aAAa,EAAE,SAAS,QAAQ,IAAI,0BAA0B,QAAQ,UAAU;AAAA,EAChF,YAAY;AAAA,IACV,IAAI,eAAAA,QAAQ,WAAW,QAAQ;AAAA,EACjC;AACF,CAAC;;;ADYD,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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ACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AAAA,EACA;AAAA,IACI,UAAU;AAAA,IACV,KAAK;AAAA,IACL,UAAU;AAAA,EACd;AACJ;;;AClNA,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/utils/index.ts","../src/utils/automation.ts","../src/utils/account.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';\nimport * as utils from './utils/index.js';\n\nexport { api, logger, consumption, monitoring, db, slack, units, reporting, utils };\n\nexport * from './types/index.js';\n","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 CompanyInvoiceValidationRule,\n DataIngest,\n Invoice,\n InvoiceCapture,\n InvoiceValidation,\n Log,\n Reading,\n Report,\n Supplier\n} from './types/index.js';\nimport { start } from 'repl';\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 getCompanyInvoiceValidationRules: factory.getWithId<CompanyInvoiceValidationRule<string>[]>(\n etainablApi,\n 'companies',\n 'invoice-validation-rules'\n ),\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 // invoice validation\n getInvoiceValidation: factory.getWithId<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n listInvoicesValidation: factory.list<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n updateInvoiceValidation: factory.update<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n createInvoiceValidation: factory.create<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n removeInvoiceValidation: factory.remove<InvoiceValidation<string>>(etainablApi, 'invoice-validation'),\n getInvoiceValidationSchema: factory.get(etainablApi, 'invoice-validation', '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}","import type { UtilityType } from 'types/global.js';\n\ninterface 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 = UtilityType;\nexport type ETNUnit =\n | 'kwh'\n | 'kg'\n | 'm3'\n | 'lbs'\n | 'tonnes'\n | 'wh'\n | 'mwh'\n | 'ft3'\n | 'hcf'\n | 'm3/h'\n | 'qty'\n | 'l'\n | 'C'\n | 'mcuf'\n | 'hcuf'\n | 'tcuf'\n | 'ocuf'\n | 'hm3'\n | 'tm3'\n | '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","export * from './automation.js';\nexport * from './account.js';\n","import { AutomationSource, AutomationService, AutomationServiceCategory } from 'types/automation.js';\n\nexport const automationSources: AutomationSource[] = ['ftp', 'email', 's3'];\n\nexport const automationServices: { key: AutomationService, friendly: string, category: AutomationServiceCategory }[] = [\n {\n friendly: 'Account Status',\n key: 'accountStatus',\n category: 'system'\n },\n {\n friendly: 'Autometer',\n key: 'autometer',\n category: 'company'\n },\n {\n friendly: 'BACnet',\n key: 'bacnet',\n category: 'account'\n },\n {\n friendly: 'CarloGavazziVmuc',\n key: 'carlogavazzivmuc',\n category: 'company'\n },\n {\n friendly: 'Carlo Gavazzi UWP',\n key: 'carlogavazziuwp',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Column',\n key: 'cxgmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Single Column',\n key: 'etnsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Column',\n key: 'etnmulticolumn',\n category: 'company'\n },\n {\n friendly: 'ETN Multi Time Column',\n key: 'etnmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Multi Time Column',\n key: 'cxgmultitimecolumn',\n category: 'company'\n },\n {\n friendly: 'CXG Single Column',\n key: 'cxgsinglecolumn',\n category: 'company'\n },\n {\n friendly: 'Deepki',\n key: 'deepki',\n category: 'company'\n },\n {\n friendly: 'Crown AMR',\n key: 'crownamr',\n category: 'company'\n },\n {\n friendly: 'eLogBooks',\n key: 'elogbooks',\n category: 'account'\n },\n {\n friendly: 'Elveco',\n key: 'elveco',\n category: 'company'\n },\n {\n friendly: 'Elveco 2108',\n key: 'elveco2108',\n category: 'company'\n },\n {\n friendly: 'Gridfetch',\n key: 'gridfetch',\n category: 'account'\n },\n {\n friendly: 'IMServ Data Vision',\n key: 'imserv',\n category: 'company'\n },\n {\n friendly: 'Meter.co.uk',\n key: 'meteruk',\n category: 'account'\n },\n {\n friendly: 'MJ Church',\n key: 'mjchurch',\n category: 'company'\n },\n {\n friendly: 'MSM Solutions',\n key: 'msmsolutions',\n category: 'company'\n },\n {\n friendly: 'Niagara N4',\n key: 'niagaran4',\n category: 'company'\n },\n {\n friendly: 'Octanise',\n key: 'octanise',\n category: 'company'\n },\n {\n friendly: 'Orsis',\n key: 'orsis',\n category: 'company'\n },\n {\n friendly: 'Schneider',\n key: 'schneider',\n category: 'company'\n },\n {\n friendly: 'Schneider EGX',\n key: 'schneideregx',\n category: 'company'\n },\n {\n friendly: 'Schneider Com X',\n key: 'schneidercomx',\n category: 'company'\n },\n {\n friendly: 'Sentinel',\n key: 'sentinel',\n category: 'company'\n },\n {\n friendly: 'Siemens',\n key: 'siemens',\n category: 'company'\n },\n {\n friendly: 'Siemens Tem',\n key: 'siemenstem',\n category: 'company'\n },\n {\n friendly: 'Smart Flow',\n key: 'smartflow',\n category: 'account'\n },\n {\n friendly: 'Smartvatten',\n key: 'smartvatten',\n category: 'account'\n },\n {\n friendly: 'SMS Energy',\n key: 'sms',\n category: 'company'\n },\n {\n friendly: 'SoClean',\n key: 'soclean',\n category: 'company'\n },\n {\n friendly: 'Solarman',\n key: 'solarman',\n category: 'account'\n },\n {\n friendly: 'Solis',\n key: 'solis',\n category: 'account'\n },\n {\n friendly: 'SSE Clarity',\n key: 'sse',\n category: 'company'\n },\n {\n friendly: 'Stark',\n key: 'stark',\n category: 'company'\n },\n {\n friendly: 'Synapsys',\n key: 'synapsys',\n category: 'company'\n },\n {\n friendly: 'Trendlogs',\n key: 'trendlogs',\n category: 'company'\n },\n {\n friendly: 'Trio',\n key: 'trio',\n category: 'company'\n }\n];\n","import { WasteCategories, WasteTypes } from 'types/account.js';\n\nexport const wasteCategories: { name: WasteCategories, type: WasteTypes }[] = [\n { name: 'General Waste', type: 'EfW' },\n { name: 'Food', type: 'Compost' },\n { name: 'Mixed Recyclables', type: 'Recyclable' },\n { name: 'WEEE', type: 'EfW' },\n { name: 'Batteries', type: 'Recyclable' },\n { name: 'Confi. Shredding', type: 'EfW' },\n { name: 'General bulky', type: 'EfW' },\n { name: 'Glass', type: 'Recyclable' },\n { name: 'Other', type: 'N/A' }\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 './invoiceValidation.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAElB,mBAAkB;;;ACFlB,qBAAoB;AAEpB,IAAO,iBAAQ,CAAC,cAAsB,eAAAA,QAAQ,aAAa;AAAA,EACzD,OAAO;AAAA,EACP,QAAQ,eAAAA,QAAQ,OAAO;AAAA,IACrB,eAAAA,QAAQ,OAAO,UAAU;AAAA,IACzB,eAAAA,QAAQ,OAAO,KAAK;AAAA,EACtB;AAAA,EACA,aAAa,EAAE,SAAS,QAAQ,IAAI,0BAA0B,QAAQ,UAAU;AAAA,EAChF,YAAY;AAAA,IACV,IAAI,eAAAA,QAAQ,WAAW,QAAQ;AAAA,EACjC;AACF,CAAC;;;ADYD,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,IAAI,IAAI,GAAG,GAAG;AAAA,EAClG;AAEA,MAAI,CAAC,IAAI,MAAM;AACX,UAAM,IAAI,MAAM,qBAAqB,IAAI,MAAM,IAAI,IAAI,GAAG,GAAG;AAAA,EACjE;AAEA,MAAI,WAAW,CAAC,IAAI,KAAK,MAAM;AAC3B,UAAM,IAAI,MAAM,qBAAqB,IAAI,MAAM,IA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AAA,EAC1E,EAAE,MAAM,iBAAiB,MAAM,MAAM;AAAA,EACrC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,EAChC,EAAE,MAAM,qBAAqB,MAAM,aAAa;AAAA,EAChD,EAAE,MAAM,QAAQ,MAAM,MAAM;AAAA,EAC5B,EAAE,MAAM,aAAa,MAAM,aAAa;AAAA,EACxC,EAAE,MAAM,oBAAoB,MAAM,MAAM;AAAA,EACxC,EAAE,MAAM,iBAAiB,MAAM,MAAM;AAAA,EACrC,EAAE,MAAM,SAAS,MAAM,aAAa;AAAA,EACpC,EAAE,MAAM,SAAS,MAAM,MAAM;AACjC;;;ACZA,IAAAC,kBAAyB;","names":["winston","axios","https","log","client","import_axios","axios","moment","import_axios","log","axios","import_moment","moment","import_mongodb"]}
|