@xyo-network/location-certainty-plugin 5.3.1 → 5.3.3

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 +1 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/Diviner/Diviner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAO9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAA;AAGjE,MAAM,MAAM,8BAA8B,GAAG,aAAa,CAAC,eAAe,CAAC,8BAA8B,CAAC,CAAC,CAAA;AAE3G,qBAAa,wBAAwB,CAAC,MAAM,SAAS,8BAA8B,GAAG,8BAA8B,CAClH,SAAQ,eAAe,CAAC,MAAM,CAC9B,YAAW,aAAa;IACxB,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAiE;IACjH,gBAAyB,mBAAmB,EAAE,MAAM,CAAuC;IAC3F,gBAAyB,YAAY;;MAA0B;IAG/D,OAAO,CAAC,MAAM,CAAC,aAAa;IAgC5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAqBpC,wHAAwH;cAC/F,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA4BjF"}
1
+ {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/Diviner/Diviner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAO9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAGjE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAA;AAGjE,MAAM,MAAM,8BAA8B,GAAG,aAAa,CAAC,eAAe,CAAC,8BAA8B,CAAC,CAAC,CAAA;AAE3G,qBAAa,wBAAwB,CAAC,MAAM,SAAS,8BAA8B,GAAG,8BAA8B,CAClH,SAAQ,eAAe,CAAC,MAAM,CAC9B,YAAW,aAAa;IACxB,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAiE;IACjH,gBAAyB,mBAAmB,EAAE,MAAM,CAAuC;IAC3F,gBAAyB,YAAY;;MAA0B;IAG/D,OAAO,CAAC,MAAM,CAAC,aAAa;IAgC5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAqBpC,wHAAwH;cAC/F,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA4BjF"}
@@ -7,7 +7,7 @@ import { AbstractDiviner } from "@xyo-network/diviner-abstract";
7
7
  import { ElevationWitness, ElevationWitnessConfigSchema } from "@xyo-network/elevation-plugin";
8
8
  import { LocationCertaintySchema } from "@xyo-network/location-certainty-payload-plugin";
9
9
  import { LocationSchema } from "@xyo-network/location-payload-plugin";
10
- import { PayloadBuilder } from "@xyo-network/payload-builder";
10
+ import { PayloadBuilder } from "@xyo-network/sdk-js";
11
11
  var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractDiviner {
12
12
  static configSchemas = [...super.configSchemas, LocationCertaintyDivinerConfigSchema];
13
13
  static defaultConfigSchema = LocationCertaintyDivinerConfigSchema;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner/Config.ts","../../src/Diviner/Diviner.ts","../../src/Plugin.ts"],"sourcesContent":["import type { DivinerConfig } from '@xyo-network/diviner-model'\nimport type { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport { asSchema, type Payload } from '@xyo-network/payload-model'\n\nexport type LocationCertaintyDivinerConfigSchema = typeof LocationCertaintyDivinerConfigSchema\nexport const LocationCertaintyDivinerConfigSchema = asSchema('network.xyo.location.elevation.diviner.config', true)\n\nexport type LocationCertaintyDivinerConfig<TConfig extends Payload = Payload> = DivinerConfig<\n TConfig & {\n schema: LocationCertaintyDivinerConfigSchema\n targetSchema?: LocationCertaintySchema\n }\n>\n","import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerModule, DivinerParams } from '@xyo-network/diviner-model'\nimport type { ElevationPayload } from '@xyo-network/elevation-payload-plugin'\nimport { ElevationWitness, ElevationWitnessConfigSchema } from '@xyo-network/elevation-plugin'\nimport type { LocationCertaintyHeuristic, LocationCertaintyPayload } from '@xyo-network/location-certainty-payload-plugin'\nimport { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport type { LocationPayload } from '@xyo-network/location-payload-plugin'\nimport { LocationSchema } from '@xyo-network/location-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { LocationCertaintyDivinerConfig } from './Config.ts'\nimport { LocationCertaintyDivinerConfigSchema } from './Config.ts'\n\nexport type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>\n\nexport class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams>\n extends AbstractDiviner<TParam>\n implements DivinerModule {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, LocationCertaintyDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = LocationCertaintyDivinerConfigSchema\n static override readonly targetSchema = LocationCertaintySchema\n\n /* Given an array of numbers, find the min/max/mean */\n private static calcHeuristic(heuristic: (number | null)[]): LocationCertaintyHeuristic {\n return {\n // eslint-disable-next-line unicorn/no-array-reduce\n max: heuristic.reduce<number>((prev, value) => {\n return (\n value === null\n ? prev\n : Math.max(value, prev)\n )\n }, Number.NEGATIVE_INFINITY),\n mean: (() => {\n // eslint-disable-next-line unicorn/no-array-reduce\n const values = heuristic.reduce<number[]>(\n (prev, value) => {\n return value === null ? prev : [value + prev[0], prev[1] + 1]\n },\n [0, 0],\n )\n return values[0] / values[1]\n })(),\n // eslint-disable-next-line unicorn/no-array-reduce\n min: heuristic.reduce<number>((prev, value) => {\n return (\n value === null\n ? prev\n : Math.min(value, prev)\n )\n }, Number.POSITIVE_INFINITY),\n }\n }\n\n /* Given elevation and location payloads, generate heuristic arrays */\n private static locationsToHeuristics(elevations: ElevationPayload[], locations: LocationPayload[]) {\n // eslint-disable-next-line unicorn/no-array-reduce\n const heuristics = elevations.reduce<{ altitude: (number | null)[]; elevation: number[]; variance: (number | null)[] }>(\n (prev, elev, index) => {\n const elevation = elev.elevation\n if (elevation === undefined || elevation === null) {\n throw new Error('Invalid Elevation')\n }\n const altitude = locations[index].altitude\n prev.altitude.push(altitude ?? null)\n prev.elevation.push(elevation)\n prev.variance.push(altitude !== undefined && altitude !== null ? altitude - elevation : null)\n return prev\n },\n {\n altitude: [], elevation: [], variance: [],\n },\n )\n return heuristics\n }\n\n /** @description Given a set of locations, get the expected elevations (witness if needed), and return score/variance */\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const locations = payloads?.filter<LocationPayload>((payload): payload is LocationPayload => payload?.schema === LocationSchema)\n // If this is a query we support\n if (locations && locations?.length > 0) {\n const elevationWitness = await ElevationWitness.create({\n account: this.account,\n config: {\n locations,\n schema: ElevationWitnessConfigSchema,\n },\n })\n const elevations = (await elevationWitness.observe()) as ElevationPayload[]\n\n const heuristics = LocationCertaintyDiviner.locationsToHeuristics(elevations, locations)\n\n const result = new PayloadBuilder<LocationCertaintyPayload>({ schema: LocationCertaintySchema })\n .fields({\n altitude: LocationCertaintyDiviner.calcHeuristic(heuristics.altitude),\n elevation: LocationCertaintyDiviner.calcHeuristic(heuristics.elevation),\n variance: LocationCertaintyDiviner.calcHeuristic(heuristics.variance),\n })\n .build()\n\n this.logger?.log('LocationCertaintyDiviner.Divine: Processed query')\n return [result]\n }\n return []\n }\n}\n","import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { LocationCertaintyDiviner } from './Diviner/index.ts'\n\nexport const LocationCertaintyPlugin = () =>\n createPayloadSetDivinerPlugin<LocationCertaintyDiviner>(\n { required: { [LocationCertaintySchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n return (await LocationCertaintyDiviner.create(params)) as LocationCertaintyDiviner\n },\n },\n )\n"],"mappings":";AAEA,SAAS,gBAA8B;AAGhC,IAAM,uCAAuC,SAAS,iDAAiD,IAAI;;;ACLlH,SAAS,uBAAuB;AAGhC,SAAS,kBAAkB,oCAAoC;AAE/D,SAAS,+BAA+B;AAExC,SAAS,sBAAsB;AAE/B,SAAS,sBAAsB;AAQxB,IAAM,2BAAN,MAAM,kCACH,gBACiB;AAAA,EACzB,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,oCAAoC;AAAA,EAChH,OAAyB,sBAA8B;AAAA,EACvD,OAAyB,eAAe;AAAA;AAAA,EAGxC,OAAe,cAAc,WAA0D;AACrF,WAAO;AAAA;AAAA,MAEL,KAAK,UAAU,OAAe,CAAC,MAAM,UAAU;AAC7C,eACE,UAAU,OACN,OACA,KAAK,IAAI,OAAO,IAAI;AAAA,MAE5B,GAAG,OAAO,iBAAiB;AAAA,MAC3B,OAAO,MAAM;AAEX,cAAM,SAAS,UAAU;AAAA,UACvB,CAAC,MAAM,UAAU;AACf,mBAAO,UAAU,OAAO,OAAO,CAAC,QAAQ,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,C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AwB,CAAC,EAC5F,OAAO;AAAA,QACN,UAAU,0BAAyB,cAAc,WAAW,QAAQ;AAAA,QACpE,WAAW,0BAAyB,cAAc,WAAW,SAAS;AAAA,QACtE,UAAU,0BAAyB,cAAc,WAAW,QAAQ;AAAA,MACtE,CAAC,EACA,MAAM;AAET,WAAK,QAAQ,IAAI,kDAAkD;AACnE,aAAO,CAAC,MAAM;AAAA,IAChB;AACA,WAAO,CAAC;AAAA,EACV;AACF;;;AC3GA,SAAS,2BAAAA,gCAA+B;AACxC,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,0BAA0B,MACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,wBAAuB,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACvE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAQ,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACtD;AAAA,EACF;AACF;","names":["LocationCertaintySchema","LocationCertaintySchema"]}
1
+ {"version":3,"sources":["../../src/Diviner/Config.ts","../../src/Diviner/Diviner.ts","../../src/Plugin.ts"],"sourcesContent":["import type { DivinerConfig } from '@xyo-network/diviner-model'\nimport type { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport { asSchema, type Payload } from '@xyo-network/payload-model'\n\nexport type LocationCertaintyDivinerConfigSchema = typeof LocationCertaintyDivinerConfigSchema\nexport const LocationCertaintyDivinerConfigSchema = asSchema('network.xyo.location.elevation.diviner.config', true)\n\nexport type LocationCertaintyDivinerConfig<TConfig extends Payload = Payload> = DivinerConfig<\n TConfig & {\n schema: LocationCertaintyDivinerConfigSchema\n targetSchema?: LocationCertaintySchema\n }\n>\n","import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { DivinerModule, DivinerParams } from '@xyo-network/diviner-model'\nimport type { ElevationPayload } from '@xyo-network/elevation-payload-plugin'\nimport { ElevationWitness, ElevationWitnessConfigSchema } from '@xyo-network/elevation-plugin'\nimport type { LocationCertaintyHeuristic, LocationCertaintyPayload } from '@xyo-network/location-certainty-payload-plugin'\nimport { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport type { LocationPayload } from '@xyo-network/location-payload-plugin'\nimport { LocationSchema } from '@xyo-network/location-payload-plugin'\nimport type { AnyConfigSchema } from '@xyo-network/module-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { PayloadBuilder } from '@xyo-network/sdk-js'\n\nimport type { LocationCertaintyDivinerConfig } from './Config.ts'\nimport { LocationCertaintyDivinerConfigSchema } from './Config.ts'\n\nexport type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>\n\nexport class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams>\n extends AbstractDiviner<TParam>\n implements DivinerModule {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, LocationCertaintyDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = LocationCertaintyDivinerConfigSchema\n static override readonly targetSchema = LocationCertaintySchema\n\n /* Given an array of numbers, find the min/max/mean */\n private static calcHeuristic(heuristic: (number | null)[]): LocationCertaintyHeuristic {\n return {\n // eslint-disable-next-line unicorn/no-array-reduce\n max: heuristic.reduce<number>((prev, value) => {\n return (\n value === null\n ? prev\n : Math.max(value, prev)\n )\n }, Number.NEGATIVE_INFINITY),\n mean: (() => {\n // eslint-disable-next-line unicorn/no-array-reduce\n const values = heuristic.reduce<number[]>(\n (prev, value) => {\n return value === null ? prev : [value + prev[0], prev[1] + 1]\n },\n [0, 0],\n )\n return values[0] / values[1]\n })(),\n // eslint-disable-next-line unicorn/no-array-reduce\n min: heuristic.reduce<number>((prev, value) => {\n return (\n value === null\n ? prev\n : Math.min(value, prev)\n )\n }, Number.POSITIVE_INFINITY),\n }\n }\n\n /* Given elevation and location payloads, generate heuristic arrays */\n private static locationsToHeuristics(elevations: ElevationPayload[], locations: LocationPayload[]) {\n // eslint-disable-next-line unicorn/no-array-reduce\n const heuristics = elevations.reduce<{ altitude: (number | null)[]; elevation: number[]; variance: (number | null)[] }>(\n (prev, elev, index) => {\n const elevation = elev.elevation\n if (elevation === undefined || elevation === null) {\n throw new Error('Invalid Elevation')\n }\n const altitude = locations[index].altitude\n prev.altitude.push(altitude ?? null)\n prev.elevation.push(elevation)\n prev.variance.push(altitude !== undefined && altitude !== null ? altitude - elevation : null)\n return prev\n },\n {\n altitude: [], elevation: [], variance: [],\n },\n )\n return heuristics\n }\n\n /** @description Given a set of locations, get the expected elevations (witness if needed), and return score/variance */\n protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {\n const locations = payloads?.filter<LocationPayload>((payload): payload is LocationPayload => payload?.schema === LocationSchema)\n // If this is a query we support\n if (locations && locations?.length > 0) {\n const elevationWitness = await ElevationWitness.create({\n account: this.account,\n config: {\n locations,\n schema: ElevationWitnessConfigSchema,\n },\n })\n const elevations = (await elevationWitness.observe()) as ElevationPayload[]\n\n const heuristics = LocationCertaintyDiviner.locationsToHeuristics(elevations, locations)\n\n const result = new PayloadBuilder<LocationCertaintyPayload>({ schema: LocationCertaintySchema })\n .fields({\n altitude: LocationCertaintyDiviner.calcHeuristic(heuristics.altitude),\n elevation: LocationCertaintyDiviner.calcHeuristic(heuristics.elevation),\n variance: LocationCertaintyDiviner.calcHeuristic(heuristics.variance),\n })\n .build()\n\n this.logger?.log('LocationCertaintyDiviner.Divine: Processed query')\n return [result]\n }\n return []\n }\n}\n","import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { LocationCertaintyDiviner } from './Diviner/index.ts'\n\nexport const LocationCertaintyPlugin = () =>\n createPayloadSetDivinerPlugin<LocationCertaintyDiviner>(\n { required: { [LocationCertaintySchema]: 1 }, schema: PayloadSetSchema },\n {\n diviner: async (params) => {\n return (await LocationCertaintyDiviner.create(params)) as LocationC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AQ,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACtD;AAAA,EACF;AACF;","names":["LocationCertaintySchema","LocationCertaintySchema"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/location-certainty-plugin",
3
- "version": "5.3.1",
3
+ "version": "5.3.3",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,33 +30,43 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
- "!**/*.bench.*",
35
- "!**/*.spec.*",
36
- "!**/*.test.*"
33
+ "README.md"
37
34
  ],
38
35
  "dependencies": {
39
- "@xyo-network/diviner-abstract": "~5.3.2",
40
- "@xyo-network/diviner-model": "~5.3.2",
41
- "@xyo-network/elevation-plugin": "5.3.1",
42
- "@xyo-network/location-certainty-payload-plugin": "5.3.1",
43
- "@xyo-network/location-payload-plugin": "5.3.1",
44
- "@xyo-network/module-model": "~5.3.2",
45
- "@xyo-network/payload-builder": "~5.3.2",
46
- "@xyo-network/payload-model": "~5.3.2",
47
- "@xyo-network/payloadset-plugin": "~5.3.2"
36
+ "@xyo-network/elevation-plugin": "workspace:^",
37
+ "@xyo-network/location-certainty-payload-plugin": "workspace:^",
38
+ "@xyo-network/location-payload-plugin": "workspace:^"
48
39
  },
49
40
  "devDependencies": {
50
- "@xylabs/ts-scripts-yarn3": "~7.3.2",
51
- "@xylabs/tsconfig": "~7.3.2",
52
- "@xylabs/vitest-extended": "~5.0.64",
53
- "@xyo-network/archivist-abstract": "~5.3.2",
54
- "@xyo-network/archivist-memory": "~5.3.2",
55
- "@xyo-network/elevation-payload-plugin": "5.3.1",
56
- "@xyo-network/module-resolver": "~5.3.2",
41
+ "@xylabs/sdk-js": "^5.0.90",
42
+ "@xylabs/ts-scripts-common": "~7.5.10",
43
+ "@xylabs/ts-scripts-yarn3": "~7.5.10",
44
+ "@xylabs/tsconfig": "~7.5.10",
45
+ "@xylabs/vitest-extended": "~5.0.90",
46
+ "@xyo-network/archivist-abstract": "~5.3.5",
47
+ "@xyo-network/archivist-memory": "~5.3.5",
48
+ "@xyo-network/diviner-abstract": "~5.3.5",
49
+ "@xyo-network/diviner-model": "~5.3.5",
50
+ "@xyo-network/elevation-payload-plugin": "5.3.3",
51
+ "@xyo-network/module-model": "~5.3.5",
52
+ "@xyo-network/payload-model": "~5.3.5",
53
+ "@xyo-network/payloadset-plugin": "~5.3.5",
54
+ "@xyo-network/sdk-js": "~5.3.5",
57
55
  "fast-text-encoding": "~1.0.6",
56
+ "mapbox-gl": "^3",
58
57
  "typescript": "~5.9.3",
59
- "vitest": "~4.0.18"
58
+ "vitest": "~4.1.2",
59
+ "zod": "^4.3.6"
60
+ },
61
+ "peerDependencies": {
62
+ "@xylabs/sdk-js": "^5",
63
+ "@xyo-network/diviner-abstract": "^5",
64
+ "@xyo-network/diviner-model": "^5",
65
+ "@xyo-network/module-model": "^5",
66
+ "@xyo-network/payload-model": "^5",
67
+ "@xyo-network/payloadset-plugin": "^5",
68
+ "@xyo-network/sdk-js": "^5",
69
+ "zod": "^4"
60
70
  },
61
71
  "publishConfig": {
62
72
  "access": "public"
@@ -1,13 +0,0 @@
1
- import type { DivinerConfig } from '@xyo-network/diviner-model'
2
- import type { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'
3
- import { asSchema, type Payload } from '@xyo-network/payload-model'
4
-
5
- export type LocationCertaintyDivinerConfigSchema = typeof LocationCertaintyDivinerConfigSchema
6
- export const LocationCertaintyDivinerConfigSchema = asSchema('network.xyo.location.elevation.diviner.config', true)
7
-
8
- export type LocationCertaintyDivinerConfig<TConfig extends Payload = Payload> = DivinerConfig<
9
- TConfig & {
10
- schema: LocationCertaintyDivinerConfigSchema
11
- targetSchema?: LocationCertaintySchema
12
- }
13
- >
@@ -1,108 +0,0 @@
1
- import { AbstractDiviner } from '@xyo-network/diviner-abstract'
2
- import type { DivinerModule, DivinerParams } from '@xyo-network/diviner-model'
3
- import type { ElevationPayload } from '@xyo-network/elevation-payload-plugin'
4
- import { ElevationWitness, ElevationWitnessConfigSchema } from '@xyo-network/elevation-plugin'
5
- import type { LocationCertaintyHeuristic, 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 type { AnyConfigSchema } from '@xyo-network/module-model'
10
- import { PayloadBuilder } from '@xyo-network/payload-builder'
11
- import type { Payload, Schema } from '@xyo-network/payload-model'
12
-
13
- import type { LocationCertaintyDivinerConfig } from './Config.ts'
14
- import { LocationCertaintyDivinerConfigSchema } from './Config.ts'
15
-
16
- export type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>
17
-
18
- export class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams>
19
- extends AbstractDiviner<TParam>
20
- implements DivinerModule {
21
- static override readonly configSchemas: Schema[] = [...super.configSchemas, LocationCertaintyDivinerConfigSchema]
22
- static override readonly defaultConfigSchema: Schema = LocationCertaintyDivinerConfigSchema
23
- static override readonly targetSchema = LocationCertaintySchema
24
-
25
- /* Given an array of numbers, find the min/max/mean */
26
- private static calcHeuristic(heuristic: (number | null)[]): LocationCertaintyHeuristic {
27
- return {
28
- // eslint-disable-next-line unicorn/no-array-reduce
29
- max: heuristic.reduce<number>((prev, value) => {
30
- return (
31
- value === null
32
- ? prev
33
- : Math.max(value, prev)
34
- )
35
- }, Number.NEGATIVE_INFINITY),
36
- mean: (() => {
37
- // eslint-disable-next-line unicorn/no-array-reduce
38
- const values = heuristic.reduce<number[]>(
39
- (prev, value) => {
40
- return value === null ? prev : [value + prev[0], prev[1] + 1]
41
- },
42
- [0, 0],
43
- )
44
- return values[0] / values[1]
45
- })(),
46
- // eslint-disable-next-line unicorn/no-array-reduce
47
- min: heuristic.reduce<number>((prev, value) => {
48
- return (
49
- value === null
50
- ? prev
51
- : Math.min(value, prev)
52
- )
53
- }, Number.POSITIVE_INFINITY),
54
- }
55
- }
56
-
57
- /* Given elevation and location payloads, generate heuristic arrays */
58
- private static locationsToHeuristics(elevations: ElevationPayload[], locations: LocationPayload[]) {
59
- // eslint-disable-next-line unicorn/no-array-reduce
60
- const heuristics = elevations.reduce<{ altitude: (number | null)[]; elevation: number[]; variance: (number | null)[] }>(
61
- (prev, elev, index) => {
62
- const elevation = elev.elevation
63
- if (elevation === undefined || elevation === null) {
64
- throw new Error('Invalid Elevation')
65
- }
66
- const altitude = locations[index].altitude
67
- prev.altitude.push(altitude ?? null)
68
- prev.elevation.push(elevation)
69
- prev.variance.push(altitude !== undefined && altitude !== null ? altitude - elevation : null)
70
- return prev
71
- },
72
- {
73
- altitude: [], elevation: [], variance: [],
74
- },
75
- )
76
- return heuristics
77
- }
78
-
79
- /** @description Given a set of locations, get the expected elevations (witness if needed), and return score/variance */
80
- protected override async divineHandler(payloads?: Payload[]): Promise<Payload[]> {
81
- const locations = payloads?.filter<LocationPayload>((payload): payload is LocationPayload => payload?.schema === LocationSchema)
82
- // If this is a query we support
83
- if (locations && locations?.length > 0) {
84
- const elevationWitness = await ElevationWitness.create({
85
- account: this.account,
86
- config: {
87
- locations,
88
- schema: ElevationWitnessConfigSchema,
89
- },
90
- })
91
- const elevations = (await elevationWitness.observe()) as ElevationPayload[]
92
-
93
- const heuristics = LocationCertaintyDiviner.locationsToHeuristics(elevations, locations)
94
-
95
- const result = new PayloadBuilder<LocationCertaintyPayload>({ schema: LocationCertaintySchema })
96
- .fields({
97
- altitude: LocationCertaintyDiviner.calcHeuristic(heuristics.altitude),
98
- elevation: LocationCertaintyDiviner.calcHeuristic(heuristics.elevation),
99
- variance: LocationCertaintyDiviner.calcHeuristic(heuristics.variance),
100
- })
101
- .build()
102
-
103
- this.logger?.log('LocationCertaintyDiviner.Divine: Processed query')
104
- return [result]
105
- }
106
- return []
107
- }
108
- }
@@ -1,2 +0,0 @@
1
- export * from './Config.ts'
2
- export * from './Diviner.ts'
package/src/Plugin.ts DELETED
@@ -1,15 +0,0 @@
1
- import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'
2
- import { PayloadSetSchema } from '@xyo-network/payload-model'
3
- import { createPayloadSetDivinerPlugin } from '@xyo-network/payloadset-plugin'
4
-
5
- import { LocationCertaintyDiviner } from './Diviner/index.ts'
6
-
7
- export const LocationCertaintyPlugin = () =>
8
- createPayloadSetDivinerPlugin<LocationCertaintyDiviner>(
9
- { required: { [LocationCertaintySchema]: 1 }, schema: PayloadSetSchema },
10
- {
11
- diviner: async (params) => {
12
- return (await LocationCertaintyDiviner.create(params)) as LocationCertaintyDiviner
13
- },
14
- },
15
- )
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './Diviner/index.ts'
2
- export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin.ts'