@xyo-network/api 2.72.9 → 2.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs.json +657 -657
- package/dist/index.d.mts +192 -0
- package/dist/index.d.ts +192 -0
- package/dist/index.js +297 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +254 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -23
- package/tsup.config.ts +16 -0
- package/dist/cjs/Api/Api.js +0 -13
- package/dist/cjs/Api/Api.js.map +0 -1
- package/dist/cjs/Api/index.js +0 -5
- package/dist/cjs/Api/index.js.map +0 -1
- package/dist/cjs/Base.js +0 -119
- package/dist/cjs/Base.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/LocationDivinerApi.js +0 -28
- package/dist/cjs/Diviner/LocationDiviner/LocationDivinerApi.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +0 -23
- package/dist/cjs/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js +0 -3
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +0 -10
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +0 -6
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +0 -10
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +0 -5
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js +0 -3
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js +0 -3
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +0 -13
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js +0 -3
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +0 -10
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +0 -6
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/index.js +0 -10
- package/dist/cjs/Diviner/LocationDiviner/Queries/index.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +0 -5
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/LocationWitness.js +0 -5
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/index.js +0 -6
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/index.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/index.js +0 -8
- package/dist/cjs/Diviner/LocationDiviner/index.js.map +0 -1
- package/dist/cjs/Diviner/LocationDiviner/models.js +0 -3
- package/dist/cjs/Diviner/LocationDiviner/models.js.map +0 -1
- package/dist/cjs/Diviner/RemoteDivinerConfig.js +0 -5
- package/dist/cjs/Diviner/RemoteDivinerConfig.js.map +0 -1
- package/dist/cjs/Diviner/RemoteDivinerError.js +0 -14
- package/dist/cjs/Diviner/RemoteDivinerError.js.map +0 -1
- package/dist/cjs/Diviner/index.js +0 -6
- package/dist/cjs/Diviner/index.js.map +0 -1
- package/dist/cjs/Simple.js +0 -60
- package/dist/cjs/Simple.js.map +0 -1
- package/dist/cjs/Test/index.js +0 -6
- package/dist/cjs/Test/index.js.map +0 -1
- package/dist/cjs/Test/testBoundWitness.js +0 -17
- package/dist/cjs/Test/testBoundWitness.js.map +0 -1
- package/dist/cjs/Test/testPayload.js +0 -18
- package/dist/cjs/Test/testPayload.js.map +0 -1
- package/dist/cjs/WithArchive.js +0 -3
- package/dist/cjs/WithArchive.js.map +0 -1
- package/dist/cjs/index.js +0 -10
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/models/ArchivePath.js +0 -3
- package/dist/cjs/models/ArchivePath.js.map +0 -1
- package/dist/cjs/models/index.js +0 -5
- package/dist/cjs/models/index.js.map +0 -1
- package/dist/cjs/objToQuery.js +0 -13
- package/dist/cjs/objToQuery.js.map +0 -1
- package/dist/esm/Api/Api.js +0 -12
- package/dist/esm/Api/Api.js.map +0 -1
- package/dist/esm/Api/index.js +0 -2
- package/dist/esm/Api/index.js.map +0 -1
- package/dist/esm/Base.js +0 -100
- package/dist/esm/Base.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/LocationDivinerApi.js +0 -21
- package/dist/esm/Diviner/LocationDiviner/LocationDivinerApi.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +0 -18
- package/dist/esm/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +0 -6
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +0 -3
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +0 -6
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +0 -9
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +0 -6
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +0 -3
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/index.js +0 -7
- package/dist/esm/Diviner/LocationDiviner/Queries/index.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Witnesses/LocationWitness.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/Witnesses/index.js +0 -3
- package/dist/esm/Diviner/LocationDiviner/Witnesses/index.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/index.js +0 -5
- package/dist/esm/Diviner/LocationDiviner/index.js.map +0 -1
- package/dist/esm/Diviner/LocationDiviner/models.js +0 -2
- package/dist/esm/Diviner/LocationDiviner/models.js.map +0 -1
- package/dist/esm/Diviner/RemoteDivinerConfig.js +0 -2
- package/dist/esm/Diviner/RemoteDivinerConfig.js.map +0 -1
- package/dist/esm/Diviner/RemoteDivinerError.js +0 -10
- package/dist/esm/Diviner/RemoteDivinerError.js.map +0 -1
- package/dist/esm/Diviner/index.js +0 -3
- package/dist/esm/Diviner/index.js.map +0 -1
- package/dist/esm/Simple.js +0 -45
- package/dist/esm/Simple.js.map +0 -1
- package/dist/esm/Test/index.js +0 -3
- package/dist/esm/Test/index.js.map +0 -1
- package/dist/esm/Test/testBoundWitness.js +0 -14
- package/dist/esm/Test/testBoundWitness.js.map +0 -1
- package/dist/esm/Test/testPayload.js +0 -14
- package/dist/esm/Test/testPayload.js.map +0 -1
- package/dist/esm/WithArchive.js +0 -2
- package/dist/esm/WithArchive.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/models/ArchivePath.js +0 -2
- package/dist/esm/models/ArchivePath.js.map +0 -1
- package/dist/esm/models/index.js +0 -2
- package/dist/esm/models/index.js.map +0 -1
- package/dist/esm/objToQuery.js +0 -9
- package/dist/esm/objToQuery.js.map +0 -1
- package/dist/types/Api/Api.d.ts +0 -12
- package/dist/types/Api/Api.d.ts.map +0 -1
- package/dist/types/Api/index.d.ts +0 -2
- package/dist/types/Api/index.d.ts.map +0 -1
- package/dist/types/Base.d.ts +0 -32
- package/dist/types/Base.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/LocationDivinerApi.d.ts +0 -12
- package/dist/types/Diviner/LocationDiviner/LocationDivinerApi.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts +0 -10
- package/dist/types/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.ts +0 -5
- package/dist/types/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.ts +0 -12
- package/dist/types/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.ts +0 -3
- package/dist/types/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.ts +0 -12
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.ts +0 -2
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.ts +0 -18
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.ts +0 -5
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.ts +0 -6
- package/dist/types/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.ts +0 -8
- package/dist/types/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.ts +0 -12
- package/dist/types/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.ts +0 -3
- package/dist/types/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Queries/index.d.ts +0 -7
- package/dist/types/Diviner/LocationDiviner/Queries/index.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.ts +0 -13
- package/dist/types/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Witnesses/LocationWitness.d.ts +0 -21
- package/dist/types/Diviner/LocationDiviner/Witnesses/LocationWitness.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/Witnesses/index.d.ts +0 -3
- package/dist/types/Diviner/LocationDiviner/Witnesses/index.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/index.d.ts +0 -5
- package/dist/types/Diviner/LocationDiviner/index.d.ts.map +0 -1
- package/dist/types/Diviner/LocationDiviner/models.d.ts +0 -5
- package/dist/types/Diviner/LocationDiviner/models.d.ts.map +0 -1
- package/dist/types/Diviner/RemoteDivinerConfig.d.ts +0 -11
- package/dist/types/Diviner/RemoteDivinerConfig.d.ts.map +0 -1
- package/dist/types/Diviner/RemoteDivinerError.d.ts +0 -6
- package/dist/types/Diviner/RemoteDivinerError.d.ts.map +0 -1
- package/dist/types/Diviner/index.d.ts +0 -3
- package/dist/types/Diviner/index.d.ts.map +0 -1
- package/dist/types/Simple.d.ts +0 -22
- package/dist/types/Simple.d.ts.map +0 -1
- package/dist/types/Test/index.d.ts +0 -3
- package/dist/types/Test/index.d.ts.map +0 -1
- package/dist/types/Test/testBoundWitness.d.ts +0 -4
- package/dist/types/Test/testBoundWitness.d.ts.map +0 -1
- package/dist/types/Test/testPayload.d.ts +0 -6
- package/dist/types/Test/testPayload.d.ts.map +0 -1
- package/dist/types/WithArchive.d.ts +0 -4
- package/dist/types/WithArchive.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/models/ArchivePath.d.ts +0 -4
- package/dist/types/models/ArchivePath.d.ts.map +0 -1
- package/dist/types/models/index.d.ts +0 -2
- package/dist/types/models/index.d.ts.map +0 -1
- package/dist/types/objToQuery.d.ts +0 -2
- package/dist/types/objToQuery.d.ts.map +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as _xyo_network_payload_model from '@xyo-network/payload-model';
|
|
2
|
+
import { PayloadFindFilter, Payload } from '@xyo-network/payload-model';
|
|
3
|
+
import { ApiConfig, ApiReportable, ApiError, ApiResponse, ApiResponseBody, ApiResponseTuple, ApiEnvelope } from '@xyo-network/api-models';
|
|
4
|
+
import { Huri } from '@xyo-network/huri';
|
|
5
|
+
import { AxiosJson } from '@xyo-network/axios';
|
|
6
|
+
import { DivinerConfig } from '@xyo-network/diviner-model';
|
|
7
|
+
|
|
8
|
+
declare class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {
|
|
9
|
+
readonly config: C;
|
|
10
|
+
protected axios: AxiosJson;
|
|
11
|
+
constructor(config: C);
|
|
12
|
+
get authenticated(): boolean;
|
|
13
|
+
protected get headers(): Record<string, string>;
|
|
14
|
+
protected get query(): string;
|
|
15
|
+
protected get root(): string;
|
|
16
|
+
private static resolveResponse;
|
|
17
|
+
private static shapeResponse;
|
|
18
|
+
onError(error: ApiError, depth?: number): void;
|
|
19
|
+
onFailure(response: ApiResponse, depth?: number): void;
|
|
20
|
+
onSuccess(response: ApiResponse, depth?: number): void;
|
|
21
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>;
|
|
22
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
23
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
24
|
+
protected getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>;
|
|
25
|
+
protected getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
26
|
+
protected getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
27
|
+
protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean): ApiResponse<ApiEnvelope<T>> | undefined;
|
|
28
|
+
protected monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>): Promise<ApiResponse<ApiEnvelope<T>> | undefined>;
|
|
29
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>;
|
|
30
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
31
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
32
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>;
|
|
33
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
34
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
35
|
+
private resolveRoot;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type ApiSimpleQuery = PayloadFindFilter;
|
|
39
|
+
declare class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {
|
|
40
|
+
delete(): Promise<ApiResponseBody<T>>;
|
|
41
|
+
delete(responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
42
|
+
delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
43
|
+
find(query?: Q): Promise<ApiResponseBody<T>>;
|
|
44
|
+
find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
45
|
+
find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
46
|
+
get(): Promise<ApiResponseBody<T>>;
|
|
47
|
+
get(responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
48
|
+
get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
49
|
+
post(data?: D): Promise<ApiResponseBody<T>>;
|
|
50
|
+
post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
51
|
+
post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
52
|
+
put(data?: D): Promise<ApiResponseBody<T>>;
|
|
53
|
+
put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
54
|
+
put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {
|
|
58
|
+
huri(huri: Huri | string): ApiSimple<_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
59
|
+
schema: string;
|
|
60
|
+
}, _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
61
|
+
schema: string;
|
|
62
|
+
}, _xyo_network_payload_model.PayloadFindFilter, ApiConfig>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface GetLocationQueryResponse {
|
|
66
|
+
answerHash?: string;
|
|
67
|
+
queryHash: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface LocationHeatmapPointProperties {
|
|
71
|
+
hash: string;
|
|
72
|
+
value: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness';
|
|
76
|
+
declare const CurrentLocationWitnessSchema: CurrentLocationWitnessSchema;
|
|
77
|
+
type CurrentLocationWitnessPayload = Payload<{
|
|
78
|
+
altitudeMeters: number;
|
|
79
|
+
directionDegrees: number;
|
|
80
|
+
latitude: number;
|
|
81
|
+
longitude: number;
|
|
82
|
+
quadkey: string;
|
|
83
|
+
schema: CurrentLocationWitnessSchema;
|
|
84
|
+
speedKph: number;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
type LocationWitnessSchema = 'network.xyo.location';
|
|
88
|
+
declare const LocationWitnessSchema: LocationWitnessSchema;
|
|
89
|
+
interface Coordinates {
|
|
90
|
+
accuracy: number | null;
|
|
91
|
+
altitude: number | null;
|
|
92
|
+
altitudeAccuracy: number | null;
|
|
93
|
+
heading: number | null;
|
|
94
|
+
latitude: number;
|
|
95
|
+
longitude: number;
|
|
96
|
+
speed: number | null;
|
|
97
|
+
}
|
|
98
|
+
interface CurrentLocation {
|
|
99
|
+
coords: Coordinates;
|
|
100
|
+
timestamp: number;
|
|
101
|
+
}
|
|
102
|
+
type LocationWitnessPayload = Payload<{
|
|
103
|
+
currentLocation: CurrentLocation;
|
|
104
|
+
schema: LocationWitnessSchema;
|
|
105
|
+
}>;
|
|
106
|
+
|
|
107
|
+
type LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query';
|
|
108
|
+
declare const locationHeatmapQuerySchema: LocationHeatmapQuerySchema;
|
|
109
|
+
type LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer';
|
|
110
|
+
declare const locationHeatmapAnswerSchema: LocationHeatmapAnswerSchema;
|
|
111
|
+
type LocationHeatmapQuery = {
|
|
112
|
+
schema: LocationWitnessSchema;
|
|
113
|
+
startTime?: string;
|
|
114
|
+
stopTime?: string;
|
|
115
|
+
};
|
|
116
|
+
declare const isLocationHeatmapQuery: (query: Record<string, unknown>) => query is LocationHeatmapQuery;
|
|
117
|
+
|
|
118
|
+
type LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query';
|
|
119
|
+
declare const locationQuadkeyHeatmapQuerySchema: LocationQuadkeyHeatmapQuerySchema;
|
|
120
|
+
type LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer';
|
|
121
|
+
declare const locationQuadkeyHeatmapAnswerSchema: LocationQuadkeyHeatmapAnswerSchema;
|
|
122
|
+
type LocationQuadkeyHeatmapQuery = {
|
|
123
|
+
schema: LocationWitnessSchema;
|
|
124
|
+
startTime?: string;
|
|
125
|
+
stopTime?: string;
|
|
126
|
+
};
|
|
127
|
+
declare const isLocationQuadkeyHeatmapQuery: (query: Record<string, unknown>) => query is LocationQuadkeyHeatmapQuery;
|
|
128
|
+
|
|
129
|
+
interface LocationTimeRangePointProperties {
|
|
130
|
+
_archive: string;
|
|
131
|
+
_client: string;
|
|
132
|
+
_timestamp: number;
|
|
133
|
+
schema: LocationWitnessSchema;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
type LocationTimeRangeQuerySchema = 'network.xyo.location.range.query';
|
|
137
|
+
declare const LocationTimeRangeQuerySchema: LocationTimeRangeQuerySchema;
|
|
138
|
+
type LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer';
|
|
139
|
+
declare const LocationTimeRangeAnswerSchema: LocationTimeRangeAnswerSchema;
|
|
140
|
+
type LocationTimeRangeQuery = {
|
|
141
|
+
schema: LocationWitnessSchema;
|
|
142
|
+
startTime?: string;
|
|
143
|
+
stopTime?: string;
|
|
144
|
+
};
|
|
145
|
+
declare const isLocationTimeRangeQuery: (query: Record<string, unknown>) => query is LocationTimeRangeQuery;
|
|
146
|
+
|
|
147
|
+
type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema;
|
|
148
|
+
declare const isSupportedLocationQuerySchema: (schema: string) => schema is LocationQuerySchema;
|
|
149
|
+
|
|
150
|
+
interface LocationQueryCreationRequest<TSchema extends LocationQuerySchema = LocationQuerySchema, TQuery extends Record<string, unknown> = Record<string, unknown>> {
|
|
151
|
+
query: TQuery;
|
|
152
|
+
resultArchive: string;
|
|
153
|
+
resultArchivist: ApiConfig;
|
|
154
|
+
schema: TSchema;
|
|
155
|
+
sourceArchive: string;
|
|
156
|
+
sourceArchivist: ApiConfig;
|
|
157
|
+
}
|
|
158
|
+
type LocationTimeRangeQueryCreationRequest = LocationQueryCreationRequest<LocationTimeRangeQuerySchema, LocationTimeRangeQuery>;
|
|
159
|
+
type LocationHeatmapQueryCreationRequest = LocationQueryCreationRequest<LocationHeatmapQuerySchema, LocationHeatmapQuery>;
|
|
160
|
+
type LocationQuadkeyHeatmapQueryCreationRequest = LocationQueryCreationRequest<LocationQuadkeyHeatmapQuerySchema, LocationQuadkeyHeatmapQuery>;
|
|
161
|
+
type SupportedLocationQueryCreationRequest = LocationTimeRangeQueryCreationRequest | LocationHeatmapQueryCreationRequest | LocationQuadkeyHeatmapQueryCreationRequest;
|
|
162
|
+
|
|
163
|
+
interface LocationQueryCreationResponse extends LocationQueryCreationRequest {
|
|
164
|
+
hash: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare class LocationDivinerApi {
|
|
168
|
+
config: ApiConfig;
|
|
169
|
+
constructor(config: ApiConfig);
|
|
170
|
+
private get axiosRequestConfig();
|
|
171
|
+
getLocationQuery(hash: string): Promise<GetLocationQueryResponse>;
|
|
172
|
+
postLocationQuery(request: SupportedLocationQueryCreationRequest): Promise<LocationQueryCreationResponse>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config';
|
|
176
|
+
declare const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema;
|
|
177
|
+
type RemoteDivinerConfig = DivinerConfig & {
|
|
178
|
+
/** @deprecated use in params instead */
|
|
179
|
+
api?: ArchivistApi;
|
|
180
|
+
archive?: string;
|
|
181
|
+
schema: RemoteDivinerConfigSchema;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
interface ArchivePath {
|
|
185
|
+
archive: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare type WithArchive<ArchivistApiConfig> = ArchivistApiConfig & {
|
|
189
|
+
_archive?: string;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export { ApiBase, ApiSimple, ApiSimpleQuery, ArchivePath, ArchivistApi, Coordinates, CurrentLocation, CurrentLocationWitnessPayload, CurrentLocationWitnessSchema, GetLocationQueryResponse, LocationDivinerApi, LocationHeatmapAnswerSchema, LocationHeatmapPointProperties, LocationHeatmapQuery, LocationHeatmapQueryCreationRequest, LocationHeatmapQuerySchema, LocationQuadkeyHeatmapAnswerSchema, LocationQuadkeyHeatmapQuery, LocationQuadkeyHeatmapQueryCreationRequest, LocationQuadkeyHeatmapQuerySchema, LocationQueryCreationRequest, LocationQueryCreationResponse, LocationQuerySchema, LocationTimeRangeAnswerSchema, LocationTimeRangePointProperties, LocationTimeRangeQuery, LocationTimeRangeQueryCreationRequest, LocationTimeRangeQuerySchema, LocationWitnessPayload, LocationWitnessSchema, RemoteDivinerConfig, RemoteDivinerConfigSchema, SupportedLocationQueryCreationRequest, WithArchive, isLocationHeatmapQuery, isLocationQuadkeyHeatmapQuery, isLocationTimeRangeQuery, isSupportedLocationQuerySchema, locationHeatmapAnswerSchema, locationHeatmapQuerySchema, locationQuadkeyHeatmapAnswerSchema, locationQuadkeyHeatmapQuerySchema };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import * as _xyo_network_payload_model from '@xyo-network/payload-model';
|
|
2
|
+
import { PayloadFindFilter, Payload } from '@xyo-network/payload-model';
|
|
3
|
+
import { ApiConfig, ApiReportable, ApiError, ApiResponse, ApiResponseBody, ApiResponseTuple, ApiEnvelope } from '@xyo-network/api-models';
|
|
4
|
+
import { Huri } from '@xyo-network/huri';
|
|
5
|
+
import { AxiosJson } from '@xyo-network/axios';
|
|
6
|
+
import { DivinerConfig } from '@xyo-network/diviner-model';
|
|
7
|
+
|
|
8
|
+
declare class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {
|
|
9
|
+
readonly config: C;
|
|
10
|
+
protected axios: AxiosJson;
|
|
11
|
+
constructor(config: C);
|
|
12
|
+
get authenticated(): boolean;
|
|
13
|
+
protected get headers(): Record<string, string>;
|
|
14
|
+
protected get query(): string;
|
|
15
|
+
protected get root(): string;
|
|
16
|
+
private static resolveResponse;
|
|
17
|
+
private static shapeResponse;
|
|
18
|
+
onError(error: ApiError, depth?: number): void;
|
|
19
|
+
onFailure(response: ApiResponse, depth?: number): void;
|
|
20
|
+
onSuccess(response: ApiResponse, depth?: number): void;
|
|
21
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>;
|
|
22
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
23
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
24
|
+
protected getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>;
|
|
25
|
+
protected getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
26
|
+
protected getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
27
|
+
protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean): ApiResponse<ApiEnvelope<T>> | undefined;
|
|
28
|
+
protected monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>): Promise<ApiResponse<ApiEnvelope<T>> | undefined>;
|
|
29
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>;
|
|
30
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
31
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
32
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>;
|
|
33
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
34
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
35
|
+
private resolveRoot;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type ApiSimpleQuery = PayloadFindFilter;
|
|
39
|
+
declare class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {
|
|
40
|
+
delete(): Promise<ApiResponseBody<T>>;
|
|
41
|
+
delete(responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
42
|
+
delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
43
|
+
find(query?: Q): Promise<ApiResponseBody<T>>;
|
|
44
|
+
find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
45
|
+
find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
46
|
+
get(): Promise<ApiResponseBody<T>>;
|
|
47
|
+
get(responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
48
|
+
get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
49
|
+
post(data?: D): Promise<ApiResponseBody<T>>;
|
|
50
|
+
post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
51
|
+
post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
52
|
+
put(data?: D): Promise<ApiResponseBody<T>>;
|
|
53
|
+
put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
54
|
+
put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {
|
|
58
|
+
huri(huri: Huri | string): ApiSimple<_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
59
|
+
schema: string;
|
|
60
|
+
}, _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
61
|
+
schema: string;
|
|
62
|
+
}, _xyo_network_payload_model.PayloadFindFilter, ApiConfig>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface GetLocationQueryResponse {
|
|
66
|
+
answerHash?: string;
|
|
67
|
+
queryHash: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface LocationHeatmapPointProperties {
|
|
71
|
+
hash: string;
|
|
72
|
+
value: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type CurrentLocationWitnessSchema = 'co.coinapp.currentlocationwitness';
|
|
76
|
+
declare const CurrentLocationWitnessSchema: CurrentLocationWitnessSchema;
|
|
77
|
+
type CurrentLocationWitnessPayload = Payload<{
|
|
78
|
+
altitudeMeters: number;
|
|
79
|
+
directionDegrees: number;
|
|
80
|
+
latitude: number;
|
|
81
|
+
longitude: number;
|
|
82
|
+
quadkey: string;
|
|
83
|
+
schema: CurrentLocationWitnessSchema;
|
|
84
|
+
speedKph: number;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
type LocationWitnessSchema = 'network.xyo.location';
|
|
88
|
+
declare const LocationWitnessSchema: LocationWitnessSchema;
|
|
89
|
+
interface Coordinates {
|
|
90
|
+
accuracy: number | null;
|
|
91
|
+
altitude: number | null;
|
|
92
|
+
altitudeAccuracy: number | null;
|
|
93
|
+
heading: number | null;
|
|
94
|
+
latitude: number;
|
|
95
|
+
longitude: number;
|
|
96
|
+
speed: number | null;
|
|
97
|
+
}
|
|
98
|
+
interface CurrentLocation {
|
|
99
|
+
coords: Coordinates;
|
|
100
|
+
timestamp: number;
|
|
101
|
+
}
|
|
102
|
+
type LocationWitnessPayload = Payload<{
|
|
103
|
+
currentLocation: CurrentLocation;
|
|
104
|
+
schema: LocationWitnessSchema;
|
|
105
|
+
}>;
|
|
106
|
+
|
|
107
|
+
type LocationHeatmapQuerySchema = 'network.xyo.location.heatmap.query';
|
|
108
|
+
declare const locationHeatmapQuerySchema: LocationHeatmapQuerySchema;
|
|
109
|
+
type LocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer';
|
|
110
|
+
declare const locationHeatmapAnswerSchema: LocationHeatmapAnswerSchema;
|
|
111
|
+
type LocationHeatmapQuery = {
|
|
112
|
+
schema: LocationWitnessSchema;
|
|
113
|
+
startTime?: string;
|
|
114
|
+
stopTime?: string;
|
|
115
|
+
};
|
|
116
|
+
declare const isLocationHeatmapQuery: (query: Record<string, unknown>) => query is LocationHeatmapQuery;
|
|
117
|
+
|
|
118
|
+
type LocationQuadkeyHeatmapQuerySchema = 'network.xyo.location.heatmap.quadkey.query';
|
|
119
|
+
declare const locationQuadkeyHeatmapQuerySchema: LocationQuadkeyHeatmapQuerySchema;
|
|
120
|
+
type LocationQuadkeyHeatmapAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer';
|
|
121
|
+
declare const locationQuadkeyHeatmapAnswerSchema: LocationQuadkeyHeatmapAnswerSchema;
|
|
122
|
+
type LocationQuadkeyHeatmapQuery = {
|
|
123
|
+
schema: LocationWitnessSchema;
|
|
124
|
+
startTime?: string;
|
|
125
|
+
stopTime?: string;
|
|
126
|
+
};
|
|
127
|
+
declare const isLocationQuadkeyHeatmapQuery: (query: Record<string, unknown>) => query is LocationQuadkeyHeatmapQuery;
|
|
128
|
+
|
|
129
|
+
interface LocationTimeRangePointProperties {
|
|
130
|
+
_archive: string;
|
|
131
|
+
_client: string;
|
|
132
|
+
_timestamp: number;
|
|
133
|
+
schema: LocationWitnessSchema;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
type LocationTimeRangeQuerySchema = 'network.xyo.location.range.query';
|
|
137
|
+
declare const LocationTimeRangeQuerySchema: LocationTimeRangeQuerySchema;
|
|
138
|
+
type LocationTimeRangeAnswerSchema = 'network.xyo.location.range.answer';
|
|
139
|
+
declare const LocationTimeRangeAnswerSchema: LocationTimeRangeAnswerSchema;
|
|
140
|
+
type LocationTimeRangeQuery = {
|
|
141
|
+
schema: LocationWitnessSchema;
|
|
142
|
+
startTime?: string;
|
|
143
|
+
stopTime?: string;
|
|
144
|
+
};
|
|
145
|
+
declare const isLocationTimeRangeQuery: (query: Record<string, unknown>) => query is LocationTimeRangeQuery;
|
|
146
|
+
|
|
147
|
+
type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema;
|
|
148
|
+
declare const isSupportedLocationQuerySchema: (schema: string) => schema is LocationQuerySchema;
|
|
149
|
+
|
|
150
|
+
interface LocationQueryCreationRequest<TSchema extends LocationQuerySchema = LocationQuerySchema, TQuery extends Record<string, unknown> = Record<string, unknown>> {
|
|
151
|
+
query: TQuery;
|
|
152
|
+
resultArchive: string;
|
|
153
|
+
resultArchivist: ApiConfig;
|
|
154
|
+
schema: TSchema;
|
|
155
|
+
sourceArchive: string;
|
|
156
|
+
sourceArchivist: ApiConfig;
|
|
157
|
+
}
|
|
158
|
+
type LocationTimeRangeQueryCreationRequest = LocationQueryCreationRequest<LocationTimeRangeQuerySchema, LocationTimeRangeQuery>;
|
|
159
|
+
type LocationHeatmapQueryCreationRequest = LocationQueryCreationRequest<LocationHeatmapQuerySchema, LocationHeatmapQuery>;
|
|
160
|
+
type LocationQuadkeyHeatmapQueryCreationRequest = LocationQueryCreationRequest<LocationQuadkeyHeatmapQuerySchema, LocationQuadkeyHeatmapQuery>;
|
|
161
|
+
type SupportedLocationQueryCreationRequest = LocationTimeRangeQueryCreationRequest | LocationHeatmapQueryCreationRequest | LocationQuadkeyHeatmapQueryCreationRequest;
|
|
162
|
+
|
|
163
|
+
interface LocationQueryCreationResponse extends LocationQueryCreationRequest {
|
|
164
|
+
hash: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare class LocationDivinerApi {
|
|
168
|
+
config: ApiConfig;
|
|
169
|
+
constructor(config: ApiConfig);
|
|
170
|
+
private get axiosRequestConfig();
|
|
171
|
+
getLocationQuery(hash: string): Promise<GetLocationQueryResponse>;
|
|
172
|
+
postLocationQuery(request: SupportedLocationQueryCreationRequest): Promise<LocationQueryCreationResponse>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
type RemoteDivinerConfigSchema = 'network.xyo.diviner.remote.config';
|
|
176
|
+
declare const RemoteDivinerConfigSchema: RemoteDivinerConfigSchema;
|
|
177
|
+
type RemoteDivinerConfig = DivinerConfig & {
|
|
178
|
+
/** @deprecated use in params instead */
|
|
179
|
+
api?: ArchivistApi;
|
|
180
|
+
archive?: string;
|
|
181
|
+
schema: RemoteDivinerConfigSchema;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
interface ArchivePath {
|
|
185
|
+
archive: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare type WithArchive<ArchivistApiConfig> = ArchivistApiConfig & {
|
|
189
|
+
_archive?: string;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export { ApiBase, ApiSimple, ApiSimpleQuery, ArchivePath, ArchivistApi, Coordinates, CurrentLocation, CurrentLocationWitnessPayload, CurrentLocationWitnessSchema, GetLocationQueryResponse, LocationDivinerApi, LocationHeatmapAnswerSchema, LocationHeatmapPointProperties, LocationHeatmapQuery, LocationHeatmapQueryCreationRequest, LocationHeatmapQuerySchema, LocationQuadkeyHeatmapAnswerSchema, LocationQuadkeyHeatmapQuery, LocationQuadkeyHeatmapQueryCreationRequest, LocationQuadkeyHeatmapQuerySchema, LocationQueryCreationRequest, LocationQueryCreationResponse, LocationQuerySchema, LocationTimeRangeAnswerSchema, LocationTimeRangePointProperties, LocationTimeRangeQuery, LocationTimeRangeQueryCreationRequest, LocationTimeRangeQuerySchema, LocationWitnessPayload, LocationWitnessSchema, RemoteDivinerConfig, RemoteDivinerConfigSchema, SupportedLocationQueryCreationRequest, WithArchive, isLocationHeatmapQuery, isLocationQuadkeyHeatmapQuery, isLocationTimeRangeQuery, isSupportedLocationQuerySchema, locationHeatmapAnswerSchema, locationHeatmapQuerySchema, locationQuadkeyHeatmapAnswerSchema, locationQuadkeyHeatmapQuerySchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
ApiBase: () => ApiBase,
|
|
24
|
+
ApiSimple: () => ApiSimple,
|
|
25
|
+
ArchivistApi: () => ArchivistApi,
|
|
26
|
+
CurrentLocationWitnessSchema: () => CurrentLocationWitnessSchema,
|
|
27
|
+
LocationDivinerApi: () => LocationDivinerApi,
|
|
28
|
+
LocationTimeRangeAnswerSchema: () => LocationTimeRangeAnswerSchema,
|
|
29
|
+
LocationTimeRangeQuerySchema: () => LocationTimeRangeQuerySchema,
|
|
30
|
+
LocationWitnessSchema: () => LocationWitnessSchema,
|
|
31
|
+
RemoteDivinerConfigSchema: () => RemoteDivinerConfigSchema,
|
|
32
|
+
isLocationHeatmapQuery: () => isLocationHeatmapQuery,
|
|
33
|
+
isLocationQuadkeyHeatmapQuery: () => isLocationQuadkeyHeatmapQuery,
|
|
34
|
+
isLocationTimeRangeQuery: () => isLocationTimeRangeQuery,
|
|
35
|
+
isSupportedLocationQuerySchema: () => isSupportedLocationQuerySchema,
|
|
36
|
+
locationHeatmapAnswerSchema: () => locationHeatmapAnswerSchema,
|
|
37
|
+
locationHeatmapQuerySchema: () => locationHeatmapQuerySchema,
|
|
38
|
+
locationQuadkeyHeatmapAnswerSchema: () => locationQuadkeyHeatmapAnswerSchema,
|
|
39
|
+
locationQuadkeyHeatmapQuerySchema: () => locationQuadkeyHeatmapQuerySchema
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(src_exports);
|
|
42
|
+
|
|
43
|
+
// src/Api/Api.ts
|
|
44
|
+
var import_huri = require("@xyo-network/huri");
|
|
45
|
+
|
|
46
|
+
// src/Base.ts
|
|
47
|
+
var import_axios = require("@xyo-network/axios");
|
|
48
|
+
var ApiBase = class _ApiBase {
|
|
49
|
+
config;
|
|
50
|
+
axios;
|
|
51
|
+
constructor(config) {
|
|
52
|
+
this.config = config;
|
|
53
|
+
this.axios = new import_axios.AxiosJson({ ...this.config, headers: this.headers });
|
|
54
|
+
}
|
|
55
|
+
get authenticated() {
|
|
56
|
+
return !!this.config.apiKey || !!this.config.jwtToken;
|
|
57
|
+
}
|
|
58
|
+
get headers() {
|
|
59
|
+
const headers = {};
|
|
60
|
+
if (this.config.jwtToken) {
|
|
61
|
+
headers.Authorization = `Bearer ${this.config.jwtToken}`;
|
|
62
|
+
}
|
|
63
|
+
if (this.config.apiKey) {
|
|
64
|
+
headers["x-api-key"] = this.config.apiKey;
|
|
65
|
+
}
|
|
66
|
+
return headers;
|
|
67
|
+
}
|
|
68
|
+
get query() {
|
|
69
|
+
return this.config.query ?? "";
|
|
70
|
+
}
|
|
71
|
+
get root() {
|
|
72
|
+
return this.config.root ?? "/";
|
|
73
|
+
}
|
|
74
|
+
static resolveResponse(result) {
|
|
75
|
+
return [result?.data?.data, result?.data, result];
|
|
76
|
+
}
|
|
77
|
+
static shapeResponse(response, responseType) {
|
|
78
|
+
const resolvedResponse = _ApiBase.resolveResponse(response);
|
|
79
|
+
return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
|
|
80
|
+
}
|
|
81
|
+
onError(error, depth = 0) {
|
|
82
|
+
this.config.reportableParent?.onError?.(error, depth + 1);
|
|
83
|
+
this.config.onError?.(error, depth);
|
|
84
|
+
}
|
|
85
|
+
onFailure(response, depth = 0) {
|
|
86
|
+
this.config.reportableParent?.onFailure?.(response, depth + 1);
|
|
87
|
+
this.config.onFailure?.(response, depth);
|
|
88
|
+
}
|
|
89
|
+
onSuccess(response, depth = 0) {
|
|
90
|
+
this.config.reportableParent?.onSuccess?.(response, depth + 1);
|
|
91
|
+
this.config.onSuccess?.(response, depth);
|
|
92
|
+
}
|
|
93
|
+
async deleteEndpoint(endPoint = "", responseType) {
|
|
94
|
+
const response = await this.monitorResponse(async () => {
|
|
95
|
+
return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
96
|
+
});
|
|
97
|
+
return _ApiBase.shapeResponse(response, responseType);
|
|
98
|
+
}
|
|
99
|
+
async getEndpoint(endPoint = "", responseType) {
|
|
100
|
+
const response = await this.monitorResponse(async () => {
|
|
101
|
+
return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
102
|
+
});
|
|
103
|
+
return _ApiBase.shapeResponse(response, responseType);
|
|
104
|
+
}
|
|
105
|
+
handleMonitorResponseError(error, trapAxiosException) {
|
|
106
|
+
if (!error.isError) {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
if (trapAxiosException) {
|
|
110
|
+
error.response ? this.onFailure(error.response) : this.onError(error);
|
|
111
|
+
if (this.config.throwFailure) {
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
return error.response;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async monitorResponse(closure) {
|
|
118
|
+
let trapAxiosException = true;
|
|
119
|
+
try {
|
|
120
|
+
const response = await closure();
|
|
121
|
+
trapAxiosException = false;
|
|
122
|
+
response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
|
|
123
|
+
return response;
|
|
124
|
+
} catch (ex) {
|
|
125
|
+
this.handleMonitorResponseError(ex, trapAxiosException);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async postEndpoint(endPoint = "", data, responseType) {
|
|
129
|
+
const response = await this.monitorResponse(async () => {
|
|
130
|
+
return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
131
|
+
});
|
|
132
|
+
return _ApiBase.shapeResponse(response, responseType);
|
|
133
|
+
}
|
|
134
|
+
async putEndpoint(endPoint = "", data, responseType) {
|
|
135
|
+
const response = await this.monitorResponse(async () => {
|
|
136
|
+
return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
137
|
+
});
|
|
138
|
+
return _ApiBase.shapeResponse(response, responseType);
|
|
139
|
+
}
|
|
140
|
+
resolveRoot() {
|
|
141
|
+
return `${this.config.apiDomain}${this.root}`;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// src/objToQuery.ts
|
|
146
|
+
var objToQuery = (obj) => {
|
|
147
|
+
return `?${Object.entries(obj).map(([key, value]) => {
|
|
148
|
+
return `${key}=${value}`;
|
|
149
|
+
}).filter((value) => value !== void 0).join("&")}`;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/Simple.ts
|
|
153
|
+
var ApiSimple = class extends ApiBase {
|
|
154
|
+
async delete(responseType) {
|
|
155
|
+
switch (responseType) {
|
|
156
|
+
case "tuple":
|
|
157
|
+
return await this.deleteEndpoint(void 0, "tuple");
|
|
158
|
+
default:
|
|
159
|
+
return await this.deleteEndpoint(void 0);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async find(query = {}, responseType) {
|
|
163
|
+
switch (responseType) {
|
|
164
|
+
case "tuple":
|
|
165
|
+
return await this.getEndpoint(objToQuery(query), "tuple");
|
|
166
|
+
default:
|
|
167
|
+
return await this.getEndpoint(objToQuery(query));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async get(responseType) {
|
|
171
|
+
switch (responseType) {
|
|
172
|
+
case "tuple":
|
|
173
|
+
return await this.getEndpoint(void 0, "tuple");
|
|
174
|
+
default:
|
|
175
|
+
return await this.getEndpoint(void 0);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async post(data, responseType) {
|
|
179
|
+
switch (responseType) {
|
|
180
|
+
case "tuple":
|
|
181
|
+
return await this.postEndpoint(void 0, data, "tuple");
|
|
182
|
+
default:
|
|
183
|
+
return await this.postEndpoint(void 0, data);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async put(data, responseType) {
|
|
187
|
+
switch (responseType) {
|
|
188
|
+
case "tuple":
|
|
189
|
+
return await this.putEndpoint(void 0, data, "tuple");
|
|
190
|
+
default:
|
|
191
|
+
return await this.putEndpoint(void 0, data);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/Api/Api.ts
|
|
197
|
+
var ArchivistApi = class extends ApiSimple {
|
|
198
|
+
huri(huri) {
|
|
199
|
+
const huriObj = typeof huri === "string" ? new import_huri.Huri(huri) : huri;
|
|
200
|
+
return new ApiSimple({
|
|
201
|
+
...this.config,
|
|
202
|
+
root: `${this.root}${huriObj.href}/`
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/Diviner/LocationDiviner/LocationDivinerApi.ts
|
|
208
|
+
var import_axios3 = require("@xyo-network/axios");
|
|
209
|
+
|
|
210
|
+
// src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts
|
|
211
|
+
var import_axios2 = require("@xyo-network/axios");
|
|
212
|
+
var locationDivinerApiResponseTransformer = (data, _headers) => {
|
|
213
|
+
return data.data;
|
|
214
|
+
};
|
|
215
|
+
var getLocationDivinerApiResponseTransformer = (axiosInstance = import_axios2.axios) => {
|
|
216
|
+
return axiosInstance.defaults.transformResponse ? [].concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer) : [locationDivinerApiResponseTransformer];
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/Diviner/LocationDiviner/LocationDivinerApi.ts
|
|
220
|
+
var LocationDivinerApi = class {
|
|
221
|
+
config;
|
|
222
|
+
constructor(config) {
|
|
223
|
+
this.config = config;
|
|
224
|
+
}
|
|
225
|
+
get axiosRequestConfig() {
|
|
226
|
+
return {
|
|
227
|
+
transformResponse: getLocationDivinerApiResponseTransformer()
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
async getLocationQuery(hash) {
|
|
231
|
+
return (await import_axios3.axios.get(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data;
|
|
232
|
+
}
|
|
233
|
+
async postLocationQuery(request) {
|
|
234
|
+
return (await import_axios3.axios.post(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts
|
|
239
|
+
var locationHeatmapQuerySchema = "network.xyo.location.heatmap.query";
|
|
240
|
+
var locationHeatmapAnswerSchema = "network.xyo.location.heatmap.answer";
|
|
241
|
+
var isLocationHeatmapQuery = (query) => {
|
|
242
|
+
return query && query?.schema === locationHeatmapQuerySchema;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts
|
|
246
|
+
var locationQuadkeyHeatmapQuerySchema = "network.xyo.location.heatmap.quadkey.query";
|
|
247
|
+
var locationQuadkeyHeatmapAnswerSchema = "network.xyo.location.heatmap.quadkey.answer";
|
|
248
|
+
var isLocationQuadkeyHeatmapQuery = (query) => {
|
|
249
|
+
return query && query?.schema === locationQuadkeyHeatmapQuerySchema;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts
|
|
253
|
+
var locationQuerySchemas = {
|
|
254
|
+
"network.xyo.location.heatmap.quadkey.query": true,
|
|
255
|
+
"network.xyo.location.heatmap.query": true,
|
|
256
|
+
"network.xyo.location.range.query": true
|
|
257
|
+
};
|
|
258
|
+
var isSupportedLocationQuerySchema = (schema) => {
|
|
259
|
+
return locationQuerySchemas[schema] || false;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts
|
|
263
|
+
var LocationTimeRangeQuerySchema = "network.xyo.location.range.query";
|
|
264
|
+
var LocationTimeRangeAnswerSchema = "network.xyo.location.range.answer";
|
|
265
|
+
var isLocationTimeRangeQuery = (query) => {
|
|
266
|
+
return query && query?.schema === LocationTimeRangeAnswerSchema;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts
|
|
270
|
+
var CurrentLocationWitnessSchema = "co.coinapp.currentlocationwitness";
|
|
271
|
+
|
|
272
|
+
// src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts
|
|
273
|
+
var LocationWitnessSchema = "network.xyo.location";
|
|
274
|
+
|
|
275
|
+
// src/Diviner/RemoteDivinerConfig.ts
|
|
276
|
+
var RemoteDivinerConfigSchema = "network.xyo.diviner.remote.config";
|
|
277
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
278
|
+
0 && (module.exports = {
|
|
279
|
+
ApiBase,
|
|
280
|
+
ApiSimple,
|
|
281
|
+
ArchivistApi,
|
|
282
|
+
CurrentLocationWitnessSchema,
|
|
283
|
+
LocationDivinerApi,
|
|
284
|
+
LocationTimeRangeAnswerSchema,
|
|
285
|
+
LocationTimeRangeQuerySchema,
|
|
286
|
+
LocationWitnessSchema,
|
|
287
|
+
RemoteDivinerConfigSchema,
|
|
288
|
+
isLocationHeatmapQuery,
|
|
289
|
+
isLocationQuadkeyHeatmapQuery,
|
|
290
|
+
isLocationTimeRangeQuery,
|
|
291
|
+
isSupportedLocationQuerySchema,
|
|
292
|
+
locationHeatmapAnswerSchema,
|
|
293
|
+
locationHeatmapQuerySchema,
|
|
294
|
+
locationQuadkeyHeatmapAnswerSchema,
|
|
295
|
+
locationQuadkeyHeatmapQuerySchema
|
|
296
|
+
});
|
|
297
|
+
//# sourceMappingURL=index.js.map
|