@alwaysai/device-agent-schemas 2.3.4 → 2.4.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/index.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ import { StatusResponsePayload, ToClientStatusResponseMessage, ToDeviceStatusRes
|
|
|
10
10
|
import { SignedUrlsRequestPayload, SignedUrlsRequestMessage } from './signed-urls-request-schema';
|
|
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
|
-
import { ProjectShadowUpdate, ShadowProjectsUpdateAll, validateProjectShadowUpdate, validateShadowProjectsUpdateAll, SystemInformationShadowUpdate, SecureTunnelPortInfo,
|
|
14
|
-
export { getToClientTopic, getToCloudTopic, getToDeviceTopic, getShadowTopic, getDesiredFromMessage, AppDetails, ServiceStatus, AppState, AppStateControlValue, AppStateValue, ProjectShadowUpdate, ShadowProjectsUpdateAll, SystemInformationShadowUpdate, SecureTunnelPortInfo,
|
|
13
|
+
import { ProjectShadowUpdate, ShadowProjectsUpdateAll, validateProjectShadowUpdate, validateShadowProjectsUpdateAll, SystemInformationShadowUpdate, SecureTunnelPortInfo, SecureTunnelShadowUpdate, validateSecureTunnelShadowUpdate, validateSystemInformationShadowUpdate, buildBaseShadowMessage, ShadowTopics, ShadowNames, getShadowTopic, getDesiredFromMessage, getReportedFromMessage, ShadowUpdateTypes } from './shadow-schema';
|
|
14
|
+
export { getToClientTopic, getToCloudTopic, getToDeviceTopic, getShadowTopic, getDesiredFromMessage, getReportedFromMessage, AppDetails, ServiceStatus, AppState, AppStateControlValue, AppStateValue, ProjectShadowUpdate, ShadowProjectsUpdateAll, SystemInformationShadowUpdate, SecureTunnelPortInfo, SecureTunnelShadowUpdate, 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, BaseToDeviceAgentMessage, ToDeviceAgentMessage, ToDeviceAgentMessagePayload, ToDeviceAgentMessageTypeValue, BaseToClientMessage, ToClientMessage, ToClientMessagePayload, ToClientMessageTypeValue, BaseToCloudMessage, ToCloudMessage, ToCloudMessagePayload, DeviceActionPayload, validateToDeviceAgentMessage, validateToClientMessage, validateToCloudMessage, validateShadowProjectsUpdateAll, validateProjectShadowUpdate, validateSystemInformationShadowUpdate, validateSecureTunnelShadowUpdate, buildAppLogsMessage, buildAppStateMessage, buildDeviceStatsMessage, buildSignedUrlsRequestMessage, buildToClientStatusResponseMessage, buildToDeviceStatusResponseMessage, buildAppVersionControlMessage, buildLiveStateUpdatesToggleMessage, buildAppStateControlMessage, buildDeviceActionMessage, buildBaseShadowMessage, keyMirrors, ShadowTopics, ShadowNames, generateTxId };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateTxId = exports.ShadowTopics = exports.keyMirrors = exports.
|
|
3
|
+
exports.generateTxId = exports.ShadowTopics = exports.keyMirrors = exports.buildBaseShadowMessage = exports.buildDeviceActionMessage = exports.buildAppStateControlMessage = exports.buildLiveStateUpdatesToggleMessage = exports.buildAppVersionControlMessage = exports.buildToDeviceStatusResponseMessage = exports.buildToClientStatusResponseMessage = exports.buildSignedUrlsRequestMessage = exports.buildDeviceStatsMessage = exports.buildAppStateMessage = exports.buildAppLogsMessage = exports.validateSecureTunnelShadowUpdate = exports.validateSystemInformationShadowUpdate = exports.validateProjectShadowUpdate = exports.validateShadowProjectsUpdateAll = exports.validateToCloudMessage = exports.validateToClientMessage = exports.validateToDeviceAgentMessage = exports.getReportedFromMessage = exports.getDesiredFromMessage = exports.getShadowTopic = exports.getToDeviceTopic = exports.getToCloudTopic = exports.getToClientTopic = void 0;
|
|
4
4
|
// export types here
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
Object.defineProperty(exports, "validateToDeviceAgentMessage", { enumerable: true, get: function () { return types_1.validateToDeviceAgentMessage; } });
|
|
@@ -30,10 +30,8 @@ Object.defineProperty(exports, "validateShadowProjectsUpdateAll", { enumerable:
|
|
|
30
30
|
Object.defineProperty(exports, "validateSecureTunnelShadowUpdate", { enumerable: true, get: function () { return shadow_schema_1.validateSecureTunnelShadowUpdate; } });
|
|
31
31
|
Object.defineProperty(exports, "validateSystemInformationShadowUpdate", { enumerable: true, get: function () { return shadow_schema_1.validateSystemInformationShadowUpdate; } });
|
|
32
32
|
Object.defineProperty(exports, "buildBaseShadowMessage", { enumerable: true, get: function () { return shadow_schema_1.buildBaseShadowMessage; } });
|
|
33
|
-
Object.defineProperty(exports, "buildUpdateProjectShadowMessage", { enumerable: true, get: function () { return shadow_schema_1.buildUpdateProjectShadowMessage; } });
|
|
34
|
-
Object.defineProperty(exports, "buildUpdateSystemInfoShadowMessage", { enumerable: true, get: function () { return shadow_schema_1.buildUpdateSystemInfoShadowMessage; } });
|
|
35
|
-
Object.defineProperty(exports, "buildUpdateSecureTunnelShadowMessage", { enumerable: true, get: function () { return shadow_schema_1.buildUpdateSecureTunnelShadowMessage; } });
|
|
36
33
|
Object.defineProperty(exports, "ShadowTopics", { enumerable: true, get: function () { return shadow_schema_1.ShadowTopics; } });
|
|
37
34
|
Object.defineProperty(exports, "getShadowTopic", { enumerable: true, get: function () { return shadow_schema_1.getShadowTopic; } });
|
|
38
35
|
Object.defineProperty(exports, "getDesiredFromMessage", { enumerable: true, get: function () { return shadow_schema_1.getDesiredFromMessage; } });
|
|
36
|
+
Object.defineProperty(exports, "getReportedFromMessage", { enumerable: true, get: function () { return shadow_schema_1.getReportedFromMessage; } });
|
|
39
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$id": "https://alwaysai.co/shadow-project-update-schema.json",
|
|
3
3
|
"title": "shadow_project_update_schema",
|
|
4
|
-
"description": "The messaging payload structure for
|
|
4
|
+
"description": "The messaging payload structure for all properties of a single project shadow update",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"nullable": true,
|
|
7
7
|
"properties": {
|
package/lib/shadow-schema.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare function getDesiredFromMessage(message: any): any;
|
|
2
|
+
export declare function getReportedFromMessage(message: any): any;
|
|
3
|
+
export declare function getUpdateDeltaStateFromMessage(message: any): any;
|
|
1
4
|
export declare const ShadowTopics: {
|
|
2
5
|
get: "get";
|
|
3
6
|
'get/accepted': "get/accepted";
|
|
@@ -20,6 +23,7 @@ declare const ShadowNames: {
|
|
|
20
23
|
export declare type ShadowNames = keyof typeof ShadowNames;
|
|
21
24
|
export declare const SHADOW_NAMES: ("secure-tunnel" | "projects" | "system-info")[];
|
|
22
25
|
export declare const getShadowTopic: (clientId: string, shadowName: ShadowNames, shadowTopic: ShadowTopics) => string;
|
|
26
|
+
export declare type ShadowUpdateTypes = ShadowProjectsUpdateAll | SystemInformationShadowUpdate | SecureTunnelShadowUpdate;
|
|
23
27
|
export interface ProjectShadowUpdate {
|
|
24
28
|
appConfig?: string;
|
|
25
29
|
envVars?: {
|
|
@@ -33,7 +37,6 @@ export interface ShadowProjectsUpdateAll {
|
|
|
33
37
|
}
|
|
34
38
|
export declare const validateProjectShadowUpdate: import("ajv/dist/types").ValidateFunction<ProjectShadowUpdate>;
|
|
35
39
|
export declare const validateShadowProjectsUpdateAll: import("ajv/dist/types").ValidateFunction<ShadowProjectsUpdateAll>;
|
|
36
|
-
export declare function getDesiredFromMessage(message: any): any;
|
|
37
40
|
export interface SystemInformationShadowUpdate {
|
|
38
41
|
os?: {
|
|
39
42
|
platform?: string;
|
|
@@ -90,35 +93,22 @@ export declare type SecureTunnelPortInfo = {
|
|
|
90
93
|
ip: string;
|
|
91
94
|
port: number;
|
|
92
95
|
};
|
|
93
|
-
export declare type
|
|
96
|
+
export declare type SecureTunnelShadowUpdate = {
|
|
94
97
|
st_ports: SecureTunnelPortInfo[];
|
|
95
98
|
};
|
|
96
|
-
export declare const validateSecureTunnelShadowUpdate: import("ajv/dist/types").ValidateFunction<
|
|
97
|
-
export declare function
|
|
98
|
-
clientToken: string;
|
|
99
|
-
};
|
|
100
|
-
export declare function buildUpdateProjectShadowMessage({ clientId, reported, desired }: {
|
|
99
|
+
export declare const validateSecureTunnelShadowUpdate: import("ajv/dist/types").ValidateFunction<SecureTunnelShadowUpdate>;
|
|
100
|
+
export declare function buildUpdateShadowMessage<T extends ShadowUpdateTypes>(opts: {
|
|
101
101
|
clientId: string;
|
|
102
|
-
reported?:
|
|
103
|
-
desired?:
|
|
102
|
+
reported?: T;
|
|
103
|
+
desired?: T;
|
|
104
104
|
}): {
|
|
105
105
|
state: {
|
|
106
|
-
reported:
|
|
107
|
-
desired:
|
|
108
|
-
};
|
|
109
|
-
clientToken: string;
|
|
110
|
-
};
|
|
111
|
-
export declare function buildUpdateSystemInfoShadowMessage(clientId: string, systemInfo: SystemInformationShadowUpdate): {
|
|
112
|
-
state: {
|
|
113
|
-
reported: ShadowProjectsUpdateAll | SystemInformationShadowUpdate | undefined;
|
|
114
|
-
desired: ShadowProjectsUpdateAll | undefined;
|
|
106
|
+
reported: T | undefined;
|
|
107
|
+
desired: T | undefined;
|
|
115
108
|
};
|
|
116
109
|
clientToken: string;
|
|
117
110
|
};
|
|
118
|
-
export declare function
|
|
119
|
-
state: {
|
|
120
|
-
reported: SecureTunnelShadowDescriptionReported;
|
|
121
|
-
};
|
|
111
|
+
export declare function buildBaseShadowMessage(clientId: string): {
|
|
122
112
|
clientToken: string;
|
|
123
113
|
};
|
|
124
114
|
export {};
|
package/lib/shadow-schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.buildBaseShadowMessage = exports.buildUpdateShadowMessage = exports.validateSecureTunnelShadowUpdate = exports.validateSystemInformationShadowUpdate = exports.validateShadowProjectsUpdateAll = exports.validateProjectShadowUpdate = exports.getShadowTopic = exports.SHADOW_NAMES = exports.SHADOW_TOPICS = exports.ShadowTopics = exports.getUpdateDeltaStateFromMessage = exports.getReportedFromMessage = exports.getDesiredFromMessage = void 0;
|
|
4
4
|
const _2019_1 = require("ajv/dist/2019");
|
|
5
5
|
const shadowProjectsUpdateAllSchema = require("./schemas/shadow-projects-update-all-schema.json");
|
|
6
6
|
const shadowProjectUpdateSchema = require("./schemas/shadow-project-update-schema.json");
|
|
@@ -12,6 +12,32 @@ const ajv = new _2019_1.default({
|
|
|
12
12
|
allErrors: true,
|
|
13
13
|
schemas: [commonSchema]
|
|
14
14
|
});
|
|
15
|
+
function getDesiredFromMessage(message) {
|
|
16
|
+
var _a;
|
|
17
|
+
if ((_a = message === null || message === void 0 ? void 0 : message.state) === null || _a === void 0 ? void 0 : _a.desired) {
|
|
18
|
+
return message.state.desired;
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
exports.getDesiredFromMessage = getDesiredFromMessage;
|
|
24
|
+
function getReportedFromMessage(message) {
|
|
25
|
+
var _a;
|
|
26
|
+
if ((_a = message === null || message === void 0 ? void 0 : message.state) === null || _a === void 0 ? void 0 : _a.reported) {
|
|
27
|
+
return message.state.reported;
|
|
28
|
+
}
|
|
29
|
+
else
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
exports.getReportedFromMessage = getReportedFromMessage;
|
|
33
|
+
function getUpdateDeltaStateFromMessage(message) {
|
|
34
|
+
if (message === null || message === void 0 ? void 0 : message.state) {
|
|
35
|
+
return message.state;
|
|
36
|
+
}
|
|
37
|
+
else
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
exports.getUpdateDeltaStateFromMessage = getUpdateDeltaStateFromMessage;
|
|
15
41
|
/* ============================================================================
|
|
16
42
|
Shadow Topics
|
|
17
43
|
============================================================================ */
|
|
@@ -42,15 +68,6 @@ ajv.addSchema(shadowProjectUpdateSchema, 'shadow-project-update-schema.json');
|
|
|
42
68
|
exports.validateProjectShadowUpdate = ajv.compile(shadowProjectUpdateSchema);
|
|
43
69
|
ajv.addSchema(shadowProjectsUpdateAllSchema, 'shadow-projects-update-all-schema.json');
|
|
44
70
|
exports.validateShadowProjectsUpdateAll = ajv.compile(shadowProjectsUpdateAllSchema);
|
|
45
|
-
function getDesiredFromMessage(message) {
|
|
46
|
-
var _a;
|
|
47
|
-
if ((_a = message === null || message === void 0 ? void 0 : message.state) === null || _a === void 0 ? void 0 : _a.desired) {
|
|
48
|
-
return message.state.desired;
|
|
49
|
-
}
|
|
50
|
-
else
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
exports.getDesiredFromMessage = getDesiredFromMessage;
|
|
54
71
|
ajv.addSchema(systemInformationSchema, 'system-information-schema.json');
|
|
55
72
|
exports.validateSystemInformationShadowUpdate = ajv.compile(systemInformationSchema);
|
|
56
73
|
ajv.addSchema(secureTunnelSchema, 'secure-tunnel-schema.json');
|
|
@@ -58,6 +75,13 @@ exports.validateSecureTunnelShadowUpdate = ajv.compile(secureTunnelSchema);
|
|
|
58
75
|
/* ============================================================================
|
|
59
76
|
Shadow Message Builders
|
|
60
77
|
============================================================================ */
|
|
78
|
+
function buildUpdateShadowMessage(opts) {
|
|
79
|
+
const { clientId, reported, desired } = opts;
|
|
80
|
+
const state = { reported, desired };
|
|
81
|
+
const message = Object.assign(Object.assign({}, buildBaseShadowMessage(clientId)), { state });
|
|
82
|
+
return message;
|
|
83
|
+
}
|
|
84
|
+
exports.buildUpdateShadowMessage = buildUpdateShadowMessage;
|
|
61
85
|
function buildBaseShadowMessage(clientId) {
|
|
62
86
|
const baseShadowMessage = {
|
|
63
87
|
clientToken: clientId
|
|
@@ -65,19 +89,4 @@ function buildBaseShadowMessage(clientId) {
|
|
|
65
89
|
return baseShadowMessage;
|
|
66
90
|
}
|
|
67
91
|
exports.buildBaseShadowMessage = buildBaseShadowMessage;
|
|
68
|
-
function buildUpdateProjectShadowMessage({ clientId, reported, desired }) {
|
|
69
|
-
const state = { reported, desired };
|
|
70
|
-
const message = Object.assign(Object.assign({}, buildBaseShadowMessage(clientId)), { state });
|
|
71
|
-
return message;
|
|
72
|
-
}
|
|
73
|
-
exports.buildUpdateProjectShadowMessage = buildUpdateProjectShadowMessage;
|
|
74
|
-
function buildUpdateSystemInfoShadowMessage(clientId, systemInfo) {
|
|
75
|
-
return buildUpdateProjectShadowMessage({ clientId, reported: systemInfo });
|
|
76
|
-
}
|
|
77
|
-
exports.buildUpdateSystemInfoShadowMessage = buildUpdateSystemInfoShadowMessage;
|
|
78
|
-
function buildUpdateSecureTunnelShadowMessage(reported, clientId) {
|
|
79
|
-
const message = Object.assign(Object.assign({}, buildBaseShadowMessage(clientId)), { state: { reported } });
|
|
80
|
-
return message;
|
|
81
|
-
}
|
|
82
|
-
exports.buildUpdateSecureTunnelShadowMessage = buildUpdateSecureTunnelShadowMessage;
|
|
83
92
|
//# sourceMappingURL=shadow-schema.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwaysai/device-agent-schemas",
|
|
3
3
|
"description": "alwaysAI schemas",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@adobe/jsonschema2md": "^7.1.5",
|
|
40
|
-
"@alwaysai/eslint-config": "^0.1.
|
|
41
|
-
"@alwaysai/tsconfig": "0.0.
|
|
40
|
+
"@alwaysai/eslint-config": "^0.1.3",
|
|
41
|
+
"@alwaysai/tsconfig": "^0.0.1",
|
|
42
42
|
"@types/jest": "27.0.3",
|
|
43
43
|
"@types/node": "16.11.12",
|
|
44
44
|
"copyfiles": "2.4.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"rimraf": "3.0.2",
|
|
47
47
|
"ts-jest": "27.1.1",
|
|
48
48
|
"ts-node": "10.4.0",
|
|
49
|
-
"typescript": "4.
|
|
49
|
+
"typescript": "^4.6.4"
|
|
50
50
|
},
|
|
51
51
|
"author": {
|
|
52
52
|
"name": "alwaysAI, Inc.",
|