@alwaysai/device-agent-schemas 2.0.4 → 2.1.0
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/lib/app-action-schema.d.ts +14 -14
- package/lib/app-action-schema.d.ts.map +1 -1
- package/lib/app-logs-schema.d.ts +2 -2
- package/lib/app-logs-schema.d.ts.map +1 -1
- package/lib/app-state-schema.d.ts +2 -2
- package/lib/app-state-schema.d.ts.map +1 -1
- package/lib/constants.d.ts +16 -10
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +10 -6
- package/lib/constants.js.map +1 -1
- package/lib/constants.test.js +10 -7
- package/lib/constants.test.js.map +1 -1
- package/lib/device-agent-action-schema.d.ts +2 -2
- package/lib/device-agent-action-schema.d.ts.map +1 -1
- package/lib/device-stats-schema.d.ts +2 -2
- package/lib/device-stats-schema.d.ts.map +1 -1
- package/lib/device-stats-schema.js +1 -1
- package/lib/device-stats-schema.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -6
- package/lib/index.js.map +1 -1
- package/lib/schemas/{app-install-cloud-response-schema.json → app-install-response-schema.json} +4 -4
- package/lib/schemas/{models-install-cloud-response-schema.json → models-install-response-schema.json} +4 -4
- package/lib/schemas/{client-message-schema.json → to-client-message-schema.json} +5 -24
- package/lib/schemas/to-cloud-message-schema.json +56 -0
- package/lib/schemas/{device-agent-message-schema.json → to-device-agent-message-schema.json} +10 -10
- package/lib/signed-urls-request-schema.d.ts +2 -2
- package/lib/signed-urls-request-schema.d.ts.map +1 -1
- package/lib/status-response-schema.d.ts +2 -2
- package/lib/status-response-schema.d.ts.map +1 -1
- package/lib/types.d.ts +21 -12
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +18 -16
- package/lib/types.js.map +1 -1
- package/lib/types.test.js +128 -43
- package/lib/types.test.js.map +1 -1
- package/package.json +1 -1
- package/src/app-action-schema.ts +15 -15
- package/src/app-logs-schema.ts +2 -2
- package/src/app-state-schema.ts +2 -2
- package/src/constants.test.ts +11 -7
- package/src/constants.ts +19 -11
- package/src/device-agent-action-schema.ts +2 -2
- package/src/device-stats-schema.ts +3 -3
- package/src/index.ts +41 -31
- package/src/schemas/{app-install-cloud-response-schema.json → app-install-response-schema.json} +4 -4
- package/src/schemas/{models-install-cloud-response-schema.json → models-install-response-schema.json} +4 -4
- package/src/schemas/{client-message-schema.json → to-client-message-schema.json} +5 -24
- package/src/schemas/to-cloud-message-schema.json +56 -0
- package/src/schemas/{device-agent-message-schema.json → to-device-agent-message-schema.json} +10 -10
- package/src/signed-urls-request-schema.ts +2 -2
- package/src/status-response-schema.ts +2 -2
- package/src/types.test.ts +149 -49
- package/src/types.ts +50 -35
package/lib/schemas/{device-agent-message-schema.json → to-device-agent-message-schema.json}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://alwaysai.co/device-agent-message-schema.json",
|
|
2
|
+
"$id": "https://alwaysai.co/to-device-agent-message-schema.json",
|
|
3
3
|
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
4
|
-
"title": "
|
|
4
|
+
"title": "to_device_agent_message",
|
|
5
5
|
"description": "A schema that describes the message payload structure for messages sent from clients to device agent",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"enum": [
|
|
15
15
|
"app_state_control",
|
|
16
16
|
"app_version_control",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"app_install_response",
|
|
18
|
+
"models_install_response",
|
|
19
19
|
"live_state_updates"
|
|
20
20
|
]
|
|
21
21
|
},
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"oneOf": [
|
|
27
27
|
{ "$ref": "https://alwaysai.co/app-state-control-schema.json" },
|
|
28
28
|
{ "$ref": "https://alwaysai.co/app-version-control-schema.json" },
|
|
29
|
-
{ "$ref": "https://alwaysai.co/app-install-
|
|
30
|
-
{ "$ref": "https://alwaysai.co/models-install-
|
|
29
|
+
{ "$ref": "https://alwaysai.co/app-install-response-schema.json" },
|
|
30
|
+
{ "$ref": "https://alwaysai.co/models-install-response-schema.json" },
|
|
31
31
|
{ "$ref": "https://alwaysai.co/live-updates-toggle-schema.json" }
|
|
32
32
|
]
|
|
33
33
|
}
|
|
@@ -60,24 +60,24 @@
|
|
|
60
60
|
{
|
|
61
61
|
"if": {
|
|
62
62
|
"properties": {
|
|
63
|
-
"messageType": { "const": "
|
|
63
|
+
"messageType": { "const": "app_install_response" }
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"then": {
|
|
67
67
|
"properties": {
|
|
68
|
-
"payload": { "$ref": "https://alwaysai.co/app-install-
|
|
68
|
+
"payload": { "$ref": "https://alwaysai.co/app-install-response-schema.json" }
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
"if": {
|
|
74
74
|
"properties": {
|
|
75
|
-
"messageType": { "const": "
|
|
75
|
+
"messageType": { "const": "models_install_response" }
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"then": {
|
|
79
79
|
"properties": {
|
|
80
|
-
"payload": { "$ref": "https://alwaysai.co/models-install-
|
|
80
|
+
"payload": { "$ref": "https://alwaysai.co/models-install-response-schema.json" }
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SignedUrlsRequestMessageType } from './constants';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseToClientMessage } from './types';
|
|
3
3
|
declare type ModelsObject = {
|
|
4
4
|
[modelId: string]: number;
|
|
5
5
|
};
|
|
@@ -13,7 +13,7 @@ export interface SignedUrlsRequestPayload {
|
|
|
13
13
|
models: ModelsObject;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
export interface SignedUrlsRequestMessage extends
|
|
16
|
+
export interface SignedUrlsRequestMessage extends BaseToClientMessage {
|
|
17
17
|
messageType: SignedUrlsRequestMessageType;
|
|
18
18
|
payload: SignedUrlsRequestPayload;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signed-urls-request-schema.d.ts","sourceRoot":"","sources":["../src/signed-urls-request-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"signed-urls-request-schema.d.ts","sourceRoot":"","sources":["../src/signed-urls-request-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,aAAK,YAAY,GAAG;IAClB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,CAAC,EAAE;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,qBAAqB,CAAC,EAAE;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,YAAY,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,WAAW,EAAE,4BAA4B,CAAC;IAC1C,OAAO,EAAE,wBAAwB,CAAC;CACnC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StatusResponseMessageType, StatusResponseValue } from './constants';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseToClientMessage } from './types';
|
|
3
3
|
export interface StatusResponsePayload {
|
|
4
4
|
status: StatusResponseValue;
|
|
5
5
|
message?: string;
|
|
6
6
|
}
|
|
7
|
-
export interface StatusResponseMessage extends
|
|
7
|
+
export interface StatusResponseMessage extends BaseToClientMessage {
|
|
8
8
|
messageType: StatusResponseMessageType;
|
|
9
9
|
payload: StatusResponsePayload;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-response-schema.d.ts","sourceRoot":"","sources":["../src/status-response-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"status-response-schema.d.ts","sourceRoot":"","sources":["../src/status-response-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,WAAW,EAAE,yBAAyB,CAAC;IACvC,OAAO,EAAE,qBAAqB,CAAC;CAChC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
import { AppLogsMessage, AppLogsPayload } from './app-logs-schema';
|
|
2
|
-
import {
|
|
2
|
+
import { AppInstallResponseMessage, AppInstallResponsePayload, AppStateControlMessage, AppStateControlPayload, AppVersionControlInstallPayload, AppVersionControlMessage, AppVersionControlUninstallPayload, ModelsInstallResponseMessage, ModelsInstallResponsePayload } from './app-action-schema';
|
|
3
3
|
import { LiveStateUpdatesToggleMessage, LiveStateUpdatesTogglePayload } from './device-agent-action-schema';
|
|
4
4
|
import { StatusResponseMessage, StatusResponsePayload } from './status-response-schema';
|
|
5
5
|
import { AppStateMessage, AppStatePayload } from './app-state-schema';
|
|
6
6
|
import { SignedUrlsRequestMessage, SignedUrlsRequestPayload } from './signed-urls-request-schema';
|
|
7
7
|
import { DeviceStatsMessage, DeviceStatsPayload } from './device-stats-schema';
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export interface
|
|
8
|
+
export declare const getToClientTopic: (deviceUuid: string, deviceType?: string) => string;
|
|
9
|
+
export declare const getToCloudTopic: (deviceUuid: string, deviceType?: string) => string;
|
|
10
|
+
export declare const getToDeviceTopic: (deviceUuid: string, deviceType?: string) => string;
|
|
11
|
+
export interface BaseToClientMessage {
|
|
12
12
|
deviceId: string;
|
|
13
13
|
timestamp: string;
|
|
14
14
|
topic?: string;
|
|
15
15
|
txId: string;
|
|
16
16
|
}
|
|
17
|
-
export declare type
|
|
18
|
-
export declare type
|
|
19
|
-
export declare const
|
|
20
|
-
export interface
|
|
17
|
+
export declare type ToClientMessage = AppLogsMessage | StatusResponseMessage | AppStateMessage | DeviceStatsMessage;
|
|
18
|
+
export declare type ToClientMessagePayload = AppLogsPayload | AppStatePayload | DeviceStatsPayload | StatusResponsePayload;
|
|
19
|
+
export declare const validateToClientMessage: import("ajv/dist/types").ValidateFunction<BaseToClientMessage>;
|
|
20
|
+
export interface BaseToCloudMessage {
|
|
21
|
+
deviceId: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
topic?: string;
|
|
24
|
+
txId: string;
|
|
25
|
+
}
|
|
26
|
+
export declare type ToCloudMessage = SignedUrlsRequestMessage;
|
|
27
|
+
export declare type ToCloudMessagePayload = SignedUrlsRequestPayload;
|
|
28
|
+
export declare const validateToCloudMessage: import("ajv/dist/types").ValidateFunction<BaseToCloudMessage>;
|
|
29
|
+
export interface BaseToDeviceAgentMessage {
|
|
21
30
|
timestamp: string;
|
|
22
31
|
topic?: string;
|
|
23
32
|
txId: string;
|
|
24
33
|
}
|
|
25
|
-
export declare type
|
|
26
|
-
export declare type
|
|
27
|
-
export declare const
|
|
34
|
+
export declare type ToDeviceAgentMessage = AppStateControlMessage | AppVersionControlMessage | LiveStateUpdatesToggleMessage | StatusResponseMessage | AppInstallResponseMessage | ModelsInstallResponseMessage;
|
|
35
|
+
export declare type ToDeviceAgentMessagePayload = AppStateControlPayload | AppVersionControlInstallPayload | AppVersionControlUninstallPayload | LiveStateUpdatesTogglePayload | StatusResponsePayload | AppInstallResponsePayload | ModelsInstallResponsePayload;
|
|
36
|
+
export declare const validateToDeviceAgentMessage: import("ajv/dist/types").ValidateFunction<ToDeviceAgentMessage>;
|
|
28
37
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,EACxB,iCAAiC,EACjC,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS/E,eAAO,MAAM,gBAAgB,eAAgB,MAAM,eAAc,MAAM,WACjB,CAAC;AAEvD,eAAO,MAAM,eAAe,eAAgB,MAAM,eAAc,MAAM,WACjB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,eAAgB,MAAM,eAAc,MAAM,WACjB,CAAC;AAMvD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oBAAY,eAAe,GACvB,cAAc,GACd,qBAAqB,GACrB,eAAe,GACf,kBAAkB,CAAC;AAEvB,oBAAY,sBAAsB,GAC9B,cAAc,GACd,eAAe,GACf,kBAAkB,GAClB,qBAAqB,CAAC;AAO1B,eAAO,MAAM,uBAAuB,gEACqB,CAAC;AAM1D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oBAAY,cAAc,GAAG,wBAAwB,CAAC;AAEtD,oBAAY,qBAAqB,GAAG,wBAAwB,CAAC;AAG7D,eAAO,MAAM,sBAAsB,+DACoB,CAAC;AAMxD,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oBAAY,oBAAoB,GAC5B,sBAAsB,GACtB,wBAAwB,GACxB,6BAA6B,GAC7B,qBAAqB,GACrB,yBAAyB,GACzB,4BAA4B,CAAC;AAEjC,oBAAY,2BAA2B,GACnC,sBAAsB,GACtB,+BAA+B,GAC/B,iCAAiC,GACjC,6BAA6B,GAC7B,qBAAqB,GACrB,yBAAyB,GACzB,4BAA4B,CAAC;AAWjC,eAAO,MAAM,4BAA4B,iEAExC,CAAC"}
|
package/lib/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateToDeviceAgentMessage = exports.validateToCloudMessage = exports.validateToClientMessage = exports.getToDeviceTopic = exports.getToCloudTopic = exports.getToClientTopic = void 0;
|
|
4
4
|
const _2019_1 = require("ajv/dist/2019");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const commonSchema = require("./schemas/common-schema.json");
|
|
@@ -9,15 +9,16 @@ const appStateSchema = require("./schemas/app-state-schema.json");
|
|
|
9
9
|
const appLogsSchema = require("./schemas/app-logs-schema.json");
|
|
10
10
|
const statusResponseSchema = require("./schemas/status-response-schema.json");
|
|
11
11
|
const signedUrlsRequestSchema = require("./schemas/signed-urls-request-schema.json");
|
|
12
|
-
const
|
|
12
|
+
const toDeviceAgentMessageSchema = require("./schemas/to-device-agent-message-schema.json");
|
|
13
13
|
const modelsInstallPayloadSchema = require("./schemas/models-install-payload-schema.json");
|
|
14
14
|
const appInstallSchema = require("./schemas/app-install-schema.json");
|
|
15
15
|
const appUninstallSchema = require("./schemas/app-uninstall-schema.json");
|
|
16
|
-
const
|
|
16
|
+
const toClientMessageSchema = require("./schemas/to-client-message-schema.json");
|
|
17
|
+
const toCloudMessageSchema = require("./schemas/to-cloud-message-schema.json");
|
|
17
18
|
const appStateControlSchema = require("./schemas/app-state-control-schema.json");
|
|
18
19
|
const appVersionControlSchema = require("./schemas/app-version-control-schema.json");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
20
|
+
const appInstallResponseSchema = require("./schemas/app-install-response-schema.json");
|
|
21
|
+
const modelsInstallResponseSchema = require("./schemas/models-install-response-schema.json");
|
|
21
22
|
const liveUpdatesTogglesSchema = require("./schemas/live-updates-toggle-schema.json");
|
|
22
23
|
// Note: the other schemas do not need to be added, because they will
|
|
23
24
|
// automatically be added in the compile step due to $ref usage (and $id lookup)
|
|
@@ -25,26 +26,27 @@ const ajv = new _2019_1.default({
|
|
|
25
26
|
allErrors: true,
|
|
26
27
|
schemas: [commonSchema],
|
|
27
28
|
});
|
|
28
|
-
const
|
|
29
|
-
exports.
|
|
30
|
-
const
|
|
31
|
-
exports.
|
|
32
|
-
const
|
|
33
|
-
exports.
|
|
29
|
+
const getToClientTopic = (deviceUuid, deviceType = constants_1.DEVICE_TYPE) => `${constants_1.CLIENT_TOPIC_PREFIX}/${deviceType}/${deviceUuid}`;
|
|
30
|
+
exports.getToClientTopic = getToClientTopic;
|
|
31
|
+
const getToCloudTopic = (deviceUuid, deviceType = constants_1.DEVICE_TYPE) => `${constants_1.CLOUD_TOPIC_PREFIX}/${deviceType}/${deviceUuid}`;
|
|
32
|
+
exports.getToCloudTopic = getToCloudTopic;
|
|
33
|
+
const getToDeviceTopic = (deviceUuid, deviceType = constants_1.DEVICE_TYPE) => `${constants_1.DEVICE_TOPIC_PREFIX}/${deviceType}/${deviceUuid}`;
|
|
34
|
+
exports.getToDeviceTopic = getToDeviceTopic;
|
|
34
35
|
ajv.addSchema(deviceStatsSchema, 'device-stats-schema.json');
|
|
35
36
|
ajv.addSchema(appStateSchema, 'app-state-schema.json');
|
|
36
37
|
ajv.addSchema(appLogsSchema, 'app-logs-schema.json');
|
|
37
38
|
ajv.addSchema(statusResponseSchema, 'status-response-schema.json');
|
|
39
|
+
ajv.addSchema(toClientMessageSchema, 'to-client-message-schema.json');
|
|
40
|
+
exports.validateToClientMessage = ajv.compile(toClientMessageSchema);
|
|
38
41
|
ajv.addSchema(signedUrlsRequestSchema, 'signed-urls-request-schema.json');
|
|
39
|
-
ajv.
|
|
40
|
-
exports.validateClientMessage = ajv.compile(clientMessageSchema);
|
|
42
|
+
exports.validateToCloudMessage = ajv.compile(toCloudMessageSchema);
|
|
41
43
|
ajv.addSchema(modelsInstallPayloadSchema, 'models-install-payload-schema.json');
|
|
42
44
|
ajv.addSchema(appInstallSchema, 'app-install-schema.json');
|
|
43
45
|
ajv.addSchema(appUninstallSchema, 'app-uninstall-schema.json');
|
|
44
46
|
ajv.addSchema(appStateControlSchema, 'app-state-control-schema.json');
|
|
45
47
|
ajv.addSchema(appVersionControlSchema, 'app-version-control-schema.json');
|
|
46
|
-
ajv.addSchema(
|
|
47
|
-
ajv.addSchema(
|
|
48
|
+
ajv.addSchema(appInstallResponseSchema, 'app-install-response-schema.json');
|
|
49
|
+
ajv.addSchema(modelsInstallResponseSchema, 'models-install-response-schema.json');
|
|
48
50
|
ajv.addSchema(liveUpdatesTogglesSchema, 'live-updates-toggle-schema.json');
|
|
49
|
-
exports.
|
|
51
|
+
exports.validateToDeviceAgentMessage = ajv.compile(toDeviceAgentMessageSchema);
|
|
50
52
|
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,2CAKqB;AACrB,6DAA6D;AAC7D,wEAAwE;AACxE,kEAAkE;AAClE,gEAAgE;AAChE,8EAA8E;AAC9E,qFAAqF;AACrF,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,2CAKqB;AACrB,6DAA6D;AAC7D,wEAAwE;AACxE,kEAAkE;AAClE,gEAAgE;AAChE,8EAA8E;AAC9E,qFAAqF;AACrF,4FAA4F;AAC5F,2FAA2F;AAC3F,sEAAsE;AACtE,0EAA0E;AAC1E,iFAAiF;AACjF,+EAA+E;AAC/E,iFAAiF;AACjF,qFAAqF;AACrF,uFAAuF;AACvF,6FAA6F;AAC7F,sFAAsF;AAyBtF,qEAAqE;AACrE,gFAAgF;AAChF,MAAM,GAAG,GAAG,IAAI,eAAO,CAAC;IACtB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,CAAC,YAAY,CAAC;CACxB,CAAC,CAAC;AAEI,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAE,aAAqB,uBAAW,EAAE,EAAE,CACvF,GAAG,+BAAmB,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;AAD1C,QAAA,gBAAgB,oBAC0B;AAEhD,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,aAAqB,uBAAW,EAAE,EAAE,CACtF,GAAG,8BAAkB,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;AADzC,QAAA,eAAe,mBAC0B;AAE/C,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAE,aAAqB,uBAAW,EAAE,EAAE,CACvF,GAAG,+BAAmB,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;AAD1C,QAAA,gBAAgB,oBAC0B;AAyBvD,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;AAC7D,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;AACvD,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;AACrD,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,6BAA6B,CAAC,CAAC;AACnE,GAAG,CAAC,SAAS,CAAC,qBAAqB,EAAE,+BAA+B,CAAC,CAAC;AACzD,QAAA,uBAAuB,GAClC,GAAG,CAAC,OAAO,CAAsB,qBAAqB,CAAC,CAAC;AAiB1D,GAAG,CAAC,SAAS,CAAC,uBAAuB,EAAE,iCAAiC,CAAC,CAAC;AAC7D,QAAA,sBAAsB,GACjC,GAAG,CAAC,OAAO,CAAqB,oBAAoB,CAAC,CAAC;AA6BxD,GAAG,CAAC,SAAS,CAAC,0BAA0B,EAAE,oCAAoC,CAAC,CAAC;AAChF,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE,yBAAyB,CAAC,CAAC;AAC3D,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,2BAA2B,CAAC,CAAC;AAC/D,GAAG,CAAC,SAAS,CAAC,qBAAqB,EAAE,+BAA+B,CAAC,CAAC;AACtE,GAAG,CAAC,SAAS,CAAC,uBAAuB,EAAE,iCAAiC,CAAC,CAAC;AAC1E,GAAG,CAAC,SAAS,CAAC,wBAAwB,EAAE,kCAAkC,CAAC,CAAC;AAC5E,GAAG,CAAC,SAAS,CAAC,2BAA2B,EAAE,qCAAqC,CAAC,CAAC;AAClF,GAAG,CAAC,SAAS,CAAC,wBAAwB,EAAE,iCAAiC,CAAC,CAAC;AAE9D,QAAA,4BAA4B,GAAG,GAAG,CAAC,OAAO,CACrD,0BAA0B,CAC3B,CAAC"}
|
package/lib/types.test.js
CHANGED
|
@@ -4,11 +4,11 @@ const constants_1 = require("./constants");
|
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
const validTxId = (0, utils_1.generateTxId)();
|
|
7
|
-
const
|
|
7
|
+
const validToCloudMessages = [
|
|
8
8
|
{
|
|
9
9
|
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
10
10
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
11
|
-
topic: (0, types_1.
|
|
11
|
+
topic: (0, types_1.getToCloudTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
12
12
|
txId: validTxId,
|
|
13
13
|
messageType: 'signed_urls_request',
|
|
14
14
|
payload: {
|
|
@@ -18,10 +18,68 @@ const validClientMessages = [
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
|
+
];
|
|
22
|
+
const invalidToCloudMessages = [
|
|
23
|
+
{
|
|
24
|
+
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
25
|
+
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
26
|
+
topic: (0, types_1.getToCloudTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
27
|
+
// missing txId
|
|
28
|
+
messageType: 'signed_urls_request',
|
|
29
|
+
payload: {
|
|
30
|
+
signedUrlsRequest: {
|
|
31
|
+
projectId: 'b8f8e280-0c59-46e7-911e-7b897263ebc3',
|
|
32
|
+
appReleaseHash: 'c36d58b6a5b5c09e5d46da8a5315f01c20f8c7ff0087b1e31e6e334a702ee8ba',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
38
|
+
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
39
|
+
topic: (0, types_1.getToCloudTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
40
|
+
txId: validTxId,
|
|
41
|
+
messageType: 'app_logs',
|
|
42
|
+
payload: {
|
|
43
|
+
signedUrlsRequest: {
|
|
44
|
+
projectId: 'b8f8e280-0c59-46e7-911e-7b897263ebc3',
|
|
45
|
+
appReleaseHash: 'c36d58b6a5b5c09e5d46da8a5315f01c20f8c7ff0087b1e31e6e334a702ee8ba',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
51
|
+
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
52
|
+
topic: (0, types_1.getToCloudTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
53
|
+
txId: validTxId,
|
|
54
|
+
messageType: 'signed_urls_request',
|
|
55
|
+
payload: {
|
|
56
|
+
signedUrlsRequest: {
|
|
57
|
+
// missing releaseHash
|
|
58
|
+
projectId: 'b8f8e280-0c59-46e7-911e-7b897263ebc3',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
// wrong type -- ToClientMessage
|
|
63
|
+
{
|
|
64
|
+
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
65
|
+
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
66
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
67
|
+
txId: validTxId,
|
|
68
|
+
messageType: 'device_stats',
|
|
69
|
+
payload: {
|
|
70
|
+
deviceStats: {
|
|
71
|
+
cpuUsage: 50,
|
|
72
|
+
diskUtil: 40,
|
|
73
|
+
usedMemoryPercentage: 70,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
const validToClientMessages = [
|
|
21
79
|
{
|
|
22
80
|
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
23
81
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
24
|
-
topic: (0, types_1.
|
|
82
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
25
83
|
txId: validTxId,
|
|
26
84
|
messageType: 'device_stats',
|
|
27
85
|
payload: {
|
|
@@ -33,7 +91,7 @@ const validClientMessages = [
|
|
|
33
91
|
{
|
|
34
92
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
35
93
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
36
|
-
topic: (0, types_1.
|
|
94
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
37
95
|
txId: validTxId,
|
|
38
96
|
messageType: 'app_logs',
|
|
39
97
|
payload: {
|
|
@@ -44,7 +102,7 @@ const validClientMessages = [
|
|
|
44
102
|
{
|
|
45
103
|
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
46
104
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
47
|
-
topic: (0, types_1.
|
|
105
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
48
106
|
txId: validTxId,
|
|
49
107
|
messageType: 'app_state',
|
|
50
108
|
payload: {
|
|
@@ -67,7 +125,7 @@ const validClientMessages = [
|
|
|
67
125
|
{
|
|
68
126
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
69
127
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
70
|
-
topic: (0, types_1.
|
|
128
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
71
129
|
txId: validTxId,
|
|
72
130
|
messageType: 'status_response',
|
|
73
131
|
payload: {
|
|
@@ -77,7 +135,7 @@ const validClientMessages = [
|
|
|
77
135
|
{
|
|
78
136
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
79
137
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
80
|
-
topic: (0, types_1.
|
|
138
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
81
139
|
txId: validTxId,
|
|
82
140
|
messageType: 'status_response',
|
|
83
141
|
payload: {
|
|
@@ -108,12 +166,12 @@ const validClientMessages = [
|
|
|
108
166
|
},
|
|
109
167
|
},
|
|
110
168
|
];
|
|
111
|
-
const
|
|
169
|
+
const invalidToClientMessages = [
|
|
112
170
|
// invalid txId -> too short
|
|
113
171
|
{
|
|
114
172
|
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
115
173
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
116
|
-
topic: (0, types_1.
|
|
174
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
117
175
|
txId: '124gabaA',
|
|
118
176
|
messageType: 'device_stats',
|
|
119
177
|
payload: {
|
|
@@ -129,7 +187,7 @@ const invalidClientMessages = [
|
|
|
129
187
|
{
|
|
130
188
|
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
131
189
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
132
|
-
topic: (0, types_1.
|
|
190
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
133
191
|
txId: validTxId,
|
|
134
192
|
messageType: 'device_stats',
|
|
135
193
|
payload: {
|
|
@@ -145,7 +203,7 @@ const invalidClientMessages = [
|
|
|
145
203
|
{
|
|
146
204
|
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
147
205
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
148
|
-
topic: (0, types_1.
|
|
206
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
149
207
|
txId: validTxId,
|
|
150
208
|
messageType: 'device_stats',
|
|
151
209
|
payload: {
|
|
@@ -160,7 +218,7 @@ const invalidClientMessages = [
|
|
|
160
218
|
{
|
|
161
219
|
timestamp: 'Mon, 06 Jun 2022 20:21:46 GMT',
|
|
162
220
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
163
|
-
topic: (0, types_1.
|
|
221
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
164
222
|
txId: validTxId,
|
|
165
223
|
messageType: 'app_state',
|
|
166
224
|
payload: {
|
|
@@ -174,7 +232,7 @@ const invalidClientMessages = [
|
|
|
174
232
|
{
|
|
175
233
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
176
234
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
177
|
-
topic: (0, types_1.
|
|
235
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
178
236
|
txId: validTxId,
|
|
179
237
|
messageType: 'app_logs',
|
|
180
238
|
payload: {
|
|
@@ -187,7 +245,7 @@ const invalidClientMessages = [
|
|
|
187
245
|
{
|
|
188
246
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
189
247
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
190
|
-
topic: (0, types_1.
|
|
248
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
191
249
|
txId: validTxId,
|
|
192
250
|
messageType: 'status_response',
|
|
193
251
|
payload: {
|
|
@@ -199,7 +257,7 @@ const invalidClientMessages = [
|
|
|
199
257
|
{
|
|
200
258
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
201
259
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
202
|
-
topic: (0, types_1.
|
|
260
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
203
261
|
messageType: 'status_response',
|
|
204
262
|
payload: {
|
|
205
263
|
txId: validTxId,
|
|
@@ -210,7 +268,7 @@ const invalidClientMessages = [
|
|
|
210
268
|
{
|
|
211
269
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
212
270
|
deviceId: '68195e4f-045c-4a9e-ae50-b87ed4d611f7',
|
|
213
|
-
topic: (0, types_1.
|
|
271
|
+
topic: (0, types_1.getToClientTopic)('68195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
214
272
|
txId: 'dagagfadb',
|
|
215
273
|
messageType: 'status_response',
|
|
216
274
|
payload: {
|
|
@@ -218,10 +276,10 @@ const invalidClientMessages = [
|
|
|
218
276
|
},
|
|
219
277
|
},
|
|
220
278
|
];
|
|
221
|
-
const
|
|
279
|
+
const validToDeviceAgentMessages = [
|
|
222
280
|
{
|
|
223
281
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
224
|
-
topic: (0, types_1.
|
|
282
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
225
283
|
txId: validTxId,
|
|
226
284
|
messageType: 'live_state_updates',
|
|
227
285
|
payload: {
|
|
@@ -231,7 +289,7 @@ const validDeviceAgentMessages = [
|
|
|
231
289
|
},
|
|
232
290
|
{
|
|
233
291
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
234
|
-
topic: (0, types_1.
|
|
292
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
235
293
|
txId: validTxId,
|
|
236
294
|
messageType: 'app_state_control',
|
|
237
295
|
payload: {
|
|
@@ -241,7 +299,7 @@ const validDeviceAgentMessages = [
|
|
|
241
299
|
},
|
|
242
300
|
{
|
|
243
301
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
244
|
-
topic: (0, types_1.
|
|
302
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
245
303
|
txId: validTxId,
|
|
246
304
|
messageType: 'app_version_control',
|
|
247
305
|
payload: {
|
|
@@ -252,7 +310,7 @@ const validDeviceAgentMessages = [
|
|
|
252
310
|
},
|
|
253
311
|
{
|
|
254
312
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
255
|
-
topic: (0, types_1.
|
|
313
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
256
314
|
txId: validTxId,
|
|
257
315
|
messageType: 'app_version_control',
|
|
258
316
|
payload: {
|
|
@@ -271,10 +329,10 @@ const validDeviceAgentMessages = [
|
|
|
271
329
|
},
|
|
272
330
|
},
|
|
273
331
|
];
|
|
274
|
-
const
|
|
332
|
+
const invalidToDeviceAgentMessages = [
|
|
275
333
|
{
|
|
276
334
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
277
|
-
topic: (0, types_1.
|
|
335
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
278
336
|
txId: validTxId,
|
|
279
337
|
messageType: 'live_updates',
|
|
280
338
|
payload: {
|
|
@@ -295,7 +353,7 @@ const invalidDeviceAgentMessages = [
|
|
|
295
353
|
},
|
|
296
354
|
{
|
|
297
355
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
298
|
-
topic: (0, types_1.
|
|
356
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
299
357
|
txId: validTxId,
|
|
300
358
|
messageType: 'app_state_control',
|
|
301
359
|
payload: {
|
|
@@ -306,7 +364,7 @@ const invalidDeviceAgentMessages = [
|
|
|
306
364
|
// Missing appReleaseHash
|
|
307
365
|
{
|
|
308
366
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
309
|
-
topic: (0, types_1.
|
|
367
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
310
368
|
txId: validTxId,
|
|
311
369
|
messageType: 'app_version_control',
|
|
312
370
|
payload: {
|
|
@@ -319,7 +377,7 @@ const invalidDeviceAgentMessages = [
|
|
|
319
377
|
// Missing projectId
|
|
320
378
|
{
|
|
321
379
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
322
|
-
topic: (0, types_1.
|
|
380
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
323
381
|
txId: validTxId,
|
|
324
382
|
messageType: 'app_version_control',
|
|
325
383
|
payload: {
|
|
@@ -331,7 +389,7 @@ const invalidDeviceAgentMessages = [
|
|
|
331
389
|
// missing txId
|
|
332
390
|
{
|
|
333
391
|
timestamp: 'Fri, 27 May 2022 03:47:15 GMT',
|
|
334
|
-
topic: (0, types_1.
|
|
392
|
+
topic: (0, types_1.getToDeviceTopic)('8195e4f-045c-4a9e-ae50-b87ed4d611f7'),
|
|
335
393
|
messageType: 'app_version_control',
|
|
336
394
|
payload: {
|
|
337
395
|
appVersionControl: {
|
|
@@ -340,40 +398,67 @@ const invalidDeviceAgentMessages = [
|
|
|
340
398
|
},
|
|
341
399
|
},
|
|
342
400
|
];
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
401
|
+
/* ============================================================================
|
|
402
|
+
Test To Device Agent Message
|
|
403
|
+
============================================================================ */
|
|
404
|
+
test('test valid to device agent message', () => {
|
|
405
|
+
validToDeviceAgentMessages.forEach((item) => {
|
|
406
|
+
const valid = (0, types_1.validateToDeviceAgentMessage)(item);
|
|
407
|
+
if (!valid) {
|
|
408
|
+
// eslint-disable-next-line no-console
|
|
409
|
+
console.log(item);
|
|
410
|
+
// eslint-disable-next-line no-console
|
|
411
|
+
console.log(types_1.validateToDeviceAgentMessage.errors);
|
|
412
|
+
}
|
|
413
|
+
expect(valid).toBe(true);
|
|
414
|
+
expect(item.messageType in constants_1.toDeviceAgentMessageTypeValues);
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
test('test invalid to device agent message', () => {
|
|
418
|
+
invalidToDeviceAgentMessages.forEach((item) => {
|
|
419
|
+
expect((0, types_1.validateToDeviceAgentMessage)(item)).toBe(false);
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
/* ============================================================================
|
|
423
|
+
Test To Cloud Message
|
|
424
|
+
============================================================================ */
|
|
425
|
+
test('test valid to cloud message', () => {
|
|
426
|
+
validToCloudMessages.forEach((item) => {
|
|
427
|
+
const valid = (0, types_1.validateToCloudMessage)(item);
|
|
346
428
|
if (!valid) {
|
|
347
429
|
// eslint-disable-next-line no-console
|
|
348
430
|
console.log(item);
|
|
349
431
|
// eslint-disable-next-line no-console
|
|
350
|
-
console.log(types_1.
|
|
432
|
+
console.log(types_1.validateToCloudMessage.errors);
|
|
351
433
|
}
|
|
352
434
|
expect(valid).toBe(true);
|
|
353
|
-
expect(item.messageType in constants_1.
|
|
435
|
+
expect(item.messageType in constants_1.toCloudMessageTypeValues);
|
|
354
436
|
});
|
|
355
437
|
});
|
|
356
|
-
test('test invalid
|
|
357
|
-
|
|
358
|
-
expect((0, types_1.
|
|
438
|
+
test('test invalid to cloud message', () => {
|
|
439
|
+
invalidToCloudMessages.forEach((item) => {
|
|
440
|
+
expect((0, types_1.validateToCloudMessage)(item)).toBe(false);
|
|
359
441
|
});
|
|
360
442
|
});
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
443
|
+
/* ============================================================================
|
|
444
|
+
Test To Client Message
|
|
445
|
+
============================================================================ */
|
|
446
|
+
test('test valid to client message', () => {
|
|
447
|
+
validToClientMessages.forEach((item) => {
|
|
448
|
+
const valid = (0, types_1.validateToClientMessage)(item);
|
|
364
449
|
if (!valid) {
|
|
365
450
|
// eslint-disable-next-line no-console
|
|
366
451
|
console.log(item);
|
|
367
452
|
// eslint-disable-next-line no-console
|
|
368
|
-
console.log(types_1.
|
|
453
|
+
console.log(types_1.validateToClientMessage.errors);
|
|
369
454
|
}
|
|
370
455
|
expect(valid).toBe(true);
|
|
371
|
-
expect(item.messageType in constants_1.
|
|
456
|
+
expect(item.messageType in constants_1.toClientMessageTypeValues);
|
|
372
457
|
});
|
|
373
458
|
});
|
|
374
|
-
test('test invalid client message', () => {
|
|
375
|
-
|
|
376
|
-
expect((0, types_1.
|
|
459
|
+
test('test invalid to client message', () => {
|
|
460
|
+
invalidToClientMessages.forEach((item) => {
|
|
461
|
+
expect((0, types_1.validateToClientMessage)(item)).toBe(false);
|
|
377
462
|
});
|
|
378
463
|
});
|
|
379
464
|
//# sourceMappingURL=types.test.js.map
|