@xyo-network/diviner-temporal-indexing-memory 2.84.5 → 2.84.7
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/IndexCandidateToIndexDiviner/Diviner.d.cts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.mts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.cts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.mts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.ts.map +1 -1
- package/dist/browser/index.cjs +12 -12
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +12 -12
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/jsonpath/reducePayloads.d.cts.map +1 -1
- package/dist/browser/jsonpath/reducePayloads.d.mts.map +1 -1
- package/dist/browser/jsonpath/reducePayloads.d.ts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.cts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.mts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.cts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.mts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.ts.map +1 -1
- package/dist/node/index.cjs +12 -12
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +12 -12
- package/dist/node/index.js.map +1 -1
- package/dist/node/jsonpath/reducePayloads.d.cts.map +1 -1
- package/dist/node/jsonpath/reducePayloads.d.mts.map +1 -1
- package/dist/node/jsonpath/reducePayloads.d.ts.map +1 -1
- package/package.json +26 -26
- package/src/DivinerQueryToIndexQueryDiviner/Diviner.ts +3 -3
- package/src/IndexCandidateToIndexDiviner/Diviner.ts +11 -12
- package/src/IndexCandidateToIndexDiviner/_Diviner.ts +11 -12
- package/src/StateToIndexCandidateDiviner/Diviner.ts +2 -2
- package/src/jsonpath/reducePayloads.ts +6 -8
package/package.json
CHANGED
|
@@ -13,36 +13,36 @@
|
|
|
13
13
|
"@xylabs/array": "^2.13.20",
|
|
14
14
|
"@xylabs/assert": "^2.13.20",
|
|
15
15
|
"@xylabs/exists": "^2.13.20",
|
|
16
|
-
"@xyo-network/abstract-diviner": "~2.84.
|
|
17
|
-
"@xyo-network/archivist-model": "~2.84.
|
|
18
|
-
"@xyo-network/archivist-wrapper": "~2.84.
|
|
19
|
-
"@xyo-network/boundwitness-model": "~2.84.
|
|
20
|
-
"@xyo-network/diviner-boundwitness-model": "~2.84.
|
|
21
|
-
"@xyo-network/diviner-indexing-memory": "~2.84.
|
|
22
|
-
"@xyo-network/diviner-indexing-model": "~2.84.
|
|
23
|
-
"@xyo-network/diviner-model": "~2.84.
|
|
24
|
-
"@xyo-network/diviner-payload-model": "~2.84.
|
|
25
|
-
"@xyo-network/diviner-temporal-indexing-model": "~2.84.
|
|
26
|
-
"@xyo-network/diviner-wrapper": "~2.84.
|
|
27
|
-
"@xyo-network/hash": "~2.84.
|
|
28
|
-
"@xyo-network/module-model": "~2.84.
|
|
29
|
-
"@xyo-network/payload-builder": "~2.84.
|
|
30
|
-
"@xyo-network/payload-model": "~2.84.
|
|
31
|
-
"@xyo-network/witness-timestamp": "~2.84.
|
|
16
|
+
"@xyo-network/abstract-diviner": "~2.84.7",
|
|
17
|
+
"@xyo-network/archivist-model": "~2.84.7",
|
|
18
|
+
"@xyo-network/archivist-wrapper": "~2.84.7",
|
|
19
|
+
"@xyo-network/boundwitness-model": "~2.84.7",
|
|
20
|
+
"@xyo-network/diviner-boundwitness-model": "~2.84.7",
|
|
21
|
+
"@xyo-network/diviner-indexing-memory": "~2.84.7",
|
|
22
|
+
"@xyo-network/diviner-indexing-model": "~2.84.7",
|
|
23
|
+
"@xyo-network/diviner-model": "~2.84.7",
|
|
24
|
+
"@xyo-network/diviner-payload-model": "~2.84.7",
|
|
25
|
+
"@xyo-network/diviner-temporal-indexing-model": "~2.84.7",
|
|
26
|
+
"@xyo-network/diviner-wrapper": "~2.84.7",
|
|
27
|
+
"@xyo-network/hash": "~2.84.7",
|
|
28
|
+
"@xyo-network/module-model": "~2.84.7",
|
|
29
|
+
"@xyo-network/payload-builder": "~2.84.7",
|
|
30
|
+
"@xyo-network/payload-model": "~2.84.7",
|
|
31
|
+
"@xyo-network/witness-timestamp": "~2.84.7",
|
|
32
32
|
"jsonpath": "^1.1.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jsonpath": "^0.2.4",
|
|
36
36
|
"@xylabs/delay": "^2.13.20",
|
|
37
|
-
"@xylabs/ts-scripts-yarn3": "^3.2.
|
|
38
|
-
"@xylabs/tsconfig": "^3.2.
|
|
39
|
-
"@xyo-network/account": "~2.84.
|
|
40
|
-
"@xyo-network/boundwitness-builder": "~2.84.
|
|
41
|
-
"@xyo-network/diviner-boundwitness-memory": "~2.84.
|
|
42
|
-
"@xyo-network/diviner-payload-memory": "~2.84.
|
|
43
|
-
"@xyo-network/manifest": "~2.84.
|
|
44
|
-
"@xyo-network/memory-archivist": "~2.84.
|
|
45
|
-
"@xyo-network/node-memory": "~2.84.
|
|
37
|
+
"@xylabs/ts-scripts-yarn3": "^3.2.24",
|
|
38
|
+
"@xylabs/tsconfig": "^3.2.24",
|
|
39
|
+
"@xyo-network/account": "~2.84.7",
|
|
40
|
+
"@xyo-network/boundwitness-builder": "~2.84.7",
|
|
41
|
+
"@xyo-network/diviner-boundwitness-memory": "~2.84.7",
|
|
42
|
+
"@xyo-network/diviner-payload-memory": "~2.84.7",
|
|
43
|
+
"@xyo-network/manifest": "~2.84.7",
|
|
44
|
+
"@xyo-network/memory-archivist": "~2.84.7",
|
|
45
|
+
"@xyo-network/node-memory": "~2.84.7",
|
|
46
46
|
"typescript": "^5.3.3"
|
|
47
47
|
},
|
|
48
48
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
@@ -84,6 +84,6 @@
|
|
|
84
84
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
85
85
|
},
|
|
86
86
|
"sideEffects": false,
|
|
87
|
-
"version": "2.84.
|
|
87
|
+
"version": "2.84.7",
|
|
88
88
|
"type": "module"
|
|
89
89
|
}
|
|
@@ -54,7 +54,7 @@ export class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<
|
|
|
54
54
|
* List of indexable schemas for this diviner
|
|
55
55
|
*/
|
|
56
56
|
protected get indexableSchemas(): string[] {
|
|
57
|
-
if (!this._indexableSchemas) this._indexableSchemas =
|
|
57
|
+
if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)
|
|
58
58
|
return this._indexableSchemas
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -97,7 +97,7 @@ export class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<
|
|
|
97
97
|
|
|
98
98
|
protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {
|
|
99
99
|
const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema))
|
|
100
|
-
if (queries.length) {
|
|
100
|
+
if (queries.length > 0) {
|
|
101
101
|
const results = await Promise.all(
|
|
102
102
|
queries.map(async (query) => {
|
|
103
103
|
const fields = await reducePayloads<PayloadDivinerQueryPayload & { sources?: string[] }>(
|
|
@@ -115,6 +115,6 @@ export class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<
|
|
|
115
115
|
)
|
|
116
116
|
return results
|
|
117
117
|
}
|
|
118
|
-
return
|
|
118
|
+
return []
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -44,7 +44,7 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
44
44
|
* List of indexable schemas for this diviner
|
|
45
45
|
*/
|
|
46
46
|
protected get indexableSchemas(): string[] {
|
|
47
|
-
if (!this._indexableSchemas) this._indexableSchemas =
|
|
47
|
+
if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)
|
|
48
48
|
return this._indexableSchemas
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -68,8 +68,9 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
68
68
|
protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {
|
|
69
69
|
const bws: BoundWitness[] = payloads.filter(isBoundWitness)
|
|
70
70
|
const indexablePayloads: Payload[] = payloads.filter((p) => this.isIndexablePayload(p))
|
|
71
|
-
if (bws.length && indexablePayloads.length) {
|
|
71
|
+
if (bws.length > 0 && indexablePayloads.length > 0) {
|
|
72
72
|
const payloadDictionary = await PayloadHasher.toMap(payloads)
|
|
73
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
73
74
|
const validIndexableTuples: IndexablePayloads[] = bws.reduce<IndexablePayloads[]>((indexableTuples, bw) => {
|
|
74
75
|
// If this Bound Witness doesn't contain all the required schemas don't index it
|
|
75
76
|
if (!containsAll(bw.payload_schemas, this.indexableSchemas)) return indexableTuples
|
|
@@ -86,14 +87,12 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
86
87
|
const indexes = await Promise.all(
|
|
87
88
|
validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bw, ...sourcePayloads]) => {
|
|
88
89
|
// Use the payload transformers to convert the fields from the source payloads to the destination fields
|
|
89
|
-
const indexFields = sourcePayloads
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
.flat()
|
|
90
|
+
const indexFields = sourcePayloads.flatMap<PayloadFields[]>((payload) => {
|
|
91
|
+
// Find the transformers for this payload
|
|
92
|
+
const transformers = this.payloadTransformers[payload.schema]
|
|
93
|
+
// If transformers exist, apply them to the payload otherwise return an empty array
|
|
94
|
+
return transformers ? transformers.map((transform) => transform(payload)) : []
|
|
95
|
+
})
|
|
97
96
|
// Include all the sources for reference
|
|
98
97
|
const sources = Object.keys(await PayloadHasher.toMap([bw, ...sourcePayloads]))
|
|
99
98
|
// Build and return the index
|
|
@@ -104,7 +103,7 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
104
103
|
)
|
|
105
104
|
return indexes.flat()
|
|
106
105
|
}
|
|
107
|
-
return
|
|
106
|
+
return []
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
/**
|
|
@@ -122,6 +121,6 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
122
121
|
* @returns True if this schema is one indexed by this diviner, false otherwise
|
|
123
122
|
*/
|
|
124
123
|
protected isIndexableSchema = (schema?: string | null) => {
|
|
125
|
-
return this.indexableSchemas.
|
|
124
|
+
return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false
|
|
126
125
|
}
|
|
127
126
|
}
|
|
@@ -45,7 +45,7 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
45
45
|
* List of indexable schemas for this diviner
|
|
46
46
|
*/
|
|
47
47
|
protected get indexableSchemas(): string[] {
|
|
48
|
-
if (!this._indexableSchemas) this._indexableSchemas =
|
|
48
|
+
if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)
|
|
49
49
|
return this._indexableSchemas
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -70,8 +70,9 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
70
70
|
const bws: BoundWitness[] = payloads.filter(isBoundWitness)
|
|
71
71
|
const timestampPayloads: TimeStamp[] = payloads.filter(isTimestamp)
|
|
72
72
|
const indexablePayloads: Payload[] = payloads.filter((p) => this.isIndexablePayload(p))
|
|
73
|
-
if (bws.length && timestampPayloads.length && indexablePayloads.length) {
|
|
73
|
+
if (bws.length > 0 && timestampPayloads.length > 0 && indexablePayloads.length > 0) {
|
|
74
74
|
const payloadDictionary = await PayloadHasher.toMap(payloads)
|
|
75
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
75
76
|
const validIndexableTuples: IndexablePayloads[] = bws.reduce<IndexablePayloads[]>((indexableTuples, bw) => {
|
|
76
77
|
// If this Bound Witness doesn't contain all the required schemas don't index it
|
|
77
78
|
if (!containsAll(bw.payload_schemas, this.indexableSchemas)) return indexableTuples
|
|
@@ -92,14 +93,12 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
92
93
|
const indexes = await Promise.all(
|
|
93
94
|
validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bw, timestampPayload, ...sourcePayloads]) => {
|
|
94
95
|
// Use the payload transformers to convert the fields from the source payloads to the destination fields
|
|
95
|
-
const indexFields = sourcePayloads
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
})
|
|
102
|
-
.flat()
|
|
96
|
+
const indexFields = sourcePayloads.flatMap<PayloadFields[]>((payload) => {
|
|
97
|
+
// Find the transformers for this payload
|
|
98
|
+
const transformers = this.payloadTransformers[payload.schema]
|
|
99
|
+
// If transformers exist, apply them to the payload otherwise return an empty array
|
|
100
|
+
return transformers ? transformers.map((transform) => transform(payload)) : []
|
|
101
|
+
})
|
|
103
102
|
// Extract the timestamp from the timestamp payload
|
|
104
103
|
const { timestamp } = timestampPayload
|
|
105
104
|
// Include all the sources for reference
|
|
@@ -112,7 +111,7 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
112
111
|
)
|
|
113
112
|
return indexes.flat()
|
|
114
113
|
}
|
|
115
|
-
return
|
|
114
|
+
return []
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
/**
|
|
@@ -130,6 +129,6 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
130
129
|
* @returns True if this schema is one indexed by this diviner, false otherwise
|
|
131
130
|
*/
|
|
132
131
|
protected isIndexableSchema = (schema?: string | null) => {
|
|
133
|
-
return this.indexableSchemas.
|
|
132
|
+
return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false
|
|
134
133
|
}
|
|
135
134
|
}
|
|
@@ -59,7 +59,7 @@ export class TemporalIndexingDivinerStateToIndexCandidateDiviner<
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
get payloadDivinerLimit() {
|
|
62
|
-
return this.config.payloadDivinerLimit ??
|
|
62
|
+
return this.config.payloadDivinerLimit ?? 1000
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -133,7 +133,7 @@ export class TemporalIndexingDivinerStateToIndexCandidateDiviner<
|
|
|
133
133
|
const results = await archivist.get(hashes)
|
|
134
134
|
const indexCandidateIdentityFunctions = this.payload_schemas.map(isPayloadOfSchemaType)
|
|
135
135
|
const filteredResults = indexCandidateIdentityFunctions.map((is) => results.find(is))
|
|
136
|
-
if (filteredResults.
|
|
136
|
+
if (filteredResults.includes(undefined)) return undefined
|
|
137
137
|
const indexCandidates: IndexCandidate[] = filteredResults.filter(exists) as IndexCandidate[]
|
|
138
138
|
return [bw, ...indexCandidates]
|
|
139
139
|
}
|
|
@@ -16,14 +16,12 @@ export const reducePayloads = async <T extends Payload = Payload>(
|
|
|
16
16
|
destinationSchema: string,
|
|
17
17
|
): Promise<T> => {
|
|
18
18
|
// Use the payload transformers to convert the fields from the source payloads to the destination fields
|
|
19
|
-
const indexFields = payloads
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
.flat()
|
|
19
|
+
const indexFields = payloads.flatMap<PayloadFields[]>((payload) => {
|
|
20
|
+
// Find the transformers for this payload
|
|
21
|
+
const transformers = payloadTransformers[payload.schema]
|
|
22
|
+
// If transformers exist, apply them to the payload otherwise return an empty array
|
|
23
|
+
return transformers ? transformers.map((transform) => transform(payload)) : []
|
|
24
|
+
})
|
|
27
25
|
// Include all the sources for reference
|
|
28
26
|
const sources = (await PayloadHasher.hashPairs([...payloads])).map(([, hash]) => hash)
|
|
29
27
|
// Build and return the index
|