@xyo-network/diviner-forecasting-memory 2.98.5 → 2.99.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.
@@ -4,8 +4,8 @@ import { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner
4
4
  import { Payload, Schema } from '@xyo-network/payload-model';
5
5
  export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName;
6
6
  export declare class MemoryForecastingDiviner<TParams extends ForecastingDivinerParams = ForecastingDivinerParams> extends AbstractForecastingDiviner<TParams> {
7
- static configSchemas: Schema[];
8
- static defaultConfigSchema: Schema;
7
+ static readonly configSchemas: Schema[];
8
+ static readonly defaultConfigSchema: Schema;
9
9
  protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod>;
10
10
  /**
11
11
  * The max number of records to search during the batch query
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEnI,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAG5D,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,OAAgB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAClG,OAAgB,mBAAmB,EAAE,MAAM,CAAiC;IAE5E,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAA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AAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
@@ -4,8 +4,8 @@ import { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner
4
4
  import { Payload, Schema } from '@xyo-network/payload-model';
5
5
  export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName;
6
6
  export declare class MemoryForecastingDiviner<TParams extends ForecastingDivinerParams = ForecastingDivinerParams> extends AbstractForecastingDiviner<TParams> {
7
- static configSchemas: Schema[];
8
- static defaultConfigSchema: Schema;
7
+ static readonly configSchemas: Schema[];
8
+ static readonly defaultConfigSchema: Schema;
9
9
  protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod>;
10
10
  /**
11
11
  * The max number of records to search during the batch query
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEnI,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAG5D,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,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B,EAAE,MAAM,CAAiC;IAErF,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAO;IAGpC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
@@ -4,8 +4,8 @@ import { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner
4
4
  import { Payload, Schema } from '@xyo-network/payload-model';
5
5
  export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName;
6
6
  export declare class MemoryForecastingDiviner<TParams extends ForecastingDivinerParams = ForecastingDivinerParams> extends AbstractForecastingDiviner<TParams> {
7
- static configSchemas: Schema[];
8
- static defaultConfigSchema: Schema;
7
+ static readonly configSchemas: Schema[];
8
+ static readonly defaultConfigSchema: Schema;
9
9
  protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod>;
10
10
  /**
11
11
  * The max number of records to search during the batch query
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAA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AO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAC3G,gBAAyB,mBAAmB,EAAE,MAAM,CAAiC;IAErF,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAO;IAGpC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
@@ -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 configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override 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,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AAmB,GAAGoB,IAAG,GAClD,uCAAA;AAEF,UAAMC,QAAQ,KAAKvB;AACnB,UAAMc,oBAAgBX,wBAAS,KAAKC,OAAOU,eAAe,MAAM,iCAAA;AAChE,QAAIU,YAAYd;AAChB,QAAIe,OAAO;AAIX,WAAOA,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;AAAG;AAGjCF,kBAAYM,eACTI,IAAI,CAACD,OAAOA,GAAGT,SAAS,EACxBQ,OAAOG,oBAAAA,EAEPC,OAAO,CAACC,GAAGC,MAAMC,KAAKC,IAAIH,GAAGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAIlB,cAAciB,OAAOC;AAAkB;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"]}
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;AAAU,aAAOA;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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AAGT,aAAaf,kBAAkBwB,GAAGT,aAAad,aAAAA;AAE5E,UAAIoB,eAAeJ,WAAW;AAAG;AAGjCF,kBAAYM,eACTI,IAAI,CAACD,OAAOA,GAAGT,SAAS,EACxBQ,OAAOG,oBAAAA,EAEPC,OAAO,CAACC,GAAGC,MAAMC,KAAKC,IAAIH,GAAGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAIlB,cAAciB,OAAOC;AAAkB;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"]}
@@ -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 configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override 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;AAAU,aAAOA;AACpC,UAAM,IAAIG,MAAM,8BAAA;EAClB,GAJoB;AAKpB,SAAOL;AACT,GAP+B;AASxB,IAAMM,2BAAN,MAAMA,kCAEHC,2BAAAA;EA9BV,OA8BUA;;;EACR,OAAgBC,gBAA0B;OAAI,MAAMA;IAAeC;;EACnE,OAAgBC,sBAA8BD;EAE9C,OAA0BE,wBAA6E;IACrGC,kBAAkBC;IAClBC,0BAA0BC;EAC5B;;;;EAKmBC,aAAa;;EAGbC,oBAAoB;EAEvC,IAAIC,sBAAsB;AACxB,WAAOC,SAAS,KAAKC,OAAOF,qBAAqB,MAAM,mCAAA;EACzD;EAEA,IAAuBG,oBAAuC;AAC5D,UAAMC,wBAAwBH,SAAS,KAAKC,OAAOC,mBAAmB,MAAM,qCAAA;AAC5E,UAAMA,oBAAoBf,0BAAyBK,sBAAsBW,qBAAAA;AACzE,QAAID;AAAmB,aAAOA;AAC9B,UAAM,IAAIhB,MAAM,mCAAmCiB,qBAAAA,EAAuB;EAC5E;EAE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,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"]}
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,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5B,UAAMC,YAAYC,oBAAoB,MAAM,KAAKC,kBAAiB,GAAI,MAAM,6BAAA;AAC5E,UAAMC,YAAYC,mBACf,MAAM,KAAKC,QAAQ,KAAKnB,mBAAmB,GAAGoB,IAAG,GAClD,uCAAA;AAEF,UAAMC,QAAQ,KAAKvB;AACnB,UAAMc,gBAAgBX,SAAS,KAAKC,OAAOU,eAAe,MAAM,iCAAA;AAChE,QAAIU,YAAYd;AAChB,QAAIe,OAAO;AAIX,WAAOA,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;AAAG;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;AAAkB;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"]}
@@ -4,8 +4,8 @@ import { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner
4
4
  import { Payload, Schema } from '@xyo-network/payload-model';
5
5
  export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName;
6
6
  export declare class MemoryForecastingDiviner<TParams extends ForecastingDivinerParams = ForecastingDivinerParams> extends AbstractForecastingDiviner<TParams> {
7
- static configSchemas: Schema[];
8
- static defaultConfigSchema: Schema;
7
+ static readonly configSchemas: Schema[];
8
+ static readonly defaultConfigSchema: Schema;
9
9
  protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod>;
10
10
  /**
11
11
  * The max number of records to search during the batch query
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO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AG5D,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAC3G,gBAAyB,mBAAmB,EAAE,MAAM,CAAiC;IAErF,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAO;IAGpC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
@@ -4,8 +4,8 @@ import { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner
4
4
  import { Payload, Schema } from '@xyo-network/payload-model';
5
5
  export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName;
6
6
  export declare class MemoryForecastingDiviner<TParams extends ForecastingDivinerParams = ForecastingDivinerParams> extends AbstractForecastingDiviner<TParams> {
7
- static configSchemas: Schema[];
8
- static defaultConfigSchema: Schema;
7
+ static readonly configSchemas: Schema[];
8
+ static readonly defaultConfigSchema: Schema;
9
9
  protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod>;
10
10
  /**
11
11
  * The max number of records to search during the batch query
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEnI,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAG5D,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,OAAgB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAClG,OAAgB,mBAAmB,EAAE,MAAM,CAAiC;IAE5E,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAO;IAGpC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
1
+ {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEnI,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAG5D,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAC3G,gBAAyB,mBAAmB,EAAE,MAAM,CAAiC;IAErF,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAO;IAGpC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
@@ -4,8 +4,8 @@ import { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner
4
4
  import { Payload, Schema } from '@xyo-network/payload-model';
5
5
  export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName;
6
6
  export declare class MemoryForecastingDiviner<TParams extends ForecastingDivinerParams = ForecastingDivinerParams> extends AbstractForecastingDiviner<TParams> {
7
- static configSchemas: Schema[];
8
- static defaultConfigSchema: Schema;
7
+ static readonly configSchemas: Schema[];
8
+ static readonly defaultConfigSchema: Schema;
9
9
  protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod>;
10
10
  /**
11
11
  * The max number of records to search during the batch query
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEnI,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAG5D,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,OAAgB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAClG,OAAgB,mBAAmB,EAAE,MAAM,CAAiC;IAE5E,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAO;IAGpC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
1
+ {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AAChH,OAAO,EAEL,oBAAoB,EAEpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAEnI,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAG5D,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAWxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAC3G,gBAAyB,mBAAmB,EAAE,MAAM,CAAiC;IAErF,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAO;IAGpC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,IAAI,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAEtB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA6ChH"}
@@ -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 configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override 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;AAAU,aAAOA;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;AAAmB,aAAOA;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,oBA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oBAAAA;AAC3DpB,iBAASiC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAO/B;EACT;AACF;AA9EUjB;AACR,cAHWD,2BAGKoD,iBAA0B;KAAI,iEAAMA;EAAeC;;AACnE,cAJWrD,2BAIKsD,uBAA8BD;AAE9C,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"]}
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,oBAA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KxB;AACnB,UAAMe,oBAAgBZ,wBAAS,KAAKC,OAAOW,eAAe,MAAM,iCAAA;AAChE,QAAIU,YAAYd;AAChB,QAAIe,OAAO;AAIX,WAAOA,QAAQV,SAASW,SAAS,KAAK1B,mBAAmB;AACvD,YAAM2B,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;AAAG;AAGjCF,kBAAYM,eACTI,IAAI,CAACD,OAAOA,GAAGT,SAAS,EACxBQ,OAAOG,oBAAAA,EAEPC,OAAO,CAACC,GAAGC,MAAMC,KAAKC,IAAIH,GAAGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAIlB,cAAciB,OAAOC;AAAkB;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;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"]}
@@ -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 configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override 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;AAAU,aAAOA;AACpC,UAAM,IAAIG,MAAM,8BAAA;EAClB,GAJoB;AAKpB,SAAOL;AACT,GAP+B;AASxB,IAAMM,4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A;AAE5E,UAAIoB,eAAeJ,WAAW;AAAG;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;AAAkB;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,2BAGKoD,iBAA0B;KAAI,iEAAMA;EAAeC;;AACnE,cAJWrD,2BAIKsD,uBAA8BD;AAE9C,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"]}
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;AAAU,aAAOA;AACpC,UAAM,IAAIG,MAAM,8BAAA;EAClB,GAJoB;AAKpB,SAAOL;AACT,GAP+B;AASxB,IAAMM,4BAAN,MAAMA,kCAEHC,2BAAAA;;;;EAYWC,aAAa;;EAGbC,oBAAoB;EAEvC,IAAIC,sBAAsB;AACxB,WAAOC,SAAS,KAAKC,OAAOF,qBAAqB,MAAM,mCAAA;EACzD;EAEA,IAAuBG,oBAAuC;AAC5D,UAAMC,wBAAwBH,SAAS,KAAKC,OAAOC,mBAAmB,MAAM,qCAAA;AAC5E,UAAMA,oBAAo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AAeJ,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,16 +10,16 @@
10
10
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@xylabs/assert": "^3.1.10",
14
- "@xylabs/exists": "^3.1.10",
15
- "@xyo-network/archivist-model": "~2.98.5",
16
- "@xyo-network/boundwitness-model": "~2.98.5",
17
- "@xyo-network/diviner-boundwitness-model": "~2.98.5",
18
- "@xyo-network/diviner-forecasting-abstract": "~2.98.5",
19
- "@xyo-network/diviner-forecasting-method-arima": "~2.98.5",
20
- "@xyo-network/diviner-forecasting-model": "~2.98.5",
21
- "@xyo-network/diviner-model": "~2.98.5",
22
- "@xyo-network/payload-model": "~2.98.5",
13
+ "@xylabs/assert": "^3.1.11",
14
+ "@xylabs/exists": "^3.1.11",
15
+ "@xyo-network/archivist-model": "~2.99.1",
16
+ "@xyo-network/boundwitness-model": "~2.99.1",
17
+ "@xyo-network/diviner-boundwitness-model": "~2.99.1",
18
+ "@xyo-network/diviner-forecasting-abstract": "~2.99.1",
19
+ "@xyo-network/diviner-forecasting-method-arima": "~2.99.1",
20
+ "@xyo-network/diviner-forecasting-model": "~2.99.1",
21
+ "@xyo-network/diviner-model": "~2.99.1",
22
+ "@xyo-network/payload-model": "~2.99.1",
23
23
  "jsonpath": "^1.1.1"
24
24
  },
25
25
  "devDependencies": {
@@ -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.98.5",
70
+ "version": "2.99.1",
71
71
  "type": "module"
72
72
  }
@@ -29,8 +29,8 @@ const getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer
29
29
  export class MemoryForecastingDiviner<
30
30
  TParams extends ForecastingDivinerParams = ForecastingDivinerParams,
31
31
  > extends AbstractForecastingDiviner<TParams> {
32
- static override configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]
33
- static override defaultConfigSchema: Schema = ForecastingDivinerConfigSchema
32
+ static override readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]
33
+ static override readonly defaultConfigSchema: Schema = ForecastingDivinerConfigSchema
34
34
 
35
35
  protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {
36
36
  arimaForecasting: arimaForecastingMethod,