@alwaysai/device-agent-schemas 3.1.0 → 3.1.2
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/README.md +0 -59
- package/lib/app-action-schema.d.ts +3 -1
- package/lib/app-logs-schema.d.ts +1 -1
- package/lib/app-state-schema.d.ts +1 -1
- package/lib/common.d.ts +18 -0
- package/lib/common.js +3 -0
- package/lib/device-action-schema.d.ts +1 -1
- package/lib/device-agent-action-schema.d.ts +1 -1
- package/lib/device-stats-schema.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/schemas/app-install-response-schema.json +3 -6
- package/lib/schemas/app-install-schema.json +7 -2
- package/lib/schemas/app-logs-schema.json +1 -2
- package/lib/schemas/app-state-control-schema.json +1 -2
- package/lib/schemas/app-state-schema.json +0 -4
- package/lib/schemas/app-uninstall-schema.json +1 -2
- package/lib/schemas/device-action-schema.json +1 -2
- package/lib/schemas/device-agent-status-schema.json +0 -2
- package/lib/schemas/device-stats-schema.json +0 -1
- package/lib/schemas/live-updates-toggle-schema.json +2 -4
- package/lib/schemas/models-install-payload-schema.json +1 -2
- package/lib/schemas/models-install-response-schema.json +2 -4
- package/lib/schemas/secure-tunnel-schema.json +0 -1
- package/lib/schemas/shadow-project-update-legacy-schema.json +4 -4
- package/lib/schemas/shadow-project-update-schema.json +1 -2
- package/lib/schemas/shadow-projects-update-all-schema.json +1 -1
- package/lib/schemas/signed-urls-request-schema.json +3 -6
- package/lib/schemas/status-response-schema.json +1 -2
- package/lib/schemas/system-information-schema.json +7 -15
- package/lib/schemas/to-client-message-schema.json +2 -8
- package/lib/schemas/to-cloud-message-schema.json +1 -4
- package/lib/schemas/to-device-agent-message-schema.json +3 -11
- package/lib/signed-urls-request-schema.d.ts +1 -1
- package/lib/status-response-schema.d.ts +2 -1
- package/lib/types.d.ts +2 -19
- package/lib/types.js +1 -0
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -1,64 +1,5 @@
|
|
|
1
1
|
# alwaysAI Device Agent Schemas
|
|
2
2
|
|
|
3
3
|
## Contents
|
|
4
|
-
* [Documentation](docs/README.md)
|
|
5
4
|
* [Schemas](src/schemas)
|
|
6
5
|
|
|
7
|
-
The alwaysAI Device Agent Schemas package provides interfaces that represent the messaging interface for communication with the alwaysAI Device Agent, as well as functions for validating JSON data that are being used as device agent messages.
|
|
8
|
-
|
|
9
|
-
## Use in Development
|
|
10
|
-
Use the provided interfaces as type guards in your development to ensure that proper messages are generated.
|
|
11
|
-
|
|
12
|
-
The provided interfaces are:
|
|
13
|
-
|
|
14
|
-
- DeviceStats,
|
|
15
|
-
- DeviceStatsPayload,
|
|
16
|
-
- AppState,
|
|
17
|
-
- AppStateValue,
|
|
18
|
-
- ServiceStatus,
|
|
19
|
-
- AppDetails,
|
|
20
|
-
- AppStatePayload,
|
|
21
|
-
- InstallationStatus,
|
|
22
|
-
- InstallationStatusMessage,
|
|
23
|
-
- AppLogs,
|
|
24
|
-
- AppLogsPayload,
|
|
25
|
-
- AppStateControlValue,
|
|
26
|
-
- AppVersionControlValue,
|
|
27
|
-
- AppStateControl,
|
|
28
|
-
- AppVersionControl,
|
|
29
|
-
- AppActionMessage,
|
|
30
|
-
- AgentActionValue,
|
|
31
|
-
- LiveUpdatesToggles,
|
|
32
|
-
- DeviceAgentMessage,
|
|
33
|
-
- ClientMessage,
|
|
34
|
-
|
|
35
|
-
## Runtime Message Validation
|
|
36
|
-
You can also incorporated the provided validation methods to ensure that incoming JSON data are properly formatted at runtime.
|
|
37
|
-
|
|
38
|
-
`validateDeviceAgentMessage` can be used to validate any package as a whole to verify that it is a valid device agent message. There are more granular validation methods for verifying packets for a specific type of device agent message. These methods are:
|
|
39
|
-
|
|
40
|
-
- validateDeviceStatsMessage,
|
|
41
|
-
- validateAppStateMessage,
|
|
42
|
-
- validateInstallationStatusMessage,
|
|
43
|
-
- validateAppLogsMessage,
|
|
44
|
-
- validateAppActionMessage,
|
|
45
|
-
- validateAgentActionMessage,
|
|
46
|
-
- validateDeviceAgentMessage,
|
|
47
|
-
- validateClientMessage,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## System Requirements
|
|
51
|
-
|
|
52
|
-
* `npm` >= 7.0.0
|
|
53
|
-
* `node` >= 16.0.0
|
|
54
|
-
|
|
55
|
-
# Release Process
|
|
56
|
-
|
|
57
|
-
> **NOTE**: Ensure unit tests are passing and new functionality is verified prior to release!
|
|
58
|
-
|
|
59
|
-
## Release procedure
|
|
60
|
-
To release the package to [npmjs.org](https://www.npmjs.com/package/@alwaysai/device-agent-schemas) follow the steps:
|
|
61
|
-
|
|
62
|
-
- publish new version: <code>npm run publish:<major|minor|patch></code>
|
|
63
|
-
- watch the [bitbucket pipeline](https://bitbucket.org/alwaysai/device-agent-schemas/pipelines) running, if successful a new version will be created and published to npmjs.org
|
|
64
|
-
- to get the auto-generated commit and tags, simply pull: <code>git pull</code>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppInstallResponseMessageType, AppStateControlMessageType, AppStateControlValue, AppVersionControlMessageType, ModelsInstallResponseMessageType, keyMirrors } from './constants';
|
|
2
|
-
import { BaseToDeviceAgentMessage } from './
|
|
2
|
+
import { BaseToDeviceAgentMessage } from './common';
|
|
3
3
|
export interface AppStateControlPayload {
|
|
4
4
|
baseCommand: AppStateControlValue;
|
|
5
5
|
projectId: string;
|
|
@@ -12,6 +12,8 @@ export declare type AppVersionControlInstallPayload = {
|
|
|
12
12
|
baseCommand: typeof keyMirrors.appVersionControl.install;
|
|
13
13
|
projectId: string;
|
|
14
14
|
appReleaseHash: string;
|
|
15
|
+
cfg?: string;
|
|
16
|
+
env_vars?: string;
|
|
15
17
|
};
|
|
16
18
|
export declare type AppVersionControlUninstallPayload = {
|
|
17
19
|
baseCommand: typeof keyMirrors.appVersionControl.uninstall;
|
package/lib/app-logs-schema.d.ts
CHANGED
package/lib/common.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface BaseToCloudMessage {
|
|
2
|
+
deviceId: string;
|
|
3
|
+
timestamp: string;
|
|
4
|
+
topic?: string;
|
|
5
|
+
txId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface BaseToClientMessage {
|
|
8
|
+
deviceId: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
topic?: string;
|
|
11
|
+
txId: string;
|
|
12
|
+
}
|
|
13
|
+
export interface BaseToDeviceAgentMessage {
|
|
14
|
+
timestamp: string;
|
|
15
|
+
topic?: string;
|
|
16
|
+
txId: string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=common.d.ts.map
|
package/lib/common.js
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LiveStateUpdatesTogglesMessageType } from './constants';
|
|
2
|
-
import { BaseToDeviceAgentMessage } from './
|
|
2
|
+
import { BaseToDeviceAgentMessage } from './common';
|
|
3
3
|
export interface LiveStateUpdatesTogglePayload {
|
|
4
4
|
deviceStats?: boolean;
|
|
5
5
|
appState?: boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateToDeviceAgentMessage, validateToClientMessage,
|
|
1
|
+
import { validateToDeviceAgentMessage, validateToClientMessage, ToDeviceAgentMessage, ToDeviceAgentMessagePayload, ToClientMessage, ToClientMessagePayload, ToCloudMessage, ToCloudMessagePayload, getToClientTopic, getToCloudTopic, getToDeviceTopic, validateToCloudMessage } from './types';
|
|
2
2
|
import { generateTxId } from './utils';
|
|
3
3
|
import { AppDetails, AppState, ServiceStatus, AppStatePayload, AppStateMessage } from './app-state-schema';
|
|
4
4
|
import { AppLogsPayload, AppLogsMessage } from './app-logs-schema';
|
|
@@ -11,5 +11,5 @@ import { SignedUrlsRequestPayload, SignedUrlsRequestMessage } from './signed-url
|
|
|
11
11
|
import { DeviceActionPayload } from './device-action-schema';
|
|
12
12
|
import { buildAppLogsMessage, buildAppStateMessage, buildAppVersionControlMessage, buildLiveStateUpdatesToggleMessage, buildAppStateControlMessage, buildDeviceActionMessage, buildDeviceStatsMessage, buildSignedUrlsRequestMessage, buildToClientStatusResponseMessage, buildToDeviceStatusResponseMessage } from './message-builders';
|
|
13
13
|
import { ProjectShadowUpdate, ShadowProjectsUpdateAll, validateProjectShadowUpdate, validateShadowProjectsUpdateAll, SystemInformationShadowUpdate, SecureTunnelPortInfo, SecureTunnelShadowUpdate, validateSecureTunnelShadowUpdate, validateSystemInformationShadowUpdate, buildBaseShadowMessage, buildUpdateShadowMessage, ShadowTopics, ShadowNames, getShadowTopic, getDesiredFromMessage, getReportedFromMessage, getUpdateDeltaStateFromMessage, ShadowUpdateTypes, EnvVars, validateEnvVarSchemaShadowUpdate } from './shadow-schema';
|
|
14
|
-
export { getToClientTopic, getToCloudTopic, getToDeviceTopic, getShadowTopic, getDesiredFromMessage, getReportedFromMessage, getUpdateDeltaStateFromMessage, AppDetails, ServiceStatus, AppState, AppStateControlValue, AppStateValue, ProjectShadowUpdate, ShadowProjectsUpdateAll, SystemInformationShadowUpdate, SecureTunnelPortInfo, SecureTunnelShadowUpdate, EnvVars, ToCloudMessageTypeValue, AppStateControlMessageType, AppLogsMessageType, DeviceStatsMessageType, AppStateMessageType, SignedUrlsRequestMessageType, StatusResponseMessageType, ShadowUpdateTypes, ModelInstallPayload, ToClientStatusResponseMessage, ToDeviceStatusResponseMessage, StatusResponseValue, AppStateControlMessage, LiveStateUpdatesTogglePayload, LiveStateUpdatesToggleMessage, DeviceStatsPayload, DeviceStatsMessage, AppStatePayload, AppStateMessage, AppLogsPayload, AppLogsMessage, StatusResponsePayload, AppStateControlPayload, AppVersionControlInstallPayload, AppVersionControlUninstallPayload, AppVersionControlMessage, AppInstallResponsePayload, ModelsInstallResponsePayload, SignedUrlsRequestPayload, SignedUrlsRequestMessage,
|
|
14
|
+
export { getToClientTopic, getToCloudTopic, getToDeviceTopic, getShadowTopic, getDesiredFromMessage, getReportedFromMessage, getUpdateDeltaStateFromMessage, AppDetails, ServiceStatus, AppState, AppStateControlValue, AppStateValue, ProjectShadowUpdate, ShadowProjectsUpdateAll, SystemInformationShadowUpdate, SecureTunnelPortInfo, SecureTunnelShadowUpdate, EnvVars, ToCloudMessageTypeValue, AppStateControlMessageType, AppLogsMessageType, DeviceStatsMessageType, AppStateMessageType, SignedUrlsRequestMessageType, StatusResponseMessageType, ShadowUpdateTypes, ModelInstallPayload, ToClientStatusResponseMessage, ToDeviceStatusResponseMessage, StatusResponseValue, AppStateControlMessage, LiveStateUpdatesTogglePayload, LiveStateUpdatesToggleMessage, DeviceStatsPayload, DeviceStatsMessage, AppStatePayload, AppStateMessage, AppLogsPayload, AppLogsMessage, StatusResponsePayload, AppStateControlPayload, AppVersionControlInstallPayload, AppVersionControlUninstallPayload, AppVersionControlMessage, AppInstallResponsePayload, ModelsInstallResponsePayload, SignedUrlsRequestPayload, SignedUrlsRequestMessage, ToDeviceAgentMessage, ToDeviceAgentMessagePayload, ToDeviceAgentMessageTypeValue, ToClientMessage, ToClientMessagePayload, ToClientMessageTypeValue, ToCloudMessage, ToCloudMessagePayload, DeviceActionPayload, validateToDeviceAgentMessage, validateToClientMessage, validateToCloudMessage, validateShadowProjectsUpdateAll, validateProjectShadowUpdate, validateSystemInformationShadowUpdate, validateSecureTunnelShadowUpdate, validateEnvVarSchemaShadowUpdate, buildAppLogsMessage, buildAppStateMessage, buildDeviceStatsMessage, buildSignedUrlsRequestMessage, buildToClientStatusResponseMessage, buildToDeviceStatusResponseMessage, buildAppVersionControlMessage, buildLiveStateUpdatesToggleMessage, buildAppStateControlMessage, buildDeviceActionMessage, buildBaseShadowMessage, buildUpdateShadowMessage, keyMirrors, ShadowTopics, ShadowNames, generateTxId };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"type": "string"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
"required": ["appSignedUrl"]
|
|
24
|
-
"additionalProperties": false
|
|
23
|
+
"required": ["appSignedUrl"]
|
|
25
24
|
},
|
|
26
25
|
"modelsInstallPayload": {
|
|
27
26
|
"$ref": "https://alwaysai.co/models-install-payload-schema.json"
|
|
@@ -32,10 +31,8 @@
|
|
|
32
31
|
"appReleaseHash",
|
|
33
32
|
"appInstallPayload",
|
|
34
33
|
"modelsInstallPayload"
|
|
35
|
-
]
|
|
36
|
-
"additionalProperties": false
|
|
34
|
+
]
|
|
37
35
|
}
|
|
38
36
|
},
|
|
39
|
-
"required": ["appInstallResponse"]
|
|
40
|
-
"additionalProperties": false
|
|
37
|
+
"required": ["appInstallResponse"]
|
|
41
38
|
}
|
|
@@ -13,8 +13,13 @@
|
|
|
13
13
|
},
|
|
14
14
|
"appReleaseHash": {
|
|
15
15
|
"$ref": "https://alwaysai.co/common-schema.json#/$defs/appReleaseHash"
|
|
16
|
+
},
|
|
17
|
+
"appConfig": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"envVars": {
|
|
21
|
+
"type": "string"
|
|
16
22
|
}
|
|
17
23
|
},
|
|
18
|
-
"required": ["baseCommand", "projectId", "appReleaseHash"]
|
|
19
|
-
"additionalProperties": false
|
|
24
|
+
"required": ["baseCommand", "projectId", "appReleaseHash"]
|
|
20
25
|
}
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"$ref": "https://alwaysai.co/common-schema.json#/$defs/appReleaseHash"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
"additionalProperties": false,
|
|
23
22
|
"required": ["projectId", "version"]
|
|
24
23
|
},
|
|
25
24
|
"services": {
|
|
@@ -34,16 +33,13 @@
|
|
|
34
33
|
"enum": ["up", "stopped", "restarting"]
|
|
35
34
|
}
|
|
36
35
|
},
|
|
37
|
-
"additionalProperties": false,
|
|
38
36
|
"required": ["name", "state"]
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
},
|
|
42
|
-
"additionalProperties": false,
|
|
43
40
|
"required": ["appDetails", "services"]
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
},
|
|
47
|
-
"additionalProperties": false,
|
|
48
44
|
"required": ["appState"]
|
|
49
45
|
}
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
"$ref": "https://alwaysai.co/models-install-payload-schema.json"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"required": ["projectId", "newModels"]
|
|
18
|
-
"additionalProperties": false
|
|
17
|
+
"required": ["projectId", "newModels"]
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
|
-
"required": ["modelsInstallResponse"]
|
|
22
|
-
"additionalProperties": false
|
|
20
|
+
"required": ["modelsInstallResponse"]
|
|
23
21
|
}
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"type": ["string", "null"]
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"required": []
|
|
21
|
+
"required": [],
|
|
22
|
+
"additionalProperties": false
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
"required": [],
|
|
25
|
-
"additionalProperties":
|
|
26
|
+
"additionalProperties": false
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
|
-
"required": []
|
|
29
|
-
"additionalProperties": true
|
|
29
|
+
"required": []
|
|
30
30
|
}
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"$ref": "https://alwaysai.co/common-schema.json#/$defs/appReleaseHash"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"required": ["projectId", "appReleaseHash"]
|
|
18
|
-
"additionalProperties": false
|
|
17
|
+
"required": ["projectId", "appReleaseHash"]
|
|
19
18
|
},
|
|
20
19
|
"modelsOnlyUrlsRequest": {
|
|
21
20
|
"type": "object",
|
|
@@ -33,10 +32,8 @@
|
|
|
33
32
|
"additionalProperties": false
|
|
34
33
|
}
|
|
35
34
|
},
|
|
36
|
-
"required": ["projectId", "models"]
|
|
37
|
-
"additionalProperties": false
|
|
35
|
+
"required": ["projectId", "models"]
|
|
38
36
|
}
|
|
39
37
|
},
|
|
40
|
-
"required": []
|
|
41
|
-
"additionalProperties": false
|
|
38
|
+
"required": []
|
|
42
39
|
}
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
"hostname": {
|
|
26
26
|
"type": "string"
|
|
27
27
|
}
|
|
28
|
-
}
|
|
29
|
-
"additionalProperties": false
|
|
28
|
+
}
|
|
30
29
|
},
|
|
31
30
|
"cpu": {
|
|
32
31
|
"type": "object",
|
|
@@ -55,8 +54,7 @@
|
|
|
55
54
|
"processors": {
|
|
56
55
|
"type": "string"
|
|
57
56
|
}
|
|
58
|
-
}
|
|
59
|
-
"additionalProperties": false
|
|
57
|
+
}
|
|
60
58
|
},
|
|
61
59
|
"disk": {
|
|
62
60
|
"type": "object",
|
|
@@ -81,12 +79,10 @@
|
|
|
81
79
|
"size": {
|
|
82
80
|
"type": "string"
|
|
83
81
|
}
|
|
84
|
-
}
|
|
85
|
-
"additionalProperties": false
|
|
82
|
+
}
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
85
|
},
|
|
89
|
-
"additionalProperties": false,
|
|
90
86
|
"required": []
|
|
91
87
|
},
|
|
92
88
|
"device": {
|
|
@@ -107,8 +103,7 @@
|
|
|
107
103
|
"virtual": {
|
|
108
104
|
"type": "boolean"
|
|
109
105
|
}
|
|
110
|
-
}
|
|
111
|
-
"additionalProperties": false
|
|
106
|
+
}
|
|
112
107
|
},
|
|
113
108
|
"network": {
|
|
114
109
|
"type": "object",
|
|
@@ -122,8 +117,7 @@
|
|
|
122
117
|
"macAddress": {
|
|
123
118
|
"type": "string"
|
|
124
119
|
}
|
|
125
|
-
}
|
|
126
|
-
"additionalProperties": false
|
|
120
|
+
}
|
|
127
121
|
},
|
|
128
122
|
"versions": {
|
|
129
123
|
"type": "object",
|
|
@@ -146,12 +140,10 @@
|
|
|
146
140
|
"dockerCompose": {
|
|
147
141
|
"type": "string"
|
|
148
142
|
}
|
|
149
|
-
}
|
|
150
|
-
"additionalProperties": false
|
|
143
|
+
}
|
|
151
144
|
},
|
|
152
145
|
"lastBootTime": {
|
|
153
146
|
"type": "string"
|
|
154
147
|
}
|
|
155
|
-
}
|
|
156
|
-
"additionalProperties": false
|
|
148
|
+
}
|
|
157
149
|
}
|
|
@@ -28,14 +28,10 @@
|
|
|
28
28
|
"$ref": "https://alwaysai.co/common-schema.json#/$defs/txId"
|
|
29
29
|
},
|
|
30
30
|
"payload": {
|
|
31
|
-
"
|
|
32
|
-
{ "$ref": "https://alwaysai.co/device-stats-schema.json" },
|
|
33
|
-
{ "$ref": "https://alwaysai.co/app-state-schema.json" },
|
|
34
|
-
{ "$ref": "https://alwaysai.co/app-logs-schema.json" },
|
|
35
|
-
{ "$ref": "https://alwaysai.co/status-response-schema.json" }
|
|
36
|
-
]
|
|
31
|
+
"type": "object"
|
|
37
32
|
}
|
|
38
33
|
},
|
|
34
|
+
"required": ["timestamp", "deviceId", "messageType", "txId", "payload"],
|
|
39
35
|
"allOf": [
|
|
40
36
|
{
|
|
41
37
|
"if": {
|
|
@@ -86,8 +82,6 @@
|
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
84
|
],
|
|
89
|
-
"required": ["timestamp", "deviceId", "txId", "payload", "messageType"],
|
|
90
|
-
"additionalProperties": false,
|
|
91
85
|
"$defs": {
|
|
92
86
|
"toClient": {
|
|
93
87
|
"description": "Messages sent from the device agent to console client",
|
|
@@ -25,9 +25,7 @@
|
|
|
25
25
|
"$ref": "https://alwaysai.co/common-schema.json#/$defs/txId"
|
|
26
26
|
},
|
|
27
27
|
"payload": {
|
|
28
|
-
"
|
|
29
|
-
{ "$ref": "https://alwaysai.co/signed-urls-request-schema.json" }
|
|
30
|
-
]
|
|
28
|
+
"type": "object"
|
|
31
29
|
}
|
|
32
30
|
},
|
|
33
31
|
"allOf": [
|
|
@@ -45,7 +43,6 @@
|
|
|
45
43
|
}
|
|
46
44
|
],
|
|
47
45
|
"required": ["timestamp", "deviceId", "txId", "payload", "messageType"],
|
|
48
|
-
"additionalProperties": false,
|
|
49
46
|
"$defs": {
|
|
50
47
|
"toCloud": {
|
|
51
48
|
"description": "Messages sent from the device agent to cloud backend client",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"enum": [
|
|
15
15
|
"app_state_control",
|
|
16
16
|
"app_version_control",
|
|
17
|
+
"fleet_app_version_control",
|
|
17
18
|
"app_install_response",
|
|
18
19
|
"models_install_response",
|
|
19
20
|
"live_state_updates",
|
|
@@ -25,17 +26,10 @@
|
|
|
25
26
|
"$ref": "https://alwaysai.co/common-schema.json#/$defs/txId"
|
|
26
27
|
},
|
|
27
28
|
"payload": {
|
|
28
|
-
"
|
|
29
|
-
{ "$ref": "https://alwaysai.co/app-state-control-schema.json" },
|
|
30
|
-
{ "$ref": "https://alwaysai.co/app-version-control-schema.json" },
|
|
31
|
-
{ "$ref": "https://alwaysai.co/app-install-response-schema.json" },
|
|
32
|
-
{ "$ref": "https://alwaysai.co/models-install-response-schema.json" },
|
|
33
|
-
{ "$ref": "https://alwaysai.co/live-updates-toggle-schema.json" },
|
|
34
|
-
{ "$ref": "https://alwaysai.co/device-action-schema.json" },
|
|
35
|
-
{ "$ref": "https://alwaysai.co/status-response-schema.json" }
|
|
36
|
-
]
|
|
29
|
+
"type": "object"
|
|
37
30
|
}
|
|
38
31
|
},
|
|
32
|
+
"required": ["messageType", "timestamp", "txId", "payload"],
|
|
39
33
|
"allOf": [
|
|
40
34
|
{
|
|
41
35
|
"if": {
|
|
@@ -122,8 +116,6 @@
|
|
|
122
116
|
}
|
|
123
117
|
}
|
|
124
118
|
],
|
|
125
|
-
"required": ["timestamp", "txId", "payload", "messageType"],
|
|
126
|
-
"additionalProperties": false,
|
|
127
119
|
"$defs": {
|
|
128
120
|
"toDevice": {
|
|
129
121
|
"description": "Topic on which messages are sent to device agent.",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { BaseToDeviceAgentMessage } from './common';
|
|
1
2
|
import { StatusResponseMessageType, StatusResponseValue } from './constants';
|
|
2
|
-
import { BaseToClientMessage
|
|
3
|
+
import { BaseToClientMessage } from './common';
|
|
3
4
|
export interface StatusResponsePayload {
|
|
4
5
|
status: StatusResponseValue;
|
|
5
6
|
message?: string;
|
package/lib/types.d.ts
CHANGED
|
@@ -9,29 +9,12 @@ import { DeviceActionMessage, DeviceActionPayload } from './device-action-schema
|
|
|
9
9
|
export declare const getToClientTopic: (deviceUuid: string, deviceType?: string) => string;
|
|
10
10
|
export declare const getToCloudTopic: (deviceUuid: string, deviceType?: string) => string;
|
|
11
11
|
export declare const getToDeviceTopic: (deviceUuid: string, deviceType?: string) => string;
|
|
12
|
-
export interface BaseToClientMessage {
|
|
13
|
-
deviceId: string;
|
|
14
|
-
timestamp: string;
|
|
15
|
-
topic?: string;
|
|
16
|
-
txId: string;
|
|
17
|
-
}
|
|
18
12
|
export declare type ToClientMessage = AppLogsMessage | ToClientStatusResponseMessage | AppStateMessage | DeviceStatsMessage;
|
|
19
13
|
export declare type ToClientMessagePayload = AppLogsPayload | AppStatePayload | DeviceStatsPayload | StatusResponsePayload;
|
|
20
|
-
export declare const validateToClientMessage: import("ajv/dist/types").ValidateFunction<
|
|
21
|
-
export interface BaseToCloudMessage {
|
|
22
|
-
deviceId: string;
|
|
23
|
-
timestamp: string;
|
|
24
|
-
topic?: string;
|
|
25
|
-
txId: string;
|
|
26
|
-
}
|
|
14
|
+
export declare const validateToClientMessage: import("ajv/dist/types").ValidateFunction<ToClientMessage>;
|
|
27
15
|
export declare type ToCloudMessage = SignedUrlsRequestMessage;
|
|
28
16
|
export declare type ToCloudMessagePayload = SignedUrlsRequestPayload;
|
|
29
|
-
export declare const validateToCloudMessage: import("ajv/dist/types").ValidateFunction<
|
|
30
|
-
export interface BaseToDeviceAgentMessage {
|
|
31
|
-
timestamp: string;
|
|
32
|
-
topic?: string;
|
|
33
|
-
txId: string;
|
|
34
|
-
}
|
|
17
|
+
export declare const validateToCloudMessage: import("ajv/dist/types").ValidateFunction<SignedUrlsRequestMessage>;
|
|
35
18
|
export declare type ToDeviceAgentMessage = AppStateControlMessage | AppVersionControlMessage | LiveStateUpdatesToggleMessage | ToDeviceStatusResponseMessage | AppInstallResponseMessage | ModelsInstallResponseMessage | DeviceActionMessage;
|
|
36
19
|
export declare type ToDeviceAgentMessagePayload = AppStateControlPayload | AppVersionControlInstallPayload | AppVersionControlUninstallPayload | LiveStateUpdatesTogglePayload | StatusResponsePayload | AppInstallResponsePayload | ModelsInstallResponsePayload | DeviceActionPayload;
|
|
37
20
|
export declare const validateToDeviceAgentMessage: import("ajv/dist/types").ValidateFunction<ToDeviceAgentMessage>;
|
package/lib/types.js
CHANGED
|
@@ -25,6 +25,7 @@ const deviceActionSchema = require("./schemas/device-action-schema.json");
|
|
|
25
25
|
// automatically be added in the compile step due to $ref usage (and $id lookup)
|
|
26
26
|
const ajv = new _2019_1.default({
|
|
27
27
|
allErrors: true,
|
|
28
|
+
verbose: true,
|
|
28
29
|
schemas: [commonSchema]
|
|
29
30
|
});
|
|
30
31
|
const getToClientTopic = (deviceUuid, deviceType = constants_1.DEVICE_TYPE) => `${constants_1.CLIENT_TOPIC_PREFIX}/${deviceType}/${deviceUuid}`;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwaysai/device-agent-schemas",
|
|
3
3
|
"description": "alwaysAI schemas",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"build:clean": "npm run clean && npm run build",
|
|
19
19
|
"build:watch": "tsc --project . --watch",
|
|
20
20
|
"clean": "rimraf lib packages coverage",
|
|
21
|
-
"gen-docs": "mkdir -p docs && jsonschema2md -o docs -d src/schemas -e json",
|
|
22
21
|
"lint": "eslint . --ext .ts",
|
|
23
22
|
"lint:fix": "npm run lint -- --fix",
|
|
24
23
|
"test": "npm run lint && npm run test:unit && npm run build:clean",
|
|
@@ -29,14 +28,13 @@
|
|
|
29
28
|
"postversion": "npm publish",
|
|
30
29
|
"publish:major": "git push && git tag -f major && git push -f origin major && git tag -d major",
|
|
31
30
|
"publish:minor": "git push && git tag -f minor && git push -f origin minor && git tag -d minor",
|
|
32
|
-
"publish:patch": "git push && git tag -f patch && git push -f origin patch && git tag -d patch"
|
|
31
|
+
"publish:patch": "[ \"$(git rev-parse --abbrev-ref HEAD)\" = \"main\" ] && git pull && git push && git tag -f patch && git push -f origin patch && git tag -d patch || echo \"Error: Not on main branch\""
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
34
|
"ajv": "8.11.0",
|
|
36
35
|
"uuid": "9.0.0"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@adobe/jsonschema2md": "^7.1.5",
|
|
40
38
|
"@alwaysai/eslint-config": "^0.1.3",
|
|
41
39
|
"@alwaysai/tsconfig": "^0.0.1",
|
|
42
40
|
"@types/jest": "27.0.3",
|