@xyo-network/api 2.41.2 → 2.41.4
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/cjs/Archivist/XyoRemoteArchivist.d.ts +1 -1
- package/dist/cjs/Archivist/XyoRemoteArchivist.d.ts.map +1 -1
- package/dist/cjs/Archivist/XyoRemoteArchivist.js +14 -7
- package/dist/cjs/Archivist/XyoRemoteArchivist.js.map +1 -1
- package/dist/cjs/Archivist/XyoRemoteArchivistConfig.d.ts +2 -2
- package/dist/cjs/Archivist/XyoRemoteArchivistConfig.d.ts.map +1 -1
- package/dist/cjs/Diviner/AddressHistoryDiviner/AddressHistoryDiviner.d.ts +3 -3
- package/dist/cjs/Diviner/AddressHistoryDiviner/AddressHistoryDiviner.d.ts.map +1 -1
- package/dist/cjs/Diviner/AddressHistoryDiviner/XyoRemoteAddressHistoryDiviner.d.ts +1 -1
- package/dist/cjs/Diviner/AddressHistoryDiviner/XyoRemoteAddressHistoryDiviner.d.ts.map +1 -1
- package/dist/cjs/Diviner/ArchiveListApiDiviner/ArchiveListApiDiviner.d.ts +1 -1
- package/dist/cjs/Diviner/ArchiveListApiDiviner/ArchiveListApiDiviner.d.ts.map +1 -1
- package/dist/cjs/Diviner/ArchiveListApiDiviner/ArchiveListApiDivinerConfig.d.ts +3 -3
- package/dist/cjs/Diviner/ArchiveListApiDiviner/ArchiveListApiDivinerConfig.d.ts.map +1 -1
- package/dist/cjs/Diviner/ArchiveListApiDiviner/Payload.d.ts +1 -1
- package/dist/cjs/Diviner/ArchiveListApiDiviner/Payload.d.ts.map +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.ts +3 -3
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.ts.map +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.ts +3 -3
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.ts.map +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.ts +4 -4
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.ts.map +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.ts +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.ts.map +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.ts +3 -3
- package/dist/cjs/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.ts.map +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.ts +2 -2
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.ts.map +1 -1
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/LocationWitness.d.ts +2 -2
- package/dist/cjs/Diviner/LocationDiviner/Witnesses/LocationWitness.d.ts.map +1 -1
- package/dist/cjs/Diviner/SchemaListApiDiviner/Payload.d.ts +1 -1
- package/dist/cjs/Diviner/SchemaListApiDiviner/Payload.d.ts.map +1 -1
- package/dist/cjs/Diviner/SchemaListApiDiviner/SchemaListApiDiviner.d.ts +1 -1
- package/dist/cjs/Diviner/SchemaListApiDiviner/SchemaListApiDiviner.d.ts.map +1 -1
- package/dist/cjs/Diviner/SchemaListApiDiviner/SchemaListApiDivinerConfig.d.ts +2 -2
- package/dist/cjs/Diviner/SchemaListApiDiviner/SchemaListApiDivinerConfig.d.ts.map +1 -1
- package/dist/cjs/Diviner/SchemaStatsApiDiviner/Payload.d.ts +2 -2
- package/dist/cjs/Diviner/SchemaStatsApiDiviner/Payload.d.ts.map +1 -1
- package/dist/cjs/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDiviner.d.ts +1 -1
- package/dist/cjs/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDiviner.d.ts.map +1 -1
- package/dist/cjs/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDivinerConfig.d.ts +2 -2
- package/dist/cjs/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDivinerConfig.d.ts.map +1 -1
- package/dist/cjs/Diviner/XyoRemoteDivinerConfig.d.ts +2 -2
- package/dist/cjs/Diviner/XyoRemoteDivinerConfig.d.ts.map +1 -1
- package/dist/cjs/Simple.d.ts +1 -1
- package/dist/cjs/Simple.d.ts.map +1 -1
- package/dist/cjs/models/Archive.d.ts +3 -3
- package/dist/cjs/models/Archive.d.ts.map +1 -1
- package/dist/docs.json +4283 -4045
- package/dist/esm/Archivist/XyoRemoteArchivist.d.ts +1 -1
- package/dist/esm/Archivist/XyoRemoteArchivist.d.ts.map +1 -1
- package/dist/esm/Archivist/XyoRemoteArchivist.js +13 -6
- package/dist/esm/Archivist/XyoRemoteArchivist.js.map +1 -1
- package/dist/esm/Archivist/XyoRemoteArchivistConfig.d.ts +2 -2
- package/dist/esm/Archivist/XyoRemoteArchivistConfig.d.ts.map +1 -1
- package/dist/esm/Diviner/AddressHistoryDiviner/AddressHistoryDiviner.d.ts +3 -3
- package/dist/esm/Diviner/AddressHistoryDiviner/AddressHistoryDiviner.d.ts.map +1 -1
- package/dist/esm/Diviner/AddressHistoryDiviner/XyoRemoteAddressHistoryDiviner.d.ts +1 -1
- package/dist/esm/Diviner/AddressHistoryDiviner/XyoRemoteAddressHistoryDiviner.d.ts.map +1 -1
- package/dist/esm/Diviner/ArchiveListApiDiviner/ArchiveListApiDiviner.d.ts +1 -1
- package/dist/esm/Diviner/ArchiveListApiDiviner/ArchiveListApiDiviner.d.ts.map +1 -1
- package/dist/esm/Diviner/ArchiveListApiDiviner/ArchiveListApiDivinerConfig.d.ts +3 -3
- package/dist/esm/Diviner/ArchiveListApiDiviner/ArchiveListApiDivinerConfig.d.ts.map +1 -1
- package/dist/esm/Diviner/ArchiveListApiDiviner/Payload.d.ts +1 -1
- package/dist/esm/Diviner/ArchiveListApiDiviner/Payload.d.ts.map +1 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.ts +3 -3
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.ts.map +1 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.ts +3 -3
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.ts.map +1 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.ts +4 -4
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.ts.map +1 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.ts +1 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.ts.map +1 -1
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.ts +3 -3
- package/dist/esm/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.ts.map +1 -1
- package/dist/esm/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.ts +2 -2
- package/dist/esm/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.ts.map +1 -1
- package/dist/esm/Diviner/LocationDiviner/Witnesses/LocationWitness.d.ts +2 -2
- package/dist/esm/Diviner/LocationDiviner/Witnesses/LocationWitness.d.ts.map +1 -1
- package/dist/esm/Diviner/SchemaListApiDiviner/Payload.d.ts +1 -1
- package/dist/esm/Diviner/SchemaListApiDiviner/Payload.d.ts.map +1 -1
- package/dist/esm/Diviner/SchemaListApiDiviner/SchemaListApiDiviner.d.ts +1 -1
- package/dist/esm/Diviner/SchemaListApiDiviner/SchemaListApiDiviner.d.ts.map +1 -1
- package/dist/esm/Diviner/SchemaListApiDiviner/SchemaListApiDivinerConfig.d.ts +2 -2
- package/dist/esm/Diviner/SchemaListApiDiviner/SchemaListApiDivinerConfig.d.ts.map +1 -1
- package/dist/esm/Diviner/SchemaStatsApiDiviner/Payload.d.ts +2 -2
- package/dist/esm/Diviner/SchemaStatsApiDiviner/Payload.d.ts.map +1 -1
- package/dist/esm/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDiviner.d.ts +1 -1
- package/dist/esm/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDiviner.d.ts.map +1 -1
- package/dist/esm/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDivinerConfig.d.ts +2 -2
- package/dist/esm/Diviner/SchemaStatsApiDiviner/SchemaStatsApiDivinerConfig.d.ts.map +1 -1
- package/dist/esm/Diviner/XyoRemoteDivinerConfig.d.ts +2 -2
- package/dist/esm/Diviner/XyoRemoteDivinerConfig.d.ts.map +1 -1
- package/dist/esm/Simple.d.ts +1 -1
- package/dist/esm/Simple.d.ts.map +1 -1
- package/dist/esm/models/Archive.d.ts +3 -3
- package/dist/esm/models/Archive.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/Archivist/XyoRemoteArchivist.spec.ts +37 -17
- package/src/Archivist/XyoRemoteArchivist.ts +13 -6
|
@@ -13,21 +13,41 @@ const configData: XyoApiConfig = {
|
|
|
13
13
|
onSuccess: (response) => response, //console.log(`Success: ${response.statusText} [${response.status}] [${JSON.stringify(response.data)}]`),
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
const payload = {
|
|
17
|
+
salt: `${Math.random() * 10000}`,
|
|
18
|
+
schema: 'network.xyo.id',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('XyoRemoteArchivist', () => {
|
|
22
|
+
let archivist: XyoRemoteArchivist
|
|
23
|
+
let wrapper: XyoArchivistWrapper
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
const api = new XyoArchivistApi(configData)
|
|
27
|
+
archivist = await XyoRemoteArchivist.create({ config: { api, schema: XyoRemoteArchivistConfigSchema } })
|
|
28
|
+
wrapper = new XyoArchivistWrapper(archivist)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('get return payloads', async () => {
|
|
32
|
+
const result = (await archivist.insert([payload])).pop()
|
|
33
|
+
expect(result?.payload_hashes.length).toBe(1)
|
|
34
|
+
const getResult = await archivist.get([new PayloadWrapper(payload).hash])
|
|
35
|
+
expect(getResult.length).toBe(1)
|
|
36
|
+
expect(getResult[0]?.schema).toBe(payload.schema)
|
|
37
|
+
|
|
38
|
+
const findResult = await wrapper.find()
|
|
39
|
+
expect(findResult.length).toBe(20)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('get returns boundwitness', async () => {
|
|
43
|
+
const payload = {
|
|
44
|
+
payload_hashes: ['123456'],
|
|
45
|
+
payload_schemas: ['network.xyo.id'],
|
|
46
|
+
schema: 'network.xyo.boundwitness',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await archivist.insert([payload])
|
|
50
|
+
const getResult = await archivist.get([new PayloadWrapper(payload).hash])
|
|
51
|
+
expect(getResult?.[0].schema).toBe('network.xyo.boundwitness')
|
|
52
|
+
})
|
|
33
53
|
})
|
|
@@ -69,14 +69,21 @@ export class XyoRemoteArchivist extends XyoArchivist<XyoRemoteArchivistConfig> {
|
|
|
69
69
|
await Promise.all(
|
|
70
70
|
hashes.map(async (hash) => {
|
|
71
71
|
try {
|
|
72
|
-
const [payloads,
|
|
73
|
-
if (
|
|
74
|
-
throw new RemoteArchivistError('get',
|
|
72
|
+
const [payloads = [], payloadEnvelope, payloadResponse] = await this.api.archive(this.archive).payload.hash(hash).get('tuple')
|
|
73
|
+
if (payloadResponse?.status >= 400) {
|
|
74
|
+
throw new RemoteArchivistError('get', `Invalid payload status [${payloadResponse.status}]`, 'payloads')
|
|
75
75
|
}
|
|
76
|
-
if (
|
|
77
|
-
throw new RemoteArchivistError('get',
|
|
76
|
+
if (payloadEnvelope?.error?.length) {
|
|
77
|
+
throw new RemoteArchivistError('get', payloadEnvelope.error.shift(), 'payloads')
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
const [blocks = [], blockEnvelope, blockResponse] = await this.api.archive(this.archive).block.hash(hash).get('tuple')
|
|
80
|
+
if (blockResponse?.status >= 400) {
|
|
81
|
+
throw new RemoteArchivistError('get', `Invalid block status [${blockResponse.status}]`, 'payloads')
|
|
82
|
+
}
|
|
83
|
+
if (blockEnvelope?.error?.length) {
|
|
84
|
+
throw new RemoteArchivistError('get', blockEnvelope.error.shift(), 'blocks')
|
|
85
|
+
}
|
|
86
|
+
return payloads?.[0] ?? blocks?.[0]
|
|
80
87
|
} catch (ex) {
|
|
81
88
|
console.error(ex)
|
|
82
89
|
throw ex
|