@xyo-network/api 2.75.0 → 2.75.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 (314) hide show
  1. package/dist/browser/Api/Api.d.cts +12 -0
  2. package/dist/browser/Api/Api.d.cts.map +1 -0
  3. package/dist/browser/Api/Api.js +3 -155
  4. package/dist/browser/Api/Api.js.map +1 -1
  5. package/dist/browser/Api/index.d.cts +2 -0
  6. package/dist/browser/Api/index.d.cts.map +1 -0
  7. package/dist/browser/Api/index.js +1 -166
  8. package/dist/browser/Api/index.js.map +1 -1
  9. package/dist/browser/Base.d.cts +32 -0
  10. package/dist/browser/Base.d.cts.map +1 -0
  11. package/dist/browser/Base.js +7 -8
  12. package/dist/browser/Base.js.map +1 -1
  13. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.d.cts +12 -0
  14. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.d.cts.map +1 -0
  15. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.js +5 -16
  16. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.js.map +1 -1
  17. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts +10 -0
  18. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts.map +1 -0
  19. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +2 -3
  20. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +1 -1
  21. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts +5 -0
  22. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts.map +1 -0
  23. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts +12 -0
  24. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts.map +1 -0
  25. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +3 -4
  26. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +1 -1
  27. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts +3 -0
  28. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts.map +1 -0
  29. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +2 -11
  30. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +1 -1
  31. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts +12 -0
  32. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts.map +1 -0
  33. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +3 -4
  34. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +1 -1
  35. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts +2 -0
  36. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts.map +1 -0
  37. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +1 -11
  38. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +1 -1
  39. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts +18 -0
  40. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts.map +1 -0
  41. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts +5 -0
  42. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts.map +1 -0
  43. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts +6 -0
  44. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts.map +1 -0
  45. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +2 -3
  46. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +1 -1
  47. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts +8 -0
  48. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts.map +1 -0
  49. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts +12 -0
  50. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts.map +1 -0
  51. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +3 -4
  52. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +1 -1
  53. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts +3 -0
  54. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts.map +1 -0
  55. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +2 -11
  56. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +1 -1
  57. package/dist/browser/Diviner/LocationDiviner/Queries/index.d.cts +7 -0
  58. package/dist/browser/Diviner/LocationDiviner/Queries/index.d.cts.map +1 -0
  59. package/dist/browser/Diviner/LocationDiviner/Queries/index.js +6 -42
  60. package/dist/browser/Diviner/LocationDiviner/Queries/index.js.map +1 -1
  61. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts +13 -0
  62. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts.map +1 -0
  63. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +1 -2
  64. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +1 -1
  65. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts +21 -0
  66. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts.map +1 -0
  67. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.js +1 -2
  68. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +1 -1
  69. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.d.cts +3 -0
  70. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.d.cts.map +1 -0
  71. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.js +2 -9
  72. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.js.map +1 -1
  73. package/dist/browser/Diviner/LocationDiviner/index.d.cts +5 -0
  74. package/dist/browser/Diviner/LocationDiviner/index.d.cts.map +1 -0
  75. package/dist/browser/Diviner/LocationDiviner/index.js +4 -82
  76. package/dist/browser/Diviner/LocationDiviner/index.js.map +1 -1
  77. package/dist/browser/Diviner/LocationDiviner/models.d.cts +5 -0
  78. package/dist/browser/Diviner/LocationDiviner/models.d.cts.map +1 -0
  79. package/dist/browser/Diviner/RemoteDivinerConfig.d.cts +11 -0
  80. package/dist/browser/Diviner/RemoteDivinerConfig.d.cts.map +1 -0
  81. package/dist/browser/Diviner/RemoteDivinerConfig.js +1 -2
  82. package/dist/browser/Diviner/RemoteDivinerConfig.js.map +1 -1
  83. package/dist/browser/Diviner/RemoteDivinerError.d.cts +6 -0
  84. package/dist/browser/Diviner/RemoteDivinerError.d.cts.map +1 -0
  85. package/dist/browser/Diviner/RemoteDivinerError.js +2 -3
  86. package/dist/browser/Diviner/RemoteDivinerError.js.map +1 -1
  87. package/dist/browser/Diviner/index.d.cts +3 -0
  88. package/dist/browser/Diviner/index.d.cts.map +1 -0
  89. package/dist/browser/Diviner/index.js +2 -86
  90. package/dist/browser/Diviner/index.js.map +1 -1
  91. package/dist/browser/Simple.d.cts +22 -0
  92. package/dist/browser/Simple.d.cts.map +1 -0
  93. package/dist/browser/Simple.js +4 -109
  94. package/dist/browser/Simple.js.map +1 -1
  95. package/dist/browser/Test/index.d.cts +3 -0
  96. package/dist/browser/Test/index.d.cts.map +1 -0
  97. package/dist/browser/Test/index.js +2 -32
  98. package/dist/browser/Test/index.js.map +1 -1
  99. package/dist/browser/Test/testBoundWitness.d.cts +4 -0
  100. package/dist/browser/Test/testBoundWitness.d.cts.map +1 -0
  101. package/dist/browser/Test/testBoundWitness.js +1 -2
  102. package/dist/browser/Test/testBoundWitness.js.map +1 -1
  103. package/dist/browser/Test/testPayload.d.cts +6 -0
  104. package/dist/browser/Test/testPayload.d.cts.map +1 -0
  105. package/dist/browser/Test/testPayload.js +2 -3
  106. package/dist/browser/Test/testPayload.js.map +1 -1
  107. package/dist/browser/WithArchive.d.cts +4 -0
  108. package/dist/browser/WithArchive.d.cts.map +1 -0
  109. package/dist/browser/index.d.cts +7 -0
  110. package/dist/browser/index.d.cts.map +1 -0
  111. package/dist/browser/index.js +6 -253
  112. package/dist/browser/index.js.map +1 -1
  113. package/dist/browser/models/ArchivePath.d.cts +4 -0
  114. package/dist/browser/models/ArchivePath.d.cts.map +1 -0
  115. package/dist/browser/models/index.d.cts +2 -0
  116. package/dist/browser/models/index.d.cts.map +1 -0
  117. package/dist/browser/models/index.js +1 -0
  118. package/dist/browser/models/index.js.map +1 -1
  119. package/dist/browser/objToQuery.d.cts +2 -0
  120. package/dist/browser/objToQuery.d.cts.map +1 -0
  121. package/dist/browser/objToQuery.js +1 -2
  122. package/dist/browser/objToQuery.js.map +1 -1
  123. package/dist/docs.json +16171 -0
  124. package/dist/node/Api/Api.d.cts +12 -0
  125. package/dist/node/Api/Api.d.cts.map +1 -0
  126. package/dist/node/Api/Api.js +161 -4
  127. package/dist/node/Api/Api.js.map +1 -1
  128. package/dist/node/Api/Api.mjs +159 -3
  129. package/dist/node/Api/Api.mjs.map +1 -1
  130. package/dist/node/Api/index.d.cts +2 -0
  131. package/dist/node/Api/index.d.cts.map +1 -0
  132. package/dist/node/Api/index.js +178 -3
  133. package/dist/node/Api/index.js.map +1 -1
  134. package/dist/node/Api/index.mjs +170 -1
  135. package/dist/node/Api/index.mjs.map +1 -1
  136. package/dist/node/Base.d.cts +32 -0
  137. package/dist/node/Base.d.cts.map +1 -0
  138. package/dist/node/Base.js +20 -14
  139. package/dist/node/Base.js.map +1 -1
  140. package/dist/node/Base.mjs +19 -14
  141. package/dist/node/Base.mjs.map +1 -1
  142. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.d.cts +12 -0
  143. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.d.cts.map +1 -0
  144. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.js +18 -6
  145. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.js.map +1 -1
  146. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.mjs +16 -5
  147. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.mjs.map +1 -1
  148. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts +10 -0
  149. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts.map +1 -0
  150. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +4 -2
  151. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +1 -1
  152. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.mjs +3 -2
  153. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.mjs.map +1 -1
  154. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts +5 -0
  155. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts.map +1 -0
  156. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js +2 -0
  157. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js.map +1 -1
  158. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts +12 -0
  159. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts.map +1 -0
  160. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +6 -4
  161. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +1 -1
  162. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.mjs +5 -4
  163. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.mjs.map +1 -1
  164. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts +3 -0
  165. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts.map +1 -0
  166. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +21 -5
  167. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +1 -1
  168. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.mjs +11 -2
  169. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.mjs.map +1 -1
  170. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts +12 -0
  171. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts.map +1 -0
  172. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +6 -4
  173. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +1 -1
  174. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.mjs +5 -4
  175. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.mjs.map +1 -1
  176. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts +2 -0
  177. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts.map +1 -0
  178. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +21 -3
  179. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +1 -1
  180. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.mjs +11 -1
  181. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.mjs.map +1 -1
  182. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts +18 -0
  183. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts.map +1 -0
  184. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js +2 -0
  185. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js.map +1 -1
  186. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts +5 -0
  187. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts.map +1 -0
  188. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js +2 -0
  189. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js.map +1 -1
  190. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts +6 -0
  191. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts.map +1 -0
  192. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +4 -2
  193. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +1 -1
  194. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.mjs +3 -2
  195. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.mjs.map +1 -1
  196. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts +8 -0
  197. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts.map +1 -0
  198. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js +2 -0
  199. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js.map +1 -1
  200. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts +12 -0
  201. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts.map +1 -0
  202. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +6 -4
  203. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +1 -1
  204. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.mjs +5 -4
  205. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.mjs.map +1 -1
  206. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts +3 -0
  207. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts.map +1 -0
  208. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +21 -5
  209. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +1 -1
  210. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.mjs +11 -2
  211. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.mjs.map +1 -1
  212. package/dist/node/Diviner/LocationDiviner/Queries/index.d.cts +7 -0
  213. package/dist/node/Diviner/LocationDiviner/Queries/index.d.cts.map +1 -0
  214. package/dist/node/Diviner/LocationDiviner/Queries/index.js +59 -13
  215. package/dist/node/Diviner/LocationDiviner/Queries/index.js.map +1 -1
  216. package/dist/node/Diviner/LocationDiviner/Queries/index.mjs +42 -6
  217. package/dist/node/Diviner/LocationDiviner/Queries/index.mjs.map +1 -1
  218. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts +13 -0
  219. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts.map +1 -0
  220. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +3 -1
  221. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +1 -1
  222. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.mjs +2 -1
  223. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.mjs.map +1 -1
  224. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts +21 -0
  225. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts.map +1 -0
  226. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.js +3 -1
  227. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +1 -1
  228. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.mjs +2 -1
  229. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.mjs.map +1 -1
  230. package/dist/node/Diviner/LocationDiviner/Witnesses/index.d.cts +3 -0
  231. package/dist/node/Diviner/LocationDiviner/Witnesses/index.d.cts.map +1 -0
  232. package/dist/node/Diviner/LocationDiviner/Witnesses/index.js +18 -5
  233. package/dist/node/Diviner/LocationDiviner/Witnesses/index.js.map +1 -1
  234. package/dist/node/Diviner/LocationDiviner/Witnesses/index.mjs +9 -2
  235. package/dist/node/Diviner/LocationDiviner/Witnesses/index.mjs.map +1 -1
  236. package/dist/node/Diviner/LocationDiviner/index.d.cts +5 -0
  237. package/dist/node/Diviner/LocationDiviner/index.d.cts.map +1 -0
  238. package/dist/node/Diviner/LocationDiviner/index.js +102 -9
  239. package/dist/node/Diviner/LocationDiviner/index.js.map +1 -1
  240. package/dist/node/Diviner/LocationDiviner/index.mjs +82 -4
  241. package/dist/node/Diviner/LocationDiviner/index.mjs.map +1 -1
  242. package/dist/node/Diviner/LocationDiviner/models.d.cts +5 -0
  243. package/dist/node/Diviner/LocationDiviner/models.d.cts.map +1 -0
  244. package/dist/node/Diviner/LocationDiviner/models.js +2 -0
  245. package/dist/node/Diviner/LocationDiviner/models.js.map +1 -1
  246. package/dist/node/Diviner/RemoteDivinerConfig.d.cts +11 -0
  247. package/dist/node/Diviner/RemoteDivinerConfig.d.cts.map +1 -0
  248. package/dist/node/Diviner/RemoteDivinerConfig.js +3 -1
  249. package/dist/node/Diviner/RemoteDivinerConfig.js.map +1 -1
  250. package/dist/node/Diviner/RemoteDivinerConfig.mjs +2 -1
  251. package/dist/node/Diviner/RemoteDivinerConfig.mjs.map +1 -1
  252. package/dist/node/Diviner/RemoteDivinerError.d.cts +6 -0
  253. package/dist/node/Diviner/RemoteDivinerError.d.cts.map +1 -0
  254. package/dist/node/Diviner/RemoteDivinerError.js +4 -2
  255. package/dist/node/Diviner/RemoteDivinerError.js.map +1 -1
  256. package/dist/node/Diviner/RemoteDivinerError.mjs +3 -2
  257. package/dist/node/Diviner/RemoteDivinerError.mjs.map +1 -1
  258. package/dist/node/Diviner/index.d.cts +3 -0
  259. package/dist/node/Diviner/index.d.cts.map +1 -0
  260. package/dist/node/Diviner/index.js +107 -5
  261. package/dist/node/Diviner/index.js.map +1 -1
  262. package/dist/node/Diviner/index.mjs +86 -2
  263. package/dist/node/Diviner/index.mjs.map +1 -1
  264. package/dist/node/Simple.d.cts +22 -0
  265. package/dist/node/Simple.d.cts.map +1 -0
  266. package/dist/node/Simple.js +118 -6
  267. package/dist/node/Simple.js.map +1 -1
  268. package/dist/node/Simple.mjs +113 -4
  269. package/dist/node/Simple.mjs.map +1 -1
  270. package/dist/node/Test/index.d.cts +3 -0
  271. package/dist/node/Test/index.d.cts.map +1 -0
  272. package/dist/node/Test/index.js +42 -5
  273. package/dist/node/Test/index.js.map +1 -1
  274. package/dist/node/Test/index.mjs +32 -2
  275. package/dist/node/Test/index.mjs.map +1 -1
  276. package/dist/node/Test/testBoundWitness.d.cts +4 -0
  277. package/dist/node/Test/testBoundWitness.d.cts.map +1 -0
  278. package/dist/node/Test/testBoundWitness.js +3 -1
  279. package/dist/node/Test/testBoundWitness.js.map +1 -1
  280. package/dist/node/Test/testBoundWitness.mjs +2 -1
  281. package/dist/node/Test/testBoundWitness.mjs.map +1 -1
  282. package/dist/node/Test/testPayload.d.cts +6 -0
  283. package/dist/node/Test/testPayload.d.cts.map +1 -0
  284. package/dist/node/Test/testPayload.js +4 -2
  285. package/dist/node/Test/testPayload.js.map +1 -1
  286. package/dist/node/Test/testPayload.mjs +3 -2
  287. package/dist/node/Test/testPayload.mjs.map +1 -1
  288. package/dist/node/WithArchive.d.cts +4 -0
  289. package/dist/node/WithArchive.d.cts.map +1 -0
  290. package/dist/node/WithArchive.js +2 -0
  291. package/dist/node/WithArchive.js.map +1 -1
  292. package/dist/node/index.d.cts +7 -0
  293. package/dist/node/index.d.cts.map +1 -0
  294. package/dist/node/index.js +281 -13
  295. package/dist/node/index.js.map +1 -1
  296. package/dist/node/index.mjs +257 -6
  297. package/dist/node/index.mjs.map +1 -1
  298. package/dist/node/models/ArchivePath.d.cts +4 -0
  299. package/dist/node/models/ArchivePath.d.cts.map +1 -0
  300. package/dist/node/models/ArchivePath.js +2 -0
  301. package/dist/node/models/ArchivePath.js.map +1 -1
  302. package/dist/node/models/index.d.cts +2 -0
  303. package/dist/node/models/index.d.cts.map +1 -0
  304. package/dist/node/models/index.js +2 -6
  305. package/dist/node/models/index.js.map +1 -1
  306. package/dist/node/models/index.mjs +0 -1
  307. package/dist/node/models/index.mjs.map +1 -1
  308. package/dist/node/objToQuery.d.cts +2 -0
  309. package/dist/node/objToQuery.d.cts.map +1 -0
  310. package/dist/node/objToQuery.js +3 -1
  311. package/dist/node/objToQuery.js.map +1 -1
  312. package/dist/node/objToQuery.mjs +2 -1
  313. package/dist/node/objToQuery.mjs.map +1 -1
  314. package/package.json +12 -12
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -11,15 +15,113 @@ var __copyProps = (to, from, except, desc) => {
11
15
  }
