@placeos/ts-client 4.7.7 → 4.7.10

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.
@@ -1,3 +1,4 @@
1
+ import { AlertSeverity } from '../alerts/alert';
1
2
  import { PlaceDriver } from '../drivers/driver';
2
3
  import { PlaceDriverRole } from '../drivers/enums';
3
4
  import { PlaceResource } from '../resources/resource';
@@ -62,6 +63,8 @@ export declare class PlaceModule extends PlaceResource {
62
63
  readonly has_runtime_error: boolean;
63
64
  /** Timestamp of the last runtime error in ms since UTC epoch */
64
65
  readonly error_timestamp: number;
66
+ /** */
67
+ readonly alert_level: AlertSeverity;
65
68
  /** ID of the system associated with the module */
66
69
  get system_id(): string;
67
70
  constructor(raw_data?: PlaceModuleComplete);
@@ -37,8 +37,8 @@ export declare class PlaceSystem extends PlaceResource {
37
37
  readonly support_url: string;
38
38
  /** URL for the timetable UI linked to the system */
39
39
  readonly timetable_url: string;
40
- /** URL for requesting snapshots of the assosiated camera */
41
- readonly camera_snapshot_url: string;
40
+ /** URLs for requesting snapshots of the assosiated camera */
41
+ readonly camera_snapshot_urls: string[];
42
42
  /** URL for managing the attached camera */
43
43
  readonly camera_url: string;
44
44
  /** External booking URL for the system */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.7.7",
2
+ "version": "4.7.10",
3
3
  "license": "MIT",
4
4
  "name": "@placeos/ts-client",
5
5
  "author": "Alex Sorafumo <alex@place.tech>",
@@ -90,6 +90,25 @@ const _online_observer = _online.asObservable();
90
90
 
91
91
  let _failed_count = 0;
92
92
 
93
+ /**
94
+ * @private
95
+ * Resolve a URL against the authority's domain if it is a relative path.
96
+ * If the URL is already absolute (starts with http:// or https://), return as-is.
97
+ * If the URL is relative (starts with /), prepend the protocol and authority domain.
98
+ */
99
+ function resolveAuthorityUrl(url: string): string {
100
+ if (!url || url.startsWith('http://') || url.startsWith('https://')) {
101
+ return url;
102
+ }
103
+ const domain = _authority?.domain;
104
+ if (domain) {
105
+ const secure =
106
+ _options.secure || window.location?.protocol.indexOf('https') >= 0;
107
+ return `${secure ? 'https:' : 'http:'}//${domain}${url}`;
108
+ }
109
+ return url;
110
+ }
111
+
93
112
  /** API Endpoint for the retrieved version of PlaceOS */
94
113
  export function apiEndpoint(): string {
95
114
  const secure =
@@ -398,7 +417,9 @@ export function authorise(
398
417
  * Logout and clear user credentials for the application
399
418
  */
400
419
  export function logout(): void {
401
- const url = _authority ? _authority.logout_url : '/logout';
420
+ const url = resolveAuthorityUrl(
421
+ _authority ? _authority.logout_url : '/logout',
422
+ );
402
423
  fetch(url, {
403
424
  method: 'GET',
404
425
  redirect: 'manual',
@@ -582,10 +603,12 @@ export function sendToLogin(api_authority: PlaceAuthority): void {
582
603
  /* istanbul ignore else */
583
604
  if (_options.handle_login !== false && !_redirecting) {
584
605
  log('Auth', 'Redirecting to login page...');
585
- // Redirect to login form
586
- const url = api_authority!.login_url?.replace(
587
- '{{url}}',
588
- encodeURIComponent(window.location?.href),
606
+ // Redirect to login form, resolving relative URLs against the authority domain
607
+ const url = resolveAuthorityUrl(
608
+ api_authority!.login_url?.replace(
609
+ '{{url}}',
610
+ encodeURIComponent(window.location?.href),
611
+ ),
589
612
  );
590
613
  setTimeout(() => window.location?.assign(url), 300);
591
614
  _redirecting = true;
@@ -1,3 +1,4 @@
1
+ import { AlertSeverity } from '../alerts/alert';
1
2
  import { PlaceResource } from '../resources/resource';
2
3
  import { EncryptionLevel } from '../settings/interfaces';
3
4
  import { PlaceSettings } from '../settings/settings';
@@ -32,6 +33,8 @@ export class PlaceDriver extends PlaceResource {
32
33
  author: string;
33
34
  date: string;
34
35
  };
36
+ /** */
37
+ public readonly alert_level: AlertSeverity;
35
38
  /** Tuple of user settings of differring encryption levels for the driver */
36
39
  public readonly settings: [
37
40
  PlaceSettings | null,
@@ -54,6 +57,7 @@ export class PlaceDriver extends PlaceResource {
54
57
  this.commit = raw_data.commit || '';
55
58
  this.update_available = raw_data.update_available || false;
56
59
  this.update_info = raw_data.update_info;
60
+ this.alert_level = raw_data.alert_level || 'medium';
57
61
  this.settings = raw_data.settings || [null, null, null, null];
58
62
  if (typeof this.settings !== 'object') {
59
63
  (this as any).settings = [null, null, null, null];
@@ -1,3 +1,4 @@
1
+ import { AlertSeverity } from '../alerts/alert';
1
2
  import { PlaceDriver } from '../drivers/driver';
2
3
  import { PlaceDriverRole } from '../drivers/enums';
3
4
  import { PlaceResource } from '../resources/resource';
@@ -66,6 +67,8 @@ export class PlaceModule extends PlaceResource {
66
67
  public readonly has_runtime_error: boolean;
67
68
  /** Timestamp of the last runtime error in ms since UTC epoch */
68
69
  public readonly error_timestamp: number;
70
+ /** */
71
+ public readonly alert_level: AlertSeverity;
69
72
  /** ID of the system associated with the module */
70
73
  public get system_id(): string {
71
74
  return this.control_system_id;
@@ -96,6 +99,7 @@ export class PlaceModule extends PlaceResource {
96
99
  this.error_timestamp = raw_data.error_timestamp || 0;
97
100
  this.driver = new PlaceDriver(raw_data.dependency || raw_data.driver);
98
101
  this.settings = raw_data.settings || [null, null, null, null];
102
+ this.alert_level = raw_data.alert_level || 'medium';
99
103
  if (typeof this.settings !== 'object') {
100
104
  (this as any).settings = [null, null, null, null];
101
105
  }
@@ -40,8 +40,8 @@ export class PlaceSystem extends PlaceResource {
40
40
  public readonly support_url: string;
41
41
  /** URL for the timetable UI linked to the system */
42
42
  public readonly timetable_url: string;
43
- /** URL for requesting snapshots of the assosiated camera */
44
- public readonly camera_snapshot_url: string;
43
+ /** URLs for requesting snapshots of the assosiated camera */
44
+ public readonly camera_snapshot_urls: string[];
45
45
  /** URL for managing the attached camera */
46
46
  public readonly camera_url: string;
47
47
  /** External booking URL for the system */
@@ -85,7 +85,7 @@ export class PlaceSystem extends PlaceResource {
85
85
  this.public = raw_data.public ?? false;
86
86
  this.installed_ui_devices = raw_data.installed_ui_devices || 0;
87
87
  this.support_url = raw_data.support_url || '';
88
- this.camera_snapshot_url = raw_data.camera_snapshot_url || '';
88
+ this.camera_snapshot_urls = raw_data.camera_snapshot_urls || [];
89
89
  this.camera_url = raw_data.camera_url || '';
90
90
  this.timetable_url = raw_data.timetable_url || '';
91
91
  this.room_booking_url = raw_data.room_booking_url || '';