@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.
Files changed (32) hide show
  1. package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.cts.map +1 -1
  2. package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.mts.map +1 -1
  3. package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
  4. package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.cts.map +1 -1
  5. package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.mts.map +1 -1
  6. package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.ts.map +1 -1
  7. package/dist/browser/index.cjs +12 -12
  8. package/dist/browser/index.cjs.map +1 -1
  9. package/dist/browser/index.js +12 -12
  10. package/dist/browser/index.js.map +1 -1
  11. package/dist/browser/jsonpath/reducePayloads.d.cts.map +1 -1
  12. package/dist/browser/jsonpath/reducePayloads.d.mts.map +1 -1
  13. package/dist/browser/jsonpath/reducePayloads.d.ts.map +1 -1
  14. package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.cts.map +1 -1
  15. package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.mts.map +1 -1
  16. package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
  17. package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.cts.map +1 -1
  18. package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.mts.map +1 -1
  19. package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.ts.map +1 -1
  20. package/dist/node/index.cjs +12 -12
  21. package/dist/node/index.cjs.map +1 -1
  22. package/dist/node/index.js +12 -12
  23. package/dist/node/index.js.map +1 -1
  24. package/dist/node/jsonpath/reducePayloads.d.cts.map +1 -1
  25. package/dist/node/jsonpath/reducePayloads.d.mts.map +1 -1
  26. package/dist/node/jsonpath/reducePayloads.d.ts.map +1 -1
  27. package/package.json +26 -26
  28. package/src/DivinerQueryToIndexQueryDiviner/Diviner.ts +3 -3
  29. package/src/IndexCandidateToIndexDiviner/Diviner.ts +11 -12
  30. package/src/IndexCandidateToIndexDiviner/_Diviner.ts +11 -12
  31. package/src/StateToIndexCandidateDiviner/Diviner.ts +2 -2
  32. 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.5",
17
- "@xyo-network/archivist-model": "~2.84.5",
18
- "@xyo-network/archivist-wrapper": "~2.84.5",
19
- "@xyo-network/boundwitness-model": "~2.84.5",
20
- "@xyo-network/diviner-boundwitness-model": "~2.84.5",
21
- "@xyo-network/diviner-indexing-memory": "~2.84.5",
22
- "@xyo-network/diviner-indexing-model": "~2.84.5",
23
- "@xyo-network/diviner-model": "~2.84.5",
24
- "@xyo-network/diviner-payload-model": "~2.84.5",
25
- "@xyo-network/diviner-temporal-indexing-model": "~2.84.5",
26
- "@xyo-network/diviner-wrapper": "~2.84.5",
27
- "@xyo-network/hash": "~2.84.5",
28
- "@xyo-network/module-model": "~2.84.5",
29
- "@xyo-network/payload-builder": "~2.84.5",
30
- "@xyo-network/payload-model": "~2.84.5",
31
- "@xyo-network/witness-timestamp": "~2.84.5",
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.19",
38
- "@xylabs/tsconfig": "^3.2.19",
39
- "@xyo-network/account": "~2.84.5",
40
- "@xyo-network/boundwitness-builder": "~2.84.5",
41
- "@xyo-network/diviner-boundwitness-memory": "~2.84.5",
42
- "@xyo-network/diviner-payload-memory": "~2.84.5",
43
- "@xyo-network/manifest": "~2.84.5",
44
- "@xyo-network/memory-archivist": "~2.84.5",
45
- "@xyo-network/node-memory": "~2.84.5",
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.5",
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 = [...Object.keys(this.schemaTransforms)]
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 Promise.resolve([])
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 = [...Object.keys(this.schemaTransforms)]
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
- .map<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
- })
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 Promise.resolve([])
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.some((s) => s === schema)
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 = [...Object.keys(this.schemaTransforms)]
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
- .map<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
- })
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 Promise.resolve([])
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.some((s) => s === schema)
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 ?? 1_000
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.some((f) => f === undefined)) return undefined
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
- .map<PayloadFields[]>((payload) => {
21
- // Find the transformers for this payload
22
- const transformers = payloadTransformers[payload.schema]
23
- // If transformers exist, apply them to the payload otherwise return an empty array
24
- return transformers ? transformers.map((transform) => transform(payload)) : []
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