12
16
  return to;
13
17
  };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/Diviner/index.ts
16
21
  var Diviner_exports = {};
22
+ __export(Diviner_exports, {
23
+ CurrentLocationWitnessSchema: () => CurrentLocationWitnessSchema,
24
+ LocationDivinerApi: () => LocationDivinerApi,
25
+ LocationTimeRangeAnswerSchema: () => LocationTimeRangeAnswerSchema,
26
+ LocationTimeRangeQuerySchema: () => LocationTimeRangeQuerySchema,
27
+ LocationWitnessSchema: () => LocationWitnessSchema,
28
+ RemoteDivinerConfigSchema: () => RemoteDivinerConfigSchema,
29
+ isLocationHeatmapQuery: () => isLocationHeatmapQuery,
30
+ isLocationQuadkeyHeatmapQuery: () => isLocationQuadkeyHeatmapQuery,
31
+ isLocationTimeRangeQuery: () => isLocationTimeRangeQuery,
32
+ isSupportedLocationQuerySchema: () => isSupportedLocationQuerySchema,
33
+ locationHeatmapAnswerSchema: () => locationHeatmapAnswerSchema,
34
+ locationHeatmapQuerySchema: () => locationHeatmapQuerySchema,
35
+ locationQuadkeyHeatmapAnswerSchema: () => locationQuadkeyHeatmapAnswerSchema,
36
+ locationQuadkeyHeatmapQuerySchema: () => locationQuadkeyHeatmapQuerySchema
37
+ });
17
38
  module.exports = __toCommonJS(Diviner_exports);
