camera.ui3 0.0.30-alpha.0 → 0.0.30-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/dist/interface/@camera.ui.KA9bRSoR.0.0.30-alpha.0.js +3 -0
  2. package/dist/interface/@tanstack.CTzdjGxD.0.0.30-alpha.0.js +1 -0
  3. package/dist/interface/{@vee-validate.0Cv0x9aN.0.0.30-alpha.0.js → @vee-validate.BJKTyKHK.0.0.30-alpha.0.js} +1 -1
  4. package/dist/interface/@vue.BeJw0wEm.0.0.30-alpha.0.js +17 -0
  5. package/dist/interface/{@vueform.Du_niMHk.0.0.30-alpha.0.js → @vueform.DIw88mcs.0.0.30-alpha.0.js} +1 -1
  6. package/dist/interface/{@vueuse.Dv9U068T.0.0.30-alpha.0.js → @vueuse.DK7Mz0BT.0.0.30-alpha.0.js} +1 -1
  7. package/dist/interface/Account.D23CSQgK.0.0.30-alpha.0.js +1 -0
  8. package/dist/interface/Adminpanel.CbDtQWxn.0.0.30-alpha.0.js +2 -0
  9. package/dist/interface/Appearance.az1S-8rV.0.0.30-alpha.0.js +1 -0
  10. package/dist/interface/Backup.BxjbY7JO.0.0.30-alpha.0.js +1 -0
  11. package/dist/interface/Camera.CWxxie6C.0.0.30-alpha.0.js +1 -0
  12. package/dist/interface/Cameras.Cs1dXd-W.0.0.30-alpha.0.js +1 -0
  13. package/dist/interface/Camview.uyIq-pxm.0.0.30-alpha.0.js +1 -0
  14. package/dist/interface/Config.DnuL5NIv.0.0.30-alpha.0.js +1 -0
  15. package/dist/interface/Console.C1dI5f9x.0.0.30-alpha.0.js +4 -0
  16. package/dist/interface/FirstSteps.C_TTm4lX.0.0.30-alpha.0.js +1 -0
  17. package/dist/interface/{NewCamera.Kn9biZIb.0.0.30-alpha.0.js → NewCamera.DjMFd-OB.0.0.30-alpha.0.js} +2 -2
  18. package/dist/interface/Plugin.rLO6u13g.0.0.30-alpha.0.js +1 -0
  19. package/dist/interface/Plugins.Dr-sUa9o.0.0.30-alpha.0.js +1 -0
  20. package/dist/interface/Recordings.4iG-hK8g.0.0.30-alpha.0.js +1 -0
  21. package/dist/interface/Recordings.Dxh2d-IQ.0.0.30-alpha.0.js +1 -0
  22. package/dist/interface/Settings.DAletWZO.0.0.30-alpha.0.js +1 -0
  23. package/dist/interface/System.Pv01yz8u.0.0.30-alpha.0.js +4 -0
  24. package/dist/interface/User.VLcbTFm_.0.0.30-alpha.0.js +1 -0
  25. package/dist/interface/{VConfigEditor.vue_vue_type_script_setup_true_lang.Br68bfQJ.0.0.30-alpha.0.js → VConfigEditor.vue_vue_type_script_setup_true_lang.pXHIBxVl.0.0.30-alpha.0.js} +1 -1
  26. package/dist/interface/{VConsole.BT0UxZb1.0.0.30-alpha.0.js → VConsole.BUZLhyeb.0.0.30-alpha.0.js} +1 -1
  27. package/dist/interface/VPlayer.DW5rNren.0.0.30-alpha.0.js +1 -0
  28. package/dist/interface/{VPluginCard.Bz3GmzAE.0.0.30-alpha.0.js → VPluginCard.D5f85QIk.0.0.30-alpha.0.js} +2 -2
  29. package/dist/interface/index.html +15 -14
  30. package/dist/interface/main.CNzh1Rg5.0.0.30-alpha.0.js +2 -0
  31. package/dist/interface/{pinia.DRjp4GU7.0.0.30-alpha.0.js → pinia.BPnxDxQ3.0.0.30-alpha.0.js} +2 -2
  32. package/dist/interface/{plugins.Ur_7V4x8.0.0.30-alpha.0.js → plugins.DIEspWyc.0.0.30-alpha.0.js} +1 -1
  33. package/dist/interface/sw.js +1 -1
  34. package/dist/interface/{system.CRn9Cy3C.0.0.30-alpha.0.js → system.23ZKsQ9W.0.0.30-alpha.0.js} +1 -1
  35. package/dist/interface/{ui.C-XbEPHk.0.0.30-alpha.0.js → ui.9t-Av5-L.0.0.30-alpha.0.js} +1 -1
  36. package/dist/interface/{v-calendar.CapJoEkJ.0.0.30-alpha.0.js → v-calendar.u5cKUC4g.0.0.30-alpha.0.js} +1 -1
  37. package/dist/interface/{vee-validate.DcgOEpak.0.0.30-alpha.0.js → vee-validate.DLoDjJ2f.0.0.30-alpha.0.js} +2 -2
  38. package/dist/interface/{vue-i18n.D2pqkMP3.0.0.30-alpha.0.js → vue-i18n.1W5jhc7l.0.0.30-alpha.0.js} +2 -2
  39. package/dist/interface/{vue-inline-svg.DorOTPIf.0.0.30-alpha.0.js → vue-inline-svg.Cc6uL4nI.0.0.30-alpha.0.js} +1 -1
  40. package/dist/interface/{vue-router.BVs4qaVs.0.0.30-alpha.0.js → vue-router.CgUDt9kL.0.0.30-alpha.0.js} +2 -2
  41. package/dist/interface/{vue3-apexcharts.CBV9x5vk.0.0.30-alpha.0.js → vue3-apexcharts.D8ONfVUq.0.0.30-alpha.0.js} +1 -1
  42. package/dist/interface/{vue3-dnd.CXMddGIZ.0.0.30-alpha.0.js → vue3-dnd.V9l5pvP2.0.0.30-alpha.0.js} +1 -1
  43. package/dist/interface/{vue3-toastify.DE7YmDSX.0.0.30-alpha.0.js → vue3-toastify.CjNgo6aC.0.0.30-alpha.0.js} +1 -1
  44. package/dist/interface/{vuetify.CYxxHEVN.0.0.30-alpha.0.js → vuetify.Box3fVLm.0.0.30-alpha.0.js} +1 -1
  45. package/dist/interface/zod.DnW1_kUe.0.0.30-alpha.0.js +1 -0
  46. package/dist/server/bin/cameraui.js +10 -7
  47. package/dist/server/bin/cameraui.js.map +1 -1
  48. package/dist/server/bin/fork.js +2 -2
  49. package/dist/server/bin/fork.js.map +1 -1
  50. package/dist/server/bin/installer/darwin.js +1 -1
  51. package/dist/server/bin/installer/darwin.js.map +1 -1
  52. package/dist/server/bin/installer/linux.js +1 -1
  53. package/dist/server/bin/installer/linux.js.map +1 -1
  54. package/dist/server/package.json +11 -15
  55. package/dist/server/src/api/controllers/backup.controller.js.map +1 -1
  56. package/dist/server/src/api/controllers/cameras.controller.js +1 -1
  57. package/dist/server/src/api/controllers/cameras.controller.js.map +1 -1
  58. package/dist/server/src/api/controllers/frameWorkers.controller.js +1 -1
  59. package/dist/server/src/api/controllers/frameWorkers.controller.js.map +1 -1
  60. package/dist/server/src/api/controllers/plugins.controller.js +1 -2
  61. package/dist/server/src/api/controllers/plugins.controller.js.map +1 -1
  62. package/dist/server/src/api/controllers/system.controller.js +1 -3
  63. package/dist/server/src/api/controllers/system.controller.js.map +1 -1
  64. package/dist/server/src/api/controllers/users.controller.js +2 -2
  65. package/dist/server/src/api/controllers/users.controller.js.map +1 -1
  66. package/dist/server/src/api/database/constants.d.ts +8 -0
  67. package/dist/server/src/api/database/constants.js +9 -0
  68. package/dist/server/src/api/database/constants.js.map +1 -0
  69. package/dist/server/src/api/database/index.d.ts +0 -8
  70. package/dist/server/src/api/database/index.js +14 -21
  71. package/dist/server/src/api/database/index.js.map +1 -1
  72. package/dist/server/src/api/database/migration.js +5 -4
  73. package/dist/server/src/api/database/migration.js.map +1 -1
  74. package/dist/server/src/api/database/types.d.ts +6 -6
  75. package/dist/server/src/api/go2rtc/api/application.js +1 -1
  76. package/dist/server/src/api/go2rtc/api/application.js.map +1 -1
  77. package/dist/server/src/api/index.js.map +1 -1
  78. package/dist/server/src/api/plugins/logger.plugin.js.map +1 -1
  79. package/dist/server/src/api/schemas/cameras.schema.d.ts +71 -71
  80. package/dist/server/src/api/schemas/config.schema.d.ts +6 -6
  81. package/dist/server/src/api/schemas/go2rtc.schema.d.ts +98 -98
  82. package/dist/server/src/api/schemas/users.schema.d.ts +116 -116
  83. package/dist/server/src/api/services/auth.service.js +1 -1
  84. package/dist/server/src/api/services/auth.service.js.map +1 -1
  85. package/dist/server/src/api/services/backup.service.js.map +1 -1
  86. package/dist/server/src/api/services/cameras.service.js +1 -1
  87. package/dist/server/src/api/services/cameras.service.js.map +1 -1
  88. package/dist/server/src/api/services/system.service.js +1 -1
  89. package/dist/server/src/api/services/system.service.js.map +1 -1
  90. package/dist/server/src/api/services/users.service.js +1 -1
  91. package/dist/server/src/api/services/users.service.js.map +1 -1
  92. package/dist/server/src/api/types/index.d.ts +2 -2
  93. package/dist/server/src/api/types/index.js.map +1 -1
  94. package/dist/server/src/api/utils/cert.js.map +1 -1
  95. package/dist/server/src/api/websocket/index.js.map +1 -1
  96. package/dist/server/src/api/websocket/nsp/notifications.js.map +1 -1
  97. package/dist/server/src/api/websocket/nsp/server.js +1 -1
  98. package/dist/server/src/api/websocket/nsp/server.js.map +1 -1
  99. package/dist/server/src/api.d.ts +1 -7
  100. package/dist/server/src/api.js.map +1 -1
  101. package/dist/server/src/camera/controller.d.ts +4 -6
  102. package/dist/server/src/camera/controller.js +5 -8
  103. package/dist/server/src/camera/controller.js.map +1 -1
  104. package/dist/server/src/camera/types.d.ts +140 -13
  105. package/dist/server/src/camera/types.js.map +1 -1
  106. package/dist/server/src/decoder/index.js.map +1 -1
  107. package/dist/server/src/decoder/types.d.ts +1 -18
  108. package/dist/server/src/decoder/worker.d.ts +3 -2
  109. package/dist/server/src/decoder/worker.js +10 -22
  110. package/dist/server/src/decoder/worker.js.map +1 -1
  111. package/dist/server/src/go2rtc/index.js +2 -3
  112. package/dist/server/src/go2rtc/index.js.map +1 -1
  113. package/dist/server/src/main.js +3 -3
  114. package/dist/server/src/main.js.map +1 -1
  115. package/dist/server/src/nats/index.d.ts +3 -4
  116. package/dist/server/src/nats/index.js +1 -3
  117. package/dist/server/src/nats/index.js.map +1 -1
  118. package/dist/server/src/nats/proxy/cameraDevice.d.ts +2 -2
  119. package/dist/server/src/nats/proxy/coreManager.d.ts +4 -2
  120. package/dist/server/src/nats/proxy/coreManager.js +7 -0
  121. package/dist/server/src/nats/proxy/coreManager.js.map +1 -1
  122. package/dist/server/src/nats/proxy/deviceManager.d.ts +5 -5
  123. package/dist/server/src/nats/proxy/deviceManager.js +4 -2
  124. package/dist/server/src/nats/proxy/deviceManager.js.map +1 -1
  125. package/dist/server/src/nats/server.js +2 -3
  126. package/dist/server/src/nats/server.js.map +1 -1
  127. package/dist/server/src/nats/types.d.ts +19 -32
  128. package/dist/server/src/nats/utils.d.ts +1 -1
  129. package/dist/server/src/nats/websocket.js.map +1 -1
  130. package/dist/server/src/plugins/index.js +11 -9
  131. package/dist/server/src/plugins/index.js.map +1 -1
  132. package/dist/server/src/plugins/interfaces/base.d.ts +1 -1
  133. package/dist/server/src/plugins/plugin.d.ts +1 -1
  134. package/dist/server/src/plugins/plugin.js +4 -4
  135. package/dist/server/src/plugins/plugin.js.map +1 -1
  136. package/dist/server/src/plugins/types.d.ts +36 -3
  137. package/dist/server/src/plugins/types.js.map +1 -1
  138. package/dist/server/src/plugins/worker.js +7 -16
  139. package/dist/server/src/plugins/worker.js.map +1 -1
  140. package/dist/server/src/services/config/constants.js +2 -2
  141. package/dist/server/src/services/config/constants.js.map +1 -1
  142. package/dist/server/src/services/config/index.d.ts +2 -0
  143. package/dist/server/src/services/config/index.js +10 -2
  144. package/dist/server/src/services/config/index.js.map +1 -1
  145. package/dist/server/src/services/logger/index.d.ts +4 -16
  146. package/dist/server/src/services/logger/index.js +4 -83
  147. package/dist/server/src/services/logger/index.js.map +1 -1
  148. package/dist/server/src/services/logger/types.d.ts +8 -0
  149. package/dist/server/src/services/logger/types.js +2 -0
  150. package/dist/server/src/services/logger/types.js.map +1 -0
  151. package/localdeps.txt +4 -0
  152. package/package.json +11 -15
  153. package/dist/interface/@tanstack.DYQ7Jj8U.0.0.30-alpha.0.js +0 -1
  154. package/dist/interface/@vue.CvjRlaU6.0.0.30-alpha.0.js +0 -17
  155. package/dist/interface/Account.Dm2FouAU.0.0.30-alpha.0.js +0 -1
  156. package/dist/interface/Adminpanel.B2Aiobnt.0.0.30-alpha.0.js +0 -2
  157. package/dist/interface/Appearance.EfH0tMdM.0.0.30-alpha.0.js +0 -1
  158. package/dist/interface/Backup.D8SRclhB.0.0.30-alpha.0.js +0 -1
  159. package/dist/interface/Camera.D-cOf4sS.0.0.30-alpha.0.js +0 -1
  160. package/dist/interface/Cameras.oolxbmXU.0.0.30-alpha.0.js +0 -1
  161. package/dist/interface/Camview.BHw8Pe3v.0.0.30-alpha.0.js +0 -1
  162. package/dist/interface/Config.DmPTI5iz.0.0.30-alpha.0.js +0 -1
  163. package/dist/interface/Console.Dq4khHFF.0.0.30-alpha.0.js +0 -4
  164. package/dist/interface/FirstSteps.Bo467abx.0.0.30-alpha.0.js +0 -1
  165. package/dist/interface/Plugin.BLTVcTt1.0.0.30-alpha.0.js +0 -1
  166. package/dist/interface/Plugins.Cp8mK__o.0.0.30-alpha.0.js +0 -1
  167. package/dist/interface/Recordings.B_JIFk_G.0.0.30-alpha.0.js +0 -1
  168. package/dist/interface/Recordings.gMbvwmk_.0.0.30-alpha.0.js +0 -1
  169. package/dist/interface/Settings.EhHJjGrl.0.0.30-alpha.0.js +0 -1
  170. package/dist/interface/System.VodoK0U6.0.0.30-alpha.0.js +0 -4
  171. package/dist/interface/User.DpcN7DEC.0.0.30-alpha.0.js +0 -1
  172. package/dist/interface/VPlayer.DYua3Eh_.0.0.30-alpha.0.js +0 -1
  173. package/dist/interface/main.19pRAqPU.0.0.30-alpha.0.js +0 -4
  174. package/dist/interface/zod.BaF2dDCd.0.0.30-alpha.0.js +0 -1
  175. package/dist/server/src/camera/device.d.ts +0 -29
  176. package/dist/server/src/camera/device.js +0 -20
  177. package/dist/server/src/camera/device.js.map +0 -1
  178. package/dist/server/src/camera/index.d.ts +0 -90
  179. package/dist/server/src/camera/index.js +0 -581
  180. package/dist/server/src/camera/index.js.map +0 -1
  181. package/dist/server/src/camera/interfaces/camera.d.ts +0 -10
  182. package/dist/server/src/camera/interfaces/camera.js +0 -23
  183. package/dist/server/src/camera/interfaces/camera.js.map +0 -1
  184. package/dist/server/src/camera/interfaces/prebuffer.d.ts +0 -11
  185. package/dist/server/src/camera/interfaces/prebuffer.js +0 -31
  186. package/dist/server/src/camera/interfaces/prebuffer.js.map +0 -1
  187. package/dist/server/src/camera/interfaces/ptz.d.ts +0 -13
  188. package/dist/server/src/camera/interfaces/ptz.js +0 -47
  189. package/dist/server/src/camera/interfaces/ptz.js.map +0 -1
  190. package/dist/server/src/camera/iou.d.ts +0 -2
  191. package/dist/server/src/camera/iou.js +0 -53
  192. package/dist/server/src/camera/iou.js.map +0 -1
  193. package/dist/server/src/camera/polygon.d.ts +0 -6
  194. package/dist/server/src/camera/polygon.js +0 -151
  195. package/dist/server/src/camera/polygon.js.map +0 -1
  196. package/dist/server/src/camera/streaming/peer-connection.d.ts +0 -55
  197. package/dist/server/src/camera/streaming/peer-connection.js +0 -203
  198. package/dist/server/src/camera/streaming/peer-connection.js.map +0 -1
  199. package/dist/server/src/camera/streaming/webrtc-connection.d.ts +0 -35
  200. package/dist/server/src/camera/streaming/webrtc-connection.js +0 -170
  201. package/dist/server/src/camera/streaming/webrtc-connection.js.map +0 -1
  202. package/dist/server/src/camera/streaming/werift-session.d.ts +0 -41
  203. package/dist/server/src/camera/streaming/werift-session.js +0 -179
  204. package/dist/server/src/camera/streaming/werift-session.js.map +0 -1
  205. package/dist/server/src/camera/videoFrame.d.ts +0 -24
  206. package/dist/server/src/camera/videoFrame.js +0 -104
  207. package/dist/server/src/camera/videoFrame.js.map +0 -1
  208. package/dist/server/src/index.d.ts +0 -18
  209. package/dist/server/src/index.js +0 -5
  210. package/dist/server/src/index.js.map +0 -1
  211. package/dist/server/src/nats/connection.d.ts +0 -17
  212. package/dist/server/src/nats/connection.js +0 -66
  213. package/dist/server/src/nats/connection.js.map +0 -1
  214. package/dist/server/src/nats/constants.d.ts +0 -1
  215. package/dist/server/src/nats/constants.js +0 -2
  216. package/dist/server/src/nats/constants.js.map +0 -1
  217. package/dist/server/src/nats/error.d.ts +0 -9
  218. package/dist/server/src/nats/error.js +0 -11
  219. package/dist/server/src/nats/error.js.map +0 -1
  220. package/dist/server/src/nats/messageQueue.d.ts +0 -20
  221. package/dist/server/src/nats/messageQueue.js +0 -132
  222. package/dist/server/src/nats/messageQueue.js.map +0 -1
  223. package/dist/server/src/nats/subscription.d.ts +0 -12
  224. package/dist/server/src/nats/subscription.js +0 -21
  225. package/dist/server/src/nats/subscription.js.map +0 -1
  226. package/dist/server/src/polyglot/node/decoder/child.d.ts +0 -1
  227. package/dist/server/src/polyglot/node/decoder/child.js +0 -644
  228. package/dist/server/src/polyglot/node/decoder/child.js.map +0 -1
  229. package/dist/server/src/polyglot/node/decoder/imageUtils.d.ts +0 -24
  230. package/dist/server/src/polyglot/node/decoder/imageUtils.js +0 -205
  231. package/dist/server/src/polyglot/node/decoder/imageUtils.js.map +0 -1
  232. package/dist/server/src/polyglot/node/decoder/wasm/build/decoder.d.ts +0 -144
  233. package/dist/server/src/polyglot/node/decoder/wasm/build/decoder.js +0 -65
  234. package/dist/server/src/polyglot/node/decoder/wasm/build/decoder.wasm +0 -0
  235. package/dist/server/src/polyglot/node/decoder/wasm/test/imageUtils.py +0 -106
  236. package/dist/server/src/polyglot/node/plugins/cameraStorage.d.ts +0 -107
  237. package/dist/server/src/polyglot/node/plugins/cameraStorage.js +0 -292
  238. package/dist/server/src/polyglot/node/plugins/cameraStorage.js.map +0 -1
  239. package/dist/server/src/polyglot/node/plugins/child.d.ts +0 -28
  240. package/dist/server/src/polyglot/node/plugins/child.js +0 -222
  241. package/dist/server/src/polyglot/node/plugins/child.js.map +0 -1
  242. package/dist/server/src/polyglot/node/plugins/configService.d.ts +0 -104
  243. package/dist/server/src/polyglot/node/plugins/configService.js +0 -213
  244. package/dist/server/src/polyglot/node/plugins/configService.js.map +0 -1
  245. package/dist/server/src/polyglot/node/plugins/pluginApi.d.ts +0 -35
  246. package/dist/server/src/polyglot/node/plugins/pluginApi.js +0 -23
  247. package/dist/server/src/polyglot/node/plugins/pluginApi.js.map +0 -1
  248. package/dist/server/src/polyglot/node/plugins/pluginLogger.d.ts +0 -18
  249. package/dist/server/src/polyglot/node/plugins/pluginLogger.js +0 -89
  250. package/dist/server/src/polyglot/node/plugins/pluginLogger.js.map +0 -1
  251. package/dist/server/src/polyglot/node/plugins/proxy/cameraDevice.d.ts +0 -69
  252. package/dist/server/src/polyglot/node/plugins/proxy/cameraDevice.js +0 -423
  253. package/dist/server/src/polyglot/node/plugins/proxy/cameraDevice.js.map +0 -1
  254. package/dist/server/src/polyglot/node/plugins/proxy/coreManager.d.ts +0 -40
  255. package/dist/server/src/polyglot/node/plugins/proxy/coreManager.js +0 -105
  256. package/dist/server/src/polyglot/node/plugins/proxy/coreManager.js.map +0 -1
  257. package/dist/server/src/polyglot/node/plugins/proxy/deviceManager.d.ts +0 -47
  258. package/dist/server/src/polyglot/node/plugins/proxy/deviceManager.js +0 -164
  259. package/dist/server/src/polyglot/node/plugins/proxy/deviceManager.js.map +0 -1
  260. package/dist/server/src/polyglot/node/plugins/schema.d.ts +0 -293
  261. package/dist/server/src/polyglot/node/plugins/schema.js +0 -740
  262. package/dist/server/src/polyglot/node/plugins/schema.js.map +0 -1
  263. package/dist/server/src/polyglot/node/plugins/storageController.d.ts +0 -30
  264. package/dist/server/src/polyglot/node/plugins/storageController.js +0 -40
  265. package/dist/server/src/polyglot/node/plugins/storageController.js.map +0 -1
  266. package/dist/server/src/polyglot/python/camera/interfaces/camera.py +0 -20
  267. package/dist/server/src/polyglot/python/camera/interfaces/prebuffer.py +0 -28
  268. package/dist/server/src/polyglot/python/camera/interfaces/ptz.py +0 -38
  269. package/dist/server/src/polyglot/python/camera/iou.py +0 -80
  270. package/dist/server/src/polyglot/python/camera/polygon.py +0 -173
  271. package/dist/server/src/polyglot/python/camera/video_frame.py +0 -188
  272. package/dist/server/src/polyglot/python/camera_ui_types/__init__.py +0 -1200
  273. package/dist/server/src/polyglot/python/decoder/child.py +0 -882
  274. package/dist/server/src/polyglot/python/decoder/image_utils.py +0 -149
  275. package/dist/server/src/polyglot/python/decoder/typings.py +0 -99
  276. package/dist/server/src/polyglot/python/plugins/camera_storage.py +0 -391
  277. package/dist/server/src/polyglot/python/plugins/child.py +0 -394
  278. package/dist/server/src/polyglot/python/plugins/config_service.py +0 -187
  279. package/dist/server/src/polyglot/python/plugins/constants.py +0 -1
  280. package/dist/server/src/polyglot/python/plugins/message_queue.py +0 -182
  281. package/dist/server/src/polyglot/python/plugins/plugin_api.py +0 -34
  282. package/dist/server/src/polyglot/python/plugins/plugin_logger.py +0 -111
  283. package/dist/server/src/polyglot/python/plugins/proxy/camera_device.py +0 -1599
  284. package/dist/server/src/polyglot/python/plugins/proxy/core_manager.py +0 -145
  285. package/dist/server/src/polyglot/python/plugins/proxy/device_manager.py +0 -226
  286. package/dist/server/src/polyglot/python/plugins/schema.py +0 -181
  287. package/dist/server/src/polyglot/python/plugins/storage_controller.py +0 -58
  288. package/dist/server/src/polyglot/python/plugins/typings.py +0 -253
  289. package/dist/server/src/polyglot/python/utilities/connection.py +0 -86
  290. package/dist/server/src/polyglot/python/utilities/json_lmdb.py +0 -19
  291. package/dist/server/src/polyglot/python/utilities/object_path.py +0 -195
  292. package/dist/server/src/polyglot/python/utilities/packer.py +0 -11
  293. package/dist/server/src/polyglot/python/utilities/subscriptions.py +0 -22
  294. package/dist/server/src/polyglot/python/utilities/task.py +0 -35
  295. package/dist/server/src/polyglot/python/utilities/thread.py +0 -10
  296. package/dist/server/src/polyglot/python/utilities/utils.py +0 -73
  297. package/dist/server/src/utils/ffmpeg.d.ts +0 -2
  298. package/dist/server/src/utils/ffmpeg.js +0 -61
  299. package/dist/server/src/utils/ffmpeg.js.map +0 -1
  300. package/dist/server/src/utils/network.d.ts +0 -12
  301. package/dist/server/src/utils/network.js +0 -92
  302. package/dist/server/src/utils/network.js.map +0 -1
  303. package/dist/server/src/utils/npm.d.ts +0 -4
  304. package/dist/server/src/utils/npm.js +0 -128
  305. package/dist/server/src/utils/npm.js.map +0 -1
  306. package/dist/server/src/utils/packer.d.ts +0 -2
  307. package/dist/server/src/utils/packer.js +0 -17
  308. package/dist/server/src/utils/packer.js.map +0 -1
  309. package/dist/server/src/utils/pythonInstaller.d.ts +0 -48
  310. package/dist/server/src/utils/pythonInstaller.js +0 -494
  311. package/dist/server/src/utils/pythonInstaller.js.map +0 -1
  312. package/dist/server/src/utils/reader.d.ts +0 -5
  313. package/dist/server/src/utils/reader.js +0 -41
  314. package/dist/server/src/utils/reader.js.map +0 -1
  315. package/dist/server/src/utils/subscribed.d.ts +0 -9
  316. package/dist/server/src/utils/subscribed.js +0 -17
  317. package/dist/server/src/utils/subscribed.js.map +0 -1
  318. package/dist/server/src/utils/utils.d.ts +0 -10
  319. package/dist/server/src/utils/utils.js +0 -165
  320. package/dist/server/src/utils/utils.js.map +0 -1
