@xyo-network/api 2.75.15 → 2.75.17

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 (266) hide show
  1. package/dist/docs.json +364 -364
  2. package/package.json +13 -13
  3. package/dist/browser/Api/Api.cjs +0 -188
  4. package/dist/browser/Api/Api.cjs.map +0 -1
  5. package/dist/browser/Api/Api.js +0 -167
  6. package/dist/browser/Api/Api.js.map +0 -1
  7. package/dist/browser/Api/index.cjs +0 -190
  8. package/dist/browser/Api/index.cjs.map +0 -1
  9. package/dist/browser/Api/index.js +0 -167
  10. package/dist/browser/Api/index.js.map +0 -1
  11. package/dist/browser/Base.cjs +0 -123
  12. package/dist/browser/Base.cjs.map +0 -1
  13. package/dist/browser/Base.js +0 -102
  14. package/dist/browser/Base.js.map +0 -1
  15. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.cjs +0 -55
  16. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.cjs.map +0 -1
  17. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.js +0 -34
  18. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.js.map +0 -1
  19. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.cjs +0 -34
  20. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.cjs.map +0 -1
  21. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +0 -13
  22. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +0 -1
  23. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.cjs +0 -19
  24. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.cjs.map +0 -1
  25. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js +0 -1
  26. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js.map +0 -1
  27. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.cjs +0 -33
  28. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.cjs.map +0 -1
  29. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +0 -12
  30. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +0 -1
  31. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.cjs +0 -35
  32. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.cjs.map +0 -1
  33. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +0 -12
  34. package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +0 -1
  35. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.cjs +0 -33
  36. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.cjs.map +0 -1
  37. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +0 -12
  38. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +0 -1
  39. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.cjs +0 -35
  40. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.cjs.map +0 -1
  41. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +0 -12
  42. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +0 -1
  43. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.cjs +0 -19
  44. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.cjs.map +0 -1
  45. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js +0 -1
  46. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js.map +0 -1
  47. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.cjs +0 -19
  48. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.cjs.map +0 -1
  49. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js +0 -1
  50. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js.map +0 -1
  51. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.cjs +0 -34
  52. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.cjs.map +0 -1
  53. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +0 -13
  54. package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +0 -1
  55. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.cjs +0 -19
  56. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.cjs.map +0 -1
  57. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js +0 -1
  58. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js.map +0 -1
  59. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.cjs +0 -33
  60. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.cjs.map +0 -1
  61. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +0 -12
  62. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +0 -1
  63. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.cjs +0 -35
  64. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.cjs.map +0 -1
  65. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +0 -12
  66. package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +0 -1
  67. package/dist/browser/Diviner/LocationDiviner/Queries/index.cjs +0 -66
  68. package/dist/browser/Diviner/LocationDiviner/Queries/index.cjs.map +0 -1
  69. package/dist/browser/Diviner/LocationDiviner/Queries/index.js +0 -43
  70. package/dist/browser/Diviner/LocationDiviner/Queries/index.js.map +0 -1
  71. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.cjs +0 -27
  72. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.cjs.map +0 -1
  73. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +0 -6
  74. package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +0 -1
  75. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.cjs +0 -27
  76. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.cjs.map +0 -1
  77. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.js +0 -6
  78. package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +0 -1
  79. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.cjs +0 -33
  80. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.cjs.map +0 -1
  81. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.js +0 -10
  82. package/dist/browser/Diviner/LocationDiviner/Witnesses/index.js.map +0 -1
  83. package/dist/browser/Diviner/LocationDiviner/index.cjs +0 -106
  84. package/dist/browser/Diviner/LocationDiviner/index.cjs.map +0 -1
  85. package/dist/browser/Diviner/LocationDiviner/index.js +0 -83
  86. package/dist/browser/Diviner/LocationDiviner/index.js.map +0 -1
  87. package/dist/browser/Diviner/LocationDiviner/models.cjs +0 -19
  88. package/dist/browser/Diviner/LocationDiviner/models.cjs.map +0 -1
  89. package/dist/browser/Diviner/LocationDiviner/models.js +0 -1
  90. package/dist/browser/Diviner/LocationDiviner/models.js.map +0 -1
  91. package/dist/browser/Diviner/RemoteDivinerConfig.cjs +0 -27
  92. package/dist/browser/Diviner/RemoteDivinerConfig.cjs.map +0 -1
  93. package/dist/browser/Diviner/RemoteDivinerConfig.js +0 -6
  94. package/dist/browser/Diviner/RemoteDivinerConfig.js.map +0 -1
  95. package/dist/browser/Diviner/RemoteDivinerError.cjs +0 -35
  96. package/dist/browser/Diviner/RemoteDivinerError.cjs.map +0 -1
  97. package/dist/browser/Diviner/RemoteDivinerError.js +0 -14
  98. package/dist/browser/Diviner/RemoteDivinerError.js.map +0 -1
  99. package/dist/browser/Diviner/index.cjs +0 -110
  100. package/dist/browser/Diviner/index.cjs.map +0 -1
  101. package/dist/browser/Diviner/index.js +0 -87
  102. package/dist/browser/Diviner/index.js.map +0 -1
  103. package/dist/browser/Simple.cjs +0 -176
  104. package/dist/browser/Simple.cjs.map +0 -1
  105. package/dist/browser/Simple.js +0 -153
  106. package/dist/browser/Simple.js.map +0 -1
  107. package/dist/browser/Test/index.cjs +0 -56
  108. package/dist/browser/Test/index.cjs.map +0 -1
  109. package/dist/browser/Test/index.js +0 -33
  110. package/dist/browser/Test/index.js.map +0 -1
  111. package/dist/browser/Test/testBoundWitness.cjs +0 -38
  112. package/dist/browser/Test/testBoundWitness.cjs.map +0 -1
  113. package/dist/browser/Test/testBoundWitness.js +0 -17
  114. package/dist/browser/Test/testBoundWitness.js.map +0 -1
  115. package/dist/browser/Test/testPayload.cjs +0 -39
  116. package/dist/browser/Test/testPayload.cjs.map +0 -1
  117. package/dist/browser/Test/testPayload.js +0 -18
  118. package/dist/browser/Test/testPayload.js.map +0 -1
  119. package/dist/browser/WithArchive.cjs +0 -19
  120. package/dist/browser/WithArchive.cjs.map +0 -1
  121. package/dist/browser/WithArchive.js +0 -1
  122. package/dist/browser/WithArchive.js.map +0 -1
  123. package/dist/browser/models/ArchivePath.cjs +0 -19
  124. package/dist/browser/models/ArchivePath.cjs.map +0 -1
  125. package/dist/browser/models/ArchivePath.js +0 -1
  126. package/dist/browser/models/ArchivePath.js.map +0 -1
  127. package/dist/browser/models/index.cjs +0 -19
  128. package/dist/browser/models/index.cjs.map +0 -1
  129. package/dist/browser/models/index.js +0 -1
  130. package/dist/browser/models/index.js.map +0 -1
  131. package/dist/browser/objToQuery.cjs +0 -31
  132. package/dist/browser/objToQuery.cjs.map +0 -1
  133. package/dist/browser/objToQuery.js +0 -10
  134. package/dist/browser/objToQuery.js.map +0 -1
  135. package/dist/node/Api/Api.js +0 -196
  136. package/dist/node/Api/Api.js.map +0 -1
  137. package/dist/node/Api/Api.mjs +0 -171
  138. package/dist/node/Api/Api.mjs.map +0 -1
  139. package/dist/node/Api/index.js +0 -198
  140. package/dist/node/Api/index.js.map +0 -1
  141. package/dist/node/Api/index.mjs +0 -171
  142. package/dist/node/Api/index.mjs.map +0 -1
  143. package/dist/node/Base.js +0 -131
  144. package/dist/node/Base.js.map +0 -1
  145. package/dist/node/Base.mjs +0 -106
  146. package/dist/node/Base.mjs.map +0 -1
  147. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.js +0 -59
  148. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.js.map +0 -1
  149. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.mjs +0 -34
  150. package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.mjs.map +0 -1
  151. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +0 -39
  152. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +0 -1
  153. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.mjs +0 -13
  154. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.mjs.map +0 -1
  155. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js +0 -19
  156. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js.map +0 -1
  157. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.mjs +0 -1
  158. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.mjs.map +0 -1
  159. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +0 -39
  160. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +0 -1
  161. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.mjs +0 -12
  162. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.mjs.map +0 -1
  163. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +0 -41
  164. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +0 -1
  165. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.mjs +0 -12
  166. package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.mjs.map +0 -1
  167. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +0 -39
  168. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +0 -1
  169. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.mjs +0 -12
  170. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.mjs.map +0 -1
  171. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +0 -41
  172. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +0 -1
  173. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.mjs +0 -12
  174. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.mjs.map +0 -1
  175. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js +0 -19
  176. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js.map +0 -1
  177. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.mjs +0 -1
  178. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.mjs.map +0 -1
  179. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js +0 -19
  180. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js.map +0 -1
  181. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.mjs +0 -1
  182. package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.mjs.map +0 -1
  183. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +0 -38
  184. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +0 -1
  185. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.mjs +0 -13
  186. package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.mjs.map +0 -1
  187. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js +0 -19
  188. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js.map +0 -1
  189. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.mjs +0 -1
  190. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.mjs.map +0 -1
  191. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +0 -39
  192. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +0 -1
  193. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.mjs +0 -12
  194. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.mjs.map +0 -1
  195. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +0 -41
  196. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +0 -1
  197. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.mjs +0 -12
  198. package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.mjs.map +0 -1
  199. package/dist/node/Diviner/LocationDiviner/Queries/index.js +0 -79
  200. package/dist/node/Diviner/LocationDiviner/Queries/index.js.map +0 -1
  201. package/dist/node/Diviner/LocationDiviner/Queries/index.mjs +0 -43
  202. package/dist/node/Diviner/LocationDiviner/Queries/index.mjs.map +0 -1
  203. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +0 -31
  204. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +0 -1
  205. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.mjs +0 -6
  206. package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.mjs.map +0 -1
  207. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.js +0 -31
  208. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +0 -1
  209. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.mjs +0 -6
  210. package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.mjs.map +0 -1
  211. package/dist/node/Diviner/LocationDiviner/Witnesses/index.js +0 -38
  212. package/dist/node/Diviner/LocationDiviner/Witnesses/index.js.map +0 -1
  213. package/dist/node/Diviner/LocationDiviner/Witnesses/index.mjs +0 -10
  214. package/dist/node/Diviner/LocationDiviner/Witnesses/index.mjs.map +0 -1
  215. package/dist/node/Diviner/LocationDiviner/index.js +0 -122
  216. package/dist/node/Diviner/LocationDiviner/index.js.map +0 -1
  217. package/dist/node/Diviner/LocationDiviner/index.mjs +0 -83
  218. package/dist/node/Diviner/LocationDiviner/index.mjs.map +0 -1
  219. package/dist/node/Diviner/LocationDiviner/models.js +0 -19
  220. package/dist/node/Diviner/LocationDiviner/models.js.map +0 -1
  221. package/dist/node/Diviner/LocationDiviner/models.mjs +0 -1
  222. package/dist/node/Diviner/LocationDiviner/models.mjs.map +0 -1
  223. package/dist/node/Diviner/RemoteDivinerConfig.js +0 -31
  224. package/dist/node/Diviner/RemoteDivinerConfig.js.map +0 -1
  225. package/dist/node/Diviner/RemoteDivinerConfig.mjs +0 -6
  226. package/dist/node/Diviner/RemoteDivinerConfig.mjs.map +0 -1
  227. package/dist/node/Diviner/RemoteDivinerError.js +0 -39
  228. package/dist/node/Diviner/RemoteDivinerError.js.map +0 -1
  229. package/dist/node/Diviner/RemoteDivinerError.mjs +0 -14
  230. package/dist/node/Diviner/RemoteDivinerError.mjs.map +0 -1
  231. package/dist/node/Diviner/index.js +0 -127
  232. package/dist/node/Diviner/index.js.map +0 -1
  233. package/dist/node/Diviner/index.mjs +0 -87
  234. package/dist/node/Diviner/index.mjs.map +0 -1
  235. package/dist/node/Simple.js +0 -184
  236. package/dist/node/Simple.js.map +0 -1
  237. package/dist/node/Simple.mjs +0 -157
  238. package/dist/node/Simple.mjs.map +0 -1
  239. package/dist/node/Test/index.js +0 -62
  240. package/dist/node/Test/index.js.map +0 -1
  241. package/dist/node/Test/index.mjs +0 -33
  242. package/dist/node/Test/index.mjs.map +0 -1
  243. package/dist/node/Test/testBoundWitness.js +0 -42
  244. package/dist/node/Test/testBoundWitness.js.map +0 -1
  245. package/dist/node/Test/testBoundWitness.mjs +0 -17
  246. package/dist/node/Test/testBoundWitness.mjs.map +0 -1
  247. package/dist/node/Test/testPayload.js +0 -44
  248. package/dist/node/Test/testPayload.js.map +0 -1
  249. package/dist/node/Test/testPayload.mjs +0 -18
  250. package/dist/node/Test/testPayload.mjs.map +0 -1
  251. package/dist/node/WithArchive.js +0 -19
  252. package/dist/node/WithArchive.js.map +0 -1
  253. package/dist/node/WithArchive.mjs +0 -1
  254. package/dist/node/WithArchive.mjs.map +0 -1
  255. package/dist/node/models/ArchivePath.js +0 -19
  256. package/dist/node/models/ArchivePath.js.map +0 -1
  257. package/dist/node/models/ArchivePath.mjs +0 -1
  258. package/dist/node/models/ArchivePath.mjs.map +0 -1
  259. package/dist/node/models/index.js +0 -19
  260. package/dist/node/models/index.js.map +0 -1
  261. package/dist/node/models/index.mjs +0 -1
  262. package/dist/node/models/index.mjs.map +0 -1
  263. package/dist/node/objToQuery.js +0 -35
  264. package/dist/node/objToQuery.js.map +0 -1
  265. package/dist/node/objToQuery.mjs +0 -10
  266. package/dist/node/objToQuery.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/Api/index.ts","../../../src/Api/Api.ts","../../../src/Base.ts","../../../src/objToQuery.ts","../../../src/Simple.ts"],"sourcesContent":["export * from './Api'\n","import { ApiConfig } from '@xyo-network/api-models'\nimport { Huri } from '@xyo-network/huri'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { ApiSimple } from '../Simple'\n\nexport class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {\n huri(huri: Huri | string) {\n const huriObj = typeof huri === 'string' ? new Huri(huri) : huri\n return new ApiSimple<Payload>({\n ...this.config,\n root: `${this.root}${huriObj.href}/`,\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","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}\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AY,WAAW,KAAK,GAAG,OAAO;AAAA,MAC1D;AACE,eAAO,MAAM,KAAK,YAAY,WAAW,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;;;AH9DO,IAAM,eAAN,cAA4D,UAAwB;AAAA,EACzF,KAAK,MAAqB;AACxB,UAAM,UAAU,OAAO,SAAS,WAAW,IAAI,iBAAK,IAAI,IAAI;AAC5D,WAAO,IAAI,UAAmB;AAAA,MAC5B,GAAG,KAAK;AAAA,MACR,MAAM,GAAG,KAAK,IAAI,GAAG,QAAQ,IAAI;AAAA,IACnC,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1,167 +0,0 @@
1
- // src/Api/Api.ts
2
- import { Huri } from "@xyo-network/huri";
3
-
4
- // src/Base.ts
5
- import { AxiosJson } from "@xyo-network/axios";
6
- var ApiBase = class _ApiBase {
7
- config;
8
- axios;
9
- constructor(config) {
10
- this.config = config;
11
- this.axios = new AxiosJson({ ...this.config, headers: this.headers });
12
- }
13
- get authenticated() {
14
- return !!this.config.apiKey || !!this.config.jwtToken;
15
- }
16
- get headers() {
17
- const headers = {};
18
- if (this.config.jwtToken) {
19
- headers.Authorization = `Bearer ${this.config.jwtToken}`;
20
- }
21
- if (this.config.apiKey) {
22
- headers["x-api-key"] = this.config.apiKey;
23
- }
24
- return headers;
25
- }
26
- get query() {
27
- return this.config.query ?? "";
28
- }
29
- get root() {
30
- return this.config.root ?? "/";
31
- }
32
- static resolveResponse(result) {
33
- return [result?.data?.data, result?.data, result];
34
- }
35
- static shapeResponse(response, responseType) {
36
- const resolvedResponse = _ApiBase.resolveResponse(response);
37
- return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
38
- }
39
- onError(error, depth = 0) {
40
- this.config.reportableParent?.onError?.(error, depth + 1);
41
- this.config.onError?.(error, depth);
42
- }
43
- onFailure(response, depth = 0) {
44
- this.config.reportableParent?.onFailure?.(response, depth + 1);
45
- this.config.onFailure?.(response, depth);
46
- }
47
- onSuccess(response, depth = 0) {
48
- this.config.reportableParent?.onSuccess?.(response, depth + 1);
49
- this.config.onSuccess?.(response, depth);
50
- }
51
- async deleteEndpoint(endPoint = "", responseType) {
52
- const response = await this.monitorResponse(async () => {
53
- return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
54
- });
55
- return _ApiBase.shapeResponse(response, responseType);
56
- }
57
- async getEndpoint(endPoint = "", responseType) {
58
- const response = await this.monitorResponse(async () => {
59
- return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
60
- });
61
- return _ApiBase.shapeResponse(response, responseType);
62
- }
63
- handleMonitorResponseError(error, trapAxiosException) {
64
- if (!error.isError) {
65
- throw error;
66
- }
67
- if (trapAxiosException) {
68
- error.response ? this.onFailure(error.response) : this.onError(error);
69
- if (this.config.throwFailure) {
70
- throw error;
71
- }
72
- return error.response;
73
- }
74
- }
75
- async monitorResponse(closure) {
76
- let trapAxiosException = true;
77
- try {
78
- const response = await closure();
79
- trapAxiosException = false;
80
- response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
81
- return response;
82
- } catch (ex) {
83
- this.handleMonitorResponseError(ex, trapAxiosException);
84
- }
85
- }
86
- async postEndpoint(endPoint = "", data, responseType) {
87
- const response = await this.monitorResponse(async () => {
88
- return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
89
- });
90
- return _ApiBase.shapeResponse(response, responseType);
91
- }
92
- async putEndpoint(endPoint = "", data, responseType) {
93
- const response = await this.monitorResponse(async () => {
94
- return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
95
- });
96
- return _ApiBase.shapeResponse(response, responseType);
97
- }
98
- resolveRoot() {
99
- return `${this.config.apiDomain}${this.root}`;
100
- }
101
- };
102
-
103
- // src/objToQuery.ts
104
- var objToQuery = (obj) => {
105
- return `?${Object.entries(obj).map(([key, value]) => {
106
- return `${key}=${value}`;
107
- }).filter((value) => value !== void 0).join("&")}`;
108
- };
109
-
110
- // src/Simple.ts
111
- var ApiSimple = class extends ApiBase {
112
- async delete(responseType) {
113
- switch (responseType) {
114
- case "tuple":
115
- return await this.deleteEndpoint(void 0, "tuple");
116
- default:
117
- return await this.deleteEndpoint(void 0);
118
- }
119
- }
120
- async find(query = {}, responseType) {
121
- switch (responseType) {
122
- case "tuple":
123
- return await this.getEndpoint(objToQuery(query), "tuple");
124
- default:
125
- return await this.getEndpoint(objToQuery(query));
126
- }
127
- }
128
- async get(responseType) {
129
- switch (responseType) {
130
- case "tuple":
131
- return await this.getEndpoint(void 0, "tuple");
132
- default:
133
- return await this.getEndpoint(void 0);
134
- }
135
- }
136
- async post(data, responseType) {
137
- switch (responseType) {
138
- case "tuple":
139
- return await this.postEndpoint(void 0, data, "tuple");
140
- default:
141
- return await this.postEndpoint(void 0, data);
142
- }
143
- }
144
- async put(data, responseType) {
145
- switch (responseType) {
146
- case "tuple":
147
- return await this.putEndpoint(void 0, data, "tuple");
148
- default:
149
- return await this.putEndpoint(void 0, data);
150
- }
151
- }
152
- };
153
-
154
- // src/Api/Api.ts
155
- var ArchivistApi = class extends ApiSimple {
156
- huri(huri) {
157
- const huriObj = typeof huri === "string" ? new Huri(huri) : huri;
158
- return new ApiSimple({
159
- ...this.config,
160
- root: `${this.root}${huriObj.href}/`
161
- });
162
- }
163
- };
164
- export {
165
- ArchivistApi
166
- };
167
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/Api/Api.ts","../../../src/Base.ts","../../../src/objToQuery.ts","../../../src/Simple.ts"],"sourcesContent":["import { ApiConfig } from '@xyo-network/api-models'\nimport { Huri } from '@xyo-network/huri'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { ApiSimple } from '../Simple'\n\nexport class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {\n huri(huri: Huri | string) {\n const huriObj = typeof huri === 'string' ? new Huri(huri) : huri\n return new ApiSimple<Payload>({\n ...this.config,\n root: `${this.root}${huriObj.href}/`,\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","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":";AACA,SAAS,YAAY;;;ACUrB,SAAS,iBAAiB;AAEnB,IAAM,UAAN,MAAM,SAAkE;AAAA,EACpE;AAAA,EACC;AAAA,EAEV,YAAY,QAAW;AACrB,SAAK,SAAS;AACd,SAAK,QAAQ,IAAI,UAAU,EAAE,GAAG,KAAK,QAAQ,SAAS,KAAK,QAAQ,CAAC;AAAA,EACtE;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,CAAC,CAAC,KAAK,OAAO,UAAU,CAAC,CAAC,KAAK,OAAO;AAAA,EAC/C;AAAA,EAEA,IAAc,UAAkC;AAC9C,UAAM,UAAkC,CAAC;AACzC,QAAI,KAAK,OAAO,UAAU;AACxB,cAAQ,gBAAgB,UAAU,KAAK,OAAO,QAAQ;AAAA,IACxD;AACA,QAAI,KAAK,OAAO,QAAQ;AACtB,cAAQ,WAAW,IAAI,KAAK,OAAO;AAAA,IACrC;AACA,WAAO;AAAA,E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MAAM,KAAK,YAAY,QAAW,IAAI;AAAA,IACjD;AAAA,EACF;AACF;;;AH9DO,IAAM,eAAN,cAA4D,UAAwB;AAAA,EACzF,KAAK,MAAqB;AACxB,UAAM,UAAU,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,IAAI;AAC5D,WAAO,IAAI,UAAmB;AAAA,MAC5B,GAAG,KAAK;AAAA,MACR,MAAM,GAAG,KAAK,IAAI,GAAG,QAAQ,IAAI;AAAA,IACnC,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1,123 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
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
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/Base.ts
21
- var Base_exports = {};
22
- __export(Base_exports, {
23
- ApiBase: () => ApiBase
24
- });
25
- module.exports = __toCommonJS(Base_exports);
26
- var import_axios = require("@xyo-network/axios");
27
- var ApiBase = class _ApiBase {
28
- config;
29
- axios;
30
- constructor(config) {
31
- this.config = config;
32
- this.axios = new import_axios.AxiosJson({ ...this.config, headers: this.headers });
33
- }
34
- get authenticated() {
35
- return !!this.config.apiKey || !!this.config.jwtToken;
36
- }
37
- get headers() {
38
- const headers = {};
39
- if (this.config.jwtToken) {
40
- headers.Authorization = `Bearer ${this.config.jwtToken}`;
41
- }
42
- if (this.config.apiKey) {
43
- headers["x-api-key"] = this.config.apiKey;
44
- }
45
- return headers;
46
- }
47
- get query() {
48
- return this.config.query ?? "";
49
- }
50
- get root() {
51
- return this.config.root ?? "/";
52
- }
53
- static resolveResponse(result) {
54
- return [result?.data?.data, result?.data, result];
55
- }
56
- static shapeResponse(response, responseType) {
57
- const resolvedResponse = _ApiBase.resolveResponse(response);
58
- return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
59
- }
60
- onError(error, depth = 0) {
61
- this.config.reportableParent?.onError?.(error, depth + 1);
62
- this.config.onError?.(error, depth);
63
- }
64
- onFailure(response, depth = 0) {
65
- this.config.reportableParent?.onFailure?.(response, depth + 1);
66
- this.config.onFailure?.(response, depth);
67
- }
68
- onSuccess(response, depth = 0) {
69
- this.config.reportableParent?.onSuccess?.(response, depth + 1);
70
- this.config.onSuccess?.(response, depth);
71
- }
72
- async deleteEndpoint(endPoint = "", responseType) {
73
- const response = await this.monitorResponse(async () => {
74
- return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
75
- });
76
- return _ApiBase.shapeResponse(response, responseType);
77
- }
78
- async getEndpoint(endPoint = "", responseType) {
79
- const response = await this.monitorResponse(async () => {
80
- return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
81
- });
82
- return _ApiBase.shapeResponse(response, responseType);
83
- }
84
- handleMonitorResponseError(error, trapAxiosException) {
85
- if (!error.isError) {
86
- throw error;
87
- }
88
- if (trapAxiosException) {
89
- error.response ? this.onFailure(error.response) : this.onError(error);
90
- if (this.config.throwFailure) {
91
- throw error;
92
- }
93
- return error.response;
94
- }
95
- }
96
- async monitorResponse(closure) {
97
- let trapAxiosException = true;
98
- try {
99
- const response = await closure();
100
- trapAxiosException = false;
101
- response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
102
- return response;
103
- } catch (ex) {
104
- this.handleMonitorResponseError(ex, trapAxiosException);
105
- }
106
- }
107
- async postEndpoint(endPoint = "", data, responseType) {
108
- const response = await this.monitorResponse(async () => {
109
- return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
110
- });
111
- return _ApiBase.shapeResponse(response, responseType);
112
- }
113
- async putEndpoint(endPoint = "", data, responseType) {
114
- const response = await this.monitorResponse(async () => {
115
- return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
116
- });
117
- return _ApiBase.shapeResponse(response, responseType);
118
- }
119
- resolveRoot() {
120
- return `${this.config.apiDomain}${this.root}`;
121
- }
122
- };
123
- //# sourceMappingURL=Base.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Base.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;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AAAA,EAKA,MAAgB,aACd,WAAW,IACX,MACA,cACoC;AACpC,UAAM,WAAW,MAAM,KAAK,gBAAmB,YAAY;AACzD,aAAO,MAAM,KAAK,MAAM,KAAwD,GAAG,KAAK,YAAY,CAAC,GAAG,QAAQ,GAAG,KAAK,KAAK,IAAI,IAAI;AAAA,IACvI,CAAC;AACD,WAAO,SAAQ,cAAiB,UAAU,YAAY;AAAA,EACxD;AAAA,EAKA,MAAgB,YAAsC,WAAW,IAAI,MAAU,cAAoE;AACjJ,UAAM,WAAW,MAAM,KAAK,gBAAmB,YAAY;AACzD,aAAO,MAAM,KAAK,MAAM,IAAuD,GAAG,KAAK,YAAY,CAAC,GAAG,QAAQ,GAAG,KAAK,KAAK,IAAI,IAAI;AAAA,IACtI,CAAC;AACD,WAAO,SAAQ,cAAiB,UAAU,YAAY;AAAA,EACxD;AAAA,EAEQ,cAAc;AACpB,WAAO,GAAG,KAAK,OAAO,SAAS,GAAG,KAAK,IAAI;AAAA,EAC7C;AACF;","names":[]}
@@ -1,102 +0,0 @@
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
- return [result?.data?.data, result?.data, result];
31
- }
32
- static shapeResponse(response, responseType) {
33
- const resolvedResponse = _ApiBase.resolveResponse(response);
34
- return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
35
- }
36
- onError(error, depth = 0) {
37
- this.config.reportableParent?.onError?.(error, depth + 1);
38
- this.config.onError?.(error, depth);
39
- }
40
- onFailure(response, depth = 0) {
41
- this.config.reportableParent?.onFailure?.(response, depth + 1);
42
- this.config.onFailure?.(response, depth);
43
- }
44
- onSuccess(response, depth = 0) {
45
- this.config.reportableParent?.onSuccess?.(response, depth + 1);
46
- this.config.onSuccess?.(response, depth);
47
- }
48
- async deleteEndpoint(endPoint = "", responseType) {
49
- const response = await this.monitorResponse(async () => {
50
- return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
51
- });
52
- return _ApiBase.shapeResponse(response, responseType);
53
- }
54
- async getEndpoint(endPoint = "", responseType) {
55
- const response = await this.monitorResponse(async () => {
56
- return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
57
- });
58
- return _ApiBase.shapeResponse(response, responseType);
59
- }
60
- handleMonitorResponseError(error, trapAxiosException) {
61
- if (!error.isError) {
62
- throw error;
63
- }
64
- if (trapAxiosException) {
65
- error.response ? this.onFailure(error.response) : this.onError(error);
66
- if (this.config.throwFailure) {
67
- throw error;
68
- }
69
- return error.response;
70
- }
71
- }
72
- async monitorResponse(closure) {
73
- let trapAxiosException = true;
74
- try {
75
- const response = await closure();
76
- trapAxiosException = false;
77
- response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
78
- return response;
79
- } catch (ex) {
80
- this.handleMonitorResponseError(ex, trapAxiosException);
81
- }
82
- }
83
- async postEndpoint(endPoint = "", data, responseType) {
84
- const response = await this.monitorResponse(async () => {
85
- return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
86
- });
87
- return _ApiBase.shapeResponse(response, responseType);
88
- }
89
- async putEndpoint(endPoint = "", data, responseType) {
90
- const response = await this.monitorResponse(async () => {
91
- return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
92
- });
93
- return _ApiBase.shapeResponse(response, responseType);
94
- }
95
- resolveRoot() {
96
- return `${this.config.apiDomain}${this.root}`;
97
- }
98
- };
99
- export {
100
- ApiBase
101
- };
102
- //# sourceMappingURL=Base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Base.ts"],"sourcesContent":["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"],"mappings":";AAWA,SAAS,iBAAiB;AAEnB,IAAM,UAAN,MAAM,SAAkE;AAAA,EACpE;AAAA,EACC;AAAA,EAEV,YAAY,QAAW;AACrB,SAAK,SAAS;AACd,SAAK,QAAQ,IAAI,UAAU,EAAE,GAAG,KAAK,QAAQ,SAAS,KAAK,QAAQ,CAAC;AAAA,EACtE;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,CAAC,CA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W,IAAI,MAAU,cAAoE;AACjJ,UAAM,WAAW,MAAM,KAAK,gBAAmB,YAAY;AACzD,aAAO,MAAM,KAAK,MAAM,IAAuD,GAAG,KAAK,YAAY,CAAC,GAAG,QAAQ,GAAG,KAAK,KAAK,IAAI,IAAI;AAAA,IACtI,CAAC;AACD,WAAO,SAAQ,cAAiB,UAAU,YAAY;AAAA,EACxD;AAAA,EAEQ,cAAc;AACpB,WAAO,GAAG,KAAK,OAAO,SAAS,GAAG,KAAK,IAAI;AAAA,EAC7C;AACF;","names":[]}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
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
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/Diviner/LocationDiviner/LocationDivinerApi.ts
21
- var LocationDivinerApi_exports = {};
22
- __export(LocationDivinerApi_exports, {
23
- LocationDivinerApi: () => LocationDivinerApi
24
- });
25
- module.exports = __toCommonJS(LocationDivinerApi_exports);
26
- var import_axios2 = require("@xyo-network/axios");
27
-
28
- // src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts
29
- var import_axios = require("@xyo-network/axios");
30
- var locationDivinerApiResponseTransformer = (data, _headers) => {
31
- return data.data;
32
- };
33
- var getLocationDivinerApiResponseTransformer = (axiosInstance = import_axios.axios) => {
34
- return axiosInstance.defaults.transformResponse ? [].concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer) : [locationDivinerApiResponseTransformer];
35
- };
36
-
37
- // src/Diviner/LocationDiviner/LocationDivinerApi.ts
38
- var LocationDivinerApi = class {
39
- config;
40
- constructor(config) {
41
- this.config = config;
42
- }
43
- get axiosRequestConfig() {
44
- return {
45
- transformResponse: getLocationDivinerApiResponseTransformer()
46
- };
47
- }
48
- async getLocationQuery(hash) {
49
- return (await import_axios2.axios.get(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data;
50
- }
51
- async postLocationQuery(request) {
52
- return (await import_axios2.axios.post(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data;
53
- }
54
- };
55
- //# sourceMappingURL=LocationDivinerApi.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/Diviner/LocationDiviner/LocationDivinerApi.ts","../../../../src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,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;","names":["import_axios"]}
@@ -1,34 +0,0 @@
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
- export {
32
- LocationDivinerApi
33
- };
34
- //# sourceMappingURL=LocationDivinerApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/Diviner/LocationDiviner/LocationDivinerApi.ts","../../../../src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.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"],"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;","names":["axios","axios"]}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
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
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts
21
- var LocationDivinerApiResponseTransformer_exports = {};
22
- __export(LocationDivinerApiResponseTransformer_exports, {
23
- getLocationDivinerApiResponseTransformer: () => getLocationDivinerApiResponseTransformer,
24
- locationDivinerApiResponseTransformer: () => locationDivinerApiResponseTransformer
25
- });
26
- module.exports = __toCommonJS(LocationDivinerApiResponseTransformer_exports);
27
- var import_axios = require("@xyo-network/axios");
28
- var locationDivinerApiResponseTransformer = (data, _headers) => {
29
- return data.data;
30
- };
31
- var getLocationDivinerApiResponseTransformer = (axiosInstance = import_axios.axios) => {
32
- return axiosInstance.defaults.transformResponse ? [].concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer) : [locationDivinerApiResponseTransformer];
33
- };
34
- //# sourceMappingURL=LocationDivinerApiResponseTransformer.cjs.map