@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.
Files changed (63) hide show
  1. package/README.md +140 -159
  2. package/dist/browser.mjs +23 -13
  3. package/dist/browser.mjs.map +4 -4
  4. package/dist/esm/advanced.js +11 -0
  5. package/dist/esm/advanced.js.map +1 -0
  6. package/dist/esm/define-protocol.js +3 -3
  7. package/dist/esm/dwn-api.js +84 -130
  8. package/dist/esm/dwn-api.js.map +1 -1
  9. package/dist/esm/dwn-reader-api.js +128 -0
  10. package/dist/esm/dwn-reader-api.js.map +1 -0
  11. package/dist/esm/index.js +4 -2
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/live-query.js +154 -0
  14. package/dist/esm/live-query.js.map +1 -0
  15. package/dist/esm/read-only-record.js +255 -0
  16. package/dist/esm/read-only-record.js.map +1 -0
  17. package/dist/esm/record.js +46 -57
  18. package/dist/esm/record.js.map +1 -1
  19. package/dist/esm/typed-web5.js +242 -0
  20. package/dist/esm/typed-web5.js.map +1 -0
  21. package/dist/esm/web5.js +71 -3
  22. package/dist/esm/web5.js.map +1 -1
  23. package/dist/types/advanced.d.ts +12 -0
  24. package/dist/types/advanced.d.ts.map +1 -0
  25. package/dist/types/define-protocol.d.ts +3 -3
  26. package/dist/types/dwn-api.d.ts +20 -104
  27. package/dist/types/dwn-api.d.ts.map +1 -1
  28. package/dist/types/dwn-reader-api.d.ts +138 -0
  29. package/dist/types/dwn-reader-api.d.ts.map +1 -0
  30. package/dist/types/index.d.ts +4 -2
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/live-query.d.ts +148 -0
  33. package/dist/types/live-query.d.ts.map +1 -0
  34. package/dist/types/protocol-types.d.ts +2 -2
  35. package/dist/types/read-only-record.d.ts +133 -0
  36. package/dist/types/read-only-record.d.ts.map +1 -0
  37. package/dist/types/record.d.ts +37 -17
  38. package/dist/types/record.d.ts.map +1 -1
  39. package/dist/types/{typed-dwn-api.d.ts → typed-web5.d.ts} +75 -76
  40. package/dist/types/typed-web5.d.ts.map +1 -0
  41. package/dist/types/web5.d.ts +79 -3
  42. package/dist/types/web5.d.ts.map +1 -1
  43. package/package.json +10 -6
  44. package/src/advanced.ts +29 -0
  45. package/src/define-protocol.ts +3 -3
  46. package/src/dwn-api.ts +141 -266
  47. package/src/dwn-reader-api.ts +255 -0
  48. package/src/index.ts +4 -2
  49. package/src/live-query.ts +261 -0
  50. package/src/protocol-types.ts +2 -2
  51. package/src/read-only-record.ts +328 -0
  52. package/src/record.ts +116 -86
  53. package/src/typed-web5.ts +445 -0
  54. package/src/web5.ts +104 -5
  55. package/dist/esm/subscription-util.js +0 -35
  56. package/dist/esm/subscription-util.js.map +0 -1
  57. package/dist/esm/typed-dwn-api.js +0 -181
  58. package/dist/esm/typed-dwn-api.js.map +0 -1
  59. package/dist/types/subscription-util.d.ts +0 -19
  60. package/dist/types/subscription-util.d.ts.map +0 -1
  61. package/dist/types/typed-dwn-api.d.ts.map +0 -1
  62. package/src/subscription-util.ts +0 -44
  63. package/src/typed-dwn-api.ts +0 -370
