@xyo-network/api 5.3.22 → 5.3.24
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/package.json +20 -20
- package/src/Api/Api.ts +0 -15
- package/src/Api/index.ts +0 -1
- package/src/Api/spec/ApiUtil.ts +0 -37
- package/src/Base.ts +0 -150
- package/src/Diviner/LocationDiviner/LocationDivinerApi.ts +0 -28
- package/src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts +0 -25
- package/src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.ts +0 -4
- package/src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts +0 -19
- package/src/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.ts +0 -2
- package/src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts +0 -19
- package/src/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.ts +0 -1
- package/src/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.ts +0 -28
- package/src/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.ts +0 -5
- package/src/Diviner/LocationDiviner/Queries/LocationQuerySchema.ts +0 -17
- package/src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.ts +0 -8
- package/src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts +0 -19
- package/src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.ts +0 -2
- package/src/Diviner/LocationDiviner/Queries/index.ts +0 -6
- package/src/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts +0 -14
- package/src/Diviner/LocationDiviner/Witnesses/LocationWitness.ts +0 -23
- package/src/Diviner/LocationDiviner/Witnesses/index.ts +0 -2
- package/src/Diviner/LocationDiviner/index.ts +0 -4
- package/src/Diviner/LocationDiviner/models.ts +0 -4
- package/src/Diviner/RemoteDivinerConfig.ts +0 -14
- package/src/Diviner/RemoteDivinerError.ts +0 -13
- package/src/Diviner/index.ts +0 -3
- package/src/Simple.ts +0 -81
- package/src/WithArchive.ts +0 -3
- package/src/index.ts +0 -6
- package/src/models/ArchivePath.ts +0 -3
- package/src/models/index.ts +0 -1
- package/src/objToQuery.ts +0 -8
- package/src/spec/testPayload.ts +0 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/api",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.24",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,43 +30,43 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src",
|
|
34
33
|
"!**/*.bench.*",
|
|
35
34
|
"!**/*.spec.*",
|
|
36
35
|
"!**/*.test.*",
|
|
37
36
|
"README.md"
|
|
38
37
|
],
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@xyo-network/api-models": "~5.3.
|
|
41
|
-
"@xyo-network/diviner-model": "~5.3.
|
|
42
|
-
"@xyo-network/huri": "~5.3.
|
|
43
|
-
"@xyo-network/payload-model": "~5.3.
|
|
39
|
+
"@xyo-network/api-models": "~5.3.24",
|
|
40
|
+
"@xyo-network/diviner-model": "~5.3.24",
|
|
41
|
+
"@xyo-network/huri": "~5.3.24",
|
|
42
|
+
"@xyo-network/payload-model": "~5.3.24"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@opentelemetry/api": "^1.9.1",
|
|
47
46
|
"@types/node": "^25.5.0",
|
|
48
47
|
"@types/uuid": "~11.0.0",
|
|
49
|
-
"@xylabs/sdk-js": "^5.0.
|
|
50
|
-
"@xylabs/ts-scripts-common": "~7.6.
|
|
51
|
-
"@xylabs/ts-scripts-
|
|
52
|
-
"@xylabs/tsconfig": "~7.6.
|
|
53
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
54
|
-
"@xyo-network/boundwitness-model": "~5.3.22",
|
|
55
|
-
"@xyo-network/module-model": "~5.3.22",
|
|
56
|
-
"@xyo-network/query-payload-plugin": "~5.3.22",
|
|
48
|
+
"@xylabs/sdk-js": "^5.0.93",
|
|
49
|
+
"@xylabs/ts-scripts-common": "~7.6.16",
|
|
50
|
+
"@xylabs/ts-scripts-pnpm": "~7.6.16",
|
|
51
|
+
"@xylabs/tsconfig": "~7.6.16",
|
|
52
|
+
"@xylabs/vitest-extended": "~5.0.93",
|
|
57
53
|
"acorn": "^8.16.0",
|
|
58
54
|
"axios": "^1.14.0",
|
|
59
|
-
"
|
|
60
|
-
"esbuild": "^0.27.4",
|
|
61
|
-
"eslint": "^10.1.0",
|
|
55
|
+
"esbuild": "^0.28.0",
|
|
62
56
|
"ethers": "^6.16.0",
|
|
63
|
-
"rollup": "^4.60.1",
|
|
64
57
|
"tslib": "^2.8.1",
|
|
65
58
|
"typescript": "~5.9.3",
|
|
66
59
|
"uuid": "~13.0.0",
|
|
67
60
|
"vite": "^8.0.3",
|
|
68
61
|
"vitest": "~4.1.2",
|
|
69
|
-
"zod": "^4.3.6"
|
|
62
|
+
"zod": "^4.3.6",
|
|
63
|
+
"@xyo-network/api-models": "~5.3.24",
|
|
64
|
+
"@xyo-network/diviner-model": "~5.3.24",
|
|
65
|
+
"@xyo-network/boundwitness-model": "~5.3.24",
|
|
66
|
+
"@xyo-network/huri": "~5.3.24",
|
|
67
|
+
"@xyo-network/payload-model": "~5.3.24",
|
|
68
|
+
"@xyo-network/module-model": "~5.3.24",
|
|
69
|
+
"@xyo-network/query-payload-plugin": "~5.3.24"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@xylabs/sdk-js": "^5",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|
package/src/Api/Api.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ApiConfig } from '@xyo-network/api-models'
|
|
2
|
-
import { Huri } from '@xyo-network/huri'
|
|
3
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
4
|
-
|
|
5
|
-
import { ApiSimple } from '../Simple.ts'
|
|
6
|
-
|
|
7
|
-
export class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {
|
|
8
|
-
huri(huri: Huri | string) {
|
|
9
|
-
const huriObj = typeof huri === 'string' ? new Huri(huri) : huri
|
|
10
|
-
return new ApiSimple<Payload>({
|
|
11
|
-
...this.config,
|
|
12
|
-
root: `${this.root}${huriObj.href}/`,
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
}
|
package/src/Api/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Api.ts'
|
package/src/Api/spec/ApiUtil.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { ApiConfig } from '@xyo-network/api-models'
|
|
4
|
-
import { v4 as uuid } from 'uuid'
|
|
5
|
-
import { expect, test } from 'vitest'
|
|
6
|
-
|
|
7
|
-
import { ArchivistApi } from '../Api.ts'
|
|
8
|
-
|
|
9
|
-
test('Must have tests defined', () => {
|
|
10
|
-
expect(true).toBeTruthy()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export const getApiConfig = (configData: Partial<ApiConfig> = {}): ApiConfig => {
|
|
14
|
-
const apiDomain = process.env.API_DOMAIN ?? 'http://localhost:8080'
|
|
15
|
-
const defaults: ApiConfig = {
|
|
16
|
-
apiDomain,
|
|
17
|
-
onError: error => error,
|
|
18
|
-
onFailure: response => response,
|
|
19
|
-
onSuccess: response => response,
|
|
20
|
-
}
|
|
21
|
-
return Object.assign({}, defaults, configData)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const getApi = (configData: Partial<ApiConfig> = {}): ArchivistApi => {
|
|
25
|
-
return new ArchivistApi(getApiConfig(configData))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const testSchemaPrefix = 'network.xyo.schema.test.'
|
|
29
|
-
export const getSchemaName = (): string => {
|
|
30
|
-
return `${testSchemaPrefix}${uuid()}`
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const getTimestampMinutesFromNow = (minutes = 0) => {
|
|
34
|
-
const t = new Date()
|
|
35
|
-
t.setMinutes(t.getMinutes() + minutes)
|
|
36
|
-
return +t
|
|
37
|
-
}
|
package/src/Base.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { axiosJsonConfig, isString } from '@xylabs/sdk-js'
|
|
2
|
-
import type {
|
|
3
|
-
ApiConfig,
|
|
4
|
-
ApiEnvelope,
|
|
5
|
-
ApiError,
|
|
6
|
-
ApiReportable,
|
|
7
|
-
ApiResponse,
|
|
8
|
-
ApiResponseBody,
|
|
9
|
-
ApiResponseTuple,
|
|
10
|
-
ApiResponseTupleOrBody,
|
|
11
|
-
ApiResponseType,
|
|
12
|
-
} from '@xyo-network/api-models'
|
|
13
|
-
import { Axios } from 'axios'
|
|
14
|
-
|
|
15
|
-
export class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {
|
|
16
|
-
readonly config: C
|
|
17
|
-
protected axios: Axios
|
|
18
|
-
|
|
19
|
-
constructor(config: C) {
|
|
20
|
-
this.config = config
|
|
21
|
-
this.axios = new Axios(axiosJsonConfig({ ...this.config, headers: this.headers }))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get authenticated() {
|
|
25
|
-
return isString(this.config.apiKey) || isString(this.config.jwtToken)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
protected get headers(): Record<string, string> {
|
|
29
|
-
const headers: Record<string, string> = {}
|
|
30
|
-
if (isString(this.config.jwtToken)) {
|
|
31
|
-
headers.Authorization = `Bearer ${this.config.jwtToken}`
|
|
32
|
-
}
|
|
33
|
-
if (isString(this.config.apiKey)) {
|
|
34
|
-
headers['x-api-key'] = this.config.apiKey
|
|
35
|
-
}
|
|
36
|
-
return headers
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
protected get query() {
|
|
40
|
-
return this.config.query ?? ''
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
protected get root() {
|
|
44
|
-
return this.config.root ?? '/'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private static resolveResponse<T>(result?: ApiResponse<ApiEnvelope<T>>) {
|
|
48
|
-
return [result?.data?.data, result?.data, result] as ApiResponseTuple<T>
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private static shapeResponse<T = unknown>(response: ApiResponse<ApiEnvelope<T>> | undefined, responseType?: ApiResponseType) {
|
|
52
|
-
const resolvedResponse = ApiBase.resolveResponse(response)
|
|
53
|
-
return responseType === 'tuple' ? resolvedResponse : resolvedResponse[0]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
onError(error: ApiError, depth = 0) {
|
|
57
|
-
this.config.reportableParent?.onError?.(error, depth + 1)
|
|
58
|
-
this.config.onError?.(error, depth)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
onFailure(response: ApiResponse, depth = 0) {
|
|
62
|
-
this.config.reportableParent?.onFailure?.(response, depth + 1)
|
|
63
|
-
this.config.onFailure?.(response, depth)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
onSuccess(response: ApiResponse, depth = 0) {
|
|
67
|
-
this.config.reportableParent?.onSuccess?.(response, depth + 1)
|
|
68
|
-
this.config.onSuccess?.(response, depth)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
protected async deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>
|
|
72
|
-
protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
73
|
-
protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
74
|
-
protected async deleteEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
75
|
-
const response = await this.monitorResponse<T>(async () => {
|
|
76
|
-
return await this.axios.delete<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)
|
|
77
|
-
})
|
|
78
|
-
return ApiBase.shapeResponse<T>(response, responseType)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
protected async getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>
|
|
82
|
-
protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
83
|
-
protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
84
|
-
protected async getEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
85
|
-
const response = await this.monitorResponse<T>(async () => {
|
|
86
|
-
return await this.axios.get<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)
|
|
87
|
-
})
|
|
88
|
-
return ApiBase.shapeResponse<T>(response, responseType)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean) {
|
|
92
|
-
if (!error.isError) {
|
|
93
|
-
throw error
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (trapAxiosException) {
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
98
|
-
error.response ? this.onFailure(error.response) : this.onError(error)
|
|
99
|
-
if (this.config.throwFailure) {
|
|
100
|
-
throw error
|
|
101
|
-
}
|
|
102
|
-
return error.response as ApiResponse<ApiEnvelope<T>>
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
protected async monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>) {
|
|
107
|
-
// we use this to prevent accidental catching on exceptions in callbacks
|
|
108
|
-
let trapAxiosException = true
|
|
109
|
-
try {
|
|
110
|
-
const response = await closure()
|
|
111
|
-
|
|
112
|
-
trapAxiosException = false
|
|
113
|
-
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
115
|
-
response.status < 300 ? this.onSuccess(response) : this.onFailure(response)
|
|
116
|
-
|
|
117
|
-
return response
|
|
118
|
-
} catch (error) {
|
|
119
|
-
this.handleMonitorResponseError(error as ApiError, trapAxiosException)
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>
|
|
124
|
-
protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
125
|
-
protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
126
|
-
protected async postEndpoint<T = unknown, D = unknown>(
|
|
127
|
-
endPoint = '',
|
|
128
|
-
data?: D,
|
|
129
|
-
responseType?: ApiResponseType,
|
|
130
|
-
): Promise<ApiResponseTupleOrBody<T>> {
|
|
131
|
-
const response = await this.monitorResponse<T>(async () => {
|
|
132
|
-
return await this.axios.post<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)
|
|
133
|
-
})
|
|
134
|
-
return ApiBase.shapeResponse<T>(response, responseType)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>
|
|
138
|
-
protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
139
|
-
protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
140
|
-
protected async putEndpoint<T = unknown, D = unknown>(endPoint = '', data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
141
|
-
const response = await this.monitorResponse<T>(async () => {
|
|
142
|
-
return await this.axios.put<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)
|
|
143
|
-
})
|
|
144
|
-
return ApiBase.shapeResponse<T>(response, responseType)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
private resolveRoot() {
|
|
148
|
-
return `${this.config.apiDomain}${this.root}`
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { axiosJson } from '@xylabs/sdk-js'
|
|
2
|
-
import type { ApiConfig } from '@xyo-network/api-models'
|
|
3
|
-
import type { RawAxiosRequestConfig } from 'axios'
|
|
4
|
-
|
|
5
|
-
import { getLocationDivinerApiResponseTransformer } from './LocationDivinerApiResponseTransformer.ts'
|
|
6
|
-
import type { GetLocationQueryResponse } from './models.ts'
|
|
7
|
-
import type { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries/index.ts'
|
|
8
|
-
|
|
9
|
-
class LocationDivinerApi {
|
|
10
|
-
config: ApiConfig
|
|
11
|
-
constructor(config: ApiConfig) {
|
|
12
|
-
this.config = config
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
private get axiosRequestConfig(): RawAxiosRequestConfig {
|
|
16
|
-
return { transformResponse: getLocationDivinerApiResponseTransformer() }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async getLocationQuery(hash: string) {
|
|
20
|
-
return (await axiosJson.get<GetLocationQueryResponse>(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async postLocationQuery(request: SupportedLocationQueryCreationRequest) {
|
|
24
|
-
return (await axiosJson.post<LocationQueryCreationResponse>(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { LocationDivinerApi }
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { AxiosResponseTransformer } from 'axios'
|
|
2
|
-
import axios from 'axios'
|
|
3
|
-
|
|
4
|
-
export const locationDivinerApiResponseTransformer: AxiosResponseTransformer = (data, _headers) => {
|
|
5
|
-
return data.data
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Gets the response transformers for the LocationDiviner API. Done as a method instead of a property
|
|
10
|
-
* to allow detection of dynamically added response transformers.
|
|
11
|
-
* @param axiosInstance The axios instance (defaults to the global instance if none provided)
|
|
12
|
-
* @returns the response transformers for the LocationDiviner API
|
|
13
|
-
*/
|
|
14
|
-
export const getLocationDivinerApiResponseTransformer = (axiosInstance = axios): AxiosResponseTransformer[] => {
|
|
15
|
-
// If there's any existing response transforms preserve them and
|
|
16
|
-
// append our response transform, otherwise just return ours
|
|
17
|
-
return axiosInstance.defaults.transformResponse
|
|
18
|
-
? [
|
|
19
|
-
...(Array.isArray(axiosInstance.defaults.transformResponse)
|
|
20
|
-
? axiosInstance.defaults.transformResponse
|
|
21
|
-
: [axiosInstance.defaults.transformResponse]),
|
|
22
|
-
locationDivinerApiResponseTransformer,
|
|
23
|
-
]
|
|
24
|
-
: [locationDivinerApiResponseTransformer]
|
|
25
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { asSchema } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
import type { LocationWitnessSchema } from '../../Witnesses/index.ts'
|
|
4
|
-
|
|
5
|
-
export const LocationHeatmapQuerySchema = asSchema('network.xyo.location.heatmap.query', true)
|
|
6
|
-
export type LocationHeatmapQuerySchema = typeof LocationHeatmapQuerySchema
|
|
7
|
-
|
|
8
|
-
export const LocationHeatmapAnswerSchema = asSchema('network.xyo.location.heatmap.answer', true)
|
|
9
|
-
export type LocationHeatmapAnswerSchema = typeof LocationHeatmapAnswerSchema
|
|
10
|
-
|
|
11
|
-
export type LocationHeatmapQuery = {
|
|
12
|
-
schema: LocationWitnessSchema
|
|
13
|
-
startTime?: string
|
|
14
|
-
stopTime?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const isLocationHeatmapQuery = (query: Record<string, unknown>): query is LocationHeatmapQuery => {
|
|
18
|
-
return query && query?.schema === LocationHeatmapQuerySchema
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { asSchema } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
import type { LocationWitnessSchema } from '../../Witnesses/index.ts'
|
|
4
|
-
|
|
5
|
-
export const LocationQuadkeyHeatmapQuerySchema = asSchema('network.xyo.location.heatmap.quadkey.query', true)
|
|
6
|
-
export type LocationQuadkeyHeatmapQuerySchema = typeof LocationQuadkeyHeatmapQuerySchema
|
|
7
|
-
|
|
8
|
-
export const LocationQuadkeyHeatmapAnswerSchema = asSchema('network.xyo.location.heatmap.quadkey.answer', true)
|
|
9
|
-
export type LocationQuadkeyHeatmapAnswerSchema = typeof LocationQuadkeyHeatmapAnswerSchema
|
|
10
|
-
|
|
11
|
-
export type LocationQuadkeyHeatmapQuery = {
|
|
12
|
-
schema: LocationWitnessSchema
|
|
13
|
-
startTime?: string
|
|
14
|
-
stopTime?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const isLocationQuadkeyHeatmapQuery = (query: Record<string, unknown>): query is LocationQuadkeyHeatmapQuery => {
|
|
18
|
-
return query && query?.schema === LocationQuadkeyHeatmapQuerySchema
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './LocationQuadkeyHeatmapQuery.ts'
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ApiConfig } from '@xyo-network/api-models'
|
|
2
|
-
|
|
3
|
-
import type { LocationHeatmapQuery, LocationHeatmapQuerySchema } from './LocationHeatmapQuery/index.ts'
|
|
4
|
-
import type { LocationQuadkeyHeatmapQuery, LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.ts'
|
|
5
|
-
import type { LocationQuerySchema } from './LocationQuerySchema.ts'
|
|
6
|
-
import type { LocationTimeRangeQuery, LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.ts'
|
|
7
|
-
|
|
8
|
-
export interface LocationQueryCreationRequest<
|
|
9
|
-
TSchema extends LocationQuerySchema = LocationQuerySchema,
|
|
10
|
-
TQuery extends Record<string, unknown> = Record<string, unknown>,
|
|
11
|
-
> {
|
|
12
|
-
query: TQuery
|
|
13
|
-
resultArchive: string
|
|
14
|
-
resultArchivist: ApiConfig
|
|
15
|
-
schema: TSchema
|
|
16
|
-
sourceArchive: string
|
|
17
|
-
sourceArchivist: ApiConfig
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type LocationTimeRangeQueryCreationRequest = LocationQueryCreationRequest<LocationTimeRangeQuerySchema, LocationTimeRangeQuery>
|
|
21
|
-
export type LocationHeatmapQueryCreationRequest = LocationQueryCreationRequest<LocationHeatmapQuerySchema, LocationHeatmapQuery>
|
|
22
|
-
|
|
23
|
-
export type LocationQuadkeyHeatmapQueryCreationRequest = LocationQueryCreationRequest<LocationQuadkeyHeatmapQuerySchema, LocationQuadkeyHeatmapQuery>
|
|
24
|
-
|
|
25
|
-
export type SupportedLocationQueryCreationRequest
|
|
26
|
-
= | LocationTimeRangeQueryCreationRequest
|
|
27
|
-
| LocationHeatmapQueryCreationRequest
|
|
28
|
-
| LocationQuadkeyHeatmapQueryCreationRequest
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Schema } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
import type { LocationHeatmapQuerySchema } from './LocationHeatmapQuery/index.ts'
|
|
4
|
-
import type { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.ts'
|
|
5
|
-
import type { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.ts'
|
|
6
|
-
|
|
7
|
-
export type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema
|
|
8
|
-
|
|
9
|
-
const locationQuerySchemas: Record<string, true> = {
|
|
10
|
-
'network.xyo.location.heatmap.quadkey.query': true,
|
|
11
|
-
'network.xyo.location.heatmap.query': true,
|
|
12
|
-
'network.xyo.location.range.query': true,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const isSupportedLocationQuerySchema = (schema: Schema): schema is LocationQuerySchema => {
|
|
16
|
-
return locationQuerySchemas[schema as LocationQuerySchema] || false
|
|
17
|
-
}
|
package/src/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { asSchema, isPayload } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
import { LocationWitnessSchema } from '../../Witnesses/index.ts'
|
|
4
|
-
|
|
5
|
-
export const LocationTimeRangeQuerySchema = asSchema('network.xyo.location.range.query', true)
|
|
6
|
-
export type LocationTimeRangeQuerySchema = typeof LocationTimeRangeQuerySchema
|
|
7
|
-
|
|
8
|
-
export const LocationTimeRangeAnswerSchema = asSchema('network.xyo.location.range.answer', true)
|
|
9
|
-
export type LocationTimeRangeAnswerSchema = typeof LocationTimeRangeAnswerSchema
|
|
10
|
-
|
|
11
|
-
export type LocationTimeRangeQuery = {
|
|
12
|
-
schema: LocationWitnessSchema
|
|
13
|
-
startTime?: string
|
|
14
|
-
stopTime?: string
|
|
15
|
-
|
|
16
|
-
// TODO: Bounding rectangle, etc.
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const isLocationTimeRangeQuery = isPayload([LocationWitnessSchema])
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './LocationHeatmapQuery/index.ts'
|
|
2
|
-
export * from './LocationQuadkeyHeatmapQuery/index.ts'
|
|
3
|
-
export * from './LocationQueryCreationRequest.ts'
|
|
4
|
-
export * from './LocationQueryCreationResponse.ts'
|
|
5
|
-
export * from './LocationQuerySchema.ts'
|
|
6
|
-
export * from './LocationTimeRangeQuery/index.ts'
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Payload } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const CurrentLocationWitnessSchema = asSchema('co.coinapp.currentlocationwitness', true)
|
|
4
|
-
export type CurrentLocationWitnessSchema = typeof CurrentLocationWitnessSchema
|
|
5
|
-
|
|
6
|
-
export type CurrentLocationWitnessPayload = Payload<{
|
|
7
|
-
altitudeMeters: number
|
|
8
|
-
directionDegrees: number
|
|
9
|
-
latitude: number
|
|
10
|
-
longitude: number
|
|
11
|
-
quadkey: string
|
|
12
|
-
schema: CurrentLocationWitnessSchema
|
|
13
|
-
speedKph: number
|
|
14
|
-
}>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { asSchema, type Payload } from '@xyo-network/payload-model'
|
|
2
|
-
|
|
3
|
-
export const LocationWitnessSchema = asSchema('network.xyo.location', true)
|
|
4
|
-
export type LocationWitnessSchema = typeof LocationWitnessSchema
|
|
5
|
-
|
|
6
|
-
export interface Coordinates {
|
|
7
|
-
accuracy: number | null
|
|
8
|
-
altitude: number | null
|
|
9
|
-
altitudeAccuracy: number | null
|
|
10
|
-
heading: number | null
|
|
11
|
-
latitude: number
|
|
12
|
-
longitude: number
|
|
13
|
-
speed: number | null
|
|
14
|
-
}
|
|
15
|
-
export interface CurrentLocation {
|
|
16
|
-
coords: Coordinates
|
|
17
|
-
timestamp: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type LocationWitnessPayload = Payload<{
|
|
21
|
-
currentLocation: CurrentLocation
|
|
22
|
-
schema: LocationWitnessSchema
|
|
23
|
-
}>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DivinerConfig } from '@xyo-network/diviner-model'
|
|
2
|
-
import { asSchema } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
import type { ArchivistApi } from '../Api/index.ts'
|
|
5
|
-
|
|
6
|
-
export const RemoteDivinerConfigSchema = asSchema('network.xyo.diviner.remote.config', true)
|
|
7
|
-
export type RemoteDivinerConfigSchema = typeof RemoteDivinerConfigSchema
|
|
8
|
-
|
|
9
|
-
export type RemoteDivinerConfig = DivinerConfig & {
|
|
10
|
-
/** @deprecated use in params instead */
|
|
11
|
-
api?: ArchivistApi
|
|
12
|
-
archive?: string
|
|
13
|
-
schema: RemoteDivinerConfigSchema
|
|
14
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isString } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
export class RemoteDivinerError extends Error {
|
|
4
|
-
isRemoteDivinerError = true
|
|
5
|
-
constructor(action: string, error: Error['cause'], message?: string) {
|
|
6
|
-
const messageString = isString(message) ? ` (${message})` : ''
|
|
7
|
-
super(`Remote Diviner [${action}] failed${messageString}`, { cause: error })
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static isRemoteDivinerError(error: unknown): RemoteDivinerError | undefined {
|
|
11
|
-
return (error as RemoteDivinerError).isRemoteDivinerError ? (error as RemoteDivinerError) : undefined
|
|
12
|
-
}
|
|
13
|
-
}
|
package/src/Diviner/index.ts
DELETED
package/src/Simple.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ApiConfig, ApiResponseBody, ApiResponseTuple, ApiResponseTupleOrBody, ApiResponseType,
|
|
3
|
-
} from '@xyo-network/api-models'
|
|
4
|
-
import type { Payload, PayloadFindFilter } from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
import { ApiBase } from './Base.ts'
|
|
7
|
-
import { objToQuery } from './objToQuery.ts'
|
|
8
|
-
|
|
9
|
-
export type ApiSimpleQuery = PayloadFindFilter
|
|
10
|
-
|
|
11
|
-
export class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {
|
|
12
|
-
async delete(): Promise<ApiResponseBody<T>>
|
|
13
|
-
async delete(responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
14
|
-
async delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
15
|
-
async delete(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
16
|
-
switch (responseType) {
|
|
17
|
-
case 'tuple': {
|
|
18
|
-
return await this.deleteEndpoint(undefined, 'tuple')
|
|
19
|
-
}
|
|
20
|
-
default: {
|
|
21
|
-
return await this.deleteEndpoint()
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async find(query?: Q): Promise<ApiResponseBody<T>>
|
|
27
|
-
async find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
28
|
-
async find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
29
|
-
async find(query = {}, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
30
|
-
switch (responseType) {
|
|
31
|
-
case 'tuple': {
|
|
32
|
-
return await this.getEndpoint(objToQuery(query), 'tuple')
|
|
33
|
-
}
|
|
34
|
-
default: {
|
|
35
|
-
return await this.getEndpoint(objToQuery(query))
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async get(): Promise<ApiResponseBody<T>>
|
|
41
|
-
async get(responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
42
|
-
async get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
43
|
-
async get(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
44
|
-
switch (responseType) {
|
|
45
|
-
case 'tuple': {
|
|
46
|
-
return await this.getEndpoint(undefined, 'tuple')
|
|
47
|
-
}
|
|
48
|
-
default: {
|
|
49
|
-
return await this.getEndpoint()
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async post(data?: D): Promise<ApiResponseBody<T>>
|
|
55
|
-
async post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
56
|
-
async post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
57
|
-
async post(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
58
|
-
switch (responseType) {
|
|
59
|
-
case 'tuple': {
|
|
60
|
-
return await this.postEndpoint(undefined, data, 'tuple')
|
|
61
|
-
}
|
|
62
|
-
default: {
|
|
63
|
-
return await this.postEndpoint(undefined, data)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async put(data?: D): Promise<ApiResponseBody<T>>
|
|
69
|
-
async put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>
|
|
70
|
-
async put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>
|
|
71
|
-
async put(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {
|
|
72
|
-
switch (responseType) {
|
|
73
|
-
case 'tuple': {
|
|
74
|
-
return await this.putEndpoint(undefined, data, 'tuple')
|
|
75
|
-
}
|
|
76
|
-
default: {
|
|
77
|
-
return await this.putEndpoint(undefined, data)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
package/src/WithArchive.ts
DELETED
package/src/index.ts
DELETED
package/src/models/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ArchivePath.ts'
|
package/src/objToQuery.ts
DELETED
package/src/spec/testPayload.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { StringKeyObject } from '@xylabs/sdk-js'
|
|
2
|
-
import { asSchema, type Payload } from '@xyo-network/payload-model'
|
|
3
|
-
import { expect, it } from 'vitest'
|
|
4
|
-
|
|
5
|
-
const testSchema = asSchema('network.xyo.test', true)
|
|
6
|
-
const testPayload: Payload<StringKeyObject> = {
|
|
7
|
-
_hash: '20e14207f952a09f767ff614a648546c037fe524ace0bfe55db31f818aff1f1c',
|
|
8
|
-
_timestamp: 1_609_459_255_555,
|
|
9
|
-
numberField: 1,
|
|
10
|
-
objectField: {
|
|
11
|
-
numberField: 1,
|
|
12
|
-
stringField: 'stringValue',
|
|
13
|
-
},
|
|
14
|
-
schema: testSchema,
|
|
15
|
-
stringField: 'stringValue',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
it('no test', () => {
|
|
19
|
-
expect(true).toBeTruthy()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
export { testPayload, testSchema }
|