@xyo-network/diviner-payload-generic 7.0.8 → 7.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- export * from './Diviner.ts';
1
+ export * from '@xyo-network/sdk/diviner-payload-generic';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,0CAA0C,CAAA"}
@@ -1,181 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __reflectGet = Reflect.get;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __decorateClass = (decorators, target, key, kind) => {
7
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
8
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
- if (decorator = decorators[i])
10
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
11
- if (kind && result) __defProp(target, key, result);
12
- return result;
13
- };
14
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
- var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
16
-
17
- // src/Diviner.ts
18
- import {
19
- assertEx,
20
- filterAs,
21
- forget,
22
- zodAsFactory,
23
- zodIsFactory,
24
- zodToFactory
25
- } from "@ariestools/sdk";
26
- import { PayloadDiviner } from "@xyo-network/diviner-payload-abstract";
27
- import { asPayloadDivinerQueryPayload, PayloadDivinerConfigZod } from "@xyo-network/diviner-payload-model";
28
- import { creatableModule } from "@xyo-network/module-model";
29
- import { PayloadBuilder } from "@xyo-network/sdk-protocol";
30
- import {
31
- asSchema
32
- } from "@xyo-network/sdk-protocol";
33
- import { Mutex } from "async-mutex";
34
- import * as z from "zod/mini";
35
- var DEFAULT_INDEX_BATCH_SIZE = 100;
36
- var DEFAULT_MAX_INDEX_SIZE = 8e3;
37
- var GenericPayloadDivinerConfigSchema = asSchema("network.xyo.diviner.payload.generic.config", true);
38
- var GenericPayloadDivinerConfigZod = z.extend(PayloadDivinerConfigZod, {
39
- indexes: z.optional(z.array(z.string())),
40
- schema: z.literal(GenericPayloadDivinerConfigSchema)
41
- });
42
- var isGenericPayloadDivinerConfig = zodIsFactory(GenericPayloadDivinerConfigZod);
43
- var asGenericPayloadDivinerConfig = zodAsFactory(GenericPayloadDivinerConfigZod, "asGenericPayloadDivinerConfig");
44
- var toGenericPayloadDivinerConfig = zodToFactory(GenericPayloadDivinerConfigZod, "toGenericPayloadDivinerConfig");
45
- var GenericPayloadDiviner = class extends PayloadDiviner {
46
- indexMaps = {};
47
- payloadsWithMeta = [];
48
- _archivistInstance;
49
- _cursor;
50
- _updatePayloadPairsMutex = new Mutex();
51
- get indexBatchSize() {
52
- return this.config.indexBatchSize ?? DEFAULT_INDEX_BATCH_SIZE;
53
- }
54
- get indexes() {
55
- return ["schema", ...this.config.indexes ?? []];
56
- }
57
- get maxIndexSize() {
58
- return this.config.maxIndexSize ?? DEFAULT_MAX_INDEX_SIZE;
59
- }
60
- all(order = "desc", cursor) {
61
- const payloads = this.payloadsWithMeta.toSorted(PayloadBuilder.compareStorageMeta);
62
- if (order === "desc") payloads.reverse();
63
- const startIndex = (cursor ? payloads.findIndex((payload) => payload._sequence === cursor) ?? -1 : -1) + 1;
64
- return payloads.slice(startIndex);
65
- }
66
- async archivistInstance(required = false) {
67
- if (!this._archivistInstance) {
68
- const archivist = await super.archivistInstance();
69
- if (required && !archivist) {
70
- throw new Error("Failed to find archivist");
71
- }
72
- archivist?.on("inserted", this.onArchivistInserted);
73
- archivist?.on("cleared", this.onArchivistCleared);
74
- archivist?.on("deleted", this.onArchivistDeleted);
75
- this._archivistInstance = archivist;
76
- }
77
- return this._archivistInstance;
78
- }
79
- async clearIndex() {
80
- await this._updatePayloadPairsMutex.runExclusive(() => {
81
- this._cursor = void 0;
82
- this.payloadsWithMeta = [];
83
- this.indexMaps = {};
84
- });
85
- }
86
- async divineHandler(payloads) {
87
- const filters = filterAs(payloads ?? [], asPayloadDivinerQueryPayload);
88
- assertEx(filters.length < 2, () => "Multiple PayloadDivinerQuery payloads may not be specified");
89
- const filter = assertEx(filters.shift(), () => "No PayloadDivinerQuery specified");
90
- await this.updateIndex();
91
- const {
92
- schema,
93
- schemas,
94
- order,
95
- limit,
96
- cursor,
97
- ...props
98
- } = filter;
99
- let all = this.all(order, cursor);
100
- if (all) {
101
- if (schemas?.length) all = all.filter((payload) => schemas.includes(payload.schema));
102
- if (Object.keys(props).length > 0) {
103
- const additionalFilterCriteria = Object.entries(props);
104
- for (const [prop, filter2] of additionalFilterCriteria) {
105
- const property = prop;
106
- all = Array.isArray(filter2) ? all.filter((payload) => filter2.every((value) => {
107
- const prop2 = payload?.[property];
108
- return Array.isArray(prop2) && prop2.includes?.(value);
109
- })) : all.filter((payload) => payload?.[property] === filter2);
110
- }
111
- }
112
- return limit ? all.slice(0, limit) : all;
113
- } else {
114
- throw new Error('Archivist does not support "all"');
115
- }
116
- }
117
- onArchivistCleared = () => {
118
- forget(
119
- (async () => {
120
- await this.clearIndex();
121
- await this.updateIndex();
122
- })()
123
- );
124
- };
125
- // we are just rebuilding the entire index at this point on delete since large archivists do not support delete
126
- onArchivistDeleted = () => {
127
- forget(
128
- (async () => {
129
- await this.clearIndex();
130
- await this.updateIndex();
131
- })()
132
- );
133
- };
134
- onArchivistInserted = () => {
135
- forget(this.updateIndex());
136
- };
137
- async stopHandler(_timeout) {
138
- await super.stopHandler();
139
- const archivist = await this.archivistInstance(true);
140
- archivist.off("inserted", this.onArchivistInserted);
141
- archivist.off("deleted", this.onArchivistDeleted);
142
- archivist.off("cleared", this.onArchivistCleared);
143
- }
144
- // index any new payloads
145
- async updateIndex() {
146
- await this._updatePayloadPairsMutex.runExclusive(async () => {
147
- const archivist = await this.archivistInstance(true);
148
- let newPayloads = await archivist.next({ limit: 100, cursor: this._cursor });
149
- while (newPayloads.length > 0) {
150
- this._cursor = newPayloads.at(-1)?._sequence;
151
- assertEx(this.payloadsWithMeta.length + newPayloads.length <= this.maxIndexSize, () => "maxIndexSize exceeded");
152
- this.indexPayloads(newPayloads);
153
- newPayloads = await archivist.next({ limit: 100, cursor: this._cursor });
154
- }
155
- });
156
- }
157
- indexPayloads(payloads) {
158
- this.payloadsWithMeta.push(...payloads);
159
- for (const index of this.indexes ?? []) {
160
- this.indexMaps[index] = this.indexMaps[index] ?? [];
161
- for (const payload of payloads) {
162
- this.indexMaps[index].push(payload);
163
- }
164
- }
165
- return assertEx(payloads.at(-1), () => "No payloads to index")._sequence;
166
- }
167
- };
168
- __publicField(GenericPayloadDiviner, "configSchemas", [...__superGet(GenericPayloadDiviner, GenericPayloadDiviner, "configSchemas"), GenericPayloadDivinerConfigSchema]);
169
- __publicField(GenericPayloadDiviner, "defaultConfigSchema", GenericPayloadDivinerConfigSchema);
170
- GenericPayloadDiviner = __decorateClass([
171
- creatableModule()
172
- ], GenericPayloadDiviner);
173
- export {
174
- GenericPayloadDiviner,
175
- GenericPayloadDivinerConfigSchema,
176
- GenericPayloadDivinerConfigZod,
177
- asGenericPayloadDivinerConfig,
178
- isGenericPayloadDivinerConfig,
179
- toGenericPayloadDivinerConfig
180
- };
1
+ // src/index.ts
2
+ export * from "@xyo-network/sdk/diviner-payload-generic";
181
3
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/Diviner.ts"],
4
- "sourcesContent": ["import type { EventListener, Hex } from '@ariestools/sdk'\nimport {\n assertEx, filterAs, forget,\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport type { ArchivistInstance, ArchivistModuleEventData } from '@xyo-network/archivist-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { PayloadDiviner } from '@xyo-network/diviner-payload-abstract'\nimport type {\n Order,\n PayloadDivinerConfig,\n PayloadDivinerParams,\n PayloadDivinerQueryPayload,\n} from '@xyo-network/diviner-payload-model'\nimport { asPayloadDivinerQueryPayload, PayloadDivinerConfigZod } from '@xyo-network/diviner-payload-model'\nimport { creatableModule } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\nimport {\n asSchema,\n type Payload, type Schema,\n type Sequence,\n type WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport { Mutex } from 'async-mutex'\nimport * as z from 'zod/mini'\n\nconst DEFAULT_INDEX_BATCH_SIZE = 100 as const\nconst DEFAULT_MAX_INDEX_SIZE = 8000 as const\n\nexport const GenericPayloadDivinerConfigSchema: 'network.xyo.diviner.payload.generic.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.payload.generic.config', true)\nexport type GenericPayloadDivinerConfigSchema = typeof GenericPayloadDivinerConfigSchema\n\nexport const GenericPayloadDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof PayloadDivinerConfigZod)['shape'], 'schema'> & {\n indexes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>\n schema: z.ZodMiniLiteral<GenericPayloadDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(PayloadDivinerConfigZod, {\n indexes: z.optional(z.array(z.string())),\n schema: z.literal(GenericPayloadDivinerConfigSchema),\n})\n\nexport type GenericPayloadDivinerConfigBase = z.infer<typeof GenericPayloadDivinerConfigZod>\n\nexport const isGenericPayloadDivinerConfig: ReturnType<typeof zodIsFactory<GenericPayloadDivinerConfigBase>> = zodIsFactory(GenericPayloadDivinerConfigZod)\nexport const asGenericPayloadDivinerConfig: ReturnType<typeof zodAsFactory<GenericPayloadDivinerConfigBase>> = zodAsFactory(GenericPayloadDivinerConfigZod, 'asGenericPayloadDivinerConfig')\nexport const toGenericPayloadDivinerConfig: ReturnType<typeof zodToFactory<GenericPayloadDivinerConfigBase>> = zodToFactory(GenericPayloadDivinerConfigZod, 'toGenericPayloadDivinerConfig')\n\nexport type GenericPayloadDivinerConfig = PayloadDivinerConfig<\n {\n indexes?: string[]\n },\n GenericPayloadDivinerConfigSchema\n>\n\n@creatableModule()\nexport class GenericPayloadDiviner<\n TParams extends PayloadDivinerParams<GenericPayloadDivinerConfig> = PayloadDivinerParams<GenericPayloadDivinerConfig>,\n TIn extends PayloadDivinerQueryPayload = PayloadDivinerQueryPayload,\n TOut extends WithStorageMeta<Payload> = WithStorageMeta<Payload>,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends PayloadDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, GenericPayloadDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = GenericPayloadDivinerConfigSchema\n\n protected indexMaps: Record<string, WithStorageMeta<TOut>[]> = {}\n protected payloadsWithMeta: WithStorageMeta<TOut>[] = []\n\n private _archivistInstance?: ArchivistInstance\n private _cursor?: Sequence\n private _updatePayloadPairsMutex = new Mutex()\n\n protected get indexBatchSize(): number {\n return this.config.indexBatchSize ?? DEFAULT_INDEX_BATCH_SIZE\n }\n\n protected get indexes(): string[] {\n return ['schema', ...(this.config.indexes ?? [])]\n }\n\n protected get maxIndexSize(): number {\n return this.config.maxIndexSize ?? DEFAULT_MAX_INDEX_SIZE\n }\n\n protected all(order: Order = 'desc', cursor?: Hex): WithStorageMeta<TOut>[] {\n const payloads = this.payloadsWithMeta.toSorted(PayloadBuilder.compareStorageMeta)\n if (order === 'desc') payloads.reverse()\n const startIndex = (cursor ? (payloads.findIndex(payload => payload._sequence === cursor) ?? -1) : -1) + 1\n return payloads.slice(startIndex)\n }\n\n protected override async archivistInstance(): Promise<ArchivistInstance | undefined>\n protected override async archivistInstance(required: true): Promise<ArchivistInstance>\n protected override async archivistInstance(required = false): Promise<ArchivistInstance | undefined> {\n if (!this._archivistInstance) {\n const archivist = await super.archivistInstance()\n if (required && !archivist) {\n throw new Error('Failed to find archivist')\n }\n archivist?.on('inserted', this.onArchivistInserted)\n archivist?.on('cleared', this.onArchivistCleared)\n archivist?.on('deleted', this.onArchivistDeleted)\n this._archivistInstance = archivist\n }\n return this._archivistInstance\n }\n\n protected async clearIndex(): Promise<void> {\n await this._updatePayloadPairsMutex.runExclusive(() => {\n this._cursor = undefined\n this.payloadsWithMeta = []\n this.indexMaps = {}\n })\n }\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const filters = filterAs(payloads ?? [], asPayloadDivinerQueryPayload)\n assertEx(filters.length < 2, () => 'Multiple PayloadDivinerQuery payloads may not be specified')\n const filter = assertEx(filters.shift(), () => 'No PayloadDivinerQuery specified')\n await this.updateIndex()\n\n const {\n\n schema, schemas, order, limit, cursor, ...props\n } = filter\n let all: TOut[] = this.all(order, cursor)\n if (all) {\n if (schemas?.length) all = all.filter(payload => schemas.includes(payload.schema))\n if (Object.keys(props).length > 0) {\n const additionalFilterCriteria = Object.entries(props)\n for (const [prop, filter] of additionalFilterCriteria) {\n const property = prop as keyof TOut\n all\n = Array.isArray(filter)\n ? all.filter(payload =>\n filter.every((value) => {\n const prop = payload?.[property]\n // TODO: This seems to be written just to check arrays, and now that $meta is there, need to check type?\n return Array.isArray(prop) && prop.includes?.(value)\n }))\n : all.filter(payload => payload?.[property] === filter)\n }\n }\n return limit ? all.slice(0, limit) : all\n } else {\n throw new Error('Archivist does not support \"all\"')\n }\n }\n\n protected onArchivistCleared: EventListener<ArchivistModuleEventData['cleared']> = () => {\n forget(\n (async () => {\n await this.clearIndex()\n await this.updateIndex()\n })(),\n )\n }\n\n // we are just rebuilding the entire index at this point on delete since large archivists do not support delete\n protected onArchivistDeleted: EventListener<ArchivistModuleEventData['deleted']> = () => {\n forget(\n (async () => {\n await this.clearIndex()\n await this.updateIndex()\n })(),\n )\n }\n\n protected onArchivistInserted: EventListener<ArchivistModuleEventData['inserted']> = () => {\n forget(this.updateIndex())\n }\n\n protected override async stopHandler(_timeout?: number): Promise<void> {\n await super.stopHandler()\n const archivist = await this.archivistInstance(true)\n archivist.off('inserted', this.onArchivistInserted)\n archivist.off('deleted', this.onArchivistDeleted)\n archivist.off('cleared', this.onArchivistCleared)\n }\n\n // index any new payloads\n protected async updateIndex(): Promise<void> {\n await this._updatePayloadPairsMutex.runExclusive(async () => {\n const archivist = await this.archivistInstance(true)\n let newPayloads = await archivist.next({ limit: 100, cursor: this._cursor }) as TOut[]\n while (newPayloads.length > 0) {\n this._cursor = newPayloads.at(-1)?._sequence\n assertEx(this.payloadsWithMeta.length + newPayloads.length <= this.maxIndexSize, () => 'maxIndexSize exceeded')\n this.indexPayloads(newPayloads)\n newPayloads = await archivist.next({ limit: 100, cursor: this._cursor }) as TOut[]\n }\n })\n }\n\n private indexPayloads(payloads: WithStorageMeta<TOut>[]): Hex {\n this.payloadsWithMeta.push(...payloads)\n\n // update the custom indexes\n for (const index of this.indexes ?? []) {\n this.indexMaps[index] = this.indexMaps[index] ?? []\n for (const payload of payloads) {\n this.indexMaps[index].push(payload)\n }\n }\n return assertEx(payloads.at(-1), () => 'No payloads to index')._sequence\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EAAU;AAAA,EAAU;AAAA,EACpB;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AAGP,SAAS,sBAAsB;AAO/B,SAAS,8BAA8B,+BAA+B;AACtE,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa;AACtB,YAAY,OAAO;AAEnB,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;A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AAC;AAClD,iBAAW,WAAW,UAAU;AAC9B,aAAK,UAAU,KAAK,EAAE,KAAK,OAAO;AAAA,MACpC;AAAA,IACF;AACA,WAAO,SAAS,SAAS,GAAG,EAAE,GAAG,MAAM,sBAAsB,EAAE;AAAA,EACjE;AACF;AAhJE,cAVW,uBAUc,iBAA0B,CAAC,GAAG,yDAAM,kBAAe,iCAAiC;AAC7G,cAXW,uBAWc,uBAA8B;AAX5C,wBAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;",
6
- "names": ["filter", "prop"]
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/sdk.\nexport * from '@xyo-network/sdk/diviner-payload-generic'\n"],
5
+ "mappings": ";AACA,cAAc;",
6
+ "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/diviner-payload-generic",
3
- "version": "7.0.8",
3
+ "version": "7.0.10",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -34,14 +34,11 @@
34
34
  "README.md"
35
35
  ],
