@xyo-network/api 2.110.9 → 2.110.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts +1 -1
  2. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts.map +1 -1
  3. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.mts +1 -1
  4. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.mts.map +1 -1
  5. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts +1 -1
  6. package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts.map +1 -1
  7. package/dist/browser/Diviner/RemoteDivinerError.d.cts.map +1 -1
  8. package/dist/browser/Diviner/RemoteDivinerError.d.mts.map +1 -1
  9. package/dist/browser/Diviner/RemoteDivinerError.d.ts.map +1 -1
  10. package/dist/browser/index.cjs +20 -46
  11. package/dist/browser/index.cjs.map +1 -1
  12. package/dist/browser/index.js +20 -48
  13. package/dist/browser/index.js.map +1 -1
  14. package/dist/neutral/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts +1 -1
  15. package/dist/neutral/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts.map +1 -1
  16. package/dist/neutral/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.mts +1 -1
  17. package/dist/neutral/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.mts.map +1 -1
  18. package/dist/neutral/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts +1 -1
  19. package/dist/neutral/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts.map +1 -1
  20. package/dist/neutral/Diviner/RemoteDivinerError.d.cts.map +1 -1
  21. package/dist/neutral/Diviner/RemoteDivinerError.d.mts.map +1 -1
  22. package/dist/neutral/Diviner/RemoteDivinerError.d.ts.map +1 -1
  23. package/dist/neutral/index.cjs +20 -46
  24. package/dist/neutral/index.cjs.map +1 -1
  25. package/dist/neutral/index.js +20 -48
  26. package/dist/neutral/index.js.map +1 -1
  27. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts +1 -1
  28. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts.map +1 -1
  29. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.mts +1 -1
  30. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.mts.map +1 -1
  31. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts +1 -1
  32. package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts.map +1 -1
  33. package/dist/node/Diviner/RemoteDivinerError.d.cts.map +1 -1
  34. package/dist/node/Diviner/RemoteDivinerError.d.mts.map +1 -1
  35. package/dist/node/Diviner/RemoteDivinerError.d.ts.map +1 -1
  36. package/dist/node/index.cjs +31 -52
  37. package/dist/node/index.cjs.map +1 -1
  38. package/dist/node/index.js +31 -54
  39. package/dist/node/index.js.map +1 -1
  40. package/package.json +15 -13
  41. package/src/Diviner/RemoteDivinerError.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../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":["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.js'\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.js'\nimport { objToQuery } from './objToQuery.js'\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.js'\nimport { GetLocationQueryResponse } from './models.js'\nimport { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries/index.js'\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/index.js'\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/index.js'\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/index.js'\nimport { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.js'\nimport { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.js'\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/index.js'\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/index.js'\n\nexport type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\nexport const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\n\nexport type RemoteDivinerConfig = DivinerConfig & {\n /** @deprecated use in params instead */\n api?: ArchivistApi\n archive?: string\n schema: RemoteDivinerConfigSchema\n}\n"],"mappings":";;;;AACA,SAASA,YAAY;;;ACDrB,SAASC,iBAAiB;AAanB,IAAMC,WAAN,MAAMA,SAAAA;EACFC;EACCC;EAEVC,YAAYF,QAAW;AACrB,SAAKA,SAASA;AACd,SAAKC,QAAQ,IAAIE,UAAU;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,OAAOM,QAAQ;AACtBF,cAAQ,WAAA,IAAe,KAAKJ,OAAOM;IACrC;AACA,WAAOF;EACT;EAEA,IAAcK,QAAQ;AACpB,WAAO,KAAKT,OAAOS,SAAS;EAC9B;EAEA,IAAcC,OAAO;AACnB,WAAO,KAAKV,OAAOU,QAAQ;EAC7B;EAEA,OAAeC,gBAAmBC,QAAsC;AA7C1E,QAAAC;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C,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":["Huri","AxiosJson","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","axios","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"]}
1
+ {"version":3,"sources":["../../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":["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.js'\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.js'\nimport { objToQuery } from './objToQuery.js'\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.js'\nimport { GetLocationQueryResponse } from './models.js'\nimport { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries/index.js'\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/index.js'\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/index.js'\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/index.js'\nimport { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.js'\nimport { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.js'\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/index.js'\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/index.js'\n\nexport type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\nexport const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config'\n\nexport type RemoteDivinerConfig = DivinerConfig & {\n /** @deprecated use in params instead */\n api?: ArchivistApi\n archive?: string\n schema: RemoteDivinerConfigSchema\n}\n"],"mappings":";AACA,SAAS,YAAY;;;ACDrB,SAAS,iBAAiB;AAanB,IAAM,UAAN,MAAM,SAAkE;AAAA,EACpE;AAAA,EACC;AAAA,EAEV,YAAY,QAAW;AACrB,SAAK,SAAS;AACd,SAAK,QAAQ,IAAI,UAAU,EAAE,GAAG,KAAK,QAAQ,SAAS,KAAK,QAAQ,CAAC;AAAA,EACtE;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,CAAC,CAAC,KAAK,OAAO,UAAU,CAAC,CAAC,KAAK,OAAO;AAAA,EAC/C;AAAA,EAEA,IAAc,UAAkC;AAC9C,UAAM,UAAkC,CAAC;AACzC,QAAI,KAAK,OAAO,UAAU;AACxB,cAAQ,gBAAgB,UAAU,KAAK,OAAO,QAAQ;AAAA,IACxD;AACA,QAAI,KAAK,OAAO,QAAQ;AACtB,cAAQ,WAAW,IAAI,KAAK,OAAO;AAAA,IACrC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,IAAc,QAAQ;AACpB,WAAO,KAAK,OAAO,SAAS;AAAA,EAC9B;AAAA,EAEA,IAAc,OAAO;AACnB,WAAO,KAAK,OAAO,QAAQ;AAAA,EAC7B;AAAA,EAEA,OAAe,gBAAmB,QAAsC;AA7C1E;AA8CI,WAAO,EAAC,sCAAQ,SAAR,mBAAc,MAAM,iCAAQ,MAAM,MAAM;AAAA,EAClD;AAAA,EAEA,OAAe,cAA2B,UAAmD,cAAgC;AAC3H,UAAM,mBAAmB,SAAQ,gBAAgB,QAAQ;AACzD,WAAO,iBAAiB,UAAU,mBAAmB,iBAAiB,CAAC;AAAA,EACzE;AAAA,EAEA,QAAQ,OAAiB,QAAQ,GAAG;AAtDtC;AAuDI,qBAAK,OAAO,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C,sCAAsC;AAAA,EACtC,oCAAoC;AACtC;AAEO,IAAM,iCAAiC,CAAC,WAAkD;AAC/F,SAAO,qBAAqB,MAA6B,KAAK;AAChE;;;ACXO,IAAM,+BAA6D;AAGnE,IAAM,gCAA+D;AAUrE,IAAM,2BAA2B,CAAC,UAAoE;AAC3G,SAAO,UAAS,+BAAO,YAAW;AACpC;;;ACfO,IAAM,+BAA6D;;;ACAnE,IAAM,wBAA+C;;;ACErD,IAAM,4BAAuD;","names":["axios","axios"]}
package/package.json CHANGED
@@ -9,21 +9,23 @@
9
9
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
10
10
  },
11
11
  "dependencies": {
12
- "@xylabs/axios": "^3.6.4",
13
- "@xylabs/object": "^3.6.4",
14
- "@xyo-network/api-models": "^2.110.9",
15
- "@xyo-network/boundwitness-model": "^2.110.9",
16
- "@xyo-network/diviner-model": "^2.110.9",
17
- "@xyo-network/huri": "^2.110.9",
18
- "@xyo-network/payload-model": "^2.110.9"
12
+ "@xylabs/axios": "^3.6.5",
13
+ "@xylabs/object": "^3.6.5",
14
+ "@xyo-network/api-models": "^2.110.11",
15
+ "@xyo-network/boundwitness-model": "^2.110.11",
16
+ "@xyo-network/diviner-model": "^2.110.11",
17
+ "@xyo-network/huri": "^2.110.11",
18
+ "@xyo-network/payload-model": "^2.110.11"
19
19
  },
20
20
  "description": "Primary SDK for using XYO Protocol 2.0",
21
21
  "devDependencies": {
22
- "@xylabs/jest-helpers": "^3.6.4",
23
- "@xylabs/ts-scripts-yarn3": "^3.12.4",
24
- "@xylabs/tsconfig": "^3.12.4",
25
- "@xyo-network/module-model": "^2.110.9",
26
- "@xyo-network/query-payload-plugin": "^2.110.9",
22
+ "@types/node": "^20.14.12",
23
+ "@types/uuid": "^10.0.0",
24
+ "@xylabs/jest-helpers": "^3.6.5",
25
+ "@xylabs/ts-scripts-yarn3": "^3.13.3",
26
+ "@xylabs/tsconfig": "^3.13.3",
27
+ "@xyo-network/module-model": "^2.110.11",
28
+ "@xyo-network/query-payload-plugin": "^2.110.11",
27
29
  "jest": "^29.7.0",
28
30
  "typescript": "^5.5.4",
29
31
  "uuid": "^10.0.0"
@@ -67,6 +69,6 @@
67
69
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
68
70
  },
69
71
  "sideEffects": false,
70
- "version": "2.110.9",
72
+ "version": "2.110.11",
71
73
  "type": "module"
72
74
  }
@@ -1,7 +1,8 @@
1
1
  export class RemoteDivinerError extends Error {
2
2
  isRemoteDivinerError = true
3
3
  constructor(action: string, error: Error['cause'], message?: string) {
4
- super(`Remote Diviner [${action}] failed${message ? ` (${message})` : ''}`, { cause: error })
4
+ const messageString = message ? ` (${message})` : ''
5
+ super(`Remote Diviner [${action}] failed${messageString}`, { cause: error })
5
6
  }
6
7
  static isRemoteDivinerError(error: unknown): RemoteDivinerError | undefined {
7
8
  return (error as RemoteDivinerError).isRemoteDivinerError ? (error as RemoteDivinerError) : undefined