@alwaysai/device-agent 0.0.14 → 0.0.16

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 (85) hide show
  1. package/lib/application-control/install.d.ts.map +1 -1
  2. package/lib/application-control/install.js +1 -0
  3. package/lib/application-control/install.js.map +1 -1
  4. package/lib/application-control/status.d.ts.map +1 -1
  5. package/lib/application-control/status.js +8 -13
  6. package/lib/application-control/status.js.map +1 -1
  7. package/lib/cloud-connection/bootstrap-provision.d.ts +1 -1
  8. package/lib/cloud-connection/bootstrap-provision.d.ts.map +1 -1
  9. package/lib/cloud-connection/bootstrap-provision.js +9 -9
  10. package/lib/cloud-connection/bootstrap-provision.js.map +1 -1
  11. package/lib/cloud-connection/cmd-status.d.ts +3 -11
  12. package/lib/cloud-connection/cmd-status.d.ts.map +1 -1
  13. package/lib/cloud-connection/cmd-status.js +24 -11
  14. package/lib/cloud-connection/cmd-status.js.map +1 -1
  15. package/lib/cloud-connection/device-agent-cloud-connection.d.ts +2 -3
  16. package/lib/cloud-connection/device-agent-cloud-connection.d.ts.map +1 -1
  17. package/lib/cloud-connection/device-agent-cloud-connection.js +93 -43
  18. package/lib/cloud-connection/device-agent-cloud-connection.js.map +1 -1
  19. package/lib/cloud-connection/device-agent.d.ts.map +1 -1
  20. package/lib/cloud-connection/device-agent.js +4 -3
  21. package/lib/cloud-connection/device-agent.js.map +1 -1
  22. package/lib/cloud-connection/live-updates-handler.d.ts +10 -18
  23. package/lib/cloud-connection/live-updates-handler.d.ts.map +1 -1
  24. package/lib/cloud-connection/live-updates-handler.js +50 -50
  25. package/lib/cloud-connection/live-updates-handler.js.map +1 -1
  26. package/lib/cloud-connection/messages.d.ts +3 -1
  27. package/lib/cloud-connection/messages.d.ts.map +1 -1
  28. package/lib/cloud-connection/messages.js +13 -1
  29. package/lib/cloud-connection/messages.js.map +1 -1
  30. package/lib/cloud-connection/passthrough-handler.js +1 -1
  31. package/lib/cloud-connection/passthrough-handler.js.map +1 -1
  32. package/lib/cloud-connection/shadow-handler.d.ts.map +1 -1
  33. package/lib/cloud-connection/shadow-handler.js +11 -4
  34. package/lib/cloud-connection/shadow-handler.js.map +1 -1
  35. package/lib/cloud-connection/shadow-handler.test.js +3 -3
  36. package/lib/cloud-connection/shadow-handler.test.js.map +1 -1
  37. package/lib/environment.d.ts.map +1 -1
  38. package/lib/environment.js +1 -1
  39. package/lib/environment.js.map +1 -1
  40. package/lib/index.js +5 -3
  41. package/lib/index.js.map +1 -1
  42. package/lib/subcommands/app/app.d.ts +2 -2
  43. package/lib/subcommands/app/app.d.ts.map +1 -1
  44. package/lib/subcommands/app/app.js +28 -10
  45. package/lib/subcommands/app/app.js.map +1 -1
  46. package/lib/subcommands/app/index.js +2 -2
  47. package/lib/subcommands/device/device.d.ts.map +1 -1
  48. package/lib/subcommands/device/device.js +2 -1
  49. package/lib/subcommands/device/device.js.map +1 -1
  50. package/lib/util/directories.d.ts +11 -12
  51. package/lib/util/directories.d.ts.map +1 -1
  52. package/lib/util/directories.js +24 -29
  53. package/lib/util/directories.js.map +1 -1
  54. package/lib/util/logger.js +1 -0
  55. package/lib/util/logger.js.map +1 -1
  56. package/package.json +1 -1
  57. package/readme.md +3 -3
  58. package/src/application-control/install.ts +3 -1
  59. package/src/application-control/status.ts +10 -16
  60. package/src/cloud-connection/bootstrap-provision.ts +13 -10
  61. package/src/cloud-connection/cmd-status.ts +30 -11
  62. package/src/cloud-connection/device-agent-cloud-connection.ts +128 -66
  63. package/src/cloud-connection/device-agent.ts +7 -4
  64. package/src/cloud-connection/live-updates-handler.ts +79 -86
  65. package/src/cloud-connection/messages.ts +22 -1
  66. package/src/cloud-connection/passthrough-handler.ts +1 -1
  67. package/src/cloud-connection/shadow-handler.test.ts +3 -3
  68. package/src/cloud-connection/shadow-handler.ts +15 -11
  69. package/src/environment.ts +1 -1
  70. package/src/index.ts +6 -3
  71. package/src/subcommands/app/app.ts +27 -10
  72. package/src/subcommands/app/index.ts +4 -4
  73. package/src/subcommands/device/device.ts +5 -2
  74. package/src/util/directories.ts +31 -29
  75. package/src/util/logger.ts +2 -0
  76. package/lib/cloud-connection/app-install-status.d.ts +0 -16
  77. package/lib/cloud-connection/app-install-status.d.ts.map +0 -1
  78. package/lib/cloud-connection/app-install-status.js +0 -53
  79. package/lib/cloud-connection/app-install-status.js.map +0 -1
  80. package/lib/util/timer.d.ts +0 -2
  81. package/lib/util/timer.d.ts.map +0 -1
  82. package/lib/util/timer.js +0 -6
  83. package/lib/util/timer.js.map +0 -1
  84. package/src/cloud-connection/app-install-status.ts +0 -62
  85. package/src/util/timer.ts +0 -1