36
36
  "dependencies": {
37
- "@xyo-network/archivist-model": "~7.0.8",
38
- "@xyo-network/diviner-model": "~7.0.8",
39
- "@xyo-network/diviner-payload-abstract": "~7.0.8",
40
- "@xyo-network/module-model": "~7.0.8",
41
- "@xyo-network/diviner-payload-model": "~7.0.8"
37
+ "@xyo-network/sdk": "~7.0.10"
42
38
  },
43
39
  "devDependencies": {
44
- "@ariestools/sdk": "~7.0.8",
40
+ "@ariestools/sdk": "~8.0.2",
41
+ "@ariestools/threads": "~8.0.2",
45
42
  "@bitauth/libauth": "~3.0.0",
46
43
  "@metamask/providers": "~22.1.1",
47
44
  "@noble/post-quantum": "~0.6.1",
@@ -49,37 +46,26 @@
49
46
  "@opentelemetry/sdk-trace-base": "~2.9.0",
50
47
  "@scure/base": "~2.2.0",
51
48
  "@scure/bip39": "~2.2.0",
52
- "@xylabs/geo": "~7.0.8",
53
- "@xylabs/indexed-db": "~7.0.8",
54
- "@xylabs/threads": "~7.0.8",
55
- "@xylabs/toolchain": "~8.6.2",
56
- "@xylabs/tsconfig": "~8.6.2",
57
- "@xylabs/vitest-extended": "~7.0.8",
58
- "@xyo-network/sdk-protocol": "~7.0.13",
49
+ "@xylabs/toolchain": "~8.6.8",
50
+ "@xylabs/tsconfig": "~8.6.8",
51
+ "@xyo-network/sdk-protocol": "~7.0.15",
59
52
  "ajv": "~8.20.0",
60
53
  "async-mutex": "~0.5.0",
61
- "browserslist": "~4.28.4",
62
54
  "debug": "~4.4.3",
63
55
  "eslint": "~10.6.0",
64
56
  "eslint-import-resolver-typescript": "~4.4.5",
65
57
  "ethers": "~6.17.0",
66
- "fake-indexeddb": "~6.2.5",
67
58
  "hash-wasm": "~4.12.0",
68
59
  "idb": "~8.0.3",
69
60
  "lru-cache": "~11.5.1",
70
61
  "observable-fns": "~0.6.1",
71
- "tslib": "~2.8.1",
72
62
  "typescript": "~6.0.3",
73
- "vite": "~8.1.3",
74
- "vitest": "~4.1.9",
75
63
  "webextension-polyfill": "~0.12.0",
76
- "zod": "~4.4.3",
77
- "@xyo-network/archivist-indexeddb": "~7.0.8",
78
- "@xyo-network/archivist-memory": "~7.0.8",
79
- "@xyo-network/node-memory": "~7.0.8"
64
+ "zod": "~4.4.3"
80
65
  },
