@xyo-network/api 2.107.3 → 2.107.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,335 @@
1
- "use strict";var f=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var s=(o,t)=>f(o,"name",{value:t,configurable:!0});var j=(o,t)=>{for(var e in t)f(o,e,{get:t[e],enumerable:!0})},D=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!T.call(o,r)&&r!==e&&f(o,r,{get:()=>t[r],enumerable:!(n=L(t,r))||n.enumerable});return o};var b=o=>D(f({},"__esModule",{value:!0}),o);var B={};j(B,{ApiBase:()=>h,ApiSimple:()=>p,ArchivistApi:()=>l,CurrentLocationWitnessSchema:()=>W,LocationDivinerApi:()=>H,LocationTimeRangeAnswerSchema:()=>S,LocationTimeRangeQuerySchema:()=>M,LocationWitnessSchema:()=>z,RemoteDivinerConfigSchema:()=>J,isLocationHeatmapQuery:()=>F,isLocationQuadkeyHeatmapQuery:()=>q,isLocationTimeRangeQuery:()=>O,isSupportedLocationQuerySchema:()=>P,locationHeatmapAnswerSchema:()=>A,locationHeatmapQuerySchema:()=>k,locationQuadkeyHeatmapAnswerSchema:()=>C,locationQuadkeyHeatmapQuerySchema:()=>Q});module.exports=b(B);var y=require("@xyo-network/huri");var x=require("@xylabs/axios");var c=class c{config;axios;constructor(t){this.config=t,this.axios=new x.AxiosJson({...this.config,headers:this.headers})}get authenticated(){return!!this.config.apiKey||!!this.config.jwtToken}get headers(){let t={};return this.config.jwtToken&&(t.Authorization=`Bearer ${this.config.jwtToken}`),this.config.apiKey&&(t["x-api-key"]=this.config.apiKey),t}get query(){return this.config.query??""}get root(){return this.config.root??"/"}static resolveResponse(t){var e;return[(e=t==null?void 0:t.data)==null?void 0:e.data,t==null?void 0:t.data,t]}static shapeResponse(t,e){let n=c.resolveResponse(t);return e==="tuple"?n:n[0]}onError(t,e=0){var n,r,i,a;(r=(n=this.config.reportableParent)==null?void 0:n.onError)==null||r.call(n,t,e+1),(a=(i=this.config).onError)==null||a.call(i,t,e)}onFailure(t,e=0){var n,r,i,a;(r=(n=this.config.reportableParent)==null?void 0:n.onFailure)==null||r.call(n,t,e+1),(a=(i=this.config).onFailure)==null||a.call(i,t,e)}onSuccess(t,e=0){var n,r,i,a;(r=(n=this.config.reportableParent)==null?void 0:n.onSuccess)==null||r.call(n,t,e+1),(a=(i=this.config).onSuccess)==null||a.call(i,t,e)}async deleteEndpoint(t="",e){let n=await this.monitorResponse(async()=>await this.axios.delete(`${this.resolveRoot()}${t}${this.query}`));return c.shapeResponse(n,e)}async getEndpoint(t="",e){let n=await this.monitorResponse(async()=>await this.axios.get(`${this.resolveRoot()}${t}${this.query}`));return c.shapeResponse(n,e)}handleMonitorResponseError(t,e){if(!t.isError)throw t;if(e){if(t.response?this.onFailure(t.response):this.onError(t),this.config.throwFailure)throw t;return t.response}}async monitorResponse(t){let e=!0;try{let n=await t();return e=!1,n.status<300?this.onSuccess(n):this.onFailure(n),n}catch(n){this.handleMonitorResponseError(n,e)}}async postEndpoint(t="",e,n){let r=await this.monitorResponse(async()=>await this.axios.post(`${this.resolveRoot()}${t}${this.query}`,e));return c.shapeResponse(r,n)}async putEndpoint(t="",e,n){let r=await this.monitorResponse(async()=>await this.axios.put(`${this.resolveRoot()}${t}${this.query}`,e));return c.shapeResponse(r,n)}resolveRoot(){return`${this.config.apiDomain}${this.root}`}};s(c,"ApiBase");var h=c;var m=s(o=>`?${Object.entries(o).map(([t,e])=>`${t}=${e}`).filter(t=>t!==void 0).join("&")}`,"objToQuery");var d=class d extends h{async delete(t){switch(t){case"tuple":return await this.deleteEndpoint(void 0,"tuple");default:return await this.deleteEndpoint()}}async find(t={},e){switch(e){case"tuple":return await this.getEndpoint(m(t),"tuple");default:return await this.getEndpoint(m(t))}}async get(t){switch(t){case"tuple":return await this.getEndpoint(void 0,"tuple");default:return await this.getEndpoint()}}async post(t,e){switch(e){case"tuple":return await this.postEndpoint(void 0,t,"tuple");default:return await this.postEndpoint(void 0,t)}}async put(t,e){switch(e){case"tuple":return await this.putEndpoint(void 0,t,"tuple");default:return await this.putEndpoint(void 0,t)}}};s(d,"ApiSimple");var p=d;var w=class w extends p{huri(t){let e=typeof t=="string"?new y.Huri(t):t;return new p({...this.config,root:`${this.root}${e.href}/`})}};s(w,"ArchivistApi");var l=w;var g=require("@xylabs/axios");var $=require("@xylabs/axios");var R=s((o,t)=>o.data,"locationDivinerApiResponseTransformer"),E=s((o=$.axios)=>o.defaults.transformResponse?[...Array.isArray(o.defaults.transformResponse)?o.defaults.transformResponse:[o.defaults.transformResponse],R]:[R],"getLocationDivinerApiResponseTransformer");var u,H=(u=class{config;constructor(t){this.config=t}get axiosRequestConfig(){return{transformResponse:E()}}async getLocationQuery(t){return(await g.axios.get(`${this.config.apiDomain}/location/query/${t}`,this.axiosRequestConfig)).data}async postLocationQuery(t){return(await g.axios.post(`${this.config.apiDomain}/location/query`,{...t},this.axiosRequestConfig)).data}},s(u,"LocationDivinerApi"),u);var k="network.xyo.location.heatmap.query",A="network.xyo.location.heatmap.answer",F=s(o=>o&&(o==null?void 0:o.schema)===k,"isLocationHeatmapQuery");var Q="network.xyo.location.heatmap.quadkey.query",C="network.xyo.location.heatmap.quadkey.answer",q=s(o=>o&&(o==null?void 0:o.schema)===Q,"isLocationQuadkeyHeatmapQuery");var K={"network.xyo.location.heatmap.quadkey.query":!0,"network.xyo.location.heatmap.query":!0,"network.xyo.location.range.query":!0},P=s(o=>K[o]||!1,"isSupportedLocationQuerySchema");var M="network.xyo.location.range.query",S="network.xyo.location.range.answer",O=s(o=>o&&(o==null?void 0:o.schema)===S,"isLocationTimeRangeQuery");var W="co.coinapp.currentlocationwitness";var z="network.xyo.location";var J="network.xyo.diviner.remote.config";0&&(module.exports={ApiBase,ApiSimple,ArchivistApi,CurrentLocationWitnessSchema,LocationDivinerApi,LocationTimeRangeAnswerSchema,LocationTimeRangeQuerySchema,LocationWitnessSchema,RemoteDivinerConfigSchema,isLocationHeatmapQuery,isLocationQuadkeyHeatmapQuery,isLocationTimeRangeQuery,isSupportedLocationQuerySchema,locationHeatmapAnswerSchema,locationHeatmapQuerySchema,locationQuadkeyHeatmapAnswerSchema,locationQuadkeyHeatmapQuerySchema});
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ ApiBase: () => ApiBase,
25
+ ApiSimple: () => ApiSimple,
26
+ ArchivistApi: () => ArchivistApi,
27
+ CurrentLocationWitnessSchema: () => CurrentLocationWitnessSchema,
28
+ LocationDivinerApi: () => LocationDivinerApi,
29
+ LocationTimeRangeAnswerSchema: () => LocationTimeRangeAnswerSchema,
30
+ LocationTimeRangeQuerySchema: () => LocationTimeRangeQuerySchema,
31
+ LocationWitnessSchema: () => LocationWitnessSchema,
32
+ RemoteDivinerConfigSchema: () => RemoteDivinerConfigSchema,
33
+ isLocationHeatmapQuery: () => isLocationHeatmapQuery,
34
+ isLocationQuadkeyHeatmapQuery: () => isLocationQuadkeyHeatmapQuery,
35
+ isLocationTimeRangeQuery: () => isLocationTimeRangeQuery,
36
+ isSupportedLocationQuerySchema: () => isSupportedLocationQuerySchema,
37
+ locationHeatmapAnswerSchema: () => locationHeatmapAnswerSchema,
38
+ locationHeatmapQuerySchema: () => locationHeatmapQuerySchema,
39
+ locationQuadkeyHeatmapAnswerSchema: () => locationQuadkeyHeatmapAnswerSchema,
40
+ locationQuadkeyHeatmapQuerySchema: () => locationQuadkeyHeatmapQuerySchema
41
+ });
42
+ module.exports = __toCommonJS(src_exports);
43
+
44
+ // src/Api/Api.ts
45
+ var import_huri = require("@xyo-network/huri");
46
+
47
+ // src/Base.ts
48
+ var import_axios = require("@xylabs/axios");
49
+ var _ApiBase = class _ApiBase {
50
+ config;
51
+ axios;
52
+ constructor(config) {
53
+ this.config = config;
54
+ this.axios = new import_axios.AxiosJson({
55
+ ...this.config,
56
+ headers: this.headers
57
+ });
58
+ }
59
+ get authenticated() {
60
+ return !!this.config.apiKey || !!this.config.jwtToken;
61
+ }
62
+ get headers() {
63
+ const headers = {};
64
+ if (this.config.jwtToken) {
65
+ headers.Authorization = `Bearer ${this.config.jwtToken}`;
66
+ }
67
+ if (this.config.apiKey) {
68
+ headers["x-api-key"] = this.config.apiKey;
69
+ }
70
+ return headers;
71
+ }
72
+ get query() {
73
+ return this.config.query ?? "";
74
+ }
75
+ get root() {
76
+ return this.config.root ?? "/";
77
+ }
78
+ static resolveResponse(result) {
79
+ var _a2;
80
+ return [
81
+ (_a2 = result == null ? void 0 : result.data) == null ? void 0 : _a2.data,
82
+ result == null ? void 0 : result.data,
83
+ result
84
+ ];
85
+ }
86
+ static shapeResponse(response, responseType) {
87
+ const resolvedResponse = _ApiBase.resolveResponse(response);
88
+ return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
89
+ }
90
+ onError(error, depth = 0) {
91
+ var _a2, _b, _c, _d;
92
+ (_b = (_a2 = this.config.reportableParent) == null ? void 0 : _a2.onError) == null ? void 0 : _b.call(_a2, error, depth + 1);
93
+ (_d = (_c = this.config).onError) == null ? void 0 : _d.call(_c, error, depth);
94
+ }
95
+ onFailure(response, depth = 0) {
96
+ var _a2, _b, _c, _d;
97
+ (_b = (_a2 = this.config.reportableParent) == null ? void 0 : _a2.onFailure) == null ? void 0 : _b.call(_a2, response, depth + 1);
98
+ (_d = (_c = this.config).onFailure) == null ? void 0 : _d.call(_c, response, depth);
99
+ }
100
+ onSuccess(response, depth = 0) {
101
+ var _a2, _b, _c, _d;
102
+ (_b = (_a2 = this.config.reportableParent) == null ? void 0 : _a2.onSuccess) == null ? void 0 : _b.call(_a2, response, depth + 1);
103
+ (_d = (_c = this.config).onSuccess) == null ? void 0 : _d.call(_c, response, depth);
104
+ }
105
+ async deleteEndpoint(endPoint = "", responseType) {
106
+ const response = await this.monitorResponse(async () => {
107
+ return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
108
+ });
109
+ return _ApiBase.shapeResponse(response, responseType);
110
+ }
111
+ async getEndpoint(endPoint = "", responseType) {
112
+ const response = await this.monitorResponse(async () => {
113
+ return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
114
+ });
115
+ return _ApiBase.shapeResponse(response, responseType);
116
+ }
117
+ handleMonitorResponseError(error, trapAxiosException) {
118
+ if (!error.isError) {
119
+ throw error;
120
+ }
121
+ if (trapAxiosException) {
122
+ error.response ? this.onFailure(error.response) : this.onError(error);
123
+ if (this.config.throwFailure) {
124
+ throw error;
125
+ }
126
+ return error.response;
127
+ }
128
+ }
129
+ async monitorResponse(closure) {
130
+ let trapAxiosException = true;
131
+ try {
132
+ const response = await closure();
133
+ trapAxiosException = false;
134
+ response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
135
+ return response;
136
+ } catch (error) {
137
+ this.handleMonitorResponseError(error, trapAxiosException);
138
+ }
139
+ }
140
+ async postEndpoint(endPoint = "", data, responseType) {
141
+ const response = await this.monitorResponse(async () => {
142
+ return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
143
+ });
144
+ return _ApiBase.shapeResponse(response, responseType);
145
+ }
146
+ async putEndpoint(endPoint = "", data, responseType) {
147
+ const response = await this.monitorResponse(async () => {
148
+ return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
149
+ });
150
+ return _ApiBase.shapeResponse(response, responseType);
151
+ }
152
+ resolveRoot() {
153
+ return `${this.config.apiDomain}${this.root}`;
154
+ }
155
+ };
156
+ __name(_ApiBase, "ApiBase");
157
+ var ApiBase = _ApiBase;
158
+
159
+ // src/objToQuery.ts
160
+ var objToQuery = /* @__PURE__ */ __name((obj) => {
161
+ return `?${Object.entries(obj).map(([key, value]) => {
162
+ return `${key}=${value}`;
163
+ }).filter((value) => value !== void 0).join("&")}`;
164
+ }, "objToQuery");
165
+
166
+ // src/Simple.ts
167
+ var _ApiSimple = class _ApiSimple extends ApiBase {
168
+ async delete(responseType) {
169
+ switch (responseType) {
170
+ case "tuple": {
171
+ return await this.deleteEndpoint(void 0, "tuple");
172
+ }
173
+ default: {
174
+ return await this.deleteEndpoint();
175
+ }
176
+ }
177
+ }
178
+ async find(query = {}, responseType) {
179
+ switch (responseType) {
180
+ case "tuple": {
181
+ return await this.getEndpoint(objToQuery(query), "tuple");
182
+ }
183
+ default: {
184
+ return await this.getEndpoint(objToQuery(query));
185
+ }
186
+ }
187
+ }
188
+ async get(responseType) {
189
+ switch (responseType) {
190
+ case "tuple": {
191
+ return await this.getEndpoint(void 0, "tuple");
192
+ }
193
+ default: {
194
+ return await this.getEndpoint();
195
+ }
196
+ }
197
+ }
198
+ async post(data, responseType) {
199
+ switch (responseType) {
200
+ case "tuple": {
201
+ return await this.postEndpoint(void 0, data, "tuple");
202
+ }
203
+ default: {
204
+ return await this.postEndpoint(void 0, data);
205
+ }
206
+ }
207
+ }
208
+ async put(data, responseType) {
209
+ switch (responseType) {
210
+ case "tuple": {
211
+ return await this.putEndpoint(void 0, data, "tuple");
212
+ }
213
+ default: {
214
+ return await this.putEndpoint(void 0, data);
215
+ }
216
+ }
217
+ }
218
+ };
219
+ __name(_ApiSimple, "ApiSimple");
220
+ var ApiSimple = _ApiSimple;
221
+
222
+ // src/Api/Api.ts
223
+ var _ArchivistApi = class _ArchivistApi extends ApiSimple {
224
+ huri(huri) {
225
+ const huriObj = typeof huri === "string" ? new import_huri.Huri(huri) : huri;
226
+ return new ApiSimple({
227
+ ...this.config,
228
+ root: `${this.root}${huriObj.href}/`
229
+ });
230
+ }
231
+ };
232
+ __name(_ArchivistApi, "ArchivistApi");
233
+ var ArchivistApi = _ArchivistApi;
234
+
235
+ // src/Diviner/LocationDiviner/LocationDivinerApi.ts
236
+ var import_axios3 = require("@xylabs/axios");
237
+
238
+ // src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts
239
+ var import_axios2 = require("@xylabs/axios");
240
+ var locationDivinerApiResponseTransformer = /* @__PURE__ */ __name((data, _headers) => {
241
+ return data.data;
242
+ }, "locationDivinerApiResponseTransformer");
243
+ var getLocationDivinerApiResponseTransformer = /* @__PURE__ */ __name((axiosInstance = import_axios2.axios) => {
244
+ return axiosInstance.defaults.transformResponse ? [
245
+ ...Array.isArray(axiosInstance.defaults.transformResponse) ? axiosInstance.defaults.transformResponse : [
246
+ axiosInstance.defaults.transformResponse
247
+ ],
248
+ locationDivinerApiResponseTransformer
249
+ ] : [
250
+ locationDivinerApiResponseTransformer
251
+ ];
252
+ }, "getLocationDivinerApiResponseTransformer");
253
+
254
+ // src/Diviner/LocationDiviner/LocationDivinerApi.ts
255
+ var _a;
256
+ var LocationDivinerApi = (_a = class {
257
+ config;
258
+ constructor(config) {
259
+ this.config = config;
260
+ }
261
+ get axiosRequestConfig() {
262
+ return {
263
+ transformResponse: getLocationDivinerApiResponseTransformer()
264
+ };
265
+ }
266
+ async getLocationQuery(hash) {
267
+ return (await import_axios3.axios.get(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data;
268
+ }
269
+ async postLocationQuery(request) {
270
+ return (await import_axios3.axios.post(`${this.config.apiDomain}/location/query`, {
271
+ ...request
272
+ }, this.axiosRequestConfig)).data;
273
+ }
274
+ }, __name(_a, "LocationDivinerApi"), _a);
275
+
276
+ // src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts
277
+ var locationHeatmapQuerySchema = "network.xyo.location.heatmap.query";
278
+ var locationHeatmapAnswerSchema = "network.xyo.location.heatmap.answer";
279
+ var isLocationHeatmapQuery = /* @__PURE__ */ __name((query) => {
280
+ return query && (query == null ? void 0 : query.schema) === locationHeatmapQuerySchema;
281
+ }, "isLocationHeatmapQuery");
282
+
283
+ // src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts
284
+ var locationQuadkeyHeatmapQuerySchema = "network.xyo.location.heatmap.quadkey.query";
285
+ var locationQuadkeyHeatmapAnswerSchema = "network.xyo.location.heatmap.quadkey.answer";
286
+ var isLocationQuadkeyHeatmapQuery = /* @__PURE__ */ __name((query) => {
287
+ return query && (query == null ? void 0 : query.schema) === locationQuadkeyHeatmapQuerySchema;
288
+ }, "isLocationQuadkeyHeatmapQuery");
289
+
290
+ // src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts
291
+ var locationQuerySchemas = {
292
+ "network.xyo.location.heatmap.quadkey.query": true,
293
+ "network.xyo.location.heatmap.query": true,
294
+ "network.xyo.location.range.query": true
295
+ };
296
+ var isSupportedLocationQuerySchema = /* @__PURE__ */ __name((schema) => {
297
+ return locationQuerySchemas[schema] || false;
298
+ }, "isSupportedLocationQuerySchema");
299
+
300
+ // src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts
301
+ var LocationTimeRangeQuerySchema = "network.xyo.location.range.query";
302
+ var LocationTimeRangeAnswerSchema = "network.xyo.location.range.answer";
303
+ var isLocationTimeRangeQuery = /* @__PURE__ */ __name((query) => {
304
+ return query && (query == null ? void 0 : query.schema) === LocationTimeRangeAnswerSchema;
305
+ }, "isLocationTimeRangeQuery");
306
+
307
+ // src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts
308
+ var CurrentLocationWitnessSchema = "co.coinapp.currentlocationwitness";
309
+
310
+ // src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts
311
+ var LocationWitnessSchema = "network.xyo.location";
312
+
313
+ // src/Diviner/RemoteDivinerConfig.ts
314
+ var RemoteDivinerConfigSchema = "network.xyo.diviner.remote.config";
315
+ // Annotate the CommonJS export names for ESM import in node:
316
+ 0 && (module.exports = {
317
+ ApiBase,
318
+ ApiSimple,
319
+ ArchivistApi,
320
+ CurrentLocationWitnessSchema,
321
+ LocationDivinerApi,
322
+ LocationTimeRangeAnswerSchema,
323
+ LocationTimeRangeQuerySchema,
324
+ LocationWitnessSchema,
325
+ RemoteDivinerConfigSchema,
326
+ isLocationHeatmapQuery,
327
+ isLocationQuadkeyHeatmapQuery,
328
+ isLocationTimeRangeQuery,
329
+ isSupportedLocationQuerySchema,
330
+ locationHeatmapAnswerSchema,
331
+ locationHeatmapQuerySchema,
332
+ locationQuadkeyHeatmapAnswerSchema,
333
+ locationQuadkeyHeatmapQuerySchema
334
+ });
2
335
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Api/Api.ts","../../src/Base.ts","../../src/objToQuery.ts","../../src/Simple.ts","../../src/Diviner/LocationDiviner/LocationDivinerApi.ts","../../src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts","../../src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts","../../src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts","../../src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts","../../src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts","../../src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts","../../src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts","../../src/Diviner/RemoteDivinerConfig.ts"],"sourcesContent":["export * from './Api'\nexport * from './Base'\nexport * from './Diviner'\nexport * from './models'\nexport * from './Simple'\nexport * from './WithArchive'\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 { AxiosJson } from '@xylabs/axios'\nimport {\n ApiConfig,\n ApiEnvelope,\n ApiError,\n ApiReportable,\n ApiResponse,\n ApiResponseBody,\n ApiResponseTuple,\n ApiResponseTupleOrBody,\n ApiResponseType,\n} from '@xyo-network/api-models'\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 (error) {\n this.handleMonitorResponseError(error 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 }\n default: {\n return await this.deleteEndpoint()\n }\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 }\n default: {\n return await this.getEndpoint(objToQuery(query))\n }\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 }\n default: {\n return await this.getEndpoint()\n }\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 }\n default: {\n return await this.postEndpoint(undefined, data)\n }\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 }\n default: {\n return await this.putEndpoint(undefined, data)\n }\n }\n }\n}\n","import { axios, RawAxiosRequestConfig } from '@xylabs/axios'\nimport { ApiConfig } from '@xyo-network/api-models'\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 '@xylabs/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 [\n ...(Array.isArray(axiosInstance.defaults.transformResponse) ?\n axiosInstance.defaults.transformResponse\n : [axiosInstance.defaults.transformResponse]),\n locationDivinerApiResponseTransformer,\n ]\n : [locationDivinerApiResponseTransformer]\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\nexport const locationHeatmapQuerySchema: LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\n\nexport type LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\nexport const locationHeatmapAnswerSchema: LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\n\nexport type LocationHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationHeatmapQuery = (query: Record<string, unknown>): query is LocationHeatmapQuery => {\n return query && query?.schema === locationHeatmapQuerySchema\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport const locationQuadkeyHeatmapQuerySchema: LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport type LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport const locationQuadkeyHeatmapAnswerSchema: LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport type LocationQuadkeyHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationQuadkeyHeatmapQuery = (query: Record<string, unknown>): query is LocationQuadkeyHeatmapQuery => {\n return query && query?.schema === locationQuadkeyHeatmapQuerySchema\n}\n","import { LocationHeatmapQuerySchema } from './LocationHeatmapQuery'\nimport { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery'\nimport { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<LocationQuerySchema, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: string): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema] || false\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\nexport const LocationTimeRangeQuerySchema: LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\n\nexport type LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\nexport const LocationTimeRangeAnswerSchema: LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\n\nexport type LocationTimeRangeQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n\n // TODO: Bounding rectangle, etc.\n}\n\nexport const isLocationTimeRangeQuery = (query: Record<string, unknown>): query is LocationTimeRangeQuery => {\n return query && query?.schema === LocationTimeRangeAnswerSchema\n}\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\nexport const CurrentLocationWitnessSchema: CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\n\nexport type CurrentLocationWitnessPayload = Payload<{\n altitudeMeters: number\n directionDegrees: number\n latitude: number\n longitude: number\n quadkey: string\n schema: CurrentLocationWitnessSchema\n speedKph: number\n}>\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type LocationWitnessSchema = 'network.xyo.location'\nexport const LocationWitnessSchema: LocationWitnessSchema = 'network.xyo.location'\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport type LocationWitnessPayload = Payload<{\n currentLocation: CurrentLocation\n schema: LocationWitnessSchema\n}>\n","import { DivinerConfig } from '@xyo-network/diviner-model'\n\nimport { ArchivistApi } from '../Api'\n\nexport type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\nexport const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\n\nexport type RemoteDivinerConfig = DivinerConfig & {\n /** @deprecated use in params instead */\n api?: ArchivistApi\n archive?: string\n schema: RemoteDivinerConfigSchema\n}\n"],"mappings":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,cAAAC,EAAA,iBAAAC,EAAA,iCAAAC,EAAA,uBAAAC,EAAA,kCAAAC,EAAA,iCAAAC,EAAA,0BAAAC,EAAA,8BAAAC,EAAA,2BAAAC,EAAA,kCAAAC,EAAA,6BAAAC,EAAA,mCAAAC,EAAA,gCAAAC,EAAA,+BAAAC,EAAA,uCAAAC,EAAA,sCAAAC,IAAA,eAAAC,EAAAnB,GCCA,IAAAoB,EAAqB,6BCDrB,IAAAC,EAA0B,yBAanB,IAAMC,EAAN,MAAMA,CAAAA,CACFC,OACCC,MAEVC,YAAYF,EAAW,CACrB,KAAKA,OAASA,EACd,KAAKC,MAAQ,IAAIE,YAAU,CAAE,GAAG,KAAKH,OAAQI,QAAS,KAAKA,OAAQ,CAAA,CACrE,CAEA,IAAIC,eAAgB,CAClB,MAAO,CAAC,CAAC,KAAKL,OAAOM,QAAU,CAAC,CAAC,KAAKN,OAAOO,QAC/C,CAEA,IAAcH,SAAkC,CAC9C,IAAMA,EAAkC,CAAC,EACzC,OAAI,KAAKJ,OAAOO,WACdH,EAAQI,cAAgB,UAAU,KAAKR,OAA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F,CAEA,MAAMC,iBAAiBC,EAAc,CACnC,OAAQ,MAAMC,QAAMC,IAA8B,GAAG,KAAKR,OAAOS,SAAS,mBAAmBH,CAAAA,GAAQ,KAAKJ,kBAAkB,GAAGQ,IACjI,CAEA,MAAMC,kBAAkBC,EAAgD,CACtE,OAAQ,MAAML,QAAMM,KAAoC,GAAG,KAAKb,OAAOS,SAAS,kBAAmB,CAAE,GAAGG,CAAQ,EAAG,KAAKV,kBAAkB,GAAGQ,IAC/I,CACF,EAnBMX,EAAAA,EAAAA,sBAAND,GEJO,IAAMgB,EAAyD,qCAGzDC,EAA2D,sCAQ3DC,EAAyBC,EAACC,GAC9BA,IAASA,GAAAA,YAAAA,EAAOC,UAAWL,EADE,0BCX/B,IAAMM,EAAuE,6CAEvEC,EAAyE,8CAOzEC,EAAgCC,EAACC,GACrCA,IAASA,GAAAA,YAAAA,EAAOC,UAAWL,EADS,iCCN7C,IAAMM,EAA0D,CAC9D,6CAA8C,GAC9C,qCAAsC,GACtC,mCAAoC,EACtC,EAEaC,EAAiCC,EAACC,GACtCH,EAAqBG,CAAAA,GAAkC,GADlB,kCCTvC,IAAMC,EAA6D,mCAG7DC,EAA+D,oCAU/DC,EAA2BC,EAACC,GAChCA,IAASA,GAAAA,YAAAA,EAAOC,UAAWJ,EADI,4BCbjC,IAAMK,EAA6D,oCCAnE,IAAMC,EAA+C,uBCErD,IAAMC,EAAuD","names":["src_exports","__export","ApiBase","ApiSimple","ArchivistApi","CurrentLocationWitnessSchema","LocationDivinerApi","LocationTimeRangeAnswerSchema","LocationTimeRangeQuerySchema","LocationWitnessSchema","RemoteDivinerConfigSchema","isLocationHeatmapQuery","isLocationQuadkeyHeatmapQuery","isLocationTimeRangeQuery","isSupportedLocationQuerySchema","locationHeatmapAnswerSchema","locationHeatmapQuerySchema","locationQuadkeyHeatmapAnswerSchema","locationQuadkeyHeatmapQuerySchema","__toCommonJS","import_huri","import_axios","ApiBase","config","axios","constructor","AxiosJson","headers","authenticated","apiKey","jwtToken","Authorization","query","root","resolveResponse","result","_a","data","shapeResponse","response","responseType","resolvedResponse","onError","error","depth","_b","_c","_d","reportableParent","onFailure","onSuccess","deleteEndpoint","endPoint","monitorResponse","delete","resolveRoot","getEndpoint","get","handleMonitorResponseError","trapAxiosException","isError","throwFailure","closure","status","postEndpoint","post","putEndpoint","put","apiDomain","_ApiBase","objToQuery","__name","obj","Object","entries","map","key","value","filter","undefined","join","ApiSimple","ApiBase","delete","responseType","deleteEndpoint","undefined","find","query","getEndpoint","objToQuery","get","post","data","postEndpoint","put","putEndpoint","_ApiSimple","ArchivistApi","ApiSimple","huri","huriObj","Huri","config","root","href","_ArchivistApi","import_axios","import_axios","locationDivinerApiResponseTransformer","__name","data","_headers","getLocationDivinerApiResponseTransformer","axiosInstance","axios","defaults","transformResponse","Array","isArray","_a","LocationDivinerApi","config","constructor","axiosRequestConfig","transformResponse","getLocationDivinerApiResponseTransformer","getLocationQuery","hash","axios","get","apiDomain","data","postLocationQuery","request","post","locationHeatmapQuerySchema","locationHeatmapAnswerSchema","isLocationHeatmapQuery","__name","query","schema","locationQuadkeyHeatmapQuerySchema","locationQuadkeyHeatmapAnswerSchema","isLocationQuadkeyHeatmapQuery","__name","query","schema","locationQuerySchemas","isSupportedLocationQuerySchema","__name","schema","LocationTimeRangeQuerySchema","LocationTimeRangeAnswerSchema","isLocationTimeRangeQuery","__name","query","schema","CurrentLocationWitnessSchema","LocationWitnessSchema","RemoteDivinerConfigSchema"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/Api/Api.ts","../../src/Base.ts","../../src/objToQuery.ts","../../src/Simple.ts","../../src/Diviner/LocationDiviner/LocationDivinerApi.ts","../../src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts","../../src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts","../../src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts","../../src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts","../../src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts","../../src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts","../../src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts","../../src/Diviner/RemoteDivinerConfig.ts"],"sourcesContent":["export * from './Api'\nexport * from './Base'\nexport * from './Diviner'\nexport * from './models'\nexport * from './Simple'\nexport * from './WithArchive'\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 { AxiosJson } from '@xylabs/axios'\nimport {\n ApiConfig,\n ApiEnvelope,\n ApiError,\n ApiReportable,\n ApiResponse,\n ApiResponseBody,\n ApiResponseTuple,\n ApiResponseTupleOrBody,\n ApiResponseType,\n} from '@xyo-network/api-models'\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 (error) {\n this.handleMonitorResponseError(error 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 }\n default: {\n return await this.deleteEndpoint()\n }\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 }\n default: {\n return await this.getEndpoint(objToQuery(query))\n }\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 }\n default: {\n return await this.getEndpoint()\n }\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 }\n default: {\n return await this.postEndpoint(undefined, data)\n }\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 }\n default: {\n return await this.putEndpoint(undefined, data)\n }\n }\n }\n}\n","import { axios, RawAxiosRequestConfig } from '@xylabs/axios'\nimport { ApiConfig } from '@xyo-network/api-models'\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 '@xylabs/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 [\n ...(Array.isArray(axiosInstance.defaults.transformResponse) ?\n axiosInstance.defaults.transformResponse\n : [axiosInstance.defaults.transformResponse]),\n locationDivinerApiResponseTransformer,\n ]\n : [locationDivinerApiResponseTransformer]\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\nexport const locationHeatmapQuerySchema: LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query'\n\nexport type LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\nexport const locationHeatmapAnswerSchema: LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\n\nexport type LocationHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationHeatmapQuery = (query: Record<string, unknown>): query is LocationHeatmapQuery => {\n return query && query?.schema === locationHeatmapQuerySchema\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport const locationQuadkeyHeatmapQuerySchema: LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query'\nexport type LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport const locationQuadkeyHeatmapAnswerSchema: LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport type LocationQuadkeyHeatmapQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n}\n\nexport const isLocationQuadkeyHeatmapQuery = (query: Record<string, unknown>): query is LocationQuadkeyHeatmapQuery => {\n return query && query?.schema === locationQuadkeyHeatmapQuerySchema\n}\n","import { LocationHeatmapQuerySchema } from './LocationHeatmapQuery'\nimport { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery'\nimport { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<LocationQuerySchema, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: string): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema] || false\n}\n","import { LocationWitnessSchema } from '../../Witnesses'\n\nexport type LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\nexport const LocationTimeRangeQuerySchema: LocationTimeRangeQuerySchema = 'network.xyo.location.range.query'\n\nexport type LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\nexport const LocationTimeRangeAnswerSchema: LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer'\n\nexport type LocationTimeRangeQuery = {\n schema: LocationWitnessSchema\n startTime?: string\n stopTime?: string\n\n // TODO: Bounding rectangle, etc.\n}\n\nexport const isLocationTimeRangeQuery = (query: Record<string, unknown>): query is LocationTimeRangeQuery => {\n return query && query?.schema === LocationTimeRangeAnswerSchema\n}\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\nexport const CurrentLocationWitnessSchema: CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness'\n\nexport type CurrentLocationWitnessPayload = Payload<{\n altitudeMeters: number\n directionDegrees: number\n latitude: number\n longitude: number\n quadkey: string\n schema: CurrentLocationWitnessSchema\n speedKph: number\n}>\n","import { Payload } from '@xyo-network/payload-model'\n\nexport type LocationWitnessSchema = 'network.xyo.location'\nexport const LocationWitnessSchema: LocationWitnessSchema = 'network.xyo.location'\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport type LocationWitnessPayload = Payload<{\n currentLocation: CurrentLocation\n schema: LocationWitnessSchema\n}>\n","import { DivinerConfig } from '@xyo-network/diviner-model'\n\nimport { ArchivistApi } from '../Api'\n\nexport type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\nexport const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\n\nexport type RemoteDivinerConfig = DivinerConfig & {\n /** @deprecated use in params instead */\n api?: ArchivistApi\n archive?: string\n schema: RemoteDivinerConfigSchema\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;ACCA,kBAAqB;;;ACDrB,mBAA0B;AAanB,IAAMA,WAAN,MAAMA,SAAAA;EACFC;EACCC;EAEVC,YAAYF,QAAW;AACrB,SAAKA,SAASA;AACd,SAAKC,QAAQ,IAAIE,uBAAU;MAAE,GAAG,KAAKH;MAAQI,SAAS,KAAKA;IAAQ,CAAA;EACrE;EAEA,IAAIC,gBAAgB;AAClB,WAAO,CAAC,CAAC,KAAKL,OAAOM,UAAU,CAAC,CAAC,KAAKN,OAAOO;EAC/C;EAEA,IAAcH,UAAkC;AAC9C,UAAMA,UAAkC,CAAC;AACzC,QAAI,KAAKJ,OAAOO,UAAU;AACxBH,cAAQI,gBAAgB,UAAU,KAAKR,OAAOO,QAAQ;IACxD;AACA,QAAI,KAAKP,OA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;MACLC,mBAAmBC,yCAAAA;IACrB;EACF;EAEA,MAAMC,iBAAiBC,MAAc;AACnC,YAAQ,MAAMC,oBAAMC,IAA8B,GAAG,KAAKR,OAAOS,SAAS,mBAAmBH,IAAAA,IAAQ,KAAKJ,kBAAkB,GAAGQ;EACjI;EAEA,MAAMC,kBAAkBC,SAAgD;AACtE,YAAQ,MAAML,oBAAMM,KAAoC,GAAG,KAAKb,OAAOS,SAAS,mBAAmB;MAAE,GAAGG;IAAQ,GAAG,KAAKV,kBAAkB,GAAGQ;EAC/I;AACF,GAnBMX,kCAAN;;;AEJO,IAAMe,6BAAyD;AAG/D,IAAMC,8BAA2D;AAQjE,IAAMC,yBAAyB,wBAACC,UAAAA;AACrC,SAAOA,UAASA,+BAAOC,YAAWJ;AACpC,GAFsC;;;ACX/B,IAAMK,oCAAuE;AAE7E,IAAMC,qCAAyE;AAO/E,IAAMC,gCAAgC,wBAACC,UAAAA;AAC5C,SAAOA,UAASA,+BAAOC,YAAWJ;AACpC,GAF6C;;;ACN7C,IAAMK,uBAA0D;EAC9D,8CAA8C;EAC9C,sCAAsC;EACtC,oCAAoC;AACtC;AAEO,IAAMC,iCAAiC,wBAACC,WAAAA;AAC7C,SAAOF,qBAAqBE,MAAAA,KAAkC;AAChE,GAF8C;;;ACTvC,IAAMC,+BAA6D;AAGnE,IAAMC,gCAA+D;AAUrE,IAAMC,2BAA2B,wBAACC,UAAAA;AACvC,SAAOA,UAASA,+BAAOC,YAAWH;AACpC,GAFwC;;;ACbjC,IAAMI,+BAA6D;;;ACAnE,IAAMC,wBAA+C;;;ACErD,IAAMC,4BAAuD;","names":["ApiBase","config","axios","constructor","AxiosJson","headers","authenticated","apiKey","jwtToken","Authorization","query","root","resolveResponse","result","_a","data","shapeResponse","response","responseType","resolvedResponse","onError","error","depth","reportableParent","onFailure","onSuccess","deleteEndpoint","endPoint","monitorResponse","delete","resolveRoot","getEndpoint","get","handleMonitorResponseError","trapAxiosException","isError","throwFailure","closure","status","postEndpoint","post","putEndpoint","put","apiDomain","objToQuery","obj","Object","entries","map","key","value","filter","undefined","join","ApiSimple","ApiBase","delete","responseType","deleteEndpoint","undefined","find","query","getEndpoint","objToQuery","get","post","data","postEndpoint","put","putEndpoint","ArchivistApi","ApiSimple","huri","huriObj","Huri","config","root","href","import_axios","import_axios","locationDivinerApiResponseTransformer","data","_headers","getLocationDivinerApiResponseTransformer","axiosInstance","axios","defaults","transformResponse","Array","isArray","LocationDivinerApi","config","constructor","axiosRequestConfig","transformResponse","getLocationDivinerApiResponseTransformer","getLocationQuery","hash","axios","get","apiDomain","data","postLocationQuery","request","post","locationHeatmapQuerySchema","locationHeatmapAnswerSchema","isLocationHeatmapQuery","query","schema","locationQuadkeyHeatmapQuerySchema","locationQuadkeyHeatmapAnswerSchema","isLocationQuadkeyHeatmapQuery","query","schema","locationQuerySchemas","isSupportedLocationQuerySchema","schema","LocationTimeRangeQuerySchema","LocationTimeRangeAnswerSchema","isLocationTimeRangeQuery","query","schema","CurrentLocationWitnessSchema","LocationWitnessSchema","RemoteDivinerConfigSchema"]}