@things-factory/integration-base 8.0.0-alpha.1 → 8.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-base",
3
- "version": "8.0.0-alpha.1",
3
+ "version": "8.0.0-alpha.8",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -27,13 +27,13 @@
27
27
  "dependencies": {
28
28
  "@apollo/client": "^3.6.9",
29
29
  "@operato/moment-timezone-es": "^8.0.0-alpha",
30
- "@things-factory/api": "^8.0.0-alpha.1",
31
- "@things-factory/auth-base": "^8.0.0-alpha.1",
32
- "@things-factory/cache-service": "^8.0.0-alpha.1",
33
- "@things-factory/env": "^8.0.0-alpha.0",
34
- "@things-factory/oauth2-client": "^8.0.0-alpha.1",
35
- "@things-factory/scheduler-client": "^8.0.0-alpha.1",
36
- "@things-factory/shell": "^8.0.0-alpha.1",
30
+ "@things-factory/api": "^8.0.0-alpha.8",
31
+ "@things-factory/auth-base": "^8.0.0-alpha.8",
32
+ "@things-factory/cache-service": "^8.0.0-alpha.8",
33
+ "@things-factory/env": "^8.0.0-alpha.8",
34
+ "@things-factory/oauth2-client": "^8.0.0-alpha.8",
35
+ "@things-factory/scheduler-client": "^8.0.0-alpha.8",
36
+ "@things-factory/shell": "^8.0.0-alpha.8",
37
37
  "@things-factory/utils": "^8.0.0-alpha.0",
38
38
  "async-mqtt": "^2.5.0",
39
39
  "chance": "^1.1.11",
@@ -44,5 +44,5 @@
44
44
  "readline": "^1.3.0",
45
45
  "ses": "^1.5.0"
46
46
  },
47
- "gitHead": "fda153ff6e86ef5ee7ace788739a100f3f413f08"
47
+ "gitHead": "0a9fb3ab431934982294b58c743d01b6f782a15f"
48
48
  }
@@ -10,7 +10,20 @@ import { ProxyConnector } from './connector/proxy-connector'
10
10
  const { combine, splat, printf, errors } = format
11
11
  const debug = require('debug')('things-factory:integration-base:connections')
12
12
 
13
- const SYSTEM_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone
13
+ function getSystemTimeZone() {
14
+ try {
15
+ const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
16
+ if (!timeZone) {
17
+ throw new Error('Unable to resolve timeZone')
18
+ }
19
+ return timeZone
20
+ } catch (e) {
21
+ console.warn('Failed to get system timeZone, falling back to UTC.', e)
22
+ return 'UTC'
23
+ }
24
+ }
25
+
26
+ const SYSTEM_TZ = getSystemTimeZone()
14
27
  const systemTimestamp = format((info, opts) => {
15
28
  if (opts.tz) info.timestamp = moment().tz(opts.tz).format()
16
29
  return info
@@ -139,13 +152,13 @@ export class ConnectionManager {
139
152
 
140
153
  static getConnectionInstanceEntityByName(domain: Domain, name: string): any {
141
154
  const connection = ConnectionManager.entities[domain.id]?.[name]
142
- if(connection) {
155
+ if (connection) {
143
156
  return connection
144
157
  }
145
158
 
146
- if(domain.parentId) {
159
+ if (domain.parentId) {
147
160
  return ConnectionManager.entities[domain.id]?.[name]
148
- }
161
+ }
149
162
  }
150
163
 
151
164
  static getConnectionInstances(domain: Domain): { [connectionName: string]: any } {
@@ -25,7 +25,20 @@ const LOGFORMAT = printf(({ level, message, timestamp, stack }) => {
25
25
  return `${timestamp} ${level}: ${stack || message}`
26
26
  })
27
27
 
28
- const SYSTEM_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone
28
+ function getSystemTimeZone() {
29
+ try {
30
+ const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
31
+ if (!timeZone) {
32
+ throw new Error('Unable to resolve timeZone')
33
+ }
34
+ return timeZone
35
+ } catch (e) {
36
+ console.warn('Failed to get system timeZone, falling back to UTC.', e)
37
+ return 'UTC'
38
+ }
39
+ }
40
+
41
+ const SYSTEM_TZ = getSystemTimeZone()
29
42
  const systemTimestamp = format((info, opts) => {
30
43
  if (opts.tz) info.timestamp = moment().tz(opts.tz).format()
31
44
  return info