@enbox/api 0.3.1 → 0.4.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 +63 -0
- package/dist/browser.mjs +11 -28
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/advanced.js +1 -1
- package/dist/esm/define-protocol.js +3 -3
- package/dist/esm/did-api.js +1 -1
- package/dist/esm/did-api.js.map +1 -1
- package/dist/esm/dwn-api.js +6 -6
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/dwn-reader-api.js +2 -2
- package/dist/esm/enbox.js +205 -0
- package/dist/esm/enbox.js.map +1 -0
- package/dist/esm/index.js +16 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/protocol.js +2 -2
- package/dist/esm/protocol.js.map +1 -1
- package/dist/esm/record-data.js +79 -5
- package/dist/esm/record-data.js.map +1 -1
- package/dist/esm/record.js +49 -10
- package/dist/esm/record.js.map +1 -1
- package/dist/esm/repository.js +7 -7
- package/dist/esm/repository.js.map +1 -1
- package/dist/esm/typed-enbox.js +583 -0
- package/dist/esm/typed-enbox.js.map +1 -0
- package/dist/esm/typed-live-query.js +1 -1
- package/dist/esm/typed-record.js +370 -46
- package/dist/esm/typed-record.js.map +1 -1
- package/dist/esm/utils.js +25 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/vc-api.js.map +1 -1
- package/dist/types/advanced.d.ts +1 -1
- package/dist/types/define-protocol.d.ts +3 -3
- package/dist/types/did-api.d.ts +4 -4
- package/dist/types/did-api.d.ts.map +1 -1
- package/dist/types/dwn-api.d.ts +12 -7
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/dwn-reader-api.d.ts +2 -2
- package/dist/types/enbox.d.ts +202 -0
- package/dist/types/enbox.d.ts.map +1 -0
- package/dist/types/grant-revocation.d.ts +2 -2
- package/dist/types/grant-revocation.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/live-query.d.ts +2 -2
- package/dist/types/live-query.d.ts.map +1 -1
- package/dist/types/permission-grant.d.ts +2 -2
- package/dist/types/permission-grant.d.ts.map +1 -1
- package/dist/types/permission-request.d.ts +2 -2
- package/dist/types/permission-request.d.ts.map +1 -1
- package/dist/types/protocol-types.d.ts +2 -2
- package/dist/types/protocol.d.ts +7 -7
- package/dist/types/protocol.d.ts.map +1 -1
- package/dist/types/record-data.d.ts +17 -0
- package/dist/types/record-data.d.ts.map +1 -1
- package/dist/types/record.d.ts +24 -10
- package/dist/types/record.d.ts.map +1 -1
- package/dist/types/repository-types.d.ts +19 -11
- package/dist/types/repository-types.d.ts.map +1 -1
- package/dist/types/repository.d.ts +7 -7
- package/dist/types/repository.d.ts.map +1 -1
- package/dist/types/typed-enbox.d.ts +613 -0
- package/dist/types/typed-enbox.d.ts.map +1 -0
- package/dist/types/typed-live-query.d.ts +1 -1
- package/dist/types/typed-record.d.ts +427 -53
- package/dist/types/typed-record.d.ts.map +1 -1
- package/dist/types/utils.d.ts +23 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/vc-api.d.ts +3 -3
- package/dist/types/vc-api.d.ts.map +1 -1
- package/package.json +12 -11
- package/src/advanced.ts +1 -1
- package/src/define-protocol.ts +3 -3
- package/src/did-api.ts +5 -5
- package/src/dwn-api.ts +22 -17
- package/src/dwn-reader-api.ts +2 -2
- package/src/enbox.ts +281 -0
- package/src/grant-revocation.ts +3 -3
- package/src/index.ts +17 -16
- package/src/live-query.ts +2 -2
- package/src/permission-grant.ts +4 -4
- package/src/permission-request.ts +3 -3
- package/src/protocol-types.ts +2 -2
- package/src/protocol.ts +8 -8
- package/src/record-data.ts +86 -5
- package/src/record.ts +54 -13
- package/src/repository-types.ts +19 -7
- package/src/repository.ts +15 -15
- package/src/typed-enbox.ts +1169 -0
- package/src/typed-live-query.ts +1 -1
- package/src/typed-record.ts +431 -53
- package/src/utils.ts +27 -0
- package/src/vc-api.ts +4 -4
- package/dist/esm/typed-web5.js +0 -339
- package/dist/esm/typed-web5.js.map +0 -1
- package/dist/esm/web5.js +0 -410
- package/dist/esm/web5.js.map +0 -1
- package/dist/types/typed-web5.d.ts +0 -221
- package/dist/types/typed-web5.d.ts.map +0 -1
- package/dist/types/web5.d.ts +0 -346
- package/dist/types/web5.d.ts.map +0 -1
- package/src/typed-web5.ts +0 -598
- package/src/web5.ts +0 -754
package/dist/types/record.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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 { DwnDateSort, DwnMessage, DwnMessageDescriptor, DwnPaginationCursor, DwnResponseStatus,
|
|
5
|
+
import type { DwnDateSort, DwnMessage, DwnMessageDescriptor, DwnPaginationCursor, DwnResponseStatus, EnboxAgent, PermissionsApi } from '@enbox/agent';
|
|
6
6
|
import type { RecordDeleteParams, RecordModel, RecordOptions, RecordUpdateParams } from './record-types.js';
|
|
7
7
|
import { DwnInterface } from '@enbox/agent';
|
|
8
8
|
import type { RecordData } from './record-data.js';
|
|
@@ -45,7 +45,7 @@ export declare class Record implements RecordModel {
|
|
|
45
45
|
* Retains awareness of the last 100 records stored/sent for up to 100 target DIDs each.
|
|
46
46
|
*/
|
|
47
47
|
private static _sendCache;
|
|
48
|
-
/** The {@link
|
|
48
|
+
/** The {@link EnboxAgent} instance that handles DWNs requests. */
|
|
49
49
|
private _agent;
|
|
50
50
|
/** The DID of the DWN tenant under which operations are being performed. */
|
|
51
51
|
private _connectedDid;
|
|
@@ -127,9 +127,9 @@ export declare class Record implements RecordModel {
|
|
|
127
127
|
get timestamp(): string;
|
|
128
128
|
/** Record's encryption */
|
|
129
129
|
get encryption(): DwnMessage[DwnInterface.RecordsWrite]['encryption'];
|
|
130
|
-
/** Record's
|
|
130
|
+
/** Record's authorization signature(s). */
|
|
131
131
|
get authorization(): DwnMessage[DwnInterface.RecordsWrite | DwnInterface.RecordsDelete]['authorization'];
|
|
132
|
-
/** Record's
|
|
132
|
+
/** Record's attestation signature. */
|
|
133
133
|
get attestation(): DwnMessage[DwnInterface.RecordsWrite]['attestation'] | undefined;
|
|
134
134
|
/** Role under which the author is writing the record */
|
|
135
135
|
get protocolRole(): string | undefined;
|
|
@@ -142,7 +142,7 @@ export declare class Record implements RecordModel {
|
|
|
142
142
|
* The result is cached and only rebuilt when the record's state changes (via `update()` or `delete()`).
|
|
143
143
|
*/
|
|
144
144
|
get rawMessage(): DwnMessage[DwnInterface.RecordsWrite] | DwnMessage[DwnInterface.RecordsDelete];
|
|
145
|
-
constructor(agent:
|
|
145
|
+
constructor(agent: EnboxAgent, options: RecordOptions, permissionsApi?: PermissionsApi);
|
|
146
146
|
/**
|
|
147
147
|
* Returns the data of the current record.
|
|
148
148
|
* If the record data is not available, it attempts to fetch the data from the DWN.
|
|
@@ -172,15 +172,18 @@ export declare class Record implements RecordModel {
|
|
|
172
172
|
*/
|
|
173
173
|
import(store?: boolean): Promise<DwnResponseStatus>;
|
|
174
174
|
/**
|
|
175
|
-
* Send the current record to a remote DWN by specifying their DID
|
|
175
|
+
* Send the current record to a remote DWN by specifying their DID.
|
|
176
176
|
* If no DID is specified, the target is assumed to be the owner (connectedDID).
|
|
177
177
|
*
|
|
178
|
-
* If
|
|
179
|
-
*
|
|
178
|
+
* If the record is in a deleted state, a `RecordsDelete` message is sent
|
|
179
|
+
* so the remote DWN reflects the deletion.
|
|
180
|
+
*
|
|
181
|
+
* If an initial write is present and the Record class send cache has no
|
|
182
|
+
* awareness of it, the initial write is sent first (vs waiting for the
|
|
183
|
+
* regular DWN sync).
|
|
180
184
|
*
|
|
181
185
|
* @param target - the optional DID to send the record to, if none is set it is sent to the connectedDid
|
|
182
186
|
* @returns the status of the send record request
|
|
183
|
-
* @throws `Error` if the record has already been deleted.
|
|
184
187
|
*
|
|
185
188
|
* @beta
|
|
186
189
|
*/
|
|
@@ -204,8 +207,14 @@ export declare class Record implements RecordModel {
|
|
|
204
207
|
paginationCursor(sort: DwnDateSort): Promise<DwnPaginationCursor | undefined>;
|
|
205
208
|
/**
|
|
206
209
|
* Update the current record on the DWN.
|
|
210
|
+
*
|
|
211
|
+
* On success, **both** a new `Record` instance is returned *and* the
|
|
212
|
+
* current instance (`this`) is mutated in-place to reflect the updated
|
|
213
|
+
* state. This means callers can safely continue using the original
|
|
214
|
+
* reference after an update without capturing the returned record.
|
|
215
|
+
*
|
|
207
216
|
* @param params - Parameters to update the record.
|
|
208
|
-
* @returns the status of the update request
|
|
217
|
+
* @returns the status of the update request and the updated Record
|
|
209
218
|
* @throws `Error` if the record has already been deleted.
|
|
210
219
|
*
|
|
211
220
|
* @beta
|
|
@@ -213,6 +222,11 @@ export declare class Record implements RecordModel {
|
|
|
213
222
|
update({ timestamp, data, encryption, protocolRole, store, ...params }: RecordUpdateParams): Promise<RecordUpdateResult>;
|
|
214
223
|
/**
|
|
215
224
|
* Delete the current record on the DWN.
|
|
225
|
+
*
|
|
226
|
+
* On success, **both** a new `Record` instance is returned *and* the
|
|
227
|
+
* current instance (`this`) is mutated in-place to reflect the deleted
|
|
228
|
+
* state (the {@link Record.deleted | deleted} getter will return `true`).
|
|
229
|
+
*
|
|
216
230
|
* @param params - Parameters to delete the record.
|
|
217
231
|
* @returns the status and a new Record instance reflecting the deleted state
|
|
218
232
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,oBAAoB,EAEpB,mBAAmB,EACnB,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,oBAAoB,EAEpB,mBAAmB,EACnB,iBAAiB,E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AAE,aAAa,EAAE,cAAc,CAAC,EAAE,cAAc;IAiDtF;;;;;;;OAOG;IACH,IAAI,IAAI,IAAI,UAAU,CA+BrB;IAED;;;;;;;OAOG;IACG,KAAK,CAAC,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKtE;;;;;;;;OAQG;IACG,MAAM,CAAC,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI/D;;;;;;;;;;;;;;;OAeG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA+CvD;;;OAGG;IACH,MAAM,IAAI,WAAW;IAyBrB;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAqBlB;;;;;OAKG;IACG,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAInF;;;;;;;;;;;;;OAaG;IACG,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,KAAY,EAAE,GAAG,MAAM,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4GrI;;;;;;;;;OASG;IACG,MAAM,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgF5E;;OAEG;YACW,2BAA2B;IAiCzC;;;OAGG;YACW,aAAa;IAkD3B;;;;;;;;;;;;;;;OAeG;YACW,cAAc;IA2C5B;;;;;;OAMG;YACW,kBAAkB;IAwBhC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAQtC;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;CAKlC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import type { SchemaMap } from './protocol-types.js';
|
|
13
13
|
import type { TypedLiveQuery } from './typed-live-query.js';
|
|
14
14
|
import type { TypedRecord } from './typed-record.js';
|
|
15
|
-
import type { DataForPath, TypedCreateRequest, TypedQueryRequest, TypedSubscribeRequest } from './typed-
|
|
15
|
+
import type { DataForPath, TypedCreateRequest, TypedQueryRequest, TypedSubscribeRequest } from './typed-enbox.js';
|
|
16
16
|
import type { DwnPaginationCursor, DwnResponseStatus } from '@enbox/agent';
|
|
17
17
|
import type { ProtocolDefinition, ProtocolRuleSet } from '@enbox/dwn-sdk-js';
|
|
18
18
|
/**
|
|
@@ -48,43 +48,51 @@ export type SingletonSetOptions<D extends ProtocolDefinition, M extends SchemaMa
|
|
|
48
48
|
};
|
|
49
49
|
/** CRUD API for a root-level collection (unbounded or max > 1). */
|
|
50
50
|
export type CollectionCRUD<D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = {
|
|
51
|
-
create(options: CollectionCreateOptions<D, M, Path>): Promise<DwnResponseStatus & {
|
|
51
|
+
create(options: CollectionCreateOptions<D, M, Path>): Promise<(DwnResponseStatus & {
|
|
52
52
|
record: TypedRecord<DataAt<D, M, Path>>;
|
|
53
|
-
}
|
|
53
|
+
}) | (DwnResponseStatus & {
|
|
54
|
+
record: undefined;
|
|
55
|
+
})>;
|
|
54
56
|
query(options?: TypedQueryRequest): Promise<DwnResponseStatus & {
|
|
55
57
|
records: TypedRecord<DataAt<D, M, Path>>[];
|
|
56
58
|
cursor?: DwnPaginationCursor;
|
|
57
59
|
}>;
|
|
58
|
-
get(recordId: string): Promise<TypedRecord<DataAt<D, M, Path
|
|
60
|
+
get(recordId: string): Promise<TypedRecord<DataAt<D, M, Path>> | undefined>;
|
|
59
61
|
delete(recordId: string): Promise<DwnResponseStatus>;
|
|
60
62
|
subscribe(options?: TypedSubscribeRequest): Promise<TypedLiveQuery<DataAt<D, M, Path>> | undefined>;
|
|
61
63
|
};
|
|
62
64
|
/** CRUD API for a root-level singleton ($recordLimit max: 1). */
|
|
63
65
|
export type SingletonCRUD<D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = {
|
|
64
|
-
set(options: SingletonSetOptions<D, M, Path>): Promise<DwnResponseStatus & {
|
|
66
|
+
set(options: SingletonSetOptions<D, M, Path>): Promise<(DwnResponseStatus & {
|
|
65
67
|
record: TypedRecord<DataAt<D, M, Path>>;
|
|
66
|
-
}
|
|
68
|
+
}) | (DwnResponseStatus & {
|
|
69
|
+
record: undefined;
|
|
70
|
+
})>;
|
|
67
71
|
get(): Promise<TypedRecord<DataAt<D, M, Path>> | undefined>;
|
|
68
72
|
delete(recordId: string): Promise<DwnResponseStatus>;
|
|
69
73
|
};
|
|
70
74
|
/** CRUD API for a nested collection (parent context required). */
|
|
71
75
|
export type NestedCollectionCRUD<D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = {
|
|
72
|
-
create(parentContextId: string, options: CollectionCreateOptions<D, M, Path>): Promise<DwnResponseStatus & {
|
|
76
|
+
create(parentContextId: string, options: CollectionCreateOptions<D, M, Path>): Promise<(DwnResponseStatus & {
|
|
73
77
|
record: TypedRecord<DataAt<D, M, Path>>;
|
|
74
|
-
}
|
|
78
|
+
}) | (DwnResponseStatus & {
|
|
79
|
+
record: undefined;
|
|
80
|
+
})>;
|
|
75
81
|
query(parentContextId: string, options?: TypedQueryRequest): Promise<DwnResponseStatus & {
|
|
76
82
|
records: TypedRecord<DataAt<D, M, Path>>[];
|
|
77
83
|
cursor?: DwnPaginationCursor;
|
|
78
84
|
}>;
|
|
79
|
-
get(recordId: string): Promise<TypedRecord<DataAt<D, M, Path
|
|
85
|
+
get(recordId: string): Promise<TypedRecord<DataAt<D, M, Path>> | undefined>;
|
|
80
86
|
delete(recordId: string): Promise<DwnResponseStatus>;
|
|
81
87
|
subscribe(parentContextId: string, options?: TypedSubscribeRequest): Promise<TypedLiveQuery<DataAt<D, M, Path>> | undefined>;
|
|
82
88
|
};
|
|
83
89
|
/** CRUD API for a nested singleton ($recordLimit max: 1). */
|
|
84
90
|
export type NestedSingletonCRUD<D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = {
|
|
85
|
-
set(parentContextId: string, options: SingletonSetOptions<D, M, Path>): Promise<DwnResponseStatus & {
|
|
91
|
+
set(parentContextId: string, options: SingletonSetOptions<D, M, Path>): Promise<(DwnResponseStatus & {
|
|
86
92
|
record: TypedRecord<DataAt<D, M, Path>>;
|
|
87
|
-
}
|
|
93
|
+
}) | (DwnResponseStatus & {
|
|
94
|
+
record: undefined;
|
|
95
|
+
})>;
|
|
88
96
|
get(parentContextId: string): Promise<TypedRecord<DataAt<D, M, Path>> | undefined>;
|
|
89
97
|
delete(recordId: string): Promise<DwnResponseStatus>;
|
|
90
98
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-types.d.ts","sourceRoot":"","sources":["../../src/repository-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"repository-types.d.ts","sourceRoot":"","sources":["../../src/repository-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAm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AAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAEhC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAM/B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,UAAU,CACpB,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,SAAS,IACjB;KACD,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,GAC/E,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,eAAe,GACrC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1C,KAAK;CACZ,GAAG;IACF,iFAAiF;IACjF,SAAS,CAAC,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC3E,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Protocol-aware repository factory.
|
|
3
3
|
*
|
|
4
|
-
* `repository()` takes a `
|
|
4
|
+
* `repository()` takes a `TypedEnbox` instance and returns a Proxy-backed
|
|
5
5
|
* object whose shape mirrors the protocol's `structure` tree with
|
|
6
6
|
* ergonomic CRUD methods on each node.
|
|
7
7
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
-
* const social = repository(
|
|
15
|
+
* const social = repository(enbox.using(SocialGraphProtocol));
|
|
16
16
|
* await social.configure();
|
|
17
17
|
*
|
|
18
18
|
* // Root collection
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import type { Repository } from './repository-types.js';
|
|
30
30
|
import type { SchemaMap } from './protocol-types.js';
|
|
31
|
-
import type {
|
|
31
|
+
import type { TypedEnbox } from './typed-enbox.js';
|
|
32
32
|
import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
|
|
33
33
|
/**
|
|
34
|
-
* Creates a protocol-aware repository from a `
|
|
34
|
+
* Creates a protocol-aware repository from a `TypedEnbox` instance.
|
|
35
35
|
*
|
|
36
36
|
* The returned object provides domain-specific CRUD methods that mirror
|
|
37
37
|
* the protocol's structure tree:
|
|
@@ -41,12 +41,12 @@ import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
|
|
|
41
41
|
* - Singletons: `repo.profile.set()`, `repo.profile.get()`
|
|
42
42
|
* - Protocol install: `repo.configure()`
|
|
43
43
|
*
|
|
44
|
-
* @param typed - A `
|
|
44
|
+
* @param typed - A `TypedEnbox` instance from `enbox.using(protocol)`.
|
|
45
45
|
* @returns A typed repository object.
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* ```ts
|
|
49
|
-
* const social = repository(
|
|
49
|
+
* const social = repository(enbox.using(SocialGraphProtocol));
|
|
50
50
|
* await social.configure();
|
|
51
51
|
*
|
|
52
52
|
* const rec = await social.friend.create({
|
|
@@ -55,5 +55,5 @@ import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
|
|
|
55
55
|
* const friends = await social.friend.query();
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
export declare function repository<D extends ProtocolDefinition, M extends SchemaMap>(typed:
|
|
58
|
+
export declare function repository<D extends ProtocolDefinition, M extends SchemaMap>(typed: TypedEnbox<D, M>): Repository<D, M>;
|
|
59
59
|
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/repository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/repository.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AAoS7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,SAAS,EACnB,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAqC3C"}
|