@etainabl/nodejs-sdk 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/units.d.ts +2 -10
- package/dist/units.js +3 -6
- package/dist/units.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/units.ts +3 -7
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,6 +3,6 @@ import consumption from './consumption.js';
|
|
|
3
3
|
import logger from './logger.js';
|
|
4
4
|
import db from './db.js';
|
|
5
5
|
import slack from './slack.js';
|
|
6
|
-
import units from './units.js';
|
|
6
|
+
import * as units from './units.js';
|
|
7
7
|
export { api, logger, consumption, db, slack, units };
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,KAAK,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,OAAO,EACL,GAAG,EACH,MAAM,EACN,WAAW,EACX,EAAE,EACF,KAAK,EACL,KAAK,EACN,CAAA"}
|
package/dist/units.d.ts
CHANGED
|
@@ -13,16 +13,8 @@ export declare const convertItems: (items: Item[], type: AccountType, defaultUni
|
|
|
13
13
|
unit: string | null;
|
|
14
14
|
factor: number | null;
|
|
15
15
|
}[];
|
|
16
|
-
export declare const checkAccountTypeVsUnits: (type: AccountType, unit: ETNUnit) => {
|
|
16
|
+
export declare const checkAccountTypeVsUnits: (type: AccountType, unit: ETNUnit, additionalLog?: number | '') => {
|
|
17
17
|
type: string;
|
|
18
18
|
unit: ETNUnit;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
convertItems: (items: Item[], type: AccountType, defaultUnits: ETNUnit | undefined) => {
|
|
22
|
-
value: number;
|
|
23
|
-
units: BaseUnit;
|
|
24
|
-
unit: string | null;
|
|
25
|
-
factor: number | null;
|
|
26
|
-
}[];
|
|
27
|
-
};
|
|
28
|
-
export default _default;
|
|
20
|
+
export {};
|
package/dist/units.js
CHANGED
|
@@ -70,7 +70,7 @@ const _getConversionFactor = (fromUnit = 'kwh', toUnit) => {
|
|
|
70
70
|
}
|
|
71
71
|
return conversionFactors[fromUnit];
|
|
72
72
|
};
|
|
73
|
-
export const checkAccountTypeVsUnits = (type, unit) => {
|
|
73
|
+
export const checkAccountTypeVsUnits = (type, unit, additionalLog = '') => {
|
|
74
74
|
if (!type)
|
|
75
75
|
throw new Error('Account type is required');
|
|
76
76
|
if (!unit)
|
|
@@ -78,14 +78,11 @@ export const checkAccountTypeVsUnits = (type, unit) => {
|
|
|
78
78
|
const parsedType = type.toLowerCase().trim();
|
|
79
79
|
const accountTypeUnits = accountTypeUnitMap[parsedType];
|
|
80
80
|
if (!accountTypeUnits)
|
|
81
|
-
throw new Error(`Account type "${parsedType}" is not supported`);
|
|
81
|
+
throw new Error(`Account type "${parsedType}" is not supported ${additionalLog}`);
|
|
82
82
|
const parsedUnit = unit.toLowerCase().trim();
|
|
83
83
|
if (!accountTypeUnits.includes(parsedUnit)) {
|
|
84
|
-
throw new Error(`Account type "${parsedType}" does not support unit "${parsedUnit}"`);
|
|
84
|
+
throw new Error(`Account type "${parsedType}" does not support unit "${parsedUnit}" ${additionalLog}`);
|
|
85
85
|
}
|
|
86
86
|
return { type: parsedType, unit: parsedUnit };
|
|
87
87
|
};
|
|
88
|
-
export default {
|
|
89
|
-
convertItems
|
|
90
|
-
};
|
|
91
88
|
//# sourceMappingURL=units.js.map
|
package/dist/units.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","sourceRoot":"","sources":["../src/units.ts"],"names":[],"mappings":"AAUA,MAAM,cAAc,GAAgC;IAClD,WAAW,EAAE,KAAK;IAClB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,GAAG;CACjB,CAAC;AAEF,MAAM,qBAAqB,GAA2B;IACpD,GAAG,EAAE;QACH,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,IAAI;QACT,EAAE,EAAE,KAAK;QACT,EAAE,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG;QACxB,GAAG,EAAE,CAAC,MAAM,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG;QAClC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG;KACjC;IACD,EAAE,EAAE;QACF,EAAE,EAAE,CAAC;QACL,CAAC,EAAE,KAAK;KACT;IACD,CAAC,EAAE;QACD,CAAC,EAAE,CAAC;KACL;IACD,EAAE,EAAE;QACF,EAAE,EAAE,CAAC;QACL,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,IAAI;KACb;IACD,MAAM,EAAE;QACN,MAAM,EAAE,CAAC;KACV;CACF,CAAC;AAEF,MAAM,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K,CAAC,iBAAiB,UAAU,sBAAsB,aAAa,EAAE,CAAC,CAAC;IAEzG,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAa,CAAC;IAExD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,iBAAiB,UAAU,4BAA4B,UAAU,KAAK,aAAa,EAAE,CAAC,CAAC;KACxG;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAC,CAAC;AAC/C,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/units.ts
CHANGED
|
@@ -89,24 +89,20 @@ const _getConversionFactor = (fromUnit: string = 'kwh', toUnit: string) => {
|
|
|
89
89
|
return conversionFactors[fromUnit];
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
export const checkAccountTypeVsUnits = (type: AccountType, unit: ETNUnit) => {
|
|
92
|
+
export const checkAccountTypeVsUnits = (type: AccountType, unit: ETNUnit, additionalLog: number | '' = '') => {
|
|
93
93
|
if (!type) throw new Error('Account type is required');
|
|
94
94
|
if (!unit) throw new Error('Unit is required');
|
|
95
95
|
|
|
96
96
|
const parsedType = type.toLowerCase().trim();
|
|
97
97
|
|
|
98
98
|
const accountTypeUnits = accountTypeUnitMap[parsedType];
|
|
99
|
-
if (!accountTypeUnits) throw new Error(`Account type "${parsedType}" is not supported`);
|
|
99
|
+
if (!accountTypeUnits) throw new Error(`Account type "${parsedType}" is not supported ${additionalLog}`);
|
|
100
100
|
|
|
101
101
|
const parsedUnit = unit.toLowerCase().trim() as ETNUnit;
|
|
102
102
|
|
|
103
103
|
if (!accountTypeUnits.includes(parsedUnit)) {
|
|
104
|
-
throw new Error(`Account type "${parsedType}" does not support unit "${parsedUnit}"`);
|
|
104
|
+
throw new Error(`Account type "${parsedType}" does not support unit "${parsedUnit}" ${additionalLog}`);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
return { type: parsedType, unit: parsedUnit};
|
|
108
108
|
};
|
|
109
|
-
|
|
110
|
-
export default {
|
|
111
|
-
convertItems
|
|
112
|
-
};
|