@xyo-network/diviner-payload-pointer-memory 7.2.3 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.d.ts +1 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -141
- package/dist/neutral/index.mjs.map +4 -4
- package/package.json +9 -17
- package/dist/neutral/Diviner.d.ts +0 -25
- package/dist/neutral/Diviner.d.ts.map +0 -1
- package/dist/neutral/combineRules.d.ts +0 -3
- package/dist/neutral/combineRules.d.ts.map +0 -1
- package/dist/neutral/findPayload.d.ts +0 -7
- package/dist/neutral/findPayload.d.ts.map +0 -1
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@xyo-network/diviner-payload-pointer/memory';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,6CAA6C,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,142 +1,3 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
isPointerPayload,
|
|
5
|
-
PayloadPointerDivinerConfigSchema
|
|
6
|
-
} from "@xyo-network/diviner-payload-pointer-model";
|
|
7
|
-
import { AbstractDiviner } from "@xyo-network/sdk/diviner-abstract";
|
|
8
|
-
import { asDivinerInstance } from "@xyo-network/sdk/diviner-model";
|
|
9
|
-
|
|
10
|
-
// src/findPayload.ts
|
|
11
|
-
import { isBoundWitnessPointer } from "@xyo-network/diviner-payload-pointer-model";
|
|
12
|
-
import { BoundWitnessDivinerQuerySchema } from "@xyo-network/sdk/diviner-boundwitness/model";
|
|
13
|
-
import { PayloadDivinerQuerySchema } from "@xyo-network/sdk/diviner-payload-model";
|
|
14
|
-
import { BoundWitnessWrapper, PayloadWrapper } from "@xyo-network/sdk-protocol";
|
|
15
|
-
|
|
16
|
-
// src/combineRules.ts
|
|
17
|
-
import { assertEx, exists } from "@ariestools/sdk";
|
|
18
|
-
import {
|
|
19
|
-
isPayloadAddressRule,
|
|
20
|
-
isPayloadSchemaRule,
|
|
21
|
-
isPayloadSequenceOrderRule
|
|
22
|
-
} from "@xyo-network/diviner-payload-pointer-model";
|
|
23
|
-
var combineRules = (rules) => {
|
|
24
|
-
const addresses = rules.flat().filter(isPayloadAddressRule).map((r) => r.address).filter(exists);
|
|
25
|
-
const schemas = rules.flat().filter(isPayloadSchemaRule).map((r) => r.schema).filter(exists);
|
|
26
|
-
assertEx(schemas.length, () => "At least one schema must be supplied");
|
|
27
|
-
const sequenceOrderRule = rules.flat().filter(isPayloadSequenceOrderRule).filter(exists);
|
|
28
|
-
assertEx(sequenceOrderRule.length < 2, () => "Must not supply more than 1 direction/timestamp rule");
|
|
29
|
-
const order = sequenceOrderRule[0]?.order ?? "desc";
|
|
30
|
-
const cursor = sequenceOrderRule[0]?.sequence;
|
|
31
|
-
return {
|
|
32
|
-
addresses,
|
|
33
|
-
cursor,
|
|
34
|
-
order,
|
|
35
|
-
schemas
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/findPayload.ts
|
|
40
|
-
var limit = 1;
|
|
41
|
-
var createBoundWitnessFilterFromSearchCriteria = (searchCriteria) => {
|
|
42
|
-
const {
|
|
43
|
-
addresses,
|
|
44
|
-
order = "desc",
|
|
45
|
-
schemas,
|
|
46
|
-
cursor
|
|
47
|
-
} = searchCriteria;
|
|
48
|
-
const query = {
|
|
49
|
-
addresses,
|
|
50
|
-
limit,
|
|
51
|
-
order,
|
|
52
|
-
payload_schemas: schemas,
|
|
53
|
-
schema: BoundWitnessDivinerQuerySchema
|
|
54
|
-
};
|
|
55
|
-
if (cursor) query.cursor = cursor;
|
|
56
|
-
return [query];
|
|
57
|
-
};
|
|
58
|
-
var createPayloadFilterFromSearchCriteria = (searchCriteria) => {
|
|
59
|
-
const { order = "desc", schemas } = searchCriteria;
|
|
60
|
-
const query = {
|
|
61
|
-
limit,
|
|
62
|
-
order,
|
|
63
|
-
schema: PayloadDivinerQuerySchema,
|
|
64
|
-
schemas
|
|
65
|
-
};
|
|
66
|
-
return [query];
|
|
67
|
-
};
|
|
68
|
-
var findPayload = async (archivist, boundWitnessDiviner, payloadDiviner, pointer) => {
|
|
69
|
-
const reference = pointer.reference;
|
|
70
|
-
const searchCriteria = combineRules(reference);
|
|
71
|
-
const { addresses } = searchCriteria;
|
|
72
|
-
const findWitnessedPayload = addresses?.length;
|
|
73
|
-
const returnBoundWitness = isBoundWitnessPointer(pointer);
|
|
74
|
-
if (returnBoundWitness || findWitnessedPayload) {
|
|
75
|
-
const filter = createBoundWitnessFilterFromSearchCriteria(searchCriteria);
|
|
76
|
-
const result = await boundWitnessDiviner.divine(filter);
|
|
77
|
-
const bw = result?.[0] ? BoundWitnessWrapper.parse(result[0]) : void 0;
|
|
78
|
-
if (bw) {
|
|
79
|
-
if (returnBoundWitness) return bw.payload;
|
|
80
|
-
const { schemas, order = "desc" } = searchCriteria;
|
|
81
|
-
let payloadIndex = order === "asc" ? 0 : bw.payloadHashes.length - 1;
|
|
82
|
-
if (schemas) {
|
|
83
|
-
const schemaInSearchCriteria = (schema) => schemas.includes(schema);
|
|
84
|
-
payloadIndex = order === "asc" ? bw.payloadSchemas.findIndex(schemaInSearchCriteria) : bw.payloadSchemas.findLastIndex(schemaInSearchCriteria);
|
|
85
|
-
}
|
|
86
|
-
const hash = bw.payloadHashes[payloadIndex];
|
|
87
|
-
const result2 = await archivist.get([hash]);
|
|
88
|
-
return result2?.[0] ? PayloadWrapper.wrap(result2?.[0]).payload : void 0;
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
const filter = createPayloadFilterFromSearchCriteria(searchCriteria);
|
|
92
|
-
const result = await payloadDiviner.divine(filter);
|
|
93
|
-
return result?.[0] ? PayloadWrapper.wrap(result?.[0]).payload : void 0;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// src/Diviner.ts
|
|
98
|
-
var PayloadPointerDiviner = class extends AbstractDiviner {
|
|
99
|
-
static configSchemas = [...super.configSchemas, PayloadPointerDivinerConfigSchema];
|
|
100
|
-
static defaultConfigSchema = PayloadPointerDivinerConfigSchema;
|
|
101
|
-
async divineHandler(payloads) {
|
|
102
|
-
const pointer = payloads?.find(isPointerPayload);
|
|
103
|
-
if (!pointer) return [];
|
|
104
|
-
const archivist = await this.getConfigArchivist();
|
|
105
|
-
const boundWitnessDiviner = await this.getBoundWitnessDiviner();
|
|
106
|
-
const payloadDiviner = await this.getPayloadDiviner();
|
|
107
|
-
const result = await findPayload(archivist, boundWitnessDiviner, payloadDiviner, pointer);
|
|
108
|
-
return result ? [result] : [];
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Returns the archivist instance for the given config
|
|
112
|
-
* @returns The archivist instance corresponding to the config
|
|
113
|
-
*/
|
|
114
|
-
async getBoundWitnessDiviner() {
|
|
115
|
-
const name = assertEx2(this.config?.boundWitnessDiviner, () => "Missing archivist in config");
|
|
116
|
-
const mod = assertEx2(await this.resolve(name), () => `Config.boundWitnessDiviner module value of ${name} not resolved`);
|
|
117
|
-
const diviner = assertEx2(asDivinerInstance(mod), () => `Module ${name} is not an BoundWitnessDiviner`);
|
|
118
|
-
return diviner;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns the archivist instance for the given config
|
|
122
|
-
* @returns The archivist instance corresponding to the config
|
|
123
|
-
*/
|
|
124
|
-
async getConfigArchivist() {
|
|
125
|
-
const name = assertEx2(this.config?.archivist, () => "Missing archivist in config");
|
|
126
|
-
return assertEx2(await this.archivistInstance(), () => `Config.archivist module value of ${name} not resolved`);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Returns the archivist instance for the given config
|
|
130
|
-
* @returns The archivist instance corresponding to the config
|
|
131
|
-
*/
|
|
132
|
-
async getPayloadDiviner() {
|
|
133
|
-
const name = assertEx2(this.config?.payloadDiviner, () => "Missing payloadDiviner in config");
|
|
134
|
-
const mod = assertEx2(await this.resolve(name), () => `Config.payloadDiviner module value of ${name} not resolved`);
|
|
135
|
-
const diviner = assertEx2(asDivinerInstance(mod), () => `Module ${name} is not an PayloadDiviner`);
|
|
136
|
-
return diviner;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
export {
|
|
140
|
-
PayloadPointerDiviner
|
|
141
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@xyo-network/diviner-payload-pointer/memory";
|
|
142
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/diviner-payload-pointer/memory.\nexport * from '@xyo-network/diviner-payload-pointer/memory'\n"],
|
|
5
|
+
"mappings": ";AACA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-payload-pointer-memory",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -34,32 +34,24 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@xyo-network/diviner-payload-pointer
|
|
38
|
-
"@xyo-network/sdk": "~7.2.3"
|
|
37
|
+
"@xyo-network/diviner-payload-pointer": "~7.3.1"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@ariestools/sdk": "~8.1.
|
|
42
|
-
"@ariestools/toolchain": "~
|
|
43
|
-
"@ariestools/tsconfig": "~
|
|
44
|
-
"@ariestools/vitest-extended": "~8.0.3",
|
|
40
|
+
"@ariestools/sdk": "~8.1.9",
|
|
41
|
+
"@ariestools/toolchain": "~9.1.1",
|
|
42
|
+
"@ariestools/tsconfig": "~9.1.1",
|
|
45
43
|
"@opentelemetry/api": "~1.9.1",
|
|
46
|
-
"@xyo-network/sdk-protocol": "~7.
|
|
47
|
-
"eslint": "~10.
|
|
44
|
+
"@xyo-network/sdk-protocol": "~7.3.3",
|
|
45
|
+
"eslint": "~10.9.0",
|
|
48
46
|
"eslint-import-resolver-typescript": "~4.4.5",
|
|
49
47
|
"typescript": "~6.0.3",
|
|
50
|
-
"uuid": "~14.0.1",
|
|
51
|
-
"vite": "~8.1.5",
|
|
52
|
-
"vitest": "~4.1.10",
|
|
53
48
|
"zod": "~4.4.3"
|
|
54
49
|
},
|
|
55
|
-
"peerDependencies": {
|
|
56
|
-
"@ariestools/sdk": "^8.1",
|
|
57
|
-
"@xyo-network/sdk-protocol": "^7.2"
|
|
58
|
-
},
|
|
59
50
|
"engines": {
|
|
60
51
|
"node": "^24"
|
|
61
52
|
},
|
|
62
53
|
"publishConfig": {
|
|
63
54
|
"access": "public"
|
|
64
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"deprecated": "Use @xyo-network/diviner-payload-pointer/memory instead. This package is a compatibility shim only and will not receive further updates."
|
|
65
57
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { PayloadPointerDivinerParams, PointerPayload } from '@xyo-network/diviner-payload-pointer-model';
|
|
2
|
-
import { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract';
|
|
3
|
-
import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/sdk/diviner-model';
|
|
4
|
-
import type { Payload, Schema } from '@xyo-network/sdk-protocol';
|
|
5
|
-
export declare class PayloadPointerDiviner<TParams extends PayloadPointerDivinerParams = PayloadPointerDivinerParams, TIn extends PointerPayload = PointerPayload, TOut extends Payload = Payload, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
|
|
6
|
-
static readonly configSchemas: Schema[];
|
|
7
|
-
static readonly defaultConfigSchema: Schema;
|
|
8
|
-
protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
|
|
9
|
-
/**
|
|
10
|
-
* Returns the archivist instance for the given config
|
|
11
|
-
* @returns The archivist instance corresponding to the config
|
|
12
|
-
*/
|
|
13
|
-
private getBoundWitnessDiviner;
|
|
14
|
-
/**
|
|
15
|
-
* Returns the archivist instance for the given config
|
|
16
|
-
* @returns The archivist instance corresponding to the config
|
|
17
|
-
*/
|
|
18
|
-
private getConfigArchivist;
|
|
19
|
-
/**
|
|
20
|
-
* Returns the archivist instance for the given config
|
|
21
|
-
* @returns The archivist instance corresponding to the config
|
|
22
|
-
*/
|
|
23
|
-
private getPayloadDiviner;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=Diviner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,cAAc,EACf,MAAM,4CAA4C,CAAA;AAMnD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAG7F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAIhE,qBAAa,qBAAqB,CAChC,OAAO,SAAS,2BAA2B,GAAG,2BAA2B,EACzE,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,UAAU,SAAS,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,sBAAsB,CAChH,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EACnC,GAAG,EACH,IAAI,CACL,CACD,SAAQ,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC;IACvD,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA8D;IAC9G,gBAAyB,mBAAmB,EAAE,MAAM,CAAoC;cAE/D,aAAa,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAUzE;;;OAGG;YACW,sBAAsB;IAOpC;;;OAGG;YACW,kBAAkB;IAKhC;;;OAGG;YACW,iBAAiB;CAMhC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"combineRules.d.ts","sourceRoot":"","sources":["../../src/combineRules.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACtB,MAAM,4CAA4C,CAAA;AAWnD,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,EAAE,EAAE,KAAG,qBA0BrD,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PointerPayload } from '@xyo-network/diviner-payload-pointer-model';
|
|
2
|
-
import type { ArchivistInstance } from '@xyo-network/sdk/archivist-model';
|
|
3
|
-
import type { BoundWitnessDiviner } from '@xyo-network/sdk/diviner-boundwitness/abstract';
|
|
4
|
-
import type { PayloadDiviner } from '@xyo-network/sdk/diviner-payload-abstract';
|
|
5
|
-
import type { Payload } from '@xyo-network/sdk-protocol';
|
|
6
|
-
export declare const findPayload: (archivist: ArchivistInstance, boundWitnessDiviner: BoundWitnessDiviner, payloadDiviner: PayloadDiviner, pointer: PointerPayload) => Promise<Payload | undefined>;
|
|
7
|
-
//# sourceMappingURL=findPayload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findPayload.d.ts","sourceRoot":"","sources":["../../src/findPayload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAEvG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AAGzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAG/E,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,2BAA2B,CAAA;AA8BhE,eAAO,MAAM,WAAW,GACtB,WAAW,iBAAiB,EAC5B,qBAAqB,mBAAmB,EACxC,gBAAgB,cAAc,EAC9B,SAAS,cAAc,KACtB,OAAO,CAAC,OAAO,GAAG,SAAS,CA4B7B,CAAA"}
|