Skip to content

Commit a33085e

Browse files
authored
Add enumType to MessageDefinitionField (#7)
Adds an `enumType?: string` field to `MessageDefinitionField`. Bumps package version to 0.4.0.
1 parent e799954 commit a33085e

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# @foxglove/message-definition
22

3+
[![@foxglove/message-definition on npm](https://shields.io/npm/v/@foxglove/message-definition)](https://www.npmjs.com/package/@foxglove/message-definition)
4+
35
> Defines common TypeScript types for message definition schemas (ROS .msg, Protobuf, FlatBuffers, IDL, PX4 ULog, JSON Schema, etc).
46
57
## Why is this useful?
68

7-
Several interface definition languages exist today for describing the structure of messages. These languages are often used to generate code for serialization and deserialization of messages. This package defines a common representation in TypeScript for interface definitions, sometimes referred to as message definitions, so they can be reasoned about in a generic way. A concrete example of this is in [Foxglove Studio](https://github.com/foxglove/studio), which supports many different message serializations but provides common functionality across all of them such as [Message Path Syntax](https://foxglove.dev/docs/studio/app-concepts/message-path-syntax) and structured message display.
9+
Several interface definition languages exist today for describing the structure of messages. These languages are often used to generate code for serialization and deserialization of messages. This package defines a common representation in TypeScript for interface definitions, sometimes referred to as message definitions, so they can be reasoned about in a generic way. A concrete example of this is in [Foxglove](https://foxglove.dev/product), which supports many different message serializations but provides common functionality across all of them such as [Message Path Syntax](https://docs.foxglove.dev/docs/visualization/message-path-syntax/) and structured message display.
810

911
## Examples
1012

@@ -55,4 +57,4 @@ Note that this package only provides type definitions, not any functionality for
5557

5658
## Stay in touch
5759

58-
Join our [Slack channel](https://foxglove.dev/slack) to ask questions, share feedback, and stay up to date on what our team is working on.
60+
Join our [Discord community](https://foxglove.dev/chat) to ask questions, share feedback, and stay up to date on what our team is working on.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@foxglove/message-definition",
3-
"version": "0.3.1",
3+
"version": "0.4.0",
44
"description": "Defines common types for message definition schemas (ROS .msg, Protobuf, FlatBuffers, IDL, PX4 ULog, JSON Schema, etc)",
55
"license": "MIT",
66
"repository": {

src/compare.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function isMsgDefFieldEqual(
4040
lhs.type === rhs.type &&
4141
lhs.name === rhs.name &&
4242
(lhs.isComplex ?? false) === (rhs.isComplex ?? false) &&
43+
lhs.enumType === rhs.enumType &&
4344
(lhs.isArray ?? false) === (rhs.isArray ?? false) &&
4445
lhs.arrayLength === rhs.arrayLength &&
4546
(lhs.isConstant ?? false) === (rhs.isConstant ?? false) &&

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ export type MessageDefinitionField = {
5757
* primitive type, a custom struct).
5858
*/
5959
isComplex?: boolean;
60+
/**
61+
* Name of an enumeration type associated with this field. The field should contain a primitive
62+
* value (`isComplex !== true`).
63+
*/
64+
enumType?: string;
6065

6166
/**
6267
* Set to true if this field is an array. For example, the following Protobuf
@@ -122,6 +127,7 @@ export type MessageDefinitionField = {
122127
* Would be represented as:
123128
* ```typescript
124129
* { type: "bool", name: "ALIVE", isConstant: true, value: true, valueText: "True" }
130+
* ```
125131
*/
126132
valueText?: string;
127133

0 commit comments

Comments
 (0)