@xyo-network/location-certainty-plugin 4.1.1 → 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.
@@ -1,29 +1,3 @@
1
- import { DivinerConfig, DivinerParams, DivinerModule } from '@xyo-network/diviner-model';
2
- import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin';
3
- import { Payload, Schema } from '@xyo-network/payload-model';
4
- import { AbstractDiviner } from '@xyo-network/diviner-abstract';
5
- import { AnyConfigSchema } from '@xyo-network/module-model';
6
- import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
7
-
8
- type LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config';
9
- declare const LocationCertaintyDivinerConfigSchema: LocationCertaintyDivinerConfigSchema;
10
- type LocationCertaintyDivinerConfig<TConfig extends Payload = Payload> = DivinerConfig<TConfig & {
11
- schema: LocationCertaintyDivinerConfigSchema;
12
- targetSchema?: LocationCertaintySchema;
13
- }>;
14
-
15
- type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>;
16
- declare class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams> extends AbstractDiviner<TParam> implements DivinerModule {
17
- static readonly configSchemas: Schema[];
18
- static readonly defaultConfigSchema: Schema;
19
- static readonly targetSchema: "network.xyo.location.certainty";
20
- private static calcHeuristic;
21
- private static locationsToHeuristics;
22
- /** @description Given a set of locations, get the expected elevations (witness if needed), and return score/variance */
23
- protected divineHandler(payloads?: Payload[]): Promise<Payload[]>;
24
- }
25
-
26
- declare const LocationCertaintyPlugin: () => _xyo_network_payloadset_plugin.PayloadSetDivinerPlugin<LocationCertaintyDiviner<LocationCertaintyDivinerParams>>;
27
-
28
- export { LocationCertaintyDiviner, LocationCertaintyDivinerConfigSchema, LocationCertaintyPlugin, LocationCertaintyPlugin as default };
29
- export type { LocationCertaintyDivinerConfig, LocationCertaintyDivinerParams };
1
+ export * from './Diviner/index.ts';
2
+ export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin.ts';
3
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/location-certainty-plugin",
3
- "version": "4.1.1",
3
+ "version": "5.0.0",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -28,27 +28,30 @@
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": "^4.1.7",
33
- "@xyo-network/diviner-model": "^4.1.7",
34
- "@xyo-network/elevation-plugin": "^4.1.1",
35
- "@xyo-network/location-certainty-payload-plugin": "^4.1.1",
36
- "@xyo-network/location-payload-plugin": "^4.1.1",
37
- "@xyo-network/module-model": "^4.1.7",
38
- "@xyo-network/payload-builder": "^4.1.7",
39
- "@xyo-network/payload-model": "^4.1.7",
40
- "@xyo-network/payloadset-plugin": "^4.1.7"
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.0-rc.24",
44
- "@xylabs/tsconfig": "^7.0.0-rc.24",
45
- "@xylabs/vitest-extended": "^4.13.23",
46
- "@xyo-network/archivist-abstract": "^4.1.7",
47
- "@xyo-network/archivist-memory": "^4.1.7",
48
- "@xyo-network/elevation-payload-plugin": "^4.1.1",
49
- "@xyo-network/module-resolver": "^4.1.7",
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
- "knip": "^5.62.0",
52
55
  "typescript": "^5.8.3",
53
56
  "vitest": "^3.2.4"
54
57
  },
@@ -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
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "https://typedoc.org/schema.json",
3
- "entryPoints": ["./src/index.ts"],
4
- "tsconfig": "./tsconfig.typedoc.json"
5
- }
package/xy.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
- const config: XyTsupConfig = {
3
- compile: {
4
- browser: {},
5
- node: {},
6
- neutral: { src: true },
7
- },
8
- }
9
-
10
- export default config