@@ -1,740 +0,0 @@
1
- import { z } from 'zod';
2
- const isISO8601 = (value) => {
3
- const iso8601Regex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
4
- return iso8601Regex.test(value);
5
- };
6
- const isTime = (value, options) => {
7
- const timeRegex = options.mode === 'withSeconds' ? /^([01]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/ : /^([01]?[0-9]|2[0-3]):([0-5][0-9])$/;
8
- return timeRegex.test(value);
9
- };
10
- const isEmail = (value) => {
11
- const emailRegex = /^\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b$/;
12
- return emailRegex.test(value);
13
- };
14
- const isUUID = (value) => {
15
- const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
16
- return uuidRegex.test(value);
17
- };
18
- const isIP = (value, version) => {
19
- const ipRegex = version === 4 ? /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/ : /^\s*([0-9a-fA-F]{1,4}:){7}([0-9a-fA-F]{1,4})\s*$/;
20
- return ipRegex.test(value);
21
- };
22
- /**
23
- * Generate root JSON schema from value.
24
- *
25
- * @param value - Value.
26
- * @returns - Root JSON schema.
27
- */
28
- export const generateRootSchema = (value) => {
29
- const schema = {};
30
- Object.entries(value).forEach(([key, subValue]) => {
31
- schema[key] = generateSchema(subValue);
32
- });
33
- return { schema };
34
- };
35
- /**
36
- * Generate JSON schema from value.
37
- *
38
- * @param value - Value.
39
- * @returns - JSON schema.
40
- */
41
- export const generateSchema = (value) => {
42
- switch (true) {
43
- case value === undefined:
44
- case typeof value === 'undefined':
45
- case typeof value === 'function':
46
- case typeof value === 'symbol':
47
- case value instanceof Date:
48
- throw new TypeError(`Invalid JSON value: ${String(value)}`);
49
- // /**
50
- // * @see https://json-schema.org/understanding-json-schema/reference/null.html
51
- // */
52
- // case value === null:
53
- // return { type: 'null' };
54
- /**
55
- * @see https://json-schema.org/understanding-json-schema/reference/numeric.html
56
- */
57
- case typeof value === 'number':
58
- return generateNumberSchema();
59
- /**
60
- * @see https://json-schema.org/understanding-json-schema/reference/boolean.html
61
- */
62
- case typeof value === 'boolean':
63
- return genereateBooleanSchema();
64
- /**
65
- * @see https://json-schema.org/understanding-json-schema/reference/string.html
66
- */
67
- case typeof value === 'string':
68
- return generateStringSchema(value);
69
- /**
70
- * @see https://json-schema.org/understanding-json-schema/reference/array.html
71
- */
72
- case Array.isArray(value):
73
- const allPrimitives = value.every((item) => typeof item === 'string' || typeof item === 'number' || typeof item === 'boolean');
74
- if (allPrimitives) {
75
- return generateEnumSchema(value);
76
- }
77
- else {
78
- return generateArraySchema(value);
79
- }
80
- /**
81
- * @see https://json-schema.org/understanding-json-schema/reference/object.html
82
- */
83
- case value instanceof Object:
84
- return generateObjectSchema(value);
85
- default:
86
- throw new TypeError(`Invalid JSON value: ${value}`);
87
- }
88
- };
89
- /**
90
- * Generate a JSON object from a given Root JSON schema.
91
- *
92
- * @param rootSchema - The Root JSON schema.
93
- * @returns - The generated JSON object.
94
- */
95
- export const generateJsonFromRootSchema = (rootSchema) => {
96
- const jsonObject = {};
97
- Object.entries(rootSchema.schema).forEach(([key, jsonSchema]) => {
98
- jsonObject[key] = generateJsonFromSchema(jsonSchema);
99
- });
100
- return jsonObject;
101
- };
102
- /**
103
- * Generate a JSON object from a JSON schema.
104
- *
105
- * @param jsonSchema - The JSON schema.
106
- * @returns - The generated JSON object.
107
- */
108
- export const generateJsonFromSchema = (jsonSchema) => {
109
- switch (jsonSchema.type) {
110
- case 'string':
111
- case 'number':
112
- case 'boolean':
113
- if (isEnumType(jsonSchema)) {
114
- if (jsonSchema.multiple) {
115
- return jsonSchema.defaultValue !== undefined ? [jsonSchema.defaultValue] : undefined;
116
- }
117
- else {
118
- return jsonSchema.defaultValue !== undefined ? jsonSchema.defaultValue : jsonSchema.required ? jsonSchema.enum[0] : undefined;
119
- }
120
- }
121
- else {
122
- return jsonSchema.defaultValue;
123
- }
124
- case 'object':
125
- if (jsonSchema.properties) {
126
- return Object.entries(jsonSchema.properties).reduce((obj, [key, value]) => {
127
- obj[key] = generateJsonFromSchema(value);
128
- return obj;
129
- }, {});
130
- }
131
- return {};
132
- case 'array':
133
- if (jsonSchema.items) {
134
- return [generateJsonFromSchema(jsonSchema.items)];
135
- }
136
- return [];
137
- default:
138
- return undefined;
139
- }
140
- };
141
- /**
142
- * Generate a JSON object from a given JSON schema and use values from a config file.
143
- *
144
- * @param jsonSchema - The JSON schema.
145
- * @param config - The config file with values to use.
146
- * @returns - The generated JSON object.
147
- */
148
- export const generateJsonFromSchemaWithConfig = (jsonSchema, config, path = '') => {
149
- switch (jsonSchema.type) {
150
- case 'string':
151
- case 'number':
152
- case 'boolean':
153
- const value = getValueByPath(config, path);
154
- return value !== undefined ? value : generateJsonFromSchema(jsonSchema);
155
- case 'object':
156
- if (jsonSchema.properties) {
157
- return Object.entries(jsonSchema.properties).reduce((obj, [key, schema]) => {
158
- const newPath = path + (path.length > 0 ? '.' : '') + key;
159
- obj[key] = generateJsonFromSchemaWithConfig(schema, config, newPath);
160
- return obj;
161
- }, {});
162
- }
163
- return {};
164
- case 'array':
165
- if (jsonSchema.items) {
166
- const items = jsonSchema.items;
167
- const arrayConfig = getValueByPath(config, path) ?? [];
168
- return arrayConfig.map((itemConfig, index) => generateJsonFromSchemaWithConfig(items, itemConfig, path + `[${index}]`));
169
- }
170
- return [];
171
- default:
172
- return undefined;
173
- }
174
- };
175
- /**
176
- * Generate a new config object from a given JSON schema and use values from a config file.
177
- * Contains only storable values.
178
- *
179
- * @param jsonSchema - The JSON schema.
180
- * @param config - The config file with values to use.
181
- * @param path - The path to the current JSON schema.
182
- */
183
- export const generateStorableConfig = (jsonSchema, config) => {
184
- const newConfig = {};
185
- const processSchema = (schema, value) => {
186
- if (isObjectType(schema) && schema.properties) {
187
- const result = {};
188
- Object.entries(schema.properties).forEach(([key, propSchema]) => {
189
- const propValue = processSchema(propSchema, value?.[key]);
190
- if (propValue !== undefined) {
191
- result[key] = propValue;
192
- }
193
- });
194
- return Object.keys(result).length > 0 ? result : undefined;
195
- }
196
- else if (isArrayType(schema) && schema.items && Array.isArray(value)) {
197
- const result = value.map((item) => processSchema(schema.items, item)).filter((item) => item !== undefined);
198
- return result.length > 0 ? result : undefined;
199
- }
200
- else if (schema.store) {
201
- return value;
202
- }
203
- return undefined;
204
- };
205
- Object.entries(jsonSchema).forEach(([key, schema]) => {
206
- const result = processSchema(schema, config[key]);
207
- if (result !== undefined) {
208
- newConfig[key] = result;
209
- }
210
- });
211
- return newConfig;
212
- };
213
- /**
214
- * Removes all functions from a given Plugin JSON schema form.
215
- *
216
- * @param schemaForm - The Plugin JSON schema form from which the functions should be removed.
217
- * @returns - The Plugin JSON schema form without functions.
218
- */
219
- export const removeFunctionsFromSchemaForm = (schemaForm) => {
220
- const filteredSchemaForm = {};
221
- Object.keys(schemaForm).forEach((key) => {
222
- filteredSchemaForm[key] = removeFunctionsFromSchema(schemaForm[key]);
223
- });
224
- return filteredSchemaForm;
225
- };
226
- /**
227
- * Removes all functions from a given Plugin JSON schema.
228
- *
229
- * @param jsonSchema - The JSON schema from which the functions should be removed.
230
- * @returns - The JSON schema without functions.
231
- */
232
- export const removeFunctionsFromSchema = (jsonSchema) => {
233
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
234
- const { onSet, onGet, ...rest } = jsonSchema;
235
- if (isObjectType(rest) && rest.properties) {
236
- rest.properties = removeFunctionsFromSchemaForm(rest.properties);
237
- }
238
- else if (isArrayType(rest) && rest.items) {
239
- rest.items = removeFunctionsFromSchema(rest.items);
240
- }
241
- return rest;
242
- };
243
- /**
244
- * Checks if a given JSON schema is readonly.
245
- *
246
- * @param jsonSchema - The JSON schema to check.
247
- * @returns - True if the JSON schema is readonly, false otherwise.
248
- */
249
- export const schemaIsReadonly = (jsonSchema) => {
250
- return Boolean(jsonSchema.readonly ||
251
- (isObjectType(jsonSchema) && jsonSchema.properties && Object.values(jsonSchema.properties).every((property) => schemaIsReadonly(property))) ||
252
- (isArrayType(jsonSchema) && jsonSchema.items && schemaIsReadonly(jsonSchema.items)));
253
- };
254
- export const schemaIsStorable = (jsonSchema) => {
255
- return Boolean(jsonSchema.store ||
256
- (isObjectType(jsonSchema) && jsonSchema.properties && Object.values(jsonSchema.properties).some((property) => schemaIsStorable(property))) ||
257
- (isArrayType(jsonSchema) && jsonSchema.items && schemaIsStorable(jsonSchema.items)));
258
- };
259
- /**
260
- * Converts a config path to a schema path.
261
- *
262
- * @param configPath - The config path to be converted.
263
- * @returns - The converted schema path.
264
- */
265
- export const configPathToSchemaPath = (configPath) => {
266
- const pathParts = configPath.split('.');
267
- const schemaPathParts = [];
268
- pathParts.forEach((part, index) => {
269
- const isNumericIndex = /^\d+$/.test(part);
270
- const isLastPart = index === pathParts.length - 1;
271
- if (isNumericIndex) {
272
- schemaPathParts.push('items', 'properties');
273
- }
274
- else {
275
- schemaPathParts.push(part);
276
- const isNumericIndex = /^\d+$/.test(pathParts[index + 1]);
277
- // if (!isLastPart && isNaN(parseInt(pathParts[index + 1]))) {
278
- if (!isLastPart && !isNumericIndex) {
279
- schemaPathParts.push('properties');
280
- }
281
- }
282
- });
283
- return schemaPathParts.join('.');
284
- };
285
- /**
286
- * Converts a schema path to a config path.
287
- *
288
- * @param schemaPath - The schema path to be converted.
289
- * @returns - The converted config path.
290
- */
291
- export const schemaPathToConfigPath = (schemaPath) => {
292
- const pathParts = schemaPath.split('.');
293
- const configPathParts = [];
294
- pathParts.forEach((part) => {
295
- // Exclude 'properties' and 'items' keywords from the path
296
- if (part !== 'properties' && part !== 'items') {
297
- // Check if the part is a numeric index and format it as an array index
298
- const isNumericIndex = /^\d+$/.test(part);
299
- if (isNumericIndex) {
300
- configPathParts.push(`[${part}]`);
301
- }
302
- else {
303
- configPathParts.push(part);
304
- }
305
- }
306
- });
307
- return configPathParts.join('.');
308
- };
309
- /**
310
- * Recursively searches a JSON object for a specific, potentially nested key path and returns its value.
311
- *
312
- * @param obj - The JSON object to be searched.
313
- * @param path - The key path to search for.
314
- * @returns - The value of the searched key path, if found, otherwise undefined.
315
- */
316
- export const getValueByPath = (obj = {}, path) => {
317
- const keys = path.split('.').reduce((acc, key) => {
318
- if (key.includes('[')) {
319
- const [pathKey, index] = key.split('[');
320
- acc.push(pathKey, index.slice(0, -1));
321
- }
322
- else {
323
- acc.push(key);
324
- }
325
- return acc;
326
- }, []);
327
- let current = obj;
328
- for (const key of keys) {
329
- if (current === undefined) {
330
- return undefined;
331
- }
332
- current = current[key];
333
- }
334
- return current;
335
- };
336
- /**
337
- * Generates a Zod schema from a given JSON schema.
338
- *
339
- * @param jsonSchema - The JSON schema from which the Zod schema should be generated.
340
- * @returns - The generated Zod schema.
341
- */
342
- export const generateZodSchemaFromRoot = (rootSchema) => {
343
- const zodObjectSchema = {};
344
- Object.entries(rootSchema.schema).forEach(([key, jsonSchema]) => {
345
- zodObjectSchema[key] = generateZodSchema(jsonSchema);
346
- });
347
- return z.object(zodObjectSchema).strict();
348
- };
349
- /**
350
- * Generates a Zod schema from a given JSON schema.
351
- *
352
- * @param jsonSchema - The JSON schema from which the Zod schema should be generated.
353
- * @param initial - A boolean indicating whether this is the initial call to the function.
354
- * This is used for handling nested schemas.
355
- * @returns - The generated Zod schema.
356
- */
357
- export const generateZodSchema = (jsonSchema) => {
358
- switch (jsonSchema.type) {
359
- case 'string':
360
- case 'number':
361
- case 'boolean':
362
- if (isEnumType(jsonSchema)) {
363
- return createEnumSchema(jsonSchema);
364
- }
365
- else if (isStringType(jsonSchema)) {
366
- return createZodStringSchema(jsonSchema);
367
- }
368
- else if (isNumberType(jsonSchema)) {
369
- return createZodNumberSchema(jsonSchema);
370
- }
371
- else {
372
- return createZodBooleanSchema(jsonSchema);
373
- }
374
- case 'object':
375
- return createZodObjectSchema(jsonSchema);
376
- case 'array':
377
- return createZodArraySchema(jsonSchema);
378
- case 'button':
379
- return z.any();
380
- }
381
- };
382
- /**
383
- * Generates a JSON schema for a number.
384
- *
385
- * @param value - The number for which the JSON schema should be generated.
386
- * @returns - The generated JSON schema for the number.
387
- */
388
- export const generateNumberSchema = () => {
389
- // return { type: Number.isInteger(value) ? 'integer' : 'number' };
390
- return { type: 'number' };
391
- };
392
- /**
393
- * Generates a JSON schema for a boolean.
394
- *
395
- * @param value - The boolean for which the JSON schema should be generated.
396
- * @returns - The generated JSON schema for the boolean.
397
- */
398
- export const genereateBooleanSchema = () => {
399
- return { type: 'boolean' };
400
- };
401
- /**
402
- * Generates a JSON schema for a string.
403
- *
404
- * @param value - The string for which the JSON schema should be generated.
405
- * @returns - The generated JSON schema for the string.
406
- */
407
- export const generateStringSchema = (value) => {
408
- const stringObject = { type: 'string' };
409
- if (isISO8601(value)) {
410
- stringObject.format = value.includes('T') ? 'date-time' : 'date';
411
- }
412
- if (isTime(value.split('+')[0], { mode: 'withSeconds' })) {
413
- stringObject.format = 'time';
414
- }
415
- if (isEmail(value)) {
416
- stringObject.format = 'email';
417
- }
418
- if (isUUID(value)) {
419
- stringObject.format = 'uuid';
420
- }
421
- if (isIP(value, 4)) {
422
- stringObject.format = 'ipv4';
423
- }
424
- if (isIP(value, 6)) {
425
- stringObject.format = 'ipv6';
426
- }
427
- return stringObject;
428
- };
429
- /**
430
- * Generates a JSON schema for an enum.
431
- *
432
- * @param value - The enum for which the JSON schema should be generated.
433
- * @param type - The type of the enum.
434
- * @returns - The generated JSON schema for the enum.
435
- */
436
- export const generateEnumSchema = (value) => {
437
- return { type: 'string', enum: value.map((item) => item.toString()) };
438
- };
439
- /**
440
- * Generates a JSON schema for an object.
441
- *
442
- * @param value - The object for which the JSON schema should be generated.
443
- * @returns - The generated JSON schema for the object.
444
- */
445
- export const generateObjectSchema = (value) => {
446
- if (!Object.keys(value).length) {
447
- return { type: 'object' };
448
- }
449
- const properties = {};
450
- Object.entries(value).forEach(([key, value]) => {
451
- const schema = generateSchema(value);
452
- schema.key = key;
453
- schema.description = schema.description || `Description for ${key}`;
454
- schema.required = schema.required === undefined ? true : schema.required;
455
- schema.readonly = schema.readonly || false;
456
- properties[key] = schema;
457
- });
458
- return { type: 'object', properties };
459
- };
460
- /**
461
- * Generates a JSON schema for an object including up to two buttons.
462
- *
463
- * @param value - The object for which the JSON schema should be generated.
464
- * @param buttons - Array of min one button and up to two buttons to be included in the schema.
465
- * @returns - The generated JSON schema for the object.
466
- */
467
- export const generateObjectSchemaWithButtons = (value, buttons) => {
468
- const baseSchema = {
469
- ...generateObjectSchema(value),
470
- buttons: buttons,
471
- };
472
- return baseSchema;
473
- };
474
- /**
475
- * Generates a JSON schema for an array.
476
- *
477
- * @param array - The array for which the JSON schema should be generated.
478
- * @returns - The generated JSON schema for the array.
479
- */
480
- export const generateArraySchema = (array) => {
481
- if (array.length === 0) {
482
- return { type: 'array' };
483
- }
484
- const allObjects = array.every((item) => typeof item === 'object' && item !== null && !Array.isArray(item));
485
- const allStrings = array.every((item) => typeof item === 'string');
486
- const allNumbers = array.every((item) => typeof item === 'number');
487
- if (allObjects) {
488
- const schemaProperties = {};
489
- const keyPresenceCount = {};
490
- // Gather all keys and their presence count
491
- array.forEach((obj) => {
492
- Object.keys(obj).forEach((key) => {
493
- keyPresenceCount[key] = (keyPresenceCount[key] || 0) + 1;
494
- });
495
- });
496
- array.forEach((obj) => {
497
- Object.entries(obj).forEach(([key, value]) => {
498
- if (!schemaProperties[key]) {
499
- const isRequired = keyPresenceCount[key] === array.length;
500
- schemaProperties[key] = {
501
- ...generateSchema(value),
502
- required: isRequired,
503
- title: key,
504
- description: `Description for ${key}`,
505
- readonly: false,
506
- };
507
- }
508
- });
509
- });
510
- return {
511
- type: 'array',
512
- items: { type: 'object', properties: schemaProperties },
513
- };
514
- }
515
- else if (allStrings) {
516
- return { type: 'array', items: { type: 'string' } };
517
- }
518
- else if (allNumbers) {
519
- return { type: 'array', items: { type: 'number' } };
520
- }
521
- else {
522
- return { type: 'array', items: { type: 'boolean' } };
523
- }
524
- };
525
- /**
526
- * Checks if the given JSON schema is of string type.
527
- *
528
- * @param jsonSchema - The JSON schema to check.
529
- * @returns - True if the JSON schema is of string type, false otherwise.
530
- */
531
- export const isStringType = (jsonSchema) => {
532
- return jsonSchema.type === 'string' && !('enum' in jsonSchema);
533
- };
534
- /**
535
- * Checks if the given JSON schema is of number type.
536
- *
537
- * @param jsonSchema - The JSON schema to check.
538
- * @returns - True if the JSON schema is of number type, false otherwise.
539
- */
540
- export const isNumberType = (jsonSchema) => {
541
- return jsonSchema.type === 'number' && !('enum' in jsonSchema);
542
- };
543
- /**
544
- * Checks if the given JSON schema is of boolean type.
545
- *
546
- * @param jsonSchema - The JSON schema to check.
547
- * @returns - True if the JSON schema is of boolean type, false otherwise.
548
- */
549
- export const isBooleanType = (jsonSchema) => {
550
- return jsonSchema.type === 'boolean' && !('enum' in jsonSchema);
551
- };
552
- /**
553
- * Checks if the given JSON schema is of enum type.
554
- *
555
- * @param jsonSchema - The JSON schema to check.
556
- * @returns - True if the JSON schema is of enum type, false otherwise.
557
- */
558
- export const isEnumType = (jsonSchema) => {
559
- return 'enum' in jsonSchema;
560
- };
561
- /**
562
- * Checks if the given JSON schema is of object type.
563
- *
564
- * @param jsonSchema - The JSON schema to check.
565
- * @returns - True if the JSON schema is of object type, false otherwise.
566
- */
567
- export const isObjectType = (jsonSchema) => {
568
- return jsonSchema.type === 'object';
569
- };
570
- /**
571
- * Checks if the given JSON schema is of object type with buttons.
572
- *
573
- * @param jsonSchema - The JSON schema to check.
574
- * @returns - True if the JSON schema is of object type with buttons, false otherwise.
575
- */
576
- export const isObjectTypeWithButtons = (jsonSchema) => {
577
- return isObjectType(jsonSchema) && 'buttons' in jsonSchema;
578
- };
579
- /**
580
- * Checks if the given JSON schema is of array type.
581
- *
582
- * @param jsonSchema - The JSON schema to check.
583
- * @returns - True if the JSON schema is of array type, false otherwise.
584
- */
585
- export const isArrayType = (jsonSchema) => {
586
- return jsonSchema.type === 'array';
587
- };
588
- /**
589
- * Checks if the given JSON schema is of button type.
590
- *
591
- * @param jsonSchema - The JSON schema to check.
592
- * @returns - True if the JSON schema is of button type, false otherwise.
593
- */
594
- export const isButtonType = (jsonSchema) => {
595
- return jsonSchema.type === 'button';
596
- };
597
- /**
598
- * Checks if the given value is a JSON schema.
599
- *
600
- * @param value - The value to check.
601
- * @returns - True if the value is a JSON schema, false otherwise.
602
- */
603
- export const isJsonSchema = (value) => {
604
- return isStringType(value) || isNumberType(value) || isBooleanType(value) || isEnumType(value) || isObjectType(value) || isArrayType(value);
605
- };
606
- /**
607
- * Checks if the given value is a JSON Primitive schema.
608
- *
609
- * @param value - The value to check.
610
- * @returns - True if the value is a JSON schema, false otherwise.
611
- */
612
- export const isPrimitiveType = (value) => {
613
- return 'onGet' in value || 'onSet' in value;
614
- };
615
- /**
616
- * Creates a Zod string schema from a given JSON schema.
617
- *
618
- * @param jsonSchema - The JSON schema from which the Zod schema should be created.
619
- * @returns - The created Zod string schema.
620
- */
621
- export const createZodStringSchema = (jsonSchema) => {
622
- let schema = z.string();
623
- if (jsonSchema.required)
624
- schema = schema.nonempty('Required');
625
- if (jsonSchema.minLength !== undefined)
626
- schema = schema.min(jsonSchema.minLength);
627
- if (jsonSchema.maxLength !== undefined)
628
- schema = schema.max(jsonSchema.maxLength);
629
- if (jsonSchema.format) {
630
- switch (jsonSchema.format) {
631
- case 'date-time':
632
- schema = schema.refine((value) => isISO8601(value) && value.includes('T'), { message: 'Invalid date-time' });
633
- break;
634
- case 'date':
635
- schema = schema.refine((value) => isISO8601(value), { message: 'Invalid date' });
636
- break;
637
- case 'time':
638
- schema = schema.refine((value) => isTime(value.split('+')[0], { mode: 'withSeconds' }), { message: 'Invalid time' });
639
- break;
640
- case 'email':
641
- schema = schema.refine((value) => isEmail(value), { message: 'Invalid email' });
642
- break;
643
- case 'uuid':
644
- schema = schema.refine((value) => isUUID(value), { message: 'Invalid uuid' });
645
- break;
646
- case 'ipv4':
647
- schema = schema.refine((value) => isIP(value, 4), { message: 'Invalid ipv4' });
648
- break;
649
- case 'ipv6':
650
- schema = schema.refine((value) => isIP(value, 6), { message: 'Invalid ipv6' });
651
- break;
652
- // case 'password':
653
- // schema = schema.refine((value) => isStrongPassword(value), { message: 'Invalid password' });
654
- // break;
655
- // case 'qrCode':
656
- // schema = schema.refine((value) => isBase64(value), { message: 'Invalid qrCode' });
657
- // break;
658
- }
659
- }
660
- return jsonSchema.required ? schema : schema.optional();
661
- };
662
- /**
663
- * Creates a Zod number schema from a given JSON schema.
664
- *
665
- * @param jsonSchema - The JSON schema from which the Zod schema should be created.
666
- * @returns - The created Zod number schema.
667
- */
668
- export const createZodNumberSchema = (jsonSchema) => {
669
- let schema = z.number();
670
- if (jsonSchema.minimum !== undefined)
671
- schema = schema.min(jsonSchema.minimum);
672
- if (jsonSchema.maximum !== undefined)
673
- schema = schema.max(jsonSchema.maximum);
674
- if (jsonSchema.required)
675
- schema = schema.refine((value) => value !== undefined && typeof value === 'number', { message: 'Required' });
676
- return jsonSchema.required ? schema : schema.optional();
677
- };
678
- /**
679
- * Creates a Zod boolean schema from a given JSON schema.
680
- *
681
- * @param jsonSchema - The JSON schema from which the Zod schema should be created.
682
- * @returns - The created Zod boolean schema.
683
- */
684
- export const createZodBooleanSchema = (jsonSchema) => {
685
- const schema = z.boolean();
686
- return jsonSchema.required ? schema : schema.optional();
687
- };
688
- /**
689
- * Creates a Zod union schema from a given JSON schema.
690
- *
691
- * @param jsonSchema - The JSON schema from which the Zod schema should be created.
692
- * @returns - The created Zod union schema.
693
- */
694
- export const createEnumSchema = (jsonSchema) => {
695
- const enumValues = jsonSchema.enum.map((item) => (jsonSchema.required ? z.literal(item) : z.literal(item).optional()));
696
- const schema = jsonSchema.required
697
- ? z.union(enumValues)
698
- : z.any().transform((val) => (!val || val === '' || !jsonSchema.enum.some((v) => v === val) ? undefined : val));
699
- if (jsonSchema.multiple) {
700
- return jsonSchema.required ? schema.array() : schema.array().optional();
701
- }
702
- return jsonSchema.required ? schema : schema.optional();
703
- };
704
- /**
705
- * Creates a Zod object schema from a given JSON schema.
706
- *
707
- * @param jsonSchema - The JSON schema from which the Zod schema should be created.
708
- * @returns - The created Zod object schema.
709
- */
710
- export const createZodObjectSchema = (jsonSchema) => {
711
- let schema;
712
- if (jsonSchema.properties) {
713
- const zodObjectProperties = Object.entries(jsonSchema.properties).reduce((acc, [key, value]) => {
714
- acc[key] = generateZodSchema(value);
715
- return acc;
716
- }, {});
717
- schema = z.object(zodObjectProperties).strict();
718
- }
719
- else {
720
- schema = z.record(z.any());
721
- }
722
- return jsonSchema.required ? schema : schema.optional();
723
- };
724
- /**
725
- * Creates a Zod array schema from a given JSON schema.
726
- *
727
- * @param jsonSchema - The JSON schema from which the Zod schema should be created.
728
- * @returns - The created Zod array schema.
729
- */
730
- export const createZodArraySchema = (jsonSchema) => {
731
- let schema;
732
- if (jsonSchema.items) {
733
- schema = generateZodSchema(jsonSchema.items).array();
734
- }
735
- else {
736
- schema = z.any().array();
737
- }
738
- return jsonSchema.required ? schema : schema.optional();
739
- };
740
- //# sourceMappingURL=schema.js.map