@@ -143,22 +143,26 @@ export class ShadowHandler {
143
143
  },
144
144
  clientToken: this.clientId
145
145
  };
146
- this.publisher.publish(
147
- this.shadowTopics.projects.update,
148
- JSON.stringify(packet)
146
+ const topic = this.shadowTopics.projects.update;
147
+ logger.debug(
148
+ `Publishing message:\n${JSON.stringify({ topic, packet }, null, 2)}`
149
149
  );
150
+ this.publisher.publish(topic, JSON.stringify(packet));
150
151
  }
151
152
 
152
153
  public getShadowUpdates() {
153
- this.publisher.publish(
154
- this.shadowTopics.projects.get,
155
- JSON.stringify({
156
- clientToken: this.clientId
157
- })
154
+ const topic = this.shadowTopics.projects.get;
155
+ const packet = {
156
+ clientToken: this.clientId
157
+ };
158
+ logger.debug(
159
+ `Publishing message:\n${JSON.stringify({ topic, packet }, null, 2)}`
158
160
  );
161
+ this.publisher.publish(topic, JSON.stringify(packet));
159
162
  }
160
163
 
161
164
  public deleteProjectShadow(projectId: string) {
165
+ const topic = this.shadowTopics.projects.update;
162
166
  const packet = {
163
167
  state: {
164
168
  reported: {
@@ -167,9 +171,9 @@ export class ShadowHandler {
167
171
  },
168
172
  clientToken: this.clientId
169
173
  };
170
- this.publisher.publish(
171
- this.shadowTopics.projects.update,
172
- JSON.stringify(packet)
174
+ logger.debug(
175
+ `Publishing message:\n${JSON.stringify({ topic, packet }, null, 2)}`
173
176
  );
177
+ this.publisher.publish(topic, JSON.stringify(packet));
174
178
  }
175
179
  }
@@ -8,7 +8,7 @@ export const ALWAYSAI_SHOW_HIDDEN = parseBoolean(
8
8
  );
9
9
  export const ALWAYSAI_DEVICE_AGENT_MODE =
10
10
  process.env.ALWAYSAI_DEVICE_AGENT_MODE;
11
- export const ALWAYSAI_LOG_LEVEL = process.env.AAI_LOG_LEVEL;
11
+ export const ALWAYSAI_LOG_LEVEL = process.env.ALWAYSAI_LOG_LEVEL;
12
12
  export const ALWAYSAI_LOG_TO_CONSOLE = process.env.ALWAYSAI_LOG_TO_CONSOLE;
13
13
  export const ALWAYSAI_ANALYTICS_PASSTHROUGH = parseBoolean(
14
14
  process.env.ALWAYSAI_ANALYTICS_PASSTHROUGH
package/src/index.ts CHANGED
@@ -12,15 +12,18 @@ import { AgentConfigFile } from './infrastructure/agent-config';
12
12
  import { ALWAYSAI_DEVICE_AGENT_MODE } from './environment';
13
13
  import { logger } from './util/logger';
14
14
 
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ const { version } = require('../package.json');
17
+
15
18
  if (module === require.main) {
16
- logger.info('Starting alwaysAI Device Agent');
19
+ logger.info(`Starting alwaysAI Device Agent v${version}`);
17
20
  if (!AgentConfigFile().exists()) {
18
21
  AgentConfigFile().initialize();
19
22
  }
20
23
 
21
24
  if (ALWAYSAI_DEVICE_AGENT_MODE === 'cloud') {
22
- runDeviceAgentCloudInterface();
25
+ void runDeviceAgentCloudInterface();
23
26
  } else {
24
- runCliAndExit(root, {});
27
+ void runCliAndExit(root, {});
25
28
  }
26
29
  }
@@ -18,13 +18,12 @@ import {
18
18
  setEnv,
19
19
  startApp,
20
20
  stopApp,
21
- uninstallApp,
22
21
  updateModels
23
22
  } from '../../application-control';
24
23
  import { DeviceAgentCloudConnection } from '../../cloud-connection/device-agent-cloud-connection';
25
24
  import { AgentConfigFile } from '../../infrastructure/agent-config';
26
25
  import { logger } from '../../util/logger';
27
- import { timer } from '../../util/timer';
26
+ import sleep from '../../util/sleep';
28
27
 
29
28
  export const listAppsCliLeaf = CliLeaf({
30
29
  name: 'list',
@@ -96,9 +95,9 @@ export const installAppCliLeaf = CliLeaf({
96
95
  }
97
96
  }
98
97
  };
99
- await deviceAgent.handleClientMessage({ topic, message });
100
- while (deviceAgent.getCmdStatus(project) === 'in_progress') {
101
- await timer(1000);
98
+ await deviceAgent.handleMessage(topic, message);
99
+ while (deviceAgent.isCmdInProgress(project)) {
100
+ await sleep(1000);
102
101
  }
103
102
  deviceAgent.stop();
104
103
  }
@@ -198,7 +197,25 @@ export const uninstallAppCliLeaf = CliLeaf({
198
197
  },
199
198
  async action(_, opts) {
200
199
  const { project } = opts;
201
- await uninstallApp({ projectId: project });
200
+ const deviceAgent = new DeviceAgentCloudConnection();
201
+ await deviceAgent.setupHandlers();
202
+ const topic = deviceAgent.getToDeviceTopic();
203
+ const message: ClientMessage = {
204
+ timestamp: '',
205
+ topic,
206
+ payload: {
207
+ messageType: keyMirrors.clientMessageType.app_version_control,
208
+ appVersionControl: {
209
+ baseCommand: keyMirrors.appVersionControl.uninstall,
210
+ projectId: project
211
+ }
212
+ }
213
+ };
214
+ await deviceAgent.handleMessage(topic, message);
215
+ while (deviceAgent.isCmdInProgress(project)) {
216
+ await sleep(1000);
217
+ }
218
+ deviceAgent.stop();
202
219
  }
203
220
  });
204
221
 
@@ -273,8 +290,8 @@ export const addModelCliLeaf = CliLeaf({
273
290
  };
274
291
 
275
292
  await deviceAgent.handleMessage(topic, message);
276
- while (deviceAgent.getCmdStatus(project) === 'in_progress') {
277
- await timer(1000);
293
+ while (deviceAgent.isCmdInProgress(project)) {
294
+ await sleep(1000);
278
295
  }
279
296
  deviceAgent.stop();
280
297
  }
@@ -333,7 +350,7 @@ export const updateModelsCliLeaf = CliLeaf({
333
350
  }
334
351
  });
335
352
 
336
- export const getAllEnvsCLiLeaf = CliLeaf({
353
+ export const getAllEnvsCliLeaf = CliLeaf({
337
354
  name: 'get-all-envs',
338
355
  description: 'Get environment variables for an application',
339
356
  namedInputs: {
@@ -348,7 +365,7 @@ export const getAllEnvsCLiLeaf = CliLeaf({
348
365
  }
349
366
  });
350
367
 
351
- export const setEnvCLiLeaf = CliLeaf({
368
+ export const setEnvCliLeaf = CliLeaf({
352
369
  name: 'set-env',
353
370
  description: 'Set environment variables for a service',
354
371
  positionalInput: CliStringArrayInput({
@@ -16,8 +16,8 @@ import {
16
16
  restartAppCliLeaf,
17
17
  replaceModelsCliLeaf,
18
18
  showAppModelsCliLeaf,
19
- getAllEnvsCLiLeaf,
20
- setEnvCLiLeaf
19
+ getAllEnvsCliLeaf,
20
+ setEnvCliLeaf
21
21
  } from './app';
22
22
 
23
23
  export const appCliBranch = CliBranch({
@@ -40,7 +40,7 @@ export const appCliBranch = CliBranch({
40
40
  removeModelCliLeaf,
41
41
  replaceModelsCliLeaf,
42
42
  updateModelsCliLeaf,
43
- getAllEnvsCLiLeaf,
44
- setEnvCLiLeaf
43
+ getAllEnvsCliLeaf,
44
+ setEnvCliLeaf
45
45
  ]
46
46
  });
@@ -7,7 +7,7 @@ import { httpClient, microServiceHttpClient } from '../../util/http-client';
7
7
  import {
8
8
  AWS_ROOT_CERTIFICATE_FILE_NAME,
9
9
  BOOTSTRAP_CERTIFICATES_DIR_PATH,
10
- getPrivateKeyFilePath
10
+ DEVICE_PRIVATE_KEY_FILE_PATH
11
11
  } from '../../util/directories';
12
12
 
13
13
  import { LOCAL_CERT_AND_KEY_DIR } from 'alwaysai/lib/constants';
@@ -39,7 +39,10 @@ export const initCliLeaf = CliLeaf({
39
39
  let { name } = opts;
40
40
  name = name || uuidv4();
41
41
 
42
- if (DeviceConfigFile().exists() || existsSync(getPrivateKeyFilePath())) {
42
+ if (
43
+ DeviceConfigFile().exists() ||
44
+ existsSync(DEVICE_PRIVATE_KEY_FILE_PATH)
45
+ ) {
43
46
  throw new Error(
44
47
  "Device has been previously provisioned. Run 'aai-agent device clean' to re-provision"
45
48
  );
@@ -33,52 +33,54 @@ export const shortenSystemId = () => {
33
33
  }
34
34
  };
35
35
 
36
+ /*===================================================================
37
+ Bootstrap Certificates
38
+ ===================================================================*/
39
+
36
40
  export const BOOTSTRAP_DIR_NAME = 'bootstrap-certificates';
37
- export const BOOTSTRAP_DEVICE_PRIVATE_KEY_FILE_NAME = () =>
41
+ export const BOOTSTRAP_PRIVATE_KEY_FILE_NAME = () =>
38
42
  `aai-claim-private-key_${shortenSystemId()}.pem.key`;
39
- export const BOOTSTRAP_DEVICE_CERTIFICATE_FILE_NAME = () =>
43
+ export const BOOTSTRAP_CERTIFICATE_FILE_NAME = () =>
40
44
  `aai-claim-cert_${shortenSystemId()}.pem.crt`;
41
- export const BOOTSTRAP_CLAIM_ID_FILE_NAME = () =>
45
+ export const BOOTSTRAP_ID_FILE_NAME = () =>
42
46
  `aai-claim-cert-id_${shortenSystemId()}.txt`;
43
47
  export const CERTIFICATE_OWNERSHIP_TOKEN_FILE_NAME =
44
48
  'certificate-ownership-token.txt';
45
- export const DEVICE_PRIVATE_KEY_FILE_NAME = () =>
46
- `aai-claim-private-key_${shortenSystemId()}.pem.key`;
47
- export const DEVICE_CERTIFICATE_FILE_NAME = () =>
48
- `aai-claim-cert_${shortenSystemId()}.pem.crt`;
49
- export const DEVICE_CLAIM_ID_FILE_NAME = () =>
50
- `aai-claim-cert-id_${shortenSystemId()}.txt`;
51
-
52
- export function getPrivateKeyFilePath() {
53
- return join(LOCAL_CERT_AND_KEY_DIR, DEVICE_PRIVATE_KEY_FILE_NAME());
54
- }
55
-
56
- export function getCertificateFilePath() {
57
- return join(LOCAL_CERT_AND_KEY_DIR, DEVICE_CERTIFICATE_FILE_NAME());
58
- }
59
49
 
60
50
  export const BOOTSTRAP_CERTIFICATES_DIR_PATH = () =>
61
51
  join(LOCAL_CERT_AND_KEY_DIR, BOOTSTRAP_DIR_NAME);
62
- export const DEVICE_CLAIM_ID_FILE_PATH = () =>
63
- join(LOCAL_CERT_AND_KEY_DIR, DEVICE_TOKEN_FILE_NAME);
64
52
 
65
- export const BOOTSTRAP_DEVICE_PRIVATE_KEY_FILE_PATH = () =>
53
+ export const BOOTSTRAP_PRIVATE_KEY_FILE_PATH = () =>
66
54
  join(
67
55
  LOCAL_CERT_AND_KEY_DIR,
68
56
  BOOTSTRAP_DIR_NAME,
69
- BOOTSTRAP_DEVICE_PRIVATE_KEY_FILE_NAME()
57
+ BOOTSTRAP_PRIVATE_KEY_FILE_NAME()
70
58
  );
71
59
 
72
- export const BOOTSTRAP_DEVICE_CERTIFICATE_FILE_PATH = () =>
60
+ export const BOOTSTRAP_CERTIFICATE_FILE_PATH = () =>
73
61
  join(
74
62
  LOCAL_CERT_AND_KEY_DIR,
75
63
  BOOTSTRAP_DIR_NAME,
76
- BOOTSTRAP_DEVICE_CERTIFICATE_FILE_NAME()
64
+ BOOTSTRAP_CERTIFICATE_FILE_NAME()
77
65
  );
78
66
 
79
- export const BOOTSTRAP_CLAIM_ID_FILE_PATH = () =>
80
- join(
81
- LOCAL_CERT_AND_KEY_DIR,
82
- BOOTSTRAP_DIR_NAME,
83
- BOOTSTRAP_CLAIM_ID_FILE_NAME()
84
- );
67
+ export const BOOTSTRAP_ID_FILE_PATH = () =>
68
+ join(LOCAL_CERT_AND_KEY_DIR, BOOTSTRAP_DIR_NAME, BOOTSTRAP_ID_FILE_NAME());
69
+
70
+ /*===================================================================
71
+ Device Certificates
72
+ ===================================================================*/
73
+
74
+ export const DEVICE_PRIVATE_KEY_FILE_NAME = 'aai-device-private-key.pem.key';
75
+ export const DEVICE_CERTIFICATE_FILE_NAME = 'aai-device-cert.pem.crt';
76
+ export const DEVICE_ID_FILE_NAME = 'aai-device-cert-id.txt';
77
+
78
+ export const DEVICE_PRIVATE_KEY_FILE_PATH = join(
79
+ LOCAL_CERT_AND_KEY_DIR,
80
+ DEVICE_PRIVATE_KEY_FILE_NAME
81
+ );
82
+
83
+ export const DEVICE_CERTIFICATE_FILE_PATH = join(
84
+ LOCAL_CERT_AND_KEY_DIR,
85
+ DEVICE_CERTIFICATE_FILE_NAME
86
+ );
@@ -26,3 +26,5 @@ export const logger = winston.createLogger({
26
26
  ),
27
27
  transports
28
28
  });
29
+
30
+ logger.info(`Initialized logger with log level: ${LOG_LEVEL}`);
@@ -1,16 +0,0 @@
1
- import { AppInstallStatusPacket } from '@alwaysai/device-agent-schemas';
2
- export declare class AppInstallStatus {
3
- private appReleaseHash;
4
- private status;
5
- private message?;
6
- constructor(appReleaseHash: any, status: any, message?: any);
7
- getAppReleaseHash(): string;
8
- update(status: any, message?: any): void;
9
- getStatusPacket(): AppInstallStatusPacket;
10
- }
11
- export declare class AppInstallStatusManager {
12
- private appList;
13
- update(appReleaseHash: any, status: any, message?: any): void;
14
- getStatusPacket(appReleaseHash: any): AppInstallStatusPacket;
15
- }
16
- //# sourceMappingURL=app-install-status.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-install-status.d.ts","sourceRoot":"","sources":["../../src/cloud-connection/app-install-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,OAAO,CAAC,CAAS;gBAEb,cAAc,KAAA,EAAE,MAAM,KAAA,EAAE,OAAO,CAAC,KAAA;IAMrC,iBAAiB;IAIjB,MAAM,CAAC,MAAM,KAAA,EAAE,OAAO,CAAC,KAAA;IAKvB,eAAe,IAAI,sBAAsB;CAOjD;AAED,qBAAa,uBAAuB;IAClC,OAAO,CAAC,OAAO,CAA0B;IAElC,MAAM,CAAC,cAAc,KAAA,EAAE,MAAM,KAAA,EAAE,OAAO,CAAC,KAAA;IAkBvC,eAAe,CAAC,cAAc,KAAA;CAQtC"}
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppInstallStatusManager = exports.AppInstallStatus = void 0;
4
- class AppInstallStatus {
5
- constructor(appReleaseHash, status, message) {
6
- this.appReleaseHash = appReleaseHash;
7
- this.status = status;
8
- this.message = message;
9
- }
10
- getAppReleaseHash() {
11
- return this.appReleaseHash;
12
- }
13
- update(status, message) {
14
- this.status = status;
15
- this.message = message;
16
- }
17
- getStatusPacket() {
18
- return {
19
- status: this.status,
20
- message: this.message,
21
- appReleaseHash: this.appReleaseHash
22
- };
23
- }
24
- }
25
- exports.AppInstallStatus = AppInstallStatus;
26
- class AppInstallStatusManager {
27
- constructor() {
28
- this.appList = [];
29
- }
30
- update(appReleaseHash, status, message) {
31
- // Update status if existing
32
- // TODO: Reimplement this as a map
33
- for (const app of this.appList) {
34
- if (app.getAppReleaseHash() === appReleaseHash) {
35
- app.update(status, message);
36
- return;
37
- }
38
- }
39
- // App was not found, so add to list
40
- const appInstallStatus = new AppInstallStatus(appReleaseHash, status, message);
41
- this.appList.push(appInstallStatus);
42
- }
43
- getStatusPacket(appReleaseHash) {
44
- for (const app of this.appList) {
45
- if (app.getAppReleaseHash() === appReleaseHash) {
46
- return app.getStatusPacket();
47
- }
48
- }
49
- throw new Error(`No status for ${appReleaseHash}`);
50
- }
51
- }
52
- exports.AppInstallStatusManager = AppInstallStatusManager;
53
- //# sourceMappingURL=app-install-status.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-install-status.js","sourceRoot":"","sources":["../../src/cloud-connection/app-install-status.ts"],"names":[],"mappings":";;;AAGA,MAAa,gBAAgB;IAK3B,YAAY,cAAc,EAAE,MAAM,EAAE,OAAQ;QAC1C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,iBAAiB;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,MAAM,EAAE,OAAQ;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,eAAe;QACpB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC;IACJ,CAAC;CACF;AA3BD,4CA2BC;AAED,MAAa,uBAAuB;IAApC;QACU,YAAO,GAAuB,EAAE,CAAC;IA4B3C,CAAC;IA1BQ,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,OAAQ;QAC5C,4BAA4B;QAC5B,kCAAkC;QAClC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;YAC9B,IAAI,GAAG,CAAC,iBAAiB,EAAE,KAAK,cAAc,EAAE;gBAC9C,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC5B,OAAO;aACR;SACF;QACD,oCAAoC;QACpC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAC3C,cAAc,EACd,MAAM,EACN,OAAO,CACR,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IAEM,eAAe,CAAC,cAAc;QACnC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;YAC9B,IAAI,GAAG,CAAC,iBAAiB,EAAE,KAAK,cAAc,EAAE;gBAC9C,OAAO,GAAG,CAAC,eAAe,EAAE,CAAC;aAC9B;SACF;QACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,cAAc,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AA7BD,0DA6BC"}
@@ -1,2 +0,0 @@
1
- export declare const timer: (ms: number) => Promise<unknown>;
2
- //# sourceMappingURL=timer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/util/timer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAA8C,CAAC"}
package/lib/util/timer.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timer = void 0;
4
- const timer = (ms) => new Promise((res) => setTimeout(res, ms));
5
- exports.timer = timer;
6
- //# sourceMappingURL=timer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timer.js","sourceRoot":"","sources":["../../src/util/timer.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AAAlE,QAAA,KAAK,SAA6D"}
@@ -1,62 +0,0 @@
1
- import { AppInstallStatusPacket } from '@alwaysai/device-agent-schemas';
2
- import { AppInstallStatusValue } from '@alwaysai/device-agent-schemas/lib/constants';
3
-
4
- export class AppInstallStatus {
5
- private appReleaseHash: string;
6
- private status: AppInstallStatusValue;
7
- private message?: string;
8
-
9
- constructor(appReleaseHash, status, message?) {
10
- this.appReleaseHash = appReleaseHash;
11
- this.status = status;
12
- this.message = message;
13
- }
14
-
15
- public getAppReleaseHash() {
16
- return this.appReleaseHash;
17
- }
18
-
19
- public update(status, message?) {
20
- this.status = status;
21
- this.message = message;
22
- }
23
-
24
- public getStatusPacket(): AppInstallStatusPacket {
25
- return {
26
- status: this.status,
27
- message: this.message,
28
- appReleaseHash: this.appReleaseHash
29
- };
30
- }
31
- }
32
-
33
- export class AppInstallStatusManager {
34
- private appList: AppInstallStatus[] = [];
35
-
36
- public update(appReleaseHash, status, message?) {
37
- // Update status if existing
38
- // TODO: Reimplement this as a map
39
- for (const app of this.appList) {
40
- if (app.getAppReleaseHash() === appReleaseHash) {
41
- app.update(status, message);
42
- return;
43
- }
44
- }
45
- // App was not found, so add to list
46
- const appInstallStatus = new AppInstallStatus(
47
- appReleaseHash,
48
- status,
49
- message
50
- );
51
- this.appList.push(appInstallStatus);
52
- }
53
-
54
- public getStatusPacket(appReleaseHash) {
55
- for (const app of this.appList) {
56
- if (app.getAppReleaseHash() === appReleaseHash) {
57
- return app.getStatusPacket();
58
- }
59
- }
60
- throw new Error(`No status for ${appReleaseHash}`);
61
- }
62
- }
package/src/util/timer.ts DELETED
@@ -1 +0,0 @@
1
- export const timer = (ms: number) => new Promise((res) => setTimeout(res, ms));