@alwaysai/device-agent-schemas 0.0.1
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/.eslintrc +25 -0
- package/README.md +8 -0
- package/bitbucket-pipelines.yml +10 -0
- package/jest.config.js +3 -0
- package/lib/constants.d.ts +18 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +21 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/schemas/action-schema.d.ts +35 -0
- package/lib/schemas/action-schema.d.ts.map +1 -0
- package/lib/schemas/action-schema.js +31 -0
- package/lib/schemas/action-schema.js.map +1 -0
- package/lib/schemas/application-logs-schema.d.ts +37 -0
- package/lib/schemas/application-logs-schema.d.ts.map +1 -0
- package/lib/schemas/application-logs-schema.js +33 -0
- package/lib/schemas/application-logs-schema.js.map +1 -0
- package/lib/schemas/application-state-schema.d.ts +68 -0
- package/lib/schemas/application-state-schema.d.ts.map +1 -0
- package/lib/schemas/application-state-schema.js +57 -0
- package/lib/schemas/application-state-schema.js.map +1 -0
- package/lib/schemas/common-schema.d.ts +17 -0
- package/lib/schemas/common-schema.d.ts.map +1 -0
- package/lib/schemas/common-schema.js +21 -0
- package/lib/schemas/common-schema.js.map +1 -0
- package/lib/schemas/device-status-schema.d.ts +41 -0
- package/lib/schemas/device-status-schema.d.ts.map +1 -0
- package/lib/schemas/device-status-schema.js +36 -0
- package/lib/schemas/device-status-schema.js.map +1 -0
- package/lib/types.d.ts +21 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +74 -0
- package/lib/types.js.map +1 -0
- package/lib/types.test.d.ts +2 -0
- package/lib/types.test.d.ts.map +1 -0
- package/lib/types.test.js +118 -0
- package/lib/types.test.js.map +1 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +8 -0
- package/lib/utils.js.map +1 -0
- package/package.json +45 -0
- package/src/constants.ts +19 -0
- package/src/index.ts +38 -0
- package/src/schemas/action-schema.ts +36 -0
- package/src/schemas/application-logs-schema.ts +39 -0
- package/src/schemas/application-state-schema.ts +74 -0
- package/src/schemas/common-schema.ts +18 -0
- package/src/schemas/device-status-schema.ts +43 -0
- package/src/types.test.ts +119 -0
- package/src/types.ts +95 -0
- package/src/utils.ts +3 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +92 -0
package/.eslintrc
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"@alwaysai/eslint-config"
|
|
4
|
+
],
|
|
5
|
+
"settings": {
|
|
6
|
+
"import/resolver": {
|
|
7
|
+
"node": {
|
|
8
|
+
"extensions": [".ts", ".js"],
|
|
9
|
+
"moduleDirectory": ["src", "node_modules"]
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"rules": {
|
|
14
|
+
"import/extensions": [
|
|
15
|
+
"error",
|
|
16
|
+
"ignorePackages",
|
|
17
|
+
{
|
|
18
|
+
"js": "never",
|
|
19
|
+
"ts": "never"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"no-shadow": "off",
|
|
23
|
+
"@typescript-eslint/no-shadow": ["error"]
|
|
24
|
+
}
|
|
25
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
The interfaces and schemas for each sub-packet can be found in `src/schemas`. The schemas are imported into `types.ts` and the overall JSONSchemaType as well as the sub-types are created, as are the validation methods. Validation methods are used to type-guard incoming messages, while the interfaces are used to type-guard at development time. This repository is configured as an `npm` package -- while under local development you can use `npm instal --save` along with the path to this repo to use it with the device agent.
|
|
3
|
+
|
|
4
|
+
# To Create New Schemas and Validation Methods
|
|
5
|
+
To create a new message type, create a new `.ts` file in `src/schemas` and create the sub-schema and a corresponding `interface`. If you are using patterns or enums, you can add these to the `src/constants` file and import them as needed. You can them import the schemas into `types.ts` and modify the main schema's `payload` property's `oneOf` list to include the new type. You can then compile a new validation method against the new schema using your newly defined type. You may need to add the schema to the `ajv` instance, however this shouldn't be necessary if the main schema is referencing the new sub-schema. More notes on the development of this repo can be found here: https://alwaysai.atlassian.net/l/c/RdjVyG1d
|
|
6
|
+
|
|
7
|
+
# To Run Tests
|
|
8
|
+
Run `npm run test:unit` to run the `types.test.ts` file. You can add valid and invalid data structures to the `validData` and `invalidData` variables and these will be checked as positive and negative tests, respectively.
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const PROJECT_ID_PATTERN = "([0-9a-z]+-+)+([0-9a-z])+";
|
|
2
|
+
export declare const DEVICE_ID_PATTERN = "([0-9a-z]+-+)+([0-9a-z])+";
|
|
3
|
+
export declare enum AppStateEnum {
|
|
4
|
+
UP = "Up",
|
|
5
|
+
STOPPED = "Stopped",
|
|
6
|
+
RESTARTING = "Restarting"
|
|
7
|
+
}
|
|
8
|
+
export declare type AppStateValue = `${AppStateEnum}`;
|
|
9
|
+
export declare const AppStateValues: AppStateValue[];
|
|
10
|
+
export declare enum ActionEnum {
|
|
11
|
+
START = "start",
|
|
12
|
+
STOP = "stop",
|
|
13
|
+
RESTART = "restart",
|
|
14
|
+
INSTALL = "install"
|
|
15
|
+
}
|
|
16
|
+
export declare type ActionValue = `${ActionEnum}`;
|
|
17
|
+
export declare const ActionValues: ActionValue[];
|
|
18
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAC9D,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D,oBAAY,YAAY;IACtB,EAAE,OAAO;IACT,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AACD,oBAAY,aAAa,GAAG,GAAG,YAAY,EAAE,CAAC;AAC9C,eAAO,MAAM,cAAc,EAAE,aAAa,EAAgC,CAAC;AAE3E,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AACD,oBAAY,WAAW,GAAG,GAAG,UAAU,EAAE,CAAC;AAC1C,eAAO,MAAM,YAAY,EAAE,WAAW,EAA8B,CAAC"}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionValues = exports.ActionEnum = exports.AppStateValues = exports.AppStateEnum = exports.DEVICE_ID_PATTERN = exports.PROJECT_ID_PATTERN = void 0;
|
|
4
|
+
exports.PROJECT_ID_PATTERN = '([0-9a-z]+-+)+([0-9a-z])+';
|
|
5
|
+
exports.DEVICE_ID_PATTERN = '([0-9a-z]+-+)+([0-9a-z])+';
|
|
6
|
+
var AppStateEnum;
|
|
7
|
+
(function (AppStateEnum) {
|
|
8
|
+
AppStateEnum["UP"] = "Up";
|
|
9
|
+
AppStateEnum["STOPPED"] = "Stopped";
|
|
10
|
+
AppStateEnum["RESTARTING"] = "Restarting";
|
|
11
|
+
})(AppStateEnum = exports.AppStateEnum || (exports.AppStateEnum = {}));
|
|
12
|
+
exports.AppStateValues = Object.values(AppStateEnum);
|
|
13
|
+
var ActionEnum;
|
|
14
|
+
(function (ActionEnum) {
|
|
15
|
+
ActionEnum["START"] = "start";
|
|
16
|
+
ActionEnum["STOP"] = "stop";
|
|
17
|
+
ActionEnum["RESTART"] = "restart";
|
|
18
|
+
ActionEnum["INSTALL"] = "install";
|
|
19
|
+
})(ActionEnum = exports.ActionEnum || (exports.ActionEnum = {}));
|
|
20
|
+
exports.ActionValues = Object.values(ActionEnum);
|
|
21
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,2BAA2B,CAAC;AACjD,QAAA,iBAAiB,GAAG,2BAA2B,CAAC;AAE7D,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,yBAAS,CAAA;IACT,mCAAmB,CAAA;IACnB,yCAAyB,CAAA;AAC3B,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAEY,QAAA,cAAc,GAAoB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAE3E,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,2BAAa,CAAA;IACb,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;AACrB,CAAC,EALW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAKrB;AAEY,QAAA,YAAY,GAAkB,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { validateDeviceStatsMessage, validateActionMessage, validateAppLogsMessage, validateAppStateMessage, DeviceAgentMessage, validateDeviceAgentMessage } from './types';
|
|
2
|
+
import { AppDetails, ServiceStatus, AppState, AppStateMessage } from './schemas/application-state-schema';
|
|
3
|
+
import { AppLogs, AppLogsMessage } from './schemas/application-logs-schema';
|
|
4
|
+
import { ActionMessage } from './schemas/action-schema';
|
|
5
|
+
import { AppStateValue } from './constants';
|
|
6
|
+
import { DeviceStats, DeviceStatsMessage } from './schemas/device-status-schema';
|
|
7
|
+
export { AppStateValue, validateDeviceStatsMessage, DeviceStats, DeviceStatsMessage, ActionMessage, validateActionMessage, AppLogs, AppLogsMessage, validateAppLogsMessage, AppDetails, ServiceStatus, AppState, AppStateMessage, validateAppStateMessage, validateDeviceAgentMessage, DeviceAgentMessage, };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,UAAU,EACV,aAAa,EACb,QAAQ,EACR,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EACL,aAAa,EACb,0BAA0B,EAC1B,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,OAAO,EACP,cAAc,EACd,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,QAAQ,EACR,eAAe,EACf,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,GACnB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateDeviceAgentMessage = exports.validateAppStateMessage = exports.validateAppLogsMessage = exports.validateActionMessage = exports.validateDeviceStatsMessage = void 0;
|
|
4
|
+
// export types here
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
Object.defineProperty(exports, "validateDeviceStatsMessage", { enumerable: true, get: function () { return types_1.validateDeviceStatsMessage; } });
|
|
7
|
+
Object.defineProperty(exports, "validateActionMessage", { enumerable: true, get: function () { return types_1.validateActionMessage; } });
|
|
8
|
+
Object.defineProperty(exports, "validateAppLogsMessage", { enumerable: true, get: function () { return types_1.validateAppLogsMessage; } });
|
|
9
|
+
Object.defineProperty(exports, "validateAppStateMessage", { enumerable: true, get: function () { return types_1.validateAppStateMessage; } });
|
|
10
|
+
Object.defineProperty(exports, "validateDeviceAgentMessage", { enumerable: true, get: function () { return types_1.validateDeviceAgentMessage; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,mCAOiB;AAcf,2GApBA,kCAA0B,OAoBA;AAI1B,sGAvBA,6BAAqB,OAuBA;AAGrB,uGAzBA,8BAAsB,OAyBA;AAKtB,wGA7BA,+BAAuB,OA6BA;AACvB,2GA5BA,kCAA0B,OA4BA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ActionValue } from '../constants';
|
|
2
|
+
export interface ActionMessage {
|
|
3
|
+
baseCommand: ActionValue;
|
|
4
|
+
parameters: {
|
|
5
|
+
projectId: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const actionSchema: {
|
|
9
|
+
$id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
$defs: {
|
|
12
|
+
action: {
|
|
13
|
+
type: string;
|
|
14
|
+
properties: {
|
|
15
|
+
baseCommand: {
|
|
16
|
+
type: string;
|
|
17
|
+
enum: string[];
|
|
18
|
+
};
|
|
19
|
+
parameters: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {
|
|
22
|
+
projectId: {
|
|
23
|
+
$ref: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
required: string[];
|
|
27
|
+
additionalProperties: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
required: string[];
|
|
31
|
+
additionalProperties: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=action-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-schema.d.ts","sourceRoot":"","sources":["../../src/schemas/action-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BxB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actionSchema = void 0;
|
|
4
|
+
exports.actionSchema = {
|
|
5
|
+
$id: 'action_schema.json',
|
|
6
|
+
type: 'object',
|
|
7
|
+
$defs: {
|
|
8
|
+
action: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
baseCommand: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
enum: ['start', 'stop', 'restart', 'install'],
|
|
14
|
+
},
|
|
15
|
+
parameters: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
projectId: {
|
|
19
|
+
$ref: 'common_schema.json#/$defs/projectId',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
required: ['projectId'],
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ['baseCommand', 'parameters'],
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=action-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-schema.js","sourceRoot":"","sources":["../../src/schemas/action-schema.ts"],"names":[],"mappings":";;;AASa,QAAA,YAAY,GAAG;IAC1B,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE;QACL,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;iBAC9C;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,SAAS,EAAE;4BACT,IAAI,EAAE,qCAAqC;yBAC5C;qBACF;oBACD,QAAQ,EAAE,CAAC,WAAW,CAAC;oBACvB,oBAAoB,EAAE,KAAK;iBAC5B;aACF;YACD,QAAQ,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;YACvC,oBAAoB,EAAE,KAAK;SAC5B;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface AppLogs {
|
|
2
|
+
projectId: string;
|
|
3
|
+
logs: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface AppLogsMessage {
|
|
6
|
+
applicationLogs: AppLogs[];
|
|
7
|
+
}
|
|
8
|
+
export declare const applicationLogsSchema: {
|
|
9
|
+
$id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
$defs: {
|
|
12
|
+
applicationLogs: {
|
|
13
|
+
type: string;
|
|
14
|
+
properties: {
|
|
15
|
+
applicationLogs: {
|
|
16
|
+
type: string;
|
|
17
|
+
properties: {
|
|
18
|
+
projectId: {
|
|
19
|
+
$ref: string;
|
|
20
|
+
};
|
|
21
|
+
logs: {
|
|
22
|
+
type: string;
|
|
23
|
+
items: {
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
required: string[];
|
|
29
|
+
additionalProperties: boolean;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
additionalProperties: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=application-logs-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-logs-schema.d.ts","sourceRoot":"","sources":["../../src/schemas/application-logs-schema.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,OAAO,EAAE,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BjC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applicationLogsSchema = void 0;
|
|
4
|
+
exports.applicationLogsSchema = {
|
|
5
|
+
$id: 'application_logs_schema.json',
|
|
6
|
+
type: 'object',
|
|
7
|
+
$defs: {
|
|
8
|
+
applicationLogs: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
applicationLogs: {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
projectId: {
|
|
15
|
+
$ref: 'common_schema.json#/$defs/projectId',
|
|
16
|
+
},
|
|
17
|
+
logs: {
|
|
18
|
+
type: 'array',
|
|
19
|
+
items: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ['logs', 'projectId'],
|
|
25
|
+
additionalProperties: false,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ['applicationLogs'],
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=application-logs-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-logs-schema.js","sourceRoot":"","sources":["../../src/schemas/application-logs-schema.ts"],"names":[],"mappings":";;;AAUa,QAAA,qBAAqB,GAAG;IACnC,GAAG,EAAE,8BAA8B;IACnC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE;QACL,eAAe,EAAE;YACf,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,eAAe,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,SAAS,EAAE;4BACT,IAAI,EAAE,qCAAqC;yBAC5C;wBACD,IAAI,EAAE;4BACJ,IAAI,EAAE,OAAO;4BACb,KAAK,EAAE;gCACL,IAAI,EAAE,QAAQ;6BACf;yBACF;qBACF;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;oBAC/B,oBAAoB,EAAE,KAAK;iBAC5B;aACF;YACD,QAAQ,EAAE,CAAC,iBAAiB,CAAC;YAC7B,oBAAoB,EAAE,KAAK;SAC5B;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AppStateValue } from '../constants';
|
|
2
|
+
export interface AppDetails {
|
|
3
|
+
projectId: string;
|
|
4
|
+
version: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ServiceStatus {
|
|
7
|
+
name: string;
|
|
8
|
+
state: AppStateValue;
|
|
9
|
+
}
|
|
10
|
+
export interface AppState {
|
|
11
|
+
appDetails: AppDetails;
|
|
12
|
+
services: ServiceStatus[];
|
|
13
|
+
}
|
|
14
|
+
export interface AppStateMessage {
|
|
15
|
+
applicationState: AppState[];
|
|
16
|
+
}
|
|
17
|
+
export declare const applicationStateSchema: {
|
|
18
|
+
$id: string;
|
|
19
|
+
$defs: {
|
|
20
|
+
applicationState: {
|
|
21
|
+
type: string;
|
|
22
|
+
properties: {
|
|
23
|
+
applicationState: {
|
|
24
|
+
type: string;
|
|
25
|
+
items: {
|
|
26
|
+
type: string;
|
|
27
|
+
properties: {
|
|
28
|
+
appDetails: {
|
|
29
|
+
type: string;
|
|
30
|
+
properties: {
|
|
31
|
+
projectId: {
|
|
32
|
+
$ref: string;
|
|
33
|
+
};
|
|
34
|
+
version: {
|
|
35
|
+
$ref: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
additionalProperties: boolean;
|
|
39
|
+
required: string[];
|
|
40
|
+
};
|
|
41
|
+
services: {
|
|
42
|
+
type: string;
|
|
43
|
+
items: {
|
|
44
|
+
type: string;
|
|
45
|
+
properties: {
|
|
46
|
+
name: {
|
|
47
|
+
type: string;
|
|
48
|
+
};
|
|
49
|
+
state: {
|
|
50
|
+
enum: ("Up" | "Stopped" | "Restarting")[];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
additionalProperties: boolean;
|
|
54
|
+
required: string[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
additionalProperties: boolean;
|
|
59
|
+
required: string[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
additionalProperties: boolean;
|
|
64
|
+
required: string[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=application-state-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-state-schema.d.ts","sourceRoot":"","sources":["../../src/schemas/application-state-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,cAAc,CAAC;AAG7D,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,gBAAgB,EAAE,QAAQ,EAAE,CAAC;CAC9B;AAGD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDlC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applicationStateSchema = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
// Application State Structures
|
|
6
|
+
exports.applicationStateSchema = {
|
|
7
|
+
$id: 'state_schema.json',
|
|
8
|
+
$defs: {
|
|
9
|
+
applicationState: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
applicationState: {
|
|
13
|
+
type: 'array',
|
|
14
|
+
items: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
appDetails: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
projectId: {
|
|
21
|
+
$ref: 'common_schema.json#/$defs/projectId',
|
|
22
|
+
},
|
|
23
|
+
version: {
|
|
24
|
+
$ref: 'common_schema.json#/$defs/releaseHash',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
required: ['projectId', 'version'],
|
|
29
|
+
},
|
|
30
|
+
services: {
|
|
31
|
+
type: 'array',
|
|
32
|
+
items: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
name: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
},
|
|
38
|
+
state: {
|
|
39
|
+
enum: constants_1.AppStateValues,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
required: ['name', 'state'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
required: ['appDetails', 'services'],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
required: ['applicationState'],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=application-state-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-state-schema.js","sourceRoot":"","sources":["../../src/schemas/application-state-schema.ts"],"names":[],"mappings":";;;AAAA,4CAA6D;AAsB7D,+BAA+B;AAClB,QAAA,sBAAsB,GAAG;IACpC,GAAG,EAAE,mBAAmB;IACxB,KAAK,EAAE;QACL,gBAAgB,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,gBAAgB,EAAE;oBAChB,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,UAAU,EAAE;gCACV,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,SAAS,EAAE;wCACT,IAAI,EAAE,qCAAqC;qCAC5C;oCACD,OAAO,EAAE;wCACP,IAAI,EAAE,uCAAuC;qCAC9C;iCACF;gCACD,oBAAoB,EAAE,KAAK;gCAC3B,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;6BACnC;4BACD,QAAQ,EAAE;gCACR,IAAI,EAAE,OAAO;gCACb,KAAK,EAAE;oCACL,IAAI,EAAE,QAAQ;oCACd,UAAU,EAAE;wCACV,IAAI,EAAE;4CACJ,IAAI,EAAE,QAAQ;yCACf;wCACD,KAAK,EAAE;4CACL,IAAI,EAAE,0BAAc;yCACrB;qCACF;oCACD,oBAAoB,EAAE,KAAK;oCAC3B,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;iCAC5B;6BACF;yBACF;wBACD,oBAAoB,EAAE,KAAK;wBAC3B,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC;qBACrC;iBACF;aACF;YACD,oBAAoB,EAAE,KAAK;YAC3B,QAAQ,EAAE,CAAC,kBAAkB,CAAC;SAC/B;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const commonSchema: {
|
|
2
|
+
$id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
$defs: {
|
|
5
|
+
projectId: {
|
|
6
|
+
description: string;
|
|
7
|
+
type: string;
|
|
8
|
+
pattern: string;
|
|
9
|
+
};
|
|
10
|
+
releaseHash: {
|
|
11
|
+
description: string;
|
|
12
|
+
type: string;
|
|
13
|
+
pattern: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=common-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-schema.d.ts","sourceRoot":"","sources":["../../src/schemas/common-schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CAexB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commonSchema = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
exports.commonSchema = {
|
|
6
|
+
$id: 'common_schema.json',
|
|
7
|
+
title: 'Common',
|
|
8
|
+
$defs: {
|
|
9
|
+
projectId: {
|
|
10
|
+
description: 'The specific project associated with the message payload.',
|
|
11
|
+
type: 'string',
|
|
12
|
+
pattern: constants_1.PROJECT_ID_PATTERN,
|
|
13
|
+
},
|
|
14
|
+
releaseHash: {
|
|
15
|
+
description: 'The version of the project associated with the message payload.',
|
|
16
|
+
type: 'string',
|
|
17
|
+
pattern: '[0-9]+',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=common-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-schema.js","sourceRoot":"","sources":["../../src/schemas/common-schema.ts"],"names":[],"mappings":";;;AAAA,4CAAkD;AAErC,QAAA,YAAY,GAAG;IAC1B,GAAG,EAAE,oBAAoB;IACzB,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE;QACL,SAAS,EAAE;YACT,WAAW,EAAE,2DAA2D;YACxE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,8BAAkB;SAC5B;QACD,WAAW,EAAE;YACX,WAAW,EAAE,iEAAiE;YAC9E,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,QAAQ;SAClB;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface DeviceStats {
|
|
2
|
+
cpuUsage: number;
|
|
3
|
+
diskUtil: number;
|
|
4
|
+
usedMemoryPercentage: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DeviceStatsMessage {
|
|
7
|
+
deviceStats: DeviceStats;
|
|
8
|
+
}
|
|
9
|
+
export declare const deviceStatusSchema: {
|
|
10
|
+
$id: string;
|
|
11
|
+
type: string;
|
|
12
|
+
$defs: {
|
|
13
|
+
status: {
|
|
14
|
+
type: string;
|
|
15
|
+
properties: {
|
|
16
|
+
deviceStats: {
|
|
17
|
+
type: string;
|
|
18
|
+
properties: {
|
|
19
|
+
cpuUsage: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
diskUtil: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
usedMemoryPercentage: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
additionalProperties: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
required: string[];
|
|
37
|
+
additionalProperties: boolean;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=device-status-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-status-schema.d.ts","sourceRoot":"","sources":["../../src/schemas/device-status-schema.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+B9B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deviceStatusSchema = void 0;
|
|
4
|
+
exports.deviceStatusSchema = {
|
|
5
|
+
$id: 'device_schema.json',
|
|
6
|
+
type: 'object',
|
|
7
|
+
$defs: {
|
|
8
|
+
status: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
deviceStats: {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
cpuUsage: {
|
|
15
|
+
type: 'number',
|
|
16
|
+
description: 'The percentage of the CPU that is currently being used.',
|
|
17
|
+
},
|
|
18
|
+
diskUtil: {
|
|
19
|
+
type: 'number',
|
|
20
|
+
description: 'The percentage of the drive storage that is being used.',
|
|
21
|
+
},
|
|
22
|
+
usedMemoryPercentage: {
|
|
23
|
+
type: 'number',
|
|
24
|
+
description: 'The percentage of the memory that is being used.',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ['cpuUsage', 'diskUtil', 'usedMemoryPercentage'],
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['deviceStats'],
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=device-status-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-status-schema.js","sourceRoot":"","sources":["../../src/schemas/device-status-schema.ts"],"names":[],"mappings":";;;AAWa,QAAA,kBAAkB,GAAG;IAChC,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE;QACL,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,yDAAyD;yBACvE;wBACD,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,yDAAyD;yBACvE;wBACD,oBAAoB,EAAE;4BACpB,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,kDAAkD;yBAChE;qBACF;oBACD,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,sBAAsB,CAAC;oBAC1D,oBAAoB,EAAE,KAAK;iBAC5B;aACF;YACD,QAAQ,EAAE,CAAC,aAAa,CAAC;YACzB,oBAAoB,EAAE,KAAK;SAC5B;KACF;CACF,CAAC"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { JSONSchemaType } from 'ajv';
|
|
2
|
+
import { DeviceStatsMessage } from './schemas/device-status-schema';
|
|
3
|
+
import { AppStateMessage } from './schemas/application-state-schema';
|
|
4
|
+
import { ActionMessage } from './schemas/action-schema';
|
|
5
|
+
import { AppLogsMessage } from './schemas/application-logs-schema';
|
|
6
|
+
export interface DeviceAgentMessage {
|
|
7
|
+
deviceId: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
topic: string;
|
|
10
|
+
payload: ActionMessage | DeviceStatsMessage | AppLogsMessage | AppStateMessage;
|
|
11
|
+
}
|
|
12
|
+
export declare const deviceMessageSchemaType: JSONSchemaType<DeviceStatsMessage>;
|
|
13
|
+
export declare const validateDeviceStatsMessage: import("ajv").ValidateFunction<DeviceStatsMessage>;
|
|
14
|
+
export declare const appLogsMessageSchemaType: JSONSchemaType<AppLogsMessage>;
|
|
15
|
+
export declare const validateAppLogsMessage: import("ajv").ValidateFunction<AppLogsMessage>;
|
|
16
|
+
export declare const appStateMessageSchemaType: JSONSchemaType<AppStateMessage>;
|
|
17
|
+
export declare const validateAppStateMessage: import("ajv").ValidateFunction<AppStateMessage>;
|
|
18
|
+
export declare const actionMessageSchemaType: JSONSchemaType<ActionMessage>;
|
|
19
|
+
export declare const validateActionMessage: import("ajv").ValidateFunction<ActionMessage>;
|
|
20
|
+
export declare const validateDeviceAgentMessage: import("ajv").ValidateFunction<DeviceAgentMessage>;
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,EAAsB,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAEL,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAgB,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAyB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAK1F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,aAAa,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC;CAChF;AAwDD,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,kBAAkB,CAC/B,CAAC;AACzC,eAAO,MAAM,0BAA0B,oDAAuC,CAAC;AAG/E,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,cAAc,CACzB,CAAC;AAC5C,eAAO,MAAM,sBAAsB,gDAAwC,CAAC;AAG5E,eAAO,MAAM,yBAAyB,EAAE,cAAc,CAAC,eAAe,CAC1B,CAAC;AAC7C,eAAO,MAAM,uBAAuB,iDAAyC,CAAC;AAE9E,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,aAAa,CAChC,CAAC;AACnC,eAAO,MAAM,qBAAqB,+CAAuC,CAAC;AAI1E,eAAO,MAAM,0BAA0B,oDAAiC,CAAC"}
|