@@ -1,23 +1,43 @@
1
1
  /**
2
- * A type-safe wrapper around {@link DwnApi} scoped to a single protocol.
2
+ * A protocol-scoped API returned by {@link Web5.using}.
3
3
  *
4
- * `TypedDwnApi` is created via `dwn.using(typedProtocol)` and provides
5
- * autocompletion for protocol paths, typed data payloads, and tag shapes.
4
+ * `TypedWeb5` is the **primary developer interface** for interacting with
5
+ * protocol-backed records. It auto-injects the protocol URI, protocolPath,
6
+ * and schema into every operation, and provides compile-time path
7
+ * autocompletion plus typed data payloads via the schema map.
6
8
  *
7
- * Every method delegates to the corresponding `dwn.records.*` method,
8
- * injecting the protocol URI, protocolPath, and schema automatically.
9
+ * @example
10
+ * ```ts
11
+ * const social = web5.using(SocialProtocol);
12
+ *
13
+ * // Install the protocol
14
+ * await social.configure();
15
+ *
16
+ * // Write — path and data type are checked at compile time
17
+ * const { record } = await social.records.write('thread', {
18
+ * data: { title: 'Hello World', body: '...' },
19
+ * });
20
+ *
21
+ * // Query — protocol and protocolPath are auto-injected
22
+ * const { records } = await social.records.query('thread');
23
+ *
24
+ * // Subscribe — real-time changes via LiveQuery
25
+ * const { liveQuery } = await social.records.subscribe('thread/reply');
26
+ * liveQuery.on('create', (record) => { ... });
27
+ * ```
9
28
  */
29
+ import type { DwnApi } from './dwn-api.js';
30
+ import type { LiveQuery } from './live-query.js';
10
31
  import type { Protocol } from './protocol.js';
11
32
  import type { Record } from './record.js';
12
33
  import type { DateSort, ProtocolDefinition, ProtocolType, RecordsFilter } from '@enbox/dwn-sdk-js';
13
- import type { DwnApi, RecordsSubscriptionHandler } from './dwn-api.js';
14
- import type { DwnMessageSubscription, DwnPaginationCursor, DwnResponseStatus } from '@enbox/agent';
34
+ import type { DwnPaginationCursor, DwnResponseStatus } from '@enbox/agent';
15
35
  import type { ProtocolPaths, SchemaMap, TypedProtocol, TypeNameAtPath } from './protocol-types.js';
16
36
  /**
17
37
  * Resolves the TypeScript data type for a given protocol path.
18
38
  *
19
39
  * If the schema map contains a mapping for the type name at the given path,
20
- * that type is returned. Otherwise falls back to `unknown`.
40
+ * that type is returned. Otherwise falls back to `unknown`.
21
41
  */
22
42
  type DataForPath<_D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = TypeNameAtPath<Path> extends keyof M ? M[TypeNameAtPath<Path>] : unknown;
23
43
  /**
@@ -30,34 +50,31 @@ type ProtocolTypeForPath<D extends ProtocolDefinition, Path extends string> = Ty
30
50
  type DataFormatForPath<D extends ProtocolDefinition, Path extends string> = ProtocolTypeForPath<D, Path> extends {
31
51
  dataFormats: infer F;
32
52
  } ? F extends readonly string[] ? F[number] : string : string;
33
- /** Options for `TypedDwnApi.write()`. */
53
+ /** Options for {@link TypedWeb5} `records.write()`. */
34
54
  export type TypedWriteRequest<D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = {
35
55
  /** The data payload. Type-checked against the schema map. */
36
56
  data: DataForPath<D, M, Path>;
37
- /** Additional message parameters (protocolPath and protocol are injected). */
38
- message?: {
39
- parentContextId?: string;
40
- published?: boolean;
41
- datePublished?: string;
42
- recipient?: string;
43
- protocolRole?: string;
44
- dataFormat?: DataFormatForPath<D, Path>;
45
- tags?: globalThis.Record<string, string | number | boolean | string[] | number[]>;
46
- };
57
+ parentContextId?: string;
58
+ published?: boolean;
59
+ datePublished?: string;
60
+ recipient?: string;
61
+ protocolRole?: string;
62
+ dataFormat?: DataFormatForPath<D, Path>;
63
+ tags?: globalThis.Record<string, string | number | boolean | string[] | number[]>;
47
64
  /** Whether to persist immediately (defaults to `true`). */
48
65
  store?: boolean;
49
66
  /** Whether to auto-encrypt (follows protocol definition if omitted). */
50
67
  encryption?: boolean;
51
68
  };
