@xyo-network/diviner-forecasting-memory 2.73.2 → 2.73.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.
- package/dist/docs.json +30 -30
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/MemoryForecastingDiviner.ts +3 -2
package/dist/docs.json
CHANGED
|
@@ -1725,7 +1725,7 @@
|
|
|
1725
1725
|
"type": {
|
|
1726
1726
|
"type": "reference",
|
|
1727
1727
|
"target": {
|
|
1728
|
-
"sourceFileName": "../../../../../../../protocol/packages/account/packages/wallet-model/
|
|
1728
|
+
"sourceFileName": "../../../../../../../protocol/packages/account/packages/wallet-model/dist/index.d.ts",
|
|
1729
1729
|
"qualifiedName": "WalletInstance"
|
|
1730
1730
|
},
|
|
1731
1731
|
"name": "WalletInstance",
|
|
@@ -3434,7 +3434,7 @@
|
|
|
3434
3434
|
"type": {
|
|
3435
3435
|
"type": "reference",
|
|
3436
3436
|
"target": {
|
|
3437
|
-
"sourceFileName": "../../../../../../../protocol/packages/account/packages/wallet-model/
|
|
3437
|
+
"sourceFileName": "../../../../../../../protocol/packages/account/packages/wallet-model/dist/index.d.ts",
|
|
3438
3438
|
"qualifiedName": "WalletInstance"
|
|
3439
3439
|
},
|
|
3440
3440
|
"name": "WalletInstance",
|
|
@@ -3822,9 +3822,9 @@
|
|
|
3822
3822
|
"sources": [
|
|
3823
3823
|
{
|
|
3824
3824
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
3825
|
-
"line":
|
|
3825
|
+
"line": 43,
|
|
3826
3826
|
"character": 21,
|
|
3827
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
3827
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L43"
|
|
3828
3828
|
}
|
|
3829
3829
|
],
|
|
3830
3830
|
"type": {
|
|
@@ -4020,9 +4020,9 @@
|
|
|
4020
4020
|
"sources": [
|
|
4021
4021
|
{
|
|
4022
4022
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
4023
|
-
"line":
|
|
4023
|
+
"line": 46,
|
|
4024
4024
|
"character": 21,
|
|
4025
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
4025
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L46"
|
|
4026
4026
|
}
|
|
4027
4027
|
],
|
|
4028
4028
|
"type": {
|
|
@@ -4670,9 +4670,9 @@
|
|
|
4670
4670
|
"sources": [
|
|
4671
4671
|
{
|
|
4672
4672
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
4673
|
-
"line":
|
|
4673
|
+
"line": 33,
|
|
4674
4674
|
"character": 18,
|
|
4675
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
4675
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L33"
|
|
4676
4676
|
}
|
|
4677
4677
|
],
|
|
4678
4678
|
"type": {
|
|
@@ -4758,9 +4758,9 @@
|
|
|
4758
4758
|
"sources": [
|
|
4759
4759
|
{
|
|
4760
4760
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
4761
|
-
"line":
|
|
4761
|
+
"line": 35,
|
|
4762
4762
|
"character": 28,
|
|
4763
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
4763
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L35"
|
|
4764
4764
|
}
|
|
4765
4765
|
],
|
|
4766
4766
|
"type": {
|
|
@@ -5136,9 +5136,9 @@
|
|
|
5136
5136
|
"sources": [
|
|
5137
5137
|
{
|
|
5138
5138
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
5139
|
-
"line":
|
|
5139
|
+
"line": 48,
|
|
5140
5140
|
"character": 25,
|
|
5141
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
5141
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L48"
|
|
5142
5142
|
}
|
|
5143
5143
|
],
|
|
5144
5144
|
"getSignature": {
|
|
@@ -5150,9 +5150,9 @@
|
|
|
5150
5150
|
"sources": [
|
|
5151
5151
|
{
|
|
5152
5152
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
5153
|
-
"line":
|
|
5153
|
+
"line": 48,
|
|
5154
5154
|
"character": 2,
|
|
5155
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
5155
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L48"
|
|
5156
5156
|
}
|
|
5157
5157
|
],
|
|
5158
5158
|
"type": {
|
|
@@ -5497,9 +5497,9 @@
|
|
|
5497
5497
|
"sources": [
|
|
5498
5498
|
{
|
|
5499
5499
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
5500
|
-
"line":
|
|
5500
|
+
"line": 55,
|
|
5501
5501
|
"character": 25,
|
|
5502
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
5502
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L55"
|
|
5503
5503
|
}
|
|
5504
5504
|
],
|
|
5505
5505
|
"getSignature": {
|
|
@@ -5511,9 +5511,9 @@
|
|
|
5511
5511
|
"sources": [
|
|
5512
5512
|
{
|
|
5513
5513
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
5514
|
-
"line":
|
|
5514
|
+
"line": 55,
|
|
5515
5515
|
"character": 2,
|
|
5516
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
5516
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L55"
|
|
5517
5517
|
}
|
|
5518
5518
|
],
|
|
5519
5519
|
"type": {
|
|
@@ -9199,9 +9199,9 @@
|
|
|
9199
9199
|
"sources": [
|
|
9200
9200
|
{
|
|
9201
9201
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
9202
|
-
"line":
|
|
9202
|
+
"line": 60,
|
|
9203
9203
|
"character": 27,
|
|
9204
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
9204
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L60"
|
|
9205
9205
|
}
|
|
9206
9206
|
],
|
|
9207
9207
|
"signatures": [
|
|
@@ -9214,9 +9214,9 @@
|
|
|
9214
9214
|
"sources": [
|
|
9215
9215
|
{
|
|
9216
9216
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
9217
|
-
"line":
|
|
9217
|
+
"line": 60,
|
|
9218
9218
|
"character": 2,
|
|
9219
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
9219
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L60"
|
|
9220
9220
|
}
|
|
9221
9221
|
],
|
|
9222
9222
|
"parameters": [
|
|
@@ -9575,7 +9575,7 @@
|
|
|
9575
9575
|
{
|
|
9576
9576
|
"type": "reference",
|
|
9577
9577
|
"target": {
|
|
9578
|
-
"sourceFileName": "../../../../../../../manifest/packages/model/
|
|
9578
|
+
"sourceFileName": "../../../../../../../manifest/packages/model/dist/index.d.ts",
|
|
9579
9579
|
"qualifiedName": "ModuleManifestPayload"
|
|
9580
9580
|
},
|
|
9581
9581
|
"name": "ModuleManifestPayload",
|
|
@@ -9655,7 +9655,7 @@
|
|
|
9655
9655
|
{
|
|
9656
9656
|
"type": "reference",
|
|
9657
9657
|
"target": {
|
|
9658
|
-
"sourceFileName": "../../../../../../../manifest/packages/model/
|
|
9658
|
+
"sourceFileName": "../../../../../../../manifest/packages/model/dist/index.d.ts",
|
|
9659
9659
|
"qualifiedName": "ModuleManifestPayload"
|
|
9660
9660
|
},
|
|
9661
9661
|
"name": "ModuleManifestPayload",
|
|
@@ -17724,7 +17724,7 @@
|
|
|
17724
17724
|
"type": {
|
|
17725
17725
|
"type": "reference",
|
|
17726
17726
|
"target": {
|
|
17727
|
-
"sourceFileName": "../../../../../../../protocol/packages/account/packages/wallet-model/
|
|
17727
|
+
"sourceFileName": "../../../../../../../protocol/packages/account/packages/wallet-model/dist/index.d.ts",
|
|
17728
17728
|
"qualifiedName": "WalletInstance"
|
|
17729
17729
|
},
|
|
17730
17730
|
"name": "WalletInstance",
|
|
@@ -18104,9 +18104,9 @@
|
|
|
18104
18104
|
"sources": [
|
|
18105
18105
|
{
|
|
18106
18106
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
18107
|
-
"line":
|
|
18107
|
+
"line": 30,
|
|
18108
18108
|
"character": 13,
|
|
18109
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
18109
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L30"
|
|
18110
18110
|
}
|
|
18111
18111
|
],
|
|
18112
18112
|
"typeParameters": [
|
|
@@ -18167,7 +18167,7 @@
|
|
|
18167
18167
|
"fileName": "modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts",
|
|
18168
18168
|
"line": 18,
|
|
18169
18169
|
"character": 12,
|
|
18170
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
18170
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/899ce501d2fd1/packages/modules/packages/diviner/packages/forecasting/packages/memory/src/MemoryForecastingDiviner.ts#L18"
|
|
18171
18171
|
}
|
|
18172
18172
|
],
|
|
18173
18173
|
"type": {
|
|
@@ -18178,7 +18178,7 @@
|
|
|
18178
18178
|
"queryType": {
|
|
18179
18179
|
"type": "reference",
|
|
18180
18180
|
"target": {
|
|
18181
|
-
"sourceFileName": "../../../../../../../node/packages/core/packages/forecasting/packages/arima/
|
|
18181
|
+
"sourceFileName": "../../../../../../../node/packages/core/packages/forecasting/packages/arima/dist/index.d.ts",
|
|
18182
18182
|
"qualifiedName": "arimaForecastingName"
|
|
18183
18183
|
},
|
|
18184
18184
|
"name": "arimaForecastingName",
|
|
@@ -18190,7 +18190,7 @@
|
|
|
18190
18190
|
"queryType": {
|
|
18191
18191
|
"type": "reference",
|
|
18192
18192
|
"target": {
|
|
18193
|
-
"sourceFileName": "../../../../../../../node/packages/core/packages/forecasting/packages/arima/
|
|
18193
|
+
"sourceFileName": "../../../../../../../node/packages/core/packages/forecasting/packages/arima/dist/index.d.ts",
|
|
18194
18194
|
"qualifiedName": "seasonalArimaForecastingName"
|
|
18195
18195
|
},
|
|
18196
18196
|
"name": "seasonalArimaForecastingName",
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -33,10 +43,10 @@ var import_diviner_forecasting_abstract = require("@xyo-network/diviner-forecast
|
|
|
33
43
|
var import_diviner_forecasting_method_arima = require("@xyo-network/diviner-forecasting-method-arima");
|
|
34
44
|
var import_diviner_forecasting_model = require("@xyo-network/diviner-forecasting-model");
|
|
35
45
|
var import_diviner_model = require("@xyo-network/diviner-model");
|
|
36
|
-
var import_jsonpath = require("jsonpath");
|
|
46
|
+
var import_jsonpath = __toESM(require("jsonpath"));
|
|
37
47
|
var getJsonPathTransformer = (pathExpression) => {
|
|
38
48
|
const transformer = (x) => {
|
|
39
|
-
const ret =
|
|
49
|
+
const ret = import_jsonpath.default.value(x, pathExpression);
|
|
40
50
|
if (typeof ret === "number")
|
|
41
51
|
return ret;
|
|
42
52
|
throw new Error("Parsed invalid payload value");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/MemoryForecastingDiviner.ts"],"sourcesContent":["export * from './MemoryForecastingDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/MemoryForecastingDiviner.ts"],"sourcesContent":["export * from './MemoryForecastingDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1_000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length !== 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,o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,UAAM,QAAQ,KAAK;AACnB,UAAM,oBAAgB,wBAAS,KAAK,OAAO,eAAe,iCAAiC;AAC3F,QAAI,YAAY;AAChB,QAAI,OAAO;AAIX,WAAO,QAAQ,SAAS,SAAS,KAAK,mBAAmB;AACvD,YAAM,QAAyC,EAAE,WAAW,OAAO,iBAAiB,QAAQ,kEAAgC,UAAU;AACtI,YAAM,kBAAmB,MAAM,UAAU,OAAO,CAAC,KAAK,CAAC,GAAsB;AAAA,QAC3E,CAAC,OAAO,GAAG,aAAa,GAAG,aAAa,kBAAkB,GAAG,aAAa;AAAA,MAC5E;AACA,UAAI,eAAe,WAAW;AAAG;AAGjC,kBAAY,eACT,IAAI,CAAC,OAAO,GAAG,SAAS,EACxB,OAAO,oBAAM,EACb,OAAO,CAAC,GAAG,MAAM,KAAK,IAAI,GAAG,CAAC,GAAG,OAAO,gBAAgB;AAC3D,UAAI,cAAc,OAAO;AAAkB;AAG3C,aAAO,eAAe,WAAW;AAGjC,YAAM,SAAS,eAAe,IAAI,CAAC,OAAO,GAAG,eAAe,GAAG,gBAAgB,UAAU,CAAC,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,OAAO,oBAAM;AAGpI,UAAI,OAAO,WAAW,GAAG;AACvB,cAAM,iBAAiB,MAAM,UAAU,IAAI,MAAM,GAAG,OAAO,oBAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["jsonpath"]}
|
package/dist/index.mjs
CHANGED
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
} from "@xyo-network/diviner-forecasting-method-arima";
|
|
11
11
|
import { ForecastingDivinerConfigSchema } from "@xyo-network/diviner-forecasting-model";
|
|
12
12
|
import { asDivinerInstance } from "@xyo-network/diviner-model";
|
|
13
|
-
import
|
|
13
|
+
import jsonpath from "jsonpath";
|
|
14
14
|
var getJsonPathTransformer = (pathExpression) => {
|
|
15
15
|
const transformer = (x) => {
|
|
16
|
-
const ret = value(x, pathExpression);
|
|
16
|
+
const ret = jsonpath.value(x, pathExpression);
|
|
17
17
|
if (typeof ret === "number")
|
|
18
18
|
return ret;
|
|
19
19
|
throw new Error("Parsed invalid payload value");
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport
|
|
1
|
+
{"version":3,"sources":["../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1_000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length !== 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAEpC,SAA0C,sCAAsC;AAChF,SAAS,kCAA4D;AACrE;AAAA,EACE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,sCAAkF;AAC3F,SAAS,yBAAyB;AAElC,OAAO,cAAc;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,SAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AA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OAAO,GAAG,aAAa,GAAG,aAAa,kBAAkB,GAAG,aAAa;AAAA,MAC5E;AACA,UAAI,eAAe,WAAW;AAAG;AAGjC,kBAAY,eACT,IAAI,CAAC,OAAO,GAAG,SAAS,EACxB,OAAO,MAAM,EACb,OAAO,CAAC,GAAG,MAAM,KAAK,IAAI,GAAG,CAAC,GAAG,OAAO,gBAAgB;AAC3D,UAAI,cAAc,OAAO;AAAkB;AAG3C,aAAO,eAAe,WAAW;AAGjC,YAAM,SAAS,eAAe,IAAI,CAAC,OAAO,GAAG,eAAe,GAAG,gBAAgB,UAAU,CAAC,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,OAAO,MAAM;AAGpI,UAAI,OAAO,WAAW,GAAG;AACvB,cAAM,iBAAiB,MAAM,UAAU,IAAI,MAAM,GAAG,OAAO,MAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -10,22 +10,22 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^2.10.
|
|
14
|
-
"@xylabs/exists": "^2.10.
|
|
15
|
-
"@xyo-network/archivist-model": "~2.73.
|
|
16
|
-
"@xyo-network/boundwitness-model": "~2.73.
|
|
17
|
-
"@xyo-network/diviner-boundwitness-model": "~2.73.
|
|
18
|
-
"@xyo-network/diviner-forecasting-abstract": "~2.73.
|
|
19
|
-
"@xyo-network/diviner-forecasting-method-arima": "~2.73.
|
|
20
|
-
"@xyo-network/diviner-forecasting-model": "~2.73.
|
|
21
|
-
"@xyo-network/diviner-model": "~2.73.
|
|
22
|
-
"@xyo-network/payload-model": "~2.73.
|
|
13
|
+
"@xylabs/assert": "^2.10.16",
|
|
14
|
+
"@xylabs/exists": "^2.10.16",
|
|
15
|
+
"@xyo-network/archivist-model": "~2.73.4",
|
|
16
|
+
"@xyo-network/boundwitness-model": "~2.73.4",
|
|
17
|
+
"@xyo-network/diviner-boundwitness-model": "~2.73.4",
|
|
18
|
+
"@xyo-network/diviner-forecasting-abstract": "~2.73.4",
|
|
19
|
+
"@xyo-network/diviner-forecasting-method-arima": "~2.73.4",
|
|
20
|
+
"@xyo-network/diviner-forecasting-model": "~2.73.4",
|
|
21
|
+
"@xyo-network/diviner-model": "~2.73.4",
|
|
22
|
+
"@xyo-network/payload-model": "~2.73.4",
|
|
23
23
|
"jsonpath": "^1.1.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/jsonpath": "^0.2.0",
|
|
27
|
-
"@xylabs/ts-scripts-yarn3": "^2.19.
|
|
28
|
-
"@xylabs/tsconfig": "^2.19.
|
|
27
|
+
"@xylabs/ts-scripts-yarn3": "^2.19.12",
|
|
28
|
+
"@xylabs/tsconfig": "^2.19.12",
|
|
29
29
|
"publint": "^0.2.2",
|
|
30
30
|
"tsup": "^7.2.0",
|
|
31
31
|
"typescript": "^5.2.2"
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
75
75
|
},
|
|
76
76
|
"sideEffects": false,
|
|
77
|
-
"version": "2.73.
|
|
77
|
+
"version": "2.73.4"
|
|
78
78
|
}
|
|
@@ -13,13 +13,14 @@ import {
|
|
|
13
13
|
import { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'
|
|
14
14
|
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
15
15
|
import { Payload } from '@xyo-network/payload-model'
|
|
16
|
-
import
|
|
16
|
+
import jsonpath from 'jsonpath'
|
|
17
17
|
|
|
18
18
|
export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName
|
|
19
19
|
|
|
20
20
|
const getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {
|
|
21
21
|
const transformer = (x: Payload): number => {
|
|
22
|
-
|
|
22
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
23
|
+
const ret = jsonpath.value(x, pathExpression)
|
|
23
24
|
if (typeof ret === 'number') return ret
|
|
24
25
|
throw new Error('Parsed invalid payload value')
|
|
25
26
|
}
|