@phystack/hub-device 4.3.40-dev

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.
Files changed (82) hide show
  1. package/.prettierignore +10 -0
  2. package/.prettierrc +10 -0
  3. package/CHANGELOG.md +1202 -0
  4. package/README.md +12 -0
  5. package/dist/index.d.ts +114 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +967 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/storage/browser.d.ts +2 -0
  10. package/dist/storage/browser.d.ts.map +1 -0
  11. package/dist/storage/browser.js +20 -0
  12. package/dist/storage/browser.js.map +1 -0
  13. package/dist/storage/index.d.ts +6 -0
  14. package/dist/storage/index.d.ts.map +1 -0
  15. package/dist/storage/index.js +31 -0
  16. package/dist/storage/index.js.map +1 -0
  17. package/dist/storage/node.d.ts +2 -0
  18. package/dist/storage/node.d.ts.map +1 -0
  19. package/dist/storage/node.js +47 -0
  20. package/dist/storage/node.js.map +1 -0
  21. package/dist/sysinfo/browser.d.ts +3 -0
  22. package/dist/sysinfo/browser.d.ts.map +1 -0
  23. package/dist/sysinfo/browser.js +194 -0
  24. package/dist/sysinfo/browser.js.map +1 -0
  25. package/dist/sysinfo/index.d.ts +3 -0
  26. package/dist/sysinfo/index.d.ts.map +1 -0
  27. package/dist/sysinfo/index.js +34 -0
  28. package/dist/sysinfo/index.js.map +1 -0
  29. package/dist/sysinfo/node.d.ts +3 -0
  30. package/dist/sysinfo/node.d.ts.map +1 -0
  31. package/dist/sysinfo/node.js +53 -0
  32. package/dist/sysinfo/node.js.map +1 -0
  33. package/dist/sysinfo/tizen.d.ts +8 -0
  34. package/dist/sysinfo/tizen.d.ts.map +1 -0
  35. package/dist/sysinfo/tizen.js +168 -0
  36. package/dist/sysinfo/tizen.js.map +1 -0
  37. package/dist/types/command.types.d.ts +8 -0
  38. package/dist/types/command.types.d.ts.map +1 -0
  39. package/dist/types/command.types.js +8 -0
  40. package/dist/types/command.types.js.map +1 -0
  41. package/dist/types/container.types.d.ts +10 -0
  42. package/dist/types/container.types.d.ts.map +1 -0
  43. package/dist/types/container.types.js +3 -0
  44. package/dist/types/container.types.js.map +1 -0
  45. package/dist/types/job.types.d.ts +31 -0
  46. package/dist/types/job.types.d.ts.map +1 -0
  47. package/dist/types/job.types.js +15 -0
  48. package/dist/types/job.types.js.map +1 -0
  49. package/dist/types/twin.types.d.ts +653 -0
  50. package/dist/types/twin.types.d.ts.map +1 -0
  51. package/dist/types/twin.types.js +21 -0
  52. package/dist/types/twin.types.js.map +1 -0
  53. package/dist/utilities/get-device-identifier.utility.d.ts +2 -0
  54. package/dist/utilities/get-device-identifier.utility.d.ts.map +1 -0
  55. package/dist/utilities/get-device-identifier.utility.js +140 -0
  56. package/dist/utilities/get-device-identifier.utility.js.map +1 -0
  57. package/dist/utilities/get-hub-credentials.utility.d.ts +8 -0
  58. package/dist/utilities/get-hub-credentials.utility.d.ts.map +1 -0
  59. package/dist/utilities/get-hub-credentials.utility.js +47 -0
  60. package/dist/utilities/get-hub-credentials.utility.js.map +1 -0
  61. package/dist/utilities/get-provisioning-code.utility.d.ts +3 -0
  62. package/dist/utilities/get-provisioning-code.utility.d.ts.map +1 -0
  63. package/dist/utilities/get-provisioning-code.utility.js +49 -0
  64. package/dist/utilities/get-provisioning-code.utility.js.map +1 -0
  65. package/package.json +39 -0
  66. package/src/hub-device.d.ts +0 -0
  67. package/src/index.ts +1228 -0
  68. package/src/storage/browser.ts +16 -0
  69. package/src/storage/index.ts +46 -0
  70. package/src/storage/node.ts +42 -0
  71. package/src/sysinfo/browser.ts +217 -0
  72. package/src/sysinfo/index.ts +29 -0
  73. package/src/sysinfo/node.ts +387 -0
  74. package/src/sysinfo/tizen.ts +203 -0
  75. package/src/types/command.types.ts +8 -0
  76. package/src/types/container.types.ts +12 -0
  77. package/src/types/job.types.ts +36 -0
  78. package/src/types/twin.types.ts +751 -0
  79. package/src/utilities/get-device-identifier.utility.ts +179 -0
  80. package/src/utilities/get-hub-credentials.utility.ts +56 -0
  81. package/src/utilities/get-provisioning-code.utility.ts +55 -0
  82. package/tsconfig.json +45 -0
