@2702rebels/wpidata 1.0.0 → 1.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/dist/abstractions.d.cts +140 -140
- package/dist/abstractions.d.cts.map +1 -1
- package/dist/abstractions.d.mts +140 -140
- package/dist/abstractions.d.mts.map +1 -1
- package/dist/formats/json.d.cts.map +1 -1
- package/dist/formats/json.d.mts.map +1 -1
- package/dist/formats/msgpack.d.cts.map +1 -1
- package/dist/formats/msgpack.d.mts.map +1 -1
- package/dist/formats/protobuf.d.cts +21 -22
- package/dist/formats/protobuf.d.cts.map +1 -1
- package/dist/formats/protobuf.d.mts +21 -22
- package/dist/formats/protobuf.d.mts.map +1 -1
- package/dist/formats/protobuf.mjs.map +1 -1
- package/dist/formats/struct.cjs +17 -4
- package/dist/formats/struct.d.cts +52 -65
- package/dist/formats/struct.d.cts.map +1 -1
- package/dist/formats/struct.d.mts +52 -65
- package/dist/formats/struct.d.mts.map +1 -1
- package/dist/formats/struct.mjs +17 -4
- package/dist/formats/struct.mjs.map +1 -1
- package/dist/sink.d.cts +35 -43
- package/dist/sink.d.cts.map +1 -1
- package/dist/sink.d.mts +35 -43
- package/dist/sink.d.mts.map +1 -1
- package/dist/types/protobuf.d.cts.map +1 -1
- package/dist/types/protobuf.d.mts.map +1 -1
- package/dist/types/sendable.d.cts.map +1 -1
- package/dist/types/sendable.d.mts.map +1 -1
- package/dist/types/struct.d.cts.map +1 -1
- package/dist/types/struct.d.mts.map +1 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts.map +1 -1
- package/package.json +4 -4
- package/src/formats/protobuf.ts +1 -0
- package/src/formats/struct.test.ts +49 -0
- package/src/formats/struct.ts +34 -4
package/dist/abstractions.d.cts
CHANGED
|
@@ -3,134 +3,134 @@ type DataType = "boolean" | "string" | "number" | "booleanArray" | "stringArray"
|
|
|
3
3
|
type DataTypeImpl = boolean | string | number | Array<boolean> | Array<string> | Array<number> | Record<string, unknown> | Array<Record<string, unknown>> | Uint8Array;
|
|
4
4
|
interface StructuredTypeDescriptor {
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
* **Type name**
|
|
7
|
+
*
|
|
8
|
+
* Typically the name represents the original type name without any adorners.
|
|
9
|
+
* For example, `struct:Pose3d`, `struct:Pose3d[]` would be represented
|
|
10
|
+
* as `Pose3d`, and `proto:wpi.proto.ProtobufPose3d` as `wpi.proto.ProtobufPose3d`.
|
|
11
|
+
*
|
|
12
|
+
* To determine if the parsed value is an array, consult `array` indicator and
|
|
13
|
+
* use `Array.isArray` method.
|
|
14
|
+
*/
|
|
15
15
|
readonly name: string;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
* **Type format**
|
|
18
|
+
*
|
|
19
|
+
* Represents the origin (protocol) of the deserialized data.
|
|
20
|
+
*
|
|
21
|
+
* Due to WPILIB idiosyncrasies deserialized JSON representation of the same
|
|
22
|
+
* structured type may differ across various serialization protocols.
|
|
23
|
+
*/
|
|
24
24
|
readonly format: "protobuf" | "struct" | "composite";
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* **Array indicator**
|
|
27
|
+
*
|
|
28
|
+
* Indicates that the value contains a top-level array of type.
|
|
29
|
+
*/
|
|
30
30
|
readonly isArray?: boolean;
|
|
31
31
|
}
|
|
32
32
|
interface DataChannelRecord<T extends DataTypeImpl = DataTypeImpl> {
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
* **Timestamp (microseconds)**
|
|
35
|
+
*
|
|
36
|
+
* Timestamp of the record in microseconds. Typically represents robot time.
|
|
37
|
+
*/
|
|
38
38
|
readonly timestamp: number;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
* **Value**
|
|
41
|
+
*
|
|
42
|
+
* Record value. Depends on the {@link DataChannel.dataType}.
|
|
43
|
+
*/
|
|
44
44
|
value: T;
|
|
45
45
|
}
|
|
46
46
|
interface DataChannelBase<T extends DataTypeImpl = DataTypeImpl> {
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
* **Channel source**
|
|
49
|
+
*
|
|
50
|
+
* For example, `nt` or `wpilog`. This field is considered opaque.
|
|
51
|
+
*/
|
|
52
52
|
readonly source: string;
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
* **Channel identifier**
|
|
55
|
+
*
|
|
56
|
+
* Must be unique within the data source.
|
|
57
|
+
* NT4 — topic name
|
|
58
|
+
* WPILOG — data channel identifier
|
|
59
|
+
*/
|
|
60
60
|
readonly id: string;
|
|
61
61
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
* **Data representation type**
|
|
63
|
+
*
|
|
64
|
+
* This type indicates the processed data representation in the Javascript world.
|
|
65
|
+
* For example, NT4 source may differentiate between numeric types, such as
|
|
66
|
+
* 32-bit integer and 64-bit float, yet both are stored as `number`.
|
|
67
|
+
*
|
|
68
|
+
* Complex types are typically serialized using JSON, msgpack, struct or protobuf
|
|
69
|
+
* protocols and require a corresponding data transformer to be registered in
|
|
70
|
+
* the pipeline to unpack them. If no transformer is present the raw `binary`
|
|
71
|
+
* representation is used where data is stored in a byte array buffer.
|
|
72
|
+
*/
|
|
73
73
|
readonly dataType: DataType;
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
* **Raw data type**
|
|
76
|
+
*
|
|
77
|
+
* Raw data type string to be used for publishing. Retains original type specifics
|
|
78
|
+
* that cannot be represented in the JavaScript world, such as differences between
|
|
79
|
+
* various numeric types.
|
|
80
|
+
*/
|
|
81
81
|
readonly publishedDataType: string;
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
* **Protocol transformer**
|
|
84
|
+
*
|
|
85
|
+
* Unpacks raw binary data into JSON object according to the serialization protocol.
|
|
86
|
+
*/
|
|
87
87
|
readonly transformer?: DataTransformer;
|
|
88
88
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
* **Structured type descriptor**
|
|
90
|
+
*
|
|
91
|
+
* Applicable to complex types, serialized as struct or protobuf. Must be set
|
|
92
|
+
* by the corresponding transformer.
|
|
93
|
+
*/
|
|
94
94
|
structuredType?: StructuredTypeDescriptor;
|
|
95
95
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
* **Channel metadata**
|
|
97
|
+
*
|
|
98
|
+
* For NT4 metadata is extracted from topic properties beyond the default set.
|
|
99
|
+
* For WPILOG metadata is read and attempted to be parsed as JSON object first
|
|
100
|
+
* and stored as string otherwise.
|
|
101
|
+
*
|
|
102
|
+
* This field represents the most recently seen values as published by the source.
|
|
103
|
+
*/
|
|
104
104
|
metadata?: Record<string, unknown> | string;
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
* **Timestamped records**
|
|
107
|
+
*
|
|
108
|
+
* Timestamps are provided by the data source. The array is sorted by the timestamp
|
|
109
|
+
* in ascending order, earlier records have smaller indices.
|
|
110
|
+
*/
|
|
111
111
|
records?: Array<DataChannelRecord<T>>;
|
|
112
112
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
* **Timestamped dead-letter queue**
|
|
114
|
+
*
|
|
115
|
+
* Records that cannot be yet unpacked due to missing type descriptors.
|
|
116
|
+
*
|
|
117
|
+
* Timestamps are provided by the data source. The array is sorted by the timestamp
|
|
118
|
+
* in ascending order, earlier records have smaller indices.
|
|
119
|
+
*/
|
|
120
120
|
dlq?: Array<DataChannelRecord<Uint8Array>>;
|
|
121
121
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
* **Composite channel container**
|
|
123
|
+
*
|
|
124
|
+
* Returns the container composite channel for sub-channels that are part of it.
|
|
125
|
+
*/
|
|
126
126
|
composite?: CompositeDataChannel;
|
|
127
127
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
* **Publishes value to the channel**
|
|
129
|
+
*
|
|
130
|
+
* @param value value to publish
|
|
131
|
+
* @param path optional path to the sub-channel
|
|
132
|
+
* @param options additional publisher options
|
|
133
|
+
*/
|
|
134
134
|
publish?: (value: unknown, path?: ReadonlyArray<string>, options?: DataChannelPublisherOptions) => void;
|
|
135
135
|
}
|
|
136
136
|
interface BooleanDataChannel extends DataChannelBase<boolean> {
|
|
@@ -160,11 +160,11 @@ interface BinaryDataChannel extends DataChannelBase<Uint8Array> {
|
|
|
160
160
|
interface CompositeDataChannel extends DataChannelBase<Record<string, unknown>> {
|
|
161
161
|
readonly dataType: "composite";
|
|
162
162
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
* **Sub-channel identifiers and record paths**
|
|
164
|
+
*
|
|
165
|
+
* Identifiers of individual data channels that comprise this composite channel
|
|
166
|
+
* and their respective paths for the data to be written in the JSON record.
|
|
167
|
+
*/
|
|
168
168
|
channels: Map<string, Array<string>>;
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
@@ -186,55 +186,55 @@ type DataChannel = BooleanDataChannel | StringDataChannel | NumberDataChannel |
|
|
|
186
186
|
*/
|
|
187
187
|
interface DataTransformer {
|
|
188
188
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
189
|
+
* Inspects a channel to determine whether it represents a schema or a data channel
|
|
190
|
+
* that must run through this transformer.
|
|
191
|
+
*
|
|
192
|
+
* This method must return either a {@link DataChannel} instance indicating a data
|
|
193
|
+
* channel, which must have {@link DataChannel.transformer} field set, or a string
|
|
194
|
+
* containing the schema type name indicating a schema channel. Otherwise,
|
|
195
|
+
* a value of `undefined` must be returned.
|
|
196
|
+
*
|
|
197
|
+
* @param source source
|
|
198
|
+
* @param name channel name
|
|
199
|
+
* @param type channel type
|
|
200
|
+
* @param metadata channel metadata
|
|
201
|
+
* @returns data channel, schema type name or `undefined`
|
|
202
|
+
*/
|
|
203
203
|
inspect(source: string, name: string, type: string, metadata?: Record<string, unknown> | string): DataChannel | string | undefined;
|
|
204
204
|
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
* Ingests raw schema data for the specified type name. This method will be invoked
|
|
206
|
+
* when the data arrives on a schema channel previously identified by {@link inspect}.
|
|
207
|
+
*
|
|
208
|
+
* @param typeName schema type name previously returned by {@link inspect}
|
|
209
|
+
* @param value raw schema data
|
|
210
|
+
*/
|
|
211
211
|
schema(typeName: string, value: unknown): void;
|
|
212
212
|
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
* Deserializes raw data. If the data cannot be transformed yet due to missing
|
|
214
|
+
* schema dependencies, this method must return `undefined` and the data will
|
|
215
|
+
* stored in the dead-letter queue to retry automatically at a later time.
|
|
216
|
+
*
|
|
217
|
+
* @param value raw value to deserialize
|
|
218
|
+
* @param type an optional {@link DataChannel.structuredType} descriptor
|
|
219
|
+
* @returns a deserialized value on success or `undefined` otherwise
|
|
220
|
+
*/
|
|
221
221
|
deserialize(value: unknown, type?: StructuredTypeDescriptor): DataTypeImpl | undefined;
|
|
222
222
|
/**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
* Serializes data into a raw format for publishing.
|
|
224
|
+
*
|
|
225
|
+
* @param value value to serialize
|
|
226
|
+
* @param type an optional {@link DataChannel.structuredType} descriptor
|
|
227
|
+
* @returns a serialized representation of the value
|
|
228
|
+
*/
|
|
229
229
|
serialize(value: unknown, type?: StructuredTypeDescriptor): string | Uint8Array;
|
|
230
230
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
231
|
+
* Determines whether data with the specified `type` can be transformed.
|
|
232
|
+
*
|
|
233
|
+
* The transformer may not be able to transform certain types if it is missing
|
|
234
|
+
* corresponding type descriptors yet to arrive via schema channel.
|
|
235
|
+
*
|
|
236
|
+
* @param type type name
|
|
237
|
+
*/
|
|
238
238
|
canTransform(type: string): boolean;
|
|
239
239
|
}
|
|
240
240
|
interface DataChannelPublisherOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractions.d.cts","names":[],"sources":["../src/abstractions.ts"],"
|
|
1
|
+
{"version":3,"file":"abstractions.d.cts","names":[],"sources":["../src/abstractions.ts"],"mappings":";KAAY,QAAA;AAA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