@xyo-network/diviner-forecasting 7.4.2 → 8.0.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.
- package/dist/neutral/abstract/AbstractForecasting.d.ts.map +1 -1
- package/dist/neutral/abstract.mjs +2 -1
- package/dist/neutral/abstract.mjs.map +2 -2
- package/dist/neutral/index.mjs +7 -4
- package/dist/neutral/index.mjs.map +2 -2
- package/dist/neutral/memory/MemoryForecastingDiviner.d.ts.map +1 -1
- package/dist/neutral/memory.mjs +7 -4
- package/dist/neutral/memory.mjs.map +2 -2
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractForecasting.d.ts","sourceRoot":"","sources":["../../../src/abstract/AbstractForecasting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EACV,eAAe,EAAE,sBAAsB,EAAE,aAAa,EACvD,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAGhE,OAAO,KAAK,EACV,wBAAwB,EACxB,8BAA8B,EAC9B,iBAAiB,EAEjB,eAAe,EACf,uBAAuB,EACxB,MAAM,mBAAmB,CAAA;AAO1B,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC,CAAA;AAE/F,8BAAsB,0BAA0B,CAC9C,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,EACnE,GAAG,SAAS,8BAA8B,GAAG,8BAA8B,EAC3E,IAAI,SAAS,eAAe,GAAG,eAAe,EAC9C,UAAU,SAAS,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,I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AI,SAAS,eAAe,GAAG,eAAe,EAC9C,UAAU,SAAS,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,sBAAsB,CAChH,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EACnC,GAAG,EACH,IAAI,CACL,CACD,SAAQ,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC;IACvD,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAC3G,gBAAyB,mBAAmB,EAAE,MAAM,CAAiC;IAErF,SAAS,CAAC,QAAQ,KAAK,iBAAiB,IAAI,iBAAiB,CAAA;IAC7D,SAAS,CAAC,QAAQ,KAAK,WAAW,IAAI,uBAAuB,CAAA;cAEpC,aAAa,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAiBzE,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;CAC7G"}
|
|
@@ -88,7 +88,8 @@ var AbstractForecastingDiviner = class extends AbstractDiviner {
|
|
|
88
88
|
if (!query) return [];
|
|
89
89
|
const windowSettings = { ...this.config, ...this.query };
|
|
90
90
|
const stopTimestamp = query.timestamp ?? Date.now();
|
|
91
|
-
const
|
|
91
|
+
const windowSize = windowSettings.windowSize;
|
|
92
|
+
const startTimestamp = windowSize !== void 0 && windowSize !== 0 ? stopTimestamp - windowSize : 0;
|
|
92
93
|
const data = await this.getPayloadsInWindow(startTimestamp, stopTimestamp);
|
|
93
94
|
const sources = await PayloadBuilder.dataHashes(data);
|
|
94
95
|
const values = await this.forecastingMethod(data, this.transformer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/abstract/AbstractForecasting.ts", "../../src/model/Config/Config.ts", "../../src/model/Schema.ts", "../../src/model/Payload/Payload.ts", "../../src/model/Query.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,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AClD,UAAM,iBAAiB,eAAe,
|
|
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 windowSize = windowSettings.windowSize\n const startTimestamp = windowSize !== undefined && windowSize !== 0 ? stopTimestamp - 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"],
|
|
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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F;",
|
|
6
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
|
}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -88,7 +88,8 @@ var AbstractForecastingDiviner = class extends AbstractDiviner {
|
|
|
88
88
|
if (!query) return [];
|
|
89
89
|
const windowSettings = { ...this.config, ...this.query };
|
|
90
90
|
const stopTimestamp = query.timestamp ?? Date.now();
|
|
91
|
-
const
|
|
91
|
+
const windowSize = windowSettings.windowSize;
|
|
92
|
+
const startTimestamp = windowSize !== void 0 && windowSize !== 0 ? stopTimestamp - windowSize : 0;
|
|
92
93
|
const data = await this.getPayloadsInWindow(startTimestamp, stopTimestamp);
|
|
93
94
|
const sources = await PayloadBuilder.dataHashes(data);
|
|
94
95
|
const values = await this.forecastingMethod(data, this.transformer);
|
|
@@ -174,7 +175,7 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
174
175
|
get forecastingMethod() {
|
|
175
176
|
const forecastingMethodName = assertEx(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
176
177
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
177
|
-
if (forecastingMethod) return forecastingMethod;
|
|
178
|
+
if (forecastingMethod !== void 0) return forecastingMethod;
|
|
178
179
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
179
180
|
}
|
|
180
181
|
get maxTrainingLength() {
|
|
@@ -203,7 +204,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
203
204
|
payload_schemas,
|
|
204
205
|
schema: BoundWitnessDivinerQuerySchema
|
|
205
206
|
};
|
|
206
|
-
const
|
|
207
|
+
const divineResults = await bwDiviner.divine([query]);
|
|
208
|
+
const boundWitnesses = divineResults.filter(
|
|
207
209
|
// TODO; Replace with sequence
|
|
208
210
|
// bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,
|
|
209
211
|
(_) => true
|
|
@@ -212,7 +214,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
212
214
|
more = boundWitnesses.length === limit;
|
|
213
215
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
|
|
214
216
|
if (hashes.length > 0) {
|
|
215
|
-
const
|
|
217
|
+
const storedPayloads = await archivist.get(hashes);
|
|
218
|
+
const batchPayloads = storedPayloads.filter(exists);
|
|
216
219
|
payloads.push(...batchPayloads);
|
|
217
220
|
}
|
|
218
221
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
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 })\n model.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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C,UAAS,GAAG,wBAAwB,UAAU,IAAI;AAG/C,IAAM,oCAcP,UAAOC,oBAAmB,6BAA6B,GAAG;AAAA,EAC9D,GAAG,eAAe;AAAA,EAClB,YAAc,YAAW,UAAO,CAAC;AAAA,EACjC,mBAAqB,YAAW,UAAO,CAAC;AAAA,EACxC,kBAAoB,YAAW,UAAO,CAAC;AAAA,EACvC,mBAAqB,YAAW,UAAO,CAAC;AAAA,EACxC,WAAa,YAAW,UAAO,CAAC;AAAA,EAChC,YAAc,YAAW,UAAO,CAAC;AAAA,EACjC,kBAAoB,YAAW,SAAQ,UAAgB,CAAC,CAAC;AAAA,EACzD,eAAiB,YAAW,UAAe,CAAC;AAC9C,CAAC;AAIM,IAAM,mCAAoGC,cAAa,iCAAiC;AACxJ,IAAM,mCAAoGC,cAAa,mCAAmC,kCAAkC;AAC5L,IAAM,mCAAoGC,cAAa,mCAAmC,kCAAkC;;;AJtB5L,IAAe,6BAAf,cASG,gBAAgD;AAAA,EACxD,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,8BAA8B;AAAA,EAC1G,OAAyB,sBAA8B;AAAA,EAKvD,MAAyB,cAAc,UAAmC;AACxE,UAAM,QAAQ,UAAU,KAAK,gCAAgC;AAC7D,QAAI,CAAC,MAAO,QAAO,CAAC;AAEpB,UAAM,iBAAsC,EAAE,GAAG,KAAK,QAAQ,GAAG,KAAK,MAAM;AAC5E,UAAM,gBAAgB,MAAM,aAAa,KAAK,IAAI;AAClD,UAAM,iBAAiB,eAAe,
|
|
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 windowSize = windowSettings.windowSize\n const startTimestamp = windowSize !== undefined && windowSize !== 0 ? stopTimestamp - 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 !== undefined) 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 divineResults = await bwDiviner.divine([query])\n const boundWitnesses = divineResults.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 storedPayloads = await archivist.get(hashes)\n const batchPayloads = storedPayloads.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 })\n model.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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AkB,GAAG,MAAM,+BAA+B,EAAE,UAAU,KAAK,CAAC;AAE7H,UAAM,YAAY;AAAA,MAChB,MAAM,KAAK,QAAQ,KAAK,mBAAmB;AAAA,MAC3C;AAAA,IACF;AACA,UAAM,QAAQ,KAAK;AACnB,UAAM,gBAAgB,SAAS,KAAK,OAAO,eAAe,MAAM,iCAAiC;AAEjG,QAAI,OAAO;AAIX,WAAO,QAAQ,SAAS,SAAS,KAAK,mBAAmB;AACvD,YAAM,QAAyC;AAAA,QAC7C;AAAA,QAAW;AAAA,QAAO;AAAA,QAAiB,QAAQ;AAAA,MAC7C;AACA,YAAM,gBAAgB,MAAM,UAAU,OAAO,CAAC,KAAK,CAAC;AACpD,YAAM,iBAAiB,cAAc;AAAA;AAAA;AAAA,QAGnC,OAAK;AAAA,MACP;AACA,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;AACjD,cAAM,gBAAgB,eAAe,OAAO,MAAM;AAClD,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../../src/memory/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAOA,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+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;CAqDlH"}
|
package/dist/neutral/memory.mjs
CHANGED
|
@@ -95,7 +95,8 @@ var AbstractForecastingDiviner = class extends AbstractDiviner {
|
|
|
95
95
|
if (!query) return [];
|
|
96
96
|
const windowSettings = { ...this.config, ...this.query };
|
|
97
97
|
const stopTimestamp = query.timestamp ?? Date.now();
|
|
98
|
-
const
|
|
98
|
+
const windowSize = windowSettings.windowSize;
|
|
99
|
+
const startTimestamp = windowSize !== void 0 && windowSize !== 0 ? stopTimestamp - windowSize : 0;
|
|
99
100
|
const data = await this.getPayloadsInWindow(startTimestamp, stopTimestamp);
|
|
100
101
|
const sources = await PayloadBuilder.dataHashes(data);
|
|
101
102
|
const values = await this.forecastingMethod(data, this.transformer);
|
|
@@ -174,7 +175,7 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
174
175
|
get forecastingMethod() {
|
|
175
176
|
const forecastingMethodName = assertEx(this.config.forecastingMethod, () => "Missing forecastingMethod in config");
|
|
176
177
|
const forecastingMethod = _MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName];
|
|
177
|
-
if (forecastingMethod) return forecastingMethod;
|
|
178
|
+
if (forecastingMethod !== void 0) return forecastingMethod;
|
|
178
179
|
throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`);
|
|
179
180
|
}
|
|
180
181
|
get maxTrainingLength() {
|
|
@@ -203,7 +204,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
203
204
|
payload_schemas,
|
|
204
205
|
schema: BoundWitnessDivinerQuerySchema
|
|
205
206
|
};
|
|
206
|
-
const
|
|
207
|
+
const divineResults = await bwDiviner.divine([query]);
|
|
208
|
+
const boundWitnesses = divineResults.filter(
|
|
207
209
|
// TODO; Replace with sequence
|
|
208
210
|
// bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,
|
|
209
211
|
(_) => true
|
|
@@ -212,7 +214,8 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
|
|
|
212
214
|
more = boundWitnesses.length === limit;
|
|
213
215
|
const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
|
|
214
216
|
if (hashes.length > 0) {
|
|
215
|
-
const
|
|
217
|
+
const storedPayloads = await archivist.get(hashes);
|
|
218
|
+
const batchPayloads = storedPayloads.filter(exists);
|
|
216
219
|
payloads.push(...batchPayloads);
|
|
217
220
|
}
|
|
218
221
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 })\n model.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,WAAW,SAAO,CAAC;AAAA,EACxC,QAAU,UAAQ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AW,UAAO,CAAC;AAAA,EACjC,kBAAoB,YAAW,SAAQ,UAAgB,CAAC,CAAC;AAAA,EACzD,eAAiB,YAAW,UAAe,CAAC;AAC9C,CAAC;AAIM,IAAM,mCAAoGC,cAAa,iCAAiC;AACxJ,IAAM,mCAAoGC,cAAa,mCAAmC,kCAAkC;AAC5L,IAAM,mCAAoGC,cAAa,mCAAmC,kCAAkC;;;AJtB5L,IAAe,6BAAf,cASG,gBAAgD;AAAA,EACxD,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,8BAA8B;AAAA,EAC1G,OAAyB,sBAA8B;AAAA,EAKvD,MAAyB,cAAc,UAAmC;AACxE,UAAM,QAAQ,UAAU,KAAK,gCAAgC;AAC7D,QAAI,CAAC,MAAO,QAAO,CAAC;AAEpB,UAAM,iBAAsC,EAAE,GAAG,KAAK,QAAQ,GAAG,KAAK,MAAM;AAC5E,UAAM,gBAAgB,MAAM,aAAa,KAAK,IAAI;AAClD,UAAM,iBAAiB,eAAe,
|
|
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 !== undefined) 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 divineResults = await bwDiviner.divine([query])\n const boundWitnesses = divineResults.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 storedPayloads = await archivist.get(hashes)\n const batchPayloads = storedPayloads.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 windowSize = windowSettings.windowSize\n const startTimestamp = windowSize !== undefined && windowSize !== 0 ? stopTimestamp - 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 })\n model.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,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AAAA,QAAW;AAAA,QAAO;AAAA,QAAiB,QAAQ;AAAA,MAC7C;AACA,YAAM,gBAAgB,MAAM,UAAU,OAAO,CAAC,KAAK,CAAC;AACpD,YAAM,iBAAiB,cAAc;AAAA;AAAA;AAAA,QAGnC,OAAK;AAAA,MACP;AACA,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;AACjD,cAAM,gBAAgB,eAAe,OAAO,MAAM;AAClD,iBAAS,KAAK,GAAG,aAAa;AAAA,MAChC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-forecasting",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -50,30 +50,30 @@
|
|
|
50
50
|
"README.md"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@xyo-network/sdk": "~
|
|
54
|
-
"@xyo-network/sdk-protocol": "~
|
|
53
|
+
"@xyo-network/sdk": "~8.0.0",
|
|
54
|
+
"@xyo-network/sdk-protocol": "~8.0.0",
|
|
55
55
|
"arima": "~0.2.8",
|
|
56
56
|
"jsonpath-plus": "~10.4.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@ariestools/sdk": "~
|
|
60
|
-
"@ariestools/testing": "~
|
|
61
|
-
"@ariestools/toolchain": "~10.0.
|
|
62
|
-
"@ariestools/tsconfig": "~10.0.
|
|
59
|
+
"@ariestools/sdk": "~9.0.0",
|
|
60
|
+
"@ariestools/testing": "~9.0.0",
|
|
61
|
+
"@ariestools/toolchain": "~10.0.7",
|
|
62
|
+
"@ariestools/tsconfig": "~10.0.7",
|
|
63
63
|
"@opentelemetry/api": "~1.9.1",
|
|
64
64
|
"eslint": "~10.10.0",
|
|
65
65
|
"eslint-import-resolver-typescript": "~4.4.5",
|
|
66
66
|
"typescript": "~6.0.3",
|
|
67
67
|
"vite": "~8.3.0",
|
|
68
|
-
"vitest": "~5.0.
|
|
69
|
-
"zod": "~4.6.
|
|
68
|
+
"vitest": "~5.0.1",
|
|
69
|
+
"zod": "~4.6.5"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@ariestools/sdk": "^
|
|
72
|
+
"@ariestools/sdk": "^9.0",
|
|
73
73
|
"zod": "^4.6"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
|
-
"node": "^
|
|
76
|
+
"node": "^26"
|
|
77
77
|
},
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|