@xyo-network/diviner-forecasting 7.2.2 → 7.3.0

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.
Files changed (67) hide show
  1. package/dist/neutral/abstract/AbstractForecasting.d.ts +16 -0
  2. package/dist/neutral/abstract/AbstractForecasting.d.ts.map +1 -0
  3. package/dist/neutral/abstract/index.d.ts +2 -0
  4. package/dist/neutral/abstract/index.d.ts.map +1 -0
  5. package/dist/neutral/abstract.d.ts +2 -0
  6. package/dist/neutral/abstract.d.ts.map +1 -0
  7. package/dist/neutral/abstract.mjs +106 -0
  8. package/dist/neutral/abstract.mjs.map +7 -0
  9. package/dist/neutral/arima/arima/configurable/configurableArima.d.ts +10 -0
  10. package/dist/neutral/arima/arima/configurable/configurableArima.d.ts.map +1 -0
  11. package/dist/neutral/arima/arima/configurable/index.d.ts +2 -0
  12. package/dist/neutral/arima/arima/configurable/index.d.ts.map +1 -0
  13. package/dist/neutral/arima/arima/configured/arima.d.ts +6 -0
  14. package/dist/neutral/arima/arima/configured/arima.d.ts.map +1 -0
  15. package/dist/neutral/arima/arima/configured/index.d.ts +3 -0
  16. package/dist/neutral/arima/arima/configured/index.d.ts.map +1 -0
  17. package/dist/neutral/arima/arima/configured/seasonalArima.d.ts +6 -0
  18. package/dist/neutral/arima/arima/configured/seasonalArima.d.ts.map +1 -0
  19. package/dist/neutral/arima/arima/index.d.ts +3 -0
  20. package/dist/neutral/arima/arima/index.d.ts.map +1 -0
  21. package/dist/neutral/arima/index.d.ts +2 -0
  22. package/dist/neutral/arima/index.d.ts.map +1 -0
  23. package/dist/neutral/arima.d.ts +2 -0
  24. package/dist/neutral/arima.d.ts.map +1 -0
  25. package/dist/neutral/arima.mjs +48 -0
  26. package/dist/neutral/arima.mjs.map +7 -0
  27. package/dist/neutral/index.d.ts +3 -3
  28. package/dist/neutral/index.d.ts.map +1 -1
  29. package/dist/neutral/index.mjs +240 -4
  30. package/dist/neutral/index.mjs.map +4 -4
  31. package/dist/neutral/memory/MemoryForecastingDiviner.d.ts +22 -0
  32. package/dist/neutral/memory/MemoryForecastingDiviner.d.ts.map +1 -0
  33. package/dist/neutral/memory/index.d.ts +2 -0
  34. package/dist/neutral/memory/index.d.ts.map +1 -0
  35. package/dist/neutral/memory.d.ts +2 -0
  36. package/dist/neutral/memory.d.ts.map +1 -0
  37. package/dist/neutral/memory.mjs +224 -0
  38. package/dist/neutral/memory.mjs.map +7 -0
  39. package/dist/neutral/model/Config/Config.d.ts +33 -0
  40. package/dist/neutral/model/Config/Config.d.ts.map +1 -0
  41. package/dist/neutral/model/Config/ForecastingSettings.d.ts +12 -0
  42. package/dist/neutral/model/Config/ForecastingSettings.d.ts.map +1 -0
  43. package/dist/neutral/model/Config/TransformerSettings.d.ts +4 -0
  44. package/dist/neutral/model/Config/TransformerSettings.d.ts.map +1 -0
  45. package/dist/neutral/model/Config/index.d.ts +4 -0
  46. package/dist/neutral/model/Config/index.d.ts.map +1 -0
  47. package/dist/neutral/model/ForecastingMethod.d.ts +6 -0
  48. package/dist/neutral/model/ForecastingMethod.d.ts.map +1 -0
  49. package/dist/neutral/model/Payload/Forecast.d.ts +6 -0
  50. package/dist/neutral/model/Payload/Forecast.d.ts.map +1 -0
  51. package/dist/neutral/model/Payload/Payload.d.ts +17 -0
  52. package/dist/neutral/model/Payload/Payload.d.ts.map +1 -0
  53. package/dist/neutral/model/Payload/index.d.ts +3 -0
  54. package/dist/neutral/model/Payload/index.d.ts.map +1 -0
  55. package/dist/neutral/model/PayloadValueTransformer.d.ts +3 -0
  56. package/dist/neutral/model/PayloadValueTransformer.d.ts.map +1 -0
  57. package/dist/neutral/model/Query.d.ts +26 -0
  58. package/dist/neutral/model/Query.d.ts.map +1 -0
  59. package/dist/neutral/model/Schema.d.ts +5 -0
  60. package/dist/neutral/model/Schema.d.ts.map +1 -0
  61. package/dist/neutral/model/index.d.ts +7 -0
  62. package/dist/neutral/model/index.d.ts.map +1 -0
  63. package/dist/neutral/model.d.ts +2 -0
  64. package/dist/neutral/model.d.ts.map +1 -0
  65. package/dist/neutral/model.mjs +95 -0
  66. package/dist/neutral/model.mjs.map +7 -0
  67. package/package.json +33 -10
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from '@xyo-network/diviner-forecasting-abstract'\nexport * from '@xyo-network/diviner-forecasting-memory'\nexport * from '@xyo-network/diviner-forecasting-model'\n"],
5
- "mappings": ";AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
6
- "names": []
3
+ "sources": ["../../src/abstract/AbstractForecasting.ts", "../../src/model/Config/Config.ts", "../../src/model/Schema.ts", "../../src/model/Payload/Payload.ts", "../../src/model/Query.ts", "../../src/memory/MemoryForecastingDiviner.ts", "../../src/arima/arima/configurable/configurableArima.ts", "../../src/arima/arima/configured/arima.ts", "../../src/arima/arima/configured/seasonalArima.ts"],
4
+ "sourcesContent": ["import type { Promisable } from '@ariestools/sdk'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type {\n DivinerInstance, DivinerModuleEventData, DivinerParams,\n} from '@xyo-network/sdk/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\n\nimport type {\n ForecastingDivinerConfig,\n ForecastingDivinerQueryPayload,\n ForecastingMethod,\n ForecastingSettings,\n ForecastPayload,\n PayloadValueTransformer,\n} from '../model/index.ts'\nimport {\n ForecastingDivinerConfigSchema,\n ForecastPayloadSchema,\n isForecastingDivinerQueryPayload,\n} from '../model/index.ts'\n\nexport type ForecastingDivinerParams = DivinerParams<AnyConfigSchema<ForecastingDivinerConfig>>\n\nexport abstract class AbstractForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n TIn extends ForecastingDivinerQueryPayload = ForecastingDivinerQueryPayload,\n TOut extends ForecastPayload = ForecastPayload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = ForecastingDivinerConfigSchema\n\n protected abstract get forecastingMethod(): ForecastingMethod\n protected abstract get transformer(): PayloadValueTransformer\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const query = payloads?.find(isForecastingDivinerQueryPayload)\n if (!query) return []\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const windowSettings: ForecastingSettings = { ...this.config, ...this.query }\n const stopTimestamp = query.timestamp ?? Date.now()\n const startTimestamp = windowSettings.windowSize ? stopTimestamp - windowSettings.windowSize : 0\n const data = await this.getPayloadsInWindow(startTimestamp, stopTimestamp)\n const sources = await PayloadBuilder.dataHashes(data)\n const values = await this.forecastingMethod(data, this.transformer)\n const response: ForecastPayload = {\n schema: ForecastPayloadSchema, sources, values,\n }\n return [response as TOut]\n }\n\n protected abstract getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promisable<Payload[]>\n}\n", "import type { Address } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport type { ModuleIdentifier } from '@xyo-network/sdk/module-model'\nimport type { Schema } from '@xyo-network/sdk-protocol'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { ForecastingDivinerSchema } from '../Schema.ts'\nimport type { ForecastingSettings } from './ForecastingSettings.ts'\nimport type { TransformerSettings } from './TransformerSettings.ts'\n\nexport const ForecastingDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${ForecastingDivinerSchema}.config`, true)\nexport type ForecastingDivinerConfigSchema = typeof ForecastingDivinerConfigSchema\n\nexport const ForecastingDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n batchLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n boundWitnessDiviner: z.ZodMiniOptional<z.ZodMiniCustom<ModuleIdentifier, ModuleIdentifier>>\n forecastingMethod: z.ZodMiniOptional<z.ZodMiniString<string>>\n forecastingSteps: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n jsonPathExpression: z.ZodMiniOptional<z.ZodMiniString<string>>\n maxTrainingLength: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<ForecastingDivinerConfigSchema>\n windowSize: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n witnessAddresses: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniCustom<Address, Address>>>\n witnessSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n batchLimit: z.optional(z.number()),\n boundWitnessDiviner: z.optional(z.custom<ModuleIdentifier>()),\n forecastingMethod: z.optional(z.string()),\n forecastingSteps: z.optional(z.number()),\n jsonPathExpression: z.optional(z.string()),\n maxTrainingLength: z.optional(z.number()),\n schema: z.literal(ForecastingDivinerConfigSchema),\n windowSize: z.optional(z.number()),\n witnessAddresses: z.optional(z.array(z.custom<Address>())),\n witnessSchema: z.optional(z.custom<Schema>()),\n})\n\nexport type ForecastingDivinerConfig = DivinerConfig<\n {\n boundWitnessDiviner?: ModuleIdentifier\n schema: ForecastingDivinerConfigSchema\n } & ForecastingSettings\n & TransformerSettings\n>\n\nexport const isForecastingDivinerConfig: ReturnType<typeof zodIsFactory<ForecastingDivinerConfig>> = zodIsFactory(ForecastingDivinerConfigZod)\nexport const asForecastingDivinerConfig: ReturnType<typeof zodAsFactory<ForecastingDivinerConfig>> = zodAsFactory(ForecastingDivinerConfigZod, 'asForecastingDivinerConfig')\nexport const toForecastingDivinerConfig: ReturnType<typeof zodToFactory<ForecastingDivinerConfig>> = zodToFactory(ForecastingDivinerConfigZod, 'toForecastingDivinerConfig')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const ForecastingDivinerSchema: 'network.xyo.diviner.forecasting' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.forecasting', true)\nexport type ForecastingDivinerSchema = typeof ForecastingDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { ForecastingDivinerSchema } from '../Schema.ts'\nimport type { Forecast } from './Forecast.ts'\n\nexport const ForecastPayloadSchema: string & {\n readonly __schema: true\n} = asSchema(`${ForecastingDivinerSchema}.forecast`, true)\nexport type ForecastPayloadSchema = typeof ForecastPayloadSchema\n\nexport const ForecastPayloadZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<ForecastPayloadSchema>\n sources: z.ZodMiniArray<z.ZodMiniString<string>>\n values: z.ZodMiniArray<z.ZodMiniCustom<Forecast, Forecast>>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(ForecastPayloadSchema), {\n sources: z.array(z.string()),\n values: z.array(z.custom<Forecast>()),\n})\n\nexport type ForecastPayload = z.infer<typeof ForecastPayloadZod>\n\nexport const isForecastPayload: ReturnType<typeof zodIsFactory<ForecastPayload>> = zodIsFactory(ForecastPayloadZod)\nexport const asForecastPayload: ReturnType<typeof zodAsFactory<ForecastPayload>> = zodAsFactory(ForecastPayloadZod, 'asForecastPayload')\nexport const toForecastPayload: ReturnType<typeof zodToFactory<ForecastPayload>> = zodToFactory(ForecastPayloadZod, 'toForecastPayload')\n", "import type { Address } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { Schema } from '@xyo-network/sdk-protocol'\nimport {\n asSchema, PayloadZodOfSchema, QueryFieldsZod,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { ForecastingDivinerSchema } from './Schema.ts'\n\nexport const ForecastingDivinerQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${ForecastingDivinerSchema}.query`, true)\nexport type ForecastingDivinerQuerySchema = typeof ForecastingDivinerQuerySchema\n\nexport const ForecastingDivinerQueryPayloadZod: z.ZodMiniObject<\n & { schema: z.ZodMiniLiteral<ForecastingDivinerQuerySchema> }\n & (typeof QueryFieldsZod)['shape']\n & {\n batchLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n forecastingMethod: z.ZodMiniOptional<z.ZodMiniString<string>>\n forecastingSteps: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n maxTrainingLength: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n timestamp: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n windowSize: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n witnessAddresses: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniCustom<Address, Address>>>\n witnessSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n },\n z.core.$strip\n> = z.extend(PayloadZodOfSchema(ForecastingDivinerQuerySchema), {\n ...QueryFieldsZod.shape,\n batchLimit: z.optional(z.number()),\n forecastingMethod: z.optional(z.string()),\n forecastingSteps: z.optional(z.number()),\n maxTrainingLength: z.optional(z.number()),\n timestamp: z.optional(z.number()),\n windowSize: z.optional(z.number()),\n witnessAddresses: z.optional(z.array(z.custom<Address>())),\n witnessSchema: z.optional(z.custom<Schema>()),\n})\n\nexport type ForecastingDivinerQueryPayload = z.infer<typeof ForecastingDivinerQueryPayloadZod>\n\nexport const isForecastingDivinerQueryPayload: ReturnType<typeof zodIsFactory<ForecastingDivinerQueryPayload>> = zodIsFactory(ForecastingDivinerQueryPayloadZod)\nexport const asForecastingDivinerQueryPayload: ReturnType<typeof zodAsFactory<ForecastingDivinerQueryPayload>> = zodAsFactory(ForecastingDivinerQueryPayloadZod, 'asForecastingDivinerQueryPayload')\nexport const toForecastingDivinerQueryPayload: ReturnType<typeof zodToFactory<ForecastingDivinerQueryPayload>> = zodToFactory(ForecastingDivinerQueryPayloadZod, 'toForecastingDivinerQueryPayload')\n", "import type { Hash } from '@ariestools/sdk'\nimport { assertEx, exists } from '@ariestools/sdk'\nimport { asArchivistInstance } from '@xyo-network/sdk/archivist-model'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport type { DivinerInstance } from '@xyo-network/sdk/diviner-model'\nimport { asDivinerInstance } from '@xyo-network/sdk/diviner-model'\nimport type { ModuleIdentifier } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol'\nimport { JSONPath } from 'jsonpath-plus'\n\nimport type { ForecastingDivinerParams } from '../abstract/index.ts'\nimport { AbstractForecastingDiviner } from '../abstract/index.ts'\nimport type {\n arimaForecastingName,\n seasonalArimaForecastingName,\n} from '../arima/index.ts'\nimport {\n arimaForecastingMethod,\n seasonalArimaForecastingMethod,\n} from '../arima/index.ts'\nimport type { ForecastingMethod, PayloadValueTransformer } from '../model/index.ts'\nimport { ForecastingDivinerConfigSchema } from '../model/index.ts'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n return (x: Payload): number => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const ret = JSONPath({ path: pathExpression, json: x })[0]\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n}\n\nconst defaultBatchLimit = 1000\nconst defaultMaxTrainingLength = 10_000\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 get boundWitnessDiviner(): ModuleIdentifier {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected get batchLimit(): number {\n return this.config.batchLimit ?? defaultBatchLimit\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 get maxTrainingLength(): number {\n return this.config.maxTrainingLength ?? defaultMaxTrainingLength\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', { required: true })\n // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style\n const bwDiviner = asDivinerInstance(\n await this.resolve(this.boundWitnessDiviner),\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 = {\n addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema,\n }\n const boundWitnesses = (await bwDiviner.divine([query])).filter(\n // TODO; Replace with sequence\n // bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,\n _ => true,\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\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)]) as Hash[]).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", "import type { Payload } from '@xyo-network/sdk-protocol'\nimport type { ARIMAOptions } from 'arima'\nimport ARIMA from 'arima'\n\nimport type {\n Forecast, ForecastingMethod, PayloadValueTransformer,\n} from '../../../model/index.ts'\n\nexport const commonOpts: ARIMAOptions = { verbose: false }\n\nexport type PredictionPayload = Payload<{ error?: number; value: number }>\n\nexport const configurableArima = (opts: ARIMAOptions = commonOpts, predictionSteps = 10): ForecastingMethod => {\n return (payloads: Payload[], transformer: PayloadValueTransformer): Forecast[] => {\n // If there's no input, there's no prediction\n if (payloads.length === 0) return []\n // Transform all the values\n const values = payloads.map(transformer)\n // Train a model on the training set\n const model = new ARIMA({ ...commonOpts, ...opts }).train(values)\n // Use the trained model to predict the next N values\n const predictions = model.predict(predictionSteps)\n // Convert the predictions into payloads\n return predictions[0].map((value, index) => {\n const error = predictions[1][index]\n return { error, value }\n })\n }\n}\n", "import type { ARIMAOptions } from 'arima'\n\nimport type { ForecastingMethod } from '../../../model/index.ts'\nimport { configurableArima } from '../configurable/index.ts'\n\nexport const arimaOpts: ARIMAOptions = {\n d: 1, p: 2, q: 2,\n}\n\nexport const arimaForecastingName = 'arimaForecasting'\n\nexport const arimaForecastingMethod: ForecastingMethod = configurableArima(arimaOpts)\n", "import type { ARIMAOptions } from 'arima'\n\nimport type { ForecastingMethod } from '../../../model/index.ts'\nimport { configurableArima } from '../configurable/index.ts'\n\nexport const seasonalArimaOpts: ARIMAOptions = {\n D: 0, P: 1, Q: 1, d: 1, p: 2, q: 2, s: 12,\n}\n\nexport const seasonalArimaForecastingName = 'seasonalArimaForecasting'\n\nexport const seasonalArimaForecastingMethod: ForecastingMethod = configurableArima(seasonalArimaOpts)\n"],
5
+ "mappings": ";AACA,SAAS,uBAAuB;AAMhC,SAAS,sBAAsB;;;ACN/B;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AAEP,SAAS,wBAAwB;AAGjC,SAAS,YAAAA,iBAAgB;AACzB,YAAY,OAAO;;;ACTnB,SAAS,gBAAgB;AAElB,IAAM,2BAET,SAAS,mCAAmC,IAAI;;;ADW7C,IAAM,iCAETC,UAAS,GAAG,wBAAwB,WAAW,IAAI;AAGhD,IAAM,8BAcP,SAAO,kBAAkB;AAAA,EAC7B,YAAc,WAAW,SAAO,CAAC;AAAA,EACjC,qBAAuB,WAAW,SAAyB,CAAC;AAAA,EAC5D,mBAAqB,WAAW,SAAO,CAAC;AAAA,EACxC,kBAAoB,WAAW,SAAO,CAAC;AAAA,EACvC,oBAAsB,WAAW,SAAO,CAAC;AAAA,EACzC,mBAAqB,W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A,UAAI,eAAe,WAAW,EAAG;AAYjC,aAAO,eAAe,WAAW;AAGjC,YAAM,SAAU,eAAe,IAAI,QAAM,GAAG,eAAe,GAAG,gBAAgB,QAAQ,aAAa,CAAC,CAAC,EAAa,OAAO,MAAM;AAG/H,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;",
6
+ "names": ["asSchema", "asSchema", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "PayloadZodOfSchema", "z", "asSchema", "PayloadZodOfSchema", "zodIsFactory", "zodAsFactory", "zodToFactory"]
7
7
  }