52
- /** Response from `TypedDwnApi.write()`. */
69
+ /** Response from {@link TypedWeb5} `records.write()`. */
53
70
  export type TypedWriteResponse = DwnResponseStatus & {
54
- record?: Record;
71
+ record: Record;
55
72
  };
56
- /** Filter options for `TypedDwnApi.query()`. */
73
+ /** Filter options for {@link TypedWeb5} `records.query()`. */
57
74
  export type TypedQueryFilter = Omit<RecordsFilter, 'protocol' | 'protocolPath' | 'schema'> & {
58
75
  tags?: globalThis.Record<string, string | number | boolean | (string | number)[]>;
59
76
  };
60
- /** Options for `TypedDwnApi.query()`. */
77
+ /** Options for {@link TypedWeb5} `records.query()`. */
61
78
  export type TypedQueryRequest = {
62
79
  /** Optional remote DWN DID to query from. */
63
80
  from?: string;
@@ -72,12 +89,12 @@ export type TypedQueryRequest = {
72
89
  /** When true, automatically decrypts encrypted records. */
73
90
  encryption?: boolean;
74
91
  };
75
- /** Response from `TypedDwnApi.query()`. */
92
+ /** Response from {@link TypedWeb5} `records.query()`. */
76
93
  export type TypedQueryResponse = DwnResponseStatus & {
77
- records?: Record[];
94
+ records: Record[];
78
95
  cursor?: DwnPaginationCursor;
79
96
  };
80
- /** Options for `TypedDwnApi.read()`. */
97
+ /** Options for {@link TypedWeb5} `records.read()`. */
81
98
  export type TypedReadRequest = {
82
99
  /** Optional remote DWN DID to read from. */
83
100
  from?: string;
@@ -86,54 +103,52 @@ export type TypedReadRequest = {
86
103
  /** When true, automatically decrypts the record. */
87
104
  encryption?: boolean;
88
105
  };
89
- /** Response from `TypedDwnApi.read()`. */
106
+ /** Response from {@link TypedWeb5} `records.read()`. */
90
107
  export type TypedReadResponse = DwnResponseStatus & {
91
108
  record: Record;
92
109
  };
93
- /** Options for `TypedDwnApi.delete()`. */
110
+ /** Options for {@link TypedWeb5} `records.delete()`. */
94
111
  export type TypedDeleteRequest = {
95
112
  /** Optional remote DWN DID to delete from. */
96
113
  from?: string;
97
114
  /** The `recordId` of the record to delete. */
98
115
  recordId: string;
99
116
  };
100
- /** Options for `TypedDwnApi.subscribe()`. */
117
+ /** Options for {@link TypedWeb5} `records.subscribe()`. */
101
118
  export type TypedSubscribeRequest = {
102
119
  /** Optional remote DWN DID to subscribe to. */
103
120
  from?: string;
104
121
  /** Subscription filter (protocol, protocolPath, schema are injected). */
105
122
  filter?: TypedQueryFilter;
106
123
  protocolRole?: string;
107
- subscriptionHandler: RecordsSubscriptionHandler;
108
- /** When true, indicates encryption is active. */
109
- encryption?: boolean;
110
124
  };
111
- /** Response from `TypedDwnApi.subscribe()`. */
125
+ /** Response from {@link TypedWeb5} `records.subscribe()`. */
112
126
  export type TypedSubscribeResponse = DwnResponseStatus & {
113
- subscription?: DwnMessageSubscription;
127
+ /** The live query instance, or `undefined` if the request failed. */
128
+ liveQuery?: LiveQuery;
114
129
  };
115
130
  /**
116
- * A protocol-scoped wrapper around `DwnApi` that automatically injects
117
- * the `protocol` URI, `protocolPath`, and `schema` into every DWN operation.
131
+ * A protocol-scoped API that auto-injects `protocol`, `protocolPath`, and
132
+ * `schema` into every DWN operation.
118
133
  *
119
- * Obtain an instance via `dwn.using(typedProtocol)`.
134
+ * Obtain an instance via `web5.using(typedProtocol)`.
120
135
  *
121
136
  * @example
122
137
  * ```ts
123
- * const social = dwn.using(SocialGraphProtocol);
138
+ * const social = web5.using(SocialProtocol);
124
139
  *
125
- * // Write — path and data type are checked at compile time
126
- * const { record } = await social.write('friend', {
140
+ * await social.configure();
141
+ *
142
+ * const { record } = await social.records.write('friend', {
127
143
  * data: { did: 'did:example:alice', alias: 'Alice' },
128
144
  * });
129
145
  *
130
- * // Query protocol and protocolPath are auto-injected
131
- * const { records } = await social.query('friend', {
146
+ * const { records } = await social.records.query('friend', {
132
147
  * filter: { tags: { did: 'did:example:alice' } },
133
148
  * });
134
149
  * ```
135
150
  */
136
- export declare class TypedDwnApi<D extends ProtocolDefinition = ProtocolDefinition, M extends SchemaMap = SchemaMap> {
151
+ export declare class TypedWeb5<D extends ProtocolDefinition = ProtocolDefinition, M extends SchemaMap = SchemaMap> {
137
152
  private _dwn;
138
153
  private _definition;
139
154
  constructor(dwn: DwnApi, protocol: TypedProtocol<D, M>);
@@ -144,6 +159,11 @@ export declare class TypedDwnApi<D extends ProtocolDefinition = ProtocolDefiniti
144
159
  /**
145
160
  * Configures (installs) this protocol on the local DWN.
146
161
  *
162
+ * If the protocol is already installed with an identical definition,
163
+ * this is a no-op and returns the existing protocol. If the definition
164
+ * has changed (e.g. new types, modified structure), the protocol is
165
+ * re-configured with the updated definition.
166
+ *
147
167
  * @param options - Optional overrides like `encryption`.
148
168
  */
149
169
  configure(options?: {
@@ -152,40 +172,19 @@ export declare class TypedDwnApi<D extends ProtocolDefinition = ProtocolDefiniti
152
172
  protocol?: Protocol;
153
173
  }>;
154
174
  /**
155
- * Write a record at the given protocol path.
156
- *
157
- * @param path - The protocol path (e.g. `'friend'`, `'group/member'`).
158
- * @param request - Write options including typed `data`.
159
- */
160
- write<Path extends ProtocolPaths<D> & string>(path: Path, request: TypedWriteRequest<D, M, Path>): Promise<TypedWriteResponse>;
161
- /**
162
- * Query records at the given protocol path.
163
- *
164
- * @param path - The protocol path to query.
165
- * @param request - Query options including optional filter, sort, and pagination.
166
- */
167
- query<Path extends ProtocolPaths<D> & string>(path: Path, request?: TypedQueryRequest): Promise<TypedQueryResponse>;
168
- /**
169
- * Read a single record at the given protocol path.
175
+ * Protocol-scoped record operations.
170
176
  *
171
- * @param path - The protocol path to read from.
172
- * @param request - Read options including a filter to identify the record.
177
+ * Every method auto-injects the protocol URI, protocolPath, and schema
178
+ * from the protocol definition. Path parameters provide compile-time
179
+ * autocompletion via `ProtocolPaths<D>`.
173
180
  */
174
- read<Path extends ProtocolPaths<D> & string>(path: Path, request: TypedReadRequest): Promise<TypedReadResponse>;
175
- /**
176
- * Delete a record at the given protocol path.
177
- *
178
- * @param path - The protocol path (used for permission scoping).
179
- * @param request - Delete options including the `recordId`.
180
- */
181
- delete<Path extends ProtocolPaths<D> & string>(_path: Path, request: TypedDeleteRequest): Promise<DwnResponseStatus>;
182
- /**
183
- * Subscribe to records at the given protocol path.
184
- *
185
- * @param path - The protocol path to subscribe to.
186
- * @param request - Subscribe options including the subscription handler.
187
- */
188
- subscribe<Path extends ProtocolPaths<D> & string>(path: Path, request: TypedSubscribeRequest): Promise<TypedSubscribeResponse>;
181
+ get records(): {
182
+ write: <Path extends ProtocolPaths<D> & string>(path: Path, request: TypedWriteRequest<D, M, Path>) => Promise<TypedWriteResponse>;
183
+ query: <Path extends ProtocolPaths<D> & string>(path: Path, request?: TypedQueryRequest) => Promise<TypedQueryResponse>;
184
+ read: <Path extends ProtocolPaths<D> & string>(path: Path, request: TypedReadRequest) => Promise<TypedReadResponse>;
185
+ delete: <Path extends ProtocolPaths<D> & string>(path: Path, request: TypedDeleteRequest) => Promise<DwnResponseStatus>;
186
+ subscribe: <Path extends ProtocolPaths<D> & string>(path: Path, request?: TypedSubscribeRequest) => Promise<TypedSubscribeResponse>;
187
+ };
189
188
  }
190
189
  export {};
191
- //# sourceMappingURL=typed-dwn-api.d.ts.map
190
+ //# sourceMappingURL=typed-web5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-web5.d.ts","sourceRoot":"","sources":["../../src/typed-web5.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E,IAAI,EAAE,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACpH,MAAM,EAAE,CAAC,IAAI,SAAS,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACxH,SAAS,EAAE,CAAC,IAAI,SAAS,aAAa,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,qBAAqB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;KACnI,CAmIF;CACF"}
@@ -2,9 +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 { DidMethodResolver } from '@enbox/dids';
6
+ import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
5
7
  import type { DwnDataEncodedRecordsWriteMessage, DwnProtocolDefinition, HdIdentityVault, Permission, WalletConnectOptions, Web5Agent } from '@enbox/agent';
8
+ import type { SchemaMap, TypedProtocol } from './protocol-types.js';
6
9
  import { DidApi } from './did-api.js';
7
- import { DwnApi } from './dwn-api.js';
10
+ import { DwnReaderApi } from './dwn-reader-api.js';
11
+ import { TypedWeb5 } from './typed-web5.js';
8
12
  import { VcApi } from './vc-api.js';
9
13
  /** Override defaults configured during the technical preview phase. */
10
14
  export type TechPreviewOptions = {
@@ -43,6 +47,26 @@ export type ConnectOptions = Omit<WalletConnectOptions, 'permissionRequests'> &
43
47
  */
44
48
  permissionRequests: ConnectPermissionRequest[];
45
49
  };
50
+ /**
51
+ * Options for creating an anonymous (read-only) Web5 instance via {@link Web5.anonymous}.
52
+ *
53
+ * @beta
54
+ */
55
+ export type Web5AnonymousOptions = {
56
+ /** Override the default DID method resolvers. Defaults to `[DidDht, DidJwk, DidKey, DidWeb]`. */
57
+ didResolvers?: DidMethodResolver[];
58
+ };
59
+ /**
60
+ * The result of calling {@link Web5.anonymous}.
61
+ *
62
+ * Contains only a read-only `dwn` property — no `did`, `vc`, or `agent`.
63
+ *
64
+ * @beta
65
+ */
66
+ export type Web5AnonymousApi = {
67
+ /** A read-only DWN API for querying public data on remote DWNs. */
68
+ dwn: DwnReaderApi;
69
+ };
46
70
  /** Optional overrides that can be provided when calling {@link Web5.connect}. */
47
71
  export type Web5ConnectOptions = {
48
72
  /**
@@ -184,11 +208,63 @@ export declare class Web5 {
184
208
  agent: Web5Agent;
185
209
  /** Exposed instance to the DID APIs, allow users to create and resolve DIDs */
186
210
  did: DidApi;
187
- /** Exposed instance to the DWN APIs, allow users to read/write records */
188
- dwn: DwnApi;
211
+ /** Internal DWN API instance. Use {@link Web5.using} for protocol-scoped access. */
212
+ private _dwn;
189
213
  /** Exposed instance to the VC APIs, allow users to issue, present and verify VCs */
190
214
  vc: VcApi;
191
215
  constructor({ agent, connectedDid, delegateDid }: Web5Params);
216
+ /**
217
+ * Returns a {@link TypedWeb5} instance scoped to the given protocol.
218
+ *
219
+ * This is the **primary developer interface** for interacting with
220
+ * protocol-backed records. It auto-injects the protocol URI, protocolPath,
221
+ * and schema into every operation, and provides compile-time path
222
+ * autocompletion plus typed data payloads via the schema map.
223
+ *
224
+ * @param protocol - A typed protocol created via `defineProtocol()`.
225
+ * @returns A `TypedWeb5` instance bound to the given protocol.
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * const social = web5.using(SocialProtocol);
230
+ *
231
+ * await social.configure();
232
+ *
233
+ * const { record } = await social.records.write('friend', {
234
+ * data: { did: 'did:example:alice', alias: 'Alice' },
235
+ * });
236
+ *
237
+ * const { records } = await social.records.query('friend');
238
+ * ```
239
+ */
240
+ using<D extends ProtocolDefinition, M extends SchemaMap>(protocol: TypedProtocol<D, M>): TypedWeb5<D, M>;
241
+ /**
242
+ * Creates a lightweight, read-only Web5 instance for querying public DWN data.
243
+ *
244
+ * No identity, vault, password, or signing keys are required. The returned
245
+ * API supports querying and reading published records and protocols from any
246
+ * remote DWN, using **unsigned** (anonymous) DWN messages.
247
+ *
248
+ * @param options - Optional configuration overrides.
249
+ * @returns A {@link Web5AnonymousApi} with a read-only `dwn` property.
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * const { dwn } = Web5.anonymous();
254
+ *
255
+ * const { records } = await dwn.records.query({
256
+ * from: 'did:dht:alice...',
257
+ * filter: { protocol: 'https://social.example/posts', protocolPath: 'post' },
258
+ * });
259
+ *
260
+ * for (const record of records) {
261
+ * console.log(record.id, await record.data.text());
262
+ * }
263
+ * ```
264
+ *
265
+ * @beta
266
+ */
267
+ static anonymous(options?: Web5AnonymousOptions): Web5AnonymousApi;
192
268
  /**
193
269
  * Connects to a {@link Web5Agent}. Defaults to creating a local {@link Web5UserAgent} if one
194
270
  * isn't provided.
@@ -1 +1 @@
1
- {"version":3,"file":"web5.d.ts","sourceRoot":"","sources":["../../src/web5.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAEV,iCAAiC,EAEjC,qBAAqB,EAErB,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,SAAS,EACV,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,kBAAkB,EAAE,qBAAqB,CAAC;IAE1C;;OAEG;IACH,WAA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IAEZ,oFAAoF;IACpF,OAAO,CAAC,IAAI,CAAS;IAErB,oFAAoF;IACpF,EAAE,EAAE,KAAK,CAAC;gBAEE,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,UAAU;IAO5D;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACI,KAAK,CAAC,CAAC,SAAS,kBAAkB,EAAE,CAAC,SAAS,SAAS,EAC5D,QAAQ,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAIlB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,gBAAgB;IAclE;;;;;;;;;;OAUG;WACU,OAAO,CAAC,EACnB,KAAK,EACL,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,GACrB,GAAE,kBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAsMvD;;;OAGG;mBACkB,eAAe;IAuBpC;;;;OAIG;WACU,sBAAsB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;QAClE,MAAM,EAAE,iCAAiC,EAAE,CAAC;QAC5C,KAAK,EAAE,SAAS,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqBtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/api",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "SDK for accessing the features and capabilities of Web5",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -53,6 +53,10 @@
53
53
  "types": "./dist/types/index.d.ts",
54
54
  "import": "./dist/esm/index.js"
55
55
  },
56
+ "./advanced": {
57
+ "types": "./dist/types/advanced.d.ts",
58
+ "import": "./dist/esm/advanced.js"
59
+ },
56
60
  "./browser": {
57
61
  "types": "./dist/types/index.d.ts",
58
62
  "import": "./dist/browser.mjs"
@@ -77,14 +81,14 @@
77
81
  "bun": ">=1.0.0"
78
82
  },
79
83
  "dependencies": {
80
- "@enbox/agent": "0.1.4",
84
+ "@enbox/agent": "0.1.6",
81
85
  "@enbox/common": "0.0.3",
82
- "@enbox/dwn-clients": "0.0.2"
86
+ "@enbox/dwn-clients": "0.0.4"
83
87
  },
84
88
  "devDependencies": {
85
- "@enbox/crypto": "0.0.3",
86
- "@enbox/dids": "0.0.3",
87
- "@enbox/dwn-sdk-js": "0.0.5",
89
+ "@enbox/crypto": "0.0.4",
90
+ "@enbox/dids": "0.0.5",
91
+ "@enbox/dwn-sdk-js": "0.0.7",
88
92
  "@types/node": "20.14.8",
89
93
  "@types/sinon": "17.0.3",
90
94
  "@typescript-eslint/eslint-plugin": "8.32.1",
@@ -0,0 +1,29 @@
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
+
11
+ export { DwnApi } from './dwn-api.js';
12
+
13
+ export type {
14
+ FetchGrantsRequest,
15
+ FetchRequestsRequest,
16
+ ProtocolsConfigureRequest,
17
+ ProtocolsConfigureResponse,
18
+ ProtocolsQueryRequest,
19
+ ProtocolsQueryResponse,
20
+ RecordsDeleteRequest,
21
+ RecordsQueryRequest,
22
+ RecordsQueryResponse,
23
+ RecordsReadRequest,
24
+ RecordsReadResponse,
25
+ RecordsSubscribeRequest,
26
+ RecordsSubscribeResponse,
27
+ RecordsWriteRequest,
28
+ RecordsWriteResponse,
29
+ } from './dwn-api.js';
@@ -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 TypedDwnApi} can provide
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
 
@@ -17,7 +17,7 @@ import type { SchemaMap, TypedProtocol } from './protocol-types.js';
17
17
  *
18
18
  * The `definition` argument is returned as-is (no cloning). The schema map
19
19
  * is a phantom type parameter — it exists only at compile time to thread
20
- * type information through to `TypedDwnApi`.
20
+ * type information through to `TypedWeb5`.
21
21
  *
22
22
  * @param definition - A standard `ProtocolDefinition` object.
23
23
  * @param _schemaMap - A phantom value (e.g. `{} as MySchemaMap`) that carries
@@ -32,7 +32,7 @@ import type { SchemaMap, TypedProtocol } from './protocol-types.js';
32
32
  * });
33
33
  *
34
34
  * // socialGraph.definition is the raw ProtocolDefinition
35
- * // TypedDwnApi infers paths like 'friend' | 'friend/message' and
35
+ * // TypedWeb5 infers paths like 'friend' | 'friend/message' and
36
36
  * // data types from the schema map.
37
37
  * ```
38
38
  */