@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
@@ -0,0 +1,12 @@
1
+ import { ApiConfig } from '@xyo-network/api-models';
2
+ import { Huri } from '@xyo-network/huri';
3
+ import { Payload } from '@xyo-network/payload-model';
4
+ import { ApiSimple } from '../Simple';
5
+ export declare class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {
6
+ huri(huri: Huri | string): ApiSimple<{
7
+ schema: string;
8
+ } & import("@xyo-network/payload-model").PayloadFields, {
9
+ schema: string;
10
+ } & import("@xyo-network/payload-model").PayloadFields, import("@xyo-network/payload-model").PayloadFindFilter, ApiConfig>;
11
+ }
12
+ //# sourceMappingURL=Api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../../src/Api/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,qBAAa,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACxF,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;;;;;CAOzB"}
@@ -16,22 +16,179 @@ 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/Api/Api.ts
19
21
  var Api_exports = {};
20
22
  __export(Api_exports, {
21
23
  ArchivistApi: () => ArchivistApi
22
24
  });
23
25
  module.exports = __toCommonJS(Api_exports);
24
26
  var import_huri = require("@xyo-network/huri");
25
- var import_Simple = require("../Simple");
26
- class ArchivistApi extends import_Simple.ApiSimple {
27
+
28
+ // src/Base.ts
29
+ var import_axios = require("@xyo-network/axios");
30
+ var ApiBase = class _ApiBase {
31
+ config;
32
+ axios;
33
+ constructor(config) {
34
+ this.config = config;
35
+ this.axios = new import_axios.AxiosJson({ ...this.config, headers: this.headers });
36
+ }
37
+ get authenticated() {
38
+ return !!this.config.apiKey || !!this.config.jwtToken;
39
+ }
40
+ get headers() {
41
+ const headers = {};
42
+ if (this.config.jwtToken) {
43
+ headers.Authorization = `Bearer ${this.config.jwtToken}`;
44
+ }
45
+ if (this.config.apiKey) {
46
+ headers["x-api-key"] = this.config.apiKey;
47
+ }
48
+ return headers;
49
+ }
50
+ get query() {
51
+ return this.config.query ?? "";
52
+ }
53
+ get root() {
54
+ return this.config.root ?? "/";
55
+ }
56
+ static resolveResponse(result) {
57
+ var _a;
58
+ return [(_a = result == null ? void 0 : result.data) == null ? void 0 : _a.data, result == null ? void 0 : result.data, result];
59
+ }
60
+ static shapeResponse(response, responseType) {
61
+ const resolvedResponse = _ApiBase.resolveResponse(response);
62
+ return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
63
+ }
64
+ onError(error, depth = 0) {
65
+ var _a, _b, _c, _d;
66
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error, depth + 1);
67
+ (_d = (_c = this.config).onError) == null ? void 0 : _d.call(_c, error, depth);
68
+ }
69
+ onFailure(response, depth = 0) {
70
+ var _a, _b, _c, _d;
71
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onFailure) == null ? void 0 : _b.call(_a, response, depth + 1);
72
+ (_d = (_c = this.config).onFailure) == null ? void 0 : _d.call(_c, response, depth);
73
+ }
74
+ onSuccess(response, depth = 0) {
75
+ var _a, _b, _c, _d;
76
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onSuccess) == null ? void 0 : _b.call(_a, response, depth + 1);
77
+ (_d = (_c = this.config).onSuccess) == null ? void 0 : _d.call(_c, response, depth);
78
+ }
79
+ async deleteEndpoint(endPoint = "", responseType) {
80
+ const response = await this.monitorResponse(async () => {
81
+ return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
82
+ });
83
+ return _ApiBase.shapeResponse(response, responseType);
84
+ }
85
+ async getEndpoint(endPoint = "", responseType) {
86
+ const response = await this.monitorResponse(async () => {
87
+ return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
88
+ });
89
+ return _ApiBase.shapeResponse(response, responseType);
90
+ }
91
+ handleMonitorResponseError(error, trapAxiosException) {
92
+ if (!error.isError) {
93
+ throw error;
94
+ }
95
+ if (trapAxiosException) {
96
+ error.response ? this.onFailure(error.response) : this.onError(error);
97
+ if (this.config.throwFailure) {
98
+ throw error;
99
+ }
100
+ return error.response;
101
+ }
102
+ }
103
+ async monitorResponse(closure) {
104
+ let trapAxiosException = true;
105
+ try {
106
+ const response = await closure();
107
+ trapAxiosException = false;
108
+ response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
109
+ return response;
110
+ } catch (ex) {
111
+ this.handleMonitorResponseError(ex, trapAxiosException);
112
+ }
113
+ }
114
+ async postEndpoint(endPoint = "", data, responseType) {
115
+ const response = await this.monitorResponse(async () => {
116
+ return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
117
+ });
118
+ return _ApiBase.shapeResponse(response, responseType);
119
+ }
120
+ async putEndpoint(endPoint = "", data, responseType) {
121
+ const response = await this.monitorResponse(async () => {
122
+ return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
123
+ });
124
+ return _ApiBase.shapeResponse(response, responseType);
125
+ }
126
+ resolveRoot() {
127
+ return `${this.config.apiDomain}${this.root}`;
128
+ }
129
+ };
130
+
131
+ // src/objToQuery.ts
132
+ var objToQuery = (obj) => {
133
+ return `?${Object.entries(obj).map(([key, value]) => {
134
+ return `${key}=${value}`;
135
+ }).filter((value) => value !== void 0).join("&")}`;
136
+ };
137
+
138
+ // src/Simple.ts
139
+ var ApiSimple = class extends ApiBase {
140
+ async delete(responseType) {
141
+ switch (responseType) {
142
+ case "tuple":
143
+ return await this.deleteEndpoint(void 0, "tuple");
144
+ default:
145
+ return await this.deleteEndpoint(void 0);
146
+ }
147
+ }
148
+ async find(query = {}, responseType) {
149
+ switch (responseType) {
150
+ case "tuple":
151
+ return await this.getEndpoint(objToQuery(query), "tuple");
152
+ default:
153
+ return await this.getEndpoint(objToQuery(query));
154
+ }
155
+ }
156
+ async get(responseType) {
157
+ switch (responseType) {
158
+ case "tuple":
159
+ return await this.getEndpoint(void 0, "tuple");
160
+ default:
161
+ return await this.getEndpoint(void 0);
162
+ }
163
+ }
164
+ async post(data, responseType) {
165
+ switch (responseType) {
166
+ case "tuple":
167
+ return await this.postEndpoint(void 0, data, "tuple");
168
+ default:
169
+ return await this.postEndpoint(void 0, data);
170
+ }
171
+ }
172
+ async put(data, responseType) {
173
+ switch (responseType) {
174
+ case "tuple":
175
+ return await this.putEndpoint(void 0, data, "tuple");
176
+ default:
177
+ return await this.putEndpoint(void 0, data);
178
+ }
179
+ }
180
+ };
181
+
182
+ // src/Api/Api.ts
183
+ var ArchivistApi = class extends ApiSimple {
27
184
  huri(huri) {
28
185
  const huriObj = typeof huri === "string" ? new import_huri.Huri(huri) : huri;
29
- return new import_Simple.ApiSimple({
186
+ return new ApiSimple({
30
187
  ...this.config,
31
188
  root: `${this.root}${huriObj.href}/`
32
189
  });
33
190
  }
34
- }
191
+ };
35
192
  // Annotate the CommonJS export names for ESM import in node:
36
193
  0 && (module.exports = {
37
194
  ArchivistApi
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Api/Api.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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAqB;AAGrB,oBAA0B;AAEnB,MAAM,qBAAsD,wBAAwB;AAAA,EACzF,KAAK,MAAqB;AACxB,UAAM,UAAU,OAAO,SAAS,WAAW,IAAI,iBAAK,IAAI,IAAI;AAC5D,WAAO,IAAI,wBAAmB;AAAA,MAC5B,GAAG,KAAK;AAAA,MACR,MAAM,GAAG,KAAK,IAAI,GAAG,QAAQ,IAAI;AAAA,IACnC,CAAC;AAAA,EACH;AACF;","names":[]}
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(und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,eAAe,MAAS;AAAA,IAC9C;AAAA,EACF;AAAA,EAKA,MAAM,KAAK,QAAQ,CAAC,GAAG,cAAoE;AACzF,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,YAAY,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,6 +1,162 @@
1
+ // src/Api/Api.ts
1
2
  import { Huri } from "@xyo-network/huri";
2
- import { ApiSimple } from "../Simple";
3
- class ArchivistApi extends ApiSimple {
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
+ var _a;
34
+ return [(_a = result == null ? void 0 : result.data) == null ? void 0 : _a.data, result == null ? void 0 : result.data, result];
35
+ }
36
+ static shapeResponse(response, responseType) {
37
+ const resolvedResponse = _ApiBase.resolveResponse(response);
38
+ return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
39
+ }
40
+ onError(error, depth = 0) {
41
+ var _a, _b, _c, _d;
42
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error, depth + 1);
43
+ (_d = (_c = this.config).onError) == null ? void 0 : _d.call(_c, error, depth);
44
+ }
45
+ onFailure(response, depth = 0) {
46
+ var _a, _b, _c, _d;
47
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onFailure) == null ? void 0 : _b.call(_a, response, depth + 1);
48
+ (_d = (_c = this.config).onFailure) == null ? void 0 : _d.call(_c, response, depth);
49
+ }
50
+ onSuccess(response, depth = 0) {
51
+ var _a, _b, _c, _d;
52
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onSuccess) == null ? void 0 : _b.call(_a, response, depth + 1);
53
+ (_d = (_c = this.config).onSuccess) == null ? void 0 : _d.call(_c, response, depth);
54
+ }
55
+ async deleteEndpoint(endPoint = "", responseType) {
56
+ const response = await this.monitorResponse(async () => {
57
+ return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
58
+ });
59
+ return _ApiBase.shapeResponse(response, responseType);
60
+ }
61
+ async getEndpoint(endPoint = "", responseType) {
62
+ const response = await this.monitorResponse(async () => {
63
+ return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
64
+ });
65
+ return _ApiBase.shapeResponse(response, responseType);
66
+ }
67
+ handleMonitorResponseError(error, trapAxiosException) {
68
+ if (!error.isError) {
69
+ throw error;
70
+ }
71
+ if (trapAxiosException) {
72
+ error.response ? this.onFailure(error.response) : this.onError(error);
73
+ if (this.config.throwFailure) {
74
+ throw error;
75
+ }
76
+ return error.response;
77
+ }
78
+ }
79
+ async monitorResponse(closure) {
80
+ let trapAxiosException = true;
81
+ try {
82
+ const response = await closure();
83
+ trapAxiosException = false;
84
+ response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
85
+ return response;
86
+ } catch (ex) {
87
+ this.handleMonitorResponseError(ex, trapAxiosException);
88
+ }
89
+ }
90
+ async postEndpoint(endPoint = "", data, responseType) {
91
+ const response = await this.monitorResponse(async () => {
92
+ return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
93
+ });
94
+ return _ApiBase.shapeResponse(response, responseType);
95
+ }
96
+ async putEndpoint(endPoint = "", data, responseType) {
97
+ const response = await this.monitorResponse(async () => {
98
+ return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
99
+ });
100
+ return _ApiBase.shapeResponse(response, responseType);
101
+ }
102
+ resolveRoot() {
103
+ return `${this.config.apiDomain}${this.root}`;
104
+ }
105
+ };
106
+
107
+ // src/objToQuery.ts
108
+ var objToQuery = (obj) => {
109
+ return `?${Object.entries(obj).map(([key, value]) => {
110
+ return `${key}=${value}`;
111
+ }).filter((value) => value !== void 0).join("&")}`;
112
+ };
113
+
114
+ // src/Simple.ts
115
+ var ApiSimple = class extends ApiBase {
116
+ async delete(responseType) {
117
+ switch (responseType) {
118
+ case "tuple":
119
+ return await this.deleteEndpoint(void 0, "tuple");
120
+ default:
121
+ return await this.deleteEndpoint(void 0);
122
+ }
123
+ }
124
+ async find(query = {}, responseType) {
125
+ switch (responseType) {
126
+ case "tuple":
127
+ return await this.getEndpoint(objToQuery(query), "tuple");
128
+ default:
129
+ return await this.getEndpoint(objToQuery(query));
130
+ }
131
+ }
132
+ async get(responseType) {
133
+ switch (responseType) {
134
+ case "tuple":
135
+ return await this.getEndpoint(void 0, "tuple");
136
+ default:
137
+ return await this.getEndpoint(void 0);
138
+ }
139
+ }
140
+ async post(data, responseType) {
141
+ switch (responseType) {
142
+ case "tuple":
143
+ return await this.postEndpoint(void 0, data, "tuple");
144
+ default:
145
+ return await this.postEndpoint(void 0, data);
146
+ }
147
+ }
148
+ async put(data, responseType) {
149
+ switch (responseType) {
150
+ case "tuple":
151
+ return await this.putEndpoint(void 0, data, "tuple");
152
+ default:
153
+ return await this.putEndpoint(void 0, data);
154
+ }
155
+ }
156
+ };
157
+
158
+ // src/Api/Api.ts
159
+ var ArchivistApi = class extends ApiSimple {
4
160
  huri(huri) {
5
161
  const huriObj = typeof huri === "string" ? new Huri(huri) : huri;
6
162
  return new ApiSimple({
@@ -8,7 +164,7 @@ class ArchivistApi extends ApiSimple {
8
164
  root: `${this.root}${huriObj.href}/`
9
165
  });
10
166
  }
11
- }
167
+ };
12
168
  export {
13
169
  ArchivistApi
14
170
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Api/Api.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"],"mappings":"AACA,SAAS,YAAY;AAGrB,SAAS,iBAAiB;AAEnB,MAAM,qBAAsD,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
+ {"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,cAA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AK,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,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":[]}
@@ -0,0 +1,2 @@
1
+ export * from './Api';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Api/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA"}
@@ -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,13 +15,184 @@ 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/Api/index.ts
16
21
  var Api_exports = {};
22
+ __export(Api_exports, {
23
+ ArchivistApi: () => ArchivistApi
24
+ });
17
25
  module.exports = __toCommonJS(Api_exports);
18
- __reExport(Api_exports, require("./Api"), module.exports);
26
+
27
+ // src/Api/Api.ts
28
+ var import_huri = require("@xyo-network/huri");
29
+
30
+ // src/Base.ts
31
+ var import_axios = require("@xyo-network/axios");
32
+ var ApiBase = class _ApiBase {
33
+ config;
34
+ axios;
35
+ constructor(config) {
36
+ this.config = config;
37
+ this.axios = new import_axios.AxiosJson({ ...this.config, headers: this.headers });
38
+ }
39
+ get authenticated() {
40
+ return !!this.config.apiKey || !!this.config.jwtToken;
41
+ }
42
+ get headers() {
43
+ const headers = {};
44
+ if (this.config.jwtToken) {
45
+ headers.Authorization = `Bearer ${this.config.jwtToken}`;
46
+ }
47
+ if (this.config.apiKey) {
48
+ headers["x-api-key"] = this.config.apiKey;
49
+ }
50
+ return headers;
51
+ }
52
+ get query() {
53
+ return this.config.query ?? "";
54
+ }
55
+ get root() {
56
+ return this.config.root ?? "/";
57
+ }
58
+ static resolveResponse(result) {
59
+ var _a;
60
+ return [(_a = result == null ? void 0 : result.data) == null ? void 0 : _a.data, result == null ? void 0 : result.data, result];
61
+ }
62
+ static shapeResponse(response, responseType) {
63
+ const resolvedResponse = _ApiBase.resolveResponse(response);
64
+ return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
65
+ }
66
+ onError(error, depth = 0) {
67
+ var _a, _b, _c, _d;
68
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, error, depth + 1);
69
+ (_d = (_c = this.config).onError) == null ? void 0 : _d.call(_c, error, depth);
70
+ }
71
+ onFailure(response, depth = 0) {
72
+ var _a, _b, _c, _d;
73
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onFailure) == null ? void 0 : _b.call(_a, response, depth + 1);
74
+ (_d = (_c = this.config).onFailure) == null ? void 0 : _d.call(_c, response, depth);
75
+ }
76
+ onSuccess(response, depth = 0) {
77
+ var _a, _b, _c, _d;
78
+ (_b = (_a = this.config.reportableParent) == null ? void 0 : _a.onSuccess) == null ? void 0 : _b.call(_a, response, depth + 1);
79
+ (_d = (_c = this.config).onSuccess) == null ? void 0 : _d.call(_c, response, depth);
80
+ }
81
+ async deleteEndpoint(endPoint = "", responseType) {
82
+ const response = await this.monitorResponse(async () => {
83
+ return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
84
+ });
85
+ return _ApiBase.shapeResponse(response, responseType);
86
+ }
87
+ async getEndpoint(endPoint = "", responseType) {
88
+ const response = await this.monitorResponse(async () => {
89
+ return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
90
+ });
91
+ return _ApiBase.shapeResponse(response, responseType);
92
+ }
93
+ handleMonitorResponseError(error, trapAxiosException) {
94
+ if (!error.isError) {
95
+ throw error;
96
+ }
97
+ if (trapAxiosException) {
98
+ error.response ? this.onFailure(error.response) : this.onError(error);
99
+ if (this.config.throwFailure) {
100
+ throw error;
101
+ }
102
+ return error.response;
103
+ }
104
+ }
105
+ async monitorResponse(closure) {
106
+ let trapAxiosException = true;
107
+ try {
108
+ const response = await closure();
109
+ trapAxiosException = false;
110
+ response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
111
+ return response;
112
+ } catch (ex) {
113
+ this.handleMonitorResponseError(ex, trapAxiosException);
114
+ }
115
+ }
116
+ async postEndpoint(endPoint = "", data, responseType) {
117
+ const response = await this.monitorResponse(async () => {
118
+ return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
119
+ });
120
+ return _ApiBase.shapeResponse(response, responseType);
121
+ }
122
+ async putEndpoint(endPoint = "", data, responseType) {
123
+ const response = await this.monitorResponse(async () => {
124
+ return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
125
+ });
126
+ return _ApiBase.shapeResponse(response, responseType);
127
+ }
128
+ resolveRoot() {
129
+ return `${this.config.apiDomain}${this.root}`;
130
+ }
131
+ };
132
+
133
+ // src/objToQuery.ts
134
+ var objToQuery = (obj) => {
135
+ return `?${Object.entries(obj).map(([key, value]) => {
136
+ return `${key}=${value}`;
137
+ }).filter((value) => value !== void 0).join("&")}`;
138
+ };
139
+
140
+ // src/Simple.ts
141
+ var ApiSimple = class extends ApiBase {
142
+ async delete(responseType) {
143
+ switch (responseType) {
144
+ case "tuple":
145
+ return await this.deleteEndpoint(void 0, "tuple");
146
+ default:
147
+ return await this.deleteEndpoint(void 0);
148
+ }
149
+ }
150
+ async find(query = {}, responseType) {
151
+ switch (responseType) {
152
+ case "tuple":
153
+ return await this.getEndpoint(objToQuery(query), "tuple");
154
+ default:
155
+ return await this.getEndpoint(objToQuery(query));
156
+ }
157
+ }
158
+ async get(responseType) {
159
+ switch (responseType) {
160
+ case "tuple":
161
+ return await this.getEndpoint(void 0, "tuple");
162
+ default:
163
+ return await this.getEndpoint(void 0);
164
+ }
165
+ }
166
+ async post(data, responseType) {
167
+ switch (responseType) {
168
+ case "tuple":
169
+ return await this.postEndpoint(void 0, data, "tuple");
170
+ default:
171
+ return await this.postEndpoint(void 0, data);
172
+ }
173
+ }
174
+ async put(data, responseType) {
175
+ switch (responseType) {
176
+ case "tuple":
177
+ return await this.putEndpoint(void 0, data, "tuple");
178
+ default:
179
+ return await this.putEndpoint(void 0, data);
180
+ }
181
+ }
182
+ };
183
+
184
+ // src/Api/Api.ts
185
+ var ArchivistApi = class extends ApiSimple {
186
+ huri(huri) {
187
+ const huriObj = typeof huri === "string" ? new import_huri.Huri(huri) : huri;
188
+ return new ApiSimple({
189
+ ...this.config,
190
+ root: `${this.root}${huriObj.href}/`
191
+ });
192
+ }
193
+ };
19
194
  // Annotate the CommonJS export names for ESM import in node:
20
195
  0 && (module.exports = {
21
- ...require("./Api")
196
+ ArchivistApi
22
197
  });
23
198
  //# sourceMappingURL=index.js.map