@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.
Files changed (506) hide show
  1. package/.eslintrc.js +19 -0
  2. package/.gitattributes +1 -0
  3. package/.github/workflows/ci.yml +89 -0
  4. package/.prettierignore +1 -0
  5. package/.prettierrc.yml +2 -0
  6. package/.vscode/launch.json +23 -0
  7. package/.vscode/settings.json +20 -0
  8. package/LICENSE.md +21 -0
  9. package/README.md +31 -0
  10. package/dist/cjs/schemas/typescript/CameraCalibration.d.ts +63 -0
  11. package/dist/cjs/schemas/typescript/CameraCalibration.d.ts.map +1 -0
  12. package/dist/cjs/schemas/typescript/CameraCalibration.js +4 -0
  13. package/dist/cjs/schemas/typescript/CameraCalibration.js.map +1 -0
  14. package/dist/cjs/schemas/typescript/CircleAnnotation.d.ts +19 -0
  15. package/dist/cjs/schemas/typescript/CircleAnnotation.d.ts.map +1 -0
  16. package/dist/cjs/schemas/typescript/CircleAnnotation.js +4 -0
  17. package/dist/cjs/schemas/typescript/CircleAnnotation.js.map +1 -0
  18. package/dist/cjs/schemas/typescript/Color.d.ts +12 -0
  19. package/dist/cjs/schemas/typescript/Color.d.ts.map +1 -0
  20. package/dist/cjs/schemas/typescript/Color.js +4 -0
  21. package/dist/cjs/schemas/typescript/Color.js.map +1 -0
  22. package/dist/cjs/schemas/typescript/CompressedImage.d.ts +11 -0
  23. package/dist/cjs/schemas/typescript/CompressedImage.d.ts.map +1 -0
  24. package/dist/cjs/schemas/typescript/CompressedImage.js +4 -0
  25. package/dist/cjs/schemas/typescript/CompressedImage.js.map +1 -0
  26. package/dist/cjs/schemas/typescript/Duration.d.ts +5 -0
  27. package/dist/cjs/schemas/typescript/Duration.d.ts.map +1 -0
  28. package/dist/cjs/schemas/typescript/Duration.js +3 -0
  29. package/dist/cjs/schemas/typescript/Duration.js.map +1 -0
  30. package/dist/cjs/schemas/typescript/FrameTransform.d.ts +14 -0
  31. package/dist/cjs/schemas/typescript/FrameTransform.d.ts.map +1 -0
  32. package/dist/cjs/schemas/typescript/FrameTransform.js +4 -0
  33. package/dist/cjs/schemas/typescript/FrameTransform.js.map +1 -0
  34. package/dist/cjs/schemas/typescript/GeoJSON.d.ts +6 -0
  35. package/dist/cjs/schemas/typescript/GeoJSON.d.ts.map +1 -0
  36. package/dist/cjs/schemas/typescript/GeoJSON.js +4 -0
  37. package/dist/cjs/schemas/typescript/GeoJSON.js.map +1 -0
  38. package/dist/cjs/schemas/typescript/Grid.d.ts +26 -0
  39. package/dist/cjs/schemas/typescript/Grid.d.ts.map +1 -0
  40. package/dist/cjs/schemas/typescript/Grid.js +4 -0
  41. package/dist/cjs/schemas/typescript/Grid.js.map +1 -0
  42. package/dist/cjs/schemas/typescript/ImageAnnotations.d.ts +10 -0
  43. package/dist/cjs/schemas/typescript/ImageAnnotations.d.ts.map +1 -0
  44. package/dist/cjs/schemas/typescript/ImageAnnotations.js +4 -0
  45. package/dist/cjs/schemas/typescript/ImageAnnotations.js.map +1 -0
  46. package/dist/cjs/schemas/typescript/LaserScan.d.ts +20 -0
  47. package/dist/cjs/schemas/typescript/LaserScan.d.ts.map +1 -0
  48. package/dist/cjs/schemas/typescript/LaserScan.js +4 -0
  49. package/dist/cjs/schemas/typescript/LaserScan.js.map +1 -0
  50. package/dist/cjs/schemas/typescript/LocationFix.d.ts +15 -0
  51. package/dist/cjs/schemas/typescript/LocationFix.d.ts.map +1 -0
  52. package/dist/cjs/schemas/typescript/LocationFix.js +4 -0
  53. package/dist/cjs/schemas/typescript/LocationFix.js.map +1 -0
  54. package/dist/cjs/schemas/typescript/Log.d.ts +18 -0
  55. package/dist/cjs/schemas/typescript/Log.d.ts.map +1 -0
  56. package/dist/cjs/schemas/typescript/Log.js +4 -0
  57. package/dist/cjs/schemas/typescript/Log.js.map +1 -0
  58. package/dist/cjs/schemas/typescript/LogLevel.d.ts +10 -0
  59. package/dist/cjs/schemas/typescript/LogLevel.d.ts.map +1 -0
  60. package/dist/cjs/schemas/typescript/LogLevel.js +15 -0
  61. package/dist/cjs/schemas/typescript/LogLevel.js.map +1 -0
  62. package/dist/cjs/schemas/typescript/NumericType.d.ts +13 -0
  63. package/dist/cjs/schemas/typescript/NumericType.d.ts.map +1 -0
  64. package/dist/cjs/schemas/typescript/NumericType.js +18 -0
  65. package/dist/cjs/schemas/typescript/NumericType.js.map +1 -0
  66. package/dist/cjs/schemas/typescript/PackedElementField.d.ts +11 -0
  67. package/dist/cjs/schemas/typescript/PackedElementField.d.ts.map +1 -0
  68. package/dist/cjs/schemas/typescript/PackedElementField.js +4 -0
  69. package/dist/cjs/schemas/typescript/PackedElementField.js.map +1 -0
  70. package/dist/cjs/schemas/typescript/Point2.d.ts +8 -0
  71. package/dist/cjs/schemas/typescript/Point2.d.ts.map +1 -0
  72. package/dist/cjs/schemas/typescript/Point2.js +4 -0
  73. package/dist/cjs/schemas/typescript/Point2.js.map +1 -0
  74. package/dist/cjs/schemas/typescript/Point3.d.ts +10 -0
  75. package/dist/cjs/schemas/typescript/Point3.d.ts.map +1 -0
  76. package/dist/cjs/schemas/typescript/Point3.js +4 -0
  77. package/dist/cjs/schemas/typescript/Point3.js.map +1 -0
  78. package/dist/cjs/schemas/typescript/PointCloud.d.ts +19 -0
  79. package/dist/cjs/schemas/typescript/PointCloud.d.ts.map +1 -0
  80. package/dist/cjs/schemas/typescript/PointCloud.js +4 -0
  81. package/dist/cjs/schemas/typescript/PointCloud.js.map +1 -0
  82. package/dist/cjs/schemas/typescript/PointsAnnotation.d.ts +18 -0
  83. package/dist/cjs/schemas/typescript/PointsAnnotation.d.ts.map +1 -0
  84. package/dist/cjs/schemas/typescript/PointsAnnotation.js +4 -0
  85. package/dist/cjs/schemas/typescript/PointsAnnotation.js.map +1 -0
  86. package/dist/cjs/schemas/typescript/PointsAnnotationType.d.ts +9 -0
  87. package/dist/cjs/schemas/typescript/PointsAnnotationType.d.ts.map +1 -0
  88. package/dist/cjs/schemas/typescript/PointsAnnotationType.js +14 -0
  89. package/dist/cjs/schemas/typescript/PointsAnnotationType.js.map +1 -0
  90. package/dist/cjs/schemas/typescript/Pose.d.ts +10 -0
  91. package/dist/cjs/schemas/typescript/Pose.d.ts.map +1 -0
  92. package/dist/cjs/schemas/typescript/Pose.js +4 -0
  93. package/dist/cjs/schemas/typescript/Pose.js.map +1 -0
  94. package/dist/cjs/schemas/typescript/PoseInFrame.d.ts +12 -0
  95. package/dist/cjs/schemas/typescript/PoseInFrame.d.ts.map +1 -0
  96. package/dist/cjs/schemas/typescript/PoseInFrame.js +4 -0
  97. package/dist/cjs/schemas/typescript/PoseInFrame.js.map +1 -0
  98. package/dist/cjs/schemas/typescript/PosesInFrame.d.ts +12 -0
  99. package/dist/cjs/schemas/typescript/PosesInFrame.d.ts.map +1 -0
  100. package/dist/cjs/schemas/typescript/PosesInFrame.js +4 -0
  101. package/dist/cjs/schemas/typescript/PosesInFrame.js.map +1 -0
  102. package/dist/cjs/schemas/typescript/PositionCovarianceType.d.ts +8 -0
  103. package/dist/cjs/schemas/typescript/PositionCovarianceType.d.ts.map +1 -0
  104. package/dist/cjs/schemas/typescript/PositionCovarianceType.js +13 -0
  105. package/dist/cjs/schemas/typescript/PositionCovarianceType.js.map +1 -0
  106. package/dist/cjs/schemas/typescript/Quaternion.d.ts +12 -0
  107. package/dist/cjs/schemas/typescript/Quaternion.d.ts.map +1 -0
  108. package/dist/cjs/schemas/typescript/Quaternion.js +4 -0
  109. package/dist/cjs/schemas/typescript/Quaternion.js.map +1 -0
  110. package/dist/cjs/schemas/typescript/RawImage.d.ts +17 -0
  111. package/dist/cjs/schemas/typescript/RawImage.d.ts.map +1 -0
  112. package/dist/cjs/schemas/typescript/RawImage.js +4 -0
  113. package/dist/cjs/schemas/typescript/RawImage.js.map +1 -0
  114. package/dist/cjs/schemas/typescript/Time.d.ts +5 -0
  115. package/dist/cjs/schemas/typescript/Time.d.ts.map +1 -0
  116. package/dist/cjs/schemas/typescript/Time.js +3 -0
  117. package/dist/cjs/schemas/typescript/Time.js.map +1 -0
  118. package/dist/cjs/schemas/typescript/Transform.d.ts +13 -0
  119. package/dist/cjs/schemas/typescript/Transform.d.ts.map +1 -0
  120. package/dist/cjs/schemas/typescript/Transform.js +4 -0
  121. package/dist/cjs/schemas/typescript/Transform.js.map +1 -0
  122. package/dist/cjs/schemas/typescript/Vector2.d.ts +8 -0
  123. package/dist/cjs/schemas/typescript/Vector2.d.ts.map +1 -0
  124. package/dist/cjs/schemas/typescript/Vector2.js +4 -0
  125. package/dist/cjs/schemas/typescript/Vector2.js.map +1 -0
  126. package/dist/cjs/schemas/typescript/Vector3.d.ts +10 -0
  127. package/dist/cjs/schemas/typescript/Vector3.d.ts.map +1 -0
  128. package/dist/cjs/schemas/typescript/Vector3.js +4 -0
  129. package/dist/cjs/schemas/typescript/Vector3.js.map +1 -0
  130. package/dist/cjs/schemas/typescript/index.d.ts +29 -0
  131. package/dist/cjs/schemas/typescript/index.d.ts.map +1 -0
  132. package/dist/cjs/schemas/typescript/index.js +32 -0
  133. package/dist/cjs/schemas/typescript/index.js.map +1 -0
  134. package/dist/cjs/scripts/updateGeneratedFiles.d.ts +2 -0
  135. package/dist/cjs/scripts/updateGeneratedFiles.d.ts.map +1 -0
  136. package/dist/cjs/scripts/updateGeneratedFiles.js +77 -0
  137. package/dist/cjs/scripts/updateGeneratedFiles.js.map +1 -0
  138. package/dist/cjs/src/generateJsonSchema.d.ts +3 -0
  139. package/dist/cjs/src/generateJsonSchema.d.ts.map +1 -0
  140. package/dist/cjs/src/generateJsonSchema.js +85 -0
  141. package/dist/cjs/src/generateJsonSchema.js.map +1 -0
  142. package/dist/cjs/src/generateJsonSchema.test.d.ts +2 -0
  143. package/dist/cjs/src/generateJsonSchema.test.d.ts.map +1 -0
  144. package/dist/cjs/src/generateJsonSchema.test.js +312 -0
  145. package/dist/cjs/src/generateJsonSchema.test.js.map +1 -0
  146. package/dist/cjs/src/generateProto.d.ts +3 -0
  147. package/dist/cjs/src/generateProto.d.ts.map +1 -0
  148. package/dist/cjs/src/generateProto.js +84 -0
  149. package/dist/cjs/src/generateProto.js.map +1 -0
  150. package/dist/cjs/src/generateProto.test.d.ts +2 -0
  151. package/dist/cjs/src/generateProto.test.d.ts.map +1 -0
  152. package/dist/cjs/src/generateProto.test.js +125 -0
  153. package/dist/cjs/src/generateProto.test.js.map +1 -0
  154. package/dist/cjs/src/generateRos.d.ts +20 -0
  155. package/dist/cjs/src/generateRos.d.ts.map +1 -0
  156. package/dist/cjs/src/generateRos.js +186 -0
  157. package/dist/cjs/src/generateRos.js.map +1 -0
  158. package/dist/cjs/src/generateRos.test.d.ts +2 -0
  159. package/dist/cjs/src/generateRos.test.d.ts.map +1 -0
  160. package/dist/cjs/src/generateRos.test.js +911 -0
  161. package/dist/cjs/src/generateRos.test.js.map +1 -0
  162. package/dist/cjs/src/generateTypeScript.d.ts +5 -0
  163. package/dist/cjs/src/generateTypeScript.d.ts.map +1 -0
  164. package/dist/cjs/src/generateTypeScript.js +100 -0
  165. package/dist/cjs/src/generateTypeScript.js.map +1 -0
  166. package/dist/cjs/src/generateTypeScript.test.d.ts +2 -0
  167. package/dist/cjs/src/generateTypeScript.test.d.ts.map +1 -0
  168. package/dist/cjs/src/generateTypeScript.test.js +142 -0
  169. package/dist/cjs/src/generateTypeScript.test.js.map +1 -0
  170. package/dist/cjs/src/index.d.ts +6 -0
  171. package/dist/cjs/src/index.d.ts.map +1 -0
  172. package/dist/cjs/src/index.js +9 -0
  173. package/dist/cjs/src/index.js.map +1 -0
  174. package/dist/cjs/src/schemas.d.ts +35 -0
  175. package/dist/cjs/src/schemas.d.ts.map +1 -0
  176. package/dist/cjs/src/schemas.js +820 -0
  177. package/dist/cjs/src/schemas.js.map +1 -0
  178. package/dist/cjs/src/schemas.test.d.ts +2 -0
  179. package/dist/cjs/src/schemas.test.d.ts.map +1 -0
  180. package/dist/cjs/src/schemas.test.js +24 -0
  181. package/dist/cjs/src/schemas.test.js.map +1 -0
  182. package/dist/cjs/src/testFixtures.d.ts +5 -0
  183. package/dist/cjs/src/testFixtures.d.ts.map +1 -0
  184. package/dist/cjs/src/testFixtures.js +86 -0
  185. package/dist/cjs/src/testFixtures.js.map +1 -0
  186. package/dist/cjs/src/types.d.ts +37 -0
  187. package/dist/cjs/src/types.d.ts.map +1 -0
  188. package/dist/cjs/src/types.js +3 -0
  189. package/dist/cjs/src/types.js.map +1 -0
  190. package/dist/esm/schemas/typescript/CameraCalibration.d.ts +63 -0
  191. package/dist/esm/schemas/typescript/CameraCalibration.d.ts.map +1 -0
  192. package/dist/esm/schemas/typescript/CameraCalibration.js +3 -0
  193. package/dist/esm/schemas/typescript/CameraCalibration.js.map +1 -0
  194. package/dist/esm/schemas/typescript/CircleAnnotation.d.ts +19 -0
  195. package/dist/esm/schemas/typescript/CircleAnnotation.d.ts.map +1 -0
  196. package/dist/esm/schemas/typescript/CircleAnnotation.js +3 -0
  197. package/dist/esm/schemas/typescript/CircleAnnotation.js.map +1 -0
  198. package/dist/esm/schemas/typescript/Color.d.ts +12 -0
  199. package/dist/esm/schemas/typescript/Color.d.ts.map +1 -0
  200. package/dist/esm/schemas/typescript/Color.js +3 -0
  201. package/dist/esm/schemas/typescript/Color.js.map +1 -0
  202. package/dist/esm/schemas/typescript/CompressedImage.d.ts +11 -0
  203. package/dist/esm/schemas/typescript/CompressedImage.d.ts.map +1 -0
  204. package/dist/esm/schemas/typescript/CompressedImage.js +3 -0
  205. package/dist/esm/schemas/typescript/CompressedImage.js.map +1 -0
  206. package/dist/esm/schemas/typescript/Duration.d.ts +5 -0
  207. package/dist/esm/schemas/typescript/Duration.d.ts.map +1 -0
  208. package/dist/esm/schemas/typescript/Duration.js +2 -0
  209. package/dist/esm/schemas/typescript/Duration.js.map +1 -0
  210. package/dist/esm/schemas/typescript/FrameTransform.d.ts +14 -0
  211. package/dist/esm/schemas/typescript/FrameTransform.d.ts.map +1 -0
  212. package/dist/esm/schemas/typescript/FrameTransform.js +3 -0
  213. package/dist/esm/schemas/typescript/FrameTransform.js.map +1 -0
  214. package/dist/esm/schemas/typescript/GeoJSON.d.ts +6 -0
  215. package/dist/esm/schemas/typescript/GeoJSON.d.ts.map +1 -0
  216. package/dist/esm/schemas/typescript/GeoJSON.js +3 -0
  217. package/dist/esm/schemas/typescript/GeoJSON.js.map +1 -0
  218. package/dist/esm/schemas/typescript/Grid.d.ts +26 -0
  219. package/dist/esm/schemas/typescript/Grid.d.ts.map +1 -0
  220. package/dist/esm/schemas/typescript/Grid.js +3 -0
  221. package/dist/esm/schemas/typescript/Grid.js.map +1 -0
  222. package/dist/esm/schemas/typescript/ImageAnnotations.d.ts +10 -0
  223. package/dist/esm/schemas/typescript/ImageAnnotations.d.ts.map +1 -0
  224. package/dist/esm/schemas/typescript/ImageAnnotations.js +3 -0
  225. package/dist/esm/schemas/typescript/ImageAnnotations.js.map +1 -0
  226. package/dist/esm/schemas/typescript/LaserScan.d.ts +20 -0
  227. package/dist/esm/schemas/typescript/LaserScan.d.ts.map +1 -0
  228. package/dist/esm/schemas/typescript/LaserScan.js +3 -0
  229. package/dist/esm/schemas/typescript/LaserScan.js.map +1 -0
  230. package/dist/esm/schemas/typescript/LocationFix.d.ts +15 -0
  231. package/dist/esm/schemas/typescript/LocationFix.d.ts.map +1 -0
  232. package/dist/esm/schemas/typescript/LocationFix.js +3 -0
  233. package/dist/esm/schemas/typescript/LocationFix.js.map +1 -0
  234. package/dist/esm/schemas/typescript/Log.d.ts +18 -0
  235. package/dist/esm/schemas/typescript/Log.d.ts.map +1 -0
  236. package/dist/esm/schemas/typescript/Log.js +3 -0
  237. package/dist/esm/schemas/typescript/Log.js.map +1 -0
  238. package/dist/esm/schemas/typescript/LogLevel.d.ts +10 -0
  239. package/dist/esm/schemas/typescript/LogLevel.d.ts.map +1 -0
  240. package/dist/esm/schemas/typescript/LogLevel.js +12 -0
  241. package/dist/esm/schemas/typescript/LogLevel.js.map +1 -0
  242. package/dist/esm/schemas/typescript/NumericType.d.ts +13 -0
  243. package/dist/esm/schemas/typescript/NumericType.d.ts.map +1 -0
  244. package/dist/esm/schemas/typescript/NumericType.js +15 -0
  245. package/dist/esm/schemas/typescript/NumericType.js.map +1 -0
  246. package/dist/esm/schemas/typescript/PackedElementField.d.ts +11 -0
  247. package/dist/esm/schemas/typescript/PackedElementField.d.ts.map +1 -0
  248. package/dist/esm/schemas/typescript/PackedElementField.js +3 -0
  249. package/dist/esm/schemas/typescript/PackedElementField.js.map +1 -0
  250. package/dist/esm/schemas/typescript/Point2.d.ts +8 -0
  251. package/dist/esm/schemas/typescript/Point2.d.ts.map +1 -0
  252. package/dist/esm/schemas/typescript/Point2.js +3 -0
  253. package/dist/esm/schemas/typescript/Point2.js.map +1 -0
  254. package/dist/esm/schemas/typescript/Point3.d.ts +10 -0
  255. package/dist/esm/schemas/typescript/Point3.d.ts.map +1 -0
  256. package/dist/esm/schemas/typescript/Point3.js +3 -0
  257. package/dist/esm/schemas/typescript/Point3.js.map +1 -0
  258. package/dist/esm/schemas/typescript/PointCloud.d.ts +19 -0
  259. package/dist/esm/schemas/typescript/PointCloud.d.ts.map +1 -0
  260. package/dist/esm/schemas/typescript/PointCloud.js +3 -0
  261. package/dist/esm/schemas/typescript/PointCloud.js.map +1 -0
  262. package/dist/esm/schemas/typescript/PointsAnnotation.d.ts +18 -0
  263. package/dist/esm/schemas/typescript/PointsAnnotation.d.ts.map +1 -0
  264. package/dist/esm/schemas/typescript/PointsAnnotation.js +3 -0
  265. package/dist/esm/schemas/typescript/PointsAnnotation.js.map +1 -0
  266. package/dist/esm/schemas/typescript/PointsAnnotationType.d.ts +9 -0
  267. package/dist/esm/schemas/typescript/PointsAnnotationType.d.ts.map +1 -0
  268. package/dist/esm/schemas/typescript/PointsAnnotationType.js +11 -0
  269. package/dist/esm/schemas/typescript/PointsAnnotationType.js.map +1 -0
  270. package/dist/esm/schemas/typescript/Pose.d.ts +10 -0
  271. package/dist/esm/schemas/typescript/Pose.d.ts.map +1 -0
  272. package/dist/esm/schemas/typescript/Pose.js +3 -0
  273. package/dist/esm/schemas/typescript/Pose.js.map +1 -0
  274. package/dist/esm/schemas/typescript/PoseInFrame.d.ts +12 -0
  275. package/dist/esm/schemas/typescript/PoseInFrame.d.ts.map +1 -0
  276. package/dist/esm/schemas/typescript/PoseInFrame.js +3 -0
  277. package/dist/esm/schemas/typescript/PoseInFrame.js.map +1 -0
  278. package/dist/esm/schemas/typescript/PosesInFrame.d.ts +12 -0
  279. package/dist/esm/schemas/typescript/PosesInFrame.d.ts.map +1 -0
  280. package/dist/esm/schemas/typescript/PosesInFrame.js +3 -0
  281. package/dist/esm/schemas/typescript/PosesInFrame.js.map +1 -0
  282. package/dist/esm/schemas/typescript/PositionCovarianceType.d.ts +8 -0
  283. package/dist/esm/schemas/typescript/PositionCovarianceType.d.ts.map +1 -0
  284. package/dist/esm/schemas/typescript/PositionCovarianceType.js +10 -0
  285. package/dist/esm/schemas/typescript/PositionCovarianceType.js.map +1 -0
  286. package/dist/esm/schemas/typescript/Quaternion.d.ts +12 -0
  287. package/dist/esm/schemas/typescript/Quaternion.d.ts.map +1 -0
  288. package/dist/esm/schemas/typescript/Quaternion.js +3 -0
  289. package/dist/esm/schemas/typescript/Quaternion.js.map +1 -0
  290. package/dist/esm/schemas/typescript/RawImage.d.ts +17 -0
  291. package/dist/esm/schemas/typescript/RawImage.d.ts.map +1 -0
  292. package/dist/esm/schemas/typescript/RawImage.js +3 -0
  293. package/dist/esm/schemas/typescript/RawImage.js.map +1 -0
  294. package/dist/esm/schemas/typescript/Time.d.ts +5 -0
  295. package/dist/esm/schemas/typescript/Time.d.ts.map +1 -0
  296. package/dist/esm/schemas/typescript/Time.js +2 -0
  297. package/dist/esm/schemas/typescript/Time.js.map +1 -0
  298. package/dist/esm/schemas/typescript/Transform.d.ts +13 -0
  299. package/dist/esm/schemas/typescript/Transform.d.ts.map +1 -0
  300. package/dist/esm/schemas/typescript/Transform.js +3 -0
  301. package/dist/esm/schemas/typescript/Transform.js.map +1 -0
  302. package/dist/esm/schemas/typescript/Vector2.d.ts +8 -0
  303. package/dist/esm/schemas/typescript/Vector2.d.ts.map +1 -0
  304. package/dist/esm/schemas/typescript/Vector2.js +3 -0
  305. package/dist/esm/schemas/typescript/Vector2.js.map +1 -0
  306. package/dist/esm/schemas/typescript/Vector3.d.ts +10 -0
  307. package/dist/esm/schemas/typescript/Vector3.d.ts.map +1 -0
  308. package/dist/esm/schemas/typescript/Vector3.js +3 -0
  309. package/dist/esm/schemas/typescript/Vector3.js.map +1 -0
  310. package/dist/esm/schemas/typescript/index.d.ts +29 -0
  311. package/dist/esm/schemas/typescript/index.d.ts.map +1 -0
  312. package/dist/esm/schemas/typescript/index.js +29 -0
  313. package/dist/esm/schemas/typescript/index.js.map +1 -0
  314. package/dist/esm/scripts/updateGeneratedFiles.d.ts +2 -0
  315. package/dist/esm/scripts/updateGeneratedFiles.d.ts.map +1 -0
  316. package/dist/esm/scripts/updateGeneratedFiles.js +74 -0
  317. package/dist/esm/scripts/updateGeneratedFiles.js.map +1 -0
  318. package/dist/esm/src/generateJsonSchema.d.ts +3 -0
  319. package/dist/esm/src/generateJsonSchema.d.ts.map +1 -0
  320. package/dist/esm/src/generateJsonSchema.js +81 -0
  321. package/dist/esm/src/generateJsonSchema.js.map +1 -0
  322. package/dist/esm/src/generateJsonSchema.test.d.ts +2 -0
  323. package/dist/esm/src/generateJsonSchema.test.d.ts.map +1 -0
  324. package/dist/esm/src/generateJsonSchema.test.js +309 -0
  325. package/dist/esm/src/generateJsonSchema.test.js.map +1 -0
  326. package/dist/esm/src/generateProto.d.ts +3 -0
  327. package/dist/esm/src/generateProto.d.ts.map +1 -0
  328. package/dist/esm/src/generateProto.js +80 -0
  329. package/dist/esm/src/generateProto.js.map +1 -0
  330. package/dist/esm/src/generateProto.test.d.ts +2 -0
  331. package/dist/esm/src/generateProto.test.d.ts.map +1 -0
  332. package/dist/esm/src/generateProto.test.js +122 -0
  333. package/dist/esm/src/generateProto.test.js.map +1 -0
  334. package/dist/esm/src/generateRos.d.ts +20 -0
  335. package/dist/esm/src/generateRos.d.ts.map +1 -0
  336. package/dist/esm/src/generateRos.js +180 -0
  337. package/dist/esm/src/generateRos.js.map +1 -0
  338. package/dist/esm/src/generateRos.test.d.ts +2 -0
  339. package/dist/esm/src/generateRos.test.d.ts.map +1 -0
  340. package/dist/esm/src/generateRos.test.js +909 -0
  341. package/dist/esm/src/generateRos.test.js.map +1 -0
  342. package/dist/esm/src/generateTypeScript.d.ts +5 -0
  343. package/dist/esm/src/generateTypeScript.d.ts.map +1 -0
  344. package/dist/esm/src/generateTypeScript.js +96 -0
  345. package/dist/esm/src/generateTypeScript.js.map +1 -0
  346. package/dist/esm/src/generateTypeScript.test.d.ts +2 -0
  347. package/dist/esm/src/generateTypeScript.test.d.ts.map +1 -0
  348. package/dist/esm/src/generateTypeScript.test.js +117 -0
  349. package/dist/esm/src/generateTypeScript.test.js.map +1 -0
  350. package/dist/esm/src/index.d.ts +6 -0
  351. package/dist/esm/src/index.d.ts.map +1 -0
  352. package/dist/esm/src/index.js +6 -0
  353. package/dist/esm/src/index.js.map +1 -0
  354. package/dist/esm/src/schemas.d.ts +35 -0
  355. package/dist/esm/src/schemas.d.ts.map +1 -0
  356. package/dist/esm/src/schemas.js +817 -0
  357. package/dist/esm/src/schemas.js.map +1 -0
  358. package/dist/esm/src/schemas.test.d.ts +2 -0
  359. package/dist/esm/src/schemas.test.d.ts.map +1 -0
  360. package/dist/esm/src/schemas.test.js +22 -0
  361. package/dist/esm/src/schemas.test.js.map +1 -0
  362. package/dist/esm/src/testFixtures.d.ts +5 -0
  363. package/dist/esm/src/testFixtures.d.ts.map +1 -0
  364. package/dist/esm/src/testFixtures.js +83 -0
  365. package/dist/esm/src/testFixtures.js.map +1 -0
  366. package/dist/esm/src/types.d.ts +37 -0
  367. package/dist/esm/src/types.d.ts.map +1 -0
  368. package/dist/esm/src/types.js +2 -0
  369. package/dist/esm/src/types.js.map +1 -0
  370. package/jest.config.json +16 -0
  371. package/package.json +55 -0
  372. package/schemas/jsonschema/CameraCalibration.json +72 -0
  373. package/schemas/jsonschema/CircleAnnotation.json +96 -0
  374. package/schemas/jsonschema/Color.json +24 -0
  375. package/schemas/jsonschema/CompressedImage.json +33 -0
  376. package/schemas/jsonschema/FrameTransform.json +100 -0
  377. package/schemas/jsonschema/GeoJSON.json +12 -0
  378. package/schemas/jsonschema/Grid.json +179 -0
  379. package/schemas/jsonschema/ImageAnnotations.json +234 -0
  380. package/schemas/jsonschema/LaserScan.json +102 -0
  381. package/schemas/jsonschema/LocationFix.json +51 -0
  382. package/schemas/jsonschema/Log.json +71 -0
  383. package/schemas/jsonschema/PackedElementField.json +59 -0
  384. package/schemas/jsonschema/Point2.json +16 -0
  385. package/schemas/jsonschema/Point3.json +20 -0
  386. package/schemas/jsonschema/PointCloud.json +153 -0
  387. package/schemas/jsonschema/PointsAnnotation.json +122 -0
  388. package/schemas/jsonschema/Pose.json +52 -0
  389. package/schemas/jsonschema/PoseInFrame.json +80 -0
  390. package/schemas/jsonschema/PosesInFrame.json +84 -0
  391. package/schemas/jsonschema/Quaternion.json +24 -0
  392. package/schemas/jsonschema/RawImage.json +48 -0
  393. package/schemas/jsonschema/Transform.json +68 -0
  394. package/schemas/jsonschema/Vector2.json +16 -0
  395. package/schemas/jsonschema/Vector3.json +20 -0
  396. package/schemas/proto/foxglove/CameraCalibration.proto +70 -0
  397. package/schemas/proto/foxglove/CircleAnnotation.proto +30 -0
  398. package/schemas/proto/foxglove/Color.proto +20 -0
  399. package/schemas/proto/foxglove/CompressedImage.proto +19 -0
  400. package/schemas/proto/foxglove/FrameTransform.proto +23 -0
  401. package/schemas/proto/foxglove/GeoJSON.proto +11 -0
  402. package/schemas/proto/foxglove/Grid.proto +40 -0
  403. package/schemas/proto/foxglove/ImageAnnotations.proto +17 -0
  404. package/schemas/proto/foxglove/LaserScan.proto +32 -0
  405. package/schemas/proto/foxglove/LocationFix.proto +33 -0
  406. package/schemas/proto/foxglove/Log.proto +42 -0
  407. package/schemas/proto/foxglove/PackedElementField.proto +37 -0
  408. package/schemas/proto/foxglove/Point2.proto +14 -0
  409. package/schemas/proto/foxglove/Point3.proto +17 -0
  410. package/schemas/proto/foxglove/PointCloud.proto +30 -0
  411. package/schemas/proto/foxglove/PointsAnnotation.proto +39 -0
  412. package/schemas/proto/foxglove/Pose.proto +17 -0
  413. package/schemas/proto/foxglove/PoseInFrame.proto +20 -0
  414. package/schemas/proto/foxglove/PosesInFrame.proto +20 -0
  415. package/schemas/proto/foxglove/Quaternion.proto +20 -0
  416. package/schemas/proto/foxglove/RawImage.proto +28 -0
  417. package/schemas/proto/foxglove/Transform.proto +21 -0
  418. package/schemas/proto/foxglove/Vector2.proto +14 -0
  419. package/schemas/proto/foxglove/Vector3.proto +17 -0
  420. package/schemas/ros1/CameraCalibration.msg +61 -0
  421. package/schemas/ros1/CircleAnnotation.msg +19 -0
  422. package/schemas/ros1/Color.msg +13 -0
  423. package/schemas/ros1/CompressedImage.msg +10 -0
  424. package/schemas/ros1/FrameTransform.msg +13 -0
  425. package/schemas/ros1/GeoJSON.msg +4 -0
  426. package/schemas/ros1/Grid.msg +28 -0
  427. package/schemas/ros1/ImageAnnotations.msg +7 -0
  428. package/schemas/ros1/LaserScan.msg +22 -0
  429. package/schemas/ros1/LocationFix.msg +21 -0
  430. package/schemas/ros1/Log.msg +26 -0
  431. package/schemas/ros1/PackedElementField.msg +20 -0
  432. package/schemas/ros1/Point2.msg +7 -0
  433. package/schemas/ros1/PointCloud.msg +19 -0
  434. package/schemas/ros1/PointsAnnotation.msg +22 -0
  435. package/schemas/ros1/PoseInFrame.msg +10 -0
  436. package/schemas/ros1/PosesInFrame.msg +10 -0
  437. package/schemas/ros1/RawImage.msg +19 -0
  438. package/schemas/ros1/Transform.msg +10 -0
  439. package/schemas/ros1/Vector2.msg +7 -0
  440. package/schemas/ros2/CameraCalibration.msg +61 -0
  441. package/schemas/ros2/CircleAnnotation.msg +19 -0
  442. package/schemas/ros2/Color.msg +13 -0
  443. package/schemas/ros2/CompressedImage.msg +10 -0
  444. package/schemas/ros2/FrameTransform.msg +13 -0
  445. package/schemas/ros2/GeoJSON.msg +4 -0
  446. package/schemas/ros2/Grid.msg +28 -0
  447. package/schemas/ros2/ImageAnnotations.msg +7 -0
  448. package/schemas/ros2/LaserScan.msg +22 -0
  449. package/schemas/ros2/LocationFix.msg +21 -0
  450. package/schemas/ros2/Log.msg +26 -0
  451. package/schemas/ros2/PackedElementField.msg +20 -0
  452. package/schemas/ros2/Point2.msg +7 -0
  453. package/schemas/ros2/PointCloud.msg +19 -0
  454. package/schemas/ros2/PointsAnnotation.msg +22 -0
  455. package/schemas/ros2/PoseInFrame.msg +10 -0
  456. package/schemas/ros2/PosesInFrame.msg +10 -0
  457. package/schemas/ros2/RawImage.msg +19 -0
  458. package/schemas/ros2/Transform.msg +10 -0
  459. package/schemas/ros2/Vector2.msg +7 -0
  460. package/schemas/typescript/CameraCalibration.ts +72 -0
  461. package/schemas/typescript/CircleAnnotation.ts +26 -0
  462. package/schemas/typescript/Color.ts +16 -0
  463. package/schemas/typescript/CompressedImage.ts +15 -0
  464. package/schemas/typescript/Duration.ts +4 -0
  465. package/schemas/typescript/FrameTransform.ts +19 -0
  466. package/schemas/typescript/GeoJSON.ts +7 -0
  467. package/schemas/typescript/Grid.ts +36 -0
  468. package/schemas/typescript/ImageAnnotations.ts +13 -0
  469. package/schemas/typescript/LaserScan.ts +28 -0
  470. package/schemas/typescript/LocationFix.ts +21 -0
  471. package/schemas/typescript/Log.ts +25 -0
  472. package/schemas/typescript/LogLevel.ts +16 -0
  473. package/schemas/typescript/NumericType.ts +22 -0
  474. package/schemas/typescript/PackedElementField.ts +15 -0
  475. package/schemas/typescript/Point2.ts +10 -0
  476. package/schemas/typescript/Point3.ts +13 -0
  477. package/schemas/typescript/PointCloud.ts +26 -0
  478. package/schemas/typescript/PointsAnnotation.ts +24 -0
  479. package/schemas/typescript/PointsAnnotationType.ts +14 -0
  480. package/schemas/typescript/Pose.ts +13 -0
  481. package/schemas/typescript/PoseInFrame.ts +16 -0
  482. package/schemas/typescript/PosesInFrame.ts +16 -0
  483. package/schemas/typescript/PositionCovarianceType.ts +12 -0
  484. package/schemas/typescript/Quaternion.ts +16 -0
  485. package/schemas/typescript/RawImage.ts +24 -0
  486. package/schemas/typescript/Time.ts +4 -0
  487. package/schemas/typescript/Transform.ts +17 -0
  488. package/schemas/typescript/Vector2.ts +10 -0
  489. package/schemas/typescript/Vector3.ts +13 -0
  490. package/schemas/typescript/index.ts +28 -0
  491. package/scripts/updateGeneratedFiles.ts +103 -0
  492. package/src/generateJsonSchema.test.ts +314 -0
  493. package/src/generateJsonSchema.ts +82 -0
  494. package/src/generateProto.test.ts +126 -0
  495. package/src/generateProto.ts +97 -0
  496. package/src/generateRos.test.ts +931 -0
  497. package/src/generateRos.ts +219 -0
  498. package/src/generateTypeScript.test.ts +118 -0
  499. package/src/generateTypeScript.ts +106 -0
  500. package/src/index.ts +5 -0
  501. package/src/schemas.test.ts +23 -0
  502. package/src/schemas.ts +853 -0
  503. package/src/testFixtures.ts +90 -0
  504. package/src/types.ts +40 -0
  505. package/tsconfig.cjs.json +7 -0
  506. package/tsconfig.json +9 -0
@@ -0,0 +1,10 @@
1
+ // Generated from Vector2 by @foxglove/schemas
2
+
3
+ /** A vector in 2D space that represents a direction only */
4
+ export type Vector2 = {
5
+ /** x coordinate length */
6
+ x: number;
7
+
8
+ /** y coordinate length */
9
+ y: number;
10
+ };
@@ -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
+ });