@xyo-network/location-certainty-plugin 3.0.2 → 3.0.4

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.
@@ -0,0 +1,10 @@
1
+ import type { DivinerConfig } from '@xyo-network/diviner-model';
2
+ import type { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin';
3
+ import type { Payload } from '@xyo-network/payload-model';
4
+ export type LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config';
5
+ export declare const LocationCertaintyDivinerConfigSchema: LocationCertaintyDivinerConfigSchema;
6
+ export type LocationCertaintyDivinerConfig<TConfig extends Payload = Payload> = DivinerConfig<TConfig & {
7
+ schema: LocationCertaintyDivinerConfigSchema;
8
+ targetSchema?: LocationCertaintySchema;
9
+ }>;
10
+ //# sourceMappingURL=Config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../src/Diviner/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAA;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEzD,MAAM,MAAM,oCAAoC,GAAG,+CAA+C,CAAA;AAClG,eAAO,MAAM,oCAAoC,EAAE,oCAAsF,CAAA;AAEzI,MAAM,MAAM,8BAA8B,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,IAAI,aAAa,CAC3F,OAAO,GAAG;IACR,MAAM,EAAE,oCAAoC,CAAA;IAC5C,YAAY,CAAC,EAAE,uBAAuB,CAAA;CACvC,CACF,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { AbstractDiviner } from '@xyo-network/diviner-abstract';
2
+ import type { DivinerModule, DivinerParams } from '@xyo-network/diviner-model';
3
+ import type { AnyConfigSchema } from '@xyo-network/module-model';
4
+ import type { Payload, Schema } from '@xyo-network/payload-model';
5
+ import type { LocationCertaintyDivinerConfig } from './Config.ts';
6
+ export type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>;
7
+ export declare class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams> extends AbstractDiviner<TParam> implements DivinerModule {
8
+ static readonly configSchemas: Schema[];
9
+ static readonly defaultConfigSchema: Schema;
10
+ static targetSchema: "network.xyo.location.certainty";
11
+ private static calcHeuristic;
12
+ private static locationsToHeuristics;
13
+ protected divineHandler(payloads?: Payload[]): Promise<Payload[]>;
14
+ }
15
+ //# sourceMappingURL=Diviner.d.ts.map
@@ -0,0 +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,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;IAoC5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;cAsBX,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA4BjF"}
@@ -0,0 +1,3 @@
1
+ export * from './Config.ts';
2
+ export * from './Diviner.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Diviner/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin';
2
+ import { LocationCertaintyDiviner } from './Diviner/index.ts';
3
+ export declare const LocationCertaintyPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDivinerPlugin<LocationCertaintyDiviner<import(".store/@xylabs-object-npm-4.0.4-83706dfe17/package").BaseParamsFields & {
4
+ account?: import(".store/@xyo-network-account-model-virtual-6a37ef4f2d/package").AccountInstance | "random";
5
+ addToResolvers?: boolean;
6
+ additionalSigners?: import(".store/@xyo-network-account-model-virtual-6a37ef4f2d/package").AccountInstance[];
7
+ allowNameResolution?: boolean;
8
+ config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
9
+ schema: "network.xyo.location.elevation.diviner.config";
10
+ } & {
11
+ schema: string;
12
+ } & import("@xyo-network/payload-model").PayloadFields & {
13
+ schema: import("./Diviner/Config.ts").LocationCertaintyDivinerConfigSchema;
14
+ targetSchema?: LocationCertaintySchema;
15
+ }, "schema"> & {
16
+ schema: "network.xyo.location.elevation.diviner.config";
17
+ }, "schema"> & {
18
+ schema: string;
19
+ };
20
+ ephemeralQueryAccountEnabled?: boolean;
21
+ moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
22
+ }>>;
23
+ //# sourceMappingURL=Plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAA;AAIxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;GAQjC,CAAA"}
@@ -1,50 +1,3 @@
1
- import { DivinerConfig, DivinerParams, DivinerModule } from '@xyo-network/diviner-model';
2
- import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin';
3
- import * as _xyo_network_payload_model from '@xyo-network/payload-model';
4
- import { Payload, Schema } from '@xyo-network/payload-model';
5
- import { AbstractDiviner } from '@xyo-network/diviner-abstract';
6
- import * as _xyo_network_module_model from '@xyo-network/module-model';
7
- import { AnyConfigSchema } from '@xyo-network/module-model';
8
- import * as _xyo_network_payloadset_plugin from '@xyo-network/payloadset-plugin';
9
- import * as _store__xyo_network_account_model_virtual_96c2d52d44_package from '.store/@xyo-network-account-model-virtual-96c2d52d44/package';
10
- import * as _store__xylabs_object_npm_4_0_1_bb8d73c5f0_package from '.store/@xylabs-object-npm-4.0.1-bb8d73c5f0/package';
11
-
12
- type LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config';
13
- declare const LocationCertaintyDivinerConfigSchema: LocationCertaintyDivinerConfigSchema;
14
- type LocationCertaintyDivinerConfig<TConfig extends Payload = Payload> = DivinerConfig<TConfig & {
15
- schema: LocationCertaintyDivinerConfigSchema;
16
- targetSchema?: LocationCertaintySchema;
17
- }>;
18
-
19
- type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>;
20
- declare class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams> extends AbstractDiviner<TParam> implements DivinerModule {
21
- static readonly configSchemas: Schema[];
22
- static readonly defaultConfigSchema: Schema;
23
- static targetSchema: "network.xyo.location.certainty";
24
- private static calcHeuristic;
25
- private static locationsToHeuristics;
26
- protected divineHandler(payloads?: Payload[]): Promise<Payload[]>;
27
- }
28
-
29
- declare const LocationCertaintyPlugin: () => _xyo_network_payloadset_plugin.PayloadSetDivinerPlugin<LocationCertaintyDiviner<_store__xylabs_object_npm_4_0_1_bb8d73c5f0_package.BaseParamsFields & {
30
- account?: _store__xyo_network_account_model_virtual_96c2d52d44_package.AccountInstance | "random";
31
- addToResolvers?: boolean;
32
- additionalSigners?: _store__xyo_network_account_model_virtual_96c2d52d44_package.AccountInstance[];
33
- allowNameResolution?: boolean;
34
- config: _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & _xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & Omit<_xyo_network_module_model.ArchivingModuleConfig & _xyo_network_module_model.ModuleConfigFields & {
35
- schema: "network.xyo.location.elevation.diviner.config";
36
- } & {
37
- schema: string;
38
- } & _xyo_network_payload_model.PayloadFields & {
39
- schema: LocationCertaintyDivinerConfigSchema;
40
- targetSchema?: LocationCertaintySchema;
41
- }, "schema"> & {
42
- schema: "network.xyo.location.elevation.diviner.config";
43
- }, "schema"> & {
44
- schema: string;
45
- };
46
- ephemeralQueryAccountEnabled?: boolean;
47
- moduleIdentifierTransformers?: _xyo_network_module_model.ModuleIdentifierTransformer[];
48
- }>>;
49
-
50
- export { LocationCertaintyDiviner, type LocationCertaintyDivinerConfig, LocationCertaintyDivinerConfigSchema, type LocationCertaintyDivinerParams, LocationCertaintyPlugin, LocationCertaintyPlugin as default };
1
+ export * from './Diviner/index.ts';
2
+ export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAElC,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA"}
@@ -47,7 +47,11 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractD
47
47
  prev.variance.push(altitude !== void 0 && altitude !== null ? altitude - elevation : null);
