@xyo-network/api 2.20.40 → 2.20.43
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/Api.d.ts +7 -1
- package/dist/cjs/Archivist/Api.js +8 -0
- package/dist/cjs/Archivist/Api.js.map +1 -1
- package/dist/docs.json +4120 -4005
- package/dist/esm/Archivist/Api.d.ts +7 -1
- package/dist/esm/Archivist/Api.js +11 -0
- package/dist/esm/Archivist/Api.js.map +1 -1
- package/package.json +2 -2
- package/src/Archivist/Api.spec.ts +26 -1
- package/src/Archivist/Api.ts +13 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Huri, XyoDataLike, XyoPayload } from '@xyo-network/core';
|
|
1
|
+
import { Huri, XyoBoundWitness, XyoDataLike, XyoPayload } from '@xyo-network/core';
|
|
2
2
|
import { XyoApiBase } from '../Base';
|
|
3
3
|
import { XyoApiResponseBody, XyoApiResponseTuple } from '../models';
|
|
4
4
|
import { XyoApiSimple } from '../Simple';
|
|
@@ -18,6 +18,12 @@ export declare class XyoArchivistApi extends XyoApiBase {
|
|
|
18
18
|
wallet(address: XyoDataLike): XyoAccountApi;
|
|
19
19
|
account(address: XyoDataLike): XyoAccountApi;
|
|
20
20
|
huri(huri: Huri | string): XyoApiSimple<import("@xyo-network/core").XyoPayloadFull, import("@xyo-network/core").XyoPayloadFull, Record<string, never>, import("../models/Api/Config").XyoApiConfig>;
|
|
21
|
+
/**
|
|
22
|
+
* Issues commands/queries as XyoBoundWitness wrapped XyoPayloads against a Node in the network
|
|
23
|
+
* @param archive Optional, the archive to issue the requests against
|
|
24
|
+
* @returns Confirmation for the request, as a BoundWitness, from the network Node
|
|
25
|
+
*/
|
|
26
|
+
node<TResponse extends XyoBoundWitness, TData extends XyoBoundWitness = TResponse>(archive?: string): XyoApiSimple<TResponse, TData, Record<string, never>, import("../models/Api/Config").XyoApiConfig>;
|
|
21
27
|
/** @deprecated use huri(huri) instead */
|
|
22
28
|
get(huri: Huri | string): Promise<XyoApiResponseBody<XyoPayload>>;
|
|
23
29
|
/** @deprecated use huri(huri) instead */
|
|
@@ -57,6 +57,17 @@ export class XyoArchivistApi extends XyoApiBase {
|
|
|
57
57
|
root: `${this.root}${huriObj.href}/`,
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Issues commands/queries as XyoBoundWitness wrapped XyoPayloads against a Node in the network
|
|
62
|
+
* @param archive Optional, the archive to issue the requests against
|
|
63
|
+
* @returns Confirmation for the request, as a BoundWitness, from the network Node
|
|
64
|
+
*/
|
|
65
|
+
node(archive) {
|
|
66
|
+
return new XyoApiSimple({
|
|
67
|
+
...this.config,
|
|
68
|
+
root: archive ? `${this.root}${archive}/` : this.root,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
60
71
|
/** @deprecated use huri(huri) instead */
|
|
61
72
|
async get(huri, responseType) {
|
|
62
73
|
const huriObj = typeof huri === 'string' ? new Huri(huri) : huri;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../../src/Archivist/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../../src/Archivist/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,eAAe,EAA4C,MAAM,mBAAmB,CAAA;AAEnG,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,OAAO,eAAgB,SAAQ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.43",
|
|
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.43",
|
|
71
71
|
"packageManager": "yarn@3.1.1"
|
|
72
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XyoAccount, XyoBoundWitness, XyoBoundWitnessBuilder } from '@xyo-network/core'
|
|
1
|
+
import { XyoAccount, XyoBoundWitness, XyoBoundWitnessBuilder, XyoPayload, XyoPayloadBuilder } from '@xyo-network/core'
|
|
2
2
|
import { config } from 'dotenv'
|
|
3
3
|
|
|
4
4
|
import { XyoApiConfig, XyoApiError } from '../models'
|
|
@@ -56,6 +56,31 @@ describe('postBoundWitnesses', () => {
|
|
|
56
56
|
})
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
+
describe('node', () => {
|
|
60
|
+
describe('with archive', () => {
|
|
61
|
+
it('calculates the correct path', () => {
|
|
62
|
+
const api = new XyoArchivistApi(configData)
|
|
63
|
+
const path = api.node().config.root
|
|
64
|
+
expect(path).toBe('/')
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
describe('without archive', () => {
|
|
68
|
+
it('calculates the correct path', () => {
|
|
69
|
+
const archive = 'foo'
|
|
70
|
+
const api = new XyoArchivistApi(configData)
|
|
71
|
+
const path = api.node(archive).config.root
|
|
72
|
+
expect(path).toBe(`/${archive}/`)
|
|
73
|
+
})
|
|
74
|
+
it('posts to the root', () => {
|
|
75
|
+
const api = new XyoArchivistApi(configData)
|
|
76
|
+
const p: XyoPayload<{ foo: string }> = new XyoPayloadBuilder<XyoPayload<{ foo: string }>>({ schema: 'foo' }).fields({ foo: 'bar' }).build()
|
|
77
|
+
const bw: XyoBoundWitness = new XyoBoundWitnessBuilder({ inlinePayloads: true }).payload(p).build()
|
|
78
|
+
const path = api.node('foo').post(bw)
|
|
79
|
+
expect(path).toBe('/foo/')
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
59
84
|
describeSkipIfNoToken('XyoArchivistApi', () => {
|
|
60
85
|
describe('get', () => {
|
|
61
86
|
it('returns a new XyoArchivistApi', () => {
|
package/src/Archivist/Api.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Huri, XyoAddressValue, XyoDataLike, XyoPayload } from '@xyo-network/core'
|
|
1
|
+
import { Huri, XyoAddressValue, XyoBoundWitness, XyoDataLike, XyoPayload } from '@xyo-network/core'
|
|
2
2
|
|
|
3
3
|
import { XyoApiBase } from '../Base'
|
|
4
4
|
import { XyoApiResponseBody, XyoApiResponseTuple, XyoApiResponseTupleOrBody, XyoApiResponseType } from '../models'
|
|
@@ -70,6 +70,18 @@ export class XyoArchivistApi extends XyoApiBase {
|
|
|
70
70
|
})
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Issues commands/queries as XyoBoundWitness wrapped XyoPayloads against a Node in the network
|
|
75
|
+
* @param archive Optional, the archive to issue the requests against
|
|
76
|
+
* @returns Confirmation for the request, as a BoundWitness, from the network Node
|
|
77
|
+
*/
|
|
78
|
+
public node<TResponse extends XyoBoundWitness, TData extends XyoBoundWitness = TResponse>(archive?: string) {
|
|
79
|
+
return new XyoApiSimple<TResponse, TData>({
|
|
80
|
+
...this.config,
|
|
81
|
+
root: archive ? `${this.root}${archive}/` : this.root,
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
73
85
|
/** @deprecated use huri(huri) instead */
|
|
74
86
|
public async get(huri: Huri | string): Promise<XyoApiResponseBody<XyoPayload>>
|
|
75
87
|
/** @deprecated use huri(huri) instead */
|