@xyo-network/location-certainty-plugin 2.85.0 → 2.85.1
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/dist/browser/Diviner/Diviner.d.cts.map +1 -1
- package/dist/browser/Diviner/Diviner.d.mts.map +1 -1
- package/dist/browser/Diviner/Diviner.d.ts.map +1 -1
- package/dist/browser/Plugin.d.cts +0 -2
- package/dist/browser/Plugin.d.cts.map +1 -1
- package/dist/browser/Plugin.d.mts +0 -2
- package/dist/browser/Plugin.d.mts.map +1 -1
- package/dist/browser/Plugin.d.ts +0 -2
- package/dist/browser/Plugin.d.ts.map +1 -1
- package/dist/browser/index.cjs +12 -15
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -3
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -3
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -3
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +12 -15
- package/dist/browser/index.js.map +1 -1
- package/dist/node/Diviner/Diviner.d.cts.map +1 -1
- package/dist/node/Diviner/Diviner.d.mts.map +1 -1
- package/dist/node/Diviner/Diviner.d.ts.map +1 -1
- package/dist/node/Plugin.d.cts +0 -2
- package/dist/node/Plugin.d.cts.map +1 -1
- package/dist/node/Plugin.d.mts +0 -2
- package/dist/node/Plugin.d.mts.map +1 -1
- package/dist/node/Plugin.d.ts +0 -2
- package/dist/node/Plugin.d.ts.map +1 -1
- package/dist/node/index.cjs +12 -15
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -3
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -3
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -3
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +12 -15
- package/dist/node/index.js.map +1 -1
- package/package.json +13 -13
- package/src/Diviner/Diviner.ts +10 -6
- package/src/index.ts +1 -7
|
@@ -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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,8BAA8B,EAAwC,MAAM,UAAU,CAAA;AAE/F,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;IAExB,OAAgB,aAAa,oDAAyC;IACtE,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;
|
|
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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,8BAA8B,EAAwC,MAAM,UAAU,CAAA;AAE/F,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;IAExB,OAAgB,aAAa,oDAAyC;IACtE,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;IAwB5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAmBpC,wHAAwH;cAC/F,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA4BjF"}
|
|
@@ -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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,8BAA8B,EAAwC,MAAM,UAAU,CAAA;AAE/F,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;IAExB,OAAgB,aAAa,oDAAyC;IACtE,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;
|
|
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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA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["../../../src/Diviner/Diviner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,8BAA8B,EAAwC,MAAM,UAAU,CAAA;AAE/F,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;IAExB,OAAgB,aAAa,oDAAyC;IACtE,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;IAwB5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAmBpC,wHAAwH;cAC/F,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA4BjF"}
|
|
@@ -2,7 +2,6 @@ import { LocationCertaintyDiviner } from './Diviner';
|
|
|
2
2
|
export declare const LocationCertaintyPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDivinerPlugin<LocationCertaintyDiviner<import("@xyo-network/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
4
4
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
5
|
-
accountPath?: string | undefined;
|
|
6
5
|
readonly archivist?: string | undefined;
|
|
7
6
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
8
7
|
readonly name?: string | undefined;
|
|
@@ -19,7 +18,6 @@ export declare const LocationCertaintyPlugin: () => import("@xyo-network/payload
|
|
|
19
18
|
readonly storeQueries?: boolean | undefined;
|
|
20
19
|
readonly timestamp?: boolean | undefined;
|
|
21
20
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
22
|
-
accountPath?: string | undefined;
|
|
23
21
|
readonly archivist?: string | undefined;
|
|
24
22
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
25
23
|
readonly name?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQjC,CAAA"}
|
|
@@ -2,7 +2,6 @@ import { LocationCertaintyDiviner } from './Diviner';
|
|
|
2
2
|
export declare const LocationCertaintyPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDivinerPlugin<LocationCertaintyDiviner<import("@xyo-network/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
4
4
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
5
|
-
accountPath?: string | undefined;
|
|
6
5
|
readonly archivist?: string | undefined;
|
|
7
6
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
8
7
|
readonly name?: string | undefined;
|
|
@@ -19,7 +18,6 @@ export declare const LocationCertaintyPlugin: () => import("@xyo-network/payload
|
|
|
19
18
|
readonly storeQueries?: boolean | undefined;
|
|
20
19
|
readonly timestamp?: boolean | undefined;
|
|
21
20
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
22
|
-
accountPath?: string | undefined;
|
|
23
21
|
readonly archivist?: string | undefined;
|
|
24
22
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
25
23
|
readonly name?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQjC,CAAA"}
|
package/dist/browser/Plugin.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { LocationCertaintyDiviner } from './Diviner';
|
|
|
2
2
|
export declare const LocationCertaintyPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDivinerPlugin<LocationCertaintyDiviner<import("@xyo-network/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
4
4
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
5
|
-
accountPath?: string | undefined;
|
|
6
5
|
readonly archivist?: string | undefined;
|
|
7
6
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
8
7
|
readonly name?: string | undefined;
|
|
@@ -19,7 +18,6 @@ export declare const LocationCertaintyPlugin: () => import("@xyo-network/payload
|
|
|
19
18
|
readonly storeQueries?: boolean | undefined;
|
|
20
19
|
readonly timestamp?: boolean | undefined;
|
|
21
20
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
22
|
-
accountPath?: string | undefined;
|
|
23
21
|
readonly archivist?: string | undefined;
|
|
24
22
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
25
23
|
readonly name?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQjC,CAAA"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -23,15 +23,10 @@ __export(src_exports, {
|
|
|
23
23
|
LocationCertaintyDiviner: () => LocationCertaintyDiviner,
|
|
24
24
|
LocationCertaintyDivinerConfigSchema: () => LocationCertaintyDivinerConfigSchema,
|
|
25
25
|
LocationCertaintyPlugin: () => LocationCertaintyPlugin,
|
|
26
|
-
default: () =>
|
|
26
|
+
default: () => LocationCertaintyPlugin
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(src_exports);
|
|
29
29
|
|
|
30
|
-
// src/Plugin.ts
|
|
31
|
-
var import_location_certainty_payload_plugin2 = require("@xyo-network/location-certainty-payload-plugin");
|
|
32
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
|
33
|
-
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
34
|
-
|
|
35
30
|
// src/Diviner/Config.ts
|
|
36
31
|
var LocationCertaintyDivinerConfigSchema = "network.xyo.location.elevation.diviner.config";
|
|
37
32
|
|
|
@@ -47,21 +42,23 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends import_ab
|
|
|
47
42
|
/* Given an array of numbers, find the min/max/mean */
|
|
48
43
|
static calcHeuristic(heuristic) {
|
|
49
44
|
return {
|
|
45
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
50
46
|
max: heuristic.reduce((prev, value) => {
|
|
51
|
-
return value
|
|
52
|
-
},
|
|
47
|
+
return value === null ? prev : value > prev ? value : prev;
|
|
48
|
+
}, Number.NEGATIVE_INFINITY),
|
|
53
49
|
mean: (() => {
|
|
54
50
|
const values = heuristic.reduce(
|
|
55
51
|
(prev, value) => {
|
|
56
|
-
return value
|
|
52
|
+
return value === null ? prev : [value + prev[0], prev[1] + 1];
|
|
57
53
|
},
|
|
58
54
|
[0, 0]
|
|
59
55
|
);
|
|
60
56
|
return values[0] / values[1];
|
|
61
57
|
})(),
|
|
58
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
62
59
|
min: heuristic.reduce((prev, value) => {
|
|
63
|
-
return value
|
|
64
|
-
},
|
|
60
|
+
return value === null ? prev : value < prev ? value : prev;
|
|
61
|
+
}, Number.POSITIVE_INFINITY)
|
|
65
62
|
};
|
|
66
63
|
}
|
|
67
64
|
/* Given elevation and location payloads, generate heuristic arrays */
|
|
@@ -70,7 +67,7 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends import_ab
|
|
|
70
67
|
(prev, elev, index) => {
|
|
71
68
|
const elevation = elev.elevation;
|
|
72
69
|
if (elevation === void 0 || elevation === null) {
|
|
73
|
-
throw Error("Invalid Elevation");
|
|
70
|
+
throw new Error("Invalid Elevation");
|
|
74
71
|
}
|
|
75
72
|
const altitude = locations[index].altitude;
|
|
76
73
|
prev.altitude.push(altitude ?? null);
|
|
@@ -108,6 +105,9 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends import_ab
|
|
|
108
105
|
};
|
|
109
106
|
|
|
110
107
|
// src/Plugin.ts
|
|
108
|
+
var import_location_certainty_payload_plugin2 = require("@xyo-network/location-certainty-payload-plugin");
|
|
109
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
110
|
+
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
111
111
|
var LocationCertaintyPlugin = () => (0, import_payloadset_plugin.createPayloadSetDivinerPlugin)(
|
|
112
112
|
{ required: { [import_location_certainty_payload_plugin2.LocationCertaintySchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
|
|
113
113
|
{
|
|
@@ -116,7 +116,4 @@ var LocationCertaintyPlugin = () => (0, import_payloadset_plugin.createPayloadSe
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
);
|
|
119
|
-
|
|
120
|
-
// src/index.ts
|
|
121
|
-
var src_default = LocationCertaintyPlugin;
|
|
122
119
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Diviner/Config.ts","../../src/Diviner/Diviner.ts","../../src/Plugin.ts"],"sourcesContent":["export * from './Diviner'\nexport { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin'\n","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/abstract-diviner'\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 } from '@xyo-network/payload-model'\n\nimport { LocationCertaintyDivinerConfig, LocationCertaintyDivinerConfigSchema } from './Config'\n\nexport type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>\n\nexport class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams>\n extends AbstractDiviner<TParam>\n implements DivinerModule\n{\n static override configSchemas = [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 value === null ? prev : value > prev ? value : prev\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 value === null ? prev : value < prev ? value : prev\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'\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,uCAA6E;;;ACL1F,8BAAgC;AAGhC,8BAA+D;AAC/D,+CAA8F;AAC9F,qCAAgD;AAEhD,6BAA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ACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAyB,cAAc,UAA0C;AAC/E,UAAM,YAAY,UAAU,OAAwB,CAAC,YAAwC,SAAS,WAAW,6CAAc;AAE/H,QAAI,aAAa,WAAW,SAAS,GAAG;AACtC,YAAM,mBAAmB,MAAM,yCAAiB,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,sCAAyC,EAAE,QAAQ,iEAAwB,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;;;AC9FA,IAAAA,4CAAwC;AACxC,2BAAiC;AACjC,+BAA8C;AAIvC,IAAM,0BAA0B,UACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,iEAAuB,GAAG,EAAE,GAAG,QAAQ,sCAAiB;AAAA,EACvE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAQ,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACtD;AAAA,EACF;AACF;","names":["import_location_certainty_payload_plugin"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { LocationCertaintyPlugin } from './Plugin';
|
|
2
1
|
export * from './Diviner';
|
|
3
|
-
export { LocationCertaintyPlugin };
|
|
4
|
-
export default LocationCertaintyPlugin;
|
|
2
|
+
export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { LocationCertaintyPlugin } from './Plugin';
|
|
2
1
|
export * from './Diviner';
|
|
3
|
-
export { LocationCertaintyPlugin };
|
|
4
|
-
export default LocationCertaintyPlugin;
|
|
2
|
+
export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { LocationCertaintyPlugin } from './Plugin';
|
|
2
1
|
export * from './Diviner';
|
|
3
|
-
export { LocationCertaintyPlugin };
|
|
4
|
-
export default LocationCertaintyPlugin;
|
|
2
|
+
export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// src/Plugin.ts
|
|
2
|
-
import { LocationCertaintySchema as LocationCertaintySchema2 } from "@xyo-network/location-certainty-payload-plugin";
|
|
3
|
-
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
4
|
-
import { createPayloadSetDivinerPlugin } from "@xyo-network/payloadset-plugin";
|
|
5
|
-
|
|
6
1
|
// src/Diviner/Config.ts
|
|
7
2
|
var LocationCertaintyDivinerConfigSchema = "network.xyo.location.elevation.diviner.config";
|
|
8
3
|
|
|
@@ -18,21 +13,23 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractD
|
|
|
18
13
|
/* Given an array of numbers, find the min/max/mean */
|
|
19
14
|
static calcHeuristic(heuristic) {
|
|
20
15
|
return {
|
|
16
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
21
17
|
max: heuristic.reduce((prev, value) => {
|
|
22
|
-
return value
|
|
23
|
-
},
|
|
18
|
+
return value === null ? prev : value > prev ? value : prev;
|
|
19
|
+
}, Number.NEGATIVE_INFINITY),
|
|
24
20
|
mean: (() => {
|
|
25
21
|
const values = heuristic.reduce(
|
|
26
22
|
(prev, value) => {
|
|
27
|
-
return value
|
|
23
|
+
return value === null ? prev : [value + prev[0], prev[1] + 1];
|
|
28
24
|
},
|
|
29
25
|
[0, 0]
|
|
30
26
|
);
|
|
31
27
|
return values[0] / values[1];
|
|
32
28
|
})(),
|
|
29
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
33
30
|
min: heuristic.reduce((prev, value) => {
|
|
34
|
-
return value
|
|
35
|
-
},
|
|
31
|
+
return value === null ? prev : value < prev ? value : prev;
|
|
32
|
+
}, Number.POSITIVE_INFINITY)
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
/* Given elevation and location payloads, generate heuristic arrays */
|
|
@@ -41,7 +38,7 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractD
|
|
|
41
38
|
(prev, elev, index) => {
|
|
42
39
|
const elevation = elev.elevation;
|
|
43
40
|
if (elevation === void 0 || elevation === null) {
|
|
44
|
-
throw Error("Invalid Elevation");
|
|
41
|
+
throw new Error("Invalid Elevation");
|
|
45
42
|
}
|
|
46
43
|
const altitude = locations[index].altitude;
|
|
47
44
|
prev.altitude.push(altitude ?? null);
|
|
@@ -79,6 +76,9 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractD
|
|
|
79
76
|
};
|
|
80
77
|
|
|
81
78
|
// src/Plugin.ts
|
|
79
|
+
import { LocationCertaintySchema as LocationCertaintySchema2 } from "@xyo-network/location-certainty-payload-plugin";
|
|
80
|
+
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
81
|
+
import { createPayloadSetDivinerPlugin } from "@xyo-network/payloadset-plugin";
|
|
82
82
|
var LocationCertaintyPlugin = () => createPayloadSetDivinerPlugin(
|
|
83
83
|
{ required: { [LocationCertaintySchema2]: 1 }, schema: PayloadSetSchema },
|
|
84
84
|
{
|
|
@@ -87,13 +87,10 @@ var LocationCertaintyPlugin = () => createPayloadSetDivinerPlugin(
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
|
-
|
|
91
|
-
// src/index.ts
|
|
92
|
-
var src_default = LocationCertaintyPlugin;
|
|
93
90
|
export {
|
|
94
91
|
LocationCertaintyDiviner,
|
|
95
92
|
LocationCertaintyDivinerConfigSchema,
|
|
96
93
|
LocationCertaintyPlugin,
|
|
97
|
-
|
|
94
|
+
LocationCertaintyPlugin as default
|
|
98
95
|
};
|
|
99
96
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
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/abstract-diviner'\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 } from '@xyo-network/payload-model'\n\nimport { LocationCertaintyDivinerConfig, LocationCertaintyDivinerConfigSchema } from './Config'\n\nexport type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>\n\nexport class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams>\n extends AbstractDiviner<TParam>\n implements DivinerModule\n{\n static override configSchemas = [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 value === null ? prev : value > prev ? value : prev\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 value === null ? prev : value < prev ? value : prev\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'\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,gBAEV;AAAA,EACE,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EACrE,OAAgB,eAAe;AAAA;AAAA,EAG/B,OAAe,cAAc,WAA0D;AACrF,WAAO;AAAA;AAAA,MAEL,KAAK,UAAU,OAAe,CAAC,MAAM,UAAU;AAC7C,eAAO,UAAU,OAAO,OAAO,QAAQ,OAAO,QAAQ;AAAA,MACxD,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,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E,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;;;AC9FA,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 +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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,8BAA8B,EAAwC,MAAM,UAAU,CAAA;AAE/F,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;IAExB,OAAgB,aAAa,oDAAyC;IACtE,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/Diviner/Diviner.ts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SAAS,8BAA8B,GAAG,8BAA8B,CAClH,SAAQ,eAAe,CAAC,MAAM,CAC9B,YAAW,aAAa;IAExB,OAAgB,aAAa,oDAAyC;IACtE,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;
|
|
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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,8BAA8B,EAAwC,MAAM,UAAU,CAAA;AAE/F,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;IAExB,OAAgB,aAAa,oDAAyC;IACtE,OAAgB,YAAY,mCAA0B;IAGtD,OAAO,CAAC,MAAM,CAAC,aAAa;IAwB5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAmBpC,wHAAwH;cAC/F,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA4BjF"}
|
|
@@ -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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,eAAe,EAAE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node/Plugin.d.cts
CHANGED
|
@@ -2,7 +2,6 @@ import { LocationCertaintyDiviner } from './Diviner';
|
|
|
2
2
|
export declare const LocationCertaintyPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDivinerPlugin<LocationCertaintyDiviner<import("@xyo-network/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
4
4
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
5
|
-
accountPath?: string | undefined;
|
|
6
5
|
readonly archivist?: string | undefined;
|
|
7
6
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
8
7
|
readonly name?: string | undefined;
|
|
@@ -19,7 +18,6 @@ export declare const LocationCertaintyPlugin: () => import("@xyo-network/payload
|
|
|
19
18
|
readonly storeQueries?: boolean | undefined;
|
|
20
19
|
readonly timestamp?: boolean | undefined;
|
|
21
20
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
22
|
-
accountPath?: string | undefined;
|
|
23
21
|
readonly archivist?: string | undefined;
|
|
24
22
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
25
23
|
readonly name?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQjC,CAAA"}
|
package/dist/node/Plugin.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { LocationCertaintyDiviner } from './Diviner';
|
|
|
2
2
|
export declare const LocationCertaintyPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDivinerPlugin<LocationCertaintyDiviner<import("@xyo-network/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
4
4
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
5
|
-
accountPath?: string | undefined;
|
|
6
5
|
readonly archivist?: string | undefined;
|
|
7
6
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
8
7
|
readonly name?: string | undefined;
|
|
@@ -19,7 +18,6 @@ export declare const LocationCertaintyPlugin: () => import("@xyo-network/payload
|
|
|
19
18
|
readonly storeQueries?: boolean | undefined;
|
|
20
19
|
readonly timestamp?: boolean | undefined;
|
|
21
20
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
22
|
-
accountPath?: string | undefined;
|
|
23
21
|
readonly archivist?: string | undefined;
|
|
24
22
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
25
23
|
readonly name?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQjC,CAAA"}
|
package/dist/node/Plugin.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { LocationCertaintyDiviner } from './Diviner';
|
|
|
2
2
|
export declare const LocationCertaintyPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetDivinerPlugin<LocationCertaintyDiviner<import("@xyo-network/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
4
4
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
5
|
-
accountPath?: string | undefined;
|
|
6
5
|
readonly archivist?: string | undefined;
|
|
7
6
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
8
7
|
readonly name?: string | undefined;
|
|
@@ -19,7 +18,6 @@ export declare const LocationCertaintyPlugin: () => import("@xyo-network/payload
|
|
|
19
18
|
readonly storeQueries?: boolean | undefined;
|
|
20
19
|
readonly timestamp?: boolean | undefined;
|
|
21
20
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
22
|
-
accountPath?: string | undefined;
|
|
23
21
|
readonly archivist?: string | undefined;
|
|
24
22
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
25
23
|
readonly name?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAEpD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQjC,CAAA"}
|
package/dist/node/index.cjs
CHANGED
|
@@ -23,15 +23,10 @@ __export(src_exports, {
|
|
|
23
23
|
LocationCertaintyDiviner: () => LocationCertaintyDiviner,
|
|
24
24
|
LocationCertaintyDivinerConfigSchema: () => LocationCertaintyDivinerConfigSchema,
|
|
25
25
|
LocationCertaintyPlugin: () => LocationCertaintyPlugin,
|
|
26
|
-
default: () =>
|
|
26
|
+
default: () => LocationCertaintyPlugin
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(src_exports);
|
|
29
29
|
|
|
30
|
-
// src/Plugin.ts
|
|
31
|
-
var import_location_certainty_payload_plugin2 = require("@xyo-network/location-certainty-payload-plugin");
|
|
32
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
|
33
|
-
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
34
|
-
|
|
35
30
|
// src/Diviner/Config.ts
|
|
36
31
|
var LocationCertaintyDivinerConfigSchema = "network.xyo.location.elevation.diviner.config";
|
|
37
32
|
|
|
@@ -47,21 +42,23 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends import_ab
|
|
|
47
42
|
/* Given an array of numbers, find the min/max/mean */
|
|
48
43
|
static calcHeuristic(heuristic) {
|
|
49
44
|
return {
|
|
45
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
50
46
|
max: heuristic.reduce((prev, value) => {
|
|
51
|
-
return value
|
|
52
|
-
},
|
|
47
|
+
return value === null ? prev : value > prev ? value : prev;
|
|
48
|
+
}, Number.NEGATIVE_INFINITY),
|
|
53
49
|
mean: (() => {
|
|
54
50
|
const values = heuristic.reduce(
|
|
55
51
|
(prev, value) => {
|
|
56
|
-
return value
|
|
52
|
+
return value === null ? prev : [value + prev[0], prev[1] + 1];
|
|
57
53
|
},
|
|
58
54
|
[0, 0]
|
|
59
55
|
);
|
|
60
56
|
return values[0] / values[1];
|
|
61
57
|
})(),
|
|
58
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
62
59
|
min: heuristic.reduce((prev, value) => {
|
|
63
|
-
return value
|
|
64
|
-
},
|
|
60
|
+
return value === null ? prev : value < prev ? value : prev;
|
|
61
|
+
}, Number.POSITIVE_INFINITY)
|
|
65
62
|
};
|
|
66
63
|
}
|
|
67
64
|
/* Given elevation and location payloads, generate heuristic arrays */
|
|
@@ -70,7 +67,7 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends import_ab
|
|
|
70
67
|
(prev, elev, index) => {
|
|
71
68
|
const elevation = elev.elevation;
|
|
72
69
|
if (elevation === void 0 || elevation === null) {
|
|
73
|
-
throw Error("Invalid Elevation");
|
|
70
|
+
throw new Error("Invalid Elevation");
|
|
74
71
|
}
|
|
75
72
|
const altitude = locations[index].altitude;
|
|
76
73
|
prev.altitude.push(altitude ?? null);
|
|
@@ -109,6 +106,9 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends import_ab
|
|
|
109
106
|
};
|
|
110
107
|
|
|
111
108
|
// src/Plugin.ts
|
|
109
|
+
var import_location_certainty_payload_plugin2 = require("@xyo-network/location-certainty-payload-plugin");
|
|
110
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
111
|
+
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
112
112
|
var LocationCertaintyPlugin = () => (0, import_payloadset_plugin.createPayloadSetDivinerPlugin)(
|
|
113
113
|
{ required: { [import_location_certainty_payload_plugin2.LocationCertaintySchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
|
|
114
114
|
{
|
|
@@ -117,9 +117,6 @@ var LocationCertaintyPlugin = () => (0, import_payloadset_plugin.createPayloadSe
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
);
|
|
120
|
-
|
|
121
|
-
// src/index.ts
|
|
122
|
-
var src_default = LocationCertaintyPlugin;
|
|
123
120
|
// Annotate the CommonJS export names for ESM import in node:
|
|
124
121
|
0 && (module.exports = {
|
|
125
122
|
LocationCertaintyDiviner,
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Diviner/Config.ts","../../src/Diviner/Diviner.ts","../../src/Plugin.ts"],"sourcesContent":["export * from './Diviner'\nexport { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin'\n","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/abstract-diviner'\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 } from '@xyo-network/payload-model'\n\nimport { LocationCertaintyDivinerConfig, LocationCertaintyDivinerConfigSchema } from './Config'\n\nexport type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>\n\nexport class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams>\n extends AbstractDiviner<TParam>\n implements DivinerModule\n{\n static override configSchemas = [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 value === null ? prev : value > prev ? value : prev\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 value === null ? prev : value < prev ? value : prev\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'\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,uCAA6E;;;ACL1F,8BAAgC;AAGhC,8BAA+D;AAC/D,+CAA8F;AAC9F,qCAAgD;AAEhD,6BAA+B;AAOxB,IAAM,2BAAN,MAAM,kCACH,wCAEV;AAAA,EACE,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EACrE,OAAgB,eAAe;AAAA;AAAA,EAG/B,OAAe,cAAc,WAA0D;AACrF,WAAO;AAAA;AAAA,MAEL,KAAK,UAAU,OAAe,CAAC,MAAM,UAAU;AAC7C,eAAO,UAAU,OAAO,OAAO,QAAQ,OAAO,QAAQ;AAAA,MACxD,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;AAAA;AAAA,MAEH,KAAK,UAAU,OAAe,CAAC,MAAM,UA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A,MAAM;AAET,iBAAK,WAAL,mBAAa,IAAI;AACjB,aAAO,CAAC,MAAM;AAAA,IAChB;AACA,WAAO,CAAC;AAAA,EACV;AACF;;;AC9FA,IAAAA,4CAAwC;AACxC,2BAAiC;AACjC,+BAA8C;AAIvC,IAAM,0BAA0B,UACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,iEAAuB,GAAG,EAAE,GAAG,QAAQ,sCAAiB;AAAA,EACvE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAQ,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACtD;AAAA,EACF;AACF;","names":["import_location_certainty_payload_plugin"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { LocationCertaintyPlugin } from './Plugin';
|
|
2
1
|
export * from './Diviner';
|
|
3
|
-
export { LocationCertaintyPlugin };
|
|
4
|
-
export default LocationCertaintyPlugin;
|
|
2
|
+
export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { LocationCertaintyPlugin } from './Plugin';
|
|
2
1
|
export * from './Diviner';
|
|
3
|
-
export { LocationCertaintyPlugin };
|
|
4
|
-
export default LocationCertaintyPlugin;
|
|
2
|
+
export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { LocationCertaintyPlugin } from './Plugin';
|
|
2
1
|
export * from './Diviner';
|
|
3
|
-
export { LocationCertaintyPlugin };
|
|
4
|
-
export default LocationCertaintyPlugin;
|
|
2
|
+
export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// src/Plugin.ts
|
|
2
|
-
import { LocationCertaintySchema as LocationCertaintySchema2 } from "@xyo-network/location-certainty-payload-plugin";
|
|
3
|
-
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
4
|
-
import { createPayloadSetDivinerPlugin } from "@xyo-network/payloadset-plugin";
|
|
5
|
-
|
|
6
1
|
// src/Diviner/Config.ts
|
|
7
2
|
var LocationCertaintyDivinerConfigSchema = "network.xyo.location.elevation.diviner.config";
|
|
8
3
|
|
|
@@ -18,21 +13,23 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractD
|
|
|
18
13
|
/* Given an array of numbers, find the min/max/mean */
|
|
19
14
|
static calcHeuristic(heuristic) {
|
|
20
15
|
return {
|
|
16
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
21
17
|
max: heuristic.reduce((prev, value) => {
|
|
22
|
-
return value
|
|
23
|
-
},
|
|
18
|
+
return value === null ? prev : value > prev ? value : prev;
|
|
19
|
+
}, Number.NEGATIVE_INFINITY),
|
|
24
20
|
mean: (() => {
|
|
25
21
|
const values = heuristic.reduce(
|
|
26
22
|
(prev, value) => {
|
|
27
|
-
return value
|
|
23
|
+
return value === null ? prev : [value + prev[0], prev[1] + 1];
|
|
28
24
|
},
|
|
29
25
|
[0, 0]
|
|
30
26
|
);
|
|
31
27
|
return values[0] / values[1];
|
|
32
28
|
})(),
|
|
29
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
33
30
|
min: heuristic.reduce((prev, value) => {
|
|
34
|
-
return value
|
|
35
|
-
},
|
|
31
|
+
return value === null ? prev : value < prev ? value : prev;
|
|
32
|
+
}, Number.POSITIVE_INFINITY)
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
/* Given elevation and location payloads, generate heuristic arrays */
|
|
@@ -41,7 +38,7 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractD
|
|
|
41
38
|
(prev, elev, index) => {
|
|
42
39
|
const elevation = elev.elevation;
|
|
43
40
|
if (elevation === void 0 || elevation === null) {
|
|
44
|
-
throw Error("Invalid Elevation");
|
|
41
|
+
throw new Error("Invalid Elevation");
|
|
45
42
|
}
|
|
46
43
|
const altitude = locations[index].altitude;
|
|
47
44
|
prev.altitude.push(altitude ?? null);
|
|
@@ -80,6 +77,9 @@ var LocationCertaintyDiviner = class _LocationCertaintyDiviner extends AbstractD
|
|
|
80
77
|
};
|
|
81
78
|
|
|
82
79
|
// src/Plugin.ts
|
|
80
|
+
import { LocationCertaintySchema as LocationCertaintySchema2 } from "@xyo-network/location-certainty-payload-plugin";
|
|
81
|
+
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
82
|
+
import { createPayloadSetDivinerPlugin } from "@xyo-network/payloadset-plugin";
|
|
83
83
|
var LocationCertaintyPlugin = () => createPayloadSetDivinerPlugin(
|
|
84
84
|
{ required: { [LocationCertaintySchema2]: 1 }, schema: PayloadSetSchema },
|
|
85
85
|
{
|
|
@@ -88,13 +88,10 @@ var LocationCertaintyPlugin = () => createPayloadSetDivinerPlugin(
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
|
|
92
|
-
// src/index.ts
|
|
93
|
-
var src_default = LocationCertaintyPlugin;
|
|
94
91
|
export {
|
|
95
92
|
LocationCertaintyDiviner,
|
|
96
93
|
LocationCertaintyDivinerConfigSchema,
|
|
97
94
|
LocationCertaintyPlugin,
|
|
98
|
-
|
|
95
|
+
LocationCertaintyPlugin as default
|
|
99
96
|
};
|
|
100
97
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
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/abstract-diviner'\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 } from '@xyo-network/payload-model'\n\nimport { LocationCertaintyDivinerConfig, LocationCertaintyDivinerConfigSchema } from './Config'\n\nexport type LocationCertaintyDivinerParams = DivinerParams<AnyConfigSchema<LocationCertaintyDivinerConfig>>\n\nexport class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerParams = LocationCertaintyDivinerParams>\n extends AbstractDiviner<TParam>\n implements DivinerModule\n{\n static override configSchemas = [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 value === null ? prev : value > prev ? value : prev\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 value === null ? prev : value < prev ? value : prev\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'\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;AAG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MACT;AAAA,MACA,EAAE,UAAU,CAAC,GAAG,WAAW,CAAC,GAAG,UAAU,CAAC,EAAE;AAAA,IAC9C;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAyB,cAAc,UAA0C;AAlEnF;AAmEI,UAAM,YAAY,qCAAU,OAAwB,CAAC,aAAwC,mCAAS,YAAW;AAEjH,QAAI,cAAa,uCAAW,UAAS,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,iBAAK,WAAL,mBAAa,IAAI;AACjB,aAAO,CAAC,MAAM;AAAA,IAChB;AACA,WAAO,CAAC;AAAA,EACV;AACF;;;AC9FA,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
|
@@ -10,23 +10,23 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/plugins/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xyo-network/abstract-diviner": "^2.85.
|
|
14
|
-
"@xyo-network/diviner-model": "^2.85.
|
|
15
|
-
"@xyo-network/elevation-payload-plugin": "~2.85.
|
|
16
|
-
"@xyo-network/elevation-plugin": "~2.85.
|
|
17
|
-
"@xyo-network/location-certainty-payload-plugin": "~2.85.
|
|
18
|
-
"@xyo-network/location-payload-plugin": "~2.85.
|
|
19
|
-
"@xyo-network/module-model": "^2.85.
|
|
20
|
-
"@xyo-network/payload-builder": "^2.85.
|
|
21
|
-
"@xyo-network/payload-model": "^2.85.
|
|
22
|
-
"@xyo-network/payloadset-plugin": "^2.85.
|
|
13
|
+
"@xyo-network/abstract-diviner": "^2.85.3",
|
|
14
|
+
"@xyo-network/diviner-model": "^2.85.3",
|
|
15
|
+
"@xyo-network/elevation-payload-plugin": "~2.85.1",
|
|
16
|
+
"@xyo-network/elevation-plugin": "~2.85.1",
|
|
17
|
+
"@xyo-network/location-certainty-payload-plugin": "~2.85.1",
|
|
18
|
+
"@xyo-network/location-payload-plugin": "~2.85.1",
|
|
19
|
+
"@xyo-network/module-model": "^2.85.3",
|
|
20
|
+
"@xyo-network/payload-builder": "^2.85.3",
|
|
21
|
+
"@xyo-network/payload-model": "^2.85.3",
|
|
22
|
+
"@xyo-network/payloadset-plugin": "^2.85.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@xylabs/ts-scripts-yarn3": "^3.2.25",
|
|
26
26
|
"@xylabs/tsconfig": "^3.2.25",
|
|
27
27
|
"@xylabs/tsconfig-jest": "^3.2.25",
|
|
28
|
-
"@xyo-network/archivist": "^2.85.
|
|
29
|
-
"@xyo-network/module-resolver": "^2.85.
|
|
28
|
+
"@xyo-network/archivist": "^2.85.3",
|
|
29
|
+
"@xyo-network/module-resolver": "^2.85.3",
|
|
30
30
|
"typescript": "^5.3.3"
|
|
31
31
|
},
|
|
32
32
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
69
69
|
},
|
|
70
70
|
"sideEffects": false,
|
|
71
|
-
"version": "2.85.
|
|
71
|
+
"version": "2.85.1",
|
|
72
72
|
"type": "module"
|
|
73
73
|
}
|
package/src/Diviner/Diviner.ts
CHANGED
|
@@ -22,31 +22,35 @@ export class LocationCertaintyDiviner<TParam extends LocationCertaintyDivinerPar
|
|
|
22
22
|
/* Given an array of numbers, find the min/max/mean */
|
|
23
23
|
private static calcHeuristic(heuristic: (number | null)[]): LocationCertaintyHeuristic {
|
|
24
24
|
return {
|
|
25
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
25
26
|
max: heuristic.reduce<number>((prev, value) => {
|
|
26
|
-
return value
|
|
27
|
-
},
|
|
27
|
+
return value === null ? prev : value > prev ? value : prev
|
|
28
|
+
}, Number.NEGATIVE_INFINITY),
|
|
28
29
|
mean: (() => {
|
|
30
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
29
31
|
const values = heuristic.reduce<number[]>(
|
|
30
32
|
(prev, value) => {
|
|
31
|
-
return value
|
|
33
|
+
return value === null ? prev : [value + prev[0], prev[1] + 1]
|
|
32
34
|
},
|
|
33
35
|
[0, 0],
|
|
34
36
|
)
|
|
35
37
|
return values[0] / values[1]
|
|
36
38
|
})(),
|
|
39
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
37
40
|
min: heuristic.reduce<number>((prev, value) => {
|
|
38
|
-
return value
|
|
39
|
-
},
|
|
41
|
+
return value === null ? prev : value < prev ? value : prev
|
|
42
|
+
}, Number.POSITIVE_INFINITY),
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
/* Given elevation and location payloads, generate heuristic arrays */
|
|
44
47
|
private static locationsToHeuristics(elevations: ElevationPayload[], locations: LocationPayload[]) {
|
|
48
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
45
49
|
const heuristics = elevations.reduce<{ altitude: (number | null)[]; elevation: number[]; variance: (number | null)[] }>(
|
|
46
50
|
(prev, elev, index) => {
|
|
47
51
|
const elevation = elev.elevation
|
|
48
52
|
if (elevation === undefined || elevation === null) {
|
|
49
|
-
throw Error('Invalid Elevation')
|
|
53
|
+
throw new Error('Invalid Elevation')
|
|
50
54
|
}
|
|
51
55
|
const altitude = locations[index].altitude
|
|
52
56
|
prev.altitude.push(altitude ?? null)
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { LocationCertaintyPlugin } from './Plugin'
|
|
2
|
-
|
|
3
1
|
export * from './Diviner'
|
|
4
|
-
|
|
5
|
-
export { LocationCertaintyPlugin }
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line import/no-default-export
|
|
8
|
-
export default LocationCertaintyPlugin
|
|
2
|
+
export { LocationCertaintyPlugin as default, LocationCertaintyPlugin } from './Plugin'
|