@xyo-network/diviner-forecasting-memory 2.84.6 → 2.84.8

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.
@@ -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,4BAA4B,CAAA;AAGpD,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAYxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,OAAgB,aAAa,6CAAmC;IAEhE,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAQ;IAGrC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,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;CAyChH"}
1
+ {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EA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,CAAC,OAAO,EAAE,CAAC;CAyChH"}
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,4BAA4B,CAAA;AAGpD,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAYxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,OAAgB,aAAa,6CAAmC;IAEhE,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,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;CA0ChH"}
@@ -97,8 +97,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_di
97
97
  if (timestamp === Number.MAX_SAFE_INTEGER)
98
98
  break;
99
99
  more = boundWitnesses.length === limit;
100
- const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(import_exists.exists);
101
- if (hashes.length !== 0) {
100
+ const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(import_exists.exists);
101
+ if (hashes.length > 0) {
102
102
  const batchPayloads = (await archivist.get(hashes)).filter(import_exists.exists);
103
103
  payloads.push(...batchPayloads);
104
104
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["export * from './MemoryForecastingDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1_000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length !== 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAAgF;AAChF,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAkC;AAElC,sBAAqB;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,gBAAAA,QAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,+DAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,+DAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EAEvC,IAAuB,oBAAuC;AAC5D,UAAM,4BAAwB,wBAAS,KAAK,OAAO,mBAAmB,qCAAqC;AAC3G,UAAM,oBAAoB,0BAAyB,sBAAsB,qBAAqB;AAC9F,QAAI;AAAmB,aAAO;AAC9B,UAAM,IAAI,MAAM,mCAAmC,qBAAqB,EAAE;AAAA,EAC5E;AAAA,EAEA,IAAuB,cAAuC;AAC5D,U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OAAO,oBAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["jsonpath"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["export * from './MemoryForecastingDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n // 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;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAAgF;AAChF,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAkC;AAElC,sBAAqB;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,gBAAAA,QAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,+DAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,+DAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EAEvC,IAAuB,oBAAuC;AAC5D,UAAM,4BAAwB,wBAAS,KAAK,OAAO,mBAAmB,qCAAqC;AAC3G,UAAM,oBAAoB,0BAAyB,sBAAsB,qBAAqB;AAC9F,QAAI;AAAmB,aAAO;AAC9B,UAAM,IAAI,MAAM,mCAAmC,qBAAqB,EAAE;AAAA,EAC5E;AAAA,EAEA,IAAuB,cAAuC;AAC5D,UAAM,qBAAiB,wBAAS,KAAK,OAAO,oBAAoB,sCAAsC;AACtG,WAAO,uBAAu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,EACT;AACF;","names":["jsonpath"]}
@@ -64,8 +64,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
64
64
  if (timestamp === Number.MAX_SAFE_INTEGER)
65
65
  break;
66
66
  more = boundWitnesses.length === limit;
67
- const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists);
68
- if (hashes.length !== 0) {
67
+ const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
68
+ if (hashes.length > 0) {
69
69
  const batchPayloads = (await archivist.get(hashes)).filter(exists);
70
70
  payloads.push(...batchPayloads);
71
71
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1_000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length !== 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAEpC,SAA0C,sCAAsC;AAChF,SAAS,kCAA4D;AACrE;AAAA,EACE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,sCAAkF;AAC3F,SAAS,yBAAyB;AAElC,OAAO,cAAc;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,SAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,2BAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,8BAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EAEvC,IAAuB,oBAAuC;AAC5D,UAAM,wBAA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,SAAS,eAAe,IAAI,CAAC,OAAO,GAAG,eAAe,GAAG,gBAAgB,UAAU,CAAC,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,OAAO,MAAM;AAGpI,UAAI,OAAO,WAAW,GAAG;AACvB,cAAM,iBAAiB,MAAM,UAAU,IAAI,MAAM,GAAG,OAAO,MAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n // 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,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAEpC,SAA0C,sCAAsC;AAChF,SAAS,kCAA4D;AACrE;AAAA,EACE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,sCAAkF;AAC3F,SAAS,yBAAyB;AAElC,OAAO,cAAc;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,SAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,2BAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,8BAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EAEvC,IAAuB,oBAAuC;AAC5D,UAAM,wBAAwB,SAAS,KAAK,OAAO,mBAAmB,qCAAqC;AAC3G,UAAM,oBAAoB,0BAAyB,sBAAsB,qBAAqB;AAC9F,QAAI;AAAmB,aAAO;AAC9B,UAAM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AS,GAAG;AACrB,cAAM,iBAAiB,MAAM,UAAU,IAAI,MAAM,GAAG,OAAO,MAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -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,4BAA4B,CAAA;AAGpD,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAYxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,OAAgB,aAAa,6CAAmC;IAEhE,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAGnG;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,QAAQ;IAGrC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,SAAS;IAE7C,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;CAyChH"}
1
+ {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAKA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AM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAyChH"}
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,4BAA4B,CAAA;AAGpD,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAYxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,OAAgB,aAAa,6CAAmC;IAEhE,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,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;CA0ChH"}
@@ -97,8 +97,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends import_di
97
97
  if (timestamp === Number.MAX_SAFE_INTEGER)
98
98
  break;
99
99
  more = boundWitnesses.length === limit;
100
- const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(import_exists.exists);
101
- if (hashes.length !== 0) {
100
+ const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(import_exists.exists);
101
+ if (hashes.length > 0) {
102
102
  const batchPayloads = (await archivist.get(hashes)).filter(import_exists.exists);
103
103
  payloads.push(...batchPayloads);
104
104
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["export * from './MemoryForecastingDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1_000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length !== 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAAgF;AAChF,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAkC;AAElC,sBAAqB;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,gBAAAA,QAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,+DAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,+DAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EAEvC,IAAuB,oBAAuC;AAC5D,UAAM,4BAAwB,wBAAS,KAAK,OAAO,mBAAmB,qCAAqC;AAC3G,UAAM,oBAAoB,0BAAyB,sBAAsB,qBAAqB;AAC9F,QAAI;AAAmB,aAAO;AAC9B,UAAM,IAAI,MAAM,mCAAmC,qBAAqB,EAAE;AAAA,EAC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iBAAiB,MAAM,UAAU,IAAI,MAAM,GAAG,OAAO,oBAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["jsonpath"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["export * from './MemoryForecastingDiviner'\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n // 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;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyB;AACzB,oBAAuB;AACvB,6BAAoC;AAEpC,wCAAgF;AAChF,0CAAqE;AACrE,8CAKO;AACP,uCAA2F;AAC3F,2BAAkC;AAElC,sBAAqB;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,gBAAAA,QAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,+DAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,+DAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EAEvC,IAAuB,oBAAuC;AAC5D,UAAM,4BAAwB,wBAAS,KAAK,OAAO,mBAAmB,qCAAqC;AAC3G,UAAM,oBAAoB,0BAAyB,sBAAsB,qBAAqB;AAC9F,QAAI;AAAmB,aAAO;AAC9B,UAAM,IAAI,MAAM,mCAAmC,qBAAqB,EAAE;AAAA,EAC5E;AAAA,EAEA,IAAuB,cAAuC;AAC5D,UAAM,qBAAiB,wBAAS,KAAK,OA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AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["jsonpath"]}
@@ -64,8 +64,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
64
64
  if (timestamp === Number.MAX_SAFE_INTEGER)
65
65
  break;
66
66
  more = boundWitnesses.length === limit;
67
- const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists);
68
- if (hashes.length !== 0) {
67
+ const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
68
+ if (hashes.length > 0) {
69
69
  const batchPayloads = (await archivist.get(hashes)).filter(exists);
70
70
  payloads.push(...batchPayloads);
71
71
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1_000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length !== 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAEpC,SAA0C,sCAAsC;AAChF,SAAS,kCAA4D;AACrE;AAAA,EACE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,sCAAkF;AAC3F,SAAS,yBAAyB;AAElC,OAAO,cAAc;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,SAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,2BAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,8BAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EA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;AAG3C,aAAO,eAAe,WAAW;AAGjC,YAAM,SAAS,eAAe,IAAI,CAAC,OAAO,GAAG,eAAe,GAAG,gBAAgB,UAAU,CAAC,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,OAAO,MAAM;AAGpI,UAAI,OAAO,WAAW,GAAG;AACvB,cAAM,iBAAiB,MAAM,UAAU,IAAI,MAAM,GAAG,OAAO,MAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { AbstractForecastingDiviner, ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport {\n arimaForecastingMethod,\n arimaForecastingName,\n seasonalArimaForecastingMethod,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport { ForecastingDivinerConfigSchema, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n const transformer = (x: Payload): number => {\n // eslint-disable-next-line import/no-named-as-default-member\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n return transformer\n}\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override configSchemas = [ForecastingDivinerConfigSchema]\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected readonly batchLimit = 1000\n\n // TODO: Inject via config\n protected readonly maxTrainingLength = 10_000\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.readArchivist(), 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance((await this.resolve(this.config.boundWitnessDiviner)).pop(), 'Unable to resolve boundWitnessDiviner')\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = { addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema, timestamp }\n const boundWitnesses = ((await bwDiviner.divine([query])) as BoundWitness[]).filter(\n (bw) => bw.timestamp && bw.timestamp >= startTimestamp && bw.timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map((bw) => bw.timestamp)\n .filter(exists)\n // 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,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAEpC,SAA0C,sCAAsC;AAChF,SAAS,kCAA4D;AACrE;AAAA,EACE;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,sCAAkF;AAC3F,SAAS,yBAAyB;AAElC,OAAO,cAAc;AAIrB,IAAM,yBAAyB,CAAC,mBAAoD;AAClF,QAAM,cAAc,CAAC,MAAuB;AAE1C,UAAM,MAAM,SAAS,MAAM,GAAG,cAAc;AAC5C,QAAI,OAAO,QAAQ;AAAU,aAAO;AACpC,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,SAAO;AACT;AAEO,IAAM,2BAAN,MAAM,kCAEH,2BAAoC;AAAA,EAC5C,OAAgB,gBAAgB,CAAC,8BAA8B;AAAA,EAE/D,OAA0B,wBAA6E;AAAA,IACrG,kBAAkB;AAAA,IAClB,0BAA0B;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKmB,aAAa;AAAA;AAAA,EAGb,oBAAoB;AAAA,EAEvC,IAAuB,oBAAuC;AAC5D,UAAM,wBAAwB,SAAS,KAAK,OAAO,mBAAmB,qCAAqC;AAC3G,UAAM,oBAAoB,0BAAyB,sBAAsB,qBAAqB;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AAE,OAAO,MAAM;AAGrH,UAAI,OAAO,SAAS,GAAG;AACrB,cAAM,iBAAiB,MAAM,UAAU,IAAI,MAAM,GAAG,OAAO,MAAM;AACjE,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -12,20 +12,20 @@
12
12
  "dependencies": {
13
13
  "@xylabs/assert": "^2.13.20",
14
14
  "@xylabs/exists": "^2.13.20",
15
- "@xyo-network/archivist-model": "~2.84.6",
16
- "@xyo-network/boundwitness-model": "~2.84.6",
17
- "@xyo-network/diviner-boundwitness-model": "~2.84.6",
18
- "@xyo-network/diviner-forecasting-abstract": "~2.84.6",
19
- "@xyo-network/diviner-forecasting-method-arima": "~2.84.6",
20
- "@xyo-network/diviner-forecasting-model": "~2.84.6",
21
- "@xyo-network/diviner-model": "~2.84.6",
22
- "@xyo-network/payload-model": "~2.84.6",
15
+ "@xyo-network/archivist-model": "~2.84.8",
16
+ "@xyo-network/boundwitness-model": "~2.84.8",
17
+ "@xyo-network/diviner-boundwitness-model": "~2.84.8",
18
+ "@xyo-network/diviner-forecasting-abstract": "~2.84.8",
19
+ "@xyo-network/diviner-forecasting-method-arima": "~2.84.8",
20
+ "@xyo-network/diviner-forecasting-model": "~2.84.8",
21
+ "@xyo-network/diviner-model": "~2.84.8",
22
+ "@xyo-network/payload-model": "~2.84.8",
23
23
  "jsonpath": "^1.1.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/jsonpath": "^0.2.4",
27
- "@xylabs/ts-scripts-yarn3": "^3.2.19",
28
- "@xylabs/tsconfig": "^3.2.19",
27
+ "@xylabs/ts-scripts-yarn3": "^3.2.24",
28
+ "@xylabs/tsconfig": "^3.2.24",
29
29
  "typescript": "^5.3.3"
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.84.6",
70
+ "version": "2.84.8",
71
71
  "type": "module"
72
72
  }
@@ -40,7 +40,7 @@ export class MemoryForecastingDiviner<
40
40
  /**
41
41
  * The max number of records to search during the batch query
42
42
  */
43
- protected readonly batchLimit = 1_000
43
+ protected readonly batchLimit = 1000
44
44
 
45
45
  // TODO: Inject via config
46
46
  protected readonly maxTrainingLength = 10_000
@@ -81,6 +81,7 @@ export class MemoryForecastingDiviner<
81
81
  timestamp = boundWitnesses
82
82
  .map((bw) => bw.timestamp)
83
83
  .filter(exists)
84
+ // eslint-disable-next-line unicorn/no-array-reduce
84
85
  .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)
85
86
  if (timestamp === Number.MAX_SAFE_INTEGER) break
86
87
 
@@ -88,10 +89,10 @@ export class MemoryForecastingDiviner<
88
89
  more = boundWitnesses.length === limit
89
90
 
90
91
  // Get the corresponding payload hashes from the BWs
91
- const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.findIndex((s) => s === witnessSchema)]).filter(exists)
92
+ const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists)
92
93
 
93
94
  // Get the payloads corresponding to the BW hashes from the archivist
94
- if (hashes.length !== 0) {
95
+ if (hashes.length > 0) {
95
96
  const batchPayloads = (await archivist.get(hashes)).filter(exists)
96
97
  payloads.push(...batchPayloads)
97
98
  }