@@ -0,0 +1,22 @@
1
+ import type { ModuleIdentifier } from '@xyo-network/sdk/module-model';
2
+ import type { Payload, Schema } from '@xyo-network/sdk-protocol';
3
+ import type { ForecastingDivinerParams } from '../abstract/index.ts';
4
+ import { AbstractForecastingDiviner } from '../abstract/index.ts';
5
+ import type { arimaForecastingName, seasonalArimaForecastingName } from '../arima/index.ts';
6
+ import type { ForecastingMethod, PayloadValueTransformer } from '../model/index.ts';
7
+ export type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName;
8
+ export declare class MemoryForecastingDiviner<TParams extends ForecastingDivinerParams = ForecastingDivinerParams> extends AbstractForecastingDiviner<TParams> {
9
+ static readonly configSchemas: Schema[];
10
+ static readonly defaultConfigSchema: Schema;
11
+ protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod>;
12
+ get boundWitnessDiviner(): ModuleIdentifier;
13
+ /**
14
+ * The max number of records to search during the batch query
15
+ */
16
+ protected get batchLimit(): number;
17
+ protected get forecastingMethod(): ForecastingMethod;
18
+ protected get maxTrainingLength(): number;
19
+ protected get transformer(): PayloadValueTransformer;
20
+ protected getPayloadsInWindow(_startTimestamp: number, _stopTimestamp: number): Promise<Payload[]>;
21
+ }
22
+ //# sourceMappingURL=MemoryForecastingDiviner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../../src/memory/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,EACI,OAAO,EAAE,MAAM,EAC9B,MAAM,2BAA2B,CAAA;AAGlC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAC7B,MAAM,mBAAmB,CAAA;AAK1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAGnF,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAcxG,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,IAAI,mBAAmB,IAAI,gBAAgB,CAE1C;IAED;;OAEG;IACH,SAAS,KAAK,UAAU,IAAI,MAAM,CAEjC;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,SAAS,KAAK,iBAAiB,IAAI,MAAM,CAExC;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAmDlH"}
@@ -0,0 +1,2 @@
1
+ export * from './MemoryForecastingDiviner.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/memory/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './memory/index.ts';
2
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,224 @@
1
+ // src/memory/MemoryForecastingDiviner.ts
2
+ import { assertEx, exists } from "@ariestools/sdk";
3
+ import { asArchivistInstance } from "@xyo-network/sdk/archivist-model";
4
+ import { BoundWitnessDivinerQuerySchema } from "@xyo-network/sdk/diviner-boundwitness/model";
5
+ import { asDivinerInstance } from "@xyo-network/sdk/diviner-model";
6
+ import { JSONPath } from "jsonpath-plus";
7
+
8
+ // src/abstract/AbstractForecasting.ts
9
+ import { AbstractDiviner } from "@xyo-network/sdk/diviner-abstract";
10
+ import { PayloadBuilder } from "@xyo-network/sdk-protocol";
11
+
12
+ // src/model/Config/Config.ts
13
+ import {
14
+ zodAsFactory,
15
+ zodIsFactory,
16
+ zodToFactory
17
+ } from "@ariestools/sdk";
18
+ import { DivinerConfigZod } from "@xyo-network/sdk/diviner-model";
19
+ import { asSchema as asSchema2 } from "@xyo-network/sdk-protocol";
20
+ import * as z from "zod/mini";
21
+
22
+ // src/model/Schema.ts
23
+ import { asSchema } from "@xyo-network/sdk-protocol";
24
+ var ForecastingDivinerSchema = asSchema("network.xyo.diviner.forecasting", true);
25
+
26
+ // src/model/Config/Config.ts
27
+ var ForecastingDivinerConfigSchema = asSchema2(`${ForecastingDivinerSchema}.config`, true);
28
+ var ForecastingDivinerConfigZod = z.extend(DivinerConfigZod, {
29
+ batchLimit: z.optional(z.number()),
30
+ boundWitnessDiviner: z.optional(z.custom()),
31
+ forecastingMethod: z.optional(z.string()),
32
+ forecastingSteps: z.optional(z.number()),
33
+ jsonPathExpression: z.optional(z.string()),
34
+ maxTrainingLength: z.optional(z.number()),
35
+ schema: z.literal(ForecastingDivinerConfigSchema),
36
+ windowSize: z.optional(z.number()),
37
+ witnessAddresses: z.optional(z.array(z.custom())),
38
+ witnessSchema: z.optional(z.custom())
39
+ });
40
+ var isForecastingDivinerConfig = zodIsFactory(ForecastingDivinerConfigZod);
41
+ var asForecastingDivinerConfig = zodAsFactory(ForecastingDivinerConfigZod, "asForecastingDivinerConfig");
42
+ var toForecastingDivinerConfig = zodToFactory(ForecastingDivinerConfigZod, "toForecastingDivinerConfig");
43
+
44
+ // src/model/Payload/Payload.ts
45
+ import {
46
+ zodAsFactory as zodAsFactory2,
47
+ zodIsFactory as zodIsFactory2,
48
+ zodToFactory as zodToFactory2
49
+ } from "@ariestools/sdk";
50
+ import { asSchema as asSchema3, PayloadZodOfSchema } from "@xyo-network/sdk-protocol";
51
+ import * as z2 from "zod/mini";
52
+ var ForecastPayloadSchema = asSchema3(`${ForecastingDivinerSchema}.forecast`, true);
53
+ var ForecastPayloadZod = z2.extend(PayloadZodOfSchema(ForecastPayloadSchema), {
54
+ sources: z2.array(z2.string()),
55
+ values: z2.array(z2.custom())
56
+ });
57
+ var isForecastPayload = zodIsFactory2(ForecastPayloadZod);
58
+ var asForecastPayload = zodAsFactory2(ForecastPayloadZod, "asForecastPayload");
59
+ var toForecastPayload = zodToFactory2(ForecastPayloadZod, "toForecastPayload");
60
+
61
+ // src/model/Query.ts
62
+ import {
63
+ zodAsFactory as zodAsFactory3,
64
+ zodIsFactory as zodIsFactory3,
65
+ zodToFactory as zodToFactory3
66
+ } from "@ariestools/sdk";
67
+ import {
68
+ asSchema as asSchema4,
69
+ PayloadZodOfSchema as PayloadZodOfSchema2,
70
+ QueryFieldsZod
71
+ } from "@xyo-network/sdk-protocol";
72
+ import * as z3 from "zod/mini";
73
+ var ForecastingDivinerQuerySchema = asSchema4(`${ForecastingDivinerSchema}.query`, true);
74
+ var ForecastingDivinerQueryPayloadZod = z3.extend(PayloadZodOfSchema2(ForecastingDivinerQuerySchema), {
75
+ ...QueryFieldsZod.shape,
76
+ batchLimit: z3.optional(z3.number()),
77
+ forecastingMethod: z3.optional(z3.string()),
78
+ forecastingSteps: z3.optional(z3.number()),
79
+ maxTrainingLength: z3.optional(z3.number()),
80
+ timestamp: z3.optional(z3.number()),
81
+ windowSize: z3.optional(z3.number()),
82
+ witnessAddresses: z3.optional(z3.array(z3.custom())),
83
+ witnessSchema: z3.optional(z3.custom())
84
+ });
85
+ var isForecastingDivinerQueryPayload = zodIsFactory3(ForecastingDivinerQueryPayloadZod);
86
+ var asForecastingDivinerQueryPayload = zodAsFactory3(ForecastingDivinerQueryPayloadZod, "asForecastingDivinerQueryPayload");
87
+ var toForecastingDivinerQueryPayload = zodToFactory3(ForecastingDivinerQueryPayloadZod, "toForecastingDivinerQueryPayload");
88
+
89
+ // src/abstract/AbstractForecasting.ts
90
+ var AbstractForecastingDiviner = class extends AbstractDiviner {
91
+ static configSchemas = [...super.configSchemas, ForecastingDivinerConfigSchema];
92
+ static defaultConfigSchema = ForecastingDivinerConfigSchema;
93
+ async divineHandler(payloads) {
94
+ const query = payloads?.find(isForecastingDivinerQueryPayload);
95
+ if (!query) return [];
96
+ const windowSettings = { ...this.config, ...this.query };
97
+ const stopTimestamp = query.timestamp ?? Date.now();
98
+ const startTimestamp = windowSettings.windowSize ? stopTimestamp - windowSettings.windowSize : 0;
99
+ const data = await this.getPayloadsInWindow(startTimestamp, stopTimestamp);
100
+ const sources = await PayloadBuilder.dataHashes(data);
101
+ const values = await this.forecastingMethod(data, this.transformer);
102
+ const response = {
103
+ schema: ForecastPayloadSchema,
104
+ sources,
105
+ values
106
+ };
107
+ return [response];
108
+ }
109
+ };
110
+
111
+ // src/arima/arima/configurable/configurableArima.ts
112
+ import ARIMA from "arima";
113
+ var commonOpts = { verbose: false };
114
+ var configurableArima = (opts = commonOpts, predictionSteps = 10) => {
115
+ return (payloads, transformer) => {
116
+ if (payloads.length === 0) return [];
117
+ const values = payloads.map(transformer);
118
+ const model = new ARIMA({ ...commonOpts, ...opts }).train(values);
119
+ const predictions = model.predict(predictionSteps);
120
+ return predictions[0].map((value, index) => {
121
+ const error = predictions[1][index];
122
+ return { error, value };
123
+ });
124
+ };
125
+ };
126
+
127
+ // src/arima/arima/configured/arima.ts
128
+ var arimaOpts = {
129
+ d: 1,
130
+ p: 2,
131
+ q: 2
132
+ };
133
+ var arimaForecastingMethod = configurableArima(arimaOpts);
134
+
135
+ // src/arima/arima/configured/seasonalArima.ts
136
+ var seasonalArimaOpts = {
137
+ D: 0,
138
+ P: 1,
139
+ Q: 1,
140
+ d: 1,
141
+ p: 2,
142
+ q: 2,
143
+ s: 12
144
+ };
145
+ var seasonalArimaForecastingMethod = configurableArima(seasonalArimaOpts);
146
+
147
+ // src/memory/MemoryForecastingDiviner.ts
148
+ var getJsonPathTransformer = (pathExpression) => {
149
+ return (x) => {
150
+ const ret = JSONPath({ path: pathExpression, json: x })[0];
151
+ if (typeof ret === "number") return ret;
152
+ throw new Error("Parsed invalid payload value");
153
+ };
154
+ };
155
+ var defaultBatchLimit = 1e3;
156
+ var defaultMaxTrainingLength = 1e4;
157
+ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractForecastingDiviner {
158
+ static configSchemas = [...super.configSchemas, ForecastingDivinerConfigSchema];
159
+ static defaultConfigSchema = ForecastingDivinerConfigSchema;
160
+ static forecastingMethodDict = {
161
+ arimaForecasting: arimaForecastingMethod,
162
+ seasonalArimaForecasting: seasonalArimaForecastingMethod
163
+ };
164
+ get boundWitnessDiviner() {
165
+ return assertEx(this.config.boundWitnessDiviner, () => "No boundWitnessDiviner configured");
166
+ }
167
+ /**
168
+ * The max number of records to search during the batch query
169
+ */
170
+ get batchLimit() {
171
+ return this.config.batchLimit ?? defaultBatchLimit;
172
+ }
173
+ get forecastingMethod() {
174
+ const forecastingMethodName = assertEx(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
175
+ const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
176
+ if (forecastingMethod) return forecastingMethod;
177
+ throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
178
+ }
179
+ get maxTrainingLength() {
180
+ return this.config.maxTrainingLength ?? defaultMaxTrainingLength;
181
+ }
182
+ get transformer() {
183
+ const pathExpression = assertEx(this.config.jsonPathExpression, () => "Missing jsonPathExpression in config");
184
+ return getJsonPathTransformer(pathExpression);
185
+ }
186
+ async getPayloadsInWindow(_startTimestamp, _stopTimestamp) {
187
+ const addresses = this.config.witnessAddresses;
188
+ const payload_schemas = [assertEx(this.config.witnessSchema, () => "Missing witnessSchema in config")];
189
+ const payloads = [];
190
+ const archivist = asArchivistInstance(await this.archivistInstance(), () => "Unable to resolve archivist", { required: true });
191
+ const bwDiviner = asDivinerInstance(
192
+ await this.resolve(this.boundWitnessDiviner),
193
+ "Unable to resolve boundWitnessDiviner"
194
+ );
195
+ const limit = this.batchLimit;
196
+ const witnessSchema = assertEx(this.config.witnessSchema, () => "Missing witnessSchema in config");
197
+ let more = true;
198
+ while (more || payloads.length < this.maxTrainingLength) {
199
+ const query = {
200
+ addresses,
201
+ limit,
202
+ payload_schemas,
203
+ schema: BoundWitnessDivinerQuerySchema
204
+ };
205
+ const boundWitnesses = (await bwDiviner.divine([query])).filter(
206
+ // TODO; Replace with sequence
207
+ // bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,
208
+ (_) => true
209
+ );
210
+ if (boundWitnesses.length === 0) break;
211
+ more = boundWitnesses.length === limit;
212
+ const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
213
+ if (hashes.length > 0) {
214
+ const batchPayloads = (await archivist.get(hashes)).filter(exists);
215
+ payloads.push(...batchPayloads);
216
+ }
217
+ }
218
+ return payloads;
219
+ }
220
+ };
221
+ export {
222
+ MemoryForecastingDiviner
223
+ };
224
+ //# sourceMappingURL=memory.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/memory/MemoryForecastingDiviner.ts", "../../src/abstract/AbstractForecasting.ts", "../../src/model/Config/Config.ts", "../../src/model/Schema.ts", "../../src/model/Payload/Payload.ts", "../../src/model/Query.ts", "../../src/arima/arima/configurable/configurableArima.ts", "../../src/arima/arima/configured/arima.ts", "../../src/arima/arima/configured/seasonalArima.ts"],
4
+ "sourcesContent": ["import type { Hash } from '@ariestools/sdk'\nimport { assertEx, exists } from '@ariestools/sdk'\nimport { asArchivistInstance } from '@xyo-network/sdk/archivist-model'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport type { DivinerInstance } from '@xyo-network/sdk/diviner-model'\nimport { asDivinerInstance } from '@xyo-network/sdk/diviner-model'\nimport type { ModuleIdentifier } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol'\nimport { JSONPath } from 'jsonpath-plus'\n\nimport type { ForecastingDivinerParams } from '../abstract/index.ts'\nimport { AbstractForecastingDiviner } from '../abstract/index.ts'\nimport type {\n arimaForecastingName,\n seasonalArimaForecastingName,\n} from '../arima/index.ts'\nimport {\n arimaForecastingMethod,\n seasonalArimaForecastingMethod,\n} from '../arima/index.ts'\nimport type { ForecastingMethod, PayloadValueTransformer } from '../model/index.ts'\nimport { ForecastingDivinerConfigSchema } from '../model/index.ts'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n return (x: Payload): number => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const ret = JSONPath({ path: pathExpression, json: x })[0]\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n}\n\nconst defaultBatchLimit = 1000\nconst defaultMaxTrainingLength = 10_000\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 get boundWitnessDiviner(): ModuleIdentifier {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured')\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected get batchLimit(): number {\n return this.config.batchLimit ?? defaultBatchLimit\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 get maxTrainingLength(): number {\n return this.config.maxTrainingLength ?? defaultMaxTrainingLength\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', { required: true })\n // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style\n const bwDiviner = asDivinerInstance(\n await this.resolve(this.boundWitnessDiviner),\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 = {\n addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema,\n }\n const boundWitnesses = (await bwDiviner.divine([query])).filter(\n // TODO; Replace with sequence\n // bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,\n _ => true,\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\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)]) as Hash[]).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", "import type { Promisable } from '@ariestools/sdk'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type {\n DivinerInstance, DivinerModuleEventData, DivinerParams,\n} from '@xyo-network/sdk/diviner-model'\nimport type { AnyConfigSchema } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\n\nimport type {\n ForecastingDivinerConfig,\n ForecastingDivinerQueryPayload,\n ForecastingMethod,\n ForecastingSettings,\n ForecastPayload,\n PayloadValueTransformer,\n} from '../model/index.ts'\nimport {\n ForecastingDivinerConfigSchema,\n ForecastPayloadSchema,\n isForecastingDivinerQueryPayload,\n} from '../model/index.ts'\n\nexport type ForecastingDivinerParams = DivinerParams<AnyConfigSchema<ForecastingDivinerConfig>>\n\nexport abstract class AbstractForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n TIn extends ForecastingDivinerQueryPayload = ForecastingDivinerQueryPayload,\n TOut extends ForecastPayload = ForecastPayload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = ForecastingDivinerConfigSchema\n\n protected abstract get forecastingMethod(): ForecastingMethod\n protected abstract get transformer(): PayloadValueTransformer\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const query = payloads?.find(isForecastingDivinerQueryPayload)\n if (!query) return []\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const windowSettings: ForecastingSettings = { ...this.config, ...this.query }\n const stopTimestamp = query.timestamp ?? Date.now()\n const startTimestamp = windowSettings.windowSize ? stopTimestamp - windowSettings.windowSize : 0\n const data = await this.getPayloadsInWindow(startTimestamp, stopTimestamp)\n const sources = await PayloadBuilder.dataHashes(data)\n const values = await this.forecastingMethod(data, this.transformer)\n const response: ForecastPayload = {\n schema: ForecastPayloadSchema, sources, values,\n }\n return [response as TOut]\n }\n\n protected abstract getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promisable<Payload[]>\n}\n", "import type { Address } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport type { ModuleIdentifier } from '@xyo-network/sdk/module-model'\nimport type { Schema } from '@xyo-network/sdk-protocol'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { ForecastingDivinerSchema } from '../Schema.ts'\nimport type { ForecastingSettings } from './ForecastingSettings.ts'\nimport type { TransformerSettings } from './TransformerSettings.ts'\n\nexport const ForecastingDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${ForecastingDivinerSchema}.config`, true)\nexport type ForecastingDivinerConfigSchema = typeof ForecastingDivinerConfigSchema\n\nexport const ForecastingDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n batchLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n boundWitnessDiviner: z.ZodMiniOptional<z.ZodMiniCustom<ModuleIdentifier, ModuleIdentifier>>\n forecastingMethod: z.ZodMiniOptional<z.ZodMiniString<string>>\n forecastingSteps: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n jsonPathExpression: z.ZodMiniOptional<z.ZodMiniString<string>>\n maxTrainingLength: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<ForecastingDivinerConfigSchema>\n windowSize: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n witnessAddresses: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniCustom<Address, Address>>>\n witnessSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n batchLimit: z.optional(z.number()),\n boundWitnessDiviner: z.optional(z.custom<ModuleIdentifier>()),\n forecastingMethod: z.optional(z.string()),\n forecastingSteps: z.optional(z.number()),\n jsonPathExpression: z.optional(z.string()),\n maxTrainingLength: z.optional(z.number()),\n schema: z.literal(ForecastingDivinerConfigSchema),\n windowSize: z.optional(z.number()),\n witnessAddresses: z.optional(z.array(z.custom<Address>())),\n witnessSchema: z.optional(z.custom<Schema>()),\n})\n\nexport type ForecastingDivinerConfig = DivinerConfig<\n {\n boundWitnessDiviner?: ModuleIdentifier\n schema: ForecastingDivinerConfigSchema\n } & ForecastingSettings\n & TransformerSettings\n>\n\nexport const isForecastingDivinerConfig: ReturnType<typeof zodIsFactory<ForecastingDivinerConfig>> = zodIsFactory(ForecastingDivinerConfigZod)\nexport const asForecastingDivinerConfig: ReturnType<typeof zodAsFactory<ForecastingDivinerConfig>> = zodAsFactory(ForecastingDivinerConfigZod, 'asForecastingDivinerConfig')\nexport const toForecastingDivinerConfig: ReturnType<typeof zodToFactory<ForecastingDivinerConfig>> = zodToFactory(ForecastingDivinerConfigZod, 'toForecastingDivinerConfig')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const ForecastingDivinerSchema: 'network.xyo.diviner.forecasting' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.forecasting', true)\nexport type ForecastingDivinerSchema = typeof ForecastingDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { ForecastingDivinerSchema } from '../Schema.ts'\nimport type { Forecast } from './Forecast.ts'\n\nexport const ForecastPayloadSchema: string & {\n readonly __schema: true\n} = asSchema(`${ForecastingDivinerSchema}.forecast`, true)\nexport type ForecastPayloadSchema = typeof ForecastPayloadSchema\n\nexport const ForecastPayloadZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<ForecastPayloadSchema>\n sources: z.ZodMiniArray<z.ZodMiniString<string>>\n values: z.ZodMiniArray<z.ZodMiniCustom<Forecast, Forecast>>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(ForecastPayloadSchema), {\n sources: z.array(z.string()),\n values: z.array(z.custom<Forecast>()),\n})\n\nexport type ForecastPayload = z.infer<typeof ForecastPayloadZod>\n\nexport const isForecastPayload: ReturnType<typeof zodIsFactory<ForecastPayload>> = zodIsFactory(ForecastPayloadZod)\nexport const asForecastPayload: ReturnType<typeof zodAsFactory<ForecastPayload>> = zodAsFactory(ForecastPayloadZod, 'asForecastPayload')\nexport const toForecastPayload: ReturnType<typeof zodToFactory<ForecastPayload>> = zodToFactory(ForecastPayloadZod, 'toForecastPayload')\n", "import type { Address } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { Schema } from '@xyo-network/sdk-protocol'\nimport {\n asSchema, PayloadZodOfSchema, QueryFieldsZod,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { ForecastingDivinerSchema } from './Schema.ts'\n\nexport const ForecastingDivinerQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${ForecastingDivinerSchema}.query`, true)\nexport type ForecastingDivinerQuerySchema = typeof ForecastingDivinerQuerySchema\n\nexport const ForecastingDivinerQueryPayloadZod: z.ZodMiniObject<\n & { schema: z.ZodMiniLiteral<ForecastingDivinerQuerySchema> }\n & (typeof QueryFieldsZod)['shape']\n & {\n batchLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n forecastingMethod: z.ZodMiniOptional<z.ZodMiniString<string>>\n forecastingSteps: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n maxTrainingLength: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n timestamp: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n windowSize: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n witnessAddresses: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniCustom<Address, Address>>>\n witnessSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n },\n z.core.$strip\n> = z.extend(PayloadZodOfSchema(ForecastingDivinerQuerySchema), {\n ...QueryFieldsZod.shape,\n batchLimit: z.optional(z.number()),\n forecastingMethod: z.optional(z.string()),\n forecastingSteps: z.optional(z.number()),\n maxTrainingLength: z.optional(z.number()),\n timestamp: z.optional(z.number()),\n windowSize: z.optional(z.number()),\n witnessAddresses: z.optional(z.array(z.custom<Address>())),\n witnessSchema: z.optional(z.custom<Schema>()),\n})\n\nexport type ForecastingDivinerQueryPayload = z.infer<typeof ForecastingDivinerQueryPayloadZod>\n\nexport const isForecastingDivinerQueryPayload: ReturnType<typeof zodIsFactory<ForecastingDivinerQueryPayload>> = zodIsFactory(ForecastingDivinerQueryPayloadZod)\nexport const asForecastingDivinerQueryPayload: ReturnType<typeof zodAsFactory<ForecastingDivinerQueryPayload>> = zodAsFactory(ForecastingDivinerQueryPayloadZod, 'asForecastingDivinerQueryPayload')\nexport const toForecastingDivinerQueryPayload: ReturnType<typeof zodToFactory<ForecastingDivinerQueryPayload>> = zodToFactory(ForecastingDivinerQueryPayloadZod, 'toForecastingDivinerQueryPayload')\n", "import type { Payload } from '@xyo-network/sdk-protocol'\nimport type { ARIMAOptions } from 'arima'\nimport ARIMA from 'arima'\n\nimport type {\n Forecast, ForecastingMethod, PayloadValueTransformer,\n} from '../../../model/index.ts'\n\nexport const commonOpts: ARIMAOptions = { verbose: false }\n\nexport type PredictionPayload = Payload<{ error?: number; value: number }>\n\nexport const configurableArima = (opts: ARIMAOptions = commonOpts, predictionSteps = 10): ForecastingMethod => {\n return (payloads: Payload[], transformer: PayloadValueTransformer): Forecast[] => {\n // If there's no input, there's no prediction\n if (payloads.length === 0) return []\n // Transform all the values\n const values = payloads.map(transformer)\n // Train a model on the training set\n const model = new ARIMA({ ...commonOpts, ...opts }).train(values)\n // Use the trained model to predict the next N values\n const predictions = model.predict(predictionSteps)\n // Convert the predictions into payloads\n return predictions[0].map((value, index) => {\n const error = predictions[1][index]\n return { error, value }\n })\n }\n}\n", "import type { ARIMAOptions } from 'arima'\n\nimport type { ForecastingMethod } from '../../../model/index.ts'\nimport { configurableArima } from '../configurable/index.ts'\n\nexport const arimaOpts: ARIMAOptions = {\n d: 1, p: 2, q: 2,\n}\n\nexport const arimaForecastingName = 'arimaForecasting'\n\nexport const arimaForecastingMethod: ForecastingMethod = configurableArima(arimaOpts)\n", "import type { ARIMAOptions } from 'arima'\n\nimport type { ForecastingMethod } from '../../../model/index.ts'\nimport { configurableArima } from '../configurable/index.ts'\n\nexport const seasonalArimaOpts: ARIMAOptions = {\n D: 0, P: 1, Q: 1, d: 1, p: 2, q: 2, s: 12,\n}\n\nexport const seasonalArimaForecastingName = 'seasonalArimaForecasting'\n\nexport const seasonalArimaForecastingMethod: ForecastingMethod = configurableArima(seasonalArimaOpts)\n"],
5
+ "mappings": ";AACA,SAAS,UAAU,cAAc;AACjC,SAAS,2BAA2B;AAEpC,SAAS,sCAAsC;AAE/C,SAAS,yBAAyB;AAKlC,SAAS,gBAAgB;;;ACVzB,SAAS,uBAAuB;AAMhC,SAAS,sBAAsB;;;ACN/B;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AAEP,SAAS,wBAAwB;AAGjC,SAAS,YAAAA,iBAAgB;AACzB,YAAY,OAAO;;;ACTnB,SAAS,gBAAgB;AAElB,IAAM,2BAET,SAAS,mCAAmC,IAAI;;;ADW7C,IAAM,iCAETC,UAAS,GAAG,wBAAwB,WAAW,IAAI;AAGhD,IAAM,8BAcP,SAAO,kBAAkB;AAAA,EAC7B,YAAc,WAAW,SAAO,CAAC;AAAA,EACjC,qBAAuB,WAAW,SAAyB,CAAC;AAAA,EAC5D,mBAAqB,WAAW,SAAO,CAAC;AAAA,EACxC,kBAAoB,WAAW,SAAO,CAAC;AAAA,EACvC,oBAAsB,WAAW,SAAO,CAAC;AAAA,EACzC,mBAAqB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AgB,QAAQ,aAAa,CAAC,CAAC,EAAa,OAAO,MAAM;AAG/H,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;",
6
+ "names": ["asSchema", "asSchema", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "PayloadZodOfSchema", "z", "asSchema", "PayloadZodOfSchema", "zodIsFactory", "zodAsFactory", "zodToFactory"]
7
+ }
@@ -0,0 +1,33 @@
1
+ import type { Address } from '@ariestools/sdk';
2
+ import { zodAsFactory, zodIsFactory, zodToFactory } from '@ariestools/sdk';
3
+ import type { DivinerConfig } from '@xyo-network/sdk/diviner-model';
4
+ import { DivinerConfigZod } from '@xyo-network/sdk/diviner-model';
5
+ import type { ModuleIdentifier } from '@xyo-network/sdk/module-model';
6
+ import type { Schema } from '@xyo-network/sdk-protocol';
7
+ import * as z from 'zod/mini';
8
+ import type { ForecastingSettings } from './ForecastingSettings.ts';
9
+ import type { TransformerSettings } from './TransformerSettings.ts';
10
+ export declare const ForecastingDivinerConfigSchema: string & {
11
+ readonly __schema: true;
12
+ };
13
+ export type ForecastingDivinerConfigSchema = typeof ForecastingDivinerConfigSchema;
14
+ export declare const ForecastingDivinerConfigZod: z.ZodMiniObject<Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {
15
+ batchLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
16
+ boundWitnessDiviner: z.ZodMiniOptional<z.ZodMiniCustom<ModuleIdentifier, ModuleIdentifier>>;
17
+ forecastingMethod: z.ZodMiniOptional<z.ZodMiniString<string>>;
18
+ forecastingSteps: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
19
+ jsonPathExpression: z.ZodMiniOptional<z.ZodMiniString<string>>;
20
+ maxTrainingLength: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
21
+ schema: z.ZodMiniLiteral<ForecastingDivinerConfigSchema>;
22
+ windowSize: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
23
+ witnessAddresses: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniCustom<Address, Address>>>;
24
+ witnessSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>;
25
+ }, z.core.$strip>;
26
+ export type ForecastingDivinerConfig = DivinerConfig<{
27
+ boundWitnessDiviner?: ModuleIdentifier;
28
+ schema: ForecastingDivinerConfigSchema;
29
+ } & ForecastingSettings & TransformerSettings>;
30
+ export declare const isForecastingDivinerConfig: ReturnType<typeof zodIsFactory<ForecastingDivinerConfig>>;
31
+ export declare const asForecastingDivinerConfig: ReturnType<typeof zodAsFactory<ForecastingDivinerConfig>>;
32
+ export declare const toForecastingDivinerConfig: ReturnType<typeof zodToFactory<ForecastingDivinerConfig>>;
33
+ //# sourceMappingURL=Config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../../src/model/Config/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EACL,YAAY,EAAE,YAAY,EAAE,YAAY,EACzC,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAG7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK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AAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAClE,EACD,CAAC,CAAC,IAAI,CAAC,MAAM,CAYb,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAClD;IACE,mBAAmB,CAAC,EAAE,gBAAgB,CAAA;IACtC,MAAM,EAAE,8BAA8B,CAAA;CACvC,GAAG,mBAAmB,GACrB,mBAAmB,CACtB,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,wBAAwB,CAAC,CAA6C,CAAA;AAC9I,eAAO,MAAM,0BAA0B,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,wBAAwB,CAAC,CAA2E,CAAA;AAC5K,eAAO,MAAM,0BAA0B,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,wBAAwB,CAAC,CAA2E,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Address } from '@ariestools/sdk';
2
+ import type { Schema } from '@xyo-network/sdk-protocol';
3
+ export interface ForecastingSettings {
4
+ batchLimit?: number;
5
+ forecastingMethod?: string;
6
+ forecastingSteps?: number;
7
+ maxTrainingLength?: number;
8
+ windowSize?: number;
9
+ witnessAddresses?: Address[];
10
+ witnessSchema?: Schema;
11
+ }
12
+ //# sourceMappingURL=ForecastingSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForecastingSettings.d.ts","sourceRoot":"","sources":["../../../../src/model/Config/ForecastingSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEvD,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB"}
@@ -0,0 +1,4 @@
1
+ export interface TransformerSettings {
2
+ jsonPathExpression?: string;
3
+ }
4
+ //# sourceMappingURL=TransformerSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransformerSettings.d.ts","sourceRoot":"","sources":["../../../../src/model/Config/TransformerSettings.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B"}
@@ -0,0 +1,4 @@
1
+ export * from './Config.ts';
2
+ export * from './ForecastingSettings.ts';
3
+ export * from './TransformerSettings.ts';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/model/Config/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { Promisable } from '@ariestools/sdk';
2
+ import type { Payload } from '@xyo-network/sdk-protocol';
3
+ import type { Forecast } from './Payload/index.ts';
4
+ import type { PayloadValueTransformer } from './PayloadValueTransformer.ts';
5
+ export type ForecastingMethod = (payloads: Payload[], transformers: PayloadValueTransformer) => Promisable<Forecast[]>;
6
+ //# sourceMappingURL=ForecastingMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForecastingMethod.d.ts","sourceRoot":"","sources":["../../../src/model/ForecastingMethod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAE3E,MAAM,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,YAAY,EAAE,uBAAuB,KAAK,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ export interface Forecast {
2
+ error?: number;
3
+ timestamp?: number;
4
+ value: number;
5
+ }
6
+ //# sourceMappingURL=Forecast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Forecast.d.ts","sourceRoot":"","sources":["../../../../src/model/Payload/Forecast.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd"}
@@ -0,0 +1,17 @@
1
+ import { zodAsFactory, zodIsFactory, zodToFactory } from '@ariestools/sdk';
2
+ import * as z from 'zod/mini';
3
+ import type { Forecast } from './Forecast.ts';
4
+ export declare const ForecastPayloadSchema: string & {
5
+ readonly __schema: true;
6
+ };
7
+ export type ForecastPayloadSchema = typeof ForecastPayloadSchema;
8
+ export declare const ForecastPayloadZod: z.ZodMiniObject<{
9
+ schema: z.ZodMiniLiteral<ForecastPayloadSchema>;
10
+ sources: z.ZodMiniArray<z.ZodMiniString<string>>;
11
+ values: z.ZodMiniArray<z.ZodMiniCustom<Forecast, Forecast>>;
12
+ }, z.core.$strip>;
13
+ export type ForecastPayload = z.infer<typeof ForecastPayloadZod>;
14
+ export declare const isForecastPayload: ReturnType<typeof zodIsFactory<ForecastPayload>>;
15
+ export declare const asForecastPayload: ReturnType<typeof zodAsFactory<ForecastPayload>>;
16
+ export declare const toForecastPayload: ReturnType<typeof zodToFactory<ForecastPayload>>;
17
+ //# sourceMappingURL=Payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Payload.d.ts","sourceRoot":"","sources":["../../../../src/model/Payload/Payload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAAE,YAAY,EAAE,YAAY,EACzC,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAG7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,eAAO,MAAM,qBAAqB,EAAE,MAAM,GAAG;IAC3C,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CACiC,CAAA;AAC1D,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAA;AAEhE,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,aAAa,CAAC;IAC/C,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAA;IAC/C,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IAChD,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;CAC5D,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAGd,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEhE,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,eAAe,CAAC,CAAoC,CAAA;AACnH,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,eAAe,CAAC,CAAyD,CAAA;AACxI,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,eAAe,CAAC,CAAyD,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './Forecast.ts';
2
+ export * from './Payload.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/model/Payload/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Payload } from '@xyo-network/sdk-protocol';
2
+ export type PayloadValueTransformer = (payload: Payload) => number;
3
+ //# sourceMappingURL=PayloadValueTransformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PayloadValueTransformer.d.ts","sourceRoot":"","sources":["../../../src/model/PayloadValueTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAA"}
@@ -0,0 +1,26 @@
1
+ import type { Address } from '@ariestools/sdk';
2
+ import { zodAsFactory, zodIsFactory, zodToFactory } from '@ariestools/sdk';
3
+ import type { Schema } from '@xyo-network/sdk-protocol';
4
+ import { QueryFieldsZod } from '@xyo-network/sdk-protocol';
5
+ import * as z from 'zod/mini';
6
+ export declare const ForecastingDivinerQuerySchema: string & {
7
+ readonly __schema: true;
8
+ };
9
+ export type ForecastingDivinerQuerySchema = typeof ForecastingDivinerQuerySchema;
10
+ export declare const ForecastingDivinerQueryPayloadZod: z.ZodMiniObject<{
11
+ schema: z.ZodMiniLiteral<ForecastingDivinerQuerySchema>;
12
+ } & (typeof QueryFieldsZod)['shape'] & {
13
+ batchLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
14
+ forecastingMethod: z.ZodMiniOptional<z.ZodMiniString<string>>;
15
+ forecastingSteps: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
16
+ maxTrainingLength: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
17
+ timestamp: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
18
+ windowSize: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
19
+ witnessAddresses: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniCustom<Address, Address>>>;
20
+ witnessSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>;
21
+ }, z.core.$strip>;
22
+ export type ForecastingDivinerQueryPayload = z.infer<typeof ForecastingDivinerQueryPayloadZod>;
23
+ export declare const isForecastingDivinerQueryPayload: ReturnType<typeof zodIsFactory<ForecastingDivinerQueryPayload>>;
24
+ export declare const asForecastingDivinerQueryPayload: ReturnType<typeof zodAsFactory<ForecastingDivinerQueryPayload>>;
25
+ export declare const toForecastingDivinerQueryPayload: ReturnType<typeof zodToFactory<ForecastingDivinerQueryPayload>>;
26
+ //# sourceMappingURL=Query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Query.d.ts","sourceRoot":"","sources":["../../../src/model/Query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EACL,YAAY,EAAE,YAAY,EAAE,YAAY,EACzC,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EACyB,cAAc,EAC7C,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAI7B,eAAO,MAAM,6BAA6B,EAAE,MAAM,GAAG;IACnD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAC8B,CAAA;AACvD,MAAM,MAAM,6BAA6B,GAAG,OAAO,6BAA6B,CAAA;AAEhF,eAAO,MAAM,iCAAiC,EAAE,CAAC,CAAC,aAAa,CAC3D;IAAE,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC,6BAA6B,CAAC,CAAA;CAAE,GAC3D,CAAC,OAAO,cAAc,CAAC,CAAC,OAAO,CAAC,GAChC;IACA,UAAU,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IACtD,iBAAiB,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7D,gBAAgB,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5D,iBAAiB,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7D,SAAS,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IACrD,UAAU,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IACtD,gBAAgB,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACtF,aAAa,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAClE,EACD,CAAC,CAAC,IAAI,CAAC,MAAM,CAWb,CAAA;AAEF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAE9F,eAAO,MAAM,gCAAgC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,8BAA8B,CAAC,CAAmD,CAAA;AAChK,eAAO,MAAM,gCAAgC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,8BAA8B,CAAC,CAAuF,CAAA;AACpM,eAAO,MAAM,gCAAgC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,8BAA8B,CAAC,CAAuF,CAAA"}
@@ -0,0 +1,5 @@
1
+ export declare const ForecastingDivinerSchema: 'network.xyo.diviner.forecasting' & {
2
+ readonly __schema: true;
3
+ };
4
+ export type ForecastingDivinerSchema = typeof ForecastingDivinerSchema;
5
+ //# sourceMappingURL=Schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/model/Schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,EAAE,iCAAiC,GAAG;IACzE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAC4B,CAAA;AACrD,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAA"}
@@ -0,0 +1,7 @@
1
+ export * from './Config/index.ts';
2
+ export * from './ForecastingMethod.ts';
3
+ export * from './Payload/index.ts';
4
+ export * from './PayloadValueTransformer.ts';
5
+ export * from './Query.ts';
6
+ export * from './Schema.ts';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './model/index.ts';
2
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}