@xyo-network/location-certainty-plugin 4.2.0 → 5.0.0
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 +21 -17
- package/src/Diviner/spec/Diviner.spec.ts +143 -0
- package/src/spec/Plugin.dom.spec.ts +23 -0
- package/typedoc.json +0 -5
- package/xy.config.ts +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/location-certainty-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -28,25 +28,29 @@
|
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@xyo-network/diviner-abstract": "^
|
|
33
|
-
"@xyo-network/diviner-model": "^
|
|
34
|
-
"@xyo-network/elevation-plugin": "^
|
|
35
|
-
"@xyo-network/location-certainty-payload-plugin": "^
|
|
36
|
-
"@xyo-network/location-payload-plugin": "^
|
|
37
|
-
"@xyo-network/module-model": "^
|
|
38
|
-
"@xyo-network/payload-builder": "^
|
|
39
|
-
"@xyo-network/payload-model": "^
|
|
40
|
-
"@xyo-network/payloadset-plugin": "^
|
|
36
|
+
"@xyo-network/diviner-abstract": "^5.0.0",
|
|
37
|
+
"@xyo-network/diviner-model": "^5.0.0",
|
|
38
|
+
"@xyo-network/elevation-plugin": "^5.0.0",
|
|
39
|
+
"@xyo-network/location-certainty-payload-plugin": "^5.0.0",
|
|
40
|
+
"@xyo-network/location-payload-plugin": "^5.0.0",
|
|
41
|
+
"@xyo-network/module-model": "^5.0.0",
|
|
42
|
+
"@xyo-network/payload-builder": "^5.0.0",
|
|
43
|
+
"@xyo-network/payload-model": "^5.0.0",
|
|
44
|
+
"@xyo-network/payloadset-plugin": "^5.0.0"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.
|
|
44
|
-
"@xylabs/tsconfig": "^7.0.
|
|
45
|
-
"@xylabs/vitest-extended": "^
|
|
46
|
-
"@xyo-network/archivist-abstract": "^
|
|
47
|
-
"@xyo-network/archivist-memory": "^
|
|
48
|
-
"@xyo-network/elevation-payload-plugin": "^
|
|
49
|
-
"@xyo-network/module-resolver": "^
|
|
47
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.2",
|
|
48
|
+
"@xylabs/tsconfig": "^7.0.2",
|
|
49
|
+
"@xylabs/vitest-extended": "^5.0.0",
|
|
50
|
+
"@xyo-network/archivist-abstract": "^5.0.0",
|
|
51
|
+
"@xyo-network/archivist-memory": "^5.0.0",
|
|
52
|
+
"@xyo-network/elevation-payload-plugin": "^5.0.0",
|
|
53
|
+
"@xyo-network/module-resolver": "^5.0.0",
|
|
50
54
|
"fast-text-encoding": "^1.0.6",
|
|
51
55
|
"typescript": "^5.8.3",
|
|
52
56
|
"vitest": "^3.2.4"
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import '@xylabs/vitest-extended'
|
|
2
|
+
|
|
3
|
+
import type { AbstractArchivist } from '@xyo-network/archivist-abstract'
|
|
4
|
+
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
5
|
+
import type { LocationCertaintyPayload } from '@xyo-network/location-certainty-payload-plugin'
|
|
6
|
+
import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'
|
|
7
|
+
import type { LocationPayload } from '@xyo-network/location-payload-plugin'
|
|
8
|
+
import { LocationSchema } from '@xyo-network/location-payload-plugin'
|
|
9
|
+
import { CompositeModuleResolver } from '@xyo-network/module-resolver'
|
|
10
|
+
import {
|
|
11
|
+
beforeEach,
|
|
12
|
+
describe, expect, it,
|
|
13
|
+
} from 'vitest'
|
|
14
|
+
|
|
15
|
+
import { LocationCertaintyDivinerConfigSchema } from '../Config.ts'
|
|
16
|
+
import { LocationCertaintyDiviner } from '../Diviner.ts'
|
|
17
|
+
|
|
18
|
+
const sample1: LocationPayload[] = [
|
|
19
|
+
{
|
|
20
|
+
altitude: -5,
|
|
21
|
+
latitude: 32.716_64,
|
|
22
|
+
longitude: -117.120_33,
|
|
23
|
+
schema: LocationSchema,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
altitude: -9,
|
|
27
|
+
latitude: 32.7174,
|
|
28
|
+
longitude: -117.116_74,
|
|
29
|
+
schema: LocationSchema,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
altitude: -11,
|
|
33
|
+
latitude: 32.717_88,
|
|
34
|
+
longitude: -117.113_77,
|
|
35
|
+
schema: LocationSchema,
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
const sample2: LocationPayload[] = [
|
|
40
|
+
{
|
|
41
|
+
altitude: 50,
|
|
42
|
+
latitude: 32.716_64,
|
|
43
|
+
longitude: -117.120_33,
|
|
44
|
+
schema: LocationSchema,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
altitude: 53,
|
|
48
|
+
latitude: 32.7174,
|
|
49
|
+
longitude: -117.116_74,
|
|
50
|
+
schema: LocationSchema,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
altitude: 55,
|
|
54
|
+
latitude: 32.717_88,
|
|
55
|
+
longitude: -117.113_77,
|
|
56
|
+
schema: LocationSchema,
|
|
57
|
+
},
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
const sample3: LocationPayload[] = [
|
|
61
|
+
{
|
|
62
|
+
altitude: 151,
|
|
63
|
+
latitude: 32.716_64,
|
|
64
|
+
longitude: -117.120_33,
|
|
65
|
+
schema: LocationSchema,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
altitude: 163,
|
|
69
|
+
latitude: 32.7174,
|
|
70
|
+
longitude: -117.116_74,
|
|
71
|
+
schema: LocationSchema,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
altitude: 168,
|
|
75
|
+
latitude: 32.717_88,
|
|
76
|
+
longitude: -117.113_77,
|
|
77
|
+
schema: LocationSchema,
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
describe.skip('MongoDBLocationCertaintyDiviner', () => {
|
|
82
|
+
let payloadsArchivist: AbstractArchivist
|
|
83
|
+
let sut: LocationCertaintyDiviner
|
|
84
|
+
beforeEach(async () => {
|
|
85
|
+
payloadsArchivist = await MemoryArchivist.create({ account: 'random' })
|
|
86
|
+
const params = {
|
|
87
|
+
config: {
|
|
88
|
+
schema: LocationCertaintyDivinerConfigSchema,
|
|
89
|
+
targetSchema: LocationCertaintySchema,
|
|
90
|
+
},
|
|
91
|
+
resolver: new CompositeModuleResolver({ root: sut }).add(payloadsArchivist),
|
|
92
|
+
}
|
|
93
|
+
sut = (await LocationCertaintyDiviner.create(params)) as LocationCertaintyDiviner
|
|
94
|
+
})
|
|
95
|
+
describe('divine', () => {
|
|
96
|
+
describe('with valid query', () => {
|
|
97
|
+
it('divines', async () => {
|
|
98
|
+
const noLocations: LocationPayload[] = []
|
|
99
|
+
const noLocationsResult = await sut.divine(noLocations)
|
|
100
|
+
expect(noLocationsResult).toBeArrayOfSize(0)
|
|
101
|
+
const locations: LocationPayload[] = [
|
|
102
|
+
{
|
|
103
|
+
altitude: 5, quadkey: '0203', schema: LocationSchema,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
altitude: 300, quadkey: '0102', schema: LocationSchema,
|
|
107
|
+
},
|
|
108
|
+
]
|
|
109
|
+
const locationsResult = await sut.divine(locations)
|
|
110
|
+
expect(locationsResult).toBeArrayOfSize(1)
|
|
111
|
+
const actual = locationsResult[0] as LocationCertaintyPayload
|
|
112
|
+
expect(actual).toBeObject()
|
|
113
|
+
expect(actual.schema).toBe(LocationCertaintySchema)
|
|
114
|
+
|
|
115
|
+
const locationsResult1 = (await sut.divine(sample1)) as LocationCertaintyPayload[]
|
|
116
|
+
const locationsResult2 = (await sut.divine(sample2)) as LocationCertaintyPayload[]
|
|
117
|
+
const locationsResult3 = (await sut.divine(sample3)) as LocationCertaintyPayload[]
|
|
118
|
+
for (let r of [locationsResult1, locationsResult2, locationsResult3]) {
|
|
119
|
+
validateLocationResult(r)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const validateLocationResult = (results: LocationCertaintyPayload[]) => {
|
|
127
|
+
expect(results).toBeArrayOfSize(1)
|
|
128
|
+
const [result] = results
|
|
129
|
+
expect(result).toBeObject()
|
|
130
|
+
expect(result.schema).toBe(LocationCertaintySchema)
|
|
131
|
+
expect(result.altitude).toBeObject()
|
|
132
|
+
expect(result.altitude.max).toBeNumber()
|
|
133
|
+
expect(result.altitude.mean).toBeNumber()
|
|
134
|
+
expect(result.altitude.min).toBeNumber()
|
|
135
|
+
expect(result.elevation).toBeObject()
|
|
136
|
+
expect(result.elevation.max).toBeNumber()
|
|
137
|
+
expect(result.elevation.mean).toBeNumber()
|
|
138
|
+
expect(result.elevation.min).toBeNumber()
|
|
139
|
+
expect(result.variance).toBeObject()
|
|
140
|
+
expect(result.variance.max).toBeNumber()
|
|
141
|
+
expect(result.variance.mean).toBeNumber()
|
|
142
|
+
expect(result.variance.min).toBeNumber()
|
|
143
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Polyfill TextDecoder
|
|
2
|
+
import 'fast-text-encoding'
|
|
3
|
+
import '@xylabs/vitest-extended'
|
|
4
|
+
|
|
5
|
+
import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'
|
|
6
|
+
import { PayloadSetPluginResolver } from '@xyo-network/payloadset-plugin'
|
|
7
|
+
import {
|
|
8
|
+
describe, expect,
|
|
9
|
+
test,
|
|
10
|
+
} from 'vitest'
|
|
11
|
+
|
|
12
|
+
import { LocationCertaintyDivinerConfigSchema } from '../Diviner/index.ts'
|
|
13
|
+
import { LocationCertaintyPlugin } from '../Plugin.ts'
|
|
14
|
+
|
|
15
|
+
describe('LocationCertaintyPlugin', () => {
|
|
16
|
+
test('Add to Resolver', async () => {
|
|
17
|
+
const plugin = LocationCertaintyPlugin()
|
|
18
|
+
const resolver = await new PayloadSetPluginResolver()
|
|
19
|
+
.register(plugin, { config: { schema: LocationCertaintyDivinerConfigSchema, targetSchema: LocationCertaintySchema } })
|
|
20
|
+
expect(await resolver.resolve(plugin.set)).toBeObject()
|
|
21
|
+
expect(await resolver.diviner(plugin.set)).toBeObject()
|
|
22
|
+
})
|
|
23
|
+
})
|
package/typedoc.json
DELETED