import * as THREE from 'three'; import type { ErrorMessageKey } from './i18n'; import type { DoorPosition, MovementState, SENSOR } from './sensors'; import type { ErrorType, ObjectType, Severity } from './status'; export type TMovementSensor = `${MovementState}`; export type TDoorPositions = `${DoorPosition}`; /** * The API types values per sensor, so a value can be a number as well as a * string. Timestamps are ISO strings; `null` means there is no neighbour. */ export interface ILiftStatusRow { date_value: string; duration?: number; next_ts?: string | null; next_val?: string | number | null; pos: number; prev_duration?: number; prev_ts?: string | null; prev_val?: string | number | null; ts: string; val?: string | number | null; start?: number; end?: number; from_ts?: string; to_ts?: string; } export interface ILiftStatusSensor { id: string; type: string; name: string; internal: string; high_volume: string; } export interface ILiftStatusSensorResponse { rows: ILiftStatusRow[]; sensor: ILiftStatusSensor; } /** * The `POST /liftstatus/auth` response. Its shape depends on the token type: * a Sense JWT gives `sensecloud`, a LiftStatus Classic session gives `liftstatus`. */ export type ILiftStatusAuth = ISenseCloudAuth | ILiftStatusSessionAuth; export interface ISenseCloudAuth { type: 'sensecloud'; tokenData: ITokenData; /** The API may leave out this or any of its sections. */ response?: IAuthResponse; /** The token's Sense object. Older API versions leave it out; system tokens give `null`. */ target?: IAuthResponseTarget | null; } export interface ILiftStatusSessionAuth { type: 'liftstatus'; response: ILiftStatusSessionAuthResponse; /** The lift's Sense object. Older API versions leave it out. */ target?: IAuthResponseTarget | null; } /** * The object a token addresses, the same shape for both token types. A failed * lookup leaves `es_number` and/or `capability` `null`. */ export interface IAuthResponseTarget { otype: string; oid: string; es_number: string | null; capability: IAuthResponseCapability | null; /** Which commands the token may send, after the API's per-token-type rules. */ commands: TCommandPermissions; } export interface ILiftStatusSessionAuthResponse { user: { id: string; roles: string[] }; organisation: { id: string; type: string }; lift?: { id: string; alarm_organisation_id: string }; env?: string; permissions?: IAuthResponsePermissions; } /** The data permissions of a session, from `permissions.lift_flow.data`. */ export type ILiftStatusSessionPermissions = ILiftFlowData; /** * The detail of the `lsSession` event `` emits once it has * authenticated. `ok` is false when the access token is missing or invalid; * `error` then says why. `ok` only means the token was accepted: the data * loads after the event, and its errors go to the store. */ export interface ILiftStatusSession { ok: boolean; esNumber?: string; objectId?: string; objectType?: ObjectType; permissions: ILiftStatusSessionPermissions; isAdmin: boolean; hasResetContactCapability: boolean; error?: ILiftStatusWebComponentError; } export interface ITokenData { org: string; oid: string; otype: string; cmds: boolean; /** Set for an admin organisation's token for an internal identifier. The API then allows every command. */ platform?: boolean; iat: number; exp: number; aud: string; iss: string; sub: string; } export interface IAuthResponse { es_number?: string; capability?: IAuthResponseCapability; permissions?: IAuthResponsePermissions; } export interface IAuthResponseCapability { lift_controller?: ILiftController; commands?: IAuthResponseCommands; } export interface IAuthResponseCommands { reset_contact?: IResetContactCommand; } export interface IResetContactCommand { output: string; state: string; duration: string; } export interface ILiftController { type: string; } /** `true` for every command, `false` for none, or a map per command. */ export type TCommandPermissions = boolean | Partial>; export interface IAuthResponsePermissions { lift_flow?: ILiftFlow; /** Passed through from the portal server unchecked, so `null` can arrive too. */ commands?: TCommandPermissions | null; } export interface ILiftFlow { data?: ILiftFlowData; } export interface ILiftFlowData { realtime: boolean; statuses: boolean; counters: boolean; history: boolean; } export interface ILiftStatusValues { /** Sense module verbonden met SenseCloud, de verbinding tussen de Sense Module en SenseCloud. (1 is verbonden) */ 10?: number; /** Mobiele signaalsterkte, waarde in procenten */ 23?: number; /** SenseCloud Round Trip Time - afgelopen uur (in ms) */ 25?: number; /** SenseCloud Round Trip Time - afgelopen 24 uur (in ms) */ 26?: number; /** Besturing verbinding met Sense module gezond (1 indien gezond) */ 50?: boolean; /** Energiemeter 3-fase verbinding gezond (multiPhaseEnergySensorCommunicationHealthy, 1 indien gezond) */ 54?: number | null; /** Energiemeter 1-fase verbinding gezond (singlePhaseEnergySensorCommunicationHealthy, 1 indien gezond) */ 55?: number | null; /** Rittenteller */ 100?: number; /** Installatie onbeschikbaar (1 indien onbeschikbaar) */ 103?: boolean; /** Bezoek */ 104?: boolean; /** Onbeschikbaar */ 105?: boolean; /** Onbeschikbaar buiten bezoek */ 106?: boolean; /** Noodstop verzamel */ 107?: boolean; /** Voeding installatie */ 108?: boolean; /** Energieverbruik teller */ 109?: number; /** Status reset contact */ 110?: boolean; /** Storingscontact */ 201?: boolean; /** Data storingsverzamelsensor met beschikbaarheidsimpact */ 210?: boolean; /** Data storingsverzamelsensor zonder beschikbaarheidsimpact */ 211?: boolean; /** Technisch beschikbaar */ 212?: boolean; /** Bewegingstoestand */ 500?: TMovementSensor; /** Huidige stopplaats (geopende deuren) */ 501?: number; /** Deur positie (status) - voor */ 502?: TDoorPositions; /** Deur positie (status) - achter */ 503?: TDoorPositions; /** Deurlijn */ 505?: boolean; /** Temperatuurregelaar (-100 t/m 200) */ 506?: number; /** Richtingveranderingenteller */ 507?: number; /** Deurcyclus teller - deur voor */ 508?: number; /** Deurcyclus teller - deur achter */ 509?: number; /** Deurcyclus teller per stopplaats - deur voor */ 510?: string; // TODO: this is a counter LIST, figure out what this sensor returns. we can prob do better than string /** Deurcyclus teller per stopplaats - deur achter */ 511?: string; // TODO: this is a counter LIST, figure out what this sensor returns. we can prob do better than string /** Stopplaatsteller */ 512?: string; // TODO: this is a counter LIST, figure out what this sensor returns. we can prob do better than string /** Statuscodes * Comma separated list of: * identifier:timestamp:status * * Where the identifier is the status code identifier, * timestamp is Unix timestamp in milliseconds and * status is 1 or 0 based on the status being active or not. */ 513?: string; /** Laatst gepasseerde stopplaats */ 514?: number; /** Huidige stopplaats */ 515?: number | string; /** Deurbeweging teller - deur voor */ 516?: number; /** Deurbeweging teller - deur achter */ 517?: number; /** Deurbeweging teller per stopplaats - deur voor */ 518?: string; // TODO: this is a counter LIST, figure out what this sensor returns. we can prob do better than string /** Deurbeweging teller per stopplaats - deur achter */ 519?: string; // TODO: this is a counter LIST, figure out what this sensor returns. we can prob do better than string /** Deur pendeling teller - deur voor */ 520?: number; /** Deur pendeling teller - deur achter */ 521?: number; /** Deur pendeling teller per stopplaats - deur voor */ 522?: string; // TODO: this is a counter LIST, figure out what this sensor returns. we can prob do better than string /** Deur pendeling teller per stopplaats - deur voor */ 523?: number; // TODO: this is a counter LIST, figure out what this sensor returns. we can prob do better than string /** Besturing verbonden met Sense module (1 indien verbonden) */ 524?: number; /** Na oproep geen reactie (Carcall request no response) */ 550?: boolean; /** Meer deurbewegingen dan verwacht op een stopplaats binnen een tijdsperiode */ 551?: boolean; /** Besturing informatie */ 590?: string; /** Maximaal aantal stopplaatsen dat de lift bedient (waarde is nul-gebaseerd) */ 591?: number; /** Lift plugin: naam van de geladen plugin, gelijk aan de prefix van de S513-codes die de plugin produceert */ 592?: string; } export type SensorId = keyof ILiftStatusValues; export interface ILiftStatusUpdated { /** Sense module verbonden met SenseCloud, de verbinding tussen de Sense Module en SenseCloud. (1 is verbonden) */ 10?: number; /** Mobiele signaalsterkte, waarde in procenten */ 23?: number; /** SenseCloud Round Trip Time - afgelopen uur (in ms) */ 25?: number; /** SenseCloud Round Trip Time - afgelopen 24 uur (in ms) */ 26?: number; /** Besturing verbinding met Sense module gezond (1 indien gezond) */ 50?: number; /** Energiemeter 3-fase verbinding gezond (multiPhaseEnergySensorCommunicationHealthy, 1 indien gezond) */ 54?: number; /** Energiemeter 1-fase verbinding gezond (singlePhaseEnergySensorCommunicationHealthy, 1 indien gezond) */ 55?: number; /** Rittenteller */ 100?: number; /** Installatie onbeschikbaar (1 indien onbeschikbaar) */ 103?: number; /** Bezoek */ 104?: number; /** Onbeschikbaar */ 105?: number; /** Onbeschikbaar buiten bezoek */ 106?: number; /** Noodstop verzamel */ 107?: number; /** Voeding installatie */ 108?: number; /** Energieverbruik teller */ 109?: number; /** Status reset contact */ 110?: number; /** Storingscontact */ 201?: number; /** Data storingsverzamelsensor met beschikbaarheidsimpact */ 210?: number; /** Data storingsverzamelsensor zonder beschikbaarheidsimpact */ 211?: number; /** Technisch beschikbaar */ 212?: number; /** Bewegingstoestand */ 500?: number; /** Huidige stopplaats (geopende deuren) */ 501?: number; /** Deur positie (status) - voor */ 502?: number; /** Deur positie (status) - achter */ 503?: number; /** Deurlijn */ 505?: number; /** Temperatuurregelaar (-100 t/m 200) */ 506?: number; /** Richtingveranderingenteller */ 507?: number; /** Deurcyclus teller - deur voor */ 508?: number; /** Deurcyclus teller - deur achter */ 509?: number; /** Deurcyclus teller per stopplaats - deur voor */ 510?: number; /** Deurcyclus teller per stopplaats - deur achter */ 511?: number; /** Stopplaatsteller */ 512?: number; /** Statuscodes * Comma separated list of: * identifier:timestamp:status * * Where the identifier is the status code identifier, * timestamp is Unix timestamp in milliseconds and * status is 1 or 0 based on the status being active or not. */ 513?: number; /** Laatst gepasseerde stopplaats */ 514?: number; /** Huidige stopplaats */ 515?: number; /** Deurbeweging teller - deur voor */ 516?: number; /** Deurbeweging teller - deur achter */ 517?: number; /** Deurbeweging teller per stopplaats - deur voor */ 518?: number; /** Deurbeweging teller per stopplaats - deur achter */ 519?: number; /** Deur pendeling teller - deur voor */ 520?: number; /** Deur pendeling teller - deur achter */ 521?: number; /** Deur pendeling teller per stopplaats - deur voor */ 522?: number; /** Deur pendeling teller per stopplaats - deur voor */ 523?: number; /** Verbinding met besturing gezond (1 indien gezond) */ 524?: number; /** Na oproep geen reactie (Carcall request no response) */ 550?: number; /** Meer deurbewegingen dan verwacht op een stopplaats binnen een tijdsperiode */ 551?: number; /** Besturing informatie */ 590?: number; /** Maximaal aantal stopplaatsen dat de lift bedient (waarde is nul-gebaseerd) */ 591?: number; /** Lift plugin: naam van de geladen plugin, gelijk aan de prefix van de S513-codes die de plugin produceert */ 592?: number; } export interface ILiftStatusSensorDataResponse { lastUpdate: number; values: ILiftStatusValues; updated: ILiftStatusUpdated; } export interface ILiftStatusMessage { mid: string; f: string; data: ILiftStatusValues; ts: number; mc: number; rts: number; } export interface ILiftStatusModuleStatus { es: string; message: ILiftStatusMessage; } export interface IElevatorMaterials { active: THREE.MeshStandardMaterial; normal: THREE.MeshStandardMaterial; pulseOn: THREE.MeshStandardMaterial; pulseOff: THREE.MeshStandardMaterial; transparent: THREE.MeshStandardMaterial; floor: THREE.MeshStandardMaterial; door: THREE.MeshStandardMaterial; } export interface ITimePoint { x: Date; y: number; id: string; sensor: SENSOR; fake: boolean; } export type TLiftStatusWebComponentErrorType = ErrorType; export interface ILiftStatusWebComponentError { hasError: boolean; messageKey: ErrorMessageKey | undefined; type: TLiftStatusWebComponentErrorType; } export type TSeverity = Severity; export interface IStatusMessage { id: string; humanReadableTimestamp: string; relativeTimestamp: string; description: string; severity: TSeverity; } export interface IStatusCode { description: string; level: TSeverity; } /** A single item as returned by the `status-codes/reference` endpoint. */ export interface IStatusCodeReferenceItem { id: number; code: string; status_code_level: string; /** The API can return `null` for a code without a description. */ description: string | null; created_at: string; updated_at: string; } /** A single status code period as returned by the `status-code` endpoint. */ export interface IStatusCodeHistoryRow { status_code: string; start_ts: string; end_ts?: string | null; /** Duration in milliseconds. Absent for statuses that are still active. */ duration?: number; /** The last passed stop at or before the start. */ stop_location?: string | null; } /** A history row enriched with the description and level of the status code. */ export interface IStatusHistoryEntry { code: string; description: string; severity: TSeverity; start: string; end: string | null; /** * How long the status was active, or `null` while it is still open. */ durationMs: number | null; /** * The stop the status started at, or `null` when unknown. */ stopLocation: string | null; } export interface DatePicker { /** * The start date/time in ISO 8601 format */ start: string; /** * The end date/time in ISO 8601 format */ end: string; }