@foxglove/schemas 0.1.2
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.js +19 -0
- package/.gitattributes +1 -0
- package/.github/workflows/ci.yml +89 -0
- package/.prettierignore +1 -0
- package/.prettierrc.yml +2 -0
- package/.vscode/launch.json +23 -0
- package/.vscode/settings.json +20 -0
- package/LICENSE.md +21 -0
- package/README.md +31 -0
- package/dist/cjs/schemas/typescript/CameraCalibration.d.ts +63 -0
- package/dist/cjs/schemas/typescript/CameraCalibration.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/CameraCalibration.js +4 -0
- package/dist/cjs/schemas/typescript/CameraCalibration.js.map +1 -0
- package/dist/cjs/schemas/typescript/CircleAnnotation.d.ts +19 -0
- package/dist/cjs/schemas/typescript/CircleAnnotation.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/CircleAnnotation.js +4 -0
- package/dist/cjs/schemas/typescript/CircleAnnotation.js.map +1 -0
- package/dist/cjs/schemas/typescript/Color.d.ts +12 -0
- package/dist/cjs/schemas/typescript/Color.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Color.js +4 -0
- package/dist/cjs/schemas/typescript/Color.js.map +1 -0
- package/dist/cjs/schemas/typescript/CompressedImage.d.ts +11 -0
- package/dist/cjs/schemas/typescript/CompressedImage.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/CompressedImage.js +4 -0
- package/dist/cjs/schemas/typescript/CompressedImage.js.map +1 -0
- package/dist/cjs/schemas/typescript/Duration.d.ts +5 -0
- package/dist/cjs/schemas/typescript/Duration.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Duration.js +3 -0
- package/dist/cjs/schemas/typescript/Duration.js.map +1 -0
- package/dist/cjs/schemas/typescript/FrameTransform.d.ts +14 -0
- package/dist/cjs/schemas/typescript/FrameTransform.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/FrameTransform.js +4 -0
- package/dist/cjs/schemas/typescript/FrameTransform.js.map +1 -0
- package/dist/cjs/schemas/typescript/GeoJSON.d.ts +6 -0
- package/dist/cjs/schemas/typescript/GeoJSON.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/GeoJSON.js +4 -0
- package/dist/cjs/schemas/typescript/GeoJSON.js.map +1 -0
- package/dist/cjs/schemas/typescript/Grid.d.ts +26 -0
- package/dist/cjs/schemas/typescript/Grid.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Grid.js +4 -0
- package/dist/cjs/schemas/typescript/Grid.js.map +1 -0
- package/dist/cjs/schemas/typescript/ImageAnnotations.d.ts +10 -0
- package/dist/cjs/schemas/typescript/ImageAnnotations.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/ImageAnnotations.js +4 -0
- package/dist/cjs/schemas/typescript/ImageAnnotations.js.map +1 -0
- package/dist/cjs/schemas/typescript/LaserScan.d.ts +20 -0
- package/dist/cjs/schemas/typescript/LaserScan.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/LaserScan.js +4 -0
- package/dist/cjs/schemas/typescript/LaserScan.js.map +1 -0
- package/dist/cjs/schemas/typescript/LocationFix.d.ts +15 -0
- package/dist/cjs/schemas/typescript/LocationFix.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/LocationFix.js +4 -0
- package/dist/cjs/schemas/typescript/LocationFix.js.map +1 -0
- package/dist/cjs/schemas/typescript/Log.d.ts +18 -0
- package/dist/cjs/schemas/typescript/Log.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Log.js +4 -0
- package/dist/cjs/schemas/typescript/Log.js.map +1 -0
- package/dist/cjs/schemas/typescript/LogLevel.d.ts +10 -0
- package/dist/cjs/schemas/typescript/LogLevel.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/LogLevel.js +15 -0
- package/dist/cjs/schemas/typescript/LogLevel.js.map +1 -0
- package/dist/cjs/schemas/typescript/NumericType.d.ts +13 -0
- package/dist/cjs/schemas/typescript/NumericType.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/NumericType.js +18 -0
- package/dist/cjs/schemas/typescript/NumericType.js.map +1 -0
- package/dist/cjs/schemas/typescript/PackedElementField.d.ts +11 -0
- package/dist/cjs/schemas/typescript/PackedElementField.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/PackedElementField.js +4 -0
- package/dist/cjs/schemas/typescript/PackedElementField.js.map +1 -0
- package/dist/cjs/schemas/typescript/Point2.d.ts +8 -0
- package/dist/cjs/schemas/typescript/Point2.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Point2.js +4 -0
- package/dist/cjs/schemas/typescript/Point2.js.map +1 -0
- package/dist/cjs/schemas/typescript/Point3.d.ts +10 -0
- package/dist/cjs/schemas/typescript/Point3.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Point3.js +4 -0
- package/dist/cjs/schemas/typescript/Point3.js.map +1 -0
- package/dist/cjs/schemas/typescript/PointCloud.d.ts +19 -0
- package/dist/cjs/schemas/typescript/PointCloud.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/PointCloud.js +4 -0
- package/dist/cjs/schemas/typescript/PointCloud.js.map +1 -0
- package/dist/cjs/schemas/typescript/PointsAnnotation.d.ts +18 -0
- package/dist/cjs/schemas/typescript/PointsAnnotation.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/PointsAnnotation.js +4 -0
- package/dist/cjs/schemas/typescript/PointsAnnotation.js.map +1 -0
- package/dist/cjs/schemas/typescript/PointsAnnotationType.d.ts +9 -0
- package/dist/cjs/schemas/typescript/PointsAnnotationType.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/PointsAnnotationType.js +14 -0
- package/dist/cjs/schemas/typescript/PointsAnnotationType.js.map +1 -0
- package/dist/cjs/schemas/typescript/Pose.d.ts +10 -0
- package/dist/cjs/schemas/typescript/Pose.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Pose.js +4 -0
- package/dist/cjs/schemas/typescript/Pose.js.map +1 -0
- package/dist/cjs/schemas/typescript/PoseInFrame.d.ts +12 -0
- package/dist/cjs/schemas/typescript/PoseInFrame.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/PoseInFrame.js +4 -0
- package/dist/cjs/schemas/typescript/PoseInFrame.js.map +1 -0
- package/dist/cjs/schemas/typescript/PosesInFrame.d.ts +12 -0
- package/dist/cjs/schemas/typescript/PosesInFrame.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/PosesInFrame.js +4 -0
- package/dist/cjs/schemas/typescript/PosesInFrame.js.map +1 -0
- package/dist/cjs/schemas/typescript/PositionCovarianceType.d.ts +8 -0
- package/dist/cjs/schemas/typescript/PositionCovarianceType.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/PositionCovarianceType.js +13 -0
- package/dist/cjs/schemas/typescript/PositionCovarianceType.js.map +1 -0
- package/dist/cjs/schemas/typescript/Quaternion.d.ts +12 -0
- package/dist/cjs/schemas/typescript/Quaternion.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Quaternion.js +4 -0
- package/dist/cjs/schemas/typescript/Quaternion.js.map +1 -0
- package/dist/cjs/schemas/typescript/RawImage.d.ts +17 -0
- package/dist/cjs/schemas/typescript/RawImage.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/RawImage.js +4 -0
- package/dist/cjs/schemas/typescript/RawImage.js.map +1 -0
- package/dist/cjs/schemas/typescript/Time.d.ts +5 -0
- package/dist/cjs/schemas/typescript/Time.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Time.js +3 -0
- package/dist/cjs/schemas/typescript/Time.js.map +1 -0
- package/dist/cjs/schemas/typescript/Transform.d.ts +13 -0
- package/dist/cjs/schemas/typescript/Transform.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Transform.js +4 -0
- package/dist/cjs/schemas/typescript/Transform.js.map +1 -0
- package/dist/cjs/schemas/typescript/Vector2.d.ts +8 -0
- package/dist/cjs/schemas/typescript/Vector2.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Vector2.js +4 -0
- package/dist/cjs/schemas/typescript/Vector2.js.map +1 -0
- package/dist/cjs/schemas/typescript/Vector3.d.ts +10 -0
- package/dist/cjs/schemas/typescript/Vector3.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/Vector3.js +4 -0
- package/dist/cjs/schemas/typescript/Vector3.js.map +1 -0
- package/dist/cjs/schemas/typescript/index.d.ts +29 -0
- package/dist/cjs/schemas/typescript/index.d.ts.map +1 -0
- package/dist/cjs/schemas/typescript/index.js +32 -0
- package/dist/cjs/schemas/typescript/index.js.map +1 -0
- package/dist/cjs/scripts/updateGeneratedFiles.d.ts +2 -0
- package/dist/cjs/scripts/updateGeneratedFiles.d.ts.map +1 -0
- package/dist/cjs/scripts/updateGeneratedFiles.js +77 -0
- package/dist/cjs/scripts/updateGeneratedFiles.js.map +1 -0
- package/dist/cjs/src/generateJsonSchema.d.ts +3 -0
- package/dist/cjs/src/generateJsonSchema.d.ts.map +1 -0
- package/dist/cjs/src/generateJsonSchema.js +85 -0
- package/dist/cjs/src/generateJsonSchema.js.map +1 -0
- package/dist/cjs/src/generateJsonSchema.test.d.ts +2 -0
- package/dist/cjs/src/generateJsonSchema.test.d.ts.map +1 -0
- package/dist/cjs/src/generateJsonSchema.test.js +312 -0
- package/dist/cjs/src/generateJsonSchema.test.js.map +1 -0
- package/dist/cjs/src/generateProto.d.ts +3 -0
- package/dist/cjs/src/generateProto.d.ts.map +1 -0
- package/dist/cjs/src/generateProto.js +84 -0
- package/dist/cjs/src/generateProto.js.map +1 -0
- package/dist/cjs/src/generateProto.test.d.ts +2 -0
- package/dist/cjs/src/generateProto.test.d.ts.map +1 -0
- package/dist/cjs/src/generateProto.test.js +125 -0
- package/dist/cjs/src/generateProto.test.js.map +1 -0
- package/dist/cjs/src/generateRos.d.ts +20 -0
- package/dist/cjs/src/generateRos.d.ts.map +1 -0
- package/dist/cjs/src/generateRos.js +186 -0
- package/dist/cjs/src/generateRos.js.map +1 -0
- package/dist/cjs/src/generateRos.test.d.ts +2 -0
- package/dist/cjs/src/generateRos.test.d.ts.map +1 -0
- package/dist/cjs/src/generateRos.test.js +911 -0
- package/dist/cjs/src/generateRos.test.js.map +1 -0
- package/dist/cjs/src/generateTypeScript.d.ts +5 -0
- package/dist/cjs/src/generateTypeScript.d.ts.map +1 -0
- package/dist/cjs/src/generateTypeScript.js +100 -0
- package/dist/cjs/src/generateTypeScript.js.map +1 -0
- package/dist/cjs/src/generateTypeScript.test.d.ts +2 -0
- package/dist/cjs/src/generateTypeScript.test.d.ts.map +1 -0
- package/dist/cjs/src/generateTypeScript.test.js +142 -0
- package/dist/cjs/src/generateTypeScript.test.js.map +1 -0
- package/dist/cjs/src/index.d.ts +6 -0
- package/dist/cjs/src/index.d.ts.map +1 -0
- package/dist/cjs/src/index.js +9 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/cjs/src/schemas.d.ts +35 -0
- package/dist/cjs/src/schemas.d.ts.map +1 -0
- package/dist/cjs/src/schemas.js +820 -0
- package/dist/cjs/src/schemas.js.map +1 -0
- package/dist/cjs/src/schemas.test.d.ts +2 -0
- package/dist/cjs/src/schemas.test.d.ts.map +1 -0
- package/dist/cjs/src/schemas.test.js +24 -0
- package/dist/cjs/src/schemas.test.js.map +1 -0
- package/dist/cjs/src/testFixtures.d.ts +5 -0
- package/dist/cjs/src/testFixtures.d.ts.map +1 -0
- package/dist/cjs/src/testFixtures.js +86 -0
- package/dist/cjs/src/testFixtures.js.map +1 -0
- package/dist/cjs/src/types.d.ts +37 -0
- package/dist/cjs/src/types.d.ts.map +1 -0
- package/dist/cjs/src/types.js +3 -0
- package/dist/cjs/src/types.js.map +1 -0
- package/dist/esm/schemas/typescript/CameraCalibration.d.ts +63 -0
- package/dist/esm/schemas/typescript/CameraCalibration.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/CameraCalibration.js +3 -0
- package/dist/esm/schemas/typescript/CameraCalibration.js.map +1 -0
- package/dist/esm/schemas/typescript/CircleAnnotation.d.ts +19 -0
- package/dist/esm/schemas/typescript/CircleAnnotation.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/CircleAnnotation.js +3 -0
- package/dist/esm/schemas/typescript/CircleAnnotation.js.map +1 -0
- package/dist/esm/schemas/typescript/Color.d.ts +12 -0
- package/dist/esm/schemas/typescript/Color.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Color.js +3 -0
- package/dist/esm/schemas/typescript/Color.js.map +1 -0
- package/dist/esm/schemas/typescript/CompressedImage.d.ts +11 -0
- package/dist/esm/schemas/typescript/CompressedImage.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/CompressedImage.js +3 -0
- package/dist/esm/schemas/typescript/CompressedImage.js.map +1 -0
- package/dist/esm/schemas/typescript/Duration.d.ts +5 -0
- package/dist/esm/schemas/typescript/Duration.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Duration.js +2 -0
- package/dist/esm/schemas/typescript/Duration.js.map +1 -0
- package/dist/esm/schemas/typescript/FrameTransform.d.ts +14 -0
- package/dist/esm/schemas/typescript/FrameTransform.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/FrameTransform.js +3 -0
- package/dist/esm/schemas/typescript/FrameTransform.js.map +1 -0
- package/dist/esm/schemas/typescript/GeoJSON.d.ts +6 -0
- package/dist/esm/schemas/typescript/GeoJSON.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/GeoJSON.js +3 -0
- package/dist/esm/schemas/typescript/GeoJSON.js.map +1 -0
- package/dist/esm/schemas/typescript/Grid.d.ts +26 -0
- package/dist/esm/schemas/typescript/Grid.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Grid.js +3 -0
- package/dist/esm/schemas/typescript/Grid.js.map +1 -0
- package/dist/esm/schemas/typescript/ImageAnnotations.d.ts +10 -0
- package/dist/esm/schemas/typescript/ImageAnnotations.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/ImageAnnotations.js +3 -0
- package/dist/esm/schemas/typescript/ImageAnnotations.js.map +1 -0
- package/dist/esm/schemas/typescript/LaserScan.d.ts +20 -0
- package/dist/esm/schemas/typescript/LaserScan.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/LaserScan.js +3 -0
- package/dist/esm/schemas/typescript/LaserScan.js.map +1 -0
- package/dist/esm/schemas/typescript/LocationFix.d.ts +15 -0
- package/dist/esm/schemas/typescript/LocationFix.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/LocationFix.js +3 -0
- package/dist/esm/schemas/typescript/LocationFix.js.map +1 -0
- package/dist/esm/schemas/typescript/Log.d.ts +18 -0
- package/dist/esm/schemas/typescript/Log.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Log.js +3 -0
- package/dist/esm/schemas/typescript/Log.js.map +1 -0
- package/dist/esm/schemas/typescript/LogLevel.d.ts +10 -0
- package/dist/esm/schemas/typescript/LogLevel.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/LogLevel.js +12 -0
- package/dist/esm/schemas/typescript/LogLevel.js.map +1 -0
- package/dist/esm/schemas/typescript/NumericType.d.ts +13 -0
- package/dist/esm/schemas/typescript/NumericType.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/NumericType.js +15 -0
- package/dist/esm/schemas/typescript/NumericType.js.map +1 -0
- package/dist/esm/schemas/typescript/PackedElementField.d.ts +11 -0
- package/dist/esm/schemas/typescript/PackedElementField.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/PackedElementField.js +3 -0
- package/dist/esm/schemas/typescript/PackedElementField.js.map +1 -0
- package/dist/esm/schemas/typescript/Point2.d.ts +8 -0
- package/dist/esm/schemas/typescript/Point2.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Point2.js +3 -0
- package/dist/esm/schemas/typescript/Point2.js.map +1 -0
- package/dist/esm/schemas/typescript/Point3.d.ts +10 -0
- package/dist/esm/schemas/typescript/Point3.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Point3.js +3 -0
- package/dist/esm/schemas/typescript/Point3.js.map +1 -0
- package/dist/esm/schemas/typescript/PointCloud.d.ts +19 -0
- package/dist/esm/schemas/typescript/PointCloud.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/PointCloud.js +3 -0
- package/dist/esm/schemas/typescript/PointCloud.js.map +1 -0
- package/dist/esm/schemas/typescript/PointsAnnotation.d.ts +18 -0
- package/dist/esm/schemas/typescript/PointsAnnotation.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/PointsAnnotation.js +3 -0
- package/dist/esm/schemas/typescript/PointsAnnotation.js.map +1 -0
- package/dist/esm/schemas/typescript/PointsAnnotationType.d.ts +9 -0
- package/dist/esm/schemas/typescript/PointsAnnotationType.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/PointsAnnotationType.js +11 -0
- package/dist/esm/schemas/typescript/PointsAnnotationType.js.map +1 -0
- package/dist/esm/schemas/typescript/Pose.d.ts +10 -0
- package/dist/esm/schemas/typescript/Pose.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Pose.js +3 -0
- package/dist/esm/schemas/typescript/Pose.js.map +1 -0
- package/dist/esm/schemas/typescript/PoseInFrame.d.ts +12 -0
- package/dist/esm/schemas/typescript/PoseInFrame.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/PoseInFrame.js +3 -0
- package/dist/esm/schemas/typescript/PoseInFrame.js.map +1 -0
- package/dist/esm/schemas/typescript/PosesInFrame.d.ts +12 -0
- package/dist/esm/schemas/typescript/PosesInFrame.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/PosesInFrame.js +3 -0
- package/dist/esm/schemas/typescript/PosesInFrame.js.map +1 -0
- package/dist/esm/schemas/typescript/PositionCovarianceType.d.ts +8 -0
- package/dist/esm/schemas/typescript/PositionCovarianceType.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/PositionCovarianceType.js +10 -0
- package/dist/esm/schemas/typescript/PositionCovarianceType.js.map +1 -0
- package/dist/esm/schemas/typescript/Quaternion.d.ts +12 -0
- package/dist/esm/schemas/typescript/Quaternion.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Quaternion.js +3 -0
- package/dist/esm/schemas/typescript/Quaternion.js.map +1 -0
- package/dist/esm/schemas/typescript/RawImage.d.ts +17 -0
- package/dist/esm/schemas/typescript/RawImage.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/RawImage.js +3 -0
- package/dist/esm/schemas/typescript/RawImage.js.map +1 -0
- package/dist/esm/schemas/typescript/Time.d.ts +5 -0
- package/dist/esm/schemas/typescript/Time.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Time.js +2 -0
- package/dist/esm/schemas/typescript/Time.js.map +1 -0
- package/dist/esm/schemas/typescript/Transform.d.ts +13 -0
- package/dist/esm/schemas/typescript/Transform.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Transform.js +3 -0
- package/dist/esm/schemas/typescript/Transform.js.map +1 -0
- package/dist/esm/schemas/typescript/Vector2.d.ts +8 -0
- package/dist/esm/schemas/typescript/Vector2.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Vector2.js +3 -0
- package/dist/esm/schemas/typescript/Vector2.js.map +1 -0
- package/dist/esm/schemas/typescript/Vector3.d.ts +10 -0
- package/dist/esm/schemas/typescript/Vector3.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/Vector3.js +3 -0
- package/dist/esm/schemas/typescript/Vector3.js.map +1 -0
- package/dist/esm/schemas/typescript/index.d.ts +29 -0
- package/dist/esm/schemas/typescript/index.d.ts.map +1 -0
- package/dist/esm/schemas/typescript/index.js +29 -0
- package/dist/esm/schemas/typescript/index.js.map +1 -0
- package/dist/esm/scripts/updateGeneratedFiles.d.ts +2 -0
- package/dist/esm/scripts/updateGeneratedFiles.d.ts.map +1 -0
- package/dist/esm/scripts/updateGeneratedFiles.js +74 -0
- package/dist/esm/scripts/updateGeneratedFiles.js.map +1 -0
- package/dist/esm/src/generateJsonSchema.d.ts +3 -0
- package/dist/esm/src/generateJsonSchema.d.ts.map +1 -0
- package/dist/esm/src/generateJsonSchema.js +81 -0
- package/dist/esm/src/generateJsonSchema.js.map +1 -0
- package/dist/esm/src/generateJsonSchema.test.d.ts +2 -0
- package/dist/esm/src/generateJsonSchema.test.d.ts.map +1 -0
- package/dist/esm/src/generateJsonSchema.test.js +309 -0
- package/dist/esm/src/generateJsonSchema.test.js.map +1 -0
- package/dist/esm/src/generateProto.d.ts +3 -0
- package/dist/esm/src/generateProto.d.ts.map +1 -0
- package/dist/esm/src/generateProto.js +80 -0
- package/dist/esm/src/generateProto.js.map +1 -0
- package/dist/esm/src/generateProto.test.d.ts +2 -0
- package/dist/esm/src/generateProto.test.d.ts.map +1 -0
- package/dist/esm/src/generateProto.test.js +122 -0
- package/dist/esm/src/generateProto.test.js.map +1 -0
- package/dist/esm/src/generateRos.d.ts +20 -0
- package/dist/esm/src/generateRos.d.ts.map +1 -0
- package/dist/esm/src/generateRos.js +180 -0
- package/dist/esm/src/generateRos.js.map +1 -0
- package/dist/esm/src/generateRos.test.d.ts +2 -0
- package/dist/esm/src/generateRos.test.d.ts.map +1 -0
- package/dist/esm/src/generateRos.test.js +909 -0
- package/dist/esm/src/generateRos.test.js.map +1 -0
- package/dist/esm/src/generateTypeScript.d.ts +5 -0
- package/dist/esm/src/generateTypeScript.d.ts.map +1 -0
- package/dist/esm/src/generateTypeScript.js +96 -0
- package/dist/esm/src/generateTypeScript.js.map +1 -0
- package/dist/esm/src/generateTypeScript.test.d.ts +2 -0
- package/dist/esm/src/generateTypeScript.test.d.ts.map +1 -0
- package/dist/esm/src/generateTypeScript.test.js +117 -0
- package/dist/esm/src/generateTypeScript.test.js.map +1 -0
- package/dist/esm/src/index.d.ts +6 -0
- package/dist/esm/src/index.d.ts.map +1 -0
- package/dist/esm/src/index.js +6 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/schemas.d.ts +35 -0
- package/dist/esm/src/schemas.d.ts.map +1 -0
- package/dist/esm/src/schemas.js +817 -0
- package/dist/esm/src/schemas.js.map +1 -0
- package/dist/esm/src/schemas.test.d.ts +2 -0
- package/dist/esm/src/schemas.test.d.ts.map +1 -0
- package/dist/esm/src/schemas.test.js +22 -0
- package/dist/esm/src/schemas.test.js.map +1 -0
- package/dist/esm/src/testFixtures.d.ts +5 -0
- package/dist/esm/src/testFixtures.d.ts.map +1 -0
- package/dist/esm/src/testFixtures.js +83 -0
- package/dist/esm/src/testFixtures.js.map +1 -0
- package/dist/esm/src/types.d.ts +37 -0
- package/dist/esm/src/types.d.ts.map +1 -0
- package/dist/esm/src/types.js +2 -0
- package/dist/esm/src/types.js.map +1 -0
- package/jest.config.json +16 -0
- package/package.json +55 -0
- package/schemas/jsonschema/CameraCalibration.json +72 -0
- package/schemas/jsonschema/CircleAnnotation.json +96 -0
- package/schemas/jsonschema/Color.json +24 -0
- package/schemas/jsonschema/CompressedImage.json +33 -0
- package/schemas/jsonschema/FrameTransform.json +100 -0
- package/schemas/jsonschema/GeoJSON.json +12 -0
- package/schemas/jsonschema/Grid.json +179 -0
- package/schemas/jsonschema/ImageAnnotations.json +234 -0
- package/schemas/jsonschema/LaserScan.json +102 -0
- package/schemas/jsonschema/LocationFix.json +51 -0
- package/schemas/jsonschema/Log.json +71 -0
- package/schemas/jsonschema/PackedElementField.json +59 -0
- package/schemas/jsonschema/Point2.json +16 -0
- package/schemas/jsonschema/Point3.json +20 -0
- package/schemas/jsonschema/PointCloud.json +153 -0
- package/schemas/jsonschema/PointsAnnotation.json +122 -0
- package/schemas/jsonschema/Pose.json +52 -0
- package/schemas/jsonschema/PoseInFrame.json +80 -0
- package/schemas/jsonschema/PosesInFrame.json +84 -0
- package/schemas/jsonschema/Quaternion.json +24 -0
- package/schemas/jsonschema/RawImage.json +48 -0
- package/schemas/jsonschema/Transform.json +68 -0
- package/schemas/jsonschema/Vector2.json +16 -0
- package/schemas/jsonschema/Vector3.json +20 -0
- package/schemas/proto/foxglove/CameraCalibration.proto +70 -0
- package/schemas/proto/foxglove/CircleAnnotation.proto +30 -0
- package/schemas/proto/foxglove/Color.proto +20 -0
- package/schemas/proto/foxglove/CompressedImage.proto +19 -0
- package/schemas/proto/foxglove/FrameTransform.proto +23 -0
- package/schemas/proto/foxglove/GeoJSON.proto +11 -0
- package/schemas/proto/foxglove/Grid.proto +40 -0
- package/schemas/proto/foxglove/ImageAnnotations.proto +17 -0
- package/schemas/proto/foxglove/LaserScan.proto +32 -0
- package/schemas/proto/foxglove/LocationFix.proto +33 -0
- package/schemas/proto/foxglove/Log.proto +42 -0
- package/schemas/proto/foxglove/PackedElementField.proto +37 -0
- package/schemas/proto/foxglove/Point2.proto +14 -0
- package/schemas/proto/foxglove/Point3.proto +17 -0
- package/schemas/proto/foxglove/PointCloud.proto +30 -0
- package/schemas/proto/foxglove/PointsAnnotation.proto +39 -0
- package/schemas/proto/foxglove/Pose.proto +17 -0
- package/schemas/proto/foxglove/PoseInFrame.proto +20 -0
- package/schemas/proto/foxglove/PosesInFrame.proto +20 -0
- package/schemas/proto/foxglove/Quaternion.proto +20 -0
- package/schemas/proto/foxglove/RawImage.proto +28 -0
- package/schemas/proto/foxglove/Transform.proto +21 -0
- package/schemas/proto/foxglove/Vector2.proto +14 -0
- package/schemas/proto/foxglove/Vector3.proto +17 -0
- package/schemas/ros1/CameraCalibration.msg +61 -0
- package/schemas/ros1/CircleAnnotation.msg +19 -0
- package/schemas/ros1/Color.msg +13 -0
- package/schemas/ros1/CompressedImage.msg +10 -0
- package/schemas/ros1/FrameTransform.msg +13 -0
- package/schemas/ros1/GeoJSON.msg +4 -0
- package/schemas/ros1/Grid.msg +28 -0
- package/schemas/ros1/ImageAnnotations.msg +7 -0
- package/schemas/ros1/LaserScan.msg +22 -0
- package/schemas/ros1/LocationFix.msg +21 -0
- package/schemas/ros1/Log.msg +26 -0
- package/schemas/ros1/PackedElementField.msg +20 -0
- package/schemas/ros1/Point2.msg +7 -0
- package/schemas/ros1/PointCloud.msg +19 -0
- package/schemas/ros1/PointsAnnotation.msg +22 -0
- package/schemas/ros1/PoseInFrame.msg +10 -0
- package/schemas/ros1/PosesInFrame.msg +10 -0
- package/schemas/ros1/RawImage.msg +19 -0
- package/schemas/ros1/Transform.msg +10 -0
- package/schemas/ros1/Vector2.msg +7 -0
- package/schemas/ros2/CameraCalibration.msg +61 -0
- package/schemas/ros2/CircleAnnotation.msg +19 -0
- package/schemas/ros2/Color.msg +13 -0
- package/schemas/ros2/CompressedImage.msg +10 -0
- package/schemas/ros2/FrameTransform.msg +13 -0
- package/schemas/ros2/GeoJSON.msg +4 -0
- package/schemas/ros2/Grid.msg +28 -0
- package/schemas/ros2/ImageAnnotations.msg +7 -0
- package/schemas/ros2/LaserScan.msg +22 -0
- package/schemas/ros2/LocationFix.msg +21 -0
- package/schemas/ros2/Log.msg +26 -0
- package/schemas/ros2/PackedElementField.msg +20 -0
- package/schemas/ros2/Point2.msg +7 -0
- package/schemas/ros2/PointCloud.msg +19 -0
- package/schemas/ros2/PointsAnnotation.msg +22 -0
- package/schemas/ros2/PoseInFrame.msg +10 -0
- package/schemas/ros2/PosesInFrame.msg +10 -0
- package/schemas/ros2/RawImage.msg +19 -0
- package/schemas/ros2/Transform.msg +10 -0
- package/schemas/ros2/Vector2.msg +7 -0
- package/schemas/typescript/CameraCalibration.ts +72 -0
- package/schemas/typescript/CircleAnnotation.ts +26 -0
- package/schemas/typescript/Color.ts +16 -0
- package/schemas/typescript/CompressedImage.ts +15 -0
- package/schemas/typescript/Duration.ts +4 -0
- package/schemas/typescript/FrameTransform.ts +19 -0
- package/schemas/typescript/GeoJSON.ts +7 -0
- package/schemas/typescript/Grid.ts +36 -0
- package/schemas/typescript/ImageAnnotations.ts +13 -0
- package/schemas/typescript/LaserScan.ts +28 -0
- package/schemas/typescript/LocationFix.ts +21 -0
- package/schemas/typescript/Log.ts +25 -0
- package/schemas/typescript/LogLevel.ts +16 -0
- package/schemas/typescript/NumericType.ts +22 -0
- package/schemas/typescript/PackedElementField.ts +15 -0
- package/schemas/typescript/Point2.ts +10 -0
- package/schemas/typescript/Point3.ts +13 -0
- package/schemas/typescript/PointCloud.ts +26 -0
- package/schemas/typescript/PointsAnnotation.ts +24 -0
- package/schemas/typescript/PointsAnnotationType.ts +14 -0
- package/schemas/typescript/Pose.ts +13 -0
- package/schemas/typescript/PoseInFrame.ts +16 -0
- package/schemas/typescript/PosesInFrame.ts +16 -0
- package/schemas/typescript/PositionCovarianceType.ts +12 -0
- package/schemas/typescript/Quaternion.ts +16 -0
- package/schemas/typescript/RawImage.ts +24 -0
- package/schemas/typescript/Time.ts +4 -0
- package/schemas/typescript/Transform.ts +17 -0
- package/schemas/typescript/Vector2.ts +10 -0
- package/schemas/typescript/Vector3.ts +13 -0
- package/schemas/typescript/index.ts +28 -0
- package/scripts/updateGeneratedFiles.ts +103 -0
- package/src/generateJsonSchema.test.ts +314 -0
- package/src/generateJsonSchema.ts +82 -0
- package/src/generateProto.test.ts +126 -0
- package/src/generateProto.ts +97 -0
- package/src/generateRos.test.ts +931 -0
- package/src/generateRos.ts +219 -0
- package/src/generateTypeScript.test.ts +118 -0
- package/src/generateTypeScript.ts +106 -0
- package/src/index.ts +5 -0
- package/src/schemas.test.ts +23 -0
- package/src/schemas.ts +853 -0
- package/src/testFixtures.ts +90 -0
- package/src/types.ts +40 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Generated from Vector3 by @foxglove/schemas
|
|
2
|
+
|
|
3
|
+
/** A vector in 3D space that represents a direction only */
|
|
4
|
+
export type Vector3 = {
|
|
5
|
+
/** x coordinate length */
|
|
6
|
+
x: number;
|
|
7
|
+
|
|
8
|
+
/** y coordinate length */
|
|
9
|
+
y: number;
|
|
10
|
+
|
|
11
|
+
/** z coordinate length */
|
|
12
|
+
z: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from "./CameraCalibration";
|
|
2
|
+
export * from "./CircleAnnotation";
|
|
3
|
+
export * from "./Color";
|
|
4
|
+
export * from "./CompressedImage";
|
|
5
|
+
export * from "./FrameTransform";
|
|
6
|
+
export * from "./GeoJSON";
|
|
7
|
+
export * from "./Grid";
|
|
8
|
+
export * from "./ImageAnnotations";
|
|
9
|
+
export * from "./LaserScan";
|
|
10
|
+
export * from "./LocationFix";
|
|
11
|
+
export * from "./Log";
|
|
12
|
+
export * from "./LogLevel";
|
|
13
|
+
export * from "./NumericType";
|
|
14
|
+
export * from "./PackedElementField";
|
|
15
|
+
export * from "./Point2";
|
|
16
|
+
export * from "./Point3";
|
|
17
|
+
export * from "./PointCloud";
|
|
18
|
+
export * from "./PointsAnnotation";
|
|
19
|
+
export * from "./PointsAnnotationType";
|
|
20
|
+
export * from "./Pose";
|
|
21
|
+
export * from "./PoseInFrame";
|
|
22
|
+
export * from "./PosesInFrame";
|
|
23
|
+
export * from "./PositionCovarianceType";
|
|
24
|
+
export * from "./Quaternion";
|
|
25
|
+
export * from "./RawImage";
|
|
26
|
+
export * from "./Transform";
|
|
27
|
+
export * from "./Vector2";
|
|
28
|
+
export * from "./Vector3";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { program } from "commander";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import rimraf from "rimraf";
|
|
5
|
+
import { promisify } from "util";
|
|
6
|
+
|
|
7
|
+
import { generateRosMsg, generateRosMsgDefinition } from "../src";
|
|
8
|
+
import { generateJsonSchema } from "../src/generateJsonSchema";
|
|
9
|
+
import { generateProto } from "../src/generateProto";
|
|
10
|
+
import { generateTypeScript, DURATION_TS, TIME_TS } from "../src/generateTypeScript";
|
|
11
|
+
import { foxgloveEnumSchemas, foxgloveMessageSchemas } from "../src/schemas";
|
|
12
|
+
|
|
13
|
+
async function logProgress(message: string, body: () => Promise<void>) {
|
|
14
|
+
process.stderr.write(`${message}... `);
|
|
15
|
+
await body();
|
|
16
|
+
process.stderr.write("done\n");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function main({ outDir }: { outDir: string }) {
|
|
20
|
+
await logProgress("Removing any existing output directory", async () => {
|
|
21
|
+
await promisify(rimraf)(outDir);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await logProgress("Generating JSONSchema definitions", async () => {
|
|
25
|
+
await fs.mkdir(path.join(outDir, "jsonschema"), { recursive: true });
|
|
26
|
+
for (const schema of Object.values(foxgloveMessageSchemas)) {
|
|
27
|
+
await fs.writeFile(
|
|
28
|
+
path.join(outDir, "jsonschema", `${schema.name}.json`),
|
|
29
|
+
JSON.stringify(generateJsonSchema(schema), undefined, 2) + "\n",
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await logProgress("Generating ROS 1 msg files", async () => {
|
|
35
|
+
await fs.mkdir(path.join(outDir, "ros1"), { recursive: true });
|
|
36
|
+
for (const schema of Object.values(foxgloveMessageSchemas)) {
|
|
37
|
+
if (schema.rosEquivalent != undefined) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
await fs.writeFile(
|
|
41
|
+
path.join(outDir, "ros1", `${schema.name}.msg`),
|
|
42
|
+
generateRosMsg(generateRosMsgDefinition(schema, { rosVersion: 1 })),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
await logProgress("Generating ROS 2 msg files", async () => {
|
|
48
|
+
await fs.mkdir(path.join(outDir, "ros2"), { recursive: true });
|
|
49
|
+
for (const schema of Object.values(foxgloveMessageSchemas)) {
|
|
50
|
+
if (schema.rosEquivalent != undefined) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
await fs.writeFile(
|
|
54
|
+
path.join(outDir, "ros2", `${schema.name}.msg`),
|
|
55
|
+
generateRosMsg(generateRosMsgDefinition(schema, { rosVersion: 2 })),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
await logProgress("Generating Protobuf definitions", async () => {
|
|
61
|
+
await fs.mkdir(path.join(outDir, "proto", "foxglove"), { recursive: true });
|
|
62
|
+
for (const schema of Object.values(foxgloveMessageSchemas)) {
|
|
63
|
+
const enums = Object.values(foxgloveEnumSchemas).filter(
|
|
64
|
+
(enumSchema) => enumSchema.protobufParentMessageName === schema.name,
|
|
65
|
+
);
|
|
66
|
+
await fs.writeFile(
|
|
67
|
+
path.join(outDir, "proto", "foxglove", `${schema.name}.proto`),
|
|
68
|
+
generateProto(schema, enums),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
await logProgress("Generating TypeScript definitions", async () => {
|
|
74
|
+
await fs.mkdir(path.join(outDir, "typescript"), { recursive: true });
|
|
75
|
+
await fs.writeFile(path.join(outDir, "typescript", "Time.ts"), TIME_TS);
|
|
76
|
+
await fs.writeFile(path.join(outDir, "typescript", "Duration.ts"), DURATION_TS);
|
|
77
|
+
for (const schema of Object.values(foxgloveMessageSchemas)) {
|
|
78
|
+
await fs.writeFile(
|
|
79
|
+
path.join(outDir, "typescript", `${schema.name}.ts`),
|
|
80
|
+
generateTypeScript(schema),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
for (const schema of Object.values(foxgloveEnumSchemas)) {
|
|
84
|
+
await fs.writeFile(
|
|
85
|
+
path.join(outDir, "typescript", `${schema.name}.ts`),
|
|
86
|
+
generateTypeScript(schema),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const allSchemaNames = [
|
|
90
|
+
...Object.values(foxgloveMessageSchemas),
|
|
91
|
+
...Object.values(foxgloveEnumSchemas),
|
|
92
|
+
].sort((a, b) => a.name.localeCompare(b.name));
|
|
93
|
+
let indexTS = "";
|
|
94
|
+
for (const schema of allSchemaNames) {
|
|
95
|
+
indexTS += `export * from "./${schema.name}";\n`;
|
|
96
|
+
}
|
|
97
|
+
await fs.writeFile(path.join(outDir, "typescript", `index.ts`), indexTS);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
program.requiredOption("-o, --out-dir <dir>", "output directory").action(main);
|
|
102
|
+
|
|
103
|
+
program.parseAsync().catch(console.error);
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import Ajv from "ajv";
|
|
2
|
+
|
|
3
|
+
import { generateJsonSchema } from "./generateJsonSchema";
|
|
4
|
+
import { foxgloveMessageSchemas } from "./schemas";
|
|
5
|
+
import { exampleMessage } from "./testFixtures";
|
|
6
|
+
|
|
7
|
+
describe("generateJsonSchema", () => {
|
|
8
|
+
it("generates expected JSON Schema", () => {
|
|
9
|
+
expect(generateJsonSchema(exampleMessage)).toMatchInlineSnapshot(`
|
|
10
|
+
Object {
|
|
11
|
+
"$comment": "Generated from ExampleMessage by @foxglove/schemas",
|
|
12
|
+
"description": "An example type",
|
|
13
|
+
"properties": Object {
|
|
14
|
+
"field_boolean": Object {
|
|
15
|
+
"description": "boolean field",
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
},
|
|
18
|
+
"field_boolean_array": Object {
|
|
19
|
+
"description": "boolean array field",
|
|
20
|
+
"items": Object {
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
},
|
|
23
|
+
"type": "array",
|
|
24
|
+
},
|
|
25
|
+
"field_boolean_fixed_array": Object {
|
|
26
|
+
"description": "boolean fixed-length array field",
|
|
27
|
+
"items": Object {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
},
|
|
30
|
+
"maxItems": 3,
|
|
31
|
+
"minItems": 3,
|
|
32
|
+
"type": "array",
|
|
33
|
+
},
|
|
34
|
+
"field_bytes": Object {
|
|
35
|
+
"contentEncoding": "base64",
|
|
36
|
+
"description": "bytes field",
|
|
37
|
+
"type": "string",
|
|
38
|
+
},
|
|
39
|
+
"field_bytes_array": Object {
|
|
40
|
+
"description": "bytes array field",
|
|
41
|
+
"items": Object {
|
|
42
|
+
"contentEncoding": "base64",
|
|
43
|
+
"type": "string",
|
|
44
|
+
},
|
|
45
|
+
"type": "array",
|
|
46
|
+
},
|
|
47
|
+
"field_bytes_fixed_array": Object {
|
|
48
|
+
"description": "bytes fixed-length array field",
|
|
49
|
+
"items": Object {
|
|
50
|
+
"contentEncoding": "base64",
|
|
51
|
+
"type": "string",
|
|
52
|
+
},
|
|
53
|
+
"maxItems": 3,
|
|
54
|
+
"minItems": 3,
|
|
55
|
+
"type": "array",
|
|
56
|
+
},
|
|
57
|
+
"field_duration": Object {
|
|
58
|
+
"description": "duration field",
|
|
59
|
+
"properties": Object {
|
|
60
|
+
"nsec": Object {
|
|
61
|
+
"maximum": 999999999,
|
|
62
|
+
"minimum": 0,
|
|
63
|
+
"type": "integer",
|
|
64
|
+
},
|
|
65
|
+
"sec": Object {
|
|
66
|
+
"type": "integer",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
"title": "duration",
|
|
70
|
+
"type": "object",
|
|
71
|
+
},
|
|
72
|
+
"field_duration_array": Object {
|
|
73
|
+
"description": "duration array field",
|
|
74
|
+
"items": Object {
|
|
75
|
+
"properties": Object {
|
|
76
|
+
"nsec": Object {
|
|
77
|
+
"maximum": 999999999,
|
|
78
|
+
"minimum": 0,
|
|
79
|
+
"type": "integer",
|
|
80
|
+
},
|
|
81
|
+
"sec": Object {
|
|
82
|
+
"type": "integer",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
"title": "duration",
|
|
86
|
+
"type": "object",
|
|
87
|
+
},
|
|
88
|
+
"type": "array",
|
|
89
|
+
},
|
|
90
|
+
"field_duration_fixed_array": Object {
|
|
91
|
+
"description": "duration fixed-length array field",
|
|
92
|
+
"items": Object {
|
|
93
|
+
"properties": Object {
|
|
94
|
+
"nsec": Object {
|
|
95
|
+
"maximum": 999999999,
|
|
96
|
+
"minimum": 0,
|
|
97
|
+
"type": "integer",
|
|
98
|
+
},
|
|
99
|
+
"sec": Object {
|
|
100
|
+
"type": "integer",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
"title": "duration",
|
|
104
|
+
"type": "object",
|
|
105
|
+
},
|
|
106
|
+
"maxItems": 3,
|
|
107
|
+
"minItems": 3,
|
|
108
|
+
"type": "array",
|
|
109
|
+
},
|
|
110
|
+
"field_enum": Object {
|
|
111
|
+
"description": "An enum field",
|
|
112
|
+
"oneOf": Array [
|
|
113
|
+
Object {
|
|
114
|
+
"const": 1,
|
|
115
|
+
"description": "Value A",
|
|
116
|
+
"title": "A",
|
|
117
|
+
},
|
|
118
|
+
Object {
|
|
119
|
+
"const": 2,
|
|
120
|
+
"description": "Value B",
|
|
121
|
+
"title": "B",
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
"title": "ExampleEnum: An example enum",
|
|
125
|
+
},
|
|
126
|
+
"field_enum_array": Object {
|
|
127
|
+
"description": "An enum array field",
|
|
128
|
+
"items": Object {
|
|
129
|
+
"description": "An enum array field",
|
|
130
|
+
"oneOf": Array [
|
|
131
|
+
Object {
|
|
132
|
+
"const": 1,
|
|
133
|
+
"description": "Value A",
|
|
134
|
+
"title": "A",
|
|
135
|
+
},
|
|
136
|
+
Object {
|
|
137
|
+
"const": 2,
|
|
138
|
+
"description": "Value B",
|
|
139
|
+
"title": "B",
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
"title": "ExampleEnum: An example enum",
|
|
143
|
+
},
|
|
144
|
+
"type": "array",
|
|
145
|
+
},
|
|
146
|
+
"field_float64": Object {
|
|
147
|
+
"description": "float64 field",
|
|
148
|
+
"type": "number",
|
|
149
|
+
},
|
|
150
|
+
"field_float64_array": Object {
|
|
151
|
+
"description": "float64 array field",
|
|
152
|
+
"items": Object {
|
|
153
|
+
"type": "number",
|
|
154
|
+
},
|
|
155
|
+
"type": "array",
|
|
156
|
+
},
|
|
157
|
+
"field_float64_fixed_array": Object {
|
|
158
|
+
"description": "float64 fixed-length array field",
|
|
159
|
+
"items": Object {
|
|
160
|
+
"type": "number",
|
|
161
|
+
},
|
|
162
|
+
"maxItems": 3,
|
|
163
|
+
"minItems": 3,
|
|
164
|
+
"type": "array",
|
|
165
|
+
},
|
|
166
|
+
"field_nested": Object {
|
|
167
|
+
"$comment": "Generated from NestedMessage by @foxglove/schemas",
|
|
168
|
+
"description": "A nested field",
|
|
169
|
+
"properties": Object {
|
|
170
|
+
"field_enum": Object {
|
|
171
|
+
"description": "An enum field",
|
|
172
|
+
"minimum": 0,
|
|
173
|
+
"type": "integer",
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
"title": "NestedMessage",
|
|
177
|
+
"type": "object",
|
|
178
|
+
},
|
|
179
|
+
"field_nested_array": Object {
|
|
180
|
+
"description": "A nested array field
|
|
181
|
+
With
|
|
182
|
+
a
|
|
183
|
+
very
|
|
184
|
+
long
|
|
185
|
+
description",
|
|
186
|
+
"items": Object {
|
|
187
|
+
"$comment": "Generated from NestedMessage by @foxglove/schemas",
|
|
188
|
+
"description": "An example nested message",
|
|
189
|
+
"properties": Object {
|
|
190
|
+
"field_enum": Object {
|
|
191
|
+
"description": "An enum field",
|
|
192
|
+
"minimum": 0,
|
|
193
|
+
"type": "integer",
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
"title": "NestedMessage",
|
|
197
|
+
"type": "object",
|
|
198
|
+
},
|
|
199
|
+
"type": "array",
|
|
200
|
+
},
|
|
201
|
+
"field_string": Object {
|
|
202
|
+
"description": "string field",
|
|
203
|
+
"type": "string",
|
|
204
|
+
},
|
|
205
|
+
"field_string_array": Object {
|
|
206
|
+
"description": "string array field",
|
|
207
|
+
"items": Object {
|
|
208
|
+
"type": "string",
|
|
209
|
+
},
|
|
210
|
+
"type": "array",
|
|
211
|
+
},
|
|
212
|
+
"field_string_fixed_array": Object {
|
|
213
|
+
"description": "string fixed-length array field",
|
|
214
|
+
"items": Object {
|
|
215
|
+
"type": "string",
|
|
216
|
+
},
|
|
217
|
+
"maxItems": 3,
|
|
218
|
+
"minItems": 3,
|
|
219
|
+
"type": "array",
|
|
220
|
+
},
|
|
221
|
+
"field_time": Object {
|
|
222
|
+
"description": "time field",
|
|
223
|
+
"properties": Object {
|
|
224
|
+
"nsec": Object {
|
|
225
|
+
"maximum": 999999999,
|
|
226
|
+
"minimum": 0,
|
|
227
|
+
"type": "integer",
|
|
228
|
+
},
|
|
229
|
+
"sec": Object {
|
|
230
|
+
"minimum": 0,
|
|
231
|
+
"type": "integer",
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
"title": "time",
|
|
235
|
+
"type": "object",
|
|
236
|
+
},
|
|
237
|
+
"field_time_array": Object {
|
|
238
|
+
"description": "time array field",
|
|
239
|
+
"items": Object {
|
|
240
|
+
"properties": Object {
|
|
241
|
+
"nsec": Object {
|
|
242
|
+
"maximum": 999999999,
|
|
243
|
+
"minimum": 0,
|
|
244
|
+
"type": "integer",
|
|
245
|
+
},
|
|
246
|
+
"sec": Object {
|
|
247
|
+
"minimum": 0,
|
|
248
|
+
"type": "integer",
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
"title": "time",
|
|
252
|
+
"type": "object",
|
|
253
|
+
},
|
|
254
|
+
"type": "array",
|
|
255
|
+
},
|
|
256
|
+
"field_time_fixed_array": Object {
|
|
257
|
+
"description": "time fixed-length array field",
|
|
258
|
+
"items": Object {
|
|
259
|
+
"properties": Object {
|
|
260
|
+
"nsec": Object {
|
|
261
|
+
"maximum": 999999999,
|
|
262
|
+
"minimum": 0,
|
|
263
|
+
"type": "integer",
|
|
264
|
+
},
|
|
265
|
+
"sec": Object {
|
|
266
|
+
"minimum": 0,
|
|
267
|
+
"type": "integer",
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
"title": "time",
|
|
271
|
+
"type": "object",
|
|
272
|
+
},
|
|
273
|
+
"maxItems": 3,
|
|
274
|
+
"minItems": 3,
|
|
275
|
+
"type": "array",
|
|
276
|
+
},
|
|
277
|
+
"field_uint32": Object {
|
|
278
|
+
"description": "uint32 field",
|
|
279
|
+
"minimum": 0,
|
|
280
|
+
"type": "integer",
|
|
281
|
+
},
|
|
282
|
+
"field_uint32_array": Object {
|
|
283
|
+
"description": "uint32 array field",
|
|
284
|
+
"items": Object {
|
|
285
|
+
"minimum": 0,
|
|
286
|
+
"type": "integer",
|
|
287
|
+
},
|
|
288
|
+
"type": "array",
|
|
289
|
+
},
|
|
290
|
+
"field_uint32_fixed_array": Object {
|
|
291
|
+
"description": "uint32 fixed-length array field",
|
|
292
|
+
"items": Object {
|
|
293
|
+
"minimum": 0,
|
|
294
|
+
"type": "integer",
|
|
295
|
+
},
|
|
296
|
+
"maxItems": 3,
|
|
297
|
+
"minItems": 3,
|
|
298
|
+
"type": "array",
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
"title": "ExampleMessage",
|
|
302
|
+
"type": "object",
|
|
303
|
+
}
|
|
304
|
+
`);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it.each(Object.values(foxgloveMessageSchemas))(
|
|
308
|
+
"generates parseable JSON Schema for $name",
|
|
309
|
+
(schema) => {
|
|
310
|
+
const ajv = new Ajv();
|
|
311
|
+
expect(() => ajv.compile(generateJsonSchema(schema))).not.toThrow();
|
|
312
|
+
},
|
|
313
|
+
);
|
|
314
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { FoxgloveMessageSchema, FoxglovePrimitive } from "./types";
|
|
2
|
+
|
|
3
|
+
function primitiveToJsonSchema(type: Exclude<FoxglovePrimitive, "bytes">) {
|
|
4
|
+
switch (type) {
|
|
5
|
+
case "string":
|
|
6
|
+
return { type: "string" };
|
|
7
|
+
case "boolean":
|
|
8
|
+
return { type: "boolean" };
|
|
9
|
+
case "float64":
|
|
10
|
+
return { type: "number" };
|
|
11
|
+
case "uint32":
|
|
12
|
+
return { type: "integer", minimum: 0 };
|
|
13
|
+
case "time":
|
|
14
|
+
return {
|
|
15
|
+
type: "object",
|
|
16
|
+
title: "time",
|
|
17
|
+
properties: {
|
|
18
|
+
sec: { type: "integer", minimum: 0 },
|
|
19
|
+
nsec: { type: "integer", minimum: 0, maximum: 999_999_999 },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
case "duration":
|
|
23
|
+
return {
|
|
24
|
+
type: "object",
|
|
25
|
+
title: "duration",
|
|
26
|
+
properties: {
|
|
27
|
+
sec: { type: "integer" },
|
|
28
|
+
nsec: { type: "integer", minimum: 0, maximum: 999_999_999 },
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function generateJsonSchema(schema: FoxgloveMessageSchema): Record<string, unknown> {
|
|
35
|
+
const properties: Record<string, unknown> = {};
|
|
36
|
+
for (const field of schema.fields) {
|
|
37
|
+
let fieldType: Record<string, unknown>;
|
|
38
|
+
switch (field.type.type) {
|
|
39
|
+
case "primitive":
|
|
40
|
+
if (field.type.name === "bytes") {
|
|
41
|
+
fieldType = { type: "string", contentEncoding: "base64" };
|
|
42
|
+
} else {
|
|
43
|
+
fieldType = primitiveToJsonSchema(field.type.name);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case "nested":
|
|
47
|
+
fieldType = generateJsonSchema(field.type.schema);
|
|
48
|
+
break;
|
|
49
|
+
case "enum":
|
|
50
|
+
fieldType = {
|
|
51
|
+
title: `${field.type.enum.name}: ${field.type.enum.description}`,
|
|
52
|
+
description: field.description,
|
|
53
|
+
oneOf: field.type.enum.values.map(({ name, value, description }) => ({
|
|
54
|
+
title: name,
|
|
55
|
+
const: value,
|
|
56
|
+
description,
|
|
57
|
+
})),
|
|
58
|
+
};
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
if (typeof field.array === "number") {
|
|
62
|
+
fieldType = {
|
|
63
|
+
type: "array",
|
|
64
|
+
items: fieldType,
|
|
65
|
+
minItems: field.array,
|
|
66
|
+
maxItems: field.array,
|
|
67
|
+
};
|
|
68
|
+
} else if (field.array === true) {
|
|
69
|
+
fieldType = { type: "array", items: fieldType };
|
|
70
|
+
}
|
|
71
|
+
fieldType.description = field.description;
|
|
72
|
+
properties[field.name] = fieldType;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
$comment: `Generated from ${schema.name} by @foxglove/schemas`,
|
|
77
|
+
title: schema.name,
|
|
78
|
+
description: schema.description,
|
|
79
|
+
type: "object",
|
|
80
|
+
properties,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import protobufjs from "protobufjs";
|
|
2
|
+
|
|
3
|
+
import { generateProto } from "./generateProto";
|
|
4
|
+
import { foxgloveEnumSchemas, foxgloveMessageSchemas } from "./schemas";
|
|
5
|
+
import { exampleEnum, exampleMessage } from "./testFixtures";
|
|
6
|
+
|
|
7
|
+
describe("generateProto", () => {
|
|
8
|
+
it("generates .proto files", () => {
|
|
9
|
+
expect(generateProto(exampleMessage, [exampleEnum])).toMatchInlineSnapshot(`
|
|
10
|
+
"// Generated from ExampleMessage by @foxglove/schemas
|
|
11
|
+
|
|
12
|
+
syntax = \\"proto3\\";
|
|
13
|
+
|
|
14
|
+
import \\"foxglove/NestedMessage.proto\\";
|
|
15
|
+
import \\"google/protobuf/duration.proto\\";
|
|
16
|
+
import \\"google/protobuf/timestamp.proto\\";
|
|
17
|
+
|
|
18
|
+
package foxglove;
|
|
19
|
+
|
|
20
|
+
// An example type
|
|
21
|
+
message ExampleMessage {
|
|
22
|
+
// An example enum
|
|
23
|
+
enum ExampleProtoEnum {
|
|
24
|
+
// Value A
|
|
25
|
+
A = 1;
|
|
26
|
+
|
|
27
|
+
// Value B
|
|
28
|
+
B = 2;
|
|
29
|
+
}
|
|
30
|
+
// duration field
|
|
31
|
+
google.protobuf.Duration field_duration = 1;
|
|
32
|
+
|
|
33
|
+
// time field
|
|
34
|
+
google.protobuf.Timestamp field_time = 2;
|
|
35
|
+
|
|
36
|
+
// boolean field
|
|
37
|
+
bool field_boolean = 3;
|
|
38
|
+
|
|
39
|
+
// bytes field
|
|
40
|
+
bytes field_bytes = 4;
|
|
41
|
+
|
|
42
|
+
// float64 field
|
|
43
|
+
double field_float64 = 5;
|
|
44
|
+
|
|
45
|
+
// uint32 field
|
|
46
|
+
fixed32 field_uint32 = 6;
|
|
47
|
+
|
|
48
|
+
// string field
|
|
49
|
+
string field_string = 7;
|
|
50
|
+
|
|
51
|
+
// duration array field
|
|
52
|
+
repeated google.protobuf.Duration field_duration_array = 8;
|
|
53
|
+
|
|
54
|
+
// time array field
|
|
55
|
+
repeated google.protobuf.Timestamp field_time_array = 9;
|
|
56
|
+
|
|
57
|
+
// boolean array field
|
|
58
|
+
repeated bool field_boolean_array = 10;
|
|
59
|
+
|
|
60
|
+
// bytes array field
|
|
61
|
+
repeated bytes field_bytes_array = 11;
|
|
62
|
+
|
|
63
|
+
// float64 array field
|
|
64
|
+
repeated double field_float64_array = 12;
|
|
65
|
+
|
|
66
|
+
// uint32 array field
|
|
67
|
+
repeated fixed32 field_uint32_array = 13;
|
|
68
|
+
|
|
69
|
+
// string array field
|
|
70
|
+
repeated string field_string_array = 14;
|
|
71
|
+
|
|
72
|
+
// duration fixed-length array field
|
|
73
|
+
repeated google.protobuf.Duration field_duration_fixed_array = 15; // length 3
|
|
74
|
+
|
|
75
|
+
// time fixed-length array field
|
|
76
|
+
repeated google.protobuf.Timestamp field_time_fixed_array = 16; // length 3
|
|
77
|
+
|
|
78
|
+
// boolean fixed-length array field
|
|
79
|
+
repeated bool field_boolean_fixed_array = 17; // length 3
|
|
80
|
+
|
|
81
|
+
// bytes fixed-length array field
|
|
82
|
+
repeated bytes field_bytes_fixed_array = 18; // length 3
|
|
83
|
+
|
|
84
|
+
// float64 fixed-length array field
|
|
85
|
+
repeated double field_float64_fixed_array = 19; // length 3
|
|
86
|
+
|
|
87
|
+
// uint32 fixed-length array field
|
|
88
|
+
repeated fixed32 field_uint32_fixed_array = 20; // length 3
|
|
89
|
+
|
|
90
|
+
// string fixed-length array field
|
|
91
|
+
repeated string field_string_fixed_array = 21; // length 3
|
|
92
|
+
|
|
93
|
+
// An enum field
|
|
94
|
+
ExampleProtoEnum field_enum = 22;
|
|
95
|
+
|
|
96
|
+
// An enum array field
|
|
97
|
+
repeated ExampleProtoEnum field_enum_array = 23;
|
|
98
|
+
|
|
99
|
+
// A nested field
|
|
100
|
+
foxglove.NestedMessage field_nested = 24;
|
|
101
|
+
|
|
102
|
+
// A nested array field
|
|
103
|
+
// With
|
|
104
|
+
// a
|
|
105
|
+
// very
|
|
106
|
+
// long
|
|
107
|
+
// description
|
|
108
|
+
repeated foxglove.NestedMessage field_nested_array = 25;
|
|
109
|
+
}
|
|
110
|
+
"
|
|
111
|
+
`);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("generates parseable .proto files", () => {
|
|
115
|
+
const root = new protobufjs.Root();
|
|
116
|
+
root.addJSON(protobufjs.common.get("google/protobuf/timestamp.proto")!.nested!);
|
|
117
|
+
root.addJSON(protobufjs.common.get("google/protobuf/duration.proto")!.nested!);
|
|
118
|
+
for (const schema of Object.values(foxgloveMessageSchemas)) {
|
|
119
|
+
const enums = Object.values(foxgloveEnumSchemas).filter(
|
|
120
|
+
(enumSchema) => enumSchema.protobufParentMessageName === schema.name,
|
|
121
|
+
);
|
|
122
|
+
root.add(protobufjs.parse(generateProto(schema, enums)).root);
|
|
123
|
+
}
|
|
124
|
+
expect(() => root.resolveAll()).not.toThrow();
|
|
125
|
+
});
|
|
126
|
+
});
|