81
66
  "peerDependencies": {
82
- "@ariestools/sdk": "^7.0.8",
67
+ "@ariestools/sdk": "^8.0.2",
68
+ "@ariestools/threads": "^8.0.2",
83
69
  "@bitauth/libauth": "^3.0.0",
84
70
  "@metamask/providers": "^22.1.1",
85
71
  "@noble/post-quantum": "^0.6.1",
@@ -87,9 +73,7 @@
87
73
  "@opentelemetry/sdk-trace-base": "^2.9.0",
88
74
  "@scure/base": "^2.2.0",
89
75
  "@scure/bip39": "^2.2.0",
90
- "@xylabs/geo": "^7.0.8",
91
- "@xylabs/threads": "^7.0.8",
92
- "@xyo-network/sdk-protocol": "^7.0.13",
76
+ "@xyo-network/sdk-protocol": "^7.0.15",
93
77
  "ajv": "^8.20.0",
94
78
  "async-mutex": "^0.5.0",
95
79
  "debug": "^4.4.3",
@@ -106,5 +90,6 @@
106
90
  },
107
91
  "publishConfig": {
108
92
  "access": "public"
109
- }
93
+ },
94
+ "deprecated": "Use @xyo-network/sdk/diviner-payload-generic instead. Replace @xyo-network/diviner-payload-generic with @xyo-network/sdk/diviner-payload-generic. This package is a compatibility shim only and will not receive further updates."
110
95
  }