@@ -0,0 +1,387 @@
1
+ import si from 'systeminformation';
2
+ // import { execSync } from 'child_process';
3
+
4
+ export async function getSystemInformation() {
5
+ // const now = new Date();
6
+ // const isoString = now.toISOString();
7
+ // const deviceStarted = new Date(now.getTime() - uptime * 1000).toISOString();
8
+
9
+ // const info = await si.getAllData();
10
+ const valueObject = {
11
+ baseboard: '*',
12
+ battery: '*',
13
+ graphics: '*',
14
+ chassis: '*',
15
+ bios: '*',
16
+ cpu: '*',
17
+ mem: '*',
18
+ inetLatency: '*',
19
+ cpuCurrentSpeed: '*',
20
+ currentLoad: '*',
21
+ wifiInterfaces: '*',
22
+ networkStats: '*',
23
+ memLayout: '*',
24
+ fsSize: '*',
25
+ fsStats: '*',
26
+ os: '*',
27
+ node: '*',
28
+ wifiNetworks: '*',
29
+ wifiConnections: '*',
30
+ uuid: '*',
31
+ time: '*',
32
+ users: '*',
33
+ temp: '*',
34
+ system: '*',
35
+ };
36
+
37
+ const info = await si.get(valueObject);
38
+ // console.log('getAllData3', {info});
39
+
40
+ // Now get all network interfaces (this call reliably returns disabled interfaces as well).
41
+ let netIfaces = await si.networkInterfaces();
42
+
43
+ // Ensure netIfaces is always an array
44
+ if (!Array.isArray(netIfaces)) {
45
+ netIfaces = [netIfaces];
46
+ }
47
+
48
+ // Map through the interfaces and assign a type if missing.
49
+ netIfaces = netIfaces.map((iface: any) => ({
50
+ ...iface,
51
+ type:
52
+ iface.type ||
53
+ (iface.ifaceName &&
54
+ (iface.ifaceName.startsWith("en") || iface.ifaceName.startsWith("eth"))
55
+ ? "wired"
56
+ : "unknown"),
57
+ }));
58
+
59
+ // Inject the full list of network interfaces into our system info.
60
+ info.networkInterfaces = netIfaces;
61
+
62
+ // TODO: update so structure is aligned with what the browser version will output. Create a type.
63
+ const systemInfo = JSON.parse(JSON.stringify(info));
64
+
65
+ return systemInfo;
66
+ }
67
+
68
+ // TODO make orientation coherent for both browser and phyos so it can be easily queried and injected as a tag
69
+ // function getDisplayInfo() {
70
+ // try {
71
+ // const displayInfo = execSync('swaymsg -t get_outputs -r').toString();
72
+ // return JSON.parse(displayInfo);
73
+ // } catch (error) {
74
+ // console.error('Error getting display information');
75
+ // return [];
76
+ // }
77
+ // }
78
+
79
+ export default getSystemInformation;
80
+
81
+ // swaymsg -t get_outputs -r
82
+ // [
83
+ // {
84
+ // "id": 3,
85
+ // "type": "output",
86
+ // "orientation": "none",
87
+ // "percent": 1.0,
88
+ // "urgent": false,
89
+ // "marks": [],
90
+ // "layout": "output",
91
+ // "border": "none",
92
+ // "current_border_width": 0,
93
+ // "rect": {
94
+ // "x": 0,
95
+ // "y": 0,
96
+ // "width": 1920,
97
+ // "height": 1080
98
+ // },
99
+ // "deco_rect": {
100
+ // "x": 0,
101
+ // "y": 0,
102
+ // "width": 0,
103
+ // "height": 0
104
+ // },
105
+ // "window_rect": {
106
+ // "x": 0,
107
+ // "y": 0,
108
+ // "width": 0,
109
+ // "height": 0
110
+ // },
111
+ // "geometry": {
112
+ // "x": 0,
113
+ // "y": 0,
114
+ // "width": 0,
115
+ // "height": 0
116
+ // },
117
+ // "name": "DP-2",
118
+ // "window": null,
119
+ // "nodes": [],
120
+ // "floating_nodes": [],
121
+ // "focus": [
122
+ // 4
123
+ // ],
124
+ // "fullscreen_mode": 0,
125
+ // "sticky": false,
126
+ // "floating": null,
127
+ // "scratchpad_state": null,
128
+ // "primary": false,
129
+ // "make": "Samsung Electric Company",
130
+ // "model": "SyncMaster",
131
+ // "serial": "H1AK500000",
132
+ // "modes": [
133
+ // {
134
+ // "width": 1920,
135
+ // "height": 1080,
136
+ // "refresh": 60000,
137
+ // "picture_aspect_ratio": "none"
138
+ // },
139
+ // {
140
+ // "width": 1920,
141
+ // "height": 1080,
142
+ // "refresh": 60000,
143
+ // "picture_aspect_ratio": "16:9"
144
+ // },
145
+ // {
146
+ // "width": 1920,
147
+ // "height": 1080,
148
+ // "refresh": 59940,
149
+ // "picture_aspect_ratio": "16:9"
150
+ // },
151
+ // {
152
+ // "width": 1920,
153
+ // "height": 1080,
154
+ // "refresh": 50000,
155
+ // "picture_aspect_ratio": "none"
156
+ // },
157
+ // {
158
+ // "width": 1920,
159
+ // "height": 1080,
160
+ // "refresh": 50000,
161
+ // "picture_aspect_ratio": "16:9"
162
+ // },
163
+ // {
164
+ // "width": 1920,
165
+ // "height": 1080,
166
+ // "refresh": 30000,
167
+ // "picture_aspect_ratio": "16:9"
168
+ // },
169
+ // {
170
+ // "width": 1920,
171
+ // "height": 1080,
172
+ // "refresh": 29970,
173
+ // "picture_aspect_ratio": "16:9"
174
+ // },
175
+ // {
176
+ // "width": 1920,
177
+ // "height": 1080,
178
+ // "refresh": 25000,
179
+ // "picture_aspect_ratio": "16:9"
180
+ // },
181
+ // {
182
+ // "width": 1920,
183
+ // "height": 1080,
184
+ // "refresh": 24000,
185
+ // "picture_aspect_ratio": "16:9"
186
+ // },
187
+ // {
188
+ // "width": 1920,
189
+ // "height": 1080,
190
+ // "refresh": 23976,
191
+ // "picture_aspect_ratio": "16:9"
192
+ // },
193
+ // {
194
+ // "width": 1680,
195
+ // "height": 1050,
196
+ // "refresh": 59883,
197
+ // "picture_aspect_ratio": "none"
198
+ // },
199
+ // {
200
+ // "width": 1600,
201
+ // "height": 900,
202
+ // "refresh": 60000,
203
+ // "picture_aspect_ratio": "none"
204
+ // },
205
+ // {
206
+ // "width": 1280,
207
+ // "height": 1024,
208
+ // "refresh": 75025,
209
+ // "picture_aspect_ratio": "none"
210
+ // },
211
+ // {
212
+ // "width": 1280,
213
+ // "height": 1024,
214
+ // "refresh": 60020,
215
+ // "picture_aspect_ratio": "none"
216
+ // },
217
+ // {
218
+ // "width": 1440,
219
+ // "height": 900,
220
+ // "refresh": 59901,
221
+ // "picture_aspect_ratio": "none"
222
+ // },
223
+ // {
224
+ // "width": 1366,
225
+ // "height": 768,
226
+ // "refresh": 59790,
227
+ // "picture_aspect_ratio": "none"
228
+ // },
229
+ // {
230
+ // "width": 1280,
231
+ // "height": 800,
232
+ // "refresh": 59910,
233
+ // "picture_aspect_ratio": "none"
234
+ // },
235
+ // {
236
+ // "width": 1152,
237
+ // "height": 864,
238
+ // "refresh": 75000,
239
+ // "picture_aspect_ratio": "none"
240
+ // },
241
+ // {
242
+ // "width": 1280,
243
+ // "height": 720,
244
+ // "refresh": 60000,
245
+ // "picture_aspect_ratio": "none"
246
+ // },
247
+ // {
248
+ // "width": 1280,
249
+ // "height": 720,
250
+ // "refresh": 60000,
251
+ // "picture_aspect_ratio": "16:9"
252
+ // },
253
+ // {
254
+ // "width": 1280,
255
+ // "height": 720,
256
+ // "refresh": 59940,
257
+ // "picture_aspect_ratio": "16:9"
258
+ // },
259
+ // {
260
+ // "width": 1280,
261
+ // "height": 720,
262
+ // "refresh": 50000,
263
+ // "picture_aspect_ratio": "none"
264
+ // },
265
+ // {
266
+ // "width": 1280,
267
+ // "height": 720,
268
+ // "refresh": 50000,
269
+ // "picture_aspect_ratio": "16:9"
270
+ // },
271
+ // {
272
+ // "width": 1024,
273
+ // "height": 768,
274
+ // "refresh": 75029,
275
+ // "picture_aspect_ratio": "none"
276
+ // },
277
+ // {
278
+ // "width": 1024,
279
+ // "height": 768,
280
+ // "refresh": 70069,
281
+ // "picture_aspect_ratio": "none"
282
+ // },
283
+ // {
284
+ // "width": 1024,
285
+ // "height": 768,
286
+ // "refresh": 60004,
287
+ // "picture_aspect_ratio": "none"
288
+ // },
289
+ // {
290
+ // "width": 832,
291
+ // "height": 624,
292
+ // "refresh": 74551,
293
+ // "picture_aspect_ratio": "none"
294
+ // },
295
+ // {
296
+ // "width": 800,
297
+ // "height": 600,
298
+ // "refresh": 75000,
299
+ // "picture_aspect_ratio": "none"
300
+ // },
301
+ // {
302
+ // "width": 800,
303
+ // "height": 600,
304
+ // "refresh": 72188,
305
+ // "picture_aspect_ratio": "none"
306
+ // },
307
+ // {
308
+ // "width": 800,
309
+ // "height": 600,
310
+ // "refresh": 60317,
311
+ // "picture_aspect_ratio": "none"
312
+ // },
313
+ // {
314
+ // "width": 720,
315
+ // "height": 576,
316
+ // "refresh": 50000,
317
+ // "picture_aspect_ratio": "16:9"
318
+ // },
319
+ // {
320
+ // "width": 720,
321
+ // "height": 480,
322
+ // "refresh": 60000,
323
+ // "picture_aspect_ratio": "16:9"
324
+ // },
325
+ // {
326
+ // "width": 720,
327
+ // "height": 480,
328
+ // "refresh": 59940,
329
+ // "picture_aspect_ratio": "16:9"
330
+ // },
331
+ // {
332
+ // "width": 640,
333
+ // "height": 480,
334
+ // "refresh": 75000,
335
+ // "picture_aspect_ratio": "none"
336
+ // },
337
+ // {
338
+ // "width": 640,
339
+ // "height": 480,
340
+ // "refresh": 72809,
341
+ // "picture_aspect_ratio": "none"
342
+ // },
343
+ // {
344
+ // "width": 640,
345
+ // "height": 480,
346
+ // "refresh": 66667,
347
+ // "picture_aspect_ratio": "none"
348
+ // },
349
+ // {
350
+ // "width": 640,
351
+ // "height": 480,
352
+ // "refresh": 60000,
353
+ // "picture_aspect_ratio": "4:3"
354
+ // },
355
+ // {
356
+ // "width": 640,
357
+ // "height": 480,
358
+ // "refresh": 59940,
359
+ // "picture_aspect_ratio": "none"
360
+ // },
361
+ // {
362
+ // "width": 720,
363
+ // "height": 400,
364
+ // "refresh": 70082,
365
+ // "picture_aspect_ratio": "none"
366
+ // }
367
+ // ],
368
+ // "non_desktop": false,
369
+ // "active": true,
370
+ // "dpms": true,
371
+ // "power": true,
372
+ // "scale": 1.0,
373
+ // "scale_filter": "nearest",
374
+ // "transform": "normal",
375
+ // "adaptive_sync_status": "disabled",
376
+ // "current_workspace": "1",
377
+ // "current_mode": {
378
+ // "width": 1920,
379
+ // "height": 1080,
380
+ // "refresh": 60000,
381
+ // "picture_aspect_ratio": "none"
382
+ // },
383
+ // "max_render_time": 0,
384
+ // "focused": true,
385
+ // "subpixel_hinting": "unknown"
386
+ // }
387
+ // ]
@@ -0,0 +1,203 @@
1
+ import { DeviceTwinReportedProperties } from '@/types/twin.types';
2
+
3
+ interface TizenBuildInformation {
4
+ model: string;
5
+ manufacturer: string;
6
+ buildVersion: string;
7
+ }
8
+
9
+ interface TizenCPUStatus {
10
+ load: number;
11
+ }
12
+
13
+ interface TizenStorageStatus {
14
+ units: TizenStorageUnit[];
15
+ }
16
+
17
+ interface TizenStorageUnit {
18
+ availableCapacity: number;
19
+ capacity: number;
20
+ type: string;
21
+ }
22
+
23
+ const getTizenBuildInformation = async (): Promise<TizenBuildInformation> => {
24
+ return new Promise(resolve => {
25
+ (window as any).tizen.systeminfo.getPropertyValue(
26
+ 'BUILD',
27
+ (buildInformation: TizenBuildInformation) => {
28
+ resolve(buildInformation);
29
+ }
30
+ );
31
+ });
32
+ };
33
+
34
+ export const getCPUStatus = (): Promise<TizenCPUStatus> => {
35
+ return new Promise(resolve => {
36
+ (window as any).tizen.systeminfo.getPropertyValue('CPU', (cpuStatus: TizenCPUStatus) => {
37
+ resolve(cpuStatus);
38
+ });
39
+ });
40
+ };
41
+
42
+ const getStorageStatus = async (): Promise<TizenStorageStatus> => {
43
+ return new Promise(resolve => {
44
+ (window as any).tizen.systeminfo.getPropertyValue(
45
+ 'STORAGE',
46
+ (storageStatus: TizenStorageStatus) => {
47
+ resolve(storageStatus);
48
+ }
49
+ );
50
+ });
51
+ };
52
+
53
+ async function getTizenSystemInfo(): Promise<Partial<DeviceTwinReportedProperties>> {
54
+ // @ts-ignore
55
+ const b2bcontrol = window.b2bapis?.b2bcontrol;
56
+ // @ts-ignore
57
+ const tizen = window.tizen;
58
+ // @ts-ignore
59
+ const webapis = window.webapis;
60
+
61
+ // const firmware = b2bctl.getFirmwareVersion()
62
+ const version = /Tizen [0-9.]+/.exec(navigator.appVersion);
63
+ const operatingSystem = version ? version[0] : '';
64
+ const cpuArch = tizen.systeminfo.getCapability('http://tizen.org/feature/platform.core.cpu.arch');
65
+ const cpuFrequency = tizen.systeminfo.getCapability('http://tizen.org/feature/platform.core.cpu.frequency');
66
+ const systemUpTime = b2bcontrol.getSystemUpTime();
67
+ const totalMemory = tizen.systeminfo.getTotalMemory();
68
+ const availableMemory = tizen.systeminfo.getAvailableMemory();
69
+ const ipAddress = b2bcontrol.getIPAddress();
70
+ const macAddress = b2bcontrol.getMACAddress();
71
+
72
+ const buildInformation = await getTizenBuildInformation();
73
+ const cpuStatus = await getCPUStatus();
74
+ const storageStatus = await getStorageStatus();
75
+
76
+ const systemInfo: Partial<DeviceTwinReportedProperties> = {
77
+ system: {
78
+ manufacturer: buildInformation.manufacturer,
79
+ model: buildInformation.model,
80
+ serial: '',
81
+ uuid: '',
82
+ sku: '',
83
+ version: '',
84
+ virtual: false,
85
+ },
86
+ os: {
87
+ osVersion: `${operatingSystem} - ${buildInformation.buildVersion}`,
88
+ },
89
+ bios: {
90
+ vendor: '',
91
+ version: '',
92
+ releaseDate: '',
93
+ revision: '',
94
+ },
95
+ chassis: {
96
+ type: '',
97
+ manufacturer: '',
98
+ model: '',
99
+ version: '',
100
+ serial: '',
101
+ assetTag: '',
102
+ sku: '',
103
+ },
104
+ cpu: {
105
+ manufacturer: buildInformation.manufacturer,
106
+ brand: `${buildInformation.manufacturer} ${cpuArch} @ ${cpuFrequency / 1000} MHz`,
107
+ vendor: '',
108
+ family: '',
109
+ model: '',
110
+ stepping: '',
111
+ revision: '',
112
+ voltage: '',
113
+ speed: cpuFrequency,
114
+ speedMin: cpuFrequency,
115
+ speedMax: cpuFrequency,
116
+ processors: 1,
117
+ socket: '',
118
+ cache: {
119
+ l1d: 0,
120
+ l1i: 0,
121
+ l2: 0,
122
+ l3: 0,
123
+ },
124
+ governor: '',
125
+ cores: 1,
126
+ physicalCores: 1,
127
+ performanceCores: 1,
128
+ efficiencyCores: 1,
129
+ flags: '',
130
+ virtualization: false,
131
+ },
132
+ mem: {
133
+ total: totalMemory,
134
+ free: availableMemory,
135
+ used: totalMemory - availableMemory,
136
+ active: availableMemory,
137
+ available: availableMemory,
138
+ buffers: 0,
139
+ cached: 0,
140
+ slab: 0,
141
+ buffcache: 0,
142
+ swaptotal: 0,
143
+ swapused: 0,
144
+ swapfree: 0,
145
+ writeback: null,
146
+ dirty: null,
147
+ },
148
+ fsSize: [
149
+ {
150
+ fs: '',
151
+ type: storageStatus.units[0].type,
152
+ size: storageStatus.units[0].capacity,
153
+ used: storageStatus.units[0].capacity - storageStatus.units[0].availableCapacity,
154
+ available: storageStatus.units[0].availableCapacity,
155
+ use: storageStatus.units[0].capacity - storageStatus.units[0].availableCapacity,
156
+ mount: '/',
157
+ rw: true,
158
+ },
159
+ ],
160
+ time: {
161
+ uptime: systemUpTime,
162
+ current: new Date().getTime(),
163
+ timezone: '',
164
+ timezoneName: '',
165
+ },
166
+ currentLoad: {
167
+ avgLoad: cpuStatus.load,
168
+ currentLoad: cpuStatus.load,
169
+ currentLoadUser: cpuStatus.load,
170
+ currentLoadSystem: cpuStatus.load,
171
+ currentLoadNice: cpuStatus.load,
172
+ currentLoadIdle: cpuStatus.load,
173
+ currentLoadIrq: cpuStatus.load,
174
+ currentLoadSteal: cpuStatus.load,
175
+ currentLoadGuest: cpuStatus.load,
176
+ rawCurrentLoad: cpuStatus.load,
177
+ rawCurrentLoadUser: cpuStatus.load,
178
+ rawCurrentLoadSystem: cpuStatus.load,
179
+ rawCurrentLoadNice: cpuStatus.load,
180
+ rawCurrentLoadIdle: cpuStatus.load,
181
+ rawCurrentLoadIrq: cpuStatus.load,
182
+ rawCurrentLoadSteal: cpuStatus.load,
183
+ rawCurrentLoadGuest: cpuStatus.load,
184
+ cpus: [],
185
+ },
186
+ ip: [
187
+ {
188
+ ipv4: ipAddress,
189
+ ipv6: '',
190
+ interface: '',
191
+ },
192
+ ],
193
+ uuid: {
194
+ os: '',
195
+ hardware: '',
196
+ macs: [macAddress]
197
+ }
198
+ };
199
+
200
+ return systemInfo;
201
+ }
202
+
203
+ export default getTizenSystemInfo;
@@ -0,0 +1,8 @@
1
+ export enum DeviceCommand {
2
+ Reboot = 'reboot',
3
+ }
4
+
5
+ export interface Command {
6
+ commandId: string;
7
+ command: DeviceCommand;
8
+ }
@@ -0,0 +1,12 @@
1
+ import { TwinStatusEnum } from './twin.types';
2
+
3
+ export interface ContainerStatus {
4
+ status: TwinStatusEnum;
5
+ error:
6
+ | {
7
+ message: string;
8
+ timestamp: Date;
9
+ errorObject?: any;
10
+ }
11
+ | undefined;
12
+ }
@@ -0,0 +1,36 @@
1
+ import { Command } from './command.types';
2
+
3
+ export enum JobStatusEnum {
4
+ Pending = 'Pending',
5
+ InProgress = 'InProgress',
6
+ Completed = 'Completed',
7
+ }
8
+
9
+ export enum JobTypeEnum {
10
+ ScheduledCmd = 'ScheduledCmd',
11
+ InstantCmd = 'InstantCmd',
12
+ }
13
+
14
+ interface JobBase {
15
+ id: string;
16
+ status: JobStatusEnum;
17
+ type: JobTypeEnum;
18
+ createdAt: Date;
19
+ schedule?: string;
20
+ maxExecutions?: number;
21
+ data: unknown;
22
+ isAcknowledged: boolean;
23
+ }
24
+
25
+ export interface ScheduledCommandJob extends JobBase {
26
+ type: JobTypeEnum.ScheduledCmd;
27
+ data: Command;
28
+ }
29
+
30
+ export interface InstantCommandJob extends JobBase {
31
+ type: JobTypeEnum.InstantCmd;
32
+ data: Command;
33
+ }
34
+
35
+ // creating a union type for Job as we will have more jobs in future
36
+ export type Job = ScheduledCommandJob | InstantCommandJob;