@xyo-network/diviner-temporal-indexing 7.4.2 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs +3 -2
- package/dist/neutral/index.mjs.map +2 -2
- package/dist/neutral/memory/StateToIndexCandidateDiviner/Diviner.d.ts +1 -1
- package/dist/neutral/memory/StateToIndexCandidateDiviner/Diviner.d.ts.map +1 -1
- package/dist/neutral/memory.mjs +3 -2
- package/dist/neutral/memory.mjs.map +2 -2
- package/package.json +17 -17
package/dist/neutral/index.mjs
CHANGED
|
@@ -372,7 +372,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
372
372
|
const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash]);
|
|
373
373
|
const indexFields = sourcePayloads.flatMap((payload) => {
|
|
374
374
|
const transformers = this.payloadTransformers[payload.schema];
|
|
375
|
-
return transformers ? transformers.map((transform) => transform(payload))
|
|
375
|
+
return transformers === void 0 ? [] : transformers.map((transform) => transform(payload));
|
|
376
376
|
});
|
|
377
377
|
const $sources = [bwHash, ...sourcePayloadHashes];
|
|
378
378
|
const payloadBuilder = new PayloadBuilder2({ schema: TemporalIndexingDivinerResultIndexSchema });
|
|
@@ -459,7 +459,8 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
|
|
|
459
459
|
const next = await sourceArchivist.next(nextOffset);
|
|
460
460
|
if (next.length === 0) return [lastState];
|
|
461
461
|
const batch = next.filter((x) => isBoundWitness2(x)).filter(exists2).filter((bw) => payloadSchemasContainsAll(bw, this.payload_schemas));
|
|
462
|
-
const
|
|
462
|
+
const batchResults = await Promise.all(batch.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)));
|
|
463
|
+
const indexCandidates = batchResults.filter(exists2).flat();
|
|
463
464
|
const nextCursor = assertEx2(next.at(-1)?._sequence, () => `${moduleName2}: Expected next to have a sequence`);
|
|
464
465
|
const nextState = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } };
|
|
465
466
|
return [nextState, ...indexCandidates];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/memory/Diviner.ts", "../../src/model/Config.ts", "../../src/model/Schema.ts", "../../src/model/DivinerQueryToIndexQueryDiviner/Config.ts", "../../src/model/DivinerQueryToIndexQueryDiviner/Schema.ts", "../../src/model/IndexCandidateToIndexDiviner/Config.ts", "../../src/model/IndexCandidateToIndexDiviner/Schema.ts", "../../src/model/IndexQueryResponseToDivinerQueryResponseDiviner/Config.ts", "../../src/model/IndexQueryResponseToDivinerQueryResponseDiviner/Schema.ts", "../../src/model/Result/Payload.ts", "../../src/model/Result/Schema.ts", "../../src/model/ResultIndex/Payload.ts", "../../src/model/ResultIndex/Schema.ts", "../../src/model/StateToIndexCandidateDiviner/Config.ts", "../../src/model/StateToIndexCandidateDiviner/Schema.ts", "../../src/memory/DivinerQueryToIndexQueryDiviner/Diviner.ts", "../../src/memory/IndexCandidateToIndexDiviner/Diviner.ts", "../../src/memory/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts", "../../src/memory/StateToIndexCandidateDiviner/Diviner.ts"],
|
|
4
|
-
"sourcesContent": ["import { IndexingDiviner } from '@xyo-network/diviner-indexing/memory'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/sdk/diviner-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerParams } from '../model/index.ts'\nimport { TemporalIndexingDivinerConfigSchema } from '../model/index.ts'\n\nexport class TemporalIndexingDiviner<\n TParams extends TemporalIndexingDivinerParams = TemporalIndexingDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerConfigSchema\n\n protected override async startHandler(): Promise<void> {\n await super.startHandler()\n }\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { IndexingDivinerStage, IndexingDivinerStageConfig } from '@xyo-network/diviner-indexing/model'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig } from './DivinerQueryToIndexQueryDiviner/index.ts'\nimport type { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig } from './IndexQueryResponseToDivinerQueryResponseDiviner/index.ts'\nimport { TemporalIndexingDivinerSchema } from './Schema.ts'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerConfig } from './StateToIndexCandidateDiviner/index.ts'\n\nexport const TemporalIndexingDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.config`, true)\nexport type TemporalIndexingDivinerConfigSchema = typeof TemporalIndexingDivinerConfigSchema\n\n/**\n * Config section for declaring each indexing diviner stage\n */\nexport type IndexingDivinerStageTransformConfig = Record<IndexingDivinerStage, SchemaToJsonPathTransformExpressionsDictionary>\n\n// TODO: Extend indexing diviner config\n/**\n * Diviner Config for a Diviner which Indexes Payloads\n */\nexport type TemporalIndexingDivinerConfig = DivinerConfig<{\n /**\n * Where the diviner should store it's index\n */\n indexStore?: SearchableStorage\n /**\n * Config section for name/address of individual diviner stages\n */\n indexingDivinerStages?: IndexingDivinerStageConfig\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * How often to poll for new payloads to index\n */\n pollFrequency?: number\n /**\n * The schema for this config\n */\n schema: TemporalIndexingDivinerConfigSchema\n /**\n * Optional config section for individual diviner stages\n */\n stageConfigs?: {\n divinerQueryToIndexQueryDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexCandidateToIndexDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexQueryResponseToDivinerQueryResponseDiviner?: Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n stateToIndexCandidateDiviner?: Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n }\n /**\n * Where the diviner should persist its internal state\n */\n stateStore?: SearchableStorage\n}>\n\nexport const TemporalIndexingDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n indexStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n indexingDivinerStages: z.ZodMiniOptional<z.ZodMiniCustom<IndexingDivinerStageConfig, IndexingDivinerStageConfig>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n pollFrequency: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerConfigSchema>\n stageConfigs: z.ZodMiniOptional<z.ZodMiniObject<{\n divinerQueryToIndexQueryDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexCandidateToIndexDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexQueryResponseToDivinerQueryResponseDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n >\n >\n stateToIndexCandidateDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n >\n >\n }, z.core.$strip>>\n stateStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n indexStore: z.optional(z.custom<SearchableStorage>()),\n indexingDivinerStages: z.optional(z.custom<IndexingDivinerStageConfig>()),\n payloadDivinerLimit: z.optional(z.number()),\n pollFrequency: z.optional(z.number()),\n schema: z.literal(TemporalIndexingDivinerConfigSchema),\n stageConfigs: z.optional(z.object({\n divinerQueryToIndexQueryDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexCandidateToIndexDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexQueryResponseToDivinerQueryResponseDiviner: z.optional(\n z.custom<Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>>(),\n ),\n stateToIndexCandidateDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>>()),\n })),\n stateStore: z.optional(z.custom<SearchableStorage>()),\n})\n\nexport type TemporalIndexingDivinerConfigBase = z.infer<typeof TemporalIndexingDivinerConfigZod>\n\nexport const isTemporalIndexingDivinerConfig: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerConfigBase>>\n = zodIsFactory(TemporalIndexingDivinerConfigZod)\nexport const asTemporalIndexingDivinerConfig: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerConfigBase>>\n = zodAsFactory(TemporalIndexingDivinerConfigZod, 'asTemporalIndexingDivinerConfig')\nexport const toTemporalIndexingDivinerConfig: ReturnType<typeof zodToFactory<TemporalIndexingDivinerConfigBase>>\n = zodToFactory(TemporalIndexingDivinerConfigZod, 'toTemporalIndexingDivinerConfig')\n", "import { IndexingDivinerSchema } from '@xyo-network/diviner-indexing/model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const TemporalIndexingDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${IndexingDivinerSchema}.temporal`, true)\nexport type TemporalIndexingDivinerSchema = typeof TemporalIndexingDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema, type Schema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n divinerQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n divinerQuerySchema: z.optional(z.custom<Schema>()),\n indexQuerySchema: z.optional(z.custom<Schema>()),\n indexSchema: z.optional(z.custom<Schema>()),\n schema: z.literal(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner Query to an Index Query\n */\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig = DivinerConfig<{\n /**\n * The schema of the diviner query payloads\n */\n divinerQuerySchema?: Schema\n /**\n * The schema of the index query payloads\n */\n indexQuerySchema?: Schema\n /**\n * The schema of the index payloads\n */\n indexSchema?: Schema\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod)\nexport const asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\nexport const toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.diviner.query.to.index.query.diviner`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms Index Candidates to Indexes\n */\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodAsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\nexport const toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodToFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.candidate.to.index.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms an Index Query Response to a Diviner Query Response\n */\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\nexport const toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.query.response.to.diviner.query.response.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerResultSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerResultZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerResultSchema>\n sources: z.ZodMiniArray<z.ZodMiniCustom<Hash, Hash>>\n timestamp: z.ZodMiniString<string>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(TemporalIndexingDivinerResultSchema), {\n sources: z.array(z.custom<Hash>()),\n timestamp: z.string(),\n})\n\nexport type TemporalIndexingDivinerResult = z.infer<typeof TemporalIndexingDivinerResultZod>\n\nexport const isTemporalIndexingDivinerResult: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerResult>>\n = zodIsFactory(TemporalIndexingDivinerResultZod)\nexport const asTemporalIndexingDivinerResult: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerResult>>\n = zodAsFactory(TemporalIndexingDivinerResultZod, 'asTemporalIndexingDivinerResult')\nexport const toTemporalIndexingDivinerResult: ReturnType<typeof zodToFactory<TemporalIndexingDivinerResult>>\n = zodToFactory(TemporalIndexingDivinerResultZod, 'toTemporalIndexingDivinerResult')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerResultSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.result`, true)\nexport type TemporalIndexingDivinerResultSchema = typeof TemporalIndexingDivinerResultSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerResultIndexSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerResultIndexZod: z.ZodMiniObject<{\n $sources: z.ZodMiniArray<z.ZodMiniCustom<Hash, Hash>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerResultIndexSchema>\n timestamp: z.ZodMiniNumber<number>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(TemporalIndexingDivinerResultIndexSchema), {\n $sources: z.array(z.custom<Hash>()),\n timestamp: z.number(),\n})\n\nexport type TemporalIndexingDivinerResultIndex = z.infer<typeof TemporalIndexingDivinerResultIndexZod>\n\nexport const isTemporalIndexingDivinerResultIndex: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerResultIndex>>\n = zodIsFactory(TemporalIndexingDivinerResultIndexZod)\nexport const asTemporalIndexingDivinerResultIndex: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerResultIndex>>\n = zodAsFactory(TemporalIndexingDivinerResultIndexZod, 'asTemporalIndexingDivinerResultIndex')\nexport const toTemporalIndexingDivinerResultIndex: ReturnType<typeof zodToFactory<TemporalIndexingDivinerResultIndex>>\n = zodToFactory(TemporalIndexingDivinerResultIndexZod, 'toTemporalIndexingDivinerResultIndex')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerResultSchema } from '../Result/index.ts'\n\nexport const TemporalIndexingDivinerResultIndexSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerResultSchema}.index`, true)\nexport type TemporalIndexingDivinerResultIndexSchema = typeof TemporalIndexingDivinerResultIndexSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { BoundWitnessDivinerPredicate } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerStateToIndexCandidateDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n filter: z.ZodMiniOptional<z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n payloadStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n filter: z.optional(z.custom<BoundWitnessDivinerPredicate>()),\n payloadDivinerLimit: z.optional(z.number()),\n payloadStore: z.optional(z.custom<SearchableStorage>()),\n schema: z.literal(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema),\n})\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner State to Index Candidates\n */\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfig = DivinerConfig<{\n /**\n * The filter to use to identify index candidates\n */\n filter?: BoundWitnessDivinerPredicate\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * Where the diviner should look for stored thumbnails\n */\n payloadStore?: SearchableStorage\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n}>\n\nexport const isTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod)\nexport const asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\nexport const toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.state.to.index.candidate.diviner`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\nimport { isPayloadOfSchemaType, PayloadBuilder } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n// TODO: Inherit from JsonPathAggregateDiviner\n/**\n * A diviner that converts diviner query to index query\n */\nexport class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<\n TParams extends TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): Schema {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): Schema {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): Schema {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return (\n this.config?.schemaTransforms ?? {\n [this.divinerQuerySchema]: [\n {\n defaultValue: 1,\n destinationField: 'limit',\n sourcePathExpression: '$.limit',\n },\n {\n // defaultValue: 0,\n destinationField: 'cursor',\n sourcePathExpression: '$.cursor',\n },\n {\n defaultValue: 'desc',\n destinationField: 'order',\n sourcePathExpression: '$.order',\n },\n ],\n }\n )\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument\n const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema as any))\n if (queries.length > 0) {\n return await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { $sources?: Hash[]; sources?: Hash[] }>(\n [query],\n this.payloadTransformers,\n this.indexQuerySchema,\n )\n // TODO: Make index schema configurable\n fields.schemas = [this.indexSchema]\n // TODO: Make sources not need to be deleted\n delete fields.sources\n delete fields?.$sources\n // TODO: Add support for additional filters\n const payloadBuilder = new PayloadBuilder<Payload>({ schema: this.indexQuerySchema })\n return payloadBuilder.fields(fields).build()\n }),\n )\n }\n return []\n }\n}\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n assertEx, containsAll, exists,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isAnyPayload, isBoundWitness, PayloadBuilder,\n} from '@xyo-network/sdk-protocol'\n\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n\ntype IndexableHashes = [Hash, ...Hash[]]\n\nconst moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'\n\n/**\n * Diviner which transforms index candidates to indexes using JSON Path to map\n * source properties in the supplied payloads to destination fields in the\n * resultant index\n */\nexport class TemporalIndexingDivinerIndexCandidateToIndexDiviner<\n TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\n .filter(bw => containsAll(bw.payload_schemas, this.indexableSchemas))\n // If the Payload is not one of the indexable schemas do not index it\n const indexablePayloads = payloads.filter(p => this.isIndexablePayload(p))\n // If there is nothing to index, return an empty array\n if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return []\n // Hash all the indexable data once\n const [bwDictionary, payloadDictionary] = await Promise.all([\n PayloadBuilder.toHashMap(indexableBoundWitnesses),\n PayloadBuilder.toAllHashMap(indexablePayloads),\n ])\n\n // Initialize the array for validIndexableTuples outside of the loop\n const validIndexableTuples: IndexableHashes[] = []\n\n // Iterate over each entry in bwDictionary\n for (const [bwHash, bw] of Object.entries(bwDictionary) as [Hash, BoundWitness][]) {\n // Find the combinations of payloads that satisfy the required schemas\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas)\n\n // Iterate over each combination\n for (const combination of combinations) {\n const indexablePayloads = combination.map(hash => payloadDictionary[hash]).filter(exists)\n\n // If we found the right amount of indexable payloads (of the correct schema as checked\n // above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) {\n validIndexableTuples.push([bwHash, ...combination])\n }\n }\n }\n\n // Create the indexes from the tuples\n const indexes = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([bwHash, ...sourcePayloadHashes]) => {\n const sourcePayloads = sourcePayloadHashes.map(hash => payloadDictionary[hash])\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap((payload) => {\n // Find the transformers for this payload\n const transformers = this.payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers ? transformers.map(transform => transform(payload)) : []\n })\n // Include all the sources for reference\n const $sources: Hash[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n const payloadBuilder = new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n return payloadBuilder\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n .fields(Object.assign({}, ...indexFields))\n .meta({ $sources })\n .build()\n })\n return indexes.flat()\n }\n\n /**\n * Identifies if a payload is one that is indexed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one indexed by this diviner, false otherwise\n */\n protected isIndexablePayload = (x: unknown): boolean => {\n return isAnyPayload(x) && this.indexableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is indexed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one indexed by this diviner, false otherwise\n */\n protected isIndexableSchema = (schema?: Schema | null): boolean => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n", "import { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * Transforms an ImageThumbnailIndex response into an ImageThumbnailResponse response\n */\nexport class TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner {\n static override readonly configSchemas: Schema[] = [\n ...super.configSchemas,\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema,\n ]\n\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // We're not doing anything with the query payloads but some diviners\n // might want to use this to transform from the query to the response (for example\n // if we use a plaintext value in the query to generate a hash key in the index)\n // const queries = payloads.filter(isPayloadDivinerQueryPayload)\n const responses = payloads.filter(p => !isPayloadDivinerQueryPayload(p))\n return responses\n }\n}\n", "import { assertEx, exists } from '@ariestools/sdk'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing/model'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/sdk/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/sdk/archivist-wrapper'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/sdk/diviner-boundwitness/abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport { DivinerWrapper } from '@xyo-network/sdk/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/sdk/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness,\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isBoundWitness, payloadSchemasContainsAll, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\nimport type { Timestamp } from '@xyo-network/witness-timestamp'\nimport { TimestampSchema } from '@xyo-network/witness-timestamp'\n\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '../../model/index.ts'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * All Payload types involved in index candidates for indexing\n */\nexport type IndexCandidate = BoundWitness | Payload | Timestamp\n\n/**\n * The response from the TemporalStateToIndexCandidateDiviner\n */\nexport type TemporalStateToIndexCandidateDivinerResponse = [\n /**\n * The next state of the diviner\n */\n nextState: ModuleState<IndexingDivinerState>,\n /**\n * The index candidates\n */\n ...IndexCandidate[],\n]\n\n/**\n * The default order to search Bound Witnesses to identify index candidates\n */\nconst order = 'asc'\n\n/**\n * The name of the module (for logging purposes)\n */\nconst moduleName = 'TemporalIndexingDivinerStateToIndexCandidateDiviner'\n\n/**\n * Transforms candidates for image thumbnail indexing into their indexed representation\n */\nexport class TemporalIndexingDivinerStateToIndexCandidateDiviner<\n TParams extends TemporalIndexingDivinerStateToIndexCandidateDivinerParams = TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n> extends AbstractDiviner<TParams, Payload, ModuleState | IndexCandidate> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit(): number {\n return this.config.payloadDivinerLimit ?? 1000\n }\n\n /**\n * The required payload_schemas within BoundWitnesses to identify index candidates\n */\n protected get payload_schemas(): Schema[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<TemporalStateToIndexCandidateDivinerResponse> {\n // Retrieve the last state from what was passed in\n const lastState = payloads.find(isModuleState<IndexingDivinerState>)\n // If there is no last state, start from the beginning\n ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n\n const batch = next.filter(x => isBoundWitness(x))\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const indexCandidates: IndexCandidate[] = (await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\n\n /**\n * Retrieves the archivist for the payloadStore\n * @returns The archivist for the payloadStore or undefined if not resolvable\n */\n protected async getArchivistForStore(): Promise<ArchivistWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.archivist,\n () => `${moduleName}: Config for payloadStore.archivist not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped archivist\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the payloadStore\n * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable\n */\n protected async getBoundWitnessDivinerForStore(): Promise<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n > | undefined\n > {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for payloadStore.boundWitnessDiviner not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return\n // Return the wrapped diviner\n return DivinerWrapper.wrap<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n >\n >(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.payload_schemas).flat()\n if (combinations.length === 0) return undefined\n const hashes = new Set(combinations)\n const indexCandidates = await archivist.get([...hashes])\n return [bw, ...indexCandidates]\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;;;ACAhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AAIP,SAAS,wBAAwB;AACjC,SAAS,YAAAA,iBAAgB;AACzB,YAAY,OAAO;;;ACRnB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAElB,IAAM,gCAET,SAAS,GAAG,qBAAqB,aAAa,IAAI;;;ADU/C,IAAM,sCAETC,UAAS,GAAG,6BAA6B,WAAW,IAAI;AAgDrD,IAAM,mCAoCP,SAAO,kBAAkB;AAAA,EAC7B,YAAc,WAAW,SAA0B,CAAC;AAAA,EACpD,uBAAyB,WAAW,SAAmC,CAAC;AAAA,EACxE,qBAAuB,WAAW,SAAO,CAAC;AAAA,EAC1C,eAAiB,WAAW,SAAO,CAAC;AAAA,EACpC,QAAU,UAAQ,mCAAmC;AAAA,EACrD,cAAgB,WAAW,SAAO;AAAA,IAChC,iCAAmC,WAAW,SAAqF,CAAC;AAAA,IACpI,8BAAgC,WAAW,SAAqF,CAAC;AAAA,IACjI,iDAAmD;AAAA,MAC/C,SAAqG;AAAA,IACzG;AAAA,IACA,8BAAgC,WAAW,SAAkF,CAAC;AAA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Instance, DivinerModuleEventData } from '@xyo-network/sdk/diviner-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerParams } from '../model/index.ts'\nimport { TemporalIndexingDivinerConfigSchema } from '../model/index.ts'\n\nexport class TemporalIndexingDiviner<\n TParams extends TemporalIndexingDivinerParams = TemporalIndexingDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerConfigSchema\n\n protected override async startHandler(): Promise<void> {\n await super.startHandler()\n }\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { IndexingDivinerStage, IndexingDivinerStageConfig } from '@xyo-network/diviner-indexing/model'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig } from './DivinerQueryToIndexQueryDiviner/index.ts'\nimport type { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig } from './IndexQueryResponseToDivinerQueryResponseDiviner/index.ts'\nimport { TemporalIndexingDivinerSchema } from './Schema.ts'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerConfig } from './StateToIndexCandidateDiviner/index.ts'\n\nexport const TemporalIndexingDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.config`, true)\nexport type TemporalIndexingDivinerConfigSchema = typeof TemporalIndexingDivinerConfigSchema\n\n/**\n * Config section for declaring each indexing diviner stage\n */\nexport type IndexingDivinerStageTransformConfig = Record<IndexingDivinerStage, SchemaToJsonPathTransformExpressionsDictionary>\n\n// TODO: Extend indexing diviner config\n/**\n * Diviner Config for a Diviner which Indexes Payloads\n */\nexport type TemporalIndexingDivinerConfig = DivinerConfig<{\n /**\n * Where the diviner should store it's index\n */\n indexStore?: SearchableStorage\n /**\n * Config section for name/address of individual diviner stages\n */\n indexingDivinerStages?: IndexingDivinerStageConfig\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * How often to poll for new payloads to index\n */\n pollFrequency?: number\n /**\n * The schema for this config\n */\n schema: TemporalIndexingDivinerConfigSchema\n /**\n * Optional config section for individual diviner stages\n */\n stageConfigs?: {\n divinerQueryToIndexQueryDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexCandidateToIndexDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexQueryResponseToDivinerQueryResponseDiviner?: Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n stateToIndexCandidateDiviner?: Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n }\n /**\n * Where the diviner should persist its internal state\n */\n stateStore?: SearchableStorage\n}>\n\nexport const TemporalIndexingDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n indexStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n indexingDivinerStages: z.ZodMiniOptional<z.ZodMiniCustom<IndexingDivinerStageConfig, IndexingDivinerStageConfig>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n pollFrequency: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerConfigSchema>\n stageConfigs: z.ZodMiniOptional<z.ZodMiniObject<{\n divinerQueryToIndexQueryDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexCandidateToIndexDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexQueryResponseToDivinerQueryResponseDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n >\n >\n stateToIndexCandidateDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n >\n >\n }, z.core.$strip>>\n stateStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n indexStore: z.optional(z.custom<SearchableStorage>()),\n indexingDivinerStages: z.optional(z.custom<IndexingDivinerStageConfig>()),\n payloadDivinerLimit: z.optional(z.number()),\n pollFrequency: z.optional(z.number()),\n schema: z.literal(TemporalIndexingDivinerConfigSchema),\n stageConfigs: z.optional(z.object({\n divinerQueryToIndexQueryDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexCandidateToIndexDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexQueryResponseToDivinerQueryResponseDiviner: z.optional(\n z.custom<Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>>(),\n ),\n stateToIndexCandidateDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>>()),\n })),\n stateStore: z.optional(z.custom<SearchableStorage>()),\n})\n\nexport type TemporalIndexingDivinerConfigBase = z.infer<typeof TemporalIndexingDivinerConfigZod>\n\nexport const isTemporalIndexingDivinerConfig: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerConfigBase>>\n = zodIsFactory(TemporalIndexingDivinerConfigZod)\nexport const asTemporalIndexingDivinerConfig: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerConfigBase>>\n = zodAsFactory(TemporalIndexingDivinerConfigZod, 'asTemporalIndexingDivinerConfig')\nexport const toTemporalIndexingDivinerConfig: ReturnType<typeof zodToFactory<TemporalIndexingDivinerConfigBase>>\n = zodToFactory(TemporalIndexingDivinerConfigZod, 'toTemporalIndexingDivinerConfig')\n", "import { IndexingDivinerSchema } from '@xyo-network/diviner-indexing/model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const TemporalIndexingDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${IndexingDivinerSchema}.temporal`, true)\nexport type TemporalIndexingDivinerSchema = typeof TemporalIndexingDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema, type Schema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n divinerQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n divinerQuerySchema: z.optional(z.custom<Schema>()),\n indexQuerySchema: z.optional(z.custom<Schema>()),\n indexSchema: z.optional(z.custom<Schema>()),\n schema: z.literal(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner Query to an Index Query\n */\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig = DivinerConfig<{\n /**\n * The schema of the diviner query payloads\n */\n divinerQuerySchema?: Schema\n /**\n * The schema of the index query payloads\n */\n indexQuerySchema?: Schema\n /**\n * The schema of the index payloads\n */\n indexSchema?: Schema\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod)\nexport const asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\nexport const toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.diviner.query.to.index.query.diviner`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms Index Candidates to Indexes\n */\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodAsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\nexport const toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodToFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.candidate.to.index.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms an Index Query Response to a Diviner Query Response\n */\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\nexport const toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.query.response.to.diviner.query.response.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerResultSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerResultZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerResultSchema>\n sources: z.ZodMiniArray<z.ZodMiniCustom<Hash, Hash>>\n timestamp: z.ZodMiniString<string>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(TemporalIndexingDivinerResultSchema), {\n sources: z.array(z.custom<Hash>()),\n timestamp: z.string(),\n})\n\nexport type TemporalIndexingDivinerResult = z.infer<typeof TemporalIndexingDivinerResultZod>\n\nexport const isTemporalIndexingDivinerResult: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerResult>>\n = zodIsFactory(TemporalIndexingDivinerResultZod)\nexport const asTemporalIndexingDivinerResult: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerResult>>\n = zodAsFactory(TemporalIndexingDivinerResultZod, 'asTemporalIndexingDivinerResult')\nexport const toTemporalIndexingDivinerResult: ReturnType<typeof zodToFactory<TemporalIndexingDivinerResult>>\n = zodToFactory(TemporalIndexingDivinerResultZod, 'toTemporalIndexingDivinerResult')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerResultSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.result`, true)\nexport type TemporalIndexingDivinerResultSchema = typeof TemporalIndexingDivinerResultSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerResultIndexSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerResultIndexZod: z.ZodMiniObject<{\n $sources: z.ZodMiniArray<z.ZodMiniCustom<Hash, Hash>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerResultIndexSchema>\n timestamp: z.ZodMiniNumber<number>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(TemporalIndexingDivinerResultIndexSchema), {\n $sources: z.array(z.custom<Hash>()),\n timestamp: z.number(),\n})\n\nexport type TemporalIndexingDivinerResultIndex = z.infer<typeof TemporalIndexingDivinerResultIndexZod>\n\nexport const isTemporalIndexingDivinerResultIndex: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerResultIndex>>\n = zodIsFactory(TemporalIndexingDivinerResultIndexZod)\nexport const asTemporalIndexingDivinerResultIndex: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerResultIndex>>\n = zodAsFactory(TemporalIndexingDivinerResultIndexZod, 'asTemporalIndexingDivinerResultIndex')\nexport const toTemporalIndexingDivinerResultIndex: ReturnType<typeof zodToFactory<TemporalIndexingDivinerResultIndex>>\n = zodToFactory(TemporalIndexingDivinerResultIndexZod, 'toTemporalIndexingDivinerResultIndex')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerResultSchema } from '../Result/index.ts'\n\nexport const TemporalIndexingDivinerResultIndexSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerResultSchema}.index`, true)\nexport type TemporalIndexingDivinerResultIndexSchema = typeof TemporalIndexingDivinerResultIndexSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { BoundWitnessDivinerPredicate } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerStateToIndexCandidateDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n filter: z.ZodMiniOptional<z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n payloadStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n filter: z.optional(z.custom<BoundWitnessDivinerPredicate>()),\n payloadDivinerLimit: z.optional(z.number()),\n payloadStore: z.optional(z.custom<SearchableStorage>()),\n schema: z.literal(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema),\n})\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner State to Index Candidates\n */\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfig = DivinerConfig<{\n /**\n * The filter to use to identify index candidates\n */\n filter?: BoundWitnessDivinerPredicate\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * Where the diviner should look for stored thumbnails\n */\n payloadStore?: SearchableStorage\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n}>\n\nexport const isTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod)\nexport const asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\nexport const toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.state.to.index.candidate.diviner`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\nimport { isPayloadOfSchemaType, PayloadBuilder } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n// TODO: Inherit from JsonPathAggregateDiviner\n/**\n * A diviner that converts diviner query to index query\n */\nexport class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<\n TParams extends TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): Schema {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): Schema {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): Schema {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return (\n this.config?.schemaTransforms ?? {\n [this.divinerQuerySchema]: [\n {\n defaultValue: 1,\n destinationField: 'limit',\n sourcePathExpression: '$.limit',\n },\n {\n // defaultValue: 0,\n destinationField: 'cursor',\n sourcePathExpression: '$.cursor',\n },\n {\n defaultValue: 'desc',\n destinationField: 'order',\n sourcePathExpression: '$.order',\n },\n ],\n }\n )\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument\n const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema as any))\n if (queries.length > 0) {\n return await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { $sources?: Hash[]; sources?: Hash[] }>(\n [query],\n this.payloadTransformers,\n this.indexQuerySchema,\n )\n // TODO: Make index schema configurable\n fields.schemas = [this.indexSchema]\n // TODO: Make sources not need to be deleted\n delete fields.sources\n delete fields?.$sources\n // TODO: Add support for additional filters\n const payloadBuilder = new PayloadBuilder<Payload>({ schema: this.indexQuerySchema })\n return payloadBuilder.fields(fields).build()\n }),\n )\n }\n return []\n }\n}\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n assertEx, containsAll, exists,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isAnyPayload, isBoundWitness, PayloadBuilder,\n} from '@xyo-network/sdk-protocol'\n\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n\ntype IndexableHashes = [Hash, ...Hash[]]\n\nconst moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'\n\n/**\n * Diviner which transforms index candidates to indexes using JSON Path to map\n * source properties in the supplied payloads to destination fields in the\n * resultant index\n */\nexport class TemporalIndexingDivinerIndexCandidateToIndexDiviner<\n TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\n .filter(bw => containsAll(bw.payload_schemas, this.indexableSchemas))\n // If the Payload is not one of the indexable schemas do not index it\n const indexablePayloads = payloads.filter(p => this.isIndexablePayload(p))\n // If there is nothing to index, return an empty array\n if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return []\n // Hash all the indexable data once\n const [bwDictionary, payloadDictionary] = await Promise.all([\n PayloadBuilder.toHashMap(indexableBoundWitnesses),\n PayloadBuilder.toAllHashMap(indexablePayloads),\n ])\n\n // Initialize the array for validIndexableTuples outside of the loop\n const validIndexableTuples: IndexableHashes[] = []\n\n // Iterate over each entry in bwDictionary\n for (const [bwHash, bw] of Object.entries(bwDictionary) as [Hash, BoundWitness][]) {\n // Find the combinations of payloads that satisfy the required schemas\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas)\n\n // Iterate over each combination\n for (const combination of combinations) {\n const indexablePayloads = combination.map(hash => payloadDictionary[hash]).filter(exists)\n\n // If we found the right amount of indexable payloads (of the correct schema as checked\n // above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) {\n validIndexableTuples.push([bwHash, ...combination])\n }\n }\n }\n\n // Create the indexes from the tuples\n const indexes = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([bwHash, ...sourcePayloadHashes]) => {\n const sourcePayloads = sourcePayloadHashes.map(hash => payloadDictionary[hash])\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap((payload) => {\n // Find the transformers for this payload\n const transformers = this.payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers === undefined ? [] : transformers.map(transform => transform(payload))\n })\n // Include all the sources for reference\n const $sources: Hash[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n const payloadBuilder = new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n return payloadBuilder\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n .fields(Object.assign({}, ...indexFields))\n .meta({ $sources })\n .build()\n })\n return indexes.flat()\n }\n\n /**\n * Identifies if a payload is one that is indexed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one indexed by this diviner, false otherwise\n */\n protected isIndexablePayload = (x: unknown): boolean => {\n return isAnyPayload(x) && this.indexableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is indexed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one indexed by this diviner, false otherwise\n */\n protected isIndexableSchema = (schema?: Schema | null): boolean => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n", "import { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * Transforms an ImageThumbnailIndex response into an ImageThumbnailResponse response\n */\nexport class TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner {\n static override readonly configSchemas: Schema[] = [\n ...super.configSchemas,\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema,\n ]\n\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // We're not doing anything with the query payloads but some diviners\n // might want to use this to transform from the query to the response (for example\n // if we use a plaintext value in the query to generate a hash key in the index)\n // const queries = payloads.filter(isPayloadDivinerQueryPayload)\n const responses = payloads.filter(p => !isPayloadDivinerQueryPayload(p))\n return responses\n }\n}\n", "import { assertEx, exists } from '@ariestools/sdk'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing/model'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/sdk/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/sdk/archivist-wrapper'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/sdk/diviner-boundwitness/abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport { DivinerWrapper } from '@xyo-network/sdk/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/sdk/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness,\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isBoundWitness, payloadSchemasContainsAll, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\nimport type { Timestamp } from '@xyo-network/witness-timestamp'\nimport { TimestampSchema } from '@xyo-network/witness-timestamp'\n\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '../../model/index.ts'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * All Payload types involved in index candidates for indexing\n */\nexport type IndexCandidate = BoundWitness | Payload | Timestamp\n\n/**\n * The response from the TemporalStateToIndexCandidateDiviner\n */\nexport type TemporalStateToIndexCandidateDivinerResponse = [\n /**\n * The next state of the diviner\n */\n nextState: ModuleState<IndexingDivinerState>,\n /**\n * The index candidates\n */\n ...indexCandidates: IndexCandidate[],\n]\n\n/**\n * The default order to search Bound Witnesses to identify index candidates\n */\nconst order = 'asc'\n\n/**\n * The name of the module (for logging purposes)\n */\nconst moduleName = 'TemporalIndexingDivinerStateToIndexCandidateDiviner'\n\n/**\n * Transforms candidates for image thumbnail indexing into their indexed representation\n */\nexport class TemporalIndexingDivinerStateToIndexCandidateDiviner<\n TParams extends TemporalIndexingDivinerStateToIndexCandidateDivinerParams = TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n> extends AbstractDiviner<TParams, Payload, ModuleState | IndexCandidate> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit(): number {\n return this.config.payloadDivinerLimit ?? 1000\n }\n\n /**\n * The required payload_schemas within BoundWitnesses to identify index candidates\n */\n protected get payload_schemas(): Schema[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<TemporalStateToIndexCandidateDivinerResponse> {\n // Retrieve the last state from what was passed in\n const lastState = payloads.find(isModuleState<IndexingDivinerState>)\n // If there is no last state, start from the beginning\n ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n\n const batch = next.filter(x => isBoundWitness(x))\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const batchResults = await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist)))\n const indexCandidates: IndexCandidate[] = batchResults\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\n\n /**\n * Retrieves the archivist for the payloadStore\n * @returns The archivist for the payloadStore or undefined if not resolvable\n */\n protected async getArchivistForStore(): Promise<ArchivistWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.archivist,\n () => `${moduleName}: Config for payloadStore.archivist not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped archivist\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the payloadStore\n * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable\n */\n protected async getBoundWitnessDivinerForStore(): Promise<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n > | undefined\n > {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for payloadStore.boundWitnessDiviner not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return\n // Return the wrapped diviner\n return DivinerWrapper.wrap<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n >\n >(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.payload_schemas).flat()\n if (combinations.length === 0) return undefined\n const hashes = new Set(combinations)\n const indexCandidates = await archivist.get([...hashes])\n return [bw, ...indexCandidates]\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,uBAAuB;;;ACAhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AAIP,SAAS,wBAAwB;AACjC,SAAS,YAAAA,iBAAgB;AACzB,YAAY,OAAO;;;ACRnB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAElB,IAAM,gCAET,SAAS,GAAG,qBAAqB,aAAa,IAAI;;;ADU/C,IAAM,sCAETC,UAAS,GAAG,6BAA6B,WAAW,IAAI;AAgDrD,IAAM,mCAoCP,SAAO,kBAAkB;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KAAK;AACxF,QAAI,aAAa,WAAW,EAAG,QAAO;AACtC,UAAM,SAAS,IAAI,IAAI,YAAY;AACnC,UAAM,kBAAkB,MAAM,UAAU,IAAI,CAAC,GAAG,MAAM,CAAC;AACvD,WAAO,CAAC,IAAI,GAAG,eAAe;AAAA,EAChC;AACF;",
|
|
6
6
|
"names": ["asSchema", "asSchema", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "z", "asSchema", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "PayloadZodOfSchema", "z", "asSchema", "asSchema", "PayloadZodOfSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "jsonPathToTransformersDictionary", "AbstractDiviner", "PayloadBuilder", "AbstractDiviner", "jsonPathToTransformersDictionary", "PayloadBuilder", "indexablePayloads", "AbstractDiviner", "AbstractDiviner", "assertEx", "exists", "AbstractDiviner", "intraBoundwitnessSchemaCombinations", "isBoundWitness", "moduleName", "AbstractDiviner", "isBoundWitness", "exists", "assertEx", "intraBoundwitnessSchemaCombinations"]
|
|
7
7
|
}
|
|
@@ -24,7 +24,7 @@ export type TemporalStateToIndexCandidateDivinerResponse = [
|
|
|
24
24
|
/**
|
|
25
25
|
* The index candidates
|
|
26
26
|
*/
|
|
27
|
-
...IndexCandidate[]
|
|
27
|
+
...indexCandidates: IndexCandidate[]
|
|
28
28
|
];
|
|
29
29
|
/**
|
|
30
30
|
* Transforms candidates for image thumbnail indexing into their indexed representation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../../src/memory/StateToIndexCandidateDiviner/Diviner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,kCAAkC,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AACzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAA;AAC7H,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EACV,MAAM,EAAoB,WAAW,EACtC,MAAM,+BAA+B,CAAA;AAEtC,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EAAE,MAAM,EACf,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAIlC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAG/D,OAAO,KAAK,EAAE,yDAAyD,EAAE,MAAM,sBAAsB,CAAA;AAGrG;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC,oBAAoB,CAAC;IAC5C;;OAEG;IACH,GAAG,cAAc,EAAE;
|
|
1
|
+
{"version":3,"file":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AE,MAAM,CAAkE;IACtH,gBAAyB,MAAM,EAAE,MAAM,CAGtC;IAED,IAAI,mBAAmB,IAAI,MAAM,CAEhC;IAED;;OAEG;IACH,SAAS,KAAK,eAAe,IAAI,MAAM,EAAE,CAGxC;cAEwB,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,4CAA4C,CAAC;IAiCvH;;;OAGG;cACa,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAa7E;;;OAGG;cACa,8BAA8B,IAAI,OAAO,CACvD,cAAc,CACZ,mBAAmB,CAAC,yBAAyB,EAAE,+BAA+B,EAAE,YAAY,CAAC,EAC7F,+BAA+B,EAC/B,eAAe,CAAC,YAAY,CAAC,CAC9B,GAAG,SAAS,CACd;cAmBe,yBAAyB,CAAC,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,SAAS,CAAC;CAOjI"}
|
package/dist/neutral/memory.mjs
CHANGED
|
@@ -336,7 +336,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
336
336
|
const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash]);
|
|
337
337
|
const indexFields = sourcePayloads.flatMap((payload) => {
|
|
338
338
|
const transformers = this.payloadTransformers[payload.schema];
|
|
339
|
-
return transformers ? transformers.map((transform) => transform(payload))
|
|
339
|
+
return transformers === void 0 ? [] : transformers.map((transform) => transform(payload));
|
|
340
340
|
});
|
|
341
341
|
const $sources = [bwHash, ...sourcePayloadHashes];
|
|
342
342
|
const payloadBuilder = new PayloadBuilder2({ schema: TemporalIndexingDivinerResultIndexSchema });
|
|
@@ -423,7 +423,8 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
|
|
|
423
423
|
const next = await sourceArchivist.next(nextOffset);
|
|
424
424
|
if (next.length === 0) return [lastState];
|
|
425
425
|
const batch = next.filter((x) => isBoundWitness2(x)).filter(exists2).filter((bw) => payloadSchemasContainsAll(bw, this.payload_schemas));
|
|
426
|
-
const
|
|
426
|
+
const batchResults = await Promise.all(batch.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)));
|
|
427
|
+
const indexCandidates = batchResults.filter(exists2).flat();
|
|
427
428
|
const nextCursor = assertEx2(next.at(-1)?._sequence, () => `${moduleName2}: Expected next to have a sequence`);
|
|
428
429
|
const nextState = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } };
|
|
429
430
|
return [nextState, ...indexCandidates];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/memory/Diviner.ts", "../../src/model/Config.ts", "../../src/model/Schema.ts", "../../src/model/DivinerQueryToIndexQueryDiviner/Config.ts", "../../src/model/DivinerQueryToIndexQueryDiviner/Schema.ts", "../../src/model/IndexCandidateToIndexDiviner/Config.ts", "../../src/model/IndexCandidateToIndexDiviner/Schema.ts", "../../src/model/IndexQueryResponseToDivinerQueryResponseDiviner/Config.ts", "../../src/model/IndexQueryResponseToDivinerQueryResponseDiviner/Schema.ts", "../../src/model/Result/Schema.ts", "../../src/model/ResultIndex/Schema.ts", "../../src/model/StateToIndexCandidateDiviner/Config.ts", "../../src/model/StateToIndexCandidateDiviner/Schema.ts", "../../src/memory/DivinerQueryToIndexQueryDiviner/Diviner.ts", "../../src/memory/IndexCandidateToIndexDiviner/Diviner.ts", "../../src/memory/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts", "../../src/memory/StateToIndexCandidateDiviner/Diviner.ts"],
|
|
4
|
-
"sourcesContent": ["import { IndexingDiviner } from '@xyo-network/diviner-indexing/memory'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/sdk/diviner-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerParams } from '../model/index.ts'\nimport { TemporalIndexingDivinerConfigSchema } from '../model/index.ts'\n\nexport class TemporalIndexingDiviner<\n TParams extends TemporalIndexingDivinerParams = TemporalIndexingDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerConfigSchema\n\n protected override async startHandler(): Promise<void> {\n await super.startHandler()\n }\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { IndexingDivinerStage, IndexingDivinerStageConfig } from '@xyo-network/diviner-indexing/model'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig } from './DivinerQueryToIndexQueryDiviner/index.ts'\nimport type { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig } from './IndexQueryResponseToDivinerQueryResponseDiviner/index.ts'\nimport { TemporalIndexingDivinerSchema } from './Schema.ts'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerConfig } from './StateToIndexCandidateDiviner/index.ts'\n\nexport const TemporalIndexingDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.config`, true)\nexport type TemporalIndexingDivinerConfigSchema = typeof TemporalIndexingDivinerConfigSchema\n\n/**\n * Config section for declaring each indexing diviner stage\n */\nexport type IndexingDivinerStageTransformConfig = Record<IndexingDivinerStage, SchemaToJsonPathTransformExpressionsDictionary>\n\n// TODO: Extend indexing diviner config\n/**\n * Diviner Config for a Diviner which Indexes Payloads\n */\nexport type TemporalIndexingDivinerConfig = DivinerConfig<{\n /**\n * Where the diviner should store it's index\n */\n indexStore?: SearchableStorage\n /**\n * Config section for name/address of individual diviner stages\n */\n indexingDivinerStages?: IndexingDivinerStageConfig\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * How often to poll for new payloads to index\n */\n pollFrequency?: number\n /**\n * The schema for this config\n */\n schema: TemporalIndexingDivinerConfigSchema\n /**\n * Optional config section for individual diviner stages\n */\n stageConfigs?: {\n divinerQueryToIndexQueryDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexCandidateToIndexDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexQueryResponseToDivinerQueryResponseDiviner?: Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n stateToIndexCandidateDiviner?: Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n }\n /**\n * Where the diviner should persist its internal state\n */\n stateStore?: SearchableStorage\n}>\n\nexport const TemporalIndexingDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n indexStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n indexingDivinerStages: z.ZodMiniOptional<z.ZodMiniCustom<IndexingDivinerStageConfig, IndexingDivinerStageConfig>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n pollFrequency: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerConfigSchema>\n stageConfigs: z.ZodMiniOptional<z.ZodMiniObject<{\n divinerQueryToIndexQueryDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexCandidateToIndexDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexQueryResponseToDivinerQueryResponseDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n >\n >\n stateToIndexCandidateDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n >\n >\n }, z.core.$strip>>\n stateStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n indexStore: z.optional(z.custom<SearchableStorage>()),\n indexingDivinerStages: z.optional(z.custom<IndexingDivinerStageConfig>()),\n payloadDivinerLimit: z.optional(z.number()),\n pollFrequency: z.optional(z.number()),\n schema: z.literal(TemporalIndexingDivinerConfigSchema),\n stageConfigs: z.optional(z.object({\n divinerQueryToIndexQueryDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexCandidateToIndexDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexQueryResponseToDivinerQueryResponseDiviner: z.optional(\n z.custom<Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>>(),\n ),\n stateToIndexCandidateDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>>()),\n })),\n stateStore: z.optional(z.custom<SearchableStorage>()),\n})\n\nexport type TemporalIndexingDivinerConfigBase = z.infer<typeof TemporalIndexingDivinerConfigZod>\n\nexport const isTemporalIndexingDivinerConfig: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerConfigBase>>\n = zodIsFactory(TemporalIndexingDivinerConfigZod)\nexport const asTemporalIndexingDivinerConfig: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerConfigBase>>\n = zodAsFactory(TemporalIndexingDivinerConfigZod, 'asTemporalIndexingDivinerConfig')\nexport const toTemporalIndexingDivinerConfig: ReturnType<typeof zodToFactory<TemporalIndexingDivinerConfigBase>>\n = zodToFactory(TemporalIndexingDivinerConfigZod, 'toTemporalIndexingDivinerConfig')\n", "import { IndexingDivinerSchema } from '@xyo-network/diviner-indexing/model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const TemporalIndexingDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${IndexingDivinerSchema}.temporal`, true)\nexport type TemporalIndexingDivinerSchema = typeof TemporalIndexingDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema, type Schema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n divinerQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n divinerQuerySchema: z.optional(z.custom<Schema>()),\n indexQuerySchema: z.optional(z.custom<Schema>()),\n indexSchema: z.optional(z.custom<Schema>()),\n schema: z.literal(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner Query to an Index Query\n */\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig = DivinerConfig<{\n /**\n * The schema of the diviner query payloads\n */\n divinerQuerySchema?: Schema\n /**\n * The schema of the index query payloads\n */\n indexQuerySchema?: Schema\n /**\n * The schema of the index payloads\n */\n indexSchema?: Schema\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod)\nexport const asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\nexport const toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.diviner.query.to.index.query.diviner`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms Index Candidates to Indexes\n */\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodAsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\nexport const toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodToFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.candidate.to.index.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms an Index Query Response to a Diviner Query Response\n */\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\nexport const toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.query.response.to.diviner.query.response.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerResultSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.result`, true)\nexport type TemporalIndexingDivinerResultSchema = typeof TemporalIndexingDivinerResultSchema\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerResultSchema } from '../Result/index.ts'\n\nexport const TemporalIndexingDivinerResultIndexSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerResultSchema}.index`, true)\nexport type TemporalIndexingDivinerResultIndexSchema = typeof TemporalIndexingDivinerResultIndexSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { BoundWitnessDivinerPredicate } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerStateToIndexCandidateDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n filter: z.ZodMiniOptional<z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n payloadStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n filter: z.optional(z.custom<BoundWitnessDivinerPredicate>()),\n payloadDivinerLimit: z.optional(z.number()),\n payloadStore: z.optional(z.custom<SearchableStorage>()),\n schema: z.literal(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema),\n})\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner State to Index Candidates\n */\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfig = DivinerConfig<{\n /**\n * The filter to use to identify index candidates\n */\n filter?: BoundWitnessDivinerPredicate\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * Where the diviner should look for stored thumbnails\n */\n payloadStore?: SearchableStorage\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n}>\n\nexport const isTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod)\nexport const asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\nexport const toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.state.to.index.candidate.diviner`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\nimport { isPayloadOfSchemaType, PayloadBuilder } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n// TODO: Inherit from JsonPathAggregateDiviner\n/**\n * A diviner that converts diviner query to index query\n */\nexport class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<\n TParams extends TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): Schema {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): Schema {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): Schema {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return (\n this.config?.schemaTransforms ?? {\n [this.divinerQuerySchema]: [\n {\n defaultValue: 1,\n destinationField: 'limit',\n sourcePathExpression: '$.limit',\n },\n {\n // defaultValue: 0,\n destinationField: 'cursor',\n sourcePathExpression: '$.cursor',\n },\n {\n defaultValue: 'desc',\n destinationField: 'order',\n sourcePathExpression: '$.order',\n },\n ],\n }\n )\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument\n const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema as any))\n if (queries.length > 0) {\n return await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { $sources?: Hash[]; sources?: Hash[] }>(\n [query],\n this.payloadTransformers,\n this.indexQuerySchema,\n )\n // TODO: Make index schema configurable\n fields.schemas = [this.indexSchema]\n // TODO: Make sources not need to be deleted\n delete fields.sources\n delete fields?.$sources\n // TODO: Add support for additional filters\n const payloadBuilder = new PayloadBuilder<Payload>({ schema: this.indexQuerySchema })\n return payloadBuilder.fields(fields).build()\n }),\n )\n }\n return []\n }\n}\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n assertEx, containsAll, exists,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isAnyPayload, isBoundWitness, PayloadBuilder,\n} from '@xyo-network/sdk-protocol'\n\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n\ntype IndexableHashes = [Hash, ...Hash[]]\n\nconst moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'\n\n/**\n * Diviner which transforms index candidates to indexes using JSON Path to map\n * source properties in the supplied payloads to destination fields in the\n * resultant index\n */\nexport class TemporalIndexingDivinerIndexCandidateToIndexDiviner<\n TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\n .filter(bw => containsAll(bw.payload_schemas, this.indexableSchemas))\n // If the Payload is not one of the indexable schemas do not index it\n const indexablePayloads = payloads.filter(p => this.isIndexablePayload(p))\n // If there is nothing to index, return an empty array\n if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return []\n // Hash all the indexable data once\n const [bwDictionary, payloadDictionary] = await Promise.all([\n PayloadBuilder.toHashMap(indexableBoundWitnesses),\n PayloadBuilder.toAllHashMap(indexablePayloads),\n ])\n\n // Initialize the array for validIndexableTuples outside of the loop\n const validIndexableTuples: IndexableHashes[] = []\n\n // Iterate over each entry in bwDictionary\n for (const [bwHash, bw] of Object.entries(bwDictionary) as [Hash, BoundWitness][]) {\n // Find the combinations of payloads that satisfy the required schemas\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas)\n\n // Iterate over each combination\n for (const combination of combinations) {\n const indexablePayloads = combination.map(hash => payloadDictionary[hash]).filter(exists)\n\n // If we found the right amount of indexable payloads (of the correct schema as checked\n // above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) {\n validIndexableTuples.push([bwHash, ...combination])\n }\n }\n }\n\n // Create the indexes from the tuples\n const indexes = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([bwHash, ...sourcePayloadHashes]) => {\n const sourcePayloads = sourcePayloadHashes.map(hash => payloadDictionary[hash])\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap((payload) => {\n // Find the transformers for this payload\n const transformers = this.payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers ? transformers.map(transform => transform(payload)) : []\n })\n // Include all the sources for reference\n const $sources: Hash[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n const payloadBuilder = new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n return payloadBuilder\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n .fields(Object.assign({}, ...indexFields))\n .meta({ $sources })\n .build()\n })\n return indexes.flat()\n }\n\n /**\n * Identifies if a payload is one that is indexed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one indexed by this diviner, false otherwise\n */\n protected isIndexablePayload = (x: unknown): boolean => {\n return isAnyPayload(x) && this.indexableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is indexed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one indexed by this diviner, false otherwise\n */\n protected isIndexableSchema = (schema?: Schema | null): boolean => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n", "import { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * Transforms an ImageThumbnailIndex response into an ImageThumbnailResponse response\n */\nexport class TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner {\n static override readonly configSchemas: Schema[] = [\n ...super.configSchemas,\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema,\n ]\n\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // We're not doing anything with the query payloads but some diviners\n // might want to use this to transform from the query to the response (for example\n // if we use a plaintext value in the query to generate a hash key in the index)\n // const queries = payloads.filter(isPayloadDivinerQueryPayload)\n const responses = payloads.filter(p => !isPayloadDivinerQueryPayload(p))\n return responses\n }\n}\n", "import { assertEx, exists } from '@ariestools/sdk'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing/model'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/sdk/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/sdk/archivist-wrapper'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/sdk/diviner-boundwitness/abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport { DivinerWrapper } from '@xyo-network/sdk/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/sdk/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness,\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isBoundWitness, payloadSchemasContainsAll, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\nimport type { Timestamp } from '@xyo-network/witness-timestamp'\nimport { TimestampSchema } from '@xyo-network/witness-timestamp'\n\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '../../model/index.ts'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * All Payload types involved in index candidates for indexing\n */\nexport type IndexCandidate = BoundWitness | Payload | Timestamp\n\n/**\n * The response from the TemporalStateToIndexCandidateDiviner\n */\nexport type TemporalStateToIndexCandidateDivinerResponse = [\n /**\n * The next state of the diviner\n */\n nextState: ModuleState<IndexingDivinerState>,\n /**\n * The index candidates\n */\n ...IndexCandidate[],\n]\n\n/**\n * The default order to search Bound Witnesses to identify index candidates\n */\nconst order = 'asc'\n\n/**\n * The name of the module (for logging purposes)\n */\nconst moduleName = 'TemporalIndexingDivinerStateToIndexCandidateDiviner'\n\n/**\n * Transforms candidates for image thumbnail indexing into their indexed representation\n */\nexport class TemporalIndexingDivinerStateToIndexCandidateDiviner<\n TParams extends TemporalIndexingDivinerStateToIndexCandidateDivinerParams = TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n> extends AbstractDiviner<TParams, Payload, ModuleState | IndexCandidate> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit(): number {\n return this.config.payloadDivinerLimit ?? 1000\n }\n\n /**\n * The required payload_schemas within BoundWitnesses to identify index candidates\n */\n protected get payload_schemas(): Schema[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<TemporalStateToIndexCandidateDivinerResponse> {\n // Retrieve the last state from what was passed in\n const lastState = payloads.find(isModuleState<IndexingDivinerState>)\n // If there is no last state, start from the beginning\n ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n\n const batch = next.filter(x => isBoundWitness(x))\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const indexCandidates: IndexCandidate[] = (await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\n\n /**\n * Retrieves the archivist for the payloadStore\n * @returns The archivist for the payloadStore or undefined if not resolvable\n */\n protected async getArchivistForStore(): Promise<ArchivistWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.archivist,\n () => `${moduleName}: Config for payloadStore.archivist not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped archivist\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the payloadStore\n * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable\n */\n protected async getBoundWitnessDivinerForStore(): Promise<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n > | undefined\n > {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for payloadStore.boundWitnessDiviner not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return\n // Return the wrapped diviner\n return DivinerWrapper.wrap<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n >\n >(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.payload_schemas).flat()\n if (combinations.length === 0) return undefined\n const hashes = new Set(combinations)\n const indexCandidates = await archivist.get([...hashes])\n return [bw, ...indexCandidates]\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;;;ACAhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AAIP,SAAS,wBAAwB;AACjC,SAAS,YAAAA,iBAAgB;AACzB,YAAY,OAAO;;;ACRnB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAElB,IAAM,gCAET,SAAS,GAAG,qBAAqB,aAAa,IAAI;;;ADU/C,IAAM,sCAETC,UAAS,GAAG,6BAA6B,WAAW,IAAI;AAgDrD,IAAM,mCAoCP,SAAO,kBAAkB;AAAA,EAC7B,YAAc,WAAW,SAA0B,CAAC;AAAA,EACpD,uBAAyB,WAAW,SAAmC,CAAC;AAAA,EACxE,qBAAuB,WAAW,SAAO,CAAC;AAAA,EAC1C,eAAiB,WAAW,SAAO,CAAC;AAAA,EACpC,QAAU,UAAQ,mCAAmC;AAAA,EACrD,cAAgB,WAAW,SAAO;AAAA,IAChC,iCAAmC,WAAW,SAAqF,CAAC;AAAA,IACpI,8BAAgC,WAAW,SAAqF,CAAC;AAAA,IACjI,iDAAmD;AAAA,MAC/C,SAAqG;AAAA,IACzG;AAAA,IACA,8BAAgC,WAAW,SAAkF,CAAC;AAAA,EAChI,CAAC,CAAC;AAAA,EACF,YAAc,WAAW,SAA0B,CAAC;AACtD,CAAC;AAIM,IAAM,kCACT,aAAa,gCAAgC;AAC1C,IAAM,kCACT,aAAa,kCAAkC,iCAAiC;AAC7E,IAAM,kCACT,aAAa,kCAAkC,iCAAiC;;;AE7HpF;AAAA,EACE,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AAGP,SAAS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AAI,UAAQ,kBAAkB,IAAI,CAAC;AAE9E,YAAM,cAAc,eAAe,QAAQ,CAAC,YAAY;AAEtD,cAAM,eAAe,KAAK,oBAAoB,QAAQ,MAAM;AAE5D,eAAO,
|
|
4
|
+
"sourcesContent": ["import { IndexingDiviner } from '@xyo-network/diviner-indexing/memory'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/sdk/diviner-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerParams } from '../model/index.ts'\nimport { TemporalIndexingDivinerConfigSchema } from '../model/index.ts'\n\nexport class TemporalIndexingDiviner<\n TParams extends TemporalIndexingDivinerParams = TemporalIndexingDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerConfigSchema\n\n protected override async startHandler(): Promise<void> {\n await super.startHandler()\n }\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { IndexingDivinerStage, IndexingDivinerStageConfig } from '@xyo-network/diviner-indexing/model'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig } from './DivinerQueryToIndexQueryDiviner/index.ts'\nimport type { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig } from './IndexQueryResponseToDivinerQueryResponseDiviner/index.ts'\nimport { TemporalIndexingDivinerSchema } from './Schema.ts'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerConfig } from './StateToIndexCandidateDiviner/index.ts'\n\nexport const TemporalIndexingDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.config`, true)\nexport type TemporalIndexingDivinerConfigSchema = typeof TemporalIndexingDivinerConfigSchema\n\n/**\n * Config section for declaring each indexing diviner stage\n */\nexport type IndexingDivinerStageTransformConfig = Record<IndexingDivinerStage, SchemaToJsonPathTransformExpressionsDictionary>\n\n// TODO: Extend indexing diviner config\n/**\n * Diviner Config for a Diviner which Indexes Payloads\n */\nexport type TemporalIndexingDivinerConfig = DivinerConfig<{\n /**\n * Where the diviner should store it's index\n */\n indexStore?: SearchableStorage\n /**\n * Config section for name/address of individual diviner stages\n */\n indexingDivinerStages?: IndexingDivinerStageConfig\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * How often to poll for new payloads to index\n */\n pollFrequency?: number\n /**\n * The schema for this config\n */\n schema: TemporalIndexingDivinerConfigSchema\n /**\n * Optional config section for individual diviner stages\n */\n stageConfigs?: {\n divinerQueryToIndexQueryDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexCandidateToIndexDiviner?: Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n indexQueryResponseToDivinerQueryResponseDiviner?: Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n stateToIndexCandidateDiviner?: Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n }\n /**\n * Where the diviner should persist its internal state\n */\n stateStore?: SearchableStorage\n}>\n\nexport const TemporalIndexingDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n indexStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n indexingDivinerStages: z.ZodMiniOptional<z.ZodMiniCustom<IndexingDivinerStageConfig, IndexingDivinerStageConfig>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n pollFrequency: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerConfigSchema>\n stageConfigs: z.ZodMiniOptional<z.ZodMiniObject<{\n divinerQueryToIndexQueryDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexCandidateToIndexDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>\n >\n >\n indexQueryResponseToDivinerQueryResponseDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>\n >\n >\n stateToIndexCandidateDiviner: z.ZodMiniOptional<\n z.ZodMiniCustom<\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>,\n Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>\n >\n >\n }, z.core.$strip>>\n stateStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n indexStore: z.optional(z.custom<SearchableStorage>()),\n indexingDivinerStages: z.optional(z.custom<IndexingDivinerStageConfig>()),\n payloadDivinerLimit: z.optional(z.number()),\n pollFrequency: z.optional(z.number()),\n schema: z.literal(TemporalIndexingDivinerConfigSchema),\n stageConfigs: z.optional(z.object({\n divinerQueryToIndexQueryDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexCandidateToIndexDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig, 'schema'>>()),\n indexQueryResponseToDivinerQueryResponseDiviner: z.optional(\n z.custom<Omit<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig, 'schema'>>(),\n ),\n stateToIndexCandidateDiviner: z.optional(z.custom<Omit<TemporalIndexingDivinerStateToIndexCandidateDivinerConfig, 'schema'>>()),\n })),\n stateStore: z.optional(z.custom<SearchableStorage>()),\n})\n\nexport type TemporalIndexingDivinerConfigBase = z.infer<typeof TemporalIndexingDivinerConfigZod>\n\nexport const isTemporalIndexingDivinerConfig: ReturnType<typeof zodIsFactory<TemporalIndexingDivinerConfigBase>>\n = zodIsFactory(TemporalIndexingDivinerConfigZod)\nexport const asTemporalIndexingDivinerConfig: ReturnType<typeof zodAsFactory<TemporalIndexingDivinerConfigBase>>\n = zodAsFactory(TemporalIndexingDivinerConfigZod, 'asTemporalIndexingDivinerConfig')\nexport const toTemporalIndexingDivinerConfig: ReturnType<typeof zodToFactory<TemporalIndexingDivinerConfigBase>>\n = zodToFactory(TemporalIndexingDivinerConfigZod, 'toTemporalIndexingDivinerConfig')\n", "import { IndexingDivinerSchema } from '@xyo-network/diviner-indexing/model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const TemporalIndexingDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${IndexingDivinerSchema}.temporal`, true)\nexport type TemporalIndexingDivinerSchema = typeof TemporalIndexingDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema, type Schema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n divinerQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexQuerySchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n indexSchema: z.ZodMiniOptional<z.ZodMiniCustom<Schema, Schema>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n divinerQuerySchema: z.optional(z.custom<Schema>()),\n indexQuerySchema: z.optional(z.custom<Schema>()),\n indexSchema: z.optional(z.custom<Schema>()),\n schema: z.literal(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner Query to an Index Query\n */\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig = DivinerConfig<{\n /**\n * The schema of the diviner query payloads\n */\n divinerQuerySchema?: Schema\n /**\n * The schema of the index query payloads\n */\n indexQuerySchema?: Schema\n /**\n * The schema of the index payloads\n */\n indexSchema?: Schema\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod)\nexport const asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'asTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\nexport const toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigZod,\n 'toTemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.diviner.query.to.index.query.diviner`, true)\n\nexport type TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n = typeof TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms Index Candidates to Indexes\n */\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodAsFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'asTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\nexport const toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigBase>\n> = zodToFactory(TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigZod, 'toTemporalIndexingDivinerIndexCandidateToIndexDivinerConfig')\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.candidate.to.index.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema = typeof TemporalIndexingDivinerIndexCandidateToIndexDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport type { DivinerConfig } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema>\n schemaTransforms: z.ZodMiniOptional<\n z.ZodMiniCustom<SchemaToJsonPathTransformExpressionsDictionary, SchemaToJsonPathTransformExpressionsDictionary>\n >\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n schema: z.literal(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema),\n schemaTransforms: z.optional(z.custom<SchemaToJsonPathTransformExpressionsDictionary>()),\n})\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms an Index Query Response to a Diviner Query Response\n */\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig = DivinerConfig<{\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n /**\n * The transforms to apply to the source payloads\n */\n schemaTransforms?: SchemaToJsonPathTransformExpressionsDictionary\n}>\n\nexport const isTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod)\nexport const asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'asTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\nexport const toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigZod,\n 'toTemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.index.query.response.to.diviner.query.response.diviner`, true)\n\nexport type TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n = typeof TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerSchema\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerResultSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.result`, true)\nexport type TemporalIndexingDivinerResultSchema = typeof TemporalIndexingDivinerResultSchema\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerResultSchema } from '../Result/index.ts'\n\nexport const TemporalIndexingDivinerResultIndexSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerResultSchema}.index`, true)\nexport type TemporalIndexingDivinerResultIndexSchema = typeof TemporalIndexingDivinerResultIndexSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { BoundWitnessDivinerPredicate } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport type { DivinerConfig, SearchableStorage } from '@xyo-network/sdk/diviner-model'\nimport { DivinerConfigZod } from '@xyo-network/sdk/diviner-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerSchema } from './Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerStateToIndexCandidateDivinerSchema}.config`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n filter: z.ZodMiniOptional<z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>>\n payloadDivinerLimit: z.ZodMiniOptional<z.ZodMiniNumber<number>>\n payloadStore: z.ZodMiniOptional<z.ZodMiniCustom<SearchableStorage, SearchableStorage>>\n schema: z.ZodMiniLiteral<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n filter: z.optional(z.custom<BoundWitnessDivinerPredicate>()),\n payloadDivinerLimit: z.optional(z.number()),\n payloadStore: z.optional(z.custom<SearchableStorage>()),\n schema: z.literal(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema),\n})\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase = z.infer<\n typeof TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod\n>\n\n/**\n * Diviner Config for a Diviner which transforms a Diviner State to Index Candidates\n */\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerConfig = DivinerConfig<{\n /**\n * The filter to use to identify index candidates\n */\n filter?: BoundWitnessDivinerPredicate\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * Where the diviner should look for stored thumbnails\n */\n payloadStore?: SearchableStorage\n /**\n * The config schema\n */\n schema: TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n}>\n\nexport const isTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodIsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodIsFactory(TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod)\nexport const asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodAsFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodAsFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'asTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\nexport const toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig: ReturnType<\n typeof zodToFactory<TemporalIndexingDivinerStateToIndexCandidateDivinerConfigBase>\n> = zodToFactory(\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigZod,\n 'toTemporalIndexingDivinerStateToIndexCandidateDivinerConfig',\n)\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerSchema } from '../Schema.ts'\n\nexport const TemporalIndexingDivinerStateToIndexCandidateDivinerSchema: string & {\n readonly __schema: true\n} = asSchema(`${TemporalIndexingDivinerSchema}.stage.state.to.index.candidate.diviner`, true)\n\nexport type TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n = typeof TemporalIndexingDivinerStateToIndexCandidateDivinerSchema\n", "import type { Hash } from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\nimport { isPayloadOfSchemaType, PayloadBuilder } from '@xyo-network/sdk-protocol'\n\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n// TODO: Inherit from JsonPathAggregateDiviner\n/**\n * A diviner that converts diviner query to index query\n */\nexport class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<\n TParams extends TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): Schema {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): Schema {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): Schema {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return (\n this.config?.schemaTransforms ?? {\n [this.divinerQuerySchema]: [\n {\n defaultValue: 1,\n destinationField: 'limit',\n sourcePathExpression: '$.limit',\n },\n {\n // defaultValue: 0,\n destinationField: 'cursor',\n sourcePathExpression: '$.cursor',\n },\n {\n defaultValue: 'desc',\n destinationField: 'order',\n sourcePathExpression: '$.order',\n },\n ],\n }\n )\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument\n const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema as any))\n if (queries.length > 0) {\n return await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { $sources?: Hash[]; sources?: Hash[] }>(\n [query],\n this.payloadTransformers,\n this.indexQuerySchema,\n )\n // TODO: Make index schema configurable\n fields.schemas = [this.indexSchema]\n // TODO: Make sources not need to be deleted\n delete fields.sources\n delete fields?.$sources\n // TODO: Add support for additional filters\n const payloadBuilder = new PayloadBuilder<Payload>({ schema: this.indexQuerySchema })\n return payloadBuilder.fields(fields).build()\n }),\n )\n }\n return []\n }\n}\n", "import type { Hash } from '@ariestools/sdk'\nimport {\n assertEx, containsAll, exists,\n} from '@ariestools/sdk'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath/model'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate/memory'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness, Payload, Schema,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isAnyPayload, isBoundWitness, PayloadBuilder,\n} from '@xyo-network/sdk-protocol'\n\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '../../model/index.ts'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '../../model/index.ts'\n\ntype IndexableHashes = [Hash, ...Hash[]]\n\nconst moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'\n\n/**\n * Diviner which transforms index candidates to indexes using JSON Path to map\n * source properties in the supplied payloads to destination fields in the\n * resultant index\n */\nexport class TemporalIndexingDivinerIndexCandidateToIndexDiviner<\n TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: Schema[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): Schema[] {\n this._indexableSchemas ??= Object.keys(this.schemaTransforms) as Schema[]\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\n .filter(bw => containsAll(bw.payload_schemas, this.indexableSchemas))\n // If the Payload is not one of the indexable schemas do not index it\n const indexablePayloads = payloads.filter(p => this.isIndexablePayload(p))\n // If there is nothing to index, return an empty array\n if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return []\n // Hash all the indexable data once\n const [bwDictionary, payloadDictionary] = await Promise.all([\n PayloadBuilder.toHashMap(indexableBoundWitnesses),\n PayloadBuilder.toAllHashMap(indexablePayloads),\n ])\n\n // Initialize the array for validIndexableTuples outside of the loop\n const validIndexableTuples: IndexableHashes[] = []\n\n // Iterate over each entry in bwDictionary\n for (const [bwHash, bw] of Object.entries(bwDictionary) as [Hash, BoundWitness][]) {\n // Find the combinations of payloads that satisfy the required schemas\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas)\n\n // Iterate over each combination\n for (const combination of combinations) {\n const indexablePayloads = combination.map(hash => payloadDictionary[hash]).filter(exists)\n\n // If we found the right amount of indexable payloads (of the correct schema as checked\n // above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) {\n validIndexableTuples.push([bwHash, ...combination])\n }\n }\n }\n\n // Create the indexes from the tuples\n const indexes = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([bwHash, ...sourcePayloadHashes]) => {\n const sourcePayloads = sourcePayloadHashes.map(hash => payloadDictionary[hash])\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap((payload) => {\n // Find the transformers for this payload\n const transformers = this.payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers === undefined ? [] : transformers.map(transform => transform(payload))\n })\n // Include all the sources for reference\n const $sources: Hash[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n const payloadBuilder = new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n return payloadBuilder\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n .fields(Object.assign({}, ...indexFields))\n .meta({ $sources })\n .build()\n })\n return indexes.flat()\n }\n\n /**\n * Identifies if a payload is one that is indexed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one indexed by this diviner, false otherwise\n */\n protected isIndexablePayload = (x: unknown): boolean => {\n return isAnyPayload(x) && this.indexableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is indexed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one indexed by this diviner, false otherwise\n */\n protected isIndexableSchema = (schema?: Schema | null): boolean => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n", "import { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/sdk/diviner-payload-model'\nimport type { Labels } from '@xyo-network/sdk/module-model'\nimport type { Payload, Schema } from '@xyo-network/sdk-protocol'\n\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * Transforms an ImageThumbnailIndex response into an ImageThumbnailResponse response\n */\nexport class TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner {\n static override readonly configSchemas: Schema[] = [\n ...super.configSchemas,\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema,\n ]\n\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // We're not doing anything with the query payloads but some diviners\n // might want to use this to transform from the query to the response (for example\n // if we use a plaintext value in the query to generate a hash key in the index)\n // const queries = payloads.filter(isPayloadDivinerQueryPayload)\n const responses = payloads.filter(p => !isPayloadDivinerQueryPayload(p))\n return responses\n }\n}\n", "import { assertEx, exists } from '@ariestools/sdk'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing/model'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/sdk/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/sdk/archivist-wrapper'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/sdk/diviner-boundwitness/abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport { DivinerWrapper } from '@xyo-network/sdk/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/sdk/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness,\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n intraBoundwitnessSchemaCombinations, isBoundWitness, payloadSchemasContainsAll, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\nimport type { Timestamp } from '@xyo-network/witness-timestamp'\nimport { TimestampSchema } from '@xyo-network/witness-timestamp'\n\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '../../model/index.ts'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '../../model/index.ts'\n\n/**\n * All Payload types involved in index candidates for indexing\n */\nexport type IndexCandidate = BoundWitness | Payload | Timestamp\n\n/**\n * The response from the TemporalStateToIndexCandidateDiviner\n */\nexport type TemporalStateToIndexCandidateDivinerResponse = [\n /**\n * The next state of the diviner\n */\n nextState: ModuleState<IndexingDivinerState>,\n /**\n * The index candidates\n */\n ...indexCandidates: IndexCandidate[],\n]\n\n/**\n * The default order to search Bound Witnesses to identify index candidates\n */\nconst order = 'asc'\n\n/**\n * The name of the module (for logging purposes)\n */\nconst moduleName = 'TemporalIndexingDivinerStateToIndexCandidateDiviner'\n\n/**\n * Transforms candidates for image thumbnail indexing into their indexed representation\n */\nexport class TemporalIndexingDivinerStateToIndexCandidateDiviner<\n TParams extends TemporalIndexingDivinerStateToIndexCandidateDivinerParams = TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n> extends AbstractDiviner<TParams, Payload, ModuleState | IndexCandidate> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override readonly labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit(): number {\n return this.config.payloadDivinerLimit ?? 1000\n }\n\n /**\n * The required payload_schemas within BoundWitnesses to identify index candidates\n */\n protected get payload_schemas(): Schema[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<TemporalStateToIndexCandidateDivinerResponse> {\n // Retrieve the last state from what was passed in\n const lastState = payloads.find(isModuleState<IndexingDivinerState>)\n // If there is no last state, start from the beginning\n ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n\n const batch = next.filter(x => isBoundWitness(x))\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const batchResults = await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist)))\n const indexCandidates: IndexCandidate[] = batchResults\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\n\n /**\n * Retrieves the archivist for the payloadStore\n * @returns The archivist for the payloadStore or undefined if not resolvable\n */\n protected async getArchivistForStore(): Promise<ArchivistWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.archivist,\n () => `${moduleName}: Config for payloadStore.archivist not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped archivist\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the payloadStore\n * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable\n */\n protected async getBoundWitnessDivinerForStore(): Promise<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n > | undefined\n > {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for payloadStore.boundWitnessDiviner not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return\n // Return the wrapped diviner\n return DivinerWrapper.wrap<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n WithStorageMeta<BoundWitness>\n >\n >(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.payload_schemas).flat()\n if (combinations.length === 0) return undefined\n const hashes = new Set(combinations)\n const indexCandidates = await archivist.get([...hashes])\n return [bw, ...indexCandidates]\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,uBAAuB;;;ACAhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AAIP,SAAS,wBAAwB;AACjC,SAAS,YAAAA,iBAAgB;AACzB,YAAY,OAAO;;;ACRnB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAElB,IAAM,gCAET,SAAS,GAAG,qBAAqB,aAAa,IAAI;;;ADU/C,IAAM,sCAETC,UAAS,GAAG,6BAA6B,WAAW,IAAI;AAgDrD,IAAM,mCAoCP,SAAO,kBAAkB;AAAA,EAC7B,YAAc,WAAW,SAA0B,CAAC;AAAA,EACpD,uBAAyB,WAAW,SAAmC,CAAC;AAAA,EACxE,qBAAuB,WAAW,SAAO,CAAC;AAAA,EAC1C,eAAiB,WAAW,SAAO,CAAC;AAAA,EACpC,QAAU,UAAQ,mCAAmC;AAAA,EACrD,cAAgB,WAAW,SAAO;AAAA,IAChC,iCAAmC,WAAW,SAAqF,CAAC;AAAA,IACpI,8BAAgC,WAAW,SAA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,MAAM,KAAK,QAAQ,IAAI;AACnC,QAAI,CAAC,IAAK;AAEV,WAAO,eAAe,KAMpB,KAAK,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,MAAgB,0BAA0B,IAAkB,WAAqE;AAC/H,UAAM,eAAeK,qCAAoC,IAAI,KAAK,eAAe,EAAE,KAAK;AACxF,QAAI,aAAa,WAAW,EAAG,QAAO;AACtC,UAAM,SAAS,IAAI,IAAI,YAAY;AACnC,UAAM,kBAAkB,MAAM,UAAU,IAAI,CAAC,GAAG,MAAM,CAAC;AACvD,WAAO,CAAC,IAAI,GAAG,eAAe;AAAA,EAChC;AACF;",
|
|
6
6
|
"names": ["asSchema", "asSchema", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "asSchema", "asSchema", "asSchema", "asSchema", "zodAsFactory", "zodIsFactory", "zodToFactory", "DivinerConfigZod", "asSchema", "z", "asSchema", "asSchema", "asSchema", "DivinerConfigZod", "zodIsFactory", "zodAsFactory", "zodToFactory", "jsonPathToTransformersDictionary", "AbstractDiviner", "PayloadBuilder", "AbstractDiviner", "jsonPathToTransformersDictionary", "PayloadBuilder", "indexablePayloads", "AbstractDiviner", "AbstractDiviner", "assertEx", "exists", "AbstractDiviner", "intraBoundwitnessSchemaCombinations", "isBoundWitness", "moduleName", "AbstractDiviner", "isBoundWitness", "exists", "assertEx", "intraBoundwitnessSchemaCombinations"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-temporal-indexing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -42,33 +42,33 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@xyo-network/diviner-indexing": "~
|
|
46
|
-
"@xyo-network/diviner-jsonpath": "~
|
|
47
|
-
"@xyo-network/diviner-jsonpath-aggregate": "~
|
|
48
|
-
"@xyo-network/sdk": "~
|
|
49
|
-
"@xyo-network/witness-timestamp": "~
|
|
45
|
+
"@xyo-network/diviner-indexing": "~8.0.1",
|
|
46
|
+
"@xyo-network/diviner-jsonpath": "~8.0.1",
|
|
47
|
+
"@xyo-network/diviner-jsonpath-aggregate": "~8.0.1",
|
|
48
|
+
"@xyo-network/sdk": "~8.0.1",
|
|
49
|
+
"@xyo-network/witness-timestamp": "~8.0.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@ariestools/sdk": "~
|
|
53
|
-
"@ariestools/testing": "~
|
|
54
|
-
"@ariestools/toolchain": "~10.0.
|
|
55
|
-
"@ariestools/tsconfig": "~10.0.
|
|
52
|
+
"@ariestools/sdk": "~9.0.0",
|
|
53
|
+
"@ariestools/testing": "~9.0.0",
|
|
54
|
+
"@ariestools/toolchain": "~10.0.7",
|
|
55
|
+
"@ariestools/tsconfig": "~10.0.7",
|
|
56
56
|
"@opentelemetry/api": "~1.9.1",
|
|
57
|
-
"@xyo-network/sdk-protocol": "~
|
|
58
|
-
"eslint": "~10.
|
|
57
|
+
"@xyo-network/sdk-protocol": "~8.0.1",
|
|
58
|
+
"eslint": "~10.11.0",
|
|
59
59
|
"eslint-import-resolver-typescript": "~4.4.5",
|
|
60
60
|
"typescript": "~6.0.3",
|
|
61
61
|
"vite": "~8.3.0",
|
|
62
|
-
"vitest": "~5.0.
|
|
63
|
-
"zod": "~4.6.
|
|
62
|
+
"vitest": "~5.0.1",
|
|
63
|
+
"zod": "~4.6.5"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@ariestools/sdk": "^
|
|
67
|
-
"@xyo-network/sdk-protocol": "^
|
|
66
|
+
"@ariestools/sdk": "^9.0",
|
|
67
|
+
"@xyo-network/sdk-protocol": "^8.0",
|
|
68
68
|
"zod": "^4.6"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
|
-
"node": "^
|
|
71
|
+
"node": "^26"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|