@xyo-network/diviner-temporal-indexing-memory 2.107.3 → 2.107.5
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/browser/index.cjs +401 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +380 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +401 -1
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +380 -1
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +414 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +385 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +28 -28
package/dist/node/index.js
CHANGED
|
@@ -1,2 +1,386 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
+
var __reflectGet = Reflect.get;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
8
|
+
|
|
9
|
+
// src/Diviner.ts
|
|
10
|
+
import { IndexingDiviner } from "@xyo-network/diviner-indexing-memory";
|
|
11
|
+
import { TemporalIndexingDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
12
|
+
var _TemporalIndexingDiviner = class _TemporalIndexingDiviner extends IndexingDiviner {
|
|
13
|
+
async startHandler() {
|
|
14
|
+
await super.startHandler();
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
__name(_TemporalIndexingDiviner, "TemporalIndexingDiviner");
|
|
19
|
+
__publicField(_TemporalIndexingDiviner, "configSchemas", [
|
|
20
|
+
...__superGet(_TemporalIndexingDiviner, _TemporalIndexingDiviner, "configSchemas"),
|
|
21
|
+
TemporalIndexingDivinerConfigSchema
|
|
22
|
+
]);
|
|
23
|
+
__publicField(_TemporalIndexingDiviner, "defaultConfigSchema", TemporalIndexingDivinerConfigSchema);
|
|
24
|
+
var TemporalIndexingDiviner = _TemporalIndexingDiviner;
|
|
25
|
+
|
|
26
|
+
// src/DivinerQueryToIndexQueryDiviner/Diviner.ts
|
|
27
|
+
import { AbstractDiviner } from "@xyo-network/diviner-abstract";
|
|
28
|
+
import { jsonPathToTransformersDictionary, reducePayloads } from "@xyo-network/diviner-jsonpath-aggregate-memory";
|
|
29
|
+
import { PayloadDivinerQuerySchema } from "@xyo-network/diviner-payload-model";
|
|
30
|
+
import { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema, TemporalIndexingDivinerResultIndexSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
31
|
+
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
32
|
+
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
33
|
+
var _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner extends AbstractDiviner {
|
|
34
|
+
_indexableSchemas;
|
|
35
|
+
_payloadTransformers;
|
|
36
|
+
/**
|
|
37
|
+
* The schema of the diviner query payloads
|
|
38
|
+
*/
|
|
39
|
+
get divinerQuerySchema() {
|
|
40
|
+
return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The schema of the index query payloads
|
|
44
|
+
*/
|
|
45
|
+
get indexQuerySchema() {
|
|
46
|
+
return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The schema of the index payloads
|
|
50
|
+
*/
|
|
51
|
+
get indexSchema() {
|
|
52
|
+
return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* List of indexable schemas for this diviner
|
|
56
|
+
*/
|
|
57
|
+
get indexableSchemas() {
|
|
58
|
+
if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms);
|
|
59
|
+
return this._indexableSchemas;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Dictionary of schemas to payload transformers for creating indexes
|
|
63
|
+
* from the payloads within a Bound Witness
|
|
64
|
+
*/
|
|
65
|
+
get payloadTransformers() {
|
|
66
|
+
if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms);
|
|
67
|
+
return this._payloadTransformers;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The dictionary of schemas to JSON Path transform expressions for creating indexes
|
|
71
|
+
* from the payloads within a Bound Witness
|
|
72
|
+
*/
|
|
73
|
+
get schemaTransforms() {
|
|
74
|
+
var _a;
|
|
75
|
+
return ((_a = this.config) == null ? void 0 : _a.schemaTransforms) ?? {
|
|
76
|
+
[this.divinerQuerySchema]: [
|
|
77
|
+
{
|
|
78
|
+
defaultValue: 1,
|
|
79
|
+
destinationField: "limit",
|
|
80
|
+
sourcePathExpression: "$.limit"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
defaultValue: 0,
|
|
84
|
+
destinationField: "offset",
|
|
85
|
+
sourcePathExpression: "$.offset"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
defaultValue: "desc",
|
|
89
|
+
destinationField: "order",
|
|
90
|
+
sourcePathExpression: "$.order"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async divineHandler(payloads = []) {
|
|
96
|
+
const queries = payloads.filter(isPayloadOfSchemaType(this.divinerQuerySchema));
|
|
97
|
+
if (queries.length > 0) {
|
|
98
|
+
const results = await Promise.all(queries.map(async (query) => {
|
|
99
|
+
const fields = await reducePayloads([
|
|
100
|
+
query
|
|
101
|
+
], this.payloadTransformers, this.indexQuerySchema);
|
|
102
|
+
fields.schemas = [
|
|
103
|
+
this.indexSchema
|
|
104
|
+
];
|
|
105
|
+
delete fields.sources;
|
|
106
|
+
return await new PayloadBuilder({
|
|
107
|
+
schema: this.indexQuerySchema
|
|
108
|
+
}).fields(fields).build();
|
|
109
|
+
}));
|
|
110
|
+
return results;
|
|
111
|
+
}
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
__name(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner");
|
|
116
|
+
__publicField(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "configSchemas", [
|
|
117
|
+
...__superGet(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "configSchemas"),
|
|
118
|
+
TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema
|
|
119
|
+
]);
|
|
120
|
+
__publicField(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "defaultConfigSchema", TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema);
|
|
121
|
+
__publicField(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "labels", {
|
|
122
|
+
...__superGet(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "labels"),
|
|
123
|
+
"network.xyo.diviner.stage": "divinerQueryToIndexQueryDiviner"
|
|
124
|
+
});
|
|
125
|
+
var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner;
|
|
126
|
+
|
|
127
|
+
// src/IndexCandidateToIndexDiviner/Diviner.ts
|
|
128
|
+
import { containsAll } from "@xylabs/array";
|
|
129
|
+
import { assertEx } from "@xylabs/assert";
|
|
130
|
+
import { exists } from "@xylabs/exists";
|
|
131
|
+
import { isBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
|
|
132
|
+
import { AbstractDiviner as AbstractDiviner2 } from "@xyo-network/diviner-abstract";
|
|
133
|
+
import { jsonPathToTransformersDictionary as jsonPathToTransformersDictionary2 } from "@xyo-network/diviner-jsonpath-aggregate-memory";
|
|
134
|
+
import { TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema, TemporalIndexingDivinerResultIndexSchema as TemporalIndexingDivinerResultIndexSchema2 } from "@xyo-network/diviner-temporal-indexing-model";
|
|
135
|
+
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
136
|
+
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
137
|
+
import { intraBoundwitnessSchemaCombinations } from "@xyo-network/payload-utils";
|
|
138
|
+
var moduleName = "TemporalIndexingDivinerIndexCandidateToIndexDiviner";
|
|
139
|
+
var _TemporalIndexingDivinerIndexCandidateToIndexDiviner = class _TemporalIndexingDivinerIndexCandidateToIndexDiviner extends AbstractDiviner2 {
|
|
140
|
+
_indexableSchemas;
|
|
141
|
+
_payloadTransformers;
|
|
142
|
+
/**
|
|
143
|
+
* List of indexable schemas for this diviner
|
|
144
|
+
*/
|
|
145
|
+
get indexableSchemas() {
|
|
146
|
+
if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms);
|
|
147
|
+
return this._indexableSchemas;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Dictionary of schemas to payload transformers for creating indexes
|
|
151
|
+
* from the payloads within a Bound Witness
|
|
152
|
+
*/
|
|
153
|
+
get payloadTransformers() {
|
|
154
|
+
if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary2(this.schemaTransforms);
|
|
155
|
+
return this._payloadTransformers;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The dictionary of schemas to JSON Path transform expressions for creating indexes
|
|
159
|
+
* from the payloads within a Bound Witness
|
|
160
|
+
*/
|
|
161
|
+
get schemaTransforms() {
|
|
162
|
+
var _a;
|
|
163
|
+
return assertEx((_a = this.config) == null ? void 0 : _a.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`);
|
|
164
|
+
}
|
|
165
|
+
async divineHandler(payloads = []) {
|
|
166
|
+
const builtPayloads = await Promise.all(payloads.map((payload) => PayloadBuilder2.build(payload)));
|
|
167
|
+
const indexableBoundWitnesses = builtPayloads.filter(isBoundWitnessWithMeta).filter((bw) => containsAll(bw.payload_schemas, this.indexableSchemas));
|
|
168
|
+
const indexablePayloads = builtPayloads.filter((p) => this.isIndexablePayload(p));
|
|
169
|
+
if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return [];
|
|
170
|
+
const [bwDictionary, payloadDictionary] = await Promise.all([
|
|
171
|
+
PayloadBuilder2.toDataHashMap(indexableBoundWitnesses),
|
|
172
|
+
PayloadBuilder2.toDataHashMap(indexablePayloads)
|
|
173
|
+
]);
|
|
174
|
+
const validIndexableTuples = [];
|
|
175
|
+
for (const [bwHash, bw] of Object.entries(bwDictionary)) {
|
|
176
|
+
const combinations = intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas);
|
|
177
|
+
for (const combination of combinations) {
|
|
178
|
+
const indexablePayloads2 = combination.map((hash) => payloadDictionary[hash]).filter(exists);
|
|
179
|
+
if (indexablePayloads2.length === this.indexableSchemas.length) {
|
|
180
|
+
validIndexableTuples.push([
|
|
181
|
+
bwHash,
|
|
182
|
+
...combination
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const indexes = await Promise.all(validIndexableTuples.map(async ([bwHash, ...sourcePayloadHashes]) => {
|
|
188
|
+
const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash]);
|
|
189
|
+
const indexFields = sourcePayloads.flatMap((payload) => {
|
|
190
|
+
const transformers = this.payloadTransformers[payload.schema];
|
|
191
|
+
return transformers ? transformers.map((transform) => transform(payload)) : [];
|
|
192
|
+
});
|
|
193
|
+
const sources = [
|
|
194
|
+
bwHash,
|
|
195
|
+
...sourcePayloadHashes
|
|
196
|
+
];
|
|
197
|
+
return await new PayloadBuilder2({
|
|
198
|
+
schema: TemporalIndexingDivinerResultIndexSchema2
|
|
199
|
+
}).fields(Object.assign({
|
|
200
|
+
sources
|
|
201
|
+
}, ...indexFields)).build();
|
|
202
|
+
}));
|
|
203
|
+
return indexes.flat();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Identifies if a payload is one that is indexed by this diviner
|
|
207
|
+
* @param x The candidate payload
|
|
208
|
+
* @returns True if the payload is one indexed by this diviner, false otherwise
|
|
209
|
+
*/
|
|
210
|
+
isIndexablePayload = /* @__PURE__ */ __name((x) => {
|
|
211
|
+
return isAnyPayload(x) && this.indexableSchemas.includes(x == null ? void 0 : x.schema);
|
|
212
|
+
}, "isIndexablePayload");
|
|
213
|
+
/**
|
|
214
|
+
* Identifies if a schema is one that is indexed by this diviner
|
|
215
|
+
* @param schema The candidate schema
|
|
216
|
+
* @returns True if this schema is one indexed by this diviner, false otherwise
|
|
217
|
+
*/
|
|
218
|
+
isIndexableSchema = /* @__PURE__ */ __name((schema) => {
|
|
219
|
+
return typeof schema === "string" ? this.indexableSchemas.includes(schema) : false;
|
|
220
|
+
}, "isIndexableSchema");
|
|
221
|
+
};
|
|
222
|
+
__name(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "TemporalIndexingDivinerIndexCandidateToIndexDiviner");
|
|
223
|
+
__publicField(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "configSchemas", [
|
|
224
|
+
...__superGet(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, _TemporalIndexingDivinerIndexCandidateToIndexDiviner, "configSchemas"),
|
|
225
|
+
TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema
|
|
226
|
+
]);
|
|
227
|
+
__publicField(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "defaultConfigSchema", TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema);
|
|
228
|
+
__publicField(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "labels", {
|
|
229
|
+
...__superGet(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, _TemporalIndexingDivinerIndexCandidateToIndexDiviner, "labels"),
|
|
230
|
+
"network.xyo.diviner.stage": "indexCandidateToIndexDiviner"
|
|
231
|
+
});
|
|
232
|
+
var TemporalIndexingDivinerIndexCandidateToIndexDiviner = _TemporalIndexingDivinerIndexCandidateToIndexDiviner;
|
|
233
|
+
|
|
234
|
+
// src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts
|
|
235
|
+
import { AbstractDiviner as AbstractDiviner3 } from "@xyo-network/diviner-abstract";
|
|
236
|
+
import { isPayloadDivinerQueryPayload } from "@xyo-network/diviner-payload-model";
|
|
237
|
+
import { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
238
|
+
var _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner = class _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner3 {
|
|
239
|
+
async divineHandler(payloads = []) {
|
|
240
|
+
const responses = payloads.filter((p) => !isPayloadDivinerQueryPayload(p));
|
|
241
|
+
return await Promise.resolve(responses);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
__name(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner");
|
|
245
|
+
__publicField(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "configSchemas", [
|
|
246
|
+
...__superGet(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "configSchemas"),
|
|
247
|
+
TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema
|
|
248
|
+
]);
|
|
249
|
+
__publicField(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "defaultConfigSchema", TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema);
|
|
250
|
+
__publicField(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "labels", {
|
|
251
|
+
...__superGet(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "labels"),
|
|
252
|
+
"network.xyo.diviner.stage": "indexQueryResponseToDivinerQueryResponseDiviner"
|
|
253
|
+
});
|
|
254
|
+
var TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner = _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner;
|
|
255
|
+
|
|
256
|
+
// src/StateToIndexCandidateDiviner/Diviner.ts
|
|
257
|
+
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
258
|
+
import { exists as exists2 } from "@xylabs/exists";
|
|
259
|
+
import { ArchivistWrapper } from "@xyo-network/archivist-wrapper";
|
|
260
|
+
import { isBoundWitnessWithMeta as isBoundWitnessWithMeta2 } from "@xyo-network/boundwitness-model";
|
|
261
|
+
import { AbstractDiviner as AbstractDiviner4 } from "@xyo-network/diviner-abstract";
|
|
262
|
+
import { BoundWitnessDivinerQuerySchema } from "@xyo-network/diviner-boundwitness-model";
|
|
263
|
+
import { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
264
|
+
import { DivinerWrapper } from "@xyo-network/diviner-wrapper";
|
|
265
|
+
import { isModuleState, ModuleStateSchema } from "@xyo-network/module-model";
|
|
266
|
+
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
|
|
267
|
+
import { intraBoundwitnessSchemaCombinations as intraBoundwitnessSchemaCombinations2 } from "@xyo-network/payload-utils";
|
|
268
|
+
import { TimestampSchema } from "@xyo-network/witness-timestamp";
|
|
269
|
+
var order = "asc";
|
|
270
|
+
var moduleName2 = "TemporalIndexingDivinerStateToIndexCandidateDiviner";
|
|
271
|
+
var _TemporalIndexingDivinerStateToIndexCandidateDiviner = class _TemporalIndexingDivinerStateToIndexCandidateDiviner extends AbstractDiviner4 {
|
|
272
|
+
get payloadDivinerLimit() {
|
|
273
|
+
return this.config.payloadDivinerLimit ?? 1e3;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The required payload_schemas within BoundWitnesses to identify index candidates
|
|
277
|
+
*/
|
|
278
|
+
get payload_schemas() {
|
|
279
|
+
var _a;
|
|
280
|
+
const schemas = (_a = this.config.filter) == null ? void 0 : _a.payload_schemas;
|
|
281
|
+
return [
|
|
282
|
+
TimestampSchema,
|
|
283
|
+
...schemas ?? []
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
async divineHandler(payloads = []) {
|
|
287
|
+
const lastState = payloads.find(isModuleState);
|
|
288
|
+
if (!lastState) return [
|
|
289
|
+
{
|
|
290
|
+
schema: ModuleStateSchema,
|
|
291
|
+
state: {
|
|
292
|
+
offset: 0
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
];
|
|
296
|
+
const { offset } = lastState.state;
|
|
297
|
+
const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore();
|
|
298
|
+
if (!boundWitnessDiviner) return [
|
|
299
|
+
lastState
|
|
300
|
+
];
|
|
301
|
+
const query = await new PayloadBuilder3({
|
|
302
|
+
schema: BoundWitnessDivinerQuerySchema
|
|
303
|
+
}).fields({
|
|
304
|
+
limit: this.payloadDivinerLimit,
|
|
305
|
+
offset,
|
|
306
|
+
order,
|
|
307
|
+
payload_schemas: this.payload_schemas
|
|
308
|
+
}).build();
|
|
309
|
+
const batch = await boundWitnessDiviner.divine([
|
|
310
|
+
query
|
|
311
|
+
]);
|
|
312
|
+
if (batch.length === 0) return [
|
|
313
|
+
lastState
|
|
314
|
+
];
|
|
315
|
+
const sourceArchivist = await this.getArchivistForStore();
|
|
316
|
+
if (!sourceArchivist) return [
|
|
317
|
+
lastState
|
|
318
|
+
];
|
|
319
|
+
const bws = batch.filter(isBoundWitnessWithMeta2);
|
|
320
|
+
const indexCandidates = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
|
|
321
|
+
const nextState = {
|
|
322
|
+
schema: ModuleStateSchema,
|
|
323
|
+
state: {
|
|
324
|
+
...lastState.state,
|
|
325
|
+
offset: offset + batch.length
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
return [
|
|
329
|
+
nextState,
|
|
330
|
+
...indexCandidates
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Retrieves the archivist for the payloadStore
|
|
335
|
+
* @returns The archivist for the payloadStore or undefined if not resolvable
|
|
336
|
+
*/
|
|
337
|
+
async getArchivistForStore() {
|
|
338
|
+
var _a, _b;
|
|
339
|
+
const name = assertEx2((_b = (_a = this.config) == null ? void 0 : _a.payloadStore) == null ? void 0 : _b.archivist, () => `${moduleName2}: Config for payloadStore.archivist not specified`);
|
|
340
|
+
const mod = await this.resolve(name);
|
|
341
|
+
if (!mod) return void 0;
|
|
342
|
+
return ArchivistWrapper.wrap(mod, this.account);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Retrieves the BoundWitness Diviner for the payloadStore
|
|
346
|
+
* @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable
|
|
347
|
+
*/
|
|
348
|
+
async getBoundWitnessDivinerForStore() {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
const name = assertEx2((_b = (_a = this.config) == null ? void 0 : _a.payloadStore) == null ? void 0 : _b.boundWitnessDiviner, () => `${moduleName2}: Config for payloadStore.boundWitnessDiviner not specified`);
|
|
351
|
+
const mod = await this.resolve(name);
|
|
352
|
+
if (!mod) return;
|
|
353
|
+
return DivinerWrapper.wrap(mod, this.account);
|
|
354
|
+
}
|
|
355
|
+
async getPayloadsInBoundWitness(bw, archivist) {
|
|
356
|
+
const combinations = intraBoundwitnessSchemaCombinations2(bw, this.payload_schemas).flat();
|
|
357
|
+
if (combinations.length === 0) return void 0;
|
|
358
|
+
const hashes = new Set(combinations);
|
|
359
|
+
const indexCandidates = await archivist.get([
|
|
360
|
+
...hashes
|
|
361
|
+
]);
|
|
362
|
+
return [
|
|
363
|
+
bw,
|
|
364
|
+
...indexCandidates
|
|
365
|
+
];
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
__name(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "TemporalIndexingDivinerStateToIndexCandidateDiviner");
|
|
369
|
+
__publicField(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "configSchemas", [
|
|
370
|
+
...__superGet(_TemporalIndexingDivinerStateToIndexCandidateDiviner, _TemporalIndexingDivinerStateToIndexCandidateDiviner, "configSchemas"),
|
|
371
|
+
TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema
|
|
372
|
+
]);
|
|
373
|
+
__publicField(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "defaultConfigSchema", TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema);
|
|
374
|
+
__publicField(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "labels", {
|
|
375
|
+
...__superGet(_TemporalIndexingDivinerStateToIndexCandidateDiviner, _TemporalIndexingDivinerStateToIndexCandidateDiviner, "labels"),
|
|
376
|
+
"network.xyo.diviner.stage": "stateToIndexCandidateDiviner"
|
|
377
|
+
});
|
|
378
|
+
var TemporalIndexingDivinerStateToIndexCandidateDiviner = _TemporalIndexingDivinerStateToIndexCandidateDiviner;
|
|
379
|
+
export {
|
|
380
|
+
TemporalIndexingDiviner,
|
|
381
|
+
TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner,
|
|
382
|
+
TemporalIndexingDivinerIndexCandidateToIndexDiviner,
|
|
383
|
+
TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner,
|
|
384
|
+
TemporalIndexingDivinerStateToIndexCandidateDiviner
|
|
385
|
+
};
|
|
2
386
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Diviner.ts","../../src/DivinerQueryToIndexQueryDiviner/Diviner.ts","../../src/IndexCandidateToIndexDiviner/Diviner.ts","../../src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts","../../src/StateToIndexCandidateDiviner/Diviner.ts"],"sourcesContent":["import { IndexingDiviner } from '@xyo-network/diviner-indexing-memory'\nimport { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { TemporalIndexingDivinerConfigSchema, TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\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<boolean> {\n await super.startHandler()\n return true\n }\n}\n","import { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport { PayloadDivinerQueryPayload, PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\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 = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): string {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): string {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): string {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\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 if (!this._payloadTransformers) 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: 'offset',\n sourcePathExpression: '$.offset',\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 const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema))\n if (queries.length > 0) {\n const results = await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { 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 // TODO: Add support for additional filters\n return await new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()\n }),\n )\n return results\n }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isAnyPayload, Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\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 labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\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 if (!this._payloadTransformers) 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 const builtPayloads = await Promise.all(payloads.map((payload) => PayloadBuilder.build(payload)))\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = builtPayloads\n .filter(isBoundWitnessWithMeta)\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 = builtPayloads.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.toDataHashMap(indexableBoundWitnesses),\n PayloadBuilder.toDataHashMap(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 = await Promise.all(\n validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([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: string[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n return await new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n .fields(Object.assign({ sources }, ...indexFields))\n .build()\n }),\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) => {\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?: string | null) => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n","import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\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 static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // NOTE: 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 await Promise.resolve(responses)\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport {\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema,\n TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, Labels, ModuleIdentifier, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport { TimeStamp, TimestampSchema } from '@xyo-network/witness-timestamp'\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 labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit() {\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(): string[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<[ModuleState, ...IndexCandidate[]]> {\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 if (!lastState) return [{ schema: ModuleStateSchema, state: { offset: 0 } }]\n // Otherwise, get the last offset\n const { offset } = lastState.state\n // Get next batch of results starting from the offset\n const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore()\n if (!boundWitnessDiviner) return [lastState]\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({ limit: this.payloadDivinerLimit, offset, order, payload_schemas: this.payload_schemas })\n .build()\n const batch = await boundWitnessDiviner.divine([query])\n if (batch.length === 0) return [lastState]\n // Get source data\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n const bws = batch.filter(isBoundWitnessWithMeta)\n const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextState = { schema: ModuleStateSchema, state: { ...lastState.state, offset: offset + batch.length } }\n return [nextState, ...indexCandidates]\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() {\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 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"],"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EoC,KAAI,EACvF,GAAIY,EAAaxB,SAAW,EAAG,OAC/B,IAAM0B,EAAS,IAAIC,IAAIH,CAAAA,EACjBnB,EAAkB,MAAMY,EAAUW,IAAI,IAAIF,EAAO,EACvD,MAAO,CAACjB,KAAOJ,EACjB,CACF,EA5FUhC,EAAAA,EAAAA,uDACRwD,EAHWzD,EAGc0D,gBAA0B,IAAIC,EAAAC,IAAMF,iBAAeG,IAC5EJ,EAJWzD,EAIc8D,sBAA8BD,GACvDJ,EALWzD,EAKK+D,SAAiB,CAC/B,GAAGJ,EAAAC,IAAMG,UACT,4BAA6B,8BAC/B,GARK,IAAM/D,EAAN4D","names":["IndexingDiviner","TemporalIndexingDivinerConfigSchema","TemporalIndexingDiviner","IndexingDiviner","startHandler","__publicField","configSchemas","__superGet","_TemporalIndexingDiviner","TemporalIndexingDivinerConfigSchema","defaultConfigSchema","AbstractDiviner","jsonPathToTransformersDictionary","reducePayloads","PayloadDivinerQuerySchema","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isPayloadOfSchemaType","TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner","AbstractDiviner","_indexableSchemas","_payloadTransformers","divinerQuerySchema","config","PayloadDivinerQuerySchema","indexQuerySchema","indexSchema","TemporalIndexingDivinerResultIndexSchema","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","_a","defaultValue","destinationField","sourcePathExpression","divineHandler","payloads","queries","filter","isPayloadOfSchemaType","length","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","__publicField","configSchemas","__superGet","_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","defaultConfigSchema","labels","containsAll","assertEx","exists","isBoundWitnessWithMeta","AbstractDiviner","jsonPathToTransformersDictionary","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isAnyPayload","intraBoundwitnessSchemaCombinations","moduleName","TemporalIndexingDivinerIndexCandidateToIndexDiviner","AbstractDiviner","_indexableSchemas","_payloadTransformers","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","_a","assertEx","config","divineHandler","payloads","builtPayloads","Promise","all","map","payload","PayloadBuilder","build","indexableBoundWitnesses","filter","isBoundWitnessWithMeta","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","hash","exists","push","sourcePayloadHashes","indexFields","flatMap","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","flat","__name","x","isAnyPayload","includes","isIndexableSchema","__publicField","configSchemas","__superGet","_TemporalIndexingDivinerIndexCandidateToIndexDiviner","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","defaultConfigSchema","labels","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","__publicField","configSchemas","__superGet","_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","assertEx","exists","ArchivistWrapper","isBoundWitnessWithMeta","AbstractDiviner","BoundWitnessDivinerQuerySchema","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","PayloadBuilder","intraBoundwitnessSchemaCombinations","TimestampSchema","order","moduleName","TemporalIndexingDivinerStateToIndexCandidateDiviner","AbstractDiviner","payloadDivinerLimit","config","payload_schemas","_a","schemas","filter","TimestampSchema","divineHandler","payloads","lastState","find","isModuleState","schema","ModuleStateSchema","state","offset","boundWitnessDiviner","getBoundWitnessDivinerForStore","query","PayloadBuilder","BoundWitnessDivinerQuerySchema","fields","limit","build","batch","divine","length","sourceArchivist","getArchivistForStore","bws","isBoundWitnessWithMeta","indexCandidates","Promise","all","map","bw","getPayloadsInBoundWitness","exists","flat","_b","name","assertEx","payloadStore","archivist","mod","resolve","ArchivistWrapper","wrap","account","DivinerWrapper","combinations","intraBoundwitnessSchemaCombinations","hashes","Set","get","__publicField","configSchemas","__superGet","_TemporalIndexingDivinerStateToIndexCandidateDiviner","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","defaultConfigSchema","labels"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Diviner.ts","../../src/DivinerQueryToIndexQueryDiviner/Diviner.ts","../../src/IndexCandidateToIndexDiviner/Diviner.ts","../../src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts","../../src/StateToIndexCandidateDiviner/Diviner.ts"],"sourcesContent":["import { IndexingDiviner } from '@xyo-network/diviner-indexing-memory'\nimport { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { TemporalIndexingDivinerConfigSchema, TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\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<boolean> {\n await super.startHandler()\n return true\n }\n}\n","import { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport { PayloadDivinerQueryPayload, PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\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 = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): string {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): string {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): string {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\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 if (!this._payloadTransformers) 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: 'offset',\n sourcePathExpression: '$.offset',\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 const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema))\n if (queries.length > 0) {\n const results = await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { 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 // TODO: Add support for additional filters\n return await new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()\n }),\n )\n return results\n }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isAnyPayload, Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\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 labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\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 if (!this._payloadTransformers) 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 const builtPayloads = await Promise.all(payloads.map((payload) => PayloadBuilder.build(payload)))\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = builtPayloads\n .filter(isBoundWitnessWithMeta)\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 = builtPayloads.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.toDataHashMap(indexableBoundWitnesses),\n PayloadBuilder.toDataHashMap(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 = await Promise.all(\n validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([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: string[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n return await new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n .fields(Object.assign({ sources }, ...indexFields))\n .build()\n }),\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) => {\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?: string | null) => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n","import { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { Payload, Schema } from '@xyo-network/payload-model'\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 static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // NOTE: 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 await Promise.resolve(responses)\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport {\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema,\n TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, Labels, ModuleIdentifier, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport { TimeStamp, TimestampSchema } from '@xyo-network/witness-timestamp'\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 labels: Labels = {\n ...super.labels,\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit() {\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(): string[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<[ModuleState, ...IndexCandidate[]]> {\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 if (!lastState) return [{ schema: ModuleStateSchema, state: { offset: 0 } }]\n // Otherwise, get the last offset\n const { offset } = lastState.state\n // Get next batch of results starting from the offset\n const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore()\n if (!boundWitnessDiviner) return [lastState]\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({ limit: this.payloadDivinerLimit, offset, order, payload_schemas: this.payload_schemas })\n .build()\n const batch = await boundWitnessDiviner.divine([query])\n if (batch.length === 0) return [lastState]\n // Get source data\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n const bws = batch.filter(isBoundWitnessWithMeta)\n const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextState = { schema: ModuleStateSchema, state: { ...lastState.state, offset: offset + batch.length } }\n return [nextState, ...indexCandidates]\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() {\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 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"],"mappings":";;;;;;;;;AAAA,SAASA,uBAAuB;AAEhC,SAASC,2CAA0E;AAG5E,IAAMC,2BAAN,MAAMA,iCASHC,gBAAAA;EAIR,MAAyBC,eAAiC;AACxD,UAAM,MAAMA,aAAAA;AACZ,WAAO;EACT;AACF;AARUD;AACR,cAVWD,0BAUcG,iBAA0B;KAAI,+DAAMA;EAAeC;;AAC5E,cAXWJ,0BAWcK,uBAA8BD;AAXlD,IAAMJ,0BAAN;;;ACJP,SAASM,uBAAuB;AAChC,SAASC,kCAAkCC,sBAAsB;AAEjE,SAAqCC,iCAAiC;AACtE,SACEC,oEAEAC,gDACK;AAEP,SAASC,sBAAsB;AAC/B,SAASC,6BAAsC;AAKxC,IAAMC,0DAAN,MAAMA,gEAEHC,gBAAAA;EAQAC;EACAC;;;;EAKR,IAAcC,qBAA6B;AACzC,WAAO,KAAKC,OAAOD,sBAAsBE;EAC3C;;;;EAKA,IAAcC,mBAA2B;AACvC,WAAO,KAAKF,OAAOE,oBAAoBD;EACzC;;;;EAKA,IAAcE,cAAsB;AAClC,WAAO,KAAKH,OAAOG,eAAeC;EACpC;;;;EAKA,IAAcC,mBAA6B;AACzC,QAAI,CAAC,KAAKR,kBAAmB,MAAKA,oBAAoBS,OAAOC,KAAK,KAAKC,gBAAgB;AACvF,WAAO,KAAKX;EACd;;;;;EAMA,IAAcY,sBAA6D;AACzE,QAAI,CAAC,KAAKX,qBAAsB,MAAKA,uBAAuBY,iCAAiC,KAAKF,gBAAgB;AAClH,WAAO,KAAKV;EACd;;;;;EAMA,IAAcU,mBAAmE;AAvEnF;AAwEI,aACE,UAAKR,WAAL,mBAAaQ,qBAAoB;MAC/B,CAAC,KA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,MAAM,KAAKC,QAAQL,IAAAA;AAC/B,QAAI,CAACI,IAAK;AAEV,WAAOM,eAAeF,KAMpBJ,KAAK,KAAKK,OAAO;EACrB;EAEA,MAAgBb,0BAA0BD,IAAkBQ,WAAqE;AAC/H,UAAMQ,eAAeC,qCAAoCjB,IAAI,KAAKhC,eAAe,EAAEmC,KAAI;AACvF,QAAIa,aAAazB,WAAW,EAAG,QAAOoB;AACtC,UAAMO,SAAS,IAAIC,IAAIH,YAAAA;AACvB,UAAMpB,kBAAkB,MAAMY,UAAUY,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAClB;SAAOJ;;EACjB;AACF;AA5FU/B;AACR,cAHWD,sDAGcyD,iBAA0B;KAAI,uHAAMA;EAAeC;;AAC5E,cAJW1D,sDAIc2D,uBAA8BD;AACvD,cALW1D,sDAKK4D,UAAiB;EAC/B,GAAG,uHAAMA;EACT,6BAA6B;AAC/B;AARK,IAAM5D,sDAAN;","names":["IndexingDiviner","TemporalIndexingDivinerConfigSchema","TemporalIndexingDiviner","IndexingDiviner","startHandler","configSchemas","TemporalIndexingDivinerConfigSchema","defaultConfigSchema","AbstractDiviner","jsonPathToTransformersDictionary","reducePayloads","PayloadDivinerQuerySchema","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isPayloadOfSchemaType","TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner","AbstractDiviner","_indexableSchemas","_payloadTransformers","divinerQuerySchema","config","PayloadDivinerQuerySchema","indexQuerySchema","indexSchema","TemporalIndexingDivinerResultIndexSchema","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","defaultValue","destinationField","sourcePathExpression","divineHandler","payloads","queries","filter","isPayloadOfSchemaType","length","results","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","configSchemas","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","defaultConfigSchema","labels","containsAll","assertEx","exists","isBoundWitnessWithMeta","AbstractDiviner","jsonPathToTransformersDictionary","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isAnyPayload","intraBoundwitnessSchemaCombinations","moduleName","TemporalIndexingDivinerIndexCandidateToIndexDiviner","AbstractDiviner","_indexableSchemas","_payloadTransformers","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","assertEx","config","divineHandler","payloads","builtPayloads","Promise","all","map","payload","PayloadBuilder","build","indexableBoundWitnesses","filter","isBoundWitnessWithMeta","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","flat","x","isAnyPayload","includes","isIndexableSchema","configSchemas","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","defaultConfigSchema","labels","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","assertEx","exists","ArchivistWrapper","isBoundWitnessWithMeta","AbstractDiviner","BoundWitnessDivinerQuerySchema","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","PayloadBuilder","intraBoundwitnessSchemaCombinations","TimestampSchema","order","moduleName","TemporalIndexingDivinerStateToIndexCandidateDiviner","AbstractDiviner","payloadDivinerLimit","config","payload_schemas","schemas","filter","TimestampSchema","divineHandler","payloads","lastState","find","isModuleState","schema","ModuleStateSchema","state","offset","boundWitnessDiviner","getBoundWitnessDivinerForStore","query","PayloadBuilder","BoundWitnessDivinerQuerySchema","fields","limit","build","batch","divine","length","sourceArchivist","getArchivistForStore","bws","isBoundWitnessWithMeta","indexCandidates","Promise","all","map","bw","getPayloadsInBoundWitness","exists","flat","nextState","name","assertEx","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","DivinerWrapper","combinations","intraBoundwitnessSchemaCombinations","hashes","Set","get","configSchemas","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","defaultConfigSchema","labels"]}
|