18
- __reExport(Diviner_exports, require("./LocationDiviner"), module.exports);
19
- __reExport(Diviner_exports, require("./RemoteDivinerConfig"), module.exports);
39
+
40
+ // src/Diviner/LocationDiviner/LocationDivinerApi.ts
41
+ var import_axios2 = require("@xyo-network/axios");
42
+
43
+ // src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts
44
+ var import_axios = require("@xyo-network/axios");
45
+ var locationDivinerApiResponseTransformer = (data, _headers) => {
46
+ return data.data;
47
+ };
48
+ var getLocationDivinerApiResponseTransformer = (axiosInstance = import_axios.axios) => {
49
+ return axiosInstance.defaults.transformResponse ? [].concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer) : [locationDivinerApiResponseTransformer];
50
+ };
51
+
52
+ // src/Diviner/LocationDiviner/LocationDivinerApi.ts
53
+ var LocationDivinerApi = class {
54
+ config;
55
+ constructor(config) {
56
+ this.config = config;
57
+ }
58
+ get axiosRequestConfig() {
59
+ return {
60
+ transformResponse: getLocationDivinerApiResponseTransformer()
61
+ };
62
+ }
63
+ async getLocationQuery(hash) {
64
+ return (await import_axios2.axios.get(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data;
65
+ }
66
+ async postLocationQuery(request) {
67
+ return (await import_axios2.axios.post(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data;
68
+ }
69
+ };
70
+
71
+ // src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts
72
+ var locationHeatmapQuerySchema = "network.xyo.location.heatmap.query";
73
+ var locationHeatmapAnswerSchema = "network.xyo.location.heatmap.answer";
74
+ var isLocationHeatmapQuery = (query) => {
75
+ return query && (query == null ? void 0 : query.schema) === locationHeatmapQuerySchema;
76
+ };
77
+
78
+ // src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts
79
+ var locationQuadkeyHeatmapQuerySchema = "network.xyo.location.heatmap.quadkey.query";
80
+ var locationQuadkeyHeatmapAnswerSchema = "network.xyo.location.heatmap.quadkey.answer";
81
+ var isLocationQuadkeyHeatmapQuery = (query) => {
82
+ return query && (query == null ? void 0 : query.schema) === locationQuadkeyHeatmapQuerySchema;
83
+ };
84
+
85
+ // src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts
86
+ var locationQuerySchemas = {
87
+ "network.xyo.location.heatmap.quadkey.query": true,
88
+ "network.xyo.location.heatmap.query": true,
89
+ "network.xyo.location.range.query": true
90
+ };
91
+ var isSupportedLocationQuerySchema = (schema) => {
92
+ return locationQuerySchemas[schema] || false;
93
+ };
94
+
95
+ // src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts
96
+ var LocationTimeRangeQuerySchema = "network.xyo.location.range.query";
97
+ var LocationTimeRangeAnswerSchema = "network.xyo.location.range.answer";
98
+ var isLocationTimeRangeQuery = (query) => {
99
+ return query && (query == null ? void 0 : query.schema) === LocationTimeRangeAnswerSchema;
100
+ };
101
+
102
+ // src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts
103
+ var CurrentLocationWitnessSchema = "co.coinapp.currentlocationwitness";
104
+
105
+ // src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts
106
+ var LocationWitnessSchema = "network.xyo.location";
107
+
108
+ // src/Diviner/RemoteDivinerConfig.ts
109
+ var RemoteDivinerConfigSchema = "network.xyo.diviner.remote.config";
20
110
  // Annotate the CommonJS export names for ESM import in node:
21
111
  0 && (module.exports = {
22
- ...require("./LocationDiviner"),
23
- ...require("./RemoteDivinerConfig")
112
+ CurrentLocationWitnessSchema,
113
+ LocationDivinerApi,
114
+ LocationTimeRangeAnswerSchema,
115
+ LocationTimeRangeQuerySchema,
116
+ LocationWitnessSchema,
117
+ RemoteDivinerConfigSchema,
118
+ isLocationHeatmapQuery,
119
+ isLocationQuadkeyHeatmapQuery,
120
+ isLocationTimeRangeQuery,
121
+ isSupportedLocationQuerySchema,
122
+ locationHeatmapAnswerSchema,
123
+ locationHeatmapQuerySchema,
124
+ locationQuadkeyHeatmapAnswerSchema,
125
+ locationQuadkeyHeatmapQuerySchema
24
126
  });
25
127
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Diviner/index.ts"],"sourcesContent":["export * from './LocationDiviner'\nexport * from './RemoteDivinerConfig'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,8BAAd;AACA,4BAAc,kCADd;","names":[]}
1
+ {"version":3,"sources":["../../../src/Diviner/index.ts","../../../src/Diviner/LocationDiviner/LocationDivinerApi.ts","../../../src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts","../../../src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts","../../../src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts","../../../src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts","../../../src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts","../../../src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts","../../../src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts","../../../src/Diviner/RemoteDivinerConfig.ts"],"sourcesContent":["export * from './LocationDiviner'\nexport * from './RemoteDivinerConfig'\n","import { ApiConfig } from '@xyo-network/api-models'\nimport { axios, RawAxiosRequestConfig } from '@xyo-network/axios'\n\nimport { getLocationDivinerApiResponseTransformer } from './LocationDivinerApiResponseTransformer'\nimport { GetLocationQueryResponse } from './models'\nimport { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries'\n\nclass LocationDivinerApi {\n config: ApiConfig\n constructor(config: ApiConfig) {\n this.config = config\n }\n\n private get axiosRequestConfig(): RawAxiosRequestConfig {\n return {\n transformResponse: getLocationDivinerApiResponseTransformer(),\n }\n }\n\n async getLocationQuery(hash: string) {\n return (await axios.get<GetLocationQueryResponse>(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data\n }\n\n async postLocationQuery(request: SupportedLocationQueryCreationRequest) {\n return (await axios.post<LocationQueryCreationResponse>(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data\n }\n}\n\nexport { LocationDivinerApi }\n","import { axios, AxiosResponseTransformer } from '@xyo-network/axios'\n\nexport const locationDivinerApiResponseTransformer: AxiosResponseTransformer = (data, _headers) => {\n return data.data\n}\n\n/**\n * Gets the response transformers for the LocationDiviner API. Done as a method instead of a property\n * to allow detection of dynamically added response transformers.\n * @param axiosInstance The axios instance (defaults to the global instance if none provided)\n * @returns the response transformers for the LocationDiviner API\n */\nexport const getLocationDivinerApiResponseTransformer = (axiosInstance = axios): AxiosResponseTransformer[] => {\n // If there's any existing response transforms preserve them and\n // append our response transform, otherwise just return ours\n return axiosInstance.defaults.transformResponse\n ? ([] as AxiosResponseTransformer[]).concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer)\n : [locationDivinerApiResponseTransformer]\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\nexport const locationHeatmapQuerySchema: LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\n\nexport type LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\nexport const locationHeatmapAnswerSchema: LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\n\nexport type LocationHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationHeatmapQuery = (query: Record<string, unknown>): query is LocationHeatmapQuery => {\n return query && query?.schema === locationHeatmapQuerySchema\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport const locationQuadkeyHeatmapQuerySchema: LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport type LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport const locationQuadkeyHeatmapAnswerSchema: LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport type LocationQuadkeyHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationQuadkeyHeatmapQuery = (query: Record<string, unknown>): query is LocationQuadkeyHeatmapQuery => {\n return query && query?.schema === locationQuadkeyHeatmapQuerySchema\n}\n","import { LocationHeatmapQuerySchema } from './LocationHeatmapQuery'\nimport { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery'\nimport { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<LocationQuerySchema, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: string): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema] || false\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\nexport const LocationTimeRangeQuerySchema: LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\n\nexport type LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\nexport const LocationTimeRangeAnswerSchema: LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\n\nexport type LocationTimeRangeQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n\n // TODO: Bounding rectangle, etc.\n}\n\nexport const isLocationTimeRangeQuery = (query: Record<string, unknown>): query is LocationTimeRangeQuery => {\n return query && query?.schema === LocationTimeRangeAnswerSchema\n}\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\nexport const CurrentLocationWitnessSchema: CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\n\nexport type CurrentLocationWitnessPayload = Payload<{\n altitudeMeters: number\n directionDegrees: number\n latitude: number\n longitude: number\n quadkey: string\n schema: CurrentLocationWitnessSchema\n speedKph: number\n}>\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type LocationWitnessSchema = 'network.xyo.location'\nexport const LocationWitnessSchema: LocationWitnessSchema = 'network.xyo.location'\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport type LocationWitnessPayload = Payload<{\n currentLocation: CurrentLocation\n schema: LocationWitnessSchema\n}>\n","import { DivinerConfig } from '@xyo-network/diviner-model'\n\nimport { ArchivistApi } from '../Api'\n\nexport type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\nexport const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\n\nexport type RemoteDivinerConfig = DivinerConfig & {\n /** @deprecated use in params instead */\n api?: ArchivistApi\n archive?: string\n schema: RemoteDivinerConfigSchema\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAA6C;;;ACD7C,mBAAgD;AAEzC,IAAM,wCAAkE,CAAC,MAAM,aAAa;AACjG,SAAO,KAAK;AACd;AAQO,IAAM,2CAA2C,CAAC,gBAAgB,uBAAsC;AAG7G,SAAO,cAAc,SAAS,oBACzB,CAAC,EAAiC,OAAO,cAAc,SAAS,mBAAmB,qCAAqC,IACzH,CAAC,qCAAqC;AAC5C;;;ADXA,IAAM,qBAAN,MAAyB;AAAA,EACvB;AAAA,EACA,YAAY,QAAmB;AAC7B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,IAAY,qBAA4C;AACtD,WAAO;AAAA,MACL,mBAAmB,yCAAyC;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,MAAc;AACnC,YAAQ,MAAM,oBAAM,IAA8B,GAAG,KAAK,OAAO,SAAS,mBAAmB,IAAI,IAAI,KAAK,kBAAkB,GAAG;AAAA,EACjI;AAAA,EAEA,MAAM,kBAAkB,SAAgD;AACtE,YAAQ,MAAM,oBAAM,KAAoC,GAAG,KAAK,OAAO,SAAS,mBAAmB,EAAE,GAAG,QAAQ,GAAG,KAAK,kBAAkB,GAAG;AAAA,EAC/I;AACF;;;AEvBO,IAAM,6BAAyD;AAG/D,IAAM,8BAA2D;AAQjE,IAAM,yBAAyB,CAAC,UAAkE;AACvG,SAAO,UAAS,+BAAO,YAAW;AACpC;;;ACbO,IAAM,oCAAuE;AAE7E,IAAM,qCAAyE;AAO/E,IAAM,gCAAgC,CAAC,UAAyE;AACrH,SAAO,UAAS,+BAAO,YAAW;AACpC;;;ACRA,IAAM,uBAA0D;AAAA,EAC9D,8CAA8C;AAAA,EAC9C,sCAAsC;AAAA,EACtC,oCAAoC;AACtC;AAEO,IAAM,iCAAiC,CAAC,WAAkD;AAC/F,SAAO,qBAAqB,MAA6B,KAAK;AAChE;;;ACXO,IAAM,+BAA6D;AAGnE,IAAM,gCAA+D;AAUrE,IAAM,2BAA2B,CAAC,UAAoE;AAC3G,SAAO,UAAS,+BAAO,YAAW;AACpC;;;ACfO,IAAM,+BAA6D;;;ACAnE,IAAM,wBAA+C;;;ACErD,IAAM,4BAAuD;","names":["import_axios"]}
@@ -1,3 +1,87 @@
1
- export * from "./LocationDiviner";
2
- export * from "./RemoteDivinerConfig";
1
+ // src/Diviner/LocationDiviner/LocationDivinerApi.ts
2
+ import { axios as axios2 } from "@xyo-network/axios";
3
+
4
+ // src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts
5
+ import { axios } from "@xyo-network/axios";
6
+ var locationDivinerApiResponseTransformer = (data, _headers) => {
7
+ return data.data;
8
+ };
9
+ var getLocationDivinerApiResponseTransformer = (axiosInstance = axios) => {
10
+ return axiosInstance.defaults.transformResponse ? [].concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer) : [locationDivinerApiResponseTransformer];
11
+ };
12
+
13
+ // src/Diviner/LocationDiviner/LocationDivinerApi.ts
14
+ var LocationDivinerApi = class {
15
+ config;
16
+ constructor(config) {
17
+ this.config = config;
18
+ }
19
+ get axiosRequestConfig() {
20
+ return {
21
+ transformResponse: getLocationDivinerApiResponseTransformer()
22
+ };
23
+ }
24
+ async getLocationQuery(hash) {
25
+ return (await axios2.get(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data;
26
+ }
27
+ async postLocationQuery(request) {
28
+ return (await axios2.post(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data;
29
+ }
30
+ };
31
+
32
+ // src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts
33
+ var locationHeatmapQuerySchema = "network.xyo.location.heatmap.query";
34
+ var locationHeatmapAnswerSchema = "network.xyo.location.heatmap.answer";
35
+ var isLocationHeatmapQuery = (query) => {
36
+ return query && (query == null ? void 0 : query.schema) === locationHeatmapQuerySchema;
37
+ };
38
+
39
+ // src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts
40
+ var locationQuadkeyHeatmapQuerySchema = "network.xyo.location.heatmap.quadkey.query";
41
+ var locationQuadkeyHeatmapAnswerSchema = "network.xyo.location.heatmap.quadkey.answer";
42
+ var isLocationQuadkeyHeatmapQuery = (query) => {
43
+ return query && (query == null ? void 0 : query.schema) === locationQuadkeyHeatmapQuerySchema;
44
+ };
45
+
46
+ // src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts
47
+ var locationQuerySchemas = {
48
+ "network.xyo.location.heatmap.quadkey.query": true,
49
+ "network.xyo.location.heatmap.query": true,
50
+ "network.xyo.location.range.query": true
51
+ };
52
+ var isSupportedLocationQuerySchema = (schema) => {
53
+ return locationQuerySchemas[schema] || false;
54
+ };
55
+
56
+ // src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts
57
+ var LocationTimeRangeQuerySchema = "network.xyo.location.range.query";
58
+ var LocationTimeRangeAnswerSchema = "network.xyo.location.range.answer";
59
+ var isLocationTimeRangeQuery = (query) => {
60
+ return query && (query == null ? void 0 : query.schema) === LocationTimeRangeAnswerSchema;
61
+ };
62
+
63
+ // src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts
64
+ var CurrentLocationWitnessSchema = "co.coinapp.currentlocationwitness";
65
+
66
+ // src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts
67
+ var LocationWitnessSchema = "network.xyo.location";
68
+
69
+ // src/Diviner/RemoteDivinerConfig.ts
70
+ var RemoteDivinerConfigSchema = "network.xyo.diviner.remote.config";
71
+ export {
72
+ CurrentLocationWitnessSchema,
73
+ LocationDivinerApi,
74
+ LocationTimeRangeAnswerSchema,
75
+ LocationTimeRangeQuerySchema,
76
+ LocationWitnessSchema,
77
+ RemoteDivinerConfigSchema,
78
+ isLocationHeatmapQuery,
79
+ isLocationQuadkeyHeatmapQuery,
80
+ isLocationTimeRangeQuery,
81
+ isSupportedLocationQuerySchema,
82
+ locationHeatmapAnswerSchema,
83
+ locationHeatmapQuerySchema,
84
+ locationQuadkeyHeatmapAnswerSchema,
85
+ locationQuadkeyHeatmapQuerySchema
86
+ };
3
87
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Diviner/index.ts"],"sourcesContent":["export * from './LocationDiviner'\nexport * from './RemoteDivinerConfig'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/Diviner/LocationDiviner/LocationDivinerApi.ts","../../../src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts","../../../src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts","../../../src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts","../../../src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts","../../../src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts","../../../src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts","../../../src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts","../../../src/Diviner/RemoteDivinerConfig.ts"],"sourcesContent":["import { ApiConfig } from '@xyo-network/api-models'\nimport { axios, RawAxiosRequestConfig } from '@xyo-network/axios'\n\nimport { getLocationDivinerApiResponseTransformer } from './LocationDivinerApiResponseTransformer'\nimport { GetLocationQueryResponse } from './models'\nimport { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries'\n\nclass LocationDivinerApi {\n config: ApiConfig\n constructor(config: ApiConfig) {\n this.config = config\n }\n\n private get axiosRequestConfig(): RawAxiosRequestConfig {\n return {\n transformResponse: getLocationDivinerApiResponseTransformer(),\n }\n }\n\n async getLocationQuery(hash: string) {\n return (await axios.get<GetLocationQueryResponse>(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data\n }\n\n async postLocationQuery(request: SupportedLocationQueryCreationRequest) {\n return (await axios.post<LocationQueryCreationResponse>(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data\n }\n}\n\nexport { LocationDivinerApi }\n","import { axios, AxiosResponseTransformer } from '@xyo-network/axios'\n\nexport const locationDivinerApiResponseTransformer: AxiosResponseTransformer = (data, _headers) => {\n return data.data\n}\n\n/**\n * Gets the response transformers for the LocationDiviner API. Done as a method instead of a property\n * to allow detection of dynamically added response transformers.\n * @param axiosInstance The axios instance (defaults to the global instance if none provided)\n * @returns the response transformers for the LocationDiviner API\n */\nexport const getLocationDivinerApiResponseTransformer = (axiosInstance = axios): AxiosResponseTransformer[] => {\n // If there's any existing response transforms preserve them and\n // append our response transform, otherwise just return ours\n return axiosInstance.defaults.transformResponse\n ? ([] as AxiosResponseTransformer[]).concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer)\n : [locationDivinerApiResponseTransformer]\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\nexport const locationHeatmapQuerySchema: LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\n\nexport type LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\nexport const locationHeatmapAnswerSchema: LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\n\nexport type LocationHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationHeatmapQuery = (query: Record<string, unknown>): query is LocationHeatmapQuery => {\n return query && query?.schema === locationHeatmapQuerySchema\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport const locationQuadkeyHeatmapQuerySchema: LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport type LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport const locationQuadkeyHeatmapAnswerSchema: LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport type LocationQuadkeyHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationQuadkeyHeatmapQuery = (query: Record<string, unknown>): query is LocationQuadkeyHeatmapQuery => {\n return query && query?.schema === locationQuadkeyHeatmapQuerySchema\n}\n","import { LocationHeatmapQuerySchema } from './LocationHeatmapQuery'\nimport { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery'\nimport { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<LocationQuerySchema, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: string): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema] || false\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\nexport const LocationTimeRangeQuerySchema: LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\n\nexport type LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\nexport const LocationTimeRangeAnswerSchema: LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\n\nexport type LocationTimeRangeQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n\n // TODO: Bounding rectangle, etc.\n}\n\nexport const isLocationTimeRangeQuery = (query: Record<string, unknown>): query is LocationTimeRangeQuery => {\n return query && query?.schema === LocationTimeRangeAnswerSchema\n}\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\nexport const CurrentLocationWitnessSchema: CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\n\nexport type CurrentLocationWitnessPayload = Payload<{\n altitudeMeters: number\n directionDegrees: number\n latitude: number\n longitude: number\n quadkey: string\n schema: CurrentLocationWitnessSchema\n speedKph: number\n}>\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type LocationWitnessSchema = 'network.xyo.location'\nexport const LocationWitnessSchema: LocationWitnessSchema = 'network.xyo.location'\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport type LocationWitnessPayload = Payload<{\n currentLocation: CurrentLocation\n schema: LocationWitnessSchema\n}>\n","import { DivinerConfig } from '@xyo-network/diviner-model'\n\nimport { ArchivistApi } from '../Api'\n\nexport type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\nexport const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\n\nexport type RemoteDivinerConfig = DivinerConfig & {\n /** @deprecated use in params instead */\n api?: ArchivistApi\n archive?: string\n schema: RemoteDivinerConfigSchema\n}\n"],"mappings":";AACA,SAAS,SAAAA,cAAoC;;;ACD7C,SAAS,aAAuC;AAEzC,IAAM,wCAAkE,CAAC,MAAM,aAAa;AACjG,SAAO,KAAK;AACd;AAQO,IAAM,2CAA2C,CAAC,gBAAgB,UAAsC;AAG7G,SAAO,cAAc,SAAS,oBACzB,CAAC,EAAiC,OAAO,cAAc,SAAS,mBAAmB,qCAAqC,IACzH,CAAC,qCAAqC;AAC5C;;;ADXA,IAAM,qBAAN,MAAyB;AAAA,EACvB;AAAA,EACA,YAAY,QAAmB;AAC7B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,IAAY,qBAA4C;AACtD,WAAO;AAAA,MACL,mBAAmB,yCAAyC;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,MAAc;AACnC,YAAQ,MAAMC,OAAM,IAA8B,GAAG,KAAK,OAAO,SAAS,mBAAmB,IAAI,IAAI,KAAK,kBAAkB,GAAG;AAAA,EACjI;AAAA,EAEA,MAAM,kBAAkB,SAAgD;AACtE,YAAQ,MAAMA,OAAM,KAAoC,GAAG,KAAK,OAAO,SAAS,mBAAmB,EAAE,GAAG,QAAQ,GAAG,KAAK,kBAAkB,GAAG;AAAA,EAC/I;AACF;;;AEvBO,IAAM,6BAAyD;AAG/D,IAAM,8BAA2D;AAQjE,IAAM,yBAAyB,CAAC,UAAkE;AACvG,SAAO,UAAS,+BAAO,YAAW;AACpC;;;ACbO,IAAM,oCAAuE;AAE7E,IAAM,qCAAyE;AAO/E,IAAM,gCAAgC,CAAC,UAAyE;AACrH,SAAO,UAAS,+BAAO,YAAW;AACpC;;;ACRA,IAAM,uBAA0D;AAAA,EAC9D,8CAA8C;AAAA,EAC9C,sCAAsC;AAAA,EACtC,oCAAoC;AACtC;AAEO,IAAM,iCAAiC,CAAC,WAAkD;AAC/F,SAAO,qBAAqB,MAA6B,KAAK;AAChE;;;ACXO,IAAM,+BAA6D;AAGnE,IAAM,gCAA+D;AAUrE,IAAM,2BAA2B,CAAC,UAAoE;AAC3G,SAAO,UAAS,+BAAO,YAAW;AACpC;;;ACfO,IAAM,+BAA6D;;;ACAnE,IAAM,wBAA+C;;;ACErD,IAAM,4BAAuD;","names":["axios","axios"]}
@@ -0,0 +1,22 @@
1
+ import { ApiConfig, ApiResponseBody, ApiResponseTuple } from '@xyo-network/api-models';
2
+ import { Payload, PayloadFindFilter } from '@xyo-network/payload-model';
3
+ import { ApiBase } from './Base';
4
+ export type ApiSimpleQuery = PayloadFindFilter;
5
+ export declare class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {
6
+ delete(): Promise<ApiResponseBody<T>>;
7
+ delete(responseType?: 'body'): Promise<ApiResponseBody<T>>;
8
+ delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
9
+ find(query?: Q): Promise<ApiResponseBody<T>>;
10
+ find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>;
11
+ find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
12
+ get(): Promise<ApiResponseBody<T>>;
13
+ get(responseType?: 'body'): Promise<ApiResponseBody<T>>;
14
+ get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
15
+ post(data?: D): Promise<ApiResponseBody<T>>;
16
+ post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
17
+ post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
18
+ put(data?: D): Promise<ApiResponseBody<T>>;
19
+ put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
20
+ put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
21
+ }
22
+ //# sourceMappingURL=Simple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Simple.d.ts","sourceRoot":"","sources":["../../src/Simple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAA2C,MAAM,yBAAyB,CAAA;AAC/H,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAGhC,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAE9C,qBAAa,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IACjI,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAU5D,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACnE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAUrE,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAClC,GAAG,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACvD,GAAG,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAUzD,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAUpE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1C,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACjE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAS1E"}
@@ -16,14 +16,126 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/Simple.ts
19
21
  var Simple_exports = {};
20
22
  __export(Simple_exports, {
21
23
  ApiSimple: () => ApiSimple
22
24
  });
23
25
  module.exports = __toCommonJS(Simple_exports);
24
- var import_Base = require("./Base");
25
- var import_objToQuery = require("./objToQuery");
26
- class ApiSimple extends import_Base.ApiBase {
26
+
27
+ // src/Base.ts
28
+ var import_axios = require("@xyo-network/axios");
29
+ var ApiBase = class _ApiBase {
30
+ config;
31
+ axios;
32
+ constructor(config) {
33
+ this.config = config;
34
+ this.axios = new import_axios.AxiosJson({ ...this.config, headers: this.headers });
35
+ }
36
+ get authenticated() {
37
+ return !!this.config.apiKey || !!this.config.jwtToken;
38
+ }
39
+ get headers() {
40
+ const headers = {};
41
+ if (this.config.jwtToken) {
42
+ headers.Authorization = `Bearer ${this.config.jwtToken}`;
43
+ }
44
+ if (this.config.apiKey) {
45
+ headers["x-api-key"] = this.config.apiKey;
46
+ }
47
+ return headers;
48
+ }
49
+ get query() {
50
+ return this.config.query ?? "";
51
+ }
52
+ get root() {
53
+ return this.config.root ?? "/";
54
+ }
55
+ static resolveResponse(result) {
56
+ var _a;
57
+ return [(_a = result == null ? void 0 : result.data) == null ? void 0 : _a.data, result == null ? void 0 : result.data, result];
58
+ }
59
+ static shapeResponse(response, responseType) {
60
+ const resolvedResponse = _ApiBase.resolveResponse(response);
61
+ return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
62
+ }
63
+ onError(error, depth = 0) {
64
+ var _a, _b, _c, _d;
65
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error, depth + 1);
66
+ (_d = (_c = this.config).onError) == null ? void 0 : _d.call(_c, error, depth);
67
+ }
68
+ onFailure(response, depth = 0) {
69
+ var _a, _b, _c, _d;
70
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onFailure) == null ? void 0 : _b.call(_a, response, depth + 1);
71
+ (_d = (_c = this.config).onFailure) == null ? void 0 : _d.call(_c, response, depth);
72
+ }
73
+ onSuccess(response, depth = 0) {
74
+ var _a, _b, _c, _d;
75
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onSuccess) == null ? void 0 : _b.call(_a, response, depth + 1);
76
+ (_d = (_c = this.config).onSuccess) == null ? void 0 : _d.call(_c, response, depth);
77
+ }
78
+ async deleteEndpoint(endPoint = "", responseType) {
79
+ const response = await this.monitorResponse(async () => {
80
+ return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
81
+ });
82
+ return _ApiBase.shapeResponse(response, responseType);
83
+ }
84
+ async getEndpoint(endPoint = "", responseType) {
85
+ const response = await this.monitorResponse(async () => {
86
+ return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
87
+ });
88
+ return _ApiBase.shapeResponse(response, responseType);
89
+ }
90
+ handleMonitorResponseError(error, trapAxiosException) {
91
+ if (!error.isError) {
92
+ throw error;
93
+ }
94
+ if (trapAxiosException) {
95
+ error.response ? this.onFailure(error.response) : this.onError(error);
96
+ if (this.config.throwFailure) {
97
+ throw error;
98
+ }
99
+ return error.response;
100
+ }
101
+ }
102
+ async monitorResponse(closure) {
103
+ let trapAxiosException = true;
104
+ try {
105
+ const response = await closure();
106
+ trapAxiosException = false;
107
+ response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
108
+ return response;
109
+ } catch (ex) {
110
+ this.handleMonitorResponseError(ex, trapAxiosException);
111
+ }
112
+ }
113
+ async postEndpoint(endPoint = "", data, responseType) {
114
+ const response = await this.monitorResponse(async () => {
115
+ return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
116
+ });
117
+ return _ApiBase.shapeResponse(response, responseType);
118
+ }
119
+ async putEndpoint(endPoint = "", data, responseType) {
120
+ const response = await this.monitorResponse(async () => {
121
+ return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
122
+ });
123
+ return _ApiBase.shapeResponse(response, responseType);
124
+ }
125
+ resolveRoot() {
126
+ return `${this.config.apiDomain}${this.root}`;
127
+ }
128
+ };
129
+
130
+ // src/objToQuery.ts
131
+ var objToQuery = (obj) => {
132
+ return `?${Object.entries(obj).map(([key, value]) => {
133
+ return `${key}=${value}`;
134
+ }).filter((value) => value !== void 0).join("&")}`;
135
+ };
136
+
137
+ // src/Simple.ts
138
+ var ApiSimple = class extends ApiBase {
27
139
  async delete(responseType) {
28
140
  switch (responseType) {
29
141
  case "tuple":
@@ -35,9 +147,9 @@ class ApiSimple extends import_Base.ApiBase {
35
147
  async find(query = {}, responseType) {
36
148
  switch (responseType) {
37
149
  case "tuple":
38
- return await this.getEndpoint((0, import_objToQuery.objToQuery)(query), "tuple");
150
+ return await this.getEndpoint(objToQuery(query), "tuple");
39
151
  default:
40
- return await this.getEndpoint((0, import_objToQuery.objToQuery)(query));
152
+ return await this.getEndpoint(objToQuery(query));
41
153
  }
42
154
  }
43
155
  async get(responseType) {
@@ -64,7 +176,7 @@ class ApiSimple extends import_Base.ApiBase {
64
176
  return await this.putEndpoint(void 0, data);
65
177
  }
66
178
  }
67
- }
179
+ };
68
180
  // Annotate the CommonJS export names for ESM import in node:
69
181
  0 && (module.exports = {
70
182
  ApiSimple
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Simple.ts"],"sourcesContent":["import { ApiConfig, ApiResponseBody, ApiResponseTuple, ApiResponseTupleOrBody, ApiResponseType } from '@xyo-network/api-models'\nimport { Payload, PayloadFindFilter } from '@xyo-network/payload-model'\n\nimport { ApiBase } from './Base'\nimport { objToQuery } from './objToQuery'\n\nexport type ApiSimpleQuery = PayloadFindFilter\n\nexport class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {\n async delete(): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async delete(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.deleteEndpoint(undefined, 'tuple')\n default:\n return await this.deleteEndpoint(undefined)\n }\n }\n\n async find(query?: Q): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async find(query = {}, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(objToQuery(query), 'tuple')\n default:\n return await this.getEndpoint(objToQuery(query))\n }\n }\n\n async get(): Promise<ApiResponseBody<T>>\n async get(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async get(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(undefined, 'tuple')\n default:\n return await this.getEndpoint(undefined)\n }\n }\n\n async post(data?: D): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async post(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.postEndpoint(undefined, data, 'tuple')\n default:\n return await this.postEndpoint(undefined, data)\n }\n }\n\n async put(data?: D): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async put(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.putEndpoint(undefined, data, 'tuple')\n default:\n return await this.putEndpoint(undefined, data)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAwB;AACxB,wBAA2B;AAIpB,MAAM,kBAAkH,oBAAW;AAAA,EAIxI,MAAM,OAAO,cAAoE;AAC/E,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,eAAe,QAAW,OAAO;AAAA,MACrD;AACE,eAAO,MAAM,KAAK,eAAe,MAAS;AAAA,IAC9C;AAAA,EACF;AAAA,EAKA,MAAM,KAAK,QAAQ,CAAC,GAAG,cAAoE;AACzF,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,gBAAY,8BAAW,KAAK,GAAG,OAAO;AAAA,MAC1D;AACE,eAAO,MAAM,KAAK,gBAAY,8BAAW,KAAK,CAAC;AAAA,IACnD;AAAA,EACF;AAAA,EAKA,MAAM,IAAI,cAAoE;AAC5E,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,YAAY,QAAW,OAAO;AAAA,MAClD;AACE,eAAO,MAAM,KAAK,YAAY,MAAS;AAAA,IAC3C;AAAA,EACF;AAAA,EAKA,MAAM,KAAK,MAAU,cAAoE;AACvF,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,aAAa,QAAW,MAAM,OAAO;AAAA,MACzD;AACE,eAAO,MAAM,KAAK,aAAa,QAAW,IAAI;AAAA,IAClD;AAAA,EACF;AAAA,EAKA,MAAM,IAAI,MAAU,cAAoE;AACtF,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,YAAY,QAAW,MAAM,OAAO;AAAA,MACxD;AACE,eAAO,MAAM,KAAK,YAAY,QAAW,IAAI;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/Simple.ts","../../src/Base.ts","../../src/objToQuery.ts"],"sourcesContent":["import { ApiConfig, ApiResponseBody, ApiResponseTuple, ApiResponseTupleOrBody, ApiResponseType } from '@xyo-network/api-models'\nimport { Payload, PayloadFindFilter } from '@xyo-network/payload-model'\n\nimport { ApiBase } from './Base'\nimport { objToQuery } from './objToQuery'\n\nexport type ApiSimpleQuery = PayloadFindFilter\n\nexport class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {\n async delete(): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async delete(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.deleteEndpoint(undefined, 'tuple')\n default:\n return await this.deleteEndpoint(undefined)\n }\n }\n\n async find(query?: Q): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async find(query = {}, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(objToQuery(query), 'tuple')\n default:\n return await this.getEndpoint(objToQuery(query))\n }\n }\n\n async get(): Promise<ApiResponseBody<T>>\n async get(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async get(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(undefined, 'tuple')\n default:\n return await this.getEndpoint(undefined)\n }\n }\n\n async post(data?: D): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async post(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.postEndpoint(undefined, data, 'tuple')\n default:\n return await this.postEndpoint(undefined, data)\n }\n }\n\n async put(data?: D): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async put(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.putEndpoint(undefined, data, 'tuple')\n default:\n return await this.putEndpoint(undefined, data)\n }\n }\n}\n","import {\n ApiConfig,\n ApiEnvelope,\n ApiError,\n ApiReportable,\n ApiResponse,\n ApiResponseBody,\n ApiResponseTuple,\n ApiResponseTupleOrBody,\n ApiResponseType,\n} from '@xyo-network/api-models'\nimport { AxiosJson } from '@xyo-network/axios'\n\nexport class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {\n readonly config: C\n protected axios: AxiosJson\n\n constructor(config: C) {\n this.config = config\n this.axios = new AxiosJson({ ...this.config, headers: this.headers })\n }\n\n get authenticated() {\n return !!this.config.apiKey || !!this.config.jwtToken\n }\n\n protected get headers(): Record<string, string> {\n const headers: Record<string, string> = {}\n if (this.config.jwtToken) {\n headers.Authorization = `Bearer ${this.config.jwtToken}`\n }\n if (this.config.apiKey) {\n headers['x-api-key'] = this.config.apiKey\n }\n return headers\n }\n\n protected get query() {\n return this.config.query ?? ''\n }\n\n protected get root() {\n return this.config.root ?? '/'\n }\n\n private static resolveResponse<T>(result?: ApiResponse<ApiEnvelope<T>>) {\n return [result?.data?.data, result?.data, result] as ApiResponseTuple<T>\n }\n\n private static shapeResponse<T = unknown>(response: ApiResponse<ApiEnvelope<T>> | undefined, responseType?: ApiResponseType) {\n const resolvedResponse = ApiBase.resolveResponse(response)\n return responseType === 'tuple' ? resolvedResponse : resolvedResponse[0]\n }\n\n onError(error: ApiError, depth = 0) {\n this.config.reportableParent?.onError?.(error, depth + 1)\n this.config.onError?.(error, depth)\n }\n\n onFailure(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onFailure?.(response, depth + 1)\n this.config.onFailure?.(response, depth)\n }\n\n onSuccess(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onSuccess?.(response, depth + 1)\n this.config.onSuccess?.(response, depth)\n }\n\n protected async deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async deleteEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.delete<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async getEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.get<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean) {\n if (!error.isError) {\n throw error\n }\n\n if (trapAxiosException) {\n error.response ? this.onFailure(error.response) : this.onError(error)\n if (this.config.throwFailure) {\n throw error\n }\n return error.response as ApiResponse<ApiEnvelope<T>>\n }\n }\n\n protected async monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>) {\n //we use this to prevent accidental catching on exceptions in callbacks\n let trapAxiosException = true\n try {\n const response = await closure()\n trapAxiosException = false\n\n response.status < 300 ? this.onSuccess(response) : this.onFailure(response)\n\n return response\n } catch (ex) {\n this.handleMonitorResponseError(ex as ApiError, trapAxiosException)\n }\n }\n\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async postEndpoint<T = unknown, D = unknown>(\n endPoint = '',\n data?: D,\n responseType?: ApiResponseType,\n ): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.post<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint = '', data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.put<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n private resolveRoot() {\n return `${this.config.apiDomain}${this.root}`\n }\n}\n","export const objToQuery = (obj: Record<string, string | number | undefined>) => {\n return `?${Object.entries(obj)\n .map(([key, value]) => {\n return `${key}=${value}`\n })\n .filter((value) => value !== undefined)\n .join('&')}`\n}\n"],"mappings":"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","names":[]}
@@ -1,6 +1,115 @@
1
- import { ApiBase } from "./Base";
2
- import { objToQuery } from "./objToQuery";
3
- class ApiSimple extends ApiBase {
1
+ // src/Base.ts
2
+ import { AxiosJson } from "@xyo-network/axios";
3
+ var ApiBase = class _ApiBase {
4
+ config;
5
+ axios;
6
+ constructor(config) {
7
+ this.config = config;
8
+ this.axios = new AxiosJson({ ...this.config, headers: this.headers });
9
+ }
10
+ get authenticated() {
11
+ return !!this.config.apiKey || !!this.config.jwtToken;
12
+ }
13
+ get headers() {
14
+ const headers = {};
15
+ if (this.config.jwtToken) {
16
+ headers.Authorization = `Bearer ${this.config.jwtToken}`;
17
+ }
18
+ if (this.config.apiKey) {
19
+ headers["x-api-key"] = this.config.apiKey;
20
+ }
21
+ return headers;
22
+ }
23
+ get query() {
24
+ return this.config.query ?? "";
25
+ }
26
+ get root() {
27
+ return this.config.root ?? "/";
28
+ }
29
+ static resolveResponse(result) {
30
+ var _a;
31
+ return [(_a = result == null ? void 0 : result.data) == null ? void 0 : _a.data, result == null ? void 0 : result.data, result];
32
+ }
33
+ static shapeResponse(response, responseType) {
34
+ const resolvedResponse = _ApiBase.resolveResponse(response);
35
+ return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
36
+ }
37
+ onError(error, depth = 0) {
38
+ var _a, _b, _c, _d;
39
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error, depth + 1);
40
+ (_d = (_c = this.config).onError) == null ? void 0 : _d.call(_c, error, depth);
41
+ }
42
+ onFailure(response, depth = 0) {
43
+ var _a, _b, _c, _d;
44
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onFailure) == null ? void 0 : _b.call(_a, response, depth + 1);
45
+ (_d = (_c = this.config).onFailure) == null ? void 0 : _d.call(_c, response, depth);
46
+ }
47
+ onSuccess(response, depth = 0) {
48
+ var _a, _b, _c, _d;
49
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onSuccess) == null ? void 0 : _b.call(_a, response, depth + 1);
50
+ (_d = (_c = this.config).onSuccess) == null ? void 0 : _d.call(_c, response, depth);
51
+ }
52
+ async deleteEndpoint(endPoint = "", responseType) {
53
+ const response = await this.monitorResponse(async () => {
54
+ return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
55
+ });
56
+ return _ApiBase.shapeResponse(response, responseType);
57
+ }
58
+ async getEndpoint(endPoint = "", responseType) {
59
+ const response = await this.monitorResponse(async () => {
60
+ return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
61
+ });
62
+ return _ApiBase.shapeResponse(response, responseType);
63
+ }
64
+ handleMonitorResponseError(error, trapAxiosException) {
65
+ if (!error.isError) {
66
+ throw error;
67
+ }
68
+ if (trapAxiosException) {
69
+ error.response ? this.onFailure(error.response) : this.onError(error);
70
+ if (this.config.throwFailure) {
71
+ throw error;
72
+ }
73
+ return error.response;
74
+ }
75
+ }
76
+ async monitorResponse(closure) {
77
+ let trapAxiosException = true;
78
+ try {
79
+ const response = await closure();
80
+ trapAxiosException = false;
81
+ response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
82
+ return response;
83
+ } catch (ex) {
84
+ this.handleMonitorResponseError(ex, trapAxiosException);
85
+ }
86
+ }
87
+ async postEndpoint(endPoint = "", data, responseType) {
88
+ const response = await this.monitorResponse(async () => {
89
+ return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
90
+ });
91
+ return _ApiBase.shapeResponse(response, responseType);
92
+ }
93
+ async putEndpoint(endPoint = "", data, responseType) {
94
+ const response = await this.monitorResponse(async () => {
95
+ return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
96
+ });
97
+ return _ApiBase.shapeResponse(response, responseType);
98
+ }
99
+ resolveRoot() {
100
+ return `${this.config.apiDomain}${this.root}`;
101
+ }
102
+ };
103
+
104
+ // src/objToQuery.ts
105
+ var objToQuery = (obj) => {
106
+ return `?${Object.entries(obj).map(([key, value]) => {
107
+ return `${key}=${value}`;
108
+ }).filter((value) => value !== void 0).join("&")}`;
109
+ };
110
+
111
+ // src/Simple.ts
112
+ var ApiSimple = class extends ApiBase {
4
113
  async delete(responseType) {
5
114
  switch (responseType) {
6
115
  case "tuple":
@@ -41,7 +150,7 @@ class ApiSimple extends ApiBase {
41
150
  return await this.putEndpoint(void 0, data);
42
151
  }
43
152
  }
44
- }
153
+ };
45
154
  export {
46
155
  ApiSimple
47
156
  };