busroot-sdk 0.0.4 → 0.0.6

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.
@@ -0,0 +1,3 @@
1
+ export declare const formattedDuration: (millis?: number, roundTo?: "millis" | "seconds" | "minutes", isShort?: boolean) => string;
2
+ export declare function formattedDateTime(input?: string, timezone?: string, includeFromNow?: boolean): string | undefined;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,EAAE,UAAS,QAAQ,GAAG,SAAS,GAAG,SAAqB,EAAE,UAAS,OAAe,WAsCjI,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,SAAkB,EAAE,cAAc,UAAQ,sBAgBnG"}
package/build/utils.js ADDED
@@ -0,0 +1,50 @@
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.formattedDuration = void 0;
7
+ exports.formattedDateTime = formattedDateTime;
8
+ const moment_timezone_1 = __importDefault(require("moment-timezone"));
9
+ const formattedDuration = (millis, roundTo = "seconds", isShort = false) => {
10
+ if (!millis) {
11
+ return "0sec";
12
+ }
13
+ const duration = moment_timezone_1.default.duration(millis);
14
+ let durationString = "";
15
+ if (duration.years() > 0) {
16
+ durationString += duration.years() + (isShort ? "Y " : "yr ");
17
+ }
18
+ if (duration.months() > 0) {
19
+ durationString += duration.months() + (isShort ? "M " : "mth ");
20
+ }
21
+ if (duration.days() > 0) {
22
+ durationString += duration.days() + (isShort ? "D " : "d ");
23
+ }
24
+ if (duration.hours() > 0) {
25
+ durationString += duration.hours() + (isShort ? "H " : "hr ");
26
+ }
27
+ if (duration.minutes() > 0) {
28
+ durationString += duration.minutes() + (isShort ? "m " : "min ");
29
+ }
30
+ if ((roundTo === "seconds" || roundTo === "millis") && duration.seconds() > 0) {
31
+ durationString += duration.seconds() + (isShort ? "s " : "sec ");
32
+ }
33
+ if (roundTo === "millis" && duration.milliseconds() > 0) {
34
+ durationString += duration.milliseconds() + (isShort ? "ms " : "ms ");
35
+ }
36
+ return durationString.trim();
37
+ };
38
+ exports.formattedDuration = formattedDuration;
39
+ function formattedDateTime(input, timezone = "Europe/London", includeFromNow = false) {
40
+ if (input == null) {
41
+ return undefined;
42
+ }
43
+ const inputMoment = moment_timezone_1.default.utc(input).tz(timezone);
44
+ const dateTimeString = inputMoment.format("HH:mm | DD-MM-YYYY");
45
+ if (includeFromNow) {
46
+ const diff = inputMoment.diff((0, moment_timezone_1.default)()).valueOf();
47
+ return dateTimeString + " (in " + (0, exports.formattedDuration)(diff, "minutes") + ")";
48
+ }
49
+ return dateTimeString;
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "busroot-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "An SDK for accessing Busroot from output.industries",
5
5
  "homepage": "https://www.output.industries",
6
6
  "main": "./build/index.js",
@@ -9,34 +9,28 @@
9
9
  "scripts": {
10
10
  "example": "ts-node -r dotenv-expand/config ./src/example.ts",
11
11
  "dev": "pnpm run lint && tsc -b --watch",
12
- "build": "pnpm run lint && tsc --build --clean && tsc --build && pnpm run rollup",
12
+ "build": "pnpm run lint && tsc --build --clean && tsc --build",
13
13
  "lint": "eslint 'src/**/*.ts'",
14
- "test": "jest",
15
- "rollup": "rollup -c"
16
- },
14
+ "test": "jest" },
17
15
  "files": [
18
16
  "build"
19
17
  ],
20
18
  "devDependencies": {
21
19
  "@jest/globals": "^29.7.0",
22
- "@rollup/plugin-commonjs": "^28.0.6",
23
- "@rollup/plugin-json": "^6.1.0",
24
- "@rollup/plugin-node-resolve": "^16.0.1",
25
- "@rollup/plugin-typescript": "^12.1.4",
26
20
  "@types/react": "^18.0.26",
27
- "busroot-common": "workspace:*",
28
- "eslint-config-custom": "workspace:*",
29
- "rollup": "^4.49.0",
21
+ "@types/chroma-js": "^3.1.2",
30
22
  "ts-jest": "^29.4.0",
31
- "tsconfig": "workspace:*",
32
23
  "typescript-eslint": "^8.38.0"
33
24
  },
34
25
  "dependencies": {
26
+ "eslint-config-prettier": "^8.10.0",
27
+ "eslint-plugin-prettier": "5.5.4",
28
+ "chroma": "^0.0.1",
29
+ "chroma-js": "^3.1.2",
35
30
  "jest": "^30.0.4",
36
- "moment": "^2.30.1",
31
+ "moment-timezone": "0.6.0",
37
32
  "mqtt": "^5.14.0",
38
33
  "react": "^18.3.1",
39
- "rollup-plugin-dts": "^6.2.3",
40
34
  "ts-node": "^10.9.1",
41
35
  "typescript": "^5.8.3",
42
36
  "zod": "^3.25.1"