@xyo-network/diviner-forecasting-memory 2.103.9 → 2.104.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/index.cjs +4 -8
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +4 -8
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +4 -8
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +4 -8
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +5 -12
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +5 -12
- package/dist/node/index.js.map +1 -1
- package/package.json +13 -13
package/dist/browser/index.cjs
CHANGED
|
@@ -48,8 +48,7 @@ var import_jsonpath = __toESM(require("jsonpath"), 1);
|
|
|
48
48
|
var getJsonPathTransformer = /* @__PURE__ */ __name((pathExpression) => {
|
|
49
49
|
const transformer = /* @__PURE__ */ __name((x) => {
|
|
50
50
|
const ret = import_jsonpath.default.value(x, pathExpression);
|
|
51
|
-
if (typeof ret === "number")
|
|
52
|
-
return ret;
|
|
51
|
+
if (typeof ret === "number") return ret;
|
|
53
52
|
throw new Error("Parsed invalid payload value");
|
|
54
53
|
}, "transformer");
|
|
55
54
|
return transformer;
|
|
@@ -79,8 +78,7 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_di
|
|
|
79
78
|
get forecastingMethod() {
|
|
80
79
|
const forecastingMethodName = (0, import_assert.assertEx)(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
81
80
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
82
|
-
if (forecastingMethod)
|
|
83
|
-
return forecastingMethod;
|
|
81
|
+
if (forecastingMethod) return forecastingMethod;
|
|
84
82
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
85
83
|
}
|
|
86
84
|
get transformer() {
|
|
@@ -110,11 +108,9 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_di
|
|
|
110
108
|
const boundWitnesses = (await bwDiviner.divine([
|
|
111
109
|
query
|
|
112
110
|
])).filter((bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp);
|
|
113
|
-
if (boundWitnesses.length === 0)
|
|
114
|
-
break;
|
|
111
|
+
if (boundWitnesses.length === 0) break;
|
|
115
112
|
timestamp = boundWitnesses.map((bw) => bw.timestamp).filter(import_exists.exists).reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER);
|
|
116
|
-
if (timestamp === Number.MAX_SAFE_INTEGER)
|
|
117
|
-
break;
|
|
113
|
+
if (timestamp === Number.MAX_SAFE_INTEGER) break;
|
|
118
114
|
more = boundWitnesses.length === limit;
|
|
119
115
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(import_exists.exists);
|
|
120
116
|
if (hashes.length > 0) {
|
|
@@ -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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAA2G;AAC3G,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAmD;AAEnD,sBAAqB;AAIrB,IAAMA,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,gBAAAA,QAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ
|
|
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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAA2G;AAC3G,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAmD;AAEnD,sBAAqB;AAIrB,IAAMA,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,gBAAAA,QAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ,SAAU,QAAOA;AACpC,UAAM,IAAIG,MAAM,8BAAA;EAClB,GAJoB;AAKpB,SAAOL;AACT,GAP+B;AASxB,IAAMM,2BAAN,MAAMA,kCAEHC,+DAAAA;EA9BV,OA8BUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,OAA0BE,wBAA6E;IACrGC,kBAAkBC;IAClBC,0BAA0BC;EAC5B;;;;EAKmBC,aAAa;;EAGbC,oBAAoB;EAEvC,IAAIC,sBAAsB;AACxB,eAAOC,wBAAS,KAAKC,OAAOF,qBAAqB,MAAM,mCAAA;EACzD;EAEA,IAAuBG,oBAAuC;AAC5D,UA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AGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAIlB,cAAciB,OAAOC,iBAAkB;AAG3CjB,aAAOK,eAAeJ,WAAWH;AAGjC,YAAMoB,SAASb,eAAeI,IAAI,CAACD,OAAOA,GAAGW,eAAeX,GAAGpB,gBAAgBgC,QAAQ/B,aAAAA,CAAAA,CAAe,EAAEkB,OAAOG,oBAAAA;AAG/G,UAAIQ,OAAOjB,SAAS,GAAG;AACrB,cAAMoB,iBAAiB,MAAM9B,UAAU+B,IAAIJ,MAAAA,GAASX,OAAOG,oBAAAA;AAC3DpB,iBAASiC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAO/B;EACT;AACF;","names":["getJsonPathTransformer","pathExpression","transformer","x","ret","jsonpath","value","Error","MemoryForecastingDiviner","AbstractForecastingDiviner","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","forecastingMethodDict","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod","batchLimit","maxTrainingLength","boundWitnessDiviner","assertEx","config","forecastingMethod","forecastingMethodName","jsonPathExpression","getPayloadsInWindow","startTimestamp","stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","timestamp","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","bw","map","exists","reduce","a","b","Math","min","Number","MAX_SAFE_INTEGER","hashes","payload_hashes","indexOf","batchPayloads","get","push"]}
|
package/dist/browser/index.js
CHANGED
|
@@ -14,8 +14,7 @@ import jsonpath from "jsonpath";
|
|
|
14
14
|
var getJsonPathTransformer = /* @__PURE__ */ __name((pathExpression) => {
|
|
15
15
|
const transformer = /* @__PURE__ */ __name((x) => {
|
|
16
16
|
const ret = jsonpath.value(x, pathExpression);
|
|
17
|
-
if (typeof ret === "number")
|
|
18
|
-
return ret;
|
|
17
|
+
if (typeof ret === "number") return ret;
|
|
19
18
|
throw new Error("Parsed invalid payload value");
|
|
20
19
|
}, "transformer");
|
|
21
20
|
return transformer;
|
|
@@ -45,8 +44,7 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
45
44
|
get forecastingMethod() {
|
|
46
45
|
const forecastingMethodName = assertEx(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
47
46
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
48
|
-
if (forecastingMethod)
|
|
49
|
-
return forecastingMethod;
|
|
47
|
+
if (forecastingMethod) return forecastingMethod;
|
|
50
48
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
51
49
|
}
|
|
52
50
|
get transformer() {
|
|
@@ -76,11 +74,9 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
76
74
|
const boundWitnesses = (await bwDiviner.divine([
|
|
77
75
|
query
|
|
78
76
|
])).filter((bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp);
|
|
79
|
-
if (boundWitnesses.length === 0)
|
|
80
|
-
break;
|
|
77
|
+
if (boundWitnesses.length === 0) break;
|
|
81
78
|
timestamp = boundWitnesses.map((bw) => bw.timestamp).filter(exists).reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER);
|
|
82
|
-
if (timestamp === Number.MAX_SAFE_INTEGER)
|
|
83
|
-
break;
|
|
79
|
+
if (timestamp === Number.MAX_SAFE_INTEGER) break;
|
|
84
80
|
more = boundWitnesses.length === limit;
|
|
85
81
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
|
|
86
82
|
if (hashes.length > 0) {
|
|
@@ -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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AAEpC,SAAqEC,sCAAsC;AAC3G,SAASC,kCAA4D;AACrE,SACEC,wBAEAC,sCAEK;AACP,SAASC,sCAAkF;AAC3F,SAASC,yBAA0C;AAEnD,OAAOC,cAAc;AAIrB,IAAMC,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,SAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ
|
|
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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AAEpC,SAAqEC,sCAAsC;AAC3G,SAASC,kCAA4D;AACrE,SACEC,wBAEAC,sCAEK;AACP,SAASC,sCAAkF;AAC3F,SAASC,yBAA0C;AAEnD,OAAOC,cAAc;AAIrB,IAAMC,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,SAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ,SAAU,Q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QAAQV,SAASW,SAAS,KAAKzB,mBAAmB;AACvD,YAAM0B,QAAyC;QAAEhB;QAAWY;QAAOV;QAAiBe,QAAQC;QAAgCL;MAAU;AACtI,YAAMM,kBAAkB,MAAMX,UAAUY,OAAO;QAACJ;OAAM,GAAGK,OACvD,CAACC,OAAOA,GAAGT,aAAaS,GAAGT,aAAaf,kBAAkBwB,GAAGT,aAAad,aAAAA;AAE5E,UAAIoB,eAAeJ,WAAW,EAAG;AAGjCF,kBAAYM,eACTI,IAAI,CAACD,OAAOA,GAAGT,SAAS,EACxBQ,OAAOG,MAAAA,EAEPC,OAAO,CAACC,GAAGC,MAAMC,KAAKC,IAAIH,GAAGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAIlB,cAAciB,OAAOC,iBAAkB;AAG3CjB,aAAOK,eAAeJ,WAAWH;AAGjC,YAAMoB,SAASb,eAAeI,IAAI,CAACD,OAAOA,GAAGW,eAAeX,GAAGpB,gBAAgBgC,QAAQ/B,aAAAA,CAAAA,CAAe,EAAEkB,OAAOG,MAAAA;AAG/G,UAAIQ,OAAOjB,SAAS,GAAG;AACrB,cAAMoB,iBAAiB,MAAM9B,UAAU+B,IAAIJ,MAAAA,GAASX,OAAOG,MAAAA;AAC3DpB,iBAASiC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAO/B;EACT;AACF;","names":["assertEx","exists","asArchivistInstance","BoundWitnessDivinerQuerySchema","AbstractForecastingDiviner","arimaForecastingMethod","seasonalArimaForecastingMethod","ForecastingDivinerConfigSchema","asDivinerInstance","jsonpath","getJsonPathTransformer","pathExpression","transformer","x","ret","jsonpath","value","Error","MemoryForecastingDiviner","AbstractForecastingDiviner","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","forecastingMethodDict","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod","batchLimit","maxTrainingLength","boundWitnessDiviner","assertEx","config","forecastingMethod","forecastingMethodName","jsonPathExpression","getPayloadsInWindow","startTimestamp","stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","timestamp","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","bw","map","exists","reduce","a","b","Math","min","Number","MAX_SAFE_INTEGER","hashes","payload_hashes","indexOf","batchPayloads","get","push"]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -48,8 +48,7 @@ var import_jsonpath = __toESM(require("jsonpath"), 1);
|
|
|
48
48
|
var getJsonPathTransformer = /* @__PURE__ */ __name((pathExpression) => {
|
|
49
49
|
const transformer = /* @__PURE__ */ __name((x) => {
|
|
50
50
|
const ret = import_jsonpath.default.value(x, pathExpression);
|
|
51
|
-
if (typeof ret === "number")
|
|
52
|
-
return ret;
|
|
51
|
+
if (typeof ret === "number") return ret;
|
|
53
52
|
throw new Error("Parsed invalid payload value");
|
|
54
53
|
}, "transformer");
|
|
55
54
|
return transformer;
|
|
@@ -79,8 +78,7 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_di
|
|
|
79
78
|
get forecastingMethod() {
|
|
80
79
|
const forecastingMethodName = (0, import_assert.assertEx)(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
81
80
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
82
|
-
if (forecastingMethod)
|
|
83
|
-
return forecastingMethod;
|
|
81
|
+
if (forecastingMethod) return forecastingMethod;
|
|
84
82
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
85
83
|
}
|
|
86
84
|
get transformer() {
|
|
@@ -110,11 +108,9 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_di
|
|
|
110
108
|
const boundWitnesses = (await bwDiviner.divine([
|
|
111
109
|
query
|
|
112
110
|
])).filter((bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp);
|
|
113
|
-
if (boundWitnesses.length === 0)
|
|
114
|
-
break;
|
|
111
|
+
if (boundWitnesses.length === 0) break;
|
|
115
112
|
timestamp = boundWitnesses.map((bw) => bw.timestamp).filter(import_exists.exists).reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER);
|
|
116
|
-
if (timestamp === Number.MAX_SAFE_INTEGER)
|
|
117
|
-
break;
|
|
113
|
+
if (timestamp === Number.MAX_SAFE_INTEGER) break;
|
|
118
114
|
more = boundWitnesses.length === limit;
|
|
119
115
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(import_exists.exists);
|
|
120
116
|
if (hashes.length > 0) {
|
|
@@ -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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAA2G;AAC3G,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAmD;AAEnD,sBAAqB;AAIrB,IAAMA,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,gBAAAA,QAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ
|
|
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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAA2G;AAC3G,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAmD;AAEnD,sBAAqB;AAIrB,IAAMA,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,gBAAAA,QAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ,SAAU,QAAOA;AACpC,UAAM,IAAIG,MAAM,8BAAA;EAClB,GAJoB;AAKpB,SAAOL;AACT,GAP+B;AASxB,IAAMM,2BAAN,MAAMA,kCAEHC,+DAAAA;EA9BV,OA8BUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,OAA0BE,wBAA6E;IACrGC,kBAAkBC;IAClBC,0BAA0BC;EAC5B;;;;EAKmBC,aAAa;;EAGbC,oBAAoB;EAEvC,IAAIC,sBAAsB;AACxB,eAAOC,wBAAS,KAAKC,OAAOF,qBAAqB,MAAM,mCAAA;EACzD;EAEA,IAAuBG,oBAAuC;AAC5D,UAAMC,4BAAwBH,wBAAS,KAAKC,OAAOC,mBAAmB,MAAM,qCAAA;AAC5E,UAAMA,oBAAoBf,0BAAyBK,sBAAsBW,qBAAAA;AACzE,QAAID,kBAAmB,QAAOA;AAC9B,UAAM,IAAIhB,MAAM,mC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,GAAGpB,gBAAgBgC,QAAQ/B,aAAAA,CAAAA,CAAe,EAAEkB,OAAOG,oBAAAA;AAG/G,UAAIQ,OAAOjB,SAAS,GAAG;AACrB,cAAMoB,iBAAiB,MAAM9B,UAAU+B,IAAIJ,MAAAA,GAASX,OAAOG,oBAAAA;AAC3DpB,iBAASiC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAO/B;EACT;AACF;","names":["getJsonPathTransformer","pathExpression","transformer","x","ret","jsonpath","value","Error","MemoryForecastingDiviner","AbstractForecastingDiviner","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","forecastingMethodDict","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod","batchLimit","maxTrainingLength","boundWitnessDiviner","assertEx","config","forecastingMethod","forecastingMethodName","jsonPathExpression","getPayloadsInWindow","startTimestamp","stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","timestamp","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","bw","map","exists","reduce","a","b","Math","min","Number","MAX_SAFE_INTEGER","hashes","payload_hashes","indexOf","batchPayloads","get","push"]}
|
package/dist/neutral/index.js
CHANGED
|
@@ -14,8 +14,7 @@ import jsonpath from "jsonpath";
|
|
|
14
14
|
var getJsonPathTransformer = /* @__PURE__ */ __name((pathExpression) => {
|
|
15
15
|
const transformer = /* @__PURE__ */ __name((x) => {
|
|
16
16
|
const ret = jsonpath.value(x, pathExpression);
|
|
17
|
-
if (typeof ret === "number")
|
|
18
|
-
return ret;
|
|
17
|
+
if (typeof ret === "number") return ret;
|
|
19
18
|
throw new Error("Parsed invalid payload value");
|
|
20
19
|
}, "transformer");
|
|
21
20
|
return transformer;
|
|
@@ -45,8 +44,7 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
45
44
|
get forecastingMethod() {
|
|
46
45
|
const forecastingMethodName = assertEx(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
47
46
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
48
|
-
if (forecastingMethod)
|
|
49
|
-
return forecastingMethod;
|
|
47
|
+
if (forecastingMethod) return forecastingMethod;
|
|
50
48
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
51
49
|
}
|
|
52
50
|
get transformer() {
|
|
@@ -76,11 +74,9 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
76
74
|
const boundWitnesses = (await bwDiviner.divine([
|
|
77
75
|
query
|
|
78
76
|
])).filter((bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp);
|
|
79
|
-
if (boundWitnesses.length === 0)
|
|
80
|
-
break;
|
|
77
|
+
if (boundWitnesses.length === 0) break;
|
|
81
78
|
timestamp = boundWitnesses.map((bw) => bw.timestamp).filter(exists).reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER);
|
|
82
|
-
if (timestamp === Number.MAX_SAFE_INTEGER)
|
|
83
|
-
break;
|
|
79
|
+
if (timestamp === Number.MAX_SAFE_INTEGER) break;
|
|
84
80
|
more = boundWitnesses.length === limit;
|
|
85
81
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
|
|
86
82
|
if (hashes.length > 0) {
|
|
@@ -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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AAEpC,SAAqEC,sCAAsC;AAC3G,SAASC,kCAA4D;AACrE,SACEC,wBAEAC,sCAEK;AACP,SAASC,sCAAkF;AAC3F,SAASC,yBAA0C;AAEnD,OAAOC,cAAc;AAIrB,IAAMC,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,SAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ
|
|
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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AAEpC,SAAqEC,sCAAsC;AAC3G,SAASC,kCAA4D;AACrE,SACEC,wBAEAC,sCAEK;AACP,SAASC,sCAAkF;AAC3F,SAASC,yBAA0C;AAEnD,OAAOC,cAAc;AAIrB,IAAMC,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,SAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ,SAAU,QAAOA;AACpC,UAAM,IAAIG,MAAM,8BAAA;EAClB,GAJoB;AAKpB,SAAOL;AACT,GAP+B;AASxB,IAAMM,2BAAN,MAAMA,kCAEHC,2BAAAA;EA9BV,OA8BUA;;;EACR,OAAyBC,gBAA0B;OAA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GAAGK,OACvD,CAACC,OAAOA,GAAGT,aAAaS,GAAGT,aAAaf,kBAAkBwB,GAAGT,aAAad,aAAAA;AAE5E,UAAIoB,eAAeJ,WAAW,EAAG;AAGjCF,kBAAYM,eACTI,IAAI,CAACD,OAAOA,GAAGT,SAAS,EACxBQ,OAAOG,MAAAA,EAEPC,OAAO,CAACC,GAAGC,MAAMC,KAAKC,IAAIH,GAAGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAIlB,cAAciB,OAAOC,iBAAkB;AAG3CjB,aAAOK,eAAeJ,WAAWH;AAGjC,YAAMoB,SAASb,eAAeI,IAAI,CAACD,OAAOA,GAAGW,eAAeX,GAAGpB,gBAAgBgC,QAAQ/B,aAAAA,CAAAA,CAAe,EAAEkB,OAAOG,MAAAA;AAG/G,UAAIQ,OAAOjB,SAAS,GAAG;AACrB,cAAMoB,iBAAiB,MAAM9B,UAAU+B,IAAIJ,MAAAA,GAASX,OAAOG,MAAAA;AAC3DpB,iBAASiC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAO/B;EACT;AACF;","names":["assertEx","exists","asArchivistInstance","BoundWitnessDivinerQuerySchema","AbstractForecastingDiviner","arimaForecastingMethod","seasonalArimaForecastingMethod","ForecastingDivinerConfigSchema","asDivinerInstance","jsonpath","getJsonPathTransformer","pathExpression","transformer","x","ret","jsonpath","value","Error","MemoryForecastingDiviner","AbstractForecastingDiviner","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","forecastingMethodDict","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod","batchLimit","maxTrainingLength","boundWitnessDiviner","assertEx","config","forecastingMethod","forecastingMethodName","jsonPathExpression","getPayloadsInWindow","startTimestamp","stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","timestamp","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","bw","map","exists","reduce","a","b","Math","min","Number","MAX_SAFE_INTEGER","hashes","payload_hashes","indexOf","batchPayloads","get","push"]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -29,10 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
mod
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
var __publicField = (obj, key, value) =>
|
|
33
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
-
return value;
|
|
35
|
-
};
|
|
32
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
33
|
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
37
34
|
|
|
38
35
|
// src/index.ts
|
|
@@ -55,8 +52,7 @@ var import_jsonpath = __toESM(require("jsonpath"), 1);
|
|
|
55
52
|
var getJsonPathTransformer = /* @__PURE__ */ __name((pathExpression) => {
|
|
56
53
|
const transformer = /* @__PURE__ */ __name((x) => {
|
|
57
54
|
const ret = import_jsonpath.default.value(x, pathExpression);
|
|
58
|
-
if (typeof ret === "number")
|
|
59
|
-
return ret;
|
|
55
|
+
if (typeof ret === "number") return ret;
|
|
60
56
|
throw new Error("Parsed invalid payload value");
|
|
61
57
|
}, "transformer");
|
|
62
58
|
return transformer;
|
|
@@ -74,8 +70,7 @@ var _MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_d
|
|
|
74
70
|
get forecastingMethod() {
|
|
75
71
|
const forecastingMethodName = (0, import_assert.assertEx)(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
76
72
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
77
|
-
if (forecastingMethod)
|
|
78
|
-
return forecastingMethod;
|
|
73
|
+
if (forecastingMethod) return forecastingMethod;
|
|
79
74
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
80
75
|
}
|
|
81
76
|
get transformer() {
|
|
@@ -105,11 +100,9 @@ var _MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_d
|
|
|
105
100
|
const boundWitnesses = (await bwDiviner.divine([
|
|
106
101
|
query
|
|
107
102
|
])).filter((bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp);
|
|
108
|
-
if (boundWitnesses.length === 0)
|
|
109
|
-
break;
|
|
103
|
+
if (boundWitnesses.length === 0) break;
|
|
110
104
|
timestamp = boundWitnesses.map((bw) => bw.timestamp).filter(import_exists.exists).reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER);
|
|
111
|
-
if (timestamp === Number.MAX_SAFE_INTEGER)
|
|
112
|
-
break;
|
|
105
|
+
if (timestamp === Number.MAX_SAFE_INTEGER) break;
|
|
113
106
|
more = boundWitnesses.length === limit;
|
|
114
107
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(import_exists.exists);
|
|
115
108
|
if (hashes.length > 0) {
|
package/dist/node/index.cjs.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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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":"
|
|
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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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;;;;;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAA2G;AAC3G,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAmD;AAEnD,sBAAqB;AAIrB,IAAMA,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,gBAAAA,QAASC,MAAMH,GAAGF,cAAAA;AAC9B,QAAI,OAAOG,QAAQ,SAAU,QAAOA;AACpC,UAAM,IAAIG,MAAM,8BAAA;EAClB,GAJoB;AAKpB,SAAOL;AACT,GAP+B;AASxB,IAAMM,4BAAN,MAAMA,kCAEHC,+DAAAA;;;;EAYWC,aAAa;;EAGbC,oBAAoB;EAEvC,IAAIC,sBAAsB;AACxB,eAAOC,wBAAS,KAAKC,OAAOF,qBAAqB,MAAM,mCAAA;EACzD;EAEA,IAAuBG,oBAAuC;AAC5D,UAAMC,4BAAwBH,wBAAS,KAAKC,OAAOC,mBAAmB,MAAM,qCAAA;AAC5E,UAAMA,oBAAoBP,0BAAyBS,sBAAsBD,qBAAAA;AACzE,QAAID,kBAAmB,QAAOA;AAC9B,UAAM,IAAIR,MAAM,mCAAmCS,qBAAAA,EAAuB;EAC5E;EAEA,IAAuBd,cAAuC;AAC5D,UAAMD,qBAAiBY,wBAAS,KAAKC,OAAOI,oBAAoB,MAAM,sCAAA;AACtE,WAAOlB,uBAAuBC,cAAAA;EAChC;EAEA,MAAyBkB,oBAAoBC,g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A;AAC3DpB,iBAASiC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAO/B;EACT;AACF;AA9EUjB;AACR,cAHWD,2BAGcoD,iBAA0B;KAAI,iEAAMA;EAAeC;;AAC5E,cAJWrD,2BAIcsD,uBAA8BD;AAEvD,cANWrD,2BAMeS,yBAA6E;EACrG8C,kBAAkBC;EAClBC,0BAA0BC;AAC5B;AATK,IAAM1D,2BAAN;","names":["getJsonPathTransformer","pathExpression","transformer","x","ret","jsonpath","value","Error","MemoryForecastingDiviner","AbstractForecastingDiviner","batchLimit","maxTrainingLength","boundWitnessDiviner","assertEx","config","forecastingMethod","forecastingMethodName","forecastingMethodDict","jsonPathExpression","getPayloadsInWindow","startTimestamp","stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","timestamp","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","bw","map","exists","reduce","a","b","Math","min","Number","MAX_SAFE_INTEGER","hashes","payload_hashes","indexOf","batchPayloads","get","push","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod"]}
|
package/dist/node/index.js
CHANGED
|
@@ -3,10 +3,7 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
3
3
|
var __reflectGet = Reflect.get;
|
|
4
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __publicField = (obj, key, value) =>
|
|
7
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
-
return value;
|
|
9
|
-
};
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
7
|
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
11
8
|
|
|
12
9
|
// src/MemoryForecastingDiviner.ts
|
|
@@ -22,8 +19,7 @@ import jsonpath from "jsonpath";
|
|
|
22
19
|
var getJsonPathTransformer = /* @__PURE__ */ __name((pathExpression) => {
|
|
23
20
|
const transformer = /* @__PURE__ */ __name((x) => {
|
|
24
21
|
const ret = jsonpath.value(x, pathExpression);
|
|
25
|
-
if (typeof ret === "number")
|
|
26
|
-
return ret;
|
|
22
|
+
if (typeof ret === "number") return ret;
|
|
27
23
|
throw new Error("Parsed invalid payload value");
|
|
28
24
|
}, "transformer");
|
|
29
25
|
return transformer;
|
|
@@ -41,8 +37,7 @@ var _MemoryForecastingDiviner = class _MemoryForecastingDiviner extends Abstract
|
|
|
41
37
|
get forecastingMethod() {
|
|
42
38
|
const forecastingMethodName = assertEx(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
43
39
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
44
|
-
if (forecastingMethod)
|
|
45
|
-
return forecastingMethod;
|
|
40
|
+
if (forecastingMethod) return forecastingMethod;
|
|
46
41
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
47
42
|
}
|
|
48
43
|
get transformer() {
|
|
@@ -72,11 +67,9 @@ var _MemoryForecastingDiviner = class _MemoryForecastingDiviner extends Abstract
|
|
|
72
67
|
const boundWitnesses = (await bwDiviner.divine([
|
|
73
68
|
query
|
|
74
69
|
])).filter((bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp);
|
|
75
|
-
if (boundWitnesses.length === 0)
|
|
76
|
-
break;
|
|
70
|
+
if (boundWitnesses.length === 0) break;
|
|
77
71
|
timestamp = boundWitnesses.map((bw) => bw.timestamp).filter(exists).reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER);
|
|
78
|
-
if (timestamp === Number.MAX_SAFE_INTEGER)
|
|
79
|
-
break;
|
|
72
|
+
if (timestamp === Number.MAX_SAFE_INTEGER) break;
|
|
80
73
|
more = boundWitnesses.length === limit;
|
|
81
74
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
|
|
82
75
|
if (hashes.length > 0) {
|
package/dist/node/index.js.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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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":"
|
|
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 { BoundWitnessDivinerParams, 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, DivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload, Schema } 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 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 readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n get boundWitnessDiviner() {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\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.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\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])).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 // eslint-disable-next-line unicorn/no-array-reduce\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.indexOf(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,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AAEpC,SAAqEC,sCAAsC;AAC3G,SAASC,kCAA4D;AACrE,SACEC,wBAEAC,sCAEK;AACP,SAASC,sCAAkF;AAC3F,SAASC,yBAA0C;AAEnD,OAAOC,cAAc;AAIrB,IAAMC,yBAAyB,wBAACC,mBAAAA;AAC9B,QAAMC,cAAc,wBAACC,MAAAA;AACnB,UAAMC,MAAMC,SAASC,MAAMH,GAAGF,cA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YAAMM,kBAAkB,MAAMX,UAAUY,OAAO;QAACJ;OAAM,GAAGK,OACvD,CAACC,OAAOA,GAAGT,aAAaS,GAAGT,aAAaf,kBAAkBwB,GAAGT,aAAad,aAAAA;AAE5E,UAAIoB,eAAeJ,WAAW,EAAG;AAGjCF,kBAAYM,eACTI,IAAI,CAACD,OAAOA,GAAGT,SAAS,EACxBQ,OAAOG,MAAAA,EAEPC,OAAO,CAACC,GAAGC,MAAMC,KAAKC,IAAIH,GAAGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAIlB,cAAciB,OAAOC,iBAAkB;AAG3CjB,aAAOK,eAAeJ,WAAWH;AAGjC,YAAMoB,SAASb,eAAeI,IAAI,CAACD,OAAOA,GAAGW,eAAeX,GAAGpB,gBAAgBgC,QAAQ/B,aAAAA,CAAAA,CAAe,EAAEkB,OAAOG,MAAAA;AAG/G,UAAIQ,OAAOjB,SAAS,GAAG;AACrB,cAAMoB,iBAAiB,MAAM9B,UAAU+B,IAAIJ,MAAAA,GAASX,OAAOG,MAAAA;AAC3DpB,iBAASiC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAO/B;EACT;AACF;AA9EUjB;AACR,cAHWD,2BAGcoD,iBAA0B;KAAI,iEAAMA;EAAeC;;AAC5E,cAJWrD,2BAIcsD,uBAA8BD;AAEvD,cANWrD,2BAMeS,yBAA6E;EACrG8C,kBAAkBC;EAClBC,0BAA0BC;AAC5B;AATK,IAAM1D,2BAAN;","names":["assertEx","exists","asArchivistInstance","BoundWitnessDivinerQuerySchema","AbstractForecastingDiviner","arimaForecastingMethod","seasonalArimaForecastingMethod","ForecastingDivinerConfigSchema","asDivinerInstance","jsonpath","getJsonPathTransformer","pathExpression","transformer","x","ret","jsonpath","value","Error","MemoryForecastingDiviner","AbstractForecastingDiviner","batchLimit","maxTrainingLength","boundWitnessDiviner","assertEx","config","forecastingMethod","forecastingMethodName","forecastingMethodDict","jsonPathExpression","getPayloadsInWindow","startTimestamp","stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","timestamp","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","bw","map","exists","reduce","a","b","Math","min","Number","MAX_SAFE_INTEGER","hashes","payload_hashes","indexOf","batchPayloads","get","push","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod"]}
|
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": "^3.5.
|
|
14
|
-
"@xylabs/exists": "^3.5.
|
|
15
|
-
"@xyo-network/archivist-model": "~2.
|
|
16
|
-
"@xyo-network/boundwitness-model": "~2.
|
|
17
|
-
"@xyo-network/diviner-boundwitness-model": "~2.
|
|
18
|
-
"@xyo-network/diviner-forecasting-abstract": "~2.
|
|
19
|
-
"@xyo-network/diviner-forecasting-method-arima": "~2.
|
|
20
|
-
"@xyo-network/diviner-forecasting-model": "~2.
|
|
21
|
-
"@xyo-network/diviner-model": "~2.
|
|
22
|
-
"@xyo-network/payload-model": "~2.
|
|
13
|
+
"@xylabs/assert": "^3.5.1",
|
|
14
|
+
"@xylabs/exists": "^3.5.1",
|
|
15
|
+
"@xyo-network/archivist-model": "~2.104.1",
|
|
16
|
+
"@xyo-network/boundwitness-model": "~2.104.1",
|
|
17
|
+
"@xyo-network/diviner-boundwitness-model": "~2.104.1",
|
|
18
|
+
"@xyo-network/diviner-forecasting-abstract": "~2.104.1",
|
|
19
|
+
"@xyo-network/diviner-forecasting-method-arima": "~2.104.1",
|
|
20
|
+
"@xyo-network/diviner-forecasting-model": "~2.104.1",
|
|
21
|
+
"@xyo-network/diviner-model": "~2.104.1",
|
|
22
|
+
"@xyo-network/payload-model": "~2.104.1",
|
|
23
23
|
"jsonpath": "^1.1.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/jsonpath": "^0.2.4",
|
|
27
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
28
|
-
"@xylabs/tsconfig": "^3.
|
|
27
|
+
"@xylabs/ts-scripts-yarn3": "^3.11.2",
|
|
28
|
+
"@xylabs/tsconfig": "^3.11.2",
|
|
29
29
|
"typescript": "^5.4.5"
|
|
30
30
|
},
|
|
31
31
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
68
68
|
},
|
|
69
69
|
"sideEffects": false,
|
|
70
|
-
"version": "2.
|
|
70
|
+
"version": "2.104.1",
|
|
71
71
|
"type": "module"
|
|
72
72
|
}
|