@xyo-network/api 2.20.44 → 2.20.45
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/Node/Api.d.ts +11 -3
- package/dist/cjs/Archivist/Node/Api.js +20 -3
- package/dist/cjs/Archivist/Node/Api.js.map +1 -1
- package/dist/esm/Archivist/Node/Api.d.ts +11 -3
- package/dist/esm/Archivist/Node/Api.js +17 -3
- package/dist/esm/Archivist/Node/Api.js.map +1 -1
- package/package.json +2 -2
- package/src/Archivist/Node/Api.spec.ts +12 -4
- package/src/Archivist/Node/Api.ts +18 -4
|
@@ -12,9 +12,17 @@ export declare class XyoArchivistNodeApi<D extends XyoBoundWitness | XyoBoundWit
|
|
|
12
12
|
/**
|
|
13
13
|
* Issue the supplied queries and wait (non-blocking) for the results
|
|
14
14
|
* @param data The queries to issue
|
|
15
|
-
* @param timeout
|
|
16
|
-
* @param retryInterval
|
|
15
|
+
* @param timeout The max time to wait for the query results
|
|
16
|
+
* @param retryInterval The interval to poll for query results
|
|
17
17
|
* @returns The results for the issued queries
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
performTransaction(data: D, timeout?: number, retryInterval?: number): Promise<import("../../models").XyoApiEnvelope<import("@xyo-network/core").XyoPayloadFull | undefined>[][]>;
|
|
20
|
+
/**
|
|
21
|
+
* Issue the supplied query and wait (non-blocking) for the result
|
|
22
|
+
* @param data The query to issue
|
|
23
|
+
* @param timeout The max time to wait for the query results
|
|
24
|
+
* @param retryInterval The interval to poll for query results
|
|
25
|
+
* @returns The result for the issued query
|
|
26
|
+
*/
|
|
27
|
+
perform<T>(data: T, schema: string, timeout?: number, retryInterval?: number): Promise<import("../../models").XyoApiEnvelope<import("@xyo-network/core").XyoPayloadFull | undefined>>;
|
|
20
28
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.XyoArchivistNodeApi = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const sdk_js_1 = require("@xylabs/sdk-js");
|
|
6
|
+
const core_1 = require("@xyo-network/core");
|
|
6
7
|
const Simple_1 = require("../../Simple");
|
|
7
8
|
const getRequestStatuses = (results) => {
|
|
8
9
|
return results.flatMap((r) => r).map((r) => { var _a; return (_a = r === null || r === void 0 ? void 0 : r[2]) === null || _a === void 0 ? void 0 : _a.status; });
|
|
@@ -25,11 +26,11 @@ class XyoArchivistNodeApi extends Simple_1.XyoApiSimple {
|
|
|
25
26
|
/**
|
|
26
27
|
* Issue the supplied queries and wait (non-blocking) for the results
|
|
27
28
|
* @param data The queries to issue
|
|
28
|
-
* @param timeout
|
|
29
|
-
* @param retryInterval
|
|
29
|
+
* @param timeout The max time to wait for the query results
|
|
30
|
+
* @param retryInterval The interval to poll for query results
|
|
30
31
|
* @returns The results for the issued queries
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
+
performTransaction(data, timeout = 5000, retryInterval = 100) {
|
|
33
34
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
35
|
(0, sdk_js_1.assertEx)(timeout > 0, 'timeout must be positive');
|
|
35
36
|
(0, sdk_js_1.assertEx)(retryInterval > 0, 'retryInterval must be positive');
|
|
@@ -52,6 +53,22 @@ class XyoArchivistNodeApi extends Simple_1.XyoApiSimple {
|
|
|
52
53
|
return results.map((b) => b.map((p) => p[1]));
|
|
53
54
|
});
|
|
54
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Issue the supplied query and wait (non-blocking) for the result
|
|
58
|
+
* @param data The query to issue
|
|
59
|
+
* @param timeout The max time to wait for the query results
|
|
60
|
+
* @param retryInterval The interval to poll for query results
|
|
61
|
+
* @returns The result for the issued query
|
|
62
|
+
*/
|
|
63
|
+
perform(data, schema, timeout = 5000, retryInterval = 100) {
|
|
64
|
+
var _a;
|
|
65
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const payload = new core_1.XyoPayloadBuilder({ schema }).fields(data).build();
|
|
67
|
+
const query = new core_1.XyoBoundWitnessBuilder({ inlinePayloads: true }).payload(payload).build();
|
|
68
|
+
const result = yield this.performTransaction(query, timeout, retryInterval);
|
|
69
|
+
return (_a = result === null || result === void 0 ? void 0 : result[0]) === null || _a === void 0 ? void 0 : _a[0];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
55
72
|
}
|
|
56
73
|
exports.XyoArchivistNodeApi = XyoArchivistNodeApi;
|
|
57
74
|
//# sourceMappingURL=Api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../../../src/Archivist/Node/Api.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;
|
|
1
|
+
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../../../src/Archivist/Node/Api.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;AAChD,4CAA0G;AAG1G,yCAA8D;AAG9D,MAAM,kBAAkB,GAAG,CAAC,OAA4C,EAAY,EAAE;IACpF,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAG,CAAC,CAAC,0CAAE,MAAM,CAAA,EAAA,CAAC,CAAA;AAC7D,CAAC,CAAA;AAED,MAAM,oBAAoB,GAAG,CAAC,OAA4C,EAAW,EAAE;IACrF,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,GAAG,CAAC,CAAA;AACtE,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,OAA4C,EAAW,EAAE;IAClF,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,CA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AAC,CAAA,GAAA,CAAC,CAAC,CAAA;gBAClH,IAAI,oBAAoB,CAAC,OAAO,CAAC;oBAAE,MAAK;gBACxC,+DAA+D;gBAC/D,IAAI,iBAAiB,CAAC,OAAO,CAAC;oBAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;aACjE;YACD,iBAAiB;YACjB,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/C,CAAC;KAAA;IAED;;;;;;OAMG;IACU,OAAO,CAAI,IAAO,EAAE,MAAc,EAAE,OAAO,GAAG,IAAI,EAAE,aAAa,GAAG,GAAG;;;YAClF,MAAM,OAAO,GAAG,IAAI,wBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;YACtE,MAAM,KAAK,GAAG,IAAI,6BAAsB,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAO,CAAA;YAChG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA;YAC3E,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,CAAC,0CAAG,CAAC,CAAC,CAAA;;KACxB;CACF;AAvDD,kDAuDC"}
|
|
@@ -12,9 +12,17 @@ export declare class XyoArchivistNodeApi<D extends XyoBoundWitness | XyoBoundWit
|
|
|
12
12
|
/**
|
|
13
13
|
* Issue the supplied queries and wait (non-blocking) for the results
|
|
14
14
|
* @param data The queries to issue
|
|
15
|
-
* @param timeout
|
|
16
|
-
* @param retryInterval
|
|
15
|
+
* @param timeout The max time to wait for the query results
|
|
16
|
+
* @param retryInterval The interval to poll for query results
|
|
17
17
|
* @returns The results for the issued queries
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
performTransaction(data: D, timeout?: number, retryInterval?: number): Promise<import("../../models").XyoApiEnvelope<import("@xyo-network/core").XyoPayloadFull | undefined>[][]>;
|
|
20
|
+
/**
|
|
21
|
+
* Issue the supplied query and wait (non-blocking) for the result
|
|
22
|
+
* @param data The query to issue
|
|
23
|
+
* @param timeout The max time to wait for the query results
|
|
24
|
+
* @param retryInterval The interval to poll for query results
|
|
25
|
+
* @returns The result for the issued query
|
|
26
|
+
*/
|
|
27
|
+
perform<T>(data: T, schema: string, timeout?: number, retryInterval?: number): Promise<import("../../models").XyoApiEnvelope<import("@xyo-network/core").XyoPayloadFull | undefined>>;
|
|
20
28
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertEx, delay } from '@xylabs/sdk-js';
|
|
2
|
+
import { XyoBoundWitnessBuilder, XyoPayloadBuilder } from '@xyo-network/core';
|
|
2
3
|
import { XyoApiSimple } from '../../Simple';
|
|
3
4
|
const getRequestStatuses = (results) => {
|
|
4
5
|
return results.flatMap((r) => r).map((r) => r?.[2]?.status);
|
|
@@ -24,11 +25,11 @@ export class XyoArchivistNodeApi extends XyoApiSimple {
|
|
|
24
25
|
/**
|
|
25
26
|
* Issue the supplied queries and wait (non-blocking) for the results
|
|
26
27
|
* @param data The queries to issue
|
|
27
|
-
* @param timeout
|
|
28
|
-
* @param retryInterval
|
|
28
|
+
* @param timeout The max time to wait for the query results
|
|
29
|
+
* @param retryInterval The interval to poll for query results
|
|
29
30
|
* @returns The results for the issued queries
|
|
30
31
|
*/
|
|
31
|
-
async
|
|
32
|
+
async performTransaction(data, timeout = 5000, retryInterval = 100) {
|
|
32
33
|
assertEx(timeout > 0, 'timeout must be positive');
|
|
33
34
|
assertEx(retryInterval > 0, 'retryInterval must be positive');
|
|
34
35
|
assertEx(timeout > retryInterval, 'timeout must be greater than retryInterval');
|
|
@@ -49,5 +50,18 @@ export class XyoArchivistNodeApi extends XyoApiSimple {
|
|
|
49
50
|
// Unpack results
|
|
50
51
|
return results.map((b) => b.map((p) => p[1]));
|
|
51
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Issue the supplied query and wait (non-blocking) for the result
|
|
55
|
+
* @param data The query to issue
|
|
56
|
+
* @param timeout The max time to wait for the query results
|
|
57
|
+
* @param retryInterval The interval to poll for query results
|
|
58
|
+
* @returns The result for the issued query
|
|
59
|
+
*/
|
|
60
|
+
async perform(data, schema, timeout = 5000, retryInterval = 100) {
|
|
61
|
+
const payload = new XyoPayloadBuilder({ schema }).fields(data).build();
|
|
62
|
+
const query = new XyoBoundWitnessBuilder({ inlinePayloads: true }).payload(payload).build();
|
|
63
|
+
const result = await this.performTransaction(query, timeout, retryInterval);
|
|
64
|
+
return result?.[0]?.[0];
|
|
65
|
+
}
|
|
52
66
|
}
|
|
53
67
|
//# sourceMappingURL=Api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../../../src/Archivist/Node/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../../../src/Archivist/Node/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAmB,sBAAsB,EAAc,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG1G,OAAO,EAAE,YAAY,EAAqB,MAAM,cAAc,CAAA;AAG9D,MAAM,kBAAkB,GAAG,CAAC,OAA4C,EAAY,EAAE;IACpF,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,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AAC,CAAA;IACzB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xylabs/sdk-js": "^2.5.7",
|
|
13
|
-
"@xyo-network/core": "^2.20.
|
|
13
|
+
"@xyo-network/core": "^2.20.45",
|
|
14
14
|
"axios": "^0.27.2",
|
|
15
15
|
"pako": "^2.0.4",
|
|
16
16
|
"uuid": "^8.3.2"
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
},
|
|
68
68
|
"sideEffects": true,
|
|
69
69
|
"types": "dist/esm/index.d.ts",
|
|
70
|
-
"version": "2.20.
|
|
70
|
+
"version": "2.20.45",
|
|
71
71
|
"packageManager": "yarn@3.1.1"
|
|
72
72
|
}
|
|
@@ -85,12 +85,20 @@ describe('XyoArchivistNodeApi', () => {
|
|
|
85
85
|
})
|
|
86
86
|
})
|
|
87
87
|
describe('perform', () => {
|
|
88
|
+
it('creates and issues the query and returns the result', async () => {
|
|
89
|
+
const api = new XyoArchivistApi(config)
|
|
90
|
+
const response = await api.node().perform({ nonce: v4() }, schema)
|
|
91
|
+
expect(response).toBeDefined()
|
|
92
|
+
expect((response as unknown as XyoPayload).schema).toBe(schema)
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
describe('performTransaction', () => {
|
|
88
96
|
describe('with a single BoundWitness', () => {
|
|
89
97
|
describe('with a single Payload', () => {
|
|
90
98
|
it('issues the query and returns the result', async () => {
|
|
91
99
|
const api = new XyoArchivistApi(config)
|
|
92
100
|
const query = [getQuery()]
|
|
93
|
-
const response = await api.node().
|
|
101
|
+
const response = await api.node().performTransaction(query)
|
|
94
102
|
expect(response).toBeDefined()
|
|
95
103
|
expect(Array.isArray(response)).toBeTruthy()
|
|
96
104
|
expect(validateAllResponseSchemas(response)).toBeTruthy()
|
|
@@ -100,7 +108,7 @@ describe('XyoArchivistNodeApi', () => {
|
|
|
100
108
|
it('issues the query and returns the result', async () => {
|
|
101
109
|
const api = new XyoArchivistApi(config)
|
|
102
110
|
const query = [getQuery(2)]
|
|
103
|
-
const response = await api.node().
|
|
111
|
+
const response = await api.node().performTransaction(query)
|
|
104
112
|
expect(response).toBeDefined()
|
|
105
113
|
expect(Array.isArray(response)).toBeTruthy()
|
|
106
114
|
expect(validateAllResponseSchemas(response)).toBeTruthy()
|
|
@@ -112,7 +120,7 @@ describe('XyoArchivistNodeApi', () => {
|
|
|
112
120
|
it('issues the query and returns the result', async () => {
|
|
113
121
|
const api = new XyoArchivistApi(config)
|
|
114
122
|
const query = [getQuery(), getQuery()]
|
|
115
|
-
const response = await api.node().
|
|
123
|
+
const response = await api.node().performTransaction(query)
|
|
116
124
|
expect(response).toBeDefined()
|
|
117
125
|
expect(Array.isArray(response)).toBeTruthy()
|
|
118
126
|
expect(validateAllResponseSchemas(response)).toBeTruthy()
|
|
@@ -122,7 +130,7 @@ describe('XyoArchivistNodeApi', () => {
|
|
|
122
130
|
it('issues the query and returns the result', async () => {
|
|
123
131
|
const api = new XyoArchivistApi(config)
|
|
124
132
|
const query = [getQuery(2), getQuery(2)]
|
|
125
|
-
const response = await api.node().
|
|
133
|
+
const response = await api.node().performTransaction(query)
|
|
126
134
|
expect(response).toBeDefined()
|
|
127
135
|
expect(Array.isArray(response)).toBeTruthy()
|
|
128
136
|
expect(validateAllResponseSchemas(response)).toBeTruthy()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertEx, delay } from '@xylabs/sdk-js'
|
|
2
|
-
import { XyoBoundWitness, XyoPayload } from '@xyo-network/core'
|
|
2
|
+
import { XyoBoundWitness, XyoBoundWitnessBuilder, XyoPayload, XyoPayloadBuilder } from '@xyo-network/core'
|
|
3
3
|
|
|
4
4
|
import { XyoApiConfig, XyoApiResponseTuple } from '../../models'
|
|
5
5
|
import { XyoApiSimple, XyoApiSimpleQuery } from '../../Simple'
|
|
@@ -36,11 +36,11 @@ export class XyoArchivistNodeApi<
|
|
|
36
36
|
/**
|
|
37
37
|
* Issue the supplied queries and wait (non-blocking) for the results
|
|
38
38
|
* @param data The queries to issue
|
|
39
|
-
* @param timeout
|
|
40
|
-
* @param retryInterval
|
|
39
|
+
* @param timeout The max time to wait for the query results
|
|
40
|
+
* @param retryInterval The interval to poll for query results
|
|
41
41
|
* @returns The results for the issued queries
|
|
42
42
|
*/
|
|
43
|
-
public async
|
|
43
|
+
public async performTransaction(data: D, timeout = 5000, retryInterval = 100) {
|
|
44
44
|
assertEx(timeout > 0, 'timeout must be positive')
|
|
45
45
|
assertEx(retryInterval > 0, 'retryInterval must be positive')
|
|
46
46
|
assertEx(timeout > retryInterval, 'timeout must be greater than retryInterval')
|
|
@@ -58,4 +58,18 @@ export class XyoArchivistNodeApi<
|
|
|
58
58
|
// Unpack results
|
|
59
59
|
return results.map((b) => b.map((p) => p[1]))
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Issue the supplied query and wait (non-blocking) for the result
|
|
64
|
+
* @param data The query to issue
|
|
65
|
+
* @param timeout The max time to wait for the query results
|
|
66
|
+
* @param retryInterval The interval to poll for query results
|
|
67
|
+
* @returns The result for the issued query
|
|
68
|
+
*/
|
|
69
|
+
public async perform<T>(data: T, schema: string, timeout = 5000, retryInterval = 100) {
|
|
70
|
+
const payload = new XyoPayloadBuilder({ schema }).fields(data).build()
|
|
71
|
+
const query = new XyoBoundWitnessBuilder({ inlinePayloads: true }).payload(payload).build() as D
|
|
72
|
+
const result = await this.performTransaction(query, timeout, retryInterval)
|
|
73
|
+
return result?.[0]?.[0]
|
|
74
|
+
}
|
|
61
75
|
}
|