@metriport/shared 0.1.10 → 0.1.11-alpha2.0
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/common/duration.d.ts +5 -0
- package/dist/common/duration.d.ts.map +1 -0
- package/dist/common/duration.js +30 -0
- package/dist/common/duration.js.map +1 -0
- package/dist/common/numbers.d.ts +4 -0
- package/dist/common/numbers.d.ts.map +1 -0
- package/dist/common/numbers.js +17 -0
- package/dist/common/numbers.js.map +1 -0
- package/dist/common/types.d.ts +6 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +14 -0
- package/dist/common/types.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/common/duration.ts"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,CAAC,EACjC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5D,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logDuration = void 0;
|
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
+
const duration_1 = __importDefault(require("dayjs/plugin/duration"));
|
|
9
|
+
const numbers_1 = require("./numbers");
|
|
10
|
+
dayjs_1.default.extend(duration_1.default);
|
|
11
|
+
async function logDuration(fn, options) {
|
|
12
|
+
const { log = console.log, withMinutes = true } = options ?? {};
|
|
13
|
+
const startedAt = Date.now();
|
|
14
|
+
let success = false;
|
|
15
|
+
try {
|
|
16
|
+
const res = await fn();
|
|
17
|
+
success = true;
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
const duration = Date.now() - startedAt;
|
|
22
|
+
const durationMin = withMinutes
|
|
23
|
+
? ` / ${(0, numbers_1.formatNumber)(dayjs_1.default.duration(duration).asMinutes())} min`
|
|
24
|
+
: "";
|
|
25
|
+
const successMsg = success ? "" : " (with errors)";
|
|
26
|
+
log(`It took ${duration} ms${durationMin} to execute${successMsg}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.logDuration = logDuration;
|
|
30
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/common/duration.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,qEAA6C;AAC7C,uCAAyC;AAEzC,eAAK,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAC;AAEhB,KAAK,UAAU,WAAW,CAC/B,EAAoB,EACpB,OAA6D;IAE7D,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAChE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,EAAE,EAAE,CAAC;QACvB,OAAO,GAAG,IAAI,CAAC;QACf,OAAO,GAAG,CAAC;KACZ;YAAS;QACR,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QACxC,MAAM,WAAW,GAAG,WAAW;YAC7B,CAAC,CAAC,MAAM,IAAA,sBAAY,EAAC,eAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC,MAAM;YAChE,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;QACnD,GAAG,CAAC,WAAW,QAAQ,MAAM,WAAW,cAAc,UAAU,EAAE,CAAC,CAAC;KACrE;AACH,CAAC;AApBD,kCAoBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/common/numbers.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE5D;AAGD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAI,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomInt = exports.formatNumber = exports.getFloatValue = void 0;
|
|
4
|
+
function getFloatValue(value) {
|
|
5
|
+
return typeof value === "string" ? parseFloat(value) : value;
|
|
6
|
+
}
|
|
7
|
+
exports.getFloatValue = getFloatValue;
|
|
8
|
+
// Truncate the number to 2 decimal places
|
|
9
|
+
function formatNumber(num) {
|
|
10
|
+
return Math.floor(num * 100) / 100;
|
|
11
|
+
}
|
|
12
|
+
exports.formatNumber = formatNumber;
|
|
13
|
+
function randomInt(maxDigits = 2) {
|
|
14
|
+
return Math.floor(Math.random() * Math.pow(10, maxDigits));
|
|
15
|
+
}
|
|
16
|
+
exports.randomInt = randomInt;
|
|
17
|
+
//# sourceMappingURL=numbers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/common/numbers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAC,KAAsB;IAClD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC;AAFD,sCAEC;AAED,0CAA0C;AAC1C,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACrC,CAAC;AAFD,oCAEC;AAED,SAAgB,SAAS,CAAC,SAAS,GAAG,CAAC;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AAC7D,CAAC;AAFD,8BAEC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type AtLeastOne<T> = {
|
|
2
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
3
|
+
}[keyof T];
|
|
4
|
+
export declare function stringToBoolean(value?: string): boolean | undefined;
|
|
5
|
+
export declare function stringToBooleanRequired(value: string): boolean;
|
|
6
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC/E,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAGnE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringToBooleanRequired = exports.stringToBoolean = void 0;
|
|
4
|
+
function stringToBoolean(value) {
|
|
5
|
+
if (!value)
|
|
6
|
+
return undefined;
|
|
7
|
+
return stringToBooleanRequired(value);
|
|
8
|
+
}
|
|
9
|
+
exports.stringToBoolean = stringToBoolean;
|
|
10
|
+
function stringToBooleanRequired(value) {
|
|
11
|
+
return value.toLowerCase().trim() === "true";
|
|
12
|
+
}
|
|
13
|
+
exports.stringToBooleanRequired = stringToBooleanRequired;
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":";;;AAKA,SAAgB,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AAHD,0CAGC;AAED,SAAgB,uBAAuB,CAAC,KAAa;IACnD,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;AAC/C,CAAC;AAFD,0DAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metriport/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11-alpha2.0",
|
|
4
4
|
"description": "Common code shared across packages - by Metriport Inc.",
|
|
5
5
|
"author": "Metriport Inc. <contact@metriport.com>",
|
|
6
6
|
"homepage": "https://metriport.com/",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"test": "jest --runInBand --detectOpenHandles --passWithNoTests",
|
|
52
52
|
"test:e2e": "E2E=true jest --runInBand --detectOpenHandles --passWithNoTests"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "757c987245b69cac1f5640d884032fbd84523975"
|
|
55
55
|
}
|