Compare commits
107 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fcc02ef1f | ||
|
|
1085ce870b | ||
|
|
d73d98068a | ||
|
|
b305c2ab66 | ||
|
|
e3fbe3b178 | ||
|
|
4c46c5ae6d | ||
|
|
d416e8db07 | ||
|
|
aae0e0db9d | ||
|
|
9983ba1215 | ||
|
|
872d3755d0 | ||
|
|
6d5d34e6d2 | ||
|
|
4ed43fc8a0 | ||
|
|
78f5e4a313 | ||
|
|
e32afa0f70 | ||
|
|
405ebe1e8e | ||
|
|
1fb937973c | ||
|
|
9688c9581a | ||
|
|
6b4bd73b14 | ||
|
|
e834725b1a | ||
|
|
e6a7262cf7 | ||
|
|
850eb74210 | ||
|
|
c1c5a41aa5 | ||
|
|
2b85020d52 | ||
|
|
493739238e | ||
|
|
7d96b3a82e | ||
|
|
f49c868007 | ||
|
|
ff4248961b | ||
|
|
fbc6916e2c | ||
|
|
934b287673 | ||
|
|
9f28e5eeb6 | ||
|
|
b2d4953fb6 | ||
|
|
ec4c9ec492 | ||
|
|
27dc6f2b12 | ||
|
|
845dd30b43 | ||
|
|
4509de76a2 | ||
|
|
4337372b38 | ||
|
|
cd95b63174 | ||
|
|
17e6b75ec5 | ||
|
|
bb8014ccf3 | ||
|
|
ad9cf36e98 | ||
|
|
60bcd23f5b | ||
|
|
c674d0fa72 | ||
|
|
c072f52a1a | ||
|
|
ceadd4e5a2 | ||
|
|
b32006cf10 | ||
|
|
0ab6194b43 | ||
|
|
46f359bb1e | ||
|
|
9b852dc40c | ||
|
|
a6d837f953 | ||
|
|
921882054d | ||
|
|
cdd2fcb59e | ||
|
|
8daeed6b5f | ||
|
|
6d05233a6e | ||
|
|
3dd61ab4e8 | ||
|
|
b7ea7bc552 | ||
|
|
d23c89c3c9 | ||
|
|
fd766a822c | ||
|
|
bf580c8a84 | ||
|
|
12fc98c925 | ||
|
|
3b7ef0f3ee | ||
|
|
ada7268062 | ||
|
|
b55e1dd0a6 | ||
|
|
49f04ef82f | ||
|
|
862401fa9b | ||
|
|
20e94a7e0e | ||
|
|
7f2b8ce5aa | ||
|
|
14df9ae2cd | ||
|
|
36f2535cf8 | ||
|
|
3dfa3007bf | ||
|
|
e80ff5fece | ||
|
|
694d88bb72 | ||
|
|
9569477a26 | ||
|
|
6574f8f672 | ||
|
|
ea6605f9dc | ||
|
|
953afcbc84 | ||
|
|
1d4ade717a | ||
|
|
25ff0b9903 | ||
|
|
2f8f3ea017 | ||
|
|
c3f0fd84ac | ||
|
|
64eb6fbf4e | ||
|
|
50c951e0d3 | ||
|
|
6086c6dbcc | ||
|
|
30b5c74c06 | ||
|
|
a835f220e2 | ||
|
|
a35a3e7ecb | ||
|
|
9b61909eab | ||
|
|
a3689f4cd2 | ||
|
|
bf7f3ee77c | ||
|
|
d0e9f28c8c | ||
|
|
5f9b97ca54 | ||
|
|
0103f73c39 | ||
|
|
39d45c80b9 | ||
|
|
c415912a0a | ||
|
|
868bf0dc53 | ||
|
|
94c10f13e9 | ||
|
|
9269eaaa88 | ||
|
|
07b067279e | ||
|
|
7659fa0cf4 | ||
|
|
314ef5c2ff | ||
|
|
9b02c09677 | ||
|
|
45f4ca4d63 | ||
|
|
1aade62ddb | ||
|
|
31a02625e8 | ||
|
|
16c262f2c4 | ||
|
|
dfa93723ef | ||
|
|
59900bf294 | ||
|
|
1ab38c4c87 |
22
dist/fastify.d.ts
vendored
Normal file
22
dist/fastify.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import type { AxiosInstance } from "axios";
|
||||||
|
export type ServiceResult<T = unknown> = {
|
||||||
|
result: T;
|
||||||
|
successful: boolean;
|
||||||
|
};
|
||||||
|
export declare class API_Error {
|
||||||
|
error: string;
|
||||||
|
constructor(error: string);
|
||||||
|
}
|
||||||
|
export declare abstract class BaseClient {
|
||||||
|
private axiosInstance;
|
||||||
|
constructor(axiosInstance: AxiosInstance);
|
||||||
|
getAxios(): AxiosInstance;
|
||||||
|
}
|
||||||
|
export declare abstract class BaseService<T> {
|
||||||
|
private client;
|
||||||
|
constructor(client: T);
|
||||||
|
getClient(): T;
|
||||||
|
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R>;
|
||||||
|
getErrorResult(errorMessage: string, error?: unknown): ServiceResult<string>;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=fastify.d.ts.map
|
||||||
1
dist/fastify.d.ts.map
vendored
Normal file
1
dist/fastify.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAAa,SAAS;IACF,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAChC;AAED,8BAAsB,UAAU;IAC/B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,aAAa;IAIxC,QAAQ,IAAI,aAAa;CAGzB;AAED,8BAAsB,WAAW,CAAC,CAAC;IAClC,OAAO,CAAC,MAAM,CAAI;gBAEN,MAAM,EAAE,CAAC;IAIrB,SAAS,IAAI,CAAC;IAId,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAO7D,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC;CAO5E"}
|
||||||
38
dist/fastify.js
vendored
Normal file
38
dist/fastify.js
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { logWarning } from "./logger.js";
|
||||||
|
export class API_Error {
|
||||||
|
error;
|
||||||
|
constructor(error) {
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class BaseClient {
|
||||||
|
axiosInstance;
|
||||||
|
constructor(axiosInstance) {
|
||||||
|
this.axiosInstance = axiosInstance;
|
||||||
|
}
|
||||||
|
getAxios() {
|
||||||
|
return this.axiosInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class BaseService {
|
||||||
|
client;
|
||||||
|
constructor(client) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
getClient() {
|
||||||
|
return this.client;
|
||||||
|
}
|
||||||
|
getSuccessfulResult(result) {
|
||||||
|
return {
|
||||||
|
result,
|
||||||
|
successful: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
getErrorResult(errorMessage, error) {
|
||||||
|
logWarning(errorMessage, error);
|
||||||
|
return {
|
||||||
|
result: errorMessage,
|
||||||
|
successful: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
15
dist/grist.d.ts
vendored
Normal file
15
dist/grist.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export type GristRecord_PersonalGoals = {
|
||||||
|
went_outside: boolean;
|
||||||
|
standing: boolean;
|
||||||
|
standing_goal: number;
|
||||||
|
steps: boolean;
|
||||||
|
steps_goal: number;
|
||||||
|
pushups: boolean;
|
||||||
|
squats: boolean;
|
||||||
|
leg_raises: boolean;
|
||||||
|
reps_goal: number;
|
||||||
|
stairs: boolean;
|
||||||
|
stairs_goal: number;
|
||||||
|
is_workday: boolean;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=grist.d.ts.map
|
||||||
1
dist/grist.d.ts.map
vendored
Normal file
1
dist/grist.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"grist.d.ts","sourceRoot":"","sources":["../src/grist.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG;IACvC,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB,CAAC"}
|
||||||
1
dist/grist.js
vendored
Normal file
1
dist/grist.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export {};
|
||||||
29
dist/homeassistant.d.ts
vendored
29
dist/homeassistant.d.ts
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
import type { TimeBetween } from "./timehelper";
|
||||||
export type HomeAssistantEntity = {
|
export type HomeAssistantEntity = {
|
||||||
entity_id: string;
|
entity_id: string;
|
||||||
state: string;
|
state: string;
|
||||||
@@ -9,9 +10,9 @@ export type HomeAssistantEntity = {
|
|||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
};
|
};
|
||||||
last_changed: string;
|
last_changed: string;
|
||||||
last_reported: string;
|
last_reported?: string;
|
||||||
last_updated: string;
|
last_updated?: string;
|
||||||
context: {
|
context?: {
|
||||||
id: string;
|
id: string;
|
||||||
parent_id: string | null;
|
parent_id: string | null;
|
||||||
user_id: string | null;
|
user_id: string | null;
|
||||||
@@ -19,12 +20,24 @@ export type HomeAssistantEntity = {
|
|||||||
};
|
};
|
||||||
export interface HomeAssistantDeskPositionResult {
|
export interface HomeAssistantDeskPositionResult {
|
||||||
raw: HomeAssistantEntity;
|
raw: HomeAssistantEntity;
|
||||||
asBoolean: boolean;
|
as_boolean: boolean;
|
||||||
asText: () => string;
|
last_changed: TimeBetween;
|
||||||
}
|
}
|
||||||
export type API_HA_DeskPosition = {
|
export type API_HA_DeskPosition = {
|
||||||
position: string;
|
is_standing: boolean;
|
||||||
isStanding: boolean;
|
last_changed: string;
|
||||||
standingTime: string;
|
last_changed_seconds: number;
|
||||||
|
};
|
||||||
|
export type HA_Update = {
|
||||||
|
entity_id: string;
|
||||||
|
state: string;
|
||||||
|
attributes: {
|
||||||
|
state_class?: string;
|
||||||
|
unit_of_measurement?: string;
|
||||||
|
icon?: string;
|
||||||
|
friendly_name?: string;
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
timestamp: string;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=homeassistant.d.ts.map
|
//# sourceMappingURL=homeassistant.d.ts.map
|
||||||
2
dist/homeassistant.d.ts.map
vendored
2
dist/homeassistant.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACV,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,GAAG,EAAE,mBAAmB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,mBAAmB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;CACF,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC/C,GAAG,EAAE,mBAAmB,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
||||||
3
dist/homeassistant.js
vendored
3
dist/homeassistant.js
vendored
@@ -1,2 +1 @@
|
|||||||
"use strict";
|
export {};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
|
|||||||
11
dist/homepage.d.ts
vendored
Normal file
11
dist/homepage.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import type { GristRecord_PersonalGoals } from "./grist";
|
||||||
|
import type { API_HA_DeskPosition } from "./homeassistant";
|
||||||
|
import type { StatsComponentName } from "./stats";
|
||||||
|
import type { TidalGetCurrent } from "./tidal";
|
||||||
|
export type FullInformation = Record<StatsComponentName, unknown> & {
|
||||||
|
ha_desk_position: API_HA_DeskPosition | null;
|
||||||
|
ha_temp: string | null;
|
||||||
|
tidal_current: TidalGetCurrent | null;
|
||||||
|
grist_personal_goals: GristRecord_PersonalGoals | null;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=homepage.d.ts.map
|
||||||
1
dist/homepage.d.ts.map
vendored
Normal file
1
dist/homepage.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../src/homepage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG;IACnE,gBAAgB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC7C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,oBAAoB,EAAE,yBAAyB,GAAG,IAAI,CAAC;CACvD,CAAC"}
|
||||||
1
dist/homepage.js
vendored
Normal file
1
dist/homepage.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export {};
|
||||||
13
dist/index.d.ts
vendored
13
dist/index.d.ts
vendored
@@ -1,5 +1,10 @@
|
|||||||
export * from "./homeassistant";
|
export * from "./fastify.js";
|
||||||
export * as Logger from "./logger";
|
export * from "./grist.js";
|
||||||
export * from "./tidal";
|
export * from "./homeassistant.js";
|
||||||
export * as TimeHelper from "./timehelper";
|
export * from "./homepage.js";
|
||||||
|
export * from "./logger.js";
|
||||||
|
export * from "./stats.js";
|
||||||
|
export * from "./tidal.js";
|
||||||
|
export * from "./timehelper.js";
|
||||||
|
export * from "./ws.js";
|
||||||
//# sourceMappingURL=index.d.ts.map
|
//# sourceMappingURL=index.d.ts.map
|
||||||
2
dist/index.d.ts.map
vendored
2
dist/index.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC"}
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC"}
|
||||||
52
dist/index.js
vendored
52
dist/index.js
vendored
@@ -1,43 +1,9 @@
|
|||||||
"use strict";
|
export * from "./fastify.js";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
export * from "./grist.js";
|
||||||
if (k2 === undefined) k2 = k;
|
export * from "./homeassistant.js";
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
export * from "./homepage.js";
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
export * from "./logger.js";
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
export * from "./stats.js";
|
||||||
}
|
export * from "./tidal.js";
|
||||||
Object.defineProperty(o, k2, desc);
|
export * from "./timehelper.js";
|
||||||
}) : (function(o, m, k, k2) {
|
export * from "./ws.js";
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
||||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || (function () {
|
|
||||||
var ownKeys = function(o) {
|
|
||||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
||||||
var ar = [];
|
|
||||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
||||||
return ar;
|
|
||||||
};
|
|
||||||
return ownKeys(o);
|
|
||||||
};
|
|
||||||
return function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.TimeHelper = exports.Logger = void 0;
|
|
||||||
__exportStar(require("./homeassistant"), exports);
|
|
||||||
exports.Logger = __importStar(require("./logger"));
|
|
||||||
__exportStar(require("./tidal"), exports);
|
|
||||||
exports.TimeHelper = __importStar(require("./timehelper"));
|
|
||||||
|
|||||||
34
dist/logger.js
vendored
34
dist/logger.js
vendored
@@ -1,29 +1,19 @@
|
|||||||
"use strict";
|
import axios from "axios";
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
import chalk from "chalk";
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
export function logError(...args) {
|
||||||
};
|
console.error(chalk.red("ERROR:"), ...args);
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.logError = logError;
|
|
||||||
exports.logWarning = logWarning;
|
|
||||||
exports.logSuccess = logSuccess;
|
|
||||||
exports.logInfo = logInfo;
|
|
||||||
exports.printNetworkError = printNetworkError;
|
|
||||||
const axios_1 = __importDefault(require("axios"));
|
|
||||||
const chalk_1 = __importDefault(require("chalk"));
|
|
||||||
function logError(...args) {
|
|
||||||
console.error(chalk_1.default.red("ERROR:"), ...args);
|
|
||||||
}
|
}
|
||||||
function logWarning(...args) {
|
export function logWarning(...args) {
|
||||||
console.warn(chalk_1.default.yellow("WARNING:"), ...args);
|
console.warn(chalk.yellow("WARNING:"), ...args);
|
||||||
}
|
}
|
||||||
function logSuccess(...args) {
|
export function logSuccess(...args) {
|
||||||
console.info(chalk_1.default.green("SUCCESS:"), ...args);
|
console.info(chalk.green("SUCCESS:"), ...args);
|
||||||
}
|
}
|
||||||
function logInfo(...args) {
|
export function logInfo(...args) {
|
||||||
console.info(chalk_1.default.cyan("INFO:"), ...args);
|
console.info(chalk.cyan("INFO:"), ...args);
|
||||||
}
|
}
|
||||||
function printNetworkError(error) {
|
export function printNetworkError(error) {
|
||||||
if (axios_1.default.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
logError("Axios error details:", {
|
logError("Axios error details:", {
|
||||||
message: error.message,
|
message: error.message,
|
||||||
status: error.response?.status,
|
status: error.response?.status,
|
||||||
|
|||||||
20
dist/stats.d.ts
vendored
Normal file
20
dist/stats.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
export declare const StatsComponent: {
|
||||||
|
readonly HA_DESK_POSITION: "ha_desk_position";
|
||||||
|
readonly HA_TEMP: "ha_temp";
|
||||||
|
readonly TIDAL_CURRENT: "tidal_current";
|
||||||
|
readonly GRIST_PERSONAL_GOALS: "grist_personal_goals";
|
||||||
|
};
|
||||||
|
export type StatsComponentName = (typeof StatsComponent)[keyof typeof StatsComponent];
|
||||||
|
export type ComponentUpdate = {
|
||||||
|
component: StatsComponentName;
|
||||||
|
data: unknown;
|
||||||
|
};
|
||||||
|
export type StepRow = {
|
||||||
|
year: string;
|
||||||
|
steps: number;
|
||||||
|
};
|
||||||
|
export declare function createComponentUpdate(component: StatsComponentName, data: unknown): {
|
||||||
|
component: StatsComponentName;
|
||||||
|
data: unknown;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=stats.d.ts.map
|
||||||
1
dist/stats.d.ts.map
vendored
Normal file
1
dist/stats.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../src/stats.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC7B,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,qBAAqB,CACpC,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE,OAAO;;;EAMb"}
|
||||||
12
dist/stats.js
vendored
Normal file
12
dist/stats.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export const StatsComponent = {
|
||||||
|
HA_DESK_POSITION: "ha_desk_position",
|
||||||
|
HA_TEMP: "ha_temp",
|
||||||
|
TIDAL_CURRENT: "tidal_current",
|
||||||
|
GRIST_PERSONAL_GOALS: "grist_personal_goals",
|
||||||
|
};
|
||||||
|
export function createComponentUpdate(component, data) {
|
||||||
|
return {
|
||||||
|
component: component,
|
||||||
|
data: data,
|
||||||
|
};
|
||||||
|
}
|
||||||
18
dist/tidal.d.ts
vendored
18
dist/tidal.d.ts
vendored
@@ -1,14 +1,26 @@
|
|||||||
export type TidalSong = {
|
export type TidalGetCurrent = {
|
||||||
title: string;
|
title: string;
|
||||||
artists: string;
|
artists: string;
|
||||||
|
artistsArray: string[];
|
||||||
album: string;
|
album: string;
|
||||||
playingFrom: string;
|
playingFrom: string;
|
||||||
status: "playing" | "paused";
|
status: "playing" | "paused";
|
||||||
url: string;
|
url: string;
|
||||||
current: string;
|
current: string;
|
||||||
|
currentInSeconds: number;
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
durationInSeconds: number;
|
||||||
export type TidalVolume = {
|
image: string;
|
||||||
|
icon: string;
|
||||||
|
localAlbumArt: string;
|
||||||
|
favorite: boolean;
|
||||||
|
trackId: string;
|
||||||
volume: number;
|
volume: number;
|
||||||
|
player: {
|
||||||
|
status: "playing" | "paused";
|
||||||
|
shuffle: boolean;
|
||||||
|
repeat: "all" | "single" | "none";
|
||||||
|
};
|
||||||
|
artist: string;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=tidal.d.ts.map
|
//# sourceMappingURL=tidal.d.ts.map
|
||||||
2
dist/tidal.d.ts.map
vendored
2
dist/tidal.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"tidal.d.ts","sourceRoot":"","sources":["../src/tidal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
{"version":3,"file":"tidal.d.ts","sourceRoot":"","sources":["../src/tidal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACP,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC7B,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;KAClC,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;CACf,CAAC"}
|
||||||
3
dist/tidal.js
vendored
3
dist/tidal.js
vendored
@@ -1,2 +1 @@
|
|||||||
"use strict";
|
export {};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
|
|||||||
11
dist/timehelper.d.ts
vendored
11
dist/timehelper.d.ts
vendored
@@ -1,13 +1,16 @@
|
|||||||
export declare class TimeSpan {
|
export declare class TimeSpan {
|
||||||
private start;
|
private start;
|
||||||
private end;
|
private end;
|
||||||
constructor(timeSpanStr: string);
|
private timeZone;
|
||||||
|
constructor(timeSpanStr: string, timeZone: string);
|
||||||
private parseTime;
|
private parseTime;
|
||||||
contains(timestamp?: number): boolean;
|
contains(timestamp?: number): boolean;
|
||||||
}
|
}
|
||||||
export declare function calculateSecondsBetween(start: number, end: number): {
|
export interface TimeBetween {
|
||||||
seconds: number;
|
seconds: number;
|
||||||
toReadable: (roundToMinutes?: boolean) => string;
|
toReadable: (roundToMinutes?: boolean) => string;
|
||||||
};
|
}
|
||||||
export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string;
|
export declare function calculateSecondsBetween(start: number, end: number): TimeBetween;
|
||||||
|
export declare function formatSecondsToDHMS(secs: number, roundToMinutes?: boolean): string;
|
||||||
|
export declare function formatSecondsToMS(s: number): string;
|
||||||
//# sourceMappingURL=timehelper.d.ts.map
|
//# sourceMappingURL=timehelper.d.ts.map
|
||||||
2
dist/timehelper.d.ts.map
vendored
2
dist/timehelper.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;gBAEpC,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAgBlD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAA;CAAE,CAOvE;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"}
|
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACpB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;IAChD,OAAO,CAAC,QAAQ,CAAC;gBAEL,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOjD,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAqBjD;AAED,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CACjD;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,WAAW,CAOb;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC7B,MAAM,CAmBR;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAInD"}
|
||||||
50
dist/timehelper.js
vendored
50
dist/timehelper.js
vendored
@@ -1,13 +1,12 @@
|
|||||||
"use strict";
|
export class TimeSpan {
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
start;
|
||||||
exports.TimeSpan = void 0;
|
end;
|
||||||
exports.calculateSecondsBetween = calculateSecondsBetween;
|
timeZone;
|
||||||
exports.secondsToReadable = secondsToReadable;
|
constructor(timeSpanStr, timeZone) {
|
||||||
class TimeSpan {
|
|
||||||
constructor(timeSpanStr) {
|
|
||||||
const [startStr, endStr] = timeSpanStr.split("-");
|
const [startStr, endStr] = timeSpanStr.split("-");
|
||||||
this.start = this.parseTime(startStr);
|
this.start = this.parseTime(startStr);
|
||||||
this.end = this.parseTime(endStr);
|
this.end = this.parseTime(endStr);
|
||||||
|
this.timeZone = timeZone;
|
||||||
}
|
}
|
||||||
parseTime(timeStr) {
|
parseTime(timeStr) {
|
||||||
const [hours, minutes] = timeStr.split(":").map(Number);
|
const [hours, minutes] = timeStr.split(":").map(Number);
|
||||||
@@ -15,8 +14,13 @@ class TimeSpan {
|
|||||||
}
|
}
|
||||||
contains(timestamp = Date.now()) {
|
contains(timestamp = Date.now()) {
|
||||||
const date = new Date(timestamp);
|
const date = new Date(timestamp);
|
||||||
const hours = date.getHours();
|
const berlinTimeStr = date.toLocaleString("de-DE", {
|
||||||
const minutes = date.getMinutes();
|
timeZone: this.timeZone, // "Europe/Berlin"
|
||||||
|
hour12: false,
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
});
|
||||||
|
const [hours, minutes] = berlinTimeStr.split(":").map(Number);
|
||||||
const currentMinutes = hours * 60 + minutes;
|
const currentMinutes = hours * 60 + minutes;
|
||||||
const startMinutes = this.start.hours * 60 + this.start.minutes;
|
const startMinutes = this.start.hours * 60 + this.start.minutes;
|
||||||
const endMinutes = this.end.hours * 60 + this.end.minutes;
|
const endMinutes = this.end.hours * 60 + this.end.minutes;
|
||||||
@@ -28,23 +32,27 @@ class TimeSpan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.TimeSpan = TimeSpan;
|
export function calculateSecondsBetween(start, end) {
|
||||||
function calculateSecondsBetween(start, end) {
|
|
||||||
const seconds = Math.max(60, (end - start) / 1000);
|
const seconds = Math.max(60, (end - start) / 1000);
|
||||||
return {
|
return {
|
||||||
seconds,
|
seconds,
|
||||||
toReadable: (roundToMinutes) => secondsToReadable(seconds, roundToMinutes),
|
toReadable: (roundToMinutes) => formatSecondsToDHMS(seconds, roundToMinutes),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function secondsToReadable(secs, roundToMinutes = false) {
|
export function formatSecondsToDHMS(secs, roundToMinutes = false) {
|
||||||
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
||||||
var days = Math.floor(totalSeconds / (3600 * 24));
|
const days = Math.floor(totalSeconds / (3600 * 24));
|
||||||
var hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
||||||
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||||
var seconds = Math.floor(totalSeconds % 60);
|
const seconds = Math.floor(totalSeconds % 60);
|
||||||
var dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
const dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
||||||
var hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
const hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
||||||
var minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
const minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
||||||
var secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
const secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
||||||
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, "");
|
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, "");
|
||||||
}
|
}
|
||||||
|
export function formatSecondsToMS(s) {
|
||||||
|
const mins = Math.floor(s / 60);
|
||||||
|
const secs = s % 60;
|
||||||
|
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
|
||||||
|
}
|
||||||
|
|||||||
8
dist/timespan.d.ts
vendored
8
dist/timespan.d.ts
vendored
@@ -1,8 +0,0 @@
|
|||||||
export declare class TimeSpan {
|
|
||||||
private start;
|
|
||||||
private end;
|
|
||||||
constructor(timeSpanStr: string);
|
|
||||||
private parseTime;
|
|
||||||
contains(timestamp?: number): boolean;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=timespan.d.ts.map
|
|
||||||
1
dist/timespan.d.ts.map
vendored
1
dist/timespan.d.ts.map
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"timespan.d.ts","sourceRoot":"","sources":["../src/timespan.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;gBAEpC,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAgBlD"}
|
|
||||||
29
dist/timespan.js
vendored
29
dist/timespan.js
vendored
@@ -1,29 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.TimeSpan = void 0;
|
|
||||||
class TimeSpan {
|
|
||||||
constructor(timeSpanStr) {
|
|
||||||
const [startStr, endStr] = timeSpanStr.split("-");
|
|
||||||
this.start = this.parseTime(startStr);
|
|
||||||
this.end = this.parseTime(endStr);
|
|
||||||
}
|
|
||||||
parseTime(timeStr) {
|
|
||||||
const [hours, minutes] = timeStr.split(":").map(Number);
|
|
||||||
return { hours, minutes };
|
|
||||||
}
|
|
||||||
contains(timestamp = Date.now()) {
|
|
||||||
const date = new Date(timestamp);
|
|
||||||
const hours = date.getHours();
|
|
||||||
const minutes = date.getMinutes();
|
|
||||||
const currentMinutes = hours * 60 + minutes;
|
|
||||||
const startMinutes = this.start.hours * 60 + this.start.minutes;
|
|
||||||
const endMinutes = this.end.hours * 60 + this.end.minutes;
|
|
||||||
if (startMinutes > endMinutes) {
|
|
||||||
return currentMinutes >= startMinutes || currentMinutes < endMinutes;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return currentMinutes >= startMinutes && currentMinutes < endMinutes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.TimeSpan = TimeSpan;
|
|
||||||
40
dist/types.d.ts
vendored
40
dist/types.d.ts
vendored
@@ -1,40 +0,0 @@
|
|||||||
export interface User {
|
|
||||||
id: string;
|
|
||||||
email: string;
|
|
||||||
name: string;
|
|
||||||
createdAt: Date;
|
|
||||||
updatedAt: Date;
|
|
||||||
}
|
|
||||||
export interface UserProfile extends User {
|
|
||||||
bio?: string;
|
|
||||||
avatarUrl?: string;
|
|
||||||
}
|
|
||||||
export interface ApiResponse<T> {
|
|
||||||
success: boolean;
|
|
||||||
data?: T;
|
|
||||||
error?: string;
|
|
||||||
message?: string;
|
|
||||||
}
|
|
||||||
export interface PaginatedResponse<T> extends ApiResponse<T[]> {
|
|
||||||
page: number;
|
|
||||||
pageSize: number;
|
|
||||||
totalPages: number;
|
|
||||||
totalItems: number;
|
|
||||||
}
|
|
||||||
export type Nullable<T> = T | null;
|
|
||||||
export type Optional<T> = T | undefined;
|
|
||||||
export type ID = string | number;
|
|
||||||
export declare enum Status {
|
|
||||||
Active = "active",
|
|
||||||
Inactive = "inactive",
|
|
||||||
Pending = "pending",
|
|
||||||
Archived = "archived"
|
|
||||||
}
|
|
||||||
export declare enum HttpMethod {
|
|
||||||
GET = "GET",
|
|
||||||
POST = "POST",
|
|
||||||
PUT = "PUT",
|
|
||||||
PATCH = "PATCH",
|
|
||||||
DELETE = "DELETE"
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=types.d.ts.map
|
|
||||||
1
dist/types.d.ts.map
vendored
1
dist/types.d.ts.map
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,EAAE,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACnC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AACxC,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AAGjC,oBAAY,MAAM;IAChB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;CAClB"}
|
|
||||||
19
dist/types.js
vendored
19
dist/types.js
vendored
@@ -1,19 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.HttpMethod = exports.Status = void 0;
|
|
||||||
// Status enums
|
|
||||||
var Status;
|
|
||||||
(function (Status) {
|
|
||||||
Status["Active"] = "active";
|
|
||||||
Status["Inactive"] = "inactive";
|
|
||||||
Status["Pending"] = "pending";
|
|
||||||
Status["Archived"] = "archived";
|
|
||||||
})(Status || (exports.Status = Status = {}));
|
|
||||||
var HttpMethod;
|
|
||||||
(function (HttpMethod) {
|
|
||||||
HttpMethod["GET"] = "GET";
|
|
||||||
HttpMethod["POST"] = "POST";
|
|
||||||
HttpMethod["PUT"] = "PUT";
|
|
||||||
HttpMethod["PATCH"] = "PATCH";
|
|
||||||
HttpMethod["DELETE"] = "DELETE";
|
|
||||||
})(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
|
|
||||||
3
dist/utility.d.ts
vendored
3
dist/utility.d.ts
vendored
@@ -1,3 +0,0 @@
|
|||||||
export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string;
|
|
||||||
export declare function printNetworkError(error: unknown): void;
|
|
||||||
//# sourceMappingURL=utility.d.ts.map
|
|
||||||
1
dist/utility.d.ts.map
vendored
1
dist/utility.d.ts.map
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,QAY/C"}
|
|
||||||
35
dist/utility.js
vendored
35
dist/utility.js
vendored
@@ -1,35 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.secondsToReadable = secondsToReadable;
|
|
||||||
exports.printNetworkError = printNetworkError;
|
|
||||||
const axios_1 = __importDefault(require("axios"));
|
|
||||||
const logger_1 = require("./logger");
|
|
||||||
function secondsToReadable(secs, roundToMinutes = false) {
|
|
||||||
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
|
||||||
var days = Math.floor(totalSeconds / (3600 * 24));
|
|
||||||
var hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
|
||||||
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
||||||
var seconds = Math.floor(totalSeconds % 60);
|
|
||||||
var dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
|
||||||
var hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
|
||||||
var minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
|
||||||
var secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
|
||||||
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, "");
|
|
||||||
}
|
|
||||||
function printNetworkError(error) {
|
|
||||||
if (axios_1.default.isAxiosError(error)) {
|
|
||||||
(0, logger_1.logError)("Axios error details:", {
|
|
||||||
message: error.message,
|
|
||||||
status: error.response?.status,
|
|
||||||
statusText: error.response?.statusText,
|
|
||||||
data: error.response?.data,
|
|
||||||
url: error.config?.url,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
(0, logger_1.logError)("Unexpected error:", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
14
dist/ws.d.ts
vendored
Normal file
14
dist/ws.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import type { WebSocket } from "ws";
|
||||||
|
export type WsEvent = {
|
||||||
|
type: string;
|
||||||
|
data?: unknown;
|
||||||
|
};
|
||||||
|
export type WsClientChangeCallback = (clients: number) => void;
|
||||||
|
export declare class WsService {
|
||||||
|
private clients;
|
||||||
|
addClient(ws: WebSocket): void;
|
||||||
|
removeClient(ws: WebSocket): void;
|
||||||
|
broadcast(message: WsEvent): void;
|
||||||
|
getClientCount(): number;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=ws.d.ts.map
|
||||||
1
dist/ws.d.ts.map
vendored
Normal file
1
dist/ws.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../src/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAGpC,MAAM,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAE/D,qBAAa,SAAS;IACrB,OAAO,CAAC,OAAO,CAA6B;IAE5C,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAK9B,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAKjC,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMjC,cAAc,IAAI,MAAM;CAGxB"}
|
||||||
20
dist/ws.js
vendored
Normal file
20
dist/ws.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { logInfo } from "./logger.js";
|
||||||
|
export class WsService {
|
||||||
|
clients = new Set();
|
||||||
|
addClient(ws) {
|
||||||
|
this.clients.add(ws);
|
||||||
|
logInfo(`Socket connected. Total clients: ${this.clients.size}`);
|
||||||
|
}
|
||||||
|
removeClient(ws) {
|
||||||
|
this.clients.delete(ws);
|
||||||
|
logInfo(`Socket disconnected. Total clients: ${this.clients.size}`);
|
||||||
|
}
|
||||||
|
broadcast(message) {
|
||||||
|
this.clients.forEach((socket) => {
|
||||||
|
socket.send(JSON.stringify(message));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getClientCount() {
|
||||||
|
return this.clients.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
143
package-lock.json
generated
143
package-lock.json
generated
@@ -1,15 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.0.8",
|
"version": "1.10.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.0.8",
|
"version": "1.10.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"chalk": "^5.6.2"
|
"chalk": "^5.6.2",
|
||||||
|
"rimraf": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.1",
|
||||||
@@ -19,16 +21,45 @@
|
|||||||
"typescript": ">=4.5.0"
|
"typescript": ">=4.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@isaacs/balanced-match": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@isaacs/brace-expansion": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@isaacs/balanced-match": "^4.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.10.1",
|
"version": "24.10.11",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.11.tgz",
|
||||||
"integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==",
|
"integrity": "sha512-/Af7O8r1frCVgOz0I62jWUtMohJ0/ZQU/ZoketltOJPZpnb17yoNc9BSoVuV9qlaIXJiPNOpsfq4ByFajSArNQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~7.16.0"
|
"undici-types": "~7.16.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/ws": {
|
||||||
|
"version": "8.18.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
|
||||||
|
"integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/asynckit": {
|
"node_modules/asynckit": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||||
@@ -36,9 +67,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.13.2",
|
"version": "1.13.4",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.13.4.tgz",
|
||||||
"integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==",
|
"integrity": "sha512-1wVkUaAO6WyaYtCkcYCOx12ZgpGf9Zif+qXa4n+oYzK558YryKqiL6UWwd5DqiH3VRW0GYhTZQ/vlgJrCoNQlg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.6",
|
"follow-redirects": "^1.15.6",
|
||||||
@@ -233,6 +264,23 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/glob": {
|
||||||
|
"version": "13.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.1.tgz",
|
||||||
|
"integrity": "sha512-B7U/vJpE3DkJ5WXTgTpTRN63uV42DseiXXKMwG14LQBXmsdeIoHAPbU/MEo6II0k5ED74uc2ZGTC6MwHFQhF6w==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"minimatch": "^10.1.2",
|
||||||
|
"minipass": "^7.1.2",
|
||||||
|
"path-scurry": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/gopd": {
|
"node_modules/gopd": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||||
@@ -284,6 +332,15 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/lru-cache": {
|
||||||
|
"version": "11.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.5.tgz",
|
||||||
|
"integrity": "sha512-vFrFJkWtJvJnD5hg+hJvVE8Lh/TcMzKnTgCWmtBipwI5yLX/iX+5UB2tfuyODF5E7k9xEzMdYgGqaSb1c0c5Yw==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/math-intrinsics": {
|
"node_modules/math-intrinsics": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||||
@@ -314,12 +371,77 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/minimatch": {
|
||||||
|
"version": "10.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.2.tgz",
|
||||||
|
"integrity": "sha512-fu656aJ0n2kcXwsnwnv9g24tkU5uSmOlTjd6WyyaKm2Z+h1qmY6bAjrcaIxF/BslFqbZ8UBtbJi7KgQOZD2PTw==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@isaacs/brace-expansion": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minipass": {
|
||||||
|
"version": "7.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
||||||
|
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/package-json-from-dist": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
|
||||||
|
"license": "BlueOak-1.0.0"
|
||||||
|
},
|
||||||
|
"node_modules/path-scurry": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^11.0.0",
|
||||||
|
"minipass": "^7.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/proxy-from-env": {
|
"node_modules/proxy-from-env": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/rimraf": {
|
||||||
|
"version": "6.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.2.tgz",
|
||||||
|
"integrity": "sha512-cFCkPslJv7BAXJsYlK1dZsbP8/ZNLkCAQ0bi1hf5EKX2QHegmDFEFA6QhuYJlk7UDdc+02JjO80YSOrWPpw06g==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"glob": "^13.0.0",
|
||||||
|
"package-json-from-dist": "^1.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"rimraf": "dist/esm/bin.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.9.3",
|
"version": "5.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||||
@@ -338,7 +460,6 @@
|
|||||||
"version": "7.16.0",
|
"version": "7.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
|
||||||
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
|
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
package.json
13
package.json
@@ -1,17 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.0.8",
|
"version": "1.10.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "npm run clean && tsc",
|
||||||
"prepublishOnly": "npm run build",
|
"clean": "rimraf dist"
|
||||||
"clean": "rm -rf dist",
|
|
||||||
"update": "npm update @dpu/types"
|
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"typescript",
|
"typescript",
|
||||||
@@ -27,7 +26,9 @@
|
|||||||
"typescript": ">=4.5.0"
|
"typescript": ">=4.5.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"chalk": "^5.6.2"
|
"chalk": "^5.6.2",
|
||||||
|
"rimraf": "^6.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/fastify.ts
Normal file
50
src/fastify.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import type { AxiosInstance } from "axios";
|
||||||
|
import { logWarning } from "./logger.js";
|
||||||
|
|
||||||
|
export type ServiceResult<T = unknown> = {
|
||||||
|
result: T;
|
||||||
|
successful: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class API_Error {
|
||||||
|
constructor(public error: string) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class BaseClient {
|
||||||
|
private axiosInstance: AxiosInstance;
|
||||||
|
|
||||||
|
constructor(axiosInstance: AxiosInstance) {
|
||||||
|
this.axiosInstance = axiosInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAxios(): AxiosInstance {
|
||||||
|
return this.axiosInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class BaseService<T> {
|
||||||
|
private client: T;
|
||||||
|
|
||||||
|
constructor(client: T) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
|
||||||
|
getClient(): T {
|
||||||
|
return this.client;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R> {
|
||||||
|
return {
|
||||||
|
result,
|
||||||
|
successful: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getErrorResult(errorMessage: string, error?: unknown): ServiceResult<string> {
|
||||||
|
logWarning(errorMessage, error);
|
||||||
|
return {
|
||||||
|
result: errorMessage,
|
||||||
|
successful: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/grist.ts
Normal file
14
src/grist.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
export type GristRecord_PersonalGoals = {
|
||||||
|
went_outside: boolean;
|
||||||
|
standing: boolean;
|
||||||
|
standing_goal: number;
|
||||||
|
steps: boolean;
|
||||||
|
steps_goal: number;
|
||||||
|
pushups: boolean;
|
||||||
|
squats: boolean;
|
||||||
|
leg_raises: boolean;
|
||||||
|
reps_goal: number;
|
||||||
|
stairs: boolean;
|
||||||
|
stairs_goal: number;
|
||||||
|
is_workday: boolean;
|
||||||
|
};
|
||||||
@@ -1,31 +1,46 @@
|
|||||||
|
import type { TimeBetween } from "./timehelper";
|
||||||
|
|
||||||
export type HomeAssistantEntity = {
|
export type HomeAssistantEntity = {
|
||||||
entity_id: string;
|
entity_id: string;
|
||||||
state: string;
|
state: string;
|
||||||
attributes: {
|
attributes: {
|
||||||
state_class?: string;
|
state_class?: string;
|
||||||
unit_of_measurement?: string;
|
unit_of_measurement?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
friendly_name?: string;
|
friendly_name?: string;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
};
|
};
|
||||||
last_changed: string; // datetime string
|
last_changed: string; // datetime string
|
||||||
last_reported: string; // datetime string
|
last_reported?: string; // datetime string
|
||||||
last_updated: string; // datetime string
|
last_updated?: string; // datetime string
|
||||||
context: {
|
context?: {
|
||||||
id: string;
|
id: string;
|
||||||
parent_id: string | null;
|
parent_id: string | null;
|
||||||
user_id: string | null;
|
user_id: string | null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface HomeAssistantDeskPositionResult {
|
export interface HomeAssistantDeskPositionResult {
|
||||||
raw: HomeAssistantEntity;
|
raw: HomeAssistantEntity;
|
||||||
asBoolean: boolean;
|
as_boolean: boolean;
|
||||||
asText: () => string;
|
last_changed: TimeBetween;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type API_HA_DeskPosition = {
|
export type API_HA_DeskPosition = {
|
||||||
position: string;
|
is_standing: boolean;
|
||||||
isStanding: boolean;
|
last_changed: string;
|
||||||
standingTime: string;
|
last_changed_seconds: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type HA_Update = {
|
||||||
|
entity_id: string;
|
||||||
|
state: string;
|
||||||
|
attributes: {
|
||||||
|
state_class?: string;
|
||||||
|
unit_of_measurement?: string;
|
||||||
|
icon?: string;
|
||||||
|
friendly_name?: string;
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
timestamp: string; // datetime string
|
||||||
};
|
};
|
||||||
|
|||||||
11
src/homepage.ts
Normal file
11
src/homepage.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import type { GristRecord_PersonalGoals } from "./grist";
|
||||||
|
import type { API_HA_DeskPosition } from "./homeassistant";
|
||||||
|
import type { StatsComponentName } from "./stats";
|
||||||
|
import type { TidalGetCurrent } from "./tidal";
|
||||||
|
|
||||||
|
export type FullInformation = Record<StatsComponentName, unknown> & {
|
||||||
|
ha_desk_position: API_HA_DeskPosition | null;
|
||||||
|
ha_temp: string | null;
|
||||||
|
tidal_current: TidalGetCurrent | null;
|
||||||
|
grist_personal_goals: GristRecord_PersonalGoals | null;
|
||||||
|
};
|
||||||
13
src/index.ts
13
src/index.ts
@@ -1,4 +1,9 @@
|
|||||||
export * from "./homeassistant";
|
export * from "./fastify.js";
|
||||||
export * as Logger from "./logger";
|
export * from "./grist.js";
|
||||||
export * from "./tidal";
|
export * from "./homeassistant.js";
|
||||||
export * as TimeHelper from "./timehelper";
|
export * from "./homepage.js";
|
||||||
|
export * from "./logger.js";
|
||||||
|
export * from "./stats.js";
|
||||||
|
export * from "./tidal.js";
|
||||||
|
export * from "./timehelper.js";
|
||||||
|
export * from "./ws.js";
|
||||||
|
|||||||
@@ -2,31 +2,31 @@ import axios from "axios";
|
|||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
|
|
||||||
export function logError(...args: unknown[]) {
|
export function logError(...args: unknown[]) {
|
||||||
console.error(chalk.red("ERROR:"), ...args);
|
console.error(chalk.red("ERROR:"), ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logWarning(...args: unknown[]) {
|
export function logWarning(...args: unknown[]) {
|
||||||
console.warn(chalk.yellow("WARNING:"), ...args);
|
console.warn(chalk.yellow("WARNING:"), ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logSuccess(...args: unknown[]) {
|
export function logSuccess(...args: unknown[]) {
|
||||||
console.info(chalk.green("SUCCESS:"), ...args);
|
console.info(chalk.green("SUCCESS:"), ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logInfo(...args: unknown[]) {
|
export function logInfo(...args: unknown[]) {
|
||||||
console.info(chalk.cyan("INFO:"), ...args);
|
console.info(chalk.cyan("INFO:"), ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function printNetworkError(error: unknown) {
|
export function printNetworkError(error: unknown) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
logError("Axios error details:", {
|
logError("Axios error details:", {
|
||||||
message: error.message,
|
message: error.message,
|
||||||
status: error.response?.status,
|
status: error.response?.status,
|
||||||
statusText: error.response?.statusText,
|
statusText: error.response?.statusText,
|
||||||
data: error.response?.data,
|
data: error.response?.data,
|
||||||
url: error.config?.url,
|
url: error.config?.url,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logError("Unexpected error:", error);
|
logError("Unexpected error:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
src/stats.ts
Normal file
29
src/stats.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
export const StatsComponent = {
|
||||||
|
HA_DESK_POSITION: "ha_desk_position",
|
||||||
|
HA_TEMP: "ha_temp",
|
||||||
|
TIDAL_CURRENT: "tidal_current",
|
||||||
|
GRIST_PERSONAL_GOALS: "grist_personal_goals",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type StatsComponentName =
|
||||||
|
(typeof StatsComponent)[keyof typeof StatsComponent];
|
||||||
|
|
||||||
|
export type ComponentUpdate = {
|
||||||
|
component: StatsComponentName;
|
||||||
|
data: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StepRow = {
|
||||||
|
year: string;
|
||||||
|
steps: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function createComponentUpdate(
|
||||||
|
component: StatsComponentName,
|
||||||
|
data: unknown,
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
component: component,
|
||||||
|
data: data,
|
||||||
|
};
|
||||||
|
}
|
||||||
37
src/tidal.ts
37
src/tidal.ts
@@ -1,14 +1,25 @@
|
|||||||
export type TidalSong = {
|
export type TidalGetCurrent = {
|
||||||
title: string;
|
title: string;
|
||||||
artists: string;
|
artists: string;
|
||||||
album: string;
|
artistsArray: string[];
|
||||||
playingFrom: string;
|
album: string;
|
||||||
status: "playing" | "paused";
|
playingFrom: string;
|
||||||
url: string;
|
status: "playing" | "paused";
|
||||||
current: string;
|
url: string;
|
||||||
duration: string;
|
current: string;
|
||||||
};
|
currentInSeconds: number;
|
||||||
|
duration: string;
|
||||||
export type TidalVolume = {
|
durationInSeconds: number;
|
||||||
volume: number;
|
image: string;
|
||||||
|
icon: string;
|
||||||
|
localAlbumArt: string;
|
||||||
|
favorite: boolean;
|
||||||
|
trackId: string;
|
||||||
|
volume: number;
|
||||||
|
player: {
|
||||||
|
status: "playing" | "paused";
|
||||||
|
shuffle: boolean;
|
||||||
|
repeat: "all" | "single" | "none";
|
||||||
|
};
|
||||||
|
artist: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,68 +1,86 @@
|
|||||||
export class TimeSpan {
|
export class TimeSpan {
|
||||||
private start: { hours: number; minutes: number };
|
private start: { hours: number; minutes: number };
|
||||||
private end: { hours: number; minutes: number };
|
private end: { hours: number; minutes: number };
|
||||||
|
private timeZone;
|
||||||
|
|
||||||
constructor(timeSpanStr: string) {
|
constructor(timeSpanStr: string, timeZone: string) {
|
||||||
const [startStr, endStr] = timeSpanStr.split("-");
|
const [startStr, endStr] = timeSpanStr.split("-");
|
||||||
this.start = this.parseTime(startStr);
|
this.start = this.parseTime(startStr);
|
||||||
this.end = this.parseTime(endStr);
|
this.end = this.parseTime(endStr);
|
||||||
}
|
this.timeZone = timeZone;
|
||||||
|
}
|
||||||
|
|
||||||
private parseTime(timeStr: string) {
|
private parseTime(timeStr: string) {
|
||||||
const [hours, minutes] = timeStr.split(":").map(Number);
|
const [hours, minutes] = timeStr.split(":").map(Number);
|
||||||
return { hours, minutes };
|
return { hours, minutes };
|
||||||
}
|
}
|
||||||
|
|
||||||
contains(timestamp: number = Date.now()): boolean {
|
contains(timestamp: number = Date.now()): boolean {
|
||||||
const date = new Date(timestamp);
|
const date = new Date(timestamp);
|
||||||
|
|
||||||
const hours = date.getHours();
|
const berlinTimeStr = date.toLocaleString("de-DE", {
|
||||||
const minutes = date.getMinutes();
|
timeZone: this.timeZone, // "Europe/Berlin"
|
||||||
const currentMinutes = hours * 60 + minutes;
|
hour12: false,
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
});
|
||||||
|
|
||||||
const startMinutes = this.start.hours * 60 + this.start.minutes;
|
const [hours, minutes] = berlinTimeStr.split(":").map(Number);
|
||||||
const endMinutes = this.end.hours * 60 + this.end.minutes;
|
const currentMinutes = hours * 60 + minutes;
|
||||||
|
const startMinutes = this.start.hours * 60 + this.start.minutes;
|
||||||
|
const endMinutes = this.end.hours * 60 + this.end.minutes;
|
||||||
|
|
||||||
if (startMinutes > endMinutes) {
|
if (startMinutes > endMinutes) {
|
||||||
return currentMinutes >= startMinutes || currentMinutes < endMinutes;
|
return currentMinutes >= startMinutes || currentMinutes < endMinutes;
|
||||||
} else {
|
} else {
|
||||||
return currentMinutes >= startMinutes && currentMinutes < endMinutes;
|
return currentMinutes >= startMinutes && currentMinutes < endMinutes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TimeBetween {
|
||||||
|
seconds: number;
|
||||||
|
toReadable: (roundToMinutes?: boolean) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateSecondsBetween(
|
export function calculateSecondsBetween(
|
||||||
start: number,
|
start: number,
|
||||||
end: number,
|
end: number,
|
||||||
): { seconds: number; toReadable: (roundToMinutes?: boolean) => string } {
|
): TimeBetween {
|
||||||
const seconds = Math.max(60, (end - start) / 1000);
|
const seconds = Math.max(60, (end - start) / 1000);
|
||||||
return {
|
return {
|
||||||
seconds,
|
seconds,
|
||||||
toReadable: (roundToMinutes?: boolean) =>
|
toReadable: (roundToMinutes?: boolean) =>
|
||||||
secondsToReadable(seconds, roundToMinutes),
|
formatSecondsToDHMS(seconds, roundToMinutes),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function secondsToReadable(
|
export function formatSecondsToDHMS(
|
||||||
secs: number,
|
secs: number,
|
||||||
roundToMinutes: boolean = false,
|
roundToMinutes: boolean = false,
|
||||||
): string {
|
): string {
|
||||||
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
||||||
|
|
||||||
var days = Math.floor(totalSeconds / (3600 * 24));
|
const days = Math.floor(totalSeconds / (3600 * 24));
|
||||||
var hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
||||||
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||||
var seconds = Math.floor(totalSeconds % 60);
|
const seconds = Math.floor(totalSeconds % 60);
|
||||||
|
|
||||||
var dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
const dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
||||||
var hourDisplay =
|
const hourDisplay =
|
||||||
hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
||||||
var minuteDisplay =
|
const minuteDisplay =
|
||||||
minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
||||||
var secondDisplay =
|
const secondDisplay =
|
||||||
seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
||||||
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(
|
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(
|
||||||
/,\s*$/,
|
/,\s*$/,
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatSecondsToMS(s: number): string {
|
||||||
|
const mins = Math.floor(s / 60);
|
||||||
|
const secs = s % 60;
|
||||||
|
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/ws.ts
Normal file
33
src/ws.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import type { WebSocket } from "ws";
|
||||||
|
import { logInfo } from "./logger.js";
|
||||||
|
|
||||||
|
export type WsEvent = {
|
||||||
|
type: string;
|
||||||
|
data?: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type WsClientChangeCallback = (clients: number) => void;
|
||||||
|
|
||||||
|
export class WsService {
|
||||||
|
private clients: Set<WebSocket> = new Set();
|
||||||
|
|
||||||
|
addClient(ws: WebSocket): void {
|
||||||
|
this.clients.add(ws);
|
||||||
|
logInfo(`Socket connected. Total clients: ${this.clients.size}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeClient(ws: WebSocket): void {
|
||||||
|
this.clients.delete(ws);
|
||||||
|
logInfo(`Socket disconnected. Total clients: ${this.clients.size}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
broadcast(message: WsEvent): void {
|
||||||
|
this.clients.forEach((socket) => {
|
||||||
|
socket.send(JSON.stringify(message));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getClientCount(): number {
|
||||||
|
return this.clients.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"target": "ES2022",
|
||||||
"module": "commonjs",
|
"module": "ES2022",
|
||||||
"lib": ["ES2020"],
|
"lib": ["ES2022"],
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user