48
48
  return prev;
49
49
  },
50
- { altitude: [], elevation: [], variance: [] }
50
+ {
51
+ altitude: [],
52
+ elevation: [],
53
+ variance: []
54
+ }
51
55
  );
52
56
  return heuristics;
53
57
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner/Config.ts","../../src/Diviner/Diviner.ts","../../src/Plugin.ts"],"sourcesContent":["import { DivinerConfig } from '@xyo-network/diviner-model'\nimport { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport type LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config'\nexport const LocationCertaintyDivinerConfigSchema: LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config'\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 { DivinerModule, DivinerParams } from '@xyo-network/diviner-model'\nimport { ElevationPayload } from '@xyo-network/elevation-payload-plugin'\nimport { ElevationWitness, ElevationWitnessConfigSchema } from '@xyo-network/elevation-plugin'\nimport { LocationCertaintyHeuristic, LocationCertaintyPayload, LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'\nimport { LocationPayload, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { LocationCertaintyDivinerConfig, 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 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 : value > prev\n ? value\n : 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 : value < prev\n ? value\n : 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 { altitude: [], elevation: [], variance: [] },\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 = await 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":";AAKO,IAAM,uCAA6E;;;ACL1F,SAAS,uBAAuB;AAGhC,SAAS,kBAAkB,oCAAoC;AAC/D,SAA+D,+BAA+B;AAC9F,SAA0B,sBAAsB;AAEhD,SAAS,sBAAsB;AAOxB,IAAM,2BAAN,MAAM,kCACH,gBACiB;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AAA,EACT;AAAA;AAAA,EAGA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,YAAY,UAAU,OAAwB,CAAC,YAAwC,SAAS,WAAW,cAAc;AAE/H,QAAI,aAAa,WAAW,SAAS,GAAG;AACtC,YAAM,mBAAmB,MAAM,iBAAiB,OAAO;AAAA,QACrD,SAAS,KAAK;AAAA,QACd,QAAQ;AAAA,UACN;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AACD,YAAM,aAAc,MAAM,iBAAiB,QAAQ;AAEnD,YAAM,aAAa,0BAAyB,sBAAsB,YAAY,SAAS;AAEvF,YAAM,SAAS,MAAM,IAAI,eAAyC,EAAE,QAAQ,wBAAwB,CAAC,EAClG,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;;;AC1GA,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 type { Payload } from '@xyo-network/payload-model'\n\nexport type LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config'\nexport const LocationCertaintyDivinerConfigSchema: LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config'\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 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 : value > prev\n ? value\n : 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 : value < prev\n ? value\n : 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 = await 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":";AAKO,IAAM,uCAA6E;;;ACL1F,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,OAAgB,eAAe;AAAA;AAAA,EAG/B,OAAe,cAAc,WAA0D;AACrF,WAAO;AAAA;AAAA,MAEL,KAAK,UAAU,OAAe,CAAC,MAAM,UAAU;AAC7C,eACE,UAAU,OACN,OACA,QAAQ,OACN,QACA;AAAA,MAEV,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,CAAC;AAAA,UAC9D;AAAA,UACA,CAAC,GAAG,CAAC;AAAA,QACP;AACA,eAAO,OAAO,CAAC,IAAI,OAAO,CAAC;AAAA,MAC7B,GAAG;AA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,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;;;AC/GA,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"]}
package/package.json CHANGED
@@ -1,37 +1,24 @@
1
1
  {
2
2
  "name": "@xyo-network/location-certainty-plugin",
3
- "author": {
4
- "email": "support@xyo.network",
5
- "name": "XYO Development Team",
6
- "url": "https://xyo.network"
7
- },
3
+ "version": "3.0.4",
4
+ "description": "Typescript/Javascript Plugins for XYO Platform",
5
+ "homepage": "https://xyo.network",
8
6
  "bugs": {
9
- "email": "support@xyo.network",
10
- "url": "https://github.com/XYOracleNetwork/plugins/issues"
7
+ "url": "git+https://github.com/XYOracleNetwork/plugins/issues",
8
+ "email": "support@xyo.network"
11
9
  },
12
- "dependencies": {
13
- "@xyo-network/diviner-abstract": "^3.0.2",
14
- "@xyo-network/diviner-model": "^3.0.2",
15
- "@xyo-network/elevation-payload-plugin": "^3.0.2",
16
- "@xyo-network/elevation-plugin": "^3.0.2",
17
- "@xyo-network/location-certainty-payload-plugin": "^3.0.2",
18
- "@xyo-network/location-payload-plugin": "^3.0.2",
19
- "@xyo-network/module-model": "^3.0.2",
20
- "@xyo-network/payload-builder": "^3.0.2",
21
- "@xyo-network/payload-model": "^3.0.2",
22
- "@xyo-network/payloadset-plugin": "^3.0.2"
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/XYOracleNetwork/plugins.git"
23
13
  },
24
- "devDependencies": {
25
- "@xylabs/ts-scripts-yarn3": "^4.0.0-rc.15",
26
- "@xylabs/tsconfig": "^4.0.0-rc.15",
27
- "@xylabs/tsconfig-jest": "^4.0.0-rc.15",
28
- "@xyo-network/archivist-abstract": "^3.0.2",
29
- "@xyo-network/archivist-memory": "^3.0.2",
30
- "@xyo-network/module-resolver": "^3.0.2",
31
- "fast-text-encoding": "^1.0.6",
32
- "typescript": "^5.5.4"
14
+ "license": "LGPL-3.0-only",
15
+ "author": {
16
+ "name": "XYO Development Team",
17
+ "email": "support@xyo.network",
18
+ "url": "https://xyo.network"
33
19
  },
34
- "description": "Typescript/Javascript Plugins for XYO Platform",
20
+ "sideEffects": false,
21
+ "type": "module",
35
22
  "exports": {
36
23
  ".": {
37
24
  "types": "./dist/neutral/index.d.ts",
@@ -41,16 +28,29 @@
41
28
  },
42
29
  "module": "dist/neutral/index.mjs",
43
30
  "types": "dist/neutral/index.d.ts",
44
- "homepage": "https://xyo.network",
45
- "license": "LGPL-3.0-only",
46
- "publishConfig": {
47
- "access": "public"
31
+ "dependencies": {
32
+ "@xyo-network/diviner-abstract": "^3.0.10",
33
+ "@xyo-network/diviner-model": "^3.0.10",
34
+ "@xyo-network/elevation-payload-plugin": "^3.0.4",
35
+ "@xyo-network/elevation-plugin": "^3.0.4",
36
+ "@xyo-network/location-certainty-payload-plugin": "^3.0.4",
37
+ "@xyo-network/location-payload-plugin": "^3.0.4",
38
+ "@xyo-network/module-model": "^3.0.10",
39
+ "@xyo-network/payload-builder": "^3.0.10",
40
+ "@xyo-network/payload-model": "^3.0.10",
41
+ "@xyo-network/payloadset-plugin": "^3.0.10"
48
42
  },
49
- "repository": {
50
- "type": "git",
51
- "url": "https://github.com/XYOracleNetwork/plugins.git"
43
+ "devDependencies": {
44
+ "@xylabs/ts-scripts-yarn3": "^4.0.7",
45
+ "@xylabs/tsconfig": "^4.0.7",
46
+ "@xylabs/tsconfig-jest": "^4.0.7",
47
+ "@xyo-network/archivist-abstract": "^3.0.10",
48
+ "@xyo-network/archivist-memory": "^3.0.10",
49
+ "@xyo-network/module-resolver": "^3.0.10",
50
+ "fast-text-encoding": "^1.0.6",
51
+ "typescript": "^5.5.4"
52
52
  },
53
- "sideEffects": false,
54
- "version": "3.0.2",
55
- "type": "module"
53
+ "publishConfig": {
54
+ "access": "public"
55
+ }
56
56
  }
@@ -1,6 +1,6 @@
1
- import { DivinerConfig } from '@xyo-network/diviner-model'
2
- import { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'
3
- import { Payload } from '@xyo-network/payload-model'
1
+ import type { DivinerConfig } from '@xyo-network/diviner-model'
2
+ import type { LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'
3
+ import type { Payload } from '@xyo-network/payload-model'
4
4
 
5
5
  export type LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config'
6
6
  export const LocationCertaintyDivinerConfigSchema: LocationCertaintyDivinerConfigSchema = 'network.xyo.location.elevation.diviner.config'
@@ -1,14 +1,17 @@
1
1
  import { AbstractDiviner } from '@xyo-network/diviner-abstract'
2
- import { DivinerModule, DivinerParams } from '@xyo-network/diviner-model'
3
- import { ElevationPayload } from '@xyo-network/elevation-payload-plugin'
2
+ import type { DivinerModule, DivinerParams } from '@xyo-network/diviner-model'
3
+ import type { ElevationPayload } from '@xyo-network/elevation-payload-plugin'
4
4
  import { ElevationWitness, ElevationWitnessConfigSchema } from '@xyo-network/elevation-plugin'
5
- import { LocationCertaintyHeuristic, LocationCertaintyPayload, LocationCertaintySchema } from '@xyo-network/location-certainty-payload-plugin'
6
- import { LocationPayload, LocationSchema } from '@xyo-network/location-payload-plugin'
7
- import { AnyConfigSchema } from '@xyo-network/module-model'
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'
8
10
  import { PayloadBuilder } from '@xyo-network/payload-builder'
9
- import { Payload, Schema } from '@xyo-network/payload-model'
11
+ import type { Payload, Schema } from '@xyo-network/payload-model'
10
12
 
11
- import { LocationCertaintyDivinerConfig, LocationCertaintyDivinerConfigSchema } from './Config.ts'
13
+ import type { LocationCertaintyDivinerConfig } from './Config.ts'
14
+ import { LocationCertaintyDivinerConfigSchema } from './Config.ts'
12
15
 
13
16
  export type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>
14
17
 
@@ -70,7 +73,9 @@ export class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerPar
70
73
  prev.variance.push(altitude !== undefined && altitude !== null ? altitude - elevation : null)
71
74
  return prev
72
75
  },
73
- { altitude: [], elevation: [], variance: [] },
76
+ {
77
+ altitude: [], elevation: [], variance: [],
78
+ },
74
79
  )
75
80
  return heuristics
76
81
  }
package/xy.config.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
1
+ import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
2
  const config: XyTsupConfig = {
3
3
  compile: {
4
4
  browser: {},
5
5
  node: {},
6
- neutral: {
7
- src: true,
8
- },
6
+ neutral: { src: true },
9
7
  },
10
8
  }
11
9