@xube/kit-aws-data-schema 0.0.73
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/dist/constants.d.ts +2 -0
- package/dist/constants.js +5 -0
- package/dist/decode/aggregate.d.ts +107 -0
- package/dist/decode/aggregate.js +17 -0
- package/dist/decode/reading.d.ts +94 -0
- package/dist/decode/reading.js +23 -0
- package/dist/generated/index.d.ts +16 -0
- package/dist/generated/index.js +41 -0
- package/dist/generated/types/aggregateMetadata.d.ts +11 -0
- package/dist/generated/types/aggregateMetadata.js +23 -0
- package/dist/generated/types/aggregateMetadataTypes.d.ts +19 -0
- package/dist/generated/types/aggregateMetadataTypes.js +23 -0
- package/dist/generated/types/aggregateMetadataV1.d.ts +19 -0
- package/dist/generated/types/aggregateMetadataV1.js +23 -0
- package/dist/generated/types/dataMessage.d.ts +15 -0
- package/dist/generated/types/dataMessage.js +23 -0
- package/dist/generated/types/deviceReadingMetadataV1.d.ts +12 -0
- package/dist/generated/types/deviceReadingMetadataV1.js +23 -0
- package/dist/generated/types/deviceReadingV1.d.ts +15 -0
- package/dist/generated/types/deviceReadingV1.js +23 -0
- package/dist/generated/types/readingMetadataV1.d.ts +12 -0
- package/dist/generated/types/readingMetadataV1.js +23 -0
- package/dist/generated/types/readingV1.d.ts +16 -0
- package/dist/generated/types/readingV1.js +23 -0
- package/dist/generated/validators/aggregateMetadata.d.ts +13 -0
- package/dist/generated/validators/aggregateMetadata.js +54 -0
- package/dist/generated/validators/aggregateMetadataTypes.d.ts +13 -0
- package/dist/generated/validators/aggregateMetadataTypes.js +236 -0
- package/dist/generated/validators/aggregateMetadataV1.d.ts +13 -0
- package/dist/generated/validators/aggregateMetadataV1.js +236 -0
- package/dist/generated/validators/dataMessage.d.ts +13 -0
- package/dist/generated/validators/dataMessage.js +142 -0
- package/dist/generated/validators/deviceReadingMetadataV1.d.ts +13 -0
- package/dist/generated/validators/deviceReadingMetadataV1.js +77 -0
- package/dist/generated/validators/deviceReadingV1.d.ts +13 -0
- package/dist/generated/validators/deviceReadingV1.js +127 -0
- package/dist/generated/validators/readingMetadataV1.d.ts +13 -0
- package/dist/generated/validators/readingMetadataV1.js +77 -0
- package/dist/generated/validators/readingV1.d.ts +13 -0
- package/dist/generated/validators/readingV1.js +216 -0
- package/dist/generator.d.ts +1 -0
- package/dist/generator.js +17 -0
- package/dist/get/get-data-by-date-range.d.ts +204 -0
- package/dist/get/get-data-by-date-range.js +35 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +23 -0
- package/dist/key/get.d.ts +2 -0
- package/dist/key/get.js +11 -0
- package/dist/message/message.d.ts +20 -0
- package/dist/message/message.js +11 -0
- package/package.json +34 -0
- package/src/constants.ts +3 -0
- package/src/decode/aggregate.ts +18 -0
- package/src/decode/reading.ts +23 -0
- package/src/generated/index.ts +16 -0
- package/src/generated/types/aggregateMetadata.ts +26 -0
- package/src/generated/types/aggregateMetadataTypes.ts +34 -0
- package/src/generated/types/aggregateMetadataV1.ts +34 -0
- package/src/generated/types/dataMessage.ts +30 -0
- package/src/generated/types/deviceReadingMetadataV1.ts +27 -0
- package/src/generated/types/deviceReadingV1.ts +30 -0
- package/src/generated/types/readingMetadataV1.ts +27 -0
- package/src/generated/types/readingV1.ts +31 -0
- package/src/generated/validators/aggregateMetadata.js +1 -0
- package/src/generated/validators/aggregateMetadataTypes.js +1 -0
- package/src/generated/validators/aggregateMetadataV1.js +1 -0
- package/src/generated/validators/dataMessage.js +1 -0
- package/src/generated/validators/deviceReadingMetadataV1.js +1 -0
- package/src/generated/validators/deviceReadingV1.js +1 -0
- package/src/generated/validators/readingMetadataV1.js +1 -0
- package/src/generated/validators/readingV1.js +1 -0
- package/src/generator.ts +50 -0
- package/src/get/get-data-by-date-range.ts +52 -0
- package/src/index.ts +7 -0
- package/src/key/get.ts +11 -0
- package/src/message/message.ts +9 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validate = void 0;
|
|
4
|
+
exports.validate = validate10;
|
|
5
|
+
exports.default = validate10;
|
|
6
|
+
const schema27 = { "$ref": "#/definitions/readingv1JsonSchema", "definitions": { "readingv1JsonSchema": { "type": "object", "properties": { "data": { "anyOf": [{ "type": "string" }, { "type": "number" }, { "type": "boolean" }, { "type": "object", "properties": {}, "additionalProperties": true }] }, "component": { "type": "string" }, "s": { "type": "number" }, "us": { "type": "number" }, "type": { "type": "string" }, "id": { "type": "string" } }, "required": ["data", "component", "s", "type", "id"], "additionalProperties": true } }, "$schema": "http://json-schema.org/draft-07/schema#" };
|
|
7
|
+
const schema28 = { "type": "object", "properties": { "data": { "anyOf": [{ "type": "string" }, { "type": "number" }, { "type": "boolean" }, { "type": "object", "properties": {}, "additionalProperties": true }] }, "component": { "type": "string" }, "s": { "type": "number" }, "us": { "type": "number" }, "type": { "type": "string" }, "id": { "type": "string" } }, "required": ["data", "component", "s", "type", "id"], "additionalProperties": true };
|
|
8
|
+
function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) { let vErrors = null; let errors = 0; if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
9
|
+
if (data.data === undefined) {
|
|
10
|
+
const err0 = { instancePath, schemaPath: "#/definitions/readingv1JsonSchema/required", keyword: "required", params: { missingProperty: "data" }, message: "must have required property '" + "data" + "'" };
|
|
11
|
+
if (vErrors === null) {
|
|
12
|
+
vErrors = [err0];
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
vErrors.push(err0);
|
|
16
|
+
}
|
|
17
|
+
errors++;
|
|
18
|
+
}
|
|
19
|
+
if (data.component === undefined) {
|
|
20
|
+
const err1 = { instancePath, schemaPath: "#/definitions/readingv1JsonSchema/required", keyword: "required", params: { missingProperty: "component" }, message: "must have required property '" + "component" + "'" };
|
|
21
|
+
if (vErrors === null) {
|
|
22
|
+
vErrors = [err1];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
vErrors.push(err1);
|
|
26
|
+
}
|
|
27
|
+
errors++;
|
|
28
|
+
}
|
|
29
|
+
if (data.s === undefined) {
|
|
30
|
+
const err2 = { instancePath, schemaPath: "#/definitions/readingv1JsonSchema/required", keyword: "required", params: { missingProperty: "s" }, message: "must have required property '" + "s" + "'" };
|
|
31
|
+
if (vErrors === null) {
|
|
32
|
+
vErrors = [err2];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
vErrors.push(err2);
|
|
36
|
+
}
|
|
37
|
+
errors++;
|
|
38
|
+
}
|
|
39
|
+
if (data.type === undefined) {
|
|
40
|
+
const err3 = { instancePath, schemaPath: "#/definitions/readingv1JsonSchema/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property '" + "type" + "'" };
|
|
41
|
+
if (vErrors === null) {
|
|
42
|
+
vErrors = [err3];
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
vErrors.push(err3);
|
|
46
|
+
}
|
|
47
|
+
errors++;
|
|
48
|
+
}
|
|
49
|
+
if (data.id === undefined) {
|
|
50
|
+
const err4 = { instancePath, schemaPath: "#/definitions/readingv1JsonSchema/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property '" + "id" + "'" };
|
|
51
|
+
if (vErrors === null) {
|
|
52
|
+
vErrors = [err4];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
vErrors.push(err4);
|
|
56
|
+
}
|
|
57
|
+
errors++;
|
|
58
|
+
}
|
|
59
|
+
if (data.data !== undefined) {
|
|
60
|
+
let data0 = data.data;
|
|
61
|
+
const _errs4 = errors;
|
|
62
|
+
let valid2 = false;
|
|
63
|
+
const _errs5 = errors;
|
|
64
|
+
if (typeof data0 !== "string") {
|
|
65
|
+
const err5 = { instancePath: instancePath + "/data", schemaPath: "#/definitions/readingv1JsonSchema/properties/data/anyOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
66
|
+
if (vErrors === null) {
|
|
67
|
+
vErrors = [err5];
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
vErrors.push(err5);
|
|
71
|
+
}
|
|
72
|
+
errors++;
|
|
73
|
+
}
|
|
74
|
+
var _valid0 = _errs5 === errors;
|
|
75
|
+
valid2 = valid2 || _valid0;
|
|
76
|
+
if (!valid2) {
|
|
77
|
+
const _errs7 = errors;
|
|
78
|
+
if (!((typeof data0 == "number") && (isFinite(data0)))) {
|
|
79
|
+
const err6 = { instancePath: instancePath + "/data", schemaPath: "#/definitions/readingv1JsonSchema/properties/data/anyOf/1/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
80
|
+
if (vErrors === null) {
|
|
81
|
+
vErrors = [err6];
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
vErrors.push(err6);
|
|
85
|
+
}
|
|
86
|
+
errors++;
|
|
87
|
+
}
|
|
88
|
+
var _valid0 = _errs7 === errors;
|
|
89
|
+
valid2 = valid2 || _valid0;
|
|
90
|
+
if (!valid2) {
|
|
91
|
+
const _errs9 = errors;
|
|
92
|
+
if (typeof data0 !== "boolean") {
|
|
93
|
+
const err7 = { instancePath: instancePath + "/data", schemaPath: "#/definitions/readingv1JsonSchema/properties/data/anyOf/2/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
|
|
94
|
+
if (vErrors === null) {
|
|
95
|
+
vErrors = [err7];
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
vErrors.push(err7);
|
|
99
|
+
}
|
|
100
|
+
errors++;
|
|
101
|
+
}
|
|
102
|
+
var _valid0 = _errs9 === errors;
|
|
103
|
+
valid2 = valid2 || _valid0;
|
|
104
|
+
if (!valid2) {
|
|
105
|
+
const _errs11 = errors;
|
|
106
|
+
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) { }
|
|
107
|
+
else {
|
|
108
|
+
const err8 = { instancePath: instancePath + "/data", schemaPath: "#/definitions/readingv1JsonSchema/properties/data/anyOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
109
|
+
if (vErrors === null) {
|
|
110
|
+
vErrors = [err8];
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
vErrors.push(err8);
|
|
114
|
+
}
|
|
115
|
+
errors++;
|
|
116
|
+
}
|
|
117
|
+
var _valid0 = _errs11 === errors;
|
|
118
|
+
valid2 = valid2 || _valid0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!valid2) {
|
|
123
|
+
const err9 = { instancePath: instancePath + "/data", schemaPath: "#/definitions/readingv1JsonSchema/properties/data/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
|
|
124
|
+
if (vErrors === null) {
|
|
125
|
+
vErrors = [err9];
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
vErrors.push(err9);
|
|
129
|
+
}
|
|
130
|
+
errors++;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
errors = _errs4;
|
|
134
|
+
if (vErrors !== null) {
|
|
135
|
+
if (_errs4) {
|
|
136
|
+
vErrors.length = _errs4;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
vErrors = null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (data.component !== undefined) {
|
|
145
|
+
if (typeof data.component !== "string") {
|
|
146
|
+
const err10 = { instancePath: instancePath + "/component", schemaPath: "#/definitions/readingv1JsonSchema/properties/component/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
147
|
+
if (vErrors === null) {
|
|
148
|
+
vErrors = [err10];
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
vErrors.push(err10);
|
|
152
|
+
}
|
|
153
|
+
errors++;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (data.s !== undefined) {
|
|
157
|
+
let data2 = data.s;
|
|
158
|
+
if (!((typeof data2 == "number") && (isFinite(data2)))) {
|
|
159
|
+
const err11 = { instancePath: instancePath + "/s", schemaPath: "#/definitions/readingv1JsonSchema/properties/s/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
160
|
+
if (vErrors === null) {
|
|
161
|
+
vErrors = [err11];
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
vErrors.push(err11);
|
|
165
|
+
}
|
|
166
|
+
errors++;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (data.us !== undefined) {
|
|
170
|
+
let data3 = data.us;
|
|
171
|
+
if (!((typeof data3 == "number") && (isFinite(data3)))) {
|
|
172
|
+
const err12 = { instancePath: instancePath + "/us", schemaPath: "#/definitions/readingv1JsonSchema/properties/us/type", keyword: "type", params: { type: "number" }, message: "must be number" };
|
|
173
|
+
if (vErrors === null) {
|
|
174
|
+
vErrors = [err12];
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
vErrors.push(err12);
|
|
178
|
+
}
|
|
179
|
+
errors++;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (data.type !== undefined) {
|
|
183
|
+
if (typeof data.type !== "string") {
|
|
184
|
+
const err13 = { instancePath: instancePath + "/type", schemaPath: "#/definitions/readingv1JsonSchema/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
185
|
+
if (vErrors === null) {
|
|
186
|
+
vErrors = [err13];
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
vErrors.push(err13);
|
|
190
|
+
}
|
|
191
|
+
errors++;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (data.id !== undefined) {
|
|
195
|
+
if (typeof data.id !== "string") {
|
|
196
|
+
const err14 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/readingv1JsonSchema/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
197
|
+
if (vErrors === null) {
|
|
198
|
+
vErrors = [err14];
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
vErrors.push(err14);
|
|
202
|
+
}
|
|
203
|
+
errors++;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
const err15 = { instancePath, schemaPath: "#/definitions/readingv1JsonSchema/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
209
|
+
if (vErrors === null) {
|
|
210
|
+
vErrors = [err15];
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
vErrors.push(err15);
|
|
214
|
+
}
|
|
215
|
+
errors++;
|
|
216
|
+
} validate10.errors = vErrors; return errors === 0; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const kit_generator_1 = require("@xube/kit-generator");
|
|
4
|
+
const aggregate_1 = require("./decode/aggregate");
|
|
5
|
+
const reading_1 = require("./decode/reading");
|
|
6
|
+
const message_1 = require("./message/message");
|
|
7
|
+
const generatedFilePaths = [
|
|
8
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("aggregateMetadata", aggregate_1.AggregateMetadataSchema, __dirname),
|
|
9
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("aggregateMetadataV1", aggregate_1.AggregateMetadataV1Schema, __dirname),
|
|
10
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("aggregateMetadataTypes", aggregate_1.AggregateMetadataSchemas, __dirname),
|
|
11
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("deviceReadingMetadataV1", reading_1.DeviceReadingMetadataV1Schema, __dirname),
|
|
12
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("deviceReadingV1", reading_1.DeviceReadingV1Schema, __dirname),
|
|
13
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("readingV1", reading_1.ReadingV1Schema, __dirname),
|
|
14
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("readingMetadataV1", reading_1.ReadingMetadataV1Schema, __dirname),
|
|
15
|
+
...(0, kit_generator_1.generateTypeSchemaFiles)("dataMessage", message_1.DataMessageSchema, __dirname)
|
|
16
|
+
];
|
|
17
|
+
(0, kit_generator_1.generateExportIndex)(generatedFilePaths, __dirname);
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const GetDataByDateRangeRequestSchema: z.ZodObject<{
|
|
3
|
+
devices: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
components: z.ZodArray<z.ZodString, "many">;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
id: string;
|
|
8
|
+
components: string[];
|
|
9
|
+
}, {
|
|
10
|
+
id: string;
|
|
11
|
+
components: string[];
|
|
12
|
+
}>, "many">;
|
|
13
|
+
dateRange: z.ZodObject<{
|
|
14
|
+
start: z.ZodString;
|
|
15
|
+
end: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
start: string;
|
|
18
|
+
end: string;
|
|
19
|
+
}, {
|
|
20
|
+
start: string;
|
|
21
|
+
end: string;
|
|
22
|
+
}>;
|
|
23
|
+
email: z.ZodString;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
devices: {
|
|
26
|
+
id: string;
|
|
27
|
+
components: string[];
|
|
28
|
+
}[];
|
|
29
|
+
dateRange: {
|
|
30
|
+
start: string;
|
|
31
|
+
end: string;
|
|
32
|
+
};
|
|
33
|
+
email: string;
|
|
34
|
+
}, {
|
|
35
|
+
devices: {
|
|
36
|
+
id: string;
|
|
37
|
+
components: string[];
|
|
38
|
+
}[];
|
|
39
|
+
dateRange: {
|
|
40
|
+
start: string;
|
|
41
|
+
end: string;
|
|
42
|
+
};
|
|
43
|
+
email: string;
|
|
44
|
+
}>;
|
|
45
|
+
export type GetDataByDateRangeRequest = z.infer<typeof GetDataByDateRangeRequestSchema>;
|
|
46
|
+
export declare const isGetDataByDateRangeRequest: (object: unknown) => object is {
|
|
47
|
+
devices: {
|
|
48
|
+
id: string;
|
|
49
|
+
components: string[];
|
|
50
|
+
}[];
|
|
51
|
+
dateRange: {
|
|
52
|
+
start: string;
|
|
53
|
+
end: string;
|
|
54
|
+
};
|
|
55
|
+
email: string;
|
|
56
|
+
};
|
|
57
|
+
export declare const ComponentDataEntryResponseSchema: z.ZodObject<{
|
|
58
|
+
seconds: z.ZodNumber;
|
|
59
|
+
microseconds: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
readings: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
seconds: number;
|
|
63
|
+
readings: {};
|
|
64
|
+
microseconds?: number | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
seconds: number;
|
|
67
|
+
readings: {};
|
|
68
|
+
microseconds?: number | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export type ComponentDataEntryResponse = z.infer<typeof ComponentDataEntryResponseSchema>;
|
|
71
|
+
export declare const DeviceDataEntryResponseSchema: z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
components: z.ZodArray<z.ZodObject<{
|
|
74
|
+
id: z.ZodString;
|
|
75
|
+
data: z.ZodArray<z.ZodObject<{
|
|
76
|
+
seconds: z.ZodNumber;
|
|
77
|
+
microseconds: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
readings: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
seconds: number;
|
|
81
|
+
readings: {};
|
|
82
|
+
microseconds?: number | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
seconds: number;
|
|
85
|
+
readings: {};
|
|
86
|
+
microseconds?: number | undefined;
|
|
87
|
+
}>, "many">;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
data: {
|
|
90
|
+
seconds: number;
|
|
91
|
+
readings: {};
|
|
92
|
+
microseconds?: number | undefined;
|
|
93
|
+
}[];
|
|
94
|
+
id: string;
|
|
95
|
+
}, {
|
|
96
|
+
data: {
|
|
97
|
+
seconds: number;
|
|
98
|
+
readings: {};
|
|
99
|
+
microseconds?: number | undefined;
|
|
100
|
+
}[];
|
|
101
|
+
id: string;
|
|
102
|
+
}>, "many">;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
id: string;
|
|
105
|
+
components: {
|
|
106
|
+
data: {
|
|
107
|
+
seconds: number;
|
|
108
|
+
readings: {};
|
|
109
|
+
microseconds?: number | undefined;
|
|
110
|
+
}[];
|
|
111
|
+
id: string;
|
|
112
|
+
}[];
|
|
113
|
+
}, {
|
|
114
|
+
id: string;
|
|
115
|
+
components: {
|
|
116
|
+
data: {
|
|
117
|
+
seconds: number;
|
|
118
|
+
readings: {};
|
|
119
|
+
microseconds?: number | undefined;
|
|
120
|
+
}[];
|
|
121
|
+
id: string;
|
|
122
|
+
}[];
|
|
123
|
+
}>;
|
|
124
|
+
export type DeviceDataEntryResponse = z.infer<typeof DeviceDataEntryResponseSchema>;
|
|
125
|
+
export declare const GetDataByDateRangeResponseSchema: z.ZodObject<{
|
|
126
|
+
devices: z.ZodArray<z.ZodObject<{
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
components: z.ZodArray<z.ZodObject<{
|
|
129
|
+
id: z.ZodString;
|
|
130
|
+
data: z.ZodArray<z.ZodObject<{
|
|
131
|
+
seconds: z.ZodNumber;
|
|
132
|
+
microseconds: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
readings: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
seconds: number;
|
|
136
|
+
readings: {};
|
|
137
|
+
microseconds?: number | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
seconds: number;
|
|
140
|
+
readings: {};
|
|
141
|
+
microseconds?: number | undefined;
|
|
142
|
+
}>, "many">;
|
|
143
|
+
}, "strip", z.ZodTypeAny, {
|
|
144
|
+
data: {
|
|
145
|
+
seconds: number;
|
|
146
|
+
readings: {};
|
|
147
|
+
microseconds?: number | undefined;
|
|
148
|
+
}[];
|
|
149
|
+
id: string;
|
|
150
|
+
}, {
|
|
151
|
+
data: {
|
|
152
|
+
seconds: number;
|
|
153
|
+
readings: {};
|
|
154
|
+
microseconds?: number | undefined;
|
|
155
|
+
}[];
|
|
156
|
+
id: string;
|
|
157
|
+
}>, "many">;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
id: string;
|
|
160
|
+
components: {
|
|
161
|
+
data: {
|
|
162
|
+
seconds: number;
|
|
163
|
+
readings: {};
|
|
164
|
+
microseconds?: number | undefined;
|
|
165
|
+
}[];
|
|
166
|
+
id: string;
|
|
167
|
+
}[];
|
|
168
|
+
}, {
|
|
169
|
+
id: string;
|
|
170
|
+
components: {
|
|
171
|
+
data: {
|
|
172
|
+
seconds: number;
|
|
173
|
+
readings: {};
|
|
174
|
+
microseconds?: number | undefined;
|
|
175
|
+
}[];
|
|
176
|
+
id: string;
|
|
177
|
+
}[];
|
|
178
|
+
}>, "many">;
|
|
179
|
+
}, "strip", z.ZodTypeAny, {
|
|
180
|
+
devices: {
|
|
181
|
+
id: string;
|
|
182
|
+
components: {
|
|
183
|
+
data: {
|
|
184
|
+
seconds: number;
|
|
185
|
+
readings: {};
|
|
186
|
+
microseconds?: number | undefined;
|
|
187
|
+
}[];
|
|
188
|
+
id: string;
|
|
189
|
+
}[];
|
|
190
|
+
}[];
|
|
191
|
+
}, {
|
|
192
|
+
devices: {
|
|
193
|
+
id: string;
|
|
194
|
+
components: {
|
|
195
|
+
data: {
|
|
196
|
+
seconds: number;
|
|
197
|
+
readings: {};
|
|
198
|
+
microseconds?: number | undefined;
|
|
199
|
+
}[];
|
|
200
|
+
id: string;
|
|
201
|
+
}[];
|
|
202
|
+
}[];
|
|
203
|
+
}>;
|
|
204
|
+
export type GetDataByDateRangeResponse = z.infer<typeof GetDataByDateRangeResponseSchema>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetDataByDateRangeResponseSchema = exports.DeviceDataEntryResponseSchema = exports.ComponentDataEntryResponseSchema = exports.isGetDataByDateRangeRequest = exports.GetDataByDateRangeRequestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.GetDataByDateRangeRequestSchema = zod_1.z.object({
|
|
6
|
+
devices: zod_1.z.array(zod_1.z.object({
|
|
7
|
+
id: zod_1.z.string(),
|
|
8
|
+
components: zod_1.z.array(zod_1.z.string()),
|
|
9
|
+
})),
|
|
10
|
+
dateRange: zod_1.z.object({
|
|
11
|
+
start: zod_1.z.string().datetime(),
|
|
12
|
+
end: zod_1.z.string().datetime(),
|
|
13
|
+
}),
|
|
14
|
+
email: zod_1.z.string().email(),
|
|
15
|
+
});
|
|
16
|
+
const isGetDataByDateRangeRequest = (object) => {
|
|
17
|
+
return exports.GetDataByDateRangeRequestSchema.passthrough().safeParse(object)
|
|
18
|
+
.success;
|
|
19
|
+
};
|
|
20
|
+
exports.isGetDataByDateRangeRequest = isGetDataByDateRangeRequest;
|
|
21
|
+
exports.ComponentDataEntryResponseSchema = zod_1.z.object({
|
|
22
|
+
seconds: zod_1.z.number(),
|
|
23
|
+
microseconds: zod_1.z.number().optional(),
|
|
24
|
+
readings: zod_1.z.object({}),
|
|
25
|
+
});
|
|
26
|
+
exports.DeviceDataEntryResponseSchema = zod_1.z.object({
|
|
27
|
+
id: zod_1.z.string(),
|
|
28
|
+
components: zod_1.z.array(zod_1.z.object({
|
|
29
|
+
id: zod_1.z.string(),
|
|
30
|
+
data: zod_1.z.array(exports.ComponentDataEntryResponseSchema),
|
|
31
|
+
})),
|
|
32
|
+
});
|
|
33
|
+
exports.GetDataByDateRangeResponseSchema = zod_1.z.object({
|
|
34
|
+
devices: zod_1.z.array(exports.DeviceDataEntryResponseSchema),
|
|
35
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./decode/aggregate"), exports);
|
|
19
|
+
__exportStar(require("./decode/reading"), exports);
|
|
20
|
+
__exportStar(require("./get/get-data-by-date-range"), exports);
|
|
21
|
+
__exportStar(require("./generated/index"), exports);
|
|
22
|
+
__exportStar(require("./key/get"), exports);
|
|
23
|
+
__exportStar(require("./message/message"), exports);
|
package/dist/key/get.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDataSortKey = exports.getDataPartitionKey = void 0;
|
|
4
|
+
const getDataPartitionKey = (id) => {
|
|
5
|
+
return `DEVICE#${id}`;
|
|
6
|
+
};
|
|
7
|
+
exports.getDataPartitionKey = getDataPartitionKey;
|
|
8
|
+
const getDataSortKey = (componentId, seconds, microseconds) => {
|
|
9
|
+
return `${componentId}#${seconds}.${microseconds ?? 0}`;
|
|
10
|
+
};
|
|
11
|
+
exports.getDataSortKey = getDataSortKey;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DataMessageSchema: z.ZodObject<{
|
|
3
|
+
payload: z.ZodString;
|
|
4
|
+
account: z.ZodString;
|
|
5
|
+
device: z.ZodString;
|
|
6
|
+
component: z.ZodString;
|
|
7
|
+
timestamp: z.ZodNumber;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
component: string;
|
|
10
|
+
payload: string;
|
|
11
|
+
account: string;
|
|
12
|
+
device: string;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
}, {
|
|
15
|
+
component: string;
|
|
16
|
+
payload: string;
|
|
17
|
+
account: string;
|
|
18
|
+
device: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataMessageSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.DataMessageSchema = zod_1.z.object({
|
|
6
|
+
payload: zod_1.z.string(),
|
|
7
|
+
account: zod_1.z.string(),
|
|
8
|
+
device: zod_1.z.string(),
|
|
9
|
+
component: zod_1.z.string(),
|
|
10
|
+
timestamp: zod_1.z.number(),
|
|
11
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xube/kit-aws-data-schema",
|
|
3
|
+
"version": "0.0.73",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"generate": "npx ts-node src/generator.ts"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+ssh://git@github.com/XubeLtd/dev-kit.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "Xube Pty Ltd",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/XubeLtd/dev-kit/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/XubeLtd/dev-kit#readme",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.4.7",
|
|
22
|
+
"@xube/kit-build": "^0.0.73",
|
|
23
|
+
"ts-node": "^10.9.1",
|
|
24
|
+
"typescript": "^5.1.6"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@xube/kit-aws-schema": "^0.0.73",
|
|
28
|
+
"@xube/kit-constants": "^0.0.73",
|
|
29
|
+
"@xube/kit-generator": "^0.0.73",
|
|
30
|
+
"@xube/kit-log": "^0.0.73",
|
|
31
|
+
"@xube/kit-schema": "^0.0.73",
|
|
32
|
+
"zod": "^3.22.4"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {z} from "zod";
|
|
2
|
+
import { DeviceReadingV1Schema } from "./reading";
|
|
3
|
+
|
|
4
|
+
export const AggregateMetadataSchema = z.object({
|
|
5
|
+
v: z.number(), //Aggregate Metadata Schema Version
|
|
6
|
+
// vr: z.number(), //Reading Metadata Schema Version
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const AggregateMetaDataV1Version: number = 1
|
|
10
|
+
export const AggregateMetadataV1Schema = AggregateMetadataSchema.merge(z.object({
|
|
11
|
+
v: z.literal(AggregateMetaDataV1Version),
|
|
12
|
+
s: z.number(), //Size??
|
|
13
|
+
m: z.array(DeviceReadingV1Schema), //Reading Metadata Array
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
export const AggregateMetadataSchemas = //z.union([
|
|
17
|
+
AggregateMetadataV1Schema;
|
|
18
|
+
//]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseDataSchema, GenericDataTypesSchema } from "@xube/kit-schema";
|
|
3
|
+
|
|
4
|
+
export const ReadingDataTypesSchema = GenericDataTypesSchema;
|
|
5
|
+
|
|
6
|
+
export const DeviceReadingMetadataV1Schema = z.object({
|
|
7
|
+
s: z.number(), //Seconds,
|
|
8
|
+
us: z.number(), //Microseconds
|
|
9
|
+
});
|
|
10
|
+
export const DeviceReadingV1Schema = z.object({
|
|
11
|
+
m: DeviceReadingMetadataV1Schema,
|
|
12
|
+
s: z.number().optional(), //Size
|
|
13
|
+
});
|
|
14
|
+
export const DeviceReadingSchemas = DeviceReadingV1Schema;
|
|
15
|
+
|
|
16
|
+
export const ReadingMetadataV1Schema = DeviceReadingMetadataV1Schema;
|
|
17
|
+
export const ReadingV1Schema = z
|
|
18
|
+
.object({
|
|
19
|
+
data: ReadingDataTypesSchema,
|
|
20
|
+
component: z.string(),
|
|
21
|
+
})
|
|
22
|
+
.merge(BaseDataSchema)
|
|
23
|
+
.passthrough();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export {validate as validateAggregateMetadata} from './validators/aggregateMetadata'
|
|
2
|
+
export * from './types/aggregateMetadata'
|
|
3
|
+
export {validate as validateAggregateMetadataV1} from './validators/aggregateMetadataV1'
|
|
4
|
+
export * from './types/aggregateMetadataV1'
|
|
5
|
+
export {validate as validateAggregateMetadataTypes} from './validators/aggregateMetadataTypes'
|
|
6
|
+
export * from './types/aggregateMetadataTypes'
|
|
7
|
+
export {validate as validateDeviceReadingMetadataV1} from './validators/deviceReadingMetadataV1'
|
|
8
|
+
export * from './types/deviceReadingMetadataV1'
|
|
9
|
+
export {validate as validateDeviceReadingV1} from './validators/deviceReadingV1'
|
|
10
|
+
export * from './types/deviceReadingV1'
|
|
11
|
+
export {validate as validateReadingV1} from './validators/readingV1'
|
|
12
|
+
export * from './types/readingV1'
|
|
13
|
+
export {validate as validateReadingMetadataV1} from './validators/readingMetadataV1'
|
|
14
|
+
export * from './types/readingMetadataV1'
|
|
15
|
+
export {validate as validateDataMessage} from './validators/dataMessage'
|
|
16
|
+
export * from './types/dataMessage'
|