@@ -1,48 +0,0 @@
1
- import type { EventListener, Hex } from '@ariestools/sdk';
2
- import { zodAsFactory, zodIsFactory, zodToFactory } from '@ariestools/sdk';
3
- import type { ArchivistInstance, ArchivistModuleEventData } from '@xyo-network/archivist-model';
4
- import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model';
5
- import { PayloadDiviner } from '@xyo-network/diviner-payload-abstract';
6
- import type { Order, PayloadDivinerConfig, PayloadDivinerParams, PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model';
7
- import { PayloadDivinerConfigZod } from '@xyo-network/diviner-payload-model';
8
- import { type Payload, type Schema, type WithStorageMeta } from '@xyo-network/sdk-protocol';
9
- import * as z from 'zod/mini';
10
- export declare const GenericPayloadDivinerConfigSchema: 'network.xyo.diviner.payload.generic.config' & {
11
- readonly __schema: true;
12
- };
13
- export type GenericPayloadDivinerConfigSchema = typeof GenericPayloadDivinerConfigSchema;
14
- export declare const GenericPayloadDivinerConfigZod: z.ZodMiniObject<Omit<(typeof PayloadDivinerConfigZod)['shape'], 'schema'> & {
15
- indexes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
16
- schema: z.ZodMiniLiteral<GenericPayloadDivinerConfigSchema>;
17
- }, z.core.$strip>;
18
- export type GenericPayloadDivinerConfigBase = z.infer<typeof GenericPayloadDivinerConfigZod>;
19
- export declare const isGenericPayloadDivinerConfig: ReturnType<typeof zodIsFactory<GenericPayloadDivinerConfigBase>>;
20
- export declare const asGenericPayloadDivinerConfig: ReturnType<typeof zodAsFactory<GenericPayloadDivinerConfigBase>>;
21
- export declare const toGenericPayloadDivinerConfig: ReturnType<typeof zodToFactory<GenericPayloadDivinerConfigBase>>;
22
- export type GenericPayloadDivinerConfig = PayloadDivinerConfig<{
23
- indexes?: string[];
24
- }, GenericPayloadDivinerConfigSchema>;
25
- export declare class GenericPayloadDiviner<TParams extends PayloadDivinerParams<GenericPayloadDivinerConfig> = PayloadDivinerParams<GenericPayloadDivinerConfig>, TIn extends PayloadDivinerQueryPayload = PayloadDivinerQueryPayload, TOut extends WithStorageMeta<Payload> = WithStorageMeta<Payload>, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends PayloadDiviner<TParams, TIn, TOut, TEventData> {
26
- static readonly configSchemas: Schema[];
27
- static readonly defaultConfigSchema: Schema;
28
- protected indexMaps: Record<string, WithStorageMeta<TOut>[]>;
29
- protected payloadsWithMeta: WithStorageMeta<TOut>[];
30
- private _archivistInstance?;
31
- private _cursor?;
32
- private _updatePayloadPairsMutex;
33
- protected get indexBatchSize(): number;
34
- protected get indexes(): string[];
35
- protected get maxIndexSize(): number;
36
- protected all(order?: Order, cursor?: Hex): WithStorageMeta<TOut>[];
37
- protected archivistInstance(): Promise<ArchivistInstance | undefined>;
38
- protected archivistInstance(required: true): Promise<ArchivistInstance>;
39
- protected clearIndex(): Promise<void>;
40
- protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
41
- protected onArchivistCleared: EventListener<ArchivistModuleEventData['cleared']>;
42
- protected onArchivistDeleted: EventListener<ArchivistModuleEventData['deleted']>;
43
- protected onArchivistInserted: EventListener<ArchivistModuleEventData['inserted']>;
44
- protected stopHandler(_timeout?: number): Promise<void>;
45
- protected updateIndex(): Promise<void>;
46
- private indexPayloads;
47
- }
48
- //# sourceMappingURL=Diviner.d.ts.map
@@ -1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