@enbox/api 0.1.0 → 0.2.0
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/README.md +140 -159
- package/dist/browser.mjs +23 -13
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/advanced.js +11 -0
- package/dist/esm/advanced.js.map +1 -0
- package/dist/esm/define-protocol.js +3 -3
- package/dist/esm/dwn-api.js +84 -130
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/dwn-reader-api.js +128 -0
- package/dist/esm/dwn-reader-api.js.map +1 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/live-query.js +154 -0
- package/dist/esm/live-query.js.map +1 -0
- package/dist/esm/read-only-record.js +255 -0
- package/dist/esm/read-only-record.js.map +1 -0
- package/dist/esm/record.js +46 -57
- package/dist/esm/record.js.map +1 -1
- package/dist/esm/typed-web5.js +242 -0
- package/dist/esm/typed-web5.js.map +1 -0
- package/dist/esm/web5.js +71 -3
- package/dist/esm/web5.js.map +1 -1
- package/dist/types/advanced.d.ts +12 -0
- package/dist/types/advanced.d.ts.map +1 -0
- package/dist/types/define-protocol.d.ts +3 -3
- package/dist/types/dwn-api.d.ts +20 -104
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/dwn-reader-api.d.ts +138 -0
- package/dist/types/dwn-reader-api.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/live-query.d.ts +148 -0
- package/dist/types/live-query.d.ts.map +1 -0
- package/dist/types/protocol-types.d.ts +2 -2
- package/dist/types/read-only-record.d.ts +133 -0
- package/dist/types/read-only-record.d.ts.map +1 -0
- package/dist/types/record.d.ts +37 -17
- package/dist/types/record.d.ts.map +1 -1
- package/dist/types/{typed-dwn-api.d.ts → typed-web5.d.ts} +75 -76
- package/dist/types/typed-web5.d.ts.map +1 -0
- package/dist/types/web5.d.ts +79 -3
- package/dist/types/web5.d.ts.map +1 -1
- package/package.json +10 -6
- package/src/advanced.ts +29 -0
- package/src/define-protocol.ts +3 -3
- package/src/dwn-api.ts +141 -266
- package/src/dwn-reader-api.ts +255 -0
- package/src/index.ts +4 -2
- package/src/live-query.ts +261 -0
- package/src/protocol-types.ts +2 -2
- package/src/read-only-record.ts +328 -0
- package/src/record.ts +116 -86
- package/src/typed-web5.ts +445 -0
- package/src/web5.ts +104 -5
- package/dist/esm/subscription-util.js +0 -35
- package/dist/esm/subscription-util.js.map +0 -1
- package/dist/esm/typed-dwn-api.js +0 -181
- package/dist/esm/typed-dwn-api.js.map +0 -1
- package/dist/types/subscription-util.d.ts +0 -19
- package/dist/types/subscription-util.d.ts.map +0 -1
- package/dist/types/typed-dwn-api.d.ts.map +0 -1
- package/src/subscription-util.ts +0 -44
- package/src/typed-dwn-api.ts +0 -370
package/dist/esm/web5.js
CHANGED
|
@@ -23,11 +23,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
}
|
|
24
24
|
return t;
|
|
25
25
|
};
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
26
|
+
import { AnonymousDwnApi, WalletConnect, Web5UserAgent } from '@enbox/agent';
|
|
27
|
+
import { DidDht, DidJwk, DidKey, DidResolverCacheMemory, DidWeb, UniversalResolver } from '@enbox/dids';
|
|
28
|
+
import { DwnRegistrar, Web5RpcClient } from '@enbox/dwn-clients';
|
|
28
29
|
import { DidApi } from './did-api.js';
|
|
29
30
|
import { DwnApi } from './dwn-api.js';
|
|
31
|
+
import { DwnReaderApi } from './dwn-reader-api.js';
|
|
30
32
|
import { PermissionGrant } from './permission-grant.js';
|
|
33
|
+
import { TypedWeb5 } from './typed-web5.js';
|
|
31
34
|
import { VcApi } from './vc-api.js';
|
|
32
35
|
/**
|
|
33
36
|
* The main Web5 API interface. It manages the creation of a DID if needed, the connection to the
|
|
@@ -37,9 +40,74 @@ export class Web5 {
|
|
|
37
40
|
constructor({ agent, connectedDid, delegateDid }) {
|
|
38
41
|
this.agent = agent;
|
|
39
42
|
this.did = new DidApi({ agent, connectedDid });
|
|
40
|
-
this.
|
|
43
|
+
this._dwn = new DwnApi({ agent, connectedDid, delegateDid });
|
|
41
44
|
this.vc = new VcApi({ agent, connectedDid });
|
|
42
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns a {@link TypedWeb5} instance scoped to the given protocol.
|
|
48
|
+
*
|
|
49
|
+
* This is the **primary developer interface** for interacting with
|
|
50
|
+
* protocol-backed records. It auto-injects the protocol URI, protocolPath,
|
|
51
|
+
* and schema into every operation, and provides compile-time path
|
|
52
|
+
* autocompletion plus typed data payloads via the schema map.
|
|
53
|
+
*
|
|
54
|
+
* @param protocol - A typed protocol created via `defineProtocol()`.
|
|
55
|
+
* @returns A `TypedWeb5` instance bound to the given protocol.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const social = web5.using(SocialProtocol);
|
|
60
|
+
*
|
|
61
|
+
* await social.configure();
|
|
62
|
+
*
|
|
63
|
+
* const { record } = await social.records.write('friend', {
|
|
64
|
+
* data: { did: 'did:example:alice', alias: 'Alice' },
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* const { records } = await social.records.query('friend');
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
using(protocol) {
|
|
71
|
+
return new TypedWeb5(this._dwn, protocol);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a lightweight, read-only Web5 instance for querying public DWN data.
|
|
75
|
+
*
|
|
76
|
+
* No identity, vault, password, or signing keys are required. The returned
|
|
77
|
+
* API supports querying and reading published records and protocols from any
|
|
78
|
+
* remote DWN, using **unsigned** (anonymous) DWN messages.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Optional configuration overrides.
|
|
81
|
+
* @returns A {@link Web5AnonymousApi} with a read-only `dwn` property.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const { dwn } = Web5.anonymous();
|
|
86
|
+
*
|
|
87
|
+
* const { records } = await dwn.records.query({
|
|
88
|
+
* from: 'did:dht:alice...',
|
|
89
|
+
* filter: { protocol: 'https://social.example/posts', protocolPath: 'post' },
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* for (const record of records) {
|
|
93
|
+
* console.log(record.id, await record.data.text());
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
static anonymous(options) {
|
|
100
|
+
var _a;
|
|
101
|
+
const didResolver = new UniversalResolver({
|
|
102
|
+
didResolvers: (_a = options === null || options === void 0 ? void 0 : options.didResolvers) !== null && _a !== void 0 ? _a : [DidDht, DidJwk, DidKey, DidWeb],
|
|
103
|
+
cache: new DidResolverCacheMemory(),
|
|
104
|
+
});
|
|
105
|
+
const rpcClient = new Web5RpcClient();
|
|
106
|
+
const anonymousDwn = new AnonymousDwnApi({ didResolver, rpcClient });
|
|
107
|
+
return {
|
|
108
|
+
dwn: new DwnReaderApi(anonymousDwn),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
43
111
|
/**
|
|
44
112
|
* Connects to a {@link Web5Agent}. Defaults to creating a local {@link Web5UserAgent} if one
|
|
45
113
|
* isn't provided.
|
package/dist/esm/web5.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web5.js","sourceRoot":"","sources":["../../src/web5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"web5.js","sourceRoot":"","sources":["../../src/web5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,2CAA2C;;;;;;;;;;;;;;;;;;;;;AAkB3C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,EA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EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;gBACvG,gIAAgI;gBAChI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,MAAM,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;oBACxB,MAAM,IAAI,KAAK,CAAC,mDAAmD,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;gBACtF,CAAC;gBAED,MAAM,QAAQ,GAAI,KAAK,CAAC,KAAgE,CAAC,QAAQ,CAAC;gBAClG,IAAI,QAAQ,EAAE,CAAC;oBACb,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACnC,CAAC;YACH,CAAC;YAED,2HAA2H;YAC3H,sHAAsH;YACtH,OAAO,CAAC,GAAG,kBAAkB,CAAC,CAAC;QACjC,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced API surface for power users who need direct access to
|
|
3
|
+
* the underlying {@link DwnApi}.
|
|
4
|
+
*
|
|
5
|
+
* Most applications should use `web5.using(protocol)` instead.
|
|
6
|
+
* Import from `@enbox/api/advanced` to access these exports.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { DwnApi } from './dwn-api.js';
|
|
11
|
+
export type { FetchGrantsRequest, FetchRequestsRequest, ProtocolsConfigureRequest, ProtocolsConfigureResponse, ProtocolsQueryRequest, ProtocolsQueryResponse, RecordsDeleteRequest, RecordsQueryRequest, RecordsQueryResponse, RecordsReadRequest, RecordsReadResponse, RecordsSubscribeRequest, RecordsSubscribeResponse, RecordsWriteRequest, RecordsWriteResponse, } from './dwn-api.js';
|
|
12
|
+
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/advanced.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,cAAc,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Factory function for creating typed protocol definitions.
|
|
3
3
|
*
|
|
4
4
|
* `defineProtocol()` wraps a standard {@link ProtocolDefinition} with
|
|
5
|
-
* compile-time type metadata so that {@link
|
|
5
|
+
* compile-time type metadata so that {@link TypedWeb5} can provide
|
|
6
6
|
* path autocompletion, data-shape inference, and tag type safety.
|
|
7
7
|
*/
|
|
8
8
|
import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
|
|
@@ -14,7 +14,7 @@ import type { SchemaMap, TypedProtocol } from './protocol-types.js';
|
|
|
14
14
|
*
|
|
15
15
|
* The `definition` argument is returned as-is (no cloning). The schema map
|
|
16
16
|
* is a phantom type parameter — it exists only at compile time to thread
|
|
17
|
-
* type information through to `
|
|
17
|
+
* type information through to `TypedWeb5`.
|
|
18
18
|
*
|
|
19
19
|
* @param definition - A standard `ProtocolDefinition` object.
|
|
20
20
|
* @param _schemaMap - A phantom value (e.g. `{} as MySchemaMap`) that carries
|
|
@@ -29,7 +29,7 @@ import type { SchemaMap, TypedProtocol } from './protocol-types.js';
|
|
|
29
29
|
* });
|
|
30
30
|
*
|
|
31
31
|
* // socialGraph.definition is the raw ProtocolDefinition
|
|
32
|
-
* //
|
|
32
|
+
* // TypedWeb5 infers paths like 'friend' | 'friend/message' and
|
|
33
33
|
* // data types from the schema map.
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
package/dist/types/dwn-api.d.ts
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
* NOTE: Added reference types here to avoid a `pnpm` bug during build.
|
|
3
3
|
* https://github.com/enboxorg/enbox/pull/507
|
|
4
4
|
*/
|
|
5
|
-
import type { CreateGrantParams, CreateRequestParams, DwnMessageParams,
|
|
5
|
+
import type { CreateGrantParams, CreateRequestParams, DwnMessageParams, DwnPaginationCursor, DwnResponseStatus, FetchPermissionRequestParams, FetchPermissionsParams, Web5Agent } from '@enbox/agent';
|
|
6
6
|
import { DwnInterface } from '@enbox/agent';
|
|
7
|
-
import
|
|
8
|
-
import type { SchemaMap, TypedProtocol } from './protocol-types.js';
|
|
7
|
+
import { LiveQuery } from './live-query.js';
|
|
9
8
|
import { PermissionGrant } from './permission-grant.js';
|
|
10
9
|
import { PermissionRequest } from './permission-request.js';
|
|
11
10
|
import { Protocol } from './protocol.js';
|
|
12
11
|
import { Record } from './record.js';
|
|
13
|
-
import { TypedDwnApi } from './typed-dwn-api.js';
|
|
14
12
|
/**
|
|
15
13
|
* Represents the request payload for fetching permission requests from a Decentralized Web Node (DWN).
|
|
16
14
|
*
|
|
@@ -37,9 +35,7 @@ export type FetchGrantsRequest = Omit<FetchPermissionsParams, 'author' | 'target
|
|
|
37
35
|
*
|
|
38
36
|
* This request type is used to specify the configuration options for the protocol.
|
|
39
37
|
*/
|
|
40
|
-
export type ProtocolsConfigureRequest = {
|
|
41
|
-
/** Configuration options for the protocol. */
|
|
42
|
-
message: Omit<DwnMessageParams[DwnInterface.ProtocolsConfigure], 'signer'>;
|
|
38
|
+
export type ProtocolsConfigureRequest = Omit<DwnMessageParams[DwnInterface.ProtocolsConfigure], 'signer'> & {
|
|
43
39
|
/** When true, derives and injects $encryption public keys into the protocol definition. */
|
|
44
40
|
encryption?: boolean;
|
|
45
41
|
};
|
|
@@ -63,11 +59,9 @@ export type ProtocolsConfigureResponse = DwnResponseStatus & {
|
|
|
63
59
|
* target the local DWN. If the `from` property is provided, the query will target the specified
|
|
64
60
|
* remote DWN.
|
|
65
61
|
*/
|
|
66
|
-
export type ProtocolsQueryRequest = {
|
|
62
|
+
export type ProtocolsQueryRequest = Omit<DwnMessageParams[DwnInterface.ProtocolsQuery], 'signer'> & {
|
|
67
63
|
/** Optional DID specifying the remote target DWN tenant to be queried. */
|
|
68
64
|
from?: string;
|
|
69
|
-
/** Query filters and options that influence the results returned. */
|
|
70
|
-
message: Omit<DwnMessageParams[DwnInterface.ProtocolsQuery], 'signer'>;
|
|
71
65
|
};
|
|
72
66
|
/**
|
|
73
67
|
* Wraps the response from a protocols query, including the operation status and the list of
|
|
@@ -77,37 +71,6 @@ export type ProtocolsQueryResponse = DwnResponseStatus & {
|
|
|
77
71
|
/** Array of protocols matching the query. */
|
|
78
72
|
protocols: Protocol[];
|
|
79
73
|
};
|
|
80
|
-
/**
|
|
81
|
-
* Type alias for {@link RecordsWriteRequest}
|
|
82
|
-
*/
|
|
83
|
-
export type RecordsCreateRequest = RecordsWriteRequest;
|
|
84
|
-
/**
|
|
85
|
-
* Type alias for {@link RecordsWriteResponse}
|
|
86
|
-
*/
|
|
87
|
-
export type RecordsCreateResponse = RecordsWriteResponse;
|
|
88
|
-
/**
|
|
89
|
-
* Represents a request to create a new record based on an existing one.
|
|
90
|
-
*
|
|
91
|
-
* This request type allows specifying the new data for the record, along with any additional
|
|
92
|
-
* message parameters required for the write operation.
|
|
93
|
-
*/
|
|
94
|
-
export type RecordsCreateFromRequest = {
|
|
95
|
-
/** The DID of the entity authoring the record. */
|
|
96
|
-
author: string;
|
|
97
|
-
/** The new data for the record. */
|
|
98
|
-
data: unknown;
|
|
99
|
-
/** Optional additional parameters for the record write operation */
|
|
100
|
-
message?: Omit<DwnMessageParams[DwnInterface.RecordsWrite], 'signer'>;
|
|
101
|
-
/** The existing record instance that is being used as a basis for the new record. */
|
|
102
|
-
record: Record;
|
|
103
|
-
/**
|
|
104
|
-
* Controls whether the new record should be auto-encrypted.
|
|
105
|
-
*
|
|
106
|
-
* If omitted, auto-detected from the source record: if the source record was
|
|
107
|
-
* encrypted, the new record is automatically encrypted with a fresh DEK.
|
|
108
|
-
*/
|
|
109
|
-
encryption?: boolean;
|
|
110
|
-
};
|
|
111
74
|
/**
|
|
112
75
|
* Defines a request to delete a record from the Decentralized Web Node (DWN).
|
|
113
76
|
*
|
|
@@ -115,13 +78,11 @@ export type RecordsCreateFromRequest = {
|
|
|
115
78
|
* message parameters for the delete operation. If the `from` property is not provided, the record
|
|
116
79
|
* will be deleted from the local DWN.
|
|
117
80
|
*/
|
|
118
|
-
export type RecordsDeleteRequest = {
|
|
81
|
+
export type RecordsDeleteRequest = Omit<DwnMessageParams[DwnInterface.RecordsDelete], 'signer'> & {
|
|
119
82
|
/** Optional DID specifying the remote target DWN tenant the record will be deleted from. */
|
|
120
83
|
from?: string;
|
|
121
|
-
/**
|
|
84
|
+
/** Protocol URI for permission grant resolution. */
|
|
122
85
|
protocol?: string;
|
|
123
|
-
/** The parameters for the delete operation. */
|
|
124
|
-
message: Omit<DwnMessageParams[DwnInterface.RecordsDelete], 'signer'>;
|
|
125
86
|
};
|
|
126
87
|
/**
|
|
127
88
|
* Encapsulates a request to query records from a Decentralized Web Node (DWN).
|
|
@@ -130,13 +91,9 @@ export type RecordsDeleteRequest = {
|
|
|
130
91
|
* parameters, and optionally the target DWN to query from. If the `from` property is not provided,
|
|
131
92
|
* the query will target the local DWN.
|
|
132
93
|
*/
|
|
133
|
-
export type RecordsQueryRequest = {
|
|
94
|
+
export type RecordsQueryRequest = Omit<DwnMessageParams[DwnInterface.RecordsQuery], 'signer'> & {
|
|
134
95
|
/** Optional DID specifying the remote target DWN tenant to query from and return results. */
|
|
135
96
|
from?: string;
|
|
136
|
-
/** Records must be scoped to a specific protocol */
|
|
137
|
-
protocol?: string;
|
|
138
|
-
/** The parameters for the query operation, detailing the criteria for selecting records. */
|
|
139
|
-
message: Omit<DwnMessageParams[DwnInterface.RecordsQuery], 'signer'>;
|
|
140
97
|
/** When true, automatically decrypts encrypted records in the query results. */
|
|
141
98
|
encryption?: boolean;
|
|
142
99
|
};
|
|
@@ -146,7 +103,7 @@ export type RecordsQueryRequest = {
|
|
|
146
103
|
*/
|
|
147
104
|
export type RecordsQueryResponse = DwnResponseStatus & {
|
|
148
105
|
/** Array of records matching the query. */
|
|
149
|
-
records
|
|
106
|
+
records: Record[];
|
|
150
107
|
/** If there are additional results, the messageCid of the last record will be returned as a pagination cursor. */
|
|
151
108
|
cursor?: DwnPaginationCursor;
|
|
152
109
|
};
|
|
@@ -157,13 +114,11 @@ export type RecordsQueryResponse = DwnResponseStatus & {
|
|
|
157
114
|
* additional parameters for the read operation. It's useful for fetching the details of a single
|
|
158
115
|
* record by its identifier or other criteria.
|
|
159
116
|
*/
|
|
160
|
-
export type RecordsReadRequest = {
|
|
117
|
+
export type RecordsReadRequest = Omit<DwnMessageParams[DwnInterface.RecordsRead], 'signer'> & {
|
|
161
118
|
/** Optional DID specifying the remote target DWN tenant the record will be read from. */
|
|
162
119
|
from?: string;
|
|
163
|
-
/**
|
|
120
|
+
/** Protocol URI for permission grant resolution. */
|
|
164
121
|
protocol?: string;
|
|
165
|
-
/** The parameters for the read operation, detailing the criteria for selecting the record. */
|
|
166
|
-
message: Omit<DwnMessageParams[DwnInterface.RecordsRead], 'signer'>;
|
|
167
122
|
/** When true, automatically decrypts the encrypted record data. */
|
|
168
123
|
encryption?: boolean;
|
|
169
124
|
};
|
|
@@ -175,33 +130,21 @@ export type RecordsReadResponse = DwnResponseStatus & {
|
|
|
175
130
|
/** The record retrieved by the read operation. */
|
|
176
131
|
record: Record;
|
|
177
132
|
};
|
|
178
|
-
/** Subscription handler for Records */
|
|
179
|
-
export type RecordsSubscriptionHandler = (record: Record) => void;
|
|
180
133
|
/**
|
|
181
134
|
* Represents a request to subscribe to records from a Decentralized Web Node (DWN).
|
|
182
135
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
136
|
+
* Returns a {@link LiveQuery} that atomically provides an initial snapshot of
|
|
137
|
+
* matching records alongside a real-time stream of deduplicated, semantically-
|
|
138
|
+
* typed change events (`create`, `update`, `delete`).
|
|
185
139
|
*/
|
|
186
|
-
export type RecordsSubscribeRequest = {
|
|
140
|
+
export type RecordsSubscribeRequest = Omit<DwnMessageParams[DwnInterface.RecordsSubscribe], 'signer'> & {
|
|
187
141
|
/** Optional DID specifying the remote target DWN tenant to subscribe from. */
|
|
188
142
|
from?: string;
|
|
189
|
-
/** Records must be scoped to a specific protocol */
|
|
190
|
-
protocol?: string;
|
|
191
|
-
/** The parameters for the subscription operation, detailing the criteria for the subscription filter */
|
|
192
|
-
message: Omit<DwnMessageParams[DwnInterface.RecordsSubscribe], 'signer'>;
|
|
193
|
-
/** The handler to process the subscription events */
|
|
194
|
-
subscriptionHandler: RecordsSubscriptionHandler;
|
|
195
|
-
/** When true, indicates encryption is active (decryption happens on subsequent reads). */
|
|
196
|
-
encryption?: boolean;
|
|
197
143
|
};
|
|
198
|
-
/** Encapsulates the response from a DWN
|
|
144
|
+
/** Encapsulates the response from a DWN RecordsSubscribeRequest. */
|
|
199
145
|
export type RecordsSubscribeResponse = DwnResponseStatus & {
|
|
200
|
-
/**
|
|
201
|
-
|
|
202
|
-
*
|
|
203
|
-
* */
|
|
204
|
-
subscription?: DwnMessageSubscription;
|
|
146
|
+
/** The live query instance, or `undefined` if the request failed. */
|
|
147
|
+
liveQuery?: LiveQuery;
|
|
205
148
|
};
|
|
206
149
|
/**
|
|
207
150
|
* Defines a request to write (create) a record to a Decentralized Web Node (DWN).
|
|
@@ -209,16 +152,10 @@ export type RecordsSubscribeResponse = DwnResponseStatus & {
|
|
|
209
152
|
* This request type allows specifying the data for the new or updated record, along with any
|
|
210
153
|
* additional message parameters required for the write operation, and an optional flag to indicate
|
|
211
154
|
* whether the record should be immediately stored.
|
|
212
|
-
*
|
|
213
|
-
* @param data -
|
|
214
|
-
* @param message - , excluding the signer.
|
|
215
|
-
* @param store -
|
|
216
155
|
*/
|
|
217
|
-
export type RecordsWriteRequest = {
|
|
156
|
+
export type RecordsWriteRequest = Omit<Partial<DwnMessageParams[DwnInterface.RecordsWrite]>, 'signer' | 'data'> & {
|
|
218
157
|
/** The data payload for the record, which can be of any type. */
|
|
219
158
|
data: unknown;
|
|
220
|
-
/** Optional additional parameters for the record write operation. */
|
|
221
|
-
message?: Omit<Partial<DwnMessageParams[DwnInterface.RecordsWrite]>, 'signer'>;
|
|
222
159
|
/**
|
|
223
160
|
* Optional flag indicating whether the record should be immediately stored. If true, the record
|
|
224
161
|
* is persisted in the DWN as part of the write operation. If false, the record is created,
|
|
@@ -245,7 +182,7 @@ export type RecordsWriteResponse = DwnResponseStatus & {
|
|
|
245
182
|
* The `Record` instance representing the record that was successfully written to the
|
|
246
183
|
* DWN as a result of the write operation.
|
|
247
184
|
*/
|
|
248
|
-
record
|
|
185
|
+
record: Record;
|
|
249
186
|
};
|
|
250
187
|
/**
|
|
251
188
|
* Interface to interact with DWN Records and Protocols
|
|
@@ -267,25 +204,6 @@ export declare class DwnApi {
|
|
|
267
204
|
connectedDid: string;
|
|
268
205
|
delegateDid?: string;
|
|
269
206
|
});
|
|
270
|
-
/**
|
|
271
|
-
* Returns a {@link TypedDwnApi} scoped to the given typed protocol.
|
|
272
|
-
*
|
|
273
|
-
* The returned API provides path autocompletion, typed data payloads,
|
|
274
|
-
* and automatically injects the protocol URI and protocolPath into every
|
|
275
|
-
* DWN operation.
|
|
276
|
-
*
|
|
277
|
-
* @param protocol - A typed protocol created via `defineProtocol()`.
|
|
278
|
-
* @returns A `TypedDwnApi` instance bound to the given protocol.
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* ```ts
|
|
282
|
-
* const social = dwn.using(SocialGraphProtocol);
|
|
283
|
-
* const { record } = await social.write('friend', {
|
|
284
|
-
* data: { did: 'did:example:alice' },
|
|
285
|
-
* });
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
|
-
using<D extends ProtocolDefinition, M extends SchemaMap>(protocol: TypedProtocol<D, M>): TypedDwnApi<D, M>;
|
|
289
207
|
/**
|
|
290
208
|
* API to interact with Grants
|
|
291
209
|
*
|
|
@@ -311,11 +229,9 @@ export declare class DwnApi {
|
|
|
311
229
|
query: (request: ProtocolsQueryRequest) => Promise<ProtocolsQueryResponse>;
|
|
312
230
|
};
|
|
313
231
|
/**
|
|
314
|
-
* API to interact with DWN records (e.g., `dwn.records.
|
|
232
|
+
* API to interact with DWN records (e.g., `dwn.records.write()`).
|
|
315
233
|
*/
|
|
316
234
|
get records(): {
|
|
317
|
-
create: (request: RecordsCreateRequest) => Promise<RecordsCreateResponse>;
|
|
318
|
-
createFrom: (request: RecordsCreateFromRequest) => Promise<RecordsWriteResponse>;
|
|
319
235
|
delete: (request: RecordsDeleteRequest) => Promise<DwnResponseStatus>;
|
|
320
236
|
query: (request: RecordsQueryRequest) => Promise<RecordsQueryResponse>;
|
|
321
237
|
read: (request: RecordsReadRequest) => Promise<RecordsReadResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-api.d.ts","sourceRoot":"","sources":["../../src/dwn-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"dwn-api.d.ts","sourceRoot":"","sources":["../../src/dwn-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,gBAAgB,EAChB,mBAAmB,EAEnB,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EAEtB,SAAS,EAAE,MAAM,cAAc,CAAC;AAMlC,OAAO,EAAE,YAAY,EAAmB,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yB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AChF,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;KACzE,CA+FJ;IAED;;OAEG;IACH,IAAI,SAAS,IAAI;QACb,SAAS,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACvF,KAAK,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;KAC1E,CAsGJ;IAED;;OAEG;IACH,IAAI,OAAO,IAAI;QACX,MAAM,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACtE,KAAK,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACvE,IAAI,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACpE,SAAS,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACnF,KAAK,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;KACtE,CA6ZJ;CACF"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: Added reference types here to avoid a `pnpm` bug during build.
|
|
3
|
+
* https://github.com/enboxorg/enbox/pull/507
|
|
4
|
+
*/
|
|
5
|
+
import type { AnonymousDwnApi, DwnPaginationCursor, DwnResponseStatus } from '@enbox/agent';
|
|
6
|
+
import type { DateSort, Pagination, ProtocolDefinition, ProtocolsQueryFilter, RecordsFilter } from '@enbox/dwn-sdk-js';
|
|
7
|
+
import { ReadOnlyRecord } from './read-only-record.js';
|
|
8
|
+
/**
|
|
9
|
+
* Request to query public records from a remote DWN.
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export type ReaderRecordsQueryRequest = {
|
|
14
|
+
/** The DID of the remote DWN to query (required — reader is remote-only). */
|
|
15
|
+
from: string;
|
|
16
|
+
/** Filter criteria for the query. */
|
|
17
|
+
filter: RecordsFilter;
|
|
18
|
+
/** Sort order for results. */
|
|
19
|
+
dateSort?: DateSort;
|
|
20
|
+
/** Pagination options. */
|
|
21
|
+
pagination?: Pagination;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Response from a reader records query.
|
|
25
|
+
*
|
|
26
|
+
* @beta
|
|
27
|
+
*/
|
|
28
|
+
export type ReaderRecordsQueryResponse = DwnResponseStatus & {
|
|
29
|
+
/** Array of read-only records matching the query. */
|
|
30
|
+
records: ReadOnlyRecord[];
|
|
31
|
+
/** Pagination cursor for fetching the next page. */
|
|
32
|
+
cursor?: DwnPaginationCursor;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Request to read a specific public record from a remote DWN.
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export type ReaderRecordsReadRequest = {
|
|
40
|
+
/** The DID of the remote DWN to read from (required — reader is remote-only). */
|
|
41
|
+
from: string;
|
|
42
|
+
/** Filter to identify the record (typically `{ recordId: '...' }`). */
|
|
43
|
+
filter: RecordsFilter;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Response from a reader records read.
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
export type ReaderRecordsReadResponse = DwnResponseStatus & {
|
|
51
|
+
/** The read-only record, if found. */
|
|
52
|
+
record?: ReadOnlyRecord;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Request to count public records on a remote DWN.
|
|
56
|
+
*
|
|
57
|
+
* @beta
|
|
58
|
+
*/
|
|
59
|
+
export type ReaderRecordsCountRequest = {
|
|
60
|
+
/** The DID of the remote DWN to count records in (required). */
|
|
61
|
+
from: string;
|
|
62
|
+
/** Filter criteria for counting. */
|
|
63
|
+
filter: RecordsFilter;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Response from a reader records count.
|
|
67
|
+
*
|
|
68
|
+
* @beta
|
|
69
|
+
*/
|
|
70
|
+
export type ReaderRecordsCountResponse = DwnResponseStatus & {
|
|
71
|
+
/** The number of matching public records. */
|
|
72
|
+
count?: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Request to query published protocols from a remote DWN.
|
|
76
|
+
*
|
|
77
|
+
* @beta
|
|
78
|
+
*/
|
|
79
|
+
export type ReaderProtocolsQueryRequest = {
|
|
80
|
+
/** The DID of the remote DWN to query protocols from (required). */
|
|
81
|
+
from: string;
|
|
82
|
+
/** Optional filter for the protocol query. */
|
|
83
|
+
filter?: ProtocolsQueryFilter;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Response from a reader protocols query.
|
|
87
|
+
*
|
|
88
|
+
* @beta
|
|
89
|
+
*/
|
|
90
|
+
export type ReaderProtocolsQueryResponse = DwnResponseStatus & {
|
|
91
|
+
/** Array of published protocol definitions. */
|
|
92
|
+
protocols: ProtocolDefinition[];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* A read-only API for querying public data on remote DWNs without any identity or signing keys.
|
|
96
|
+
*
|
|
97
|
+
* This class mirrors the shape of {@link DwnApi}'s `records` and `protocols`
|
|
98
|
+
* namespaces, but restricts to read-path operations and requires a `from` DID
|
|
99
|
+
* on every call (remote-only). All messages are unsigned, so only published
|
|
100
|
+
* records and protocols are accessible.
|
|
101
|
+
*
|
|
102
|
+
* Obtain an instance via {@link Web5.anonymous | `Web5.anonymous()`}.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* const { dwn } = Web5.anonymous();
|
|
107
|
+
*
|
|
108
|
+
* const { records } = await dwn.records.query({
|
|
109
|
+
* from: 'did:dht:alice...',
|
|
110
|
+
* filter: { protocol: 'https://social.example/posts', protocolPath: 'post' },
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* for (const record of records) {
|
|
114
|
+
* console.log(record.id, await record.data.text());
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @beta
|
|
119
|
+
*/
|
|
120
|
+
export declare class DwnReaderApi {
|
|
121
|
+
private _anonymousDwn;
|
|
122
|
+
constructor(anonymousDwn: AnonymousDwnApi);
|
|
123
|
+
/**
|
|
124
|
+
* API to interact with public DWN records (query, read, count).
|
|
125
|
+
*/
|
|
126
|
+
get records(): {
|
|
127
|
+
query: (request: ReaderRecordsQueryRequest) => Promise<ReaderRecordsQueryResponse>;
|
|
128
|
+
read: (request: ReaderRecordsReadRequest) => Promise<ReaderRecordsReadResponse>;
|
|
129
|
+
count: (request: ReaderRecordsCountRequest) => Promise<ReaderRecordsCountResponse>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* API to query published protocol definitions from remote DWNs.
|
|
133
|
+
*/
|
|
134
|
+
get protocols(): {
|
|
135
|
+
query: (request: ReaderProtocolsQueryRequest) => Promise<ReaderProtocolsQueryResponse>;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=dwn-reader-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dwn-reader-api.d.ts","sourceRoot":"","sources":["../../src/dwn-reader-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,6EAA6E;IAC7E,I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AyBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,aAAa,CAAkB;gBAE3B,YAAY,EAAE,eAAe;IAIzC;;OAEG;IACH,IAAI,OAAO,IAAI;QACb,KAAK,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACnF,IAAI,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAChF,KAAK,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;KAClF,CAiEF;IAED;;OAEG;IACH,IAAI,SAAS,IAAI;QACf,KAAK,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,4BAA4B,CAAC,CAAC;KACtF,CAkBF;CACF"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -22,14 +22,16 @@
|
|
|
22
22
|
*/
|
|
23
23
|
export * from './define-protocol.js';
|
|
24
24
|
export * from './did-api.js';
|
|
25
|
-
export * from './dwn-api.js';
|
|
25
|
+
export * from './dwn-reader-api.js';
|
|
26
26
|
export * from './grant-revocation.js';
|
|
27
|
+
export * from './live-query.js';
|
|
27
28
|
export * from './permission-grant.js';
|
|
28
29
|
export * from './permission-request.js';
|
|
29
30
|
export * from './protocol.js';
|
|
30
31
|
export * from './protocol-types.js';
|
|
32
|
+
export * from './read-only-record.js';
|
|
31
33
|
export * from './record.js';
|
|
32
|
-
export * from './typed-
|
|
34
|
+
export * from './typed-web5.js';
|
|
33
35
|
export * from './vc-api.js';
|
|
34
36
|
export * from './web5.js';
|
|
35
37
|
import * as utils from './utils.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,CAAC"}
|