@enbox/api 0.3.2 → 0.4.1

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 (102) hide show
  1. package/README.md +63 -0
  2. package/dist/browser.mjs +11 -28
  3. package/dist/browser.mjs.map +4 -4
  4. package/dist/esm/advanced.js +1 -1
  5. package/dist/esm/define-protocol.js +3 -3
  6. package/dist/esm/did-api.js +1 -1
  7. package/dist/esm/did-api.js.map +1 -1
  8. package/dist/esm/dwn-api.js +6 -6
  9. package/dist/esm/dwn-api.js.map +1 -1
  10. package/dist/esm/dwn-reader-api.js +2 -2
  11. package/dist/esm/enbox.js +205 -0
  12. package/dist/esm/enbox.js.map +1 -0
  13. package/dist/esm/index.js +16 -15
  14. package/dist/esm/index.js.map +1 -1
  15. package/dist/esm/protocol.js +2 -2
  16. package/dist/esm/protocol.js.map +1 -1
  17. package/dist/esm/record-data.js +79 -5
  18. package/dist/esm/record-data.js.map +1 -1
  19. package/dist/esm/record.js +49 -10
  20. package/dist/esm/record.js.map +1 -1
  21. package/dist/esm/repository.js +7 -7
  22. package/dist/esm/repository.js.map +1 -1
  23. package/dist/esm/typed-enbox.js +583 -0
  24. package/dist/esm/typed-enbox.js.map +1 -0
  25. package/dist/esm/typed-live-query.js +1 -1
  26. package/dist/esm/typed-record.js +370 -46
  27. package/dist/esm/typed-record.js.map +1 -1
  28. package/dist/esm/utils.js +25 -0
  29. package/dist/esm/utils.js.map +1 -1
  30. package/dist/esm/vc-api.js.map +1 -1
  31. package/dist/types/advanced.d.ts +1 -1
  32. package/dist/types/define-protocol.d.ts +3 -3
  33. package/dist/types/did-api.d.ts +4 -4
  34. package/dist/types/did-api.d.ts.map +1 -1
  35. package/dist/types/dwn-api.d.ts +12 -7
  36. package/dist/types/dwn-api.d.ts.map +1 -1
  37. package/dist/types/dwn-reader-api.d.ts +2 -2
  38. package/dist/types/enbox.d.ts +202 -0
  39. package/dist/types/enbox.d.ts.map +1 -0
  40. package/dist/types/grant-revocation.d.ts +2 -2
  41. package/dist/types/grant-revocation.d.ts.map +1 -1
  42. package/dist/types/index.d.ts +16 -15
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/live-query.d.ts +2 -2
  45. package/dist/types/live-query.d.ts.map +1 -1
  46. package/dist/types/permission-grant.d.ts +2 -2
  47. package/dist/types/permission-grant.d.ts.map +1 -1
  48. package/dist/types/permission-request.d.ts +2 -2
  49. package/dist/types/permission-request.d.ts.map +1 -1
  50. package/dist/types/protocol-types.d.ts +2 -2
  51. package/dist/types/protocol.d.ts +7 -7
  52. package/dist/types/protocol.d.ts.map +1 -1
  53. package/dist/types/record-data.d.ts +17 -0
  54. package/dist/types/record-data.d.ts.map +1 -1
  55. package/dist/types/record.d.ts +24 -10
  56. package/dist/types/record.d.ts.map +1 -1
  57. package/dist/types/repository-types.d.ts +19 -11
  58. package/dist/types/repository-types.d.ts.map +1 -1
  59. package/dist/types/repository.d.ts +7 -7
  60. package/dist/types/repository.d.ts.map +1 -1
  61. package/dist/types/typed-enbox.d.ts +613 -0
  62. package/dist/types/typed-enbox.d.ts.map +1 -0
  63. package/dist/types/typed-live-query.d.ts +1 -1
  64. package/dist/types/typed-record.d.ts +427 -53
  65. package/dist/types/typed-record.d.ts.map +1 -1
  66. package/dist/types/utils.d.ts +23 -0
  67. package/dist/types/utils.d.ts.map +1 -1
  68. package/dist/types/vc-api.d.ts +3 -3
  69. package/dist/types/vc-api.d.ts.map +1 -1
  70. package/package.json +12 -11
  71. package/src/advanced.ts +1 -1
  72. package/src/define-protocol.ts +3 -3
  73. package/src/did-api.ts +5 -5
  74. package/src/dwn-api.ts +22 -17
  75. package/src/dwn-reader-api.ts +2 -2
  76. package/src/enbox.ts +281 -0
  77. package/src/grant-revocation.ts +3 -3
  78. package/src/index.ts +17 -16
  79. package/src/live-query.ts +2 -2
  80. package/src/permission-grant.ts +4 -4
  81. package/src/permission-request.ts +3 -3
  82. package/src/protocol-types.ts +2 -2
  83. package/src/protocol.ts +8 -8
  84. package/src/record-data.ts +86 -5
  85. package/src/record.ts +54 -13
  86. package/src/repository-types.ts +19 -7
  87. package/src/repository.ts +15 -15
  88. package/src/typed-enbox.ts +1169 -0
  89. package/src/typed-live-query.ts +1 -1
  90. package/src/typed-record.ts +431 -53
  91. package/src/utils.ts +27 -0
  92. package/src/vc-api.ts +4 -4
  93. package/dist/esm/typed-web5.js +0 -339
  94. package/dist/esm/typed-web5.js.map +0 -1
  95. package/dist/esm/web5.js +0 -410
  96. package/dist/esm/web5.js.map +0 -1
  97. package/dist/types/typed-web5.d.ts +0 -221
  98. package/dist/types/typed-web5.d.ts.map +0 -1
  99. package/dist/types/web5.d.ts +0 -351
  100. package/dist/types/web5.d.ts.map +0 -1
  101. package/src/typed-web5.ts +0 -598
  102. package/src/web5.ts +0 -762
@@ -11,14 +11,29 @@
11
11
  * - `.data.json()` returns `Promise<T>` instead of `Promise<unknown>`.
12
12
  * - `.update({ data })` accepts `Partial<T>` for the data payload.
13
13
  *
14
+ * You never construct `TypedRecord` directly — instances are returned by
15
+ * {@link TypedEnbox} methods such as `records.create()`, `records.query()`,
16
+ * `records.read()`, and `records.subscribe()`.
17
+ *
18
+ * @typeParam T - The TypeScript type of the record's data payload, resolved
19
+ * from the protocol's schema map at the given protocol path.
20
+ *
14
21
  * @example
15
22
  * ```ts
16
- * const { record } = await typed.records.write('friend', {
23
+ * const { record } = await proto.records.create('friend', {
17
24
  * data: { did: 'did:example:alice', alias: 'Alice' },
18
25
  * });
19
26
  *
20
27
  * // record is TypedRecord<FriendData>
21
28
  * const data = await record.data.json(); // FriendData — no manual cast
29
+ *
30
+ * // Update preserves the type
31
+ * const { record: updated } = await record.update({
32
+ * data: { alias: 'Ali' }, // Partial<FriendData>
33
+ * });
34
+ *
35
+ * // Send to the remote DWN
36
+ * await updated.send();
22
37
  * ```
23
38
  */
24
39
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -36,17 +51,56 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
36
51
  /**
37
52
  * A type-safe wrapper around {@link Record} that preserves the data type `T`.
38
53
  *
39
- * Obtain instances through `TypedWeb5.records.write()`, `.query()`, `.read()`,
40
- * or `.subscribe()` — never construct directly.
54
+ * Obtain instances through {@link TypedEnbox} methods — `records.create()`,
55
+ * `records.query()`, `records.read()`, or `records.subscribe()` — never
56
+ * construct directly.
57
+ *
58
+ * @typeParam T - The TypeScript type of the record's data payload. This type
59
+ * is inferred automatically from the protocol's schema map and the protocol
60
+ * path used when creating or querying the record.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * // TypedRecord instances are returned by TypedEnbox methods:
65
+ * const { record } = await proto.records.create('notebook', {
66
+ * data: { name: 'My Notebook' },
67
+ * });
68
+ *
69
+ * // Access metadata
70
+ * console.log(record.id); // unique record ID
71
+ * console.log(record.contextId); // context ID for hierarchical grouping
72
+ * console.log(record.dateCreated); // ISO 8601 creation timestamp
73
+ * console.log(record.timestamp); // ISO 8601 last-update timestamp
74
+ * console.log(record.tags); // key-value metadata tags
75
+ *
76
+ * // Type-safe data access
77
+ * const data = await record.data.json(); // NotebookData
78
+ *
79
+ * // Lifecycle
80
+ * await record.send(); // push to remote DWN
81
+ * await record.update({ data: { name: 'Renamed' } });
82
+ * await record.delete();
83
+ * ```
41
84
  */
42
85
  export class TypedRecord {
86
+ /**
87
+ * @internal Wrap an untyped {@link Record} in a type-safe shell.
88
+ * @param record - The underlying `Record` instance to wrap.
89
+ */
43
90
  constructor(record) {
44
91
  this._record = record;
45
92
  }
46
93
  // -------------------------------------------------------------------------
47
94
  // Escape hatch
48
95
  // -------------------------------------------------------------------------
49
- /** Access the underlying untyped {@link Record} for advanced use cases. */
96
+ /**
97
+ * Access the underlying untyped {@link Record} for advanced use cases.
98
+ *
99
+ * Use this escape hatch when you need to call `Record` methods or access
100
+ * properties that are not surfaced by the typed wrapper.
101
+ *
102
+ * @returns The wrapped {@link Record} instance.
103
+ */
50
104
  get rawRecord() {
51
105
  return this._record;
52
106
  }
@@ -54,11 +108,32 @@ export class TypedRecord {
54
108
  // Typed data accessor
55
109
  // -------------------------------------------------------------------------
56
110
  /**
57
- * Returns the data of the current record with type-safe accessors.
111
+ * Returns the record's data with type-safe accessors.
112
+ *
113
+ * The returned object provides multiple ways to consume the data:
58
114
  *
59
- * The `json()` method returns `Promise<T>` — no manual generic needed.
115
+ * | Method | Return type | Description |
116
+ * |------------|--------------------------|--------------------------------------|
117
+ * | `json()` | `Promise<T>` | Parse as JSON with full type safety |
118
+ * | `text()` | `Promise<string>` | Raw UTF-8 text |
119
+ * | `blob()` | `Promise<Blob>` | Binary blob (respects `dataFormat`) |
120
+ * | `bytes()` | `Promise<Uint8Array>` | Raw bytes |
121
+ * | `stream()` | `Promise<ReadableStream>`| Web `ReadableStream` for streaming |
60
122
  *
123
+ * The object is also directly awaitable (returns the stream).
124
+ *
125
+ * @returns A {@link TypedRecordData} accessor whose `json()` returns `Promise<T>`.
61
126
  * @throws `Error` if the record has been deleted.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const { record } = await proto.records.read('notebook', {
131
+ * filter: { recordId },
132
+ * });
133
+ *
134
+ * const notebook = await record.data.json(); // NotebookData
135
+ * const raw = await record.data.text(); // string
136
+ * ```
62
137
  */
63
138
  get data() {
64
139
  const underlying = this._record.data;
@@ -76,23 +151,63 @@ export class TypedRecord {
76
151
  // Typed mutation methods
77
152
  // -------------------------------------------------------------------------
78
153
  /**
79
- * Update the current record on the DWN.
154
+ * Update the current record's data and/or metadata on the DWN.
155
+ *
156
+ * The `data` field accepts `Partial<T>`, so you only need to provide
157
+ * the fields you want to change. A new {@link TypedRecord} is returned
158
+ * **and** the original instance is mutated in-place, so both the returned
159
+ * record and the original reference reflect the updated state.
80
160
  *
81
- * @param params - Parameters including the typed `data` payload.
82
- * @returns The status and an updated {@link TypedRecord}.
161
+ * @param params - Update parameters. `data` is type-checked as `Partial<T>`.
162
+ * Other fields like `tags`, `published`, and `datePublished` can also be
163
+ * updated.
164
+ * @returns A {@link TypedRecordUpdateResult} containing the DWN response
165
+ * `status` and the updated {@link TypedRecord}.
83
166
  * @throws `Error` if the record has been deleted.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * const { status, record: updated } = await record.update({
171
+ * data: { title: 'New Title' }, // Partial<PageData>
172
+ * tags: { priority: 'high' },
173
+ * });
174
+ *
175
+ * if (status.code === 202) {
176
+ * await updated.send(); // push update to remote
177
+ * }
178
+ * ```
84
179
  */
85
180
  update(params) {
86
181
  return __awaiter(this, void 0, void 0, function* () {
87
182
  const { status, record } = yield this._record.update(params);
183
+ // The underlying Record.update() now also mutates `this._record` in-place,
184
+ // so the original TypedRecord reference already reflects the new data.
185
+ // We still return a new TypedRecord wrapping the returned record for callers
186
+ // that use the destructured result.
88
187
  return { status, record: new TypedRecord(record) };
89
188
  });
90
189
  }
91
190
  /**
92
- * Delete the current record on the DWN.
191
+ * Delete the current record from the DWN.
93
192
  *
94
- * @param params - Delete parameters.
95
- * @returns The status and a {@link TypedRecord} reflecting the deleted state.
193
+ * After deletion, **both** the returned record and the original instance's
194
+ * {@link TypedRecord.deleted | deleted} property will be `true`, and
195
+ * calling data accessors on either will throw.
196
+ *
197
+ * @param params - Optional delete parameters:
198
+ * - `store` — whether to persist the delete message (defaults to `true`).
199
+ * - `prune` — whether to also delete child records.
200
+ * - `signAsOwner` — sign the delete as the DWN owner (for imports).
201
+ * @returns A {@link TypedRecordDeleteResult} containing the DWN response
202
+ * `status` and the record in its deleted state.
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * const { status } = await record.delete({ prune: true });
207
+ * if (status.code === 202) {
208
+ * console.log('Record and children deleted');
209
+ * }
210
+ * ```
96
211
  */
97
212
  delete(params) {
98
213
  return __awaiter(this, void 0, void 0, function* () {
@@ -104,9 +219,15 @@ export class TypedRecord {
104
219
  // Forwarded lifecycle methods
105
220
  // -------------------------------------------------------------------------
106
221
  /**
107
- * Stores the current record state to the owner's DWN.
222
+ * Stores the current record state to the local DWN.
223
+ *
224
+ * Call this after creating a record with `store: false` or after
225
+ * receiving a record from a remote DWN that you want to persist locally.
108
226
  *
109
- * @param importRecord - If true, sign as owner before storing. Defaults to false.
227
+ * @param importRecord - If `true`, sign the record as the DWN owner
228
+ * before storing (useful for importing records authored by others).
229
+ * Defaults to `false`.
230
+ * @returns The DWN response status.
110
231
  */
111
232
  store() {
112
233
  return __awaiter(this, arguments, void 0, function* (importRecord = false) {
@@ -114,10 +235,14 @@ export class TypedRecord {
114
235
  });
115
236
  }
116
237
  /**
117
- * Signs and optionally stores the record to the owner's DWN.
118
- * Useful when importing a record signed by someone else.
238
+ * Signs the record as the DWN owner and optionally stores it.
119
239
  *
120
- * @param store - If true, store after signing. Defaults to true.
240
+ * Use this when importing a record authored/signed by another DID into
241
+ * your own DWN. The record will be re-signed under your identity.
242
+ *
243
+ * @param store - If `true`, persist the record after signing.
244
+ * Defaults to `true`.
245
+ * @returns The DWN response status.
121
246
  */
122
247
  import() {
123
248
  return __awaiter(this, arguments, void 0, function* (store = true) {
@@ -125,9 +250,28 @@ export class TypedRecord {
125
250
  });
126
251
  }
127
252
  /**
128
- * Send the current record to a remote DWN.
253
+ * Push the current record to a remote DWN.
254
+ *
255
+ * This sends the record (including its data) to the specified remote
256
+ * DWN. Use this after `create`, `update`, or `delete` to sync changes
257
+ * with the remote node.
258
+ *
259
+ * @param target - The DID of the remote DWN to send to. If omitted,
260
+ * defaults to the DID of the currently connected identity.
261
+ * @returns The DWN response status from the remote node.
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * const { record } = await proto.records.create('notebook', {
266
+ * data: { name: 'Travel Notes' },
267
+ * });
129
268
  *
130
- * @param target - Optional DID of the target DWN. Defaults to the connected DID.
269
+ * // Push to your own remote DWN
270
+ * await record.send();
271
+ *
272
+ * // Or push to another user's DWN
273
+ * await record.send('did:example:bob');
274
+ * ```
131
275
  */
132
276
  send(target) {
133
277
  return __awaiter(this, void 0, void 0, function* () {
@@ -135,19 +279,36 @@ export class TypedRecord {
135
279
  });
136
280
  }
137
281
  /**
138
- * Returns a JSON representation of the Record instance.
282
+ * Returns a JSON-serializable representation of the record's metadata.
283
+ *
284
+ * Useful for logging, debugging, or serializing the record's state.
285
+ * Does **not** include the record's data payload — use {@link TypedRecord.data | data}
286
+ * accessors for that.
287
+ *
288
+ * @returns A {@link RecordModel} containing the record's metadata fields.
139
289
  */
140
290
  toJSON() {
141
291
  return this._record.toJSON();
142
292
  }
143
293
  /**
144
- * Returns a string representation of the Record instance.
294
+ * Returns a human-readable string representation of the record.
295
+ *
296
+ * @returns A string summary of the record (delegates to the underlying Record).
145
297
  */
146
298
  toString() {
147
299
  return this._record.toString();
148
300
  }
149
301
  /**
150
- * Returns a pagination cursor for the current record given a sort order.
302
+ * Returns a pagination cursor anchored at this record for the given sort
303
+ * order.
304
+ *
305
+ * Pass the returned cursor to a subsequent `query()` call's
306
+ * `pagination.cursor` to resume pagination from this record.
307
+ *
308
+ * @param sort - The date-sort order to use for cursor positioning
309
+ * (e.g. `DateSort.CreatedAscending`).
310
+ * @returns A pagination cursor, or `undefined` if the record cannot
311
+ * produce one.
151
312
  */
152
313
  paginationCursor(sort) {
153
314
  return __awaiter(this, void 0, void 0, function* () {
@@ -157,69 +318,232 @@ export class TypedRecord {
157
318
  // -------------------------------------------------------------------------
158
319
  // Forwarded immutable property getters
159
320
  // -------------------------------------------------------------------------
160
- /** Record's ID. */
321
+ /**
322
+ * The record's unique identifier.
323
+ *
324
+ * This is a stable, globally unique ID assigned when the record is first
325
+ * created. It does not change across updates or deletes.
326
+ */
161
327
  get id() { return this._record.id; }
162
- /** Record's context ID. */
328
+ /**
329
+ * The context ID used to group hierarchical records.
330
+ *
331
+ * When a record is created as a child (using `parentContextId`), the DWN
332
+ * assigns a `contextId` that links all records in the same hierarchy.
333
+ * Use this value as the `parentContextId` when creating child records,
334
+ * or as a `parentId` filter when querying for children.
335
+ *
336
+ * @returns The context ID string, or `undefined` if the record is not
337
+ * part of a hierarchical context.
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * const { record: notebook } = await proto.records.create('notebook', {
342
+ * data: { name: 'My Notebook' },
343
+ * });
344
+ *
345
+ * // Create a child page under the notebook's context
346
+ * const { record: page } = await proto.records.create('notebook/page', {
347
+ * data: { title: 'Page 1' },
348
+ * parentContextId: notebook.contextId,
349
+ * });
350
+ * ```
351
+ */
163
352
  get contextId() { return this._record.contextId; }
164
- /** Record's creation date. */
353
+ /**
354
+ * ISO 8601 timestamp of when the record was first created.
355
+ *
356
+ * This value is immutable and never changes, even when the record is
357
+ * updated or deleted. For the timestamp of the most recent mutation,
358
+ * use {@link TypedRecord.timestamp | timestamp}.
359
+ */
165
360
  get dateCreated() { return this._record.dateCreated; }
166
- /** Record's parent ID. */
361
+ /**
362
+ * The parent record's ID, if this record was created as a child.
363
+ *
364
+ * @returns The parent's record ID, or `undefined` for top-level records.
365
+ */
167
366
  get parentId() { return this._record.parentId; }
168
- /** Record's protocol. */
367
+ /**
368
+ * The protocol URI this record belongs to.
369
+ *
370
+ * @returns The protocol URI string (e.g. `'https://example.com/social'`),
371
+ * or `undefined` if the record is not protocol-scoped.
372
+ */
169
373
  get protocol() { return this._record.protocol; }
170
- /** Record's protocol path. */
374
+ /**
375
+ * The protocol path of this record within the protocol's structure.
376
+ *
377
+ * For example, `'notebook'` or `'notebook/page'`. This identifies which
378
+ * type definition in the protocol structure governs this record.
379
+ */
171
380
  get protocolPath() { return this._record.protocolPath; }
172
- /** Record's recipient. */
381
+ /**
382
+ * The DID of the intended recipient of this record.
383
+ *
384
+ * @returns The recipient's DID string, or `undefined` if no specific
385
+ * recipient was set.
386
+ */
173
387
  get recipient() { return this._record.recipient; }
174
- /** Record's schema. */
388
+ /**
389
+ * The schema URI associated with this record's type in the protocol
390
+ * definition.
391
+ *
392
+ * @returns The schema URI string, or `undefined` if the type has no schema.
393
+ */
175
394
  get schema() { return this._record.schema; }
176
395
  // -------------------------------------------------------------------------
177
396
  // Forwarded mutable property getters
178
397
  // -------------------------------------------------------------------------
179
- /** Record's data format. */
398
+ /**
399
+ * The MIME type / data format of the record's payload.
400
+ *
401
+ * Typically `'application/json'` for structured data, but can be any
402
+ * MIME type supported by the protocol definition's `dataFormats` array.
403
+ */
180
404
  get dataFormat() { return this._record.dataFormat; }
181
- /** Record's data CID. */
405
+ /**
406
+ * The Content Identifier (CID) of the record's data.
407
+ *
408
+ * This is a content-addressable hash of the data payload, useful for
409
+ * verifying data integrity.
410
+ */
182
411
  get dataCid() { return this._record.dataCid; }
183
- /** Record's data size. */
412
+ /**
413
+ * The size of the record's data payload in bytes.
414
+ */
184
415
  get dataSize() { return this._record.dataSize; }
185
- /** Record's published date. */
416
+ /**
417
+ * ISO 8601 timestamp of when the record was published.
418
+ *
419
+ * Only present if the record has been explicitly published
420
+ * (i.e. `published: true` was set during create or update).
421
+ */
186
422
  get datePublished() { return this._record.datePublished; }
187
- /** Record's published status. */
423
+ /**
424
+ * Whether the record is publicly published.
425
+ *
426
+ * Published records can be read by anyone without authorization.
427
+ * `undefined` if the published state was never explicitly set.
428
+ */
188
429
  get published() { return this._record.published; }
189
- /** Tags of the record. */
430
+ /**
431
+ * Key-value metadata tags attached to the record.
432
+ *
433
+ * Tags are indexed by the DWN and can be used in query filters for
434
+ * efficient lookups. Values can be strings, numbers, booleans, or
435
+ * arrays of strings/numbers.
436
+ *
437
+ * @returns The tags object, or `undefined` if no tags are set.
438
+ *
439
+ * @example
440
+ * ```ts
441
+ * // Query records by tag
442
+ * const { records } = await proto.records.query('notebook', {
443
+ * filter: { tags: { category: 'work' } },
444
+ * });
445
+ *
446
+ * // Read tags from a record
447
+ * const tags = record.tags; // { category: 'work', priority: 1 }
448
+ * ```
449
+ */
190
450
  get tags() {
191
451
  return this._record.tags;
192
452
  }
193
453
  // -------------------------------------------------------------------------
194
454
  // Forwarded state-dependent property getters
195
455
  // -------------------------------------------------------------------------
196
- /** DID that is the logical author of the Record. */
456
+ /**
457
+ * The DID of the logical author of this record.
458
+ *
459
+ * For records you create, this is your own DID. For records written by
460
+ * others (e.g. received via a protocol role), this is the signer's DID.
461
+ */
197
462
  get author() { return this._record.author; }
198
- /** DID that is the original creator of the Record. */
463
+ /**
464
+ * The DID of the original creator of this record.
465
+ *
466
+ * Unlike {@link TypedRecord.author | author}, which reflects the current
467
+ * message signer (and may change on updates), `creator` always refers
468
+ * to the DID that authored the initial write.
469
+ */
199
470
  get creator() { return this._record.creator; }
200
- /** Record's message timestamp. */
471
+ /**
472
+ * ISO 8601 timestamp of the record's most recent message (create, update,
473
+ * or delete).
474
+ *
475
+ * This value changes with every mutation. For the original creation time,
476
+ * use {@link TypedRecord.dateCreated | dateCreated}.
477
+ *
478
+ * **Note:** There is no `.dateModified` property — use `timestamp` to
479
+ * determine when the record was last changed.
480
+ */
201
481
  get timestamp() { return this._record.timestamp; }
202
- /** Record's encryption details. */
482
+ /**
483
+ * Encryption metadata for the record, if it was encrypted.
484
+ *
485
+ * Contains the algorithm, key encryption details, and initialization
486
+ * vectors used to encrypt the record's data. `undefined` for
487
+ * unencrypted records.
488
+ */
203
489
  get encryption() {
204
490
  return this._record.encryption;
205
491
  }
206
- /** Record's authorization. */
492
+ /**
493
+ * The authorization signature(s) for the current record message.
494
+ *
495
+ * Contains the JWS (JSON Web Signature) proving the message was
496
+ * authorized by the author.
497
+ */
207
498
  get authorization() {
208
499
  return this._record.authorization;
209
500
  }
210
- /** Record's attestation. */
501
+ /**
502
+ * Optional attestation signature(s) for the record.
503
+ *
504
+ * Attestations are additional signatures (beyond the author's
505
+ * authorization) that vouch for the record's content.
506
+ *
507
+ * @returns The attestation JWS, or `undefined` if none is present.
508
+ */
211
509
  get attestation() {
212
510
  return this._record.attestation;
213
511
  }
214
- /** Role under which the author is writing the record. */
512
+ /**
513
+ * The protocol role under which this record was written.
514
+ *
515
+ * When a record is created with a `protocolRole`, the DWN checks that
516
+ * the author is authorized to write under that role per the protocol's
517
+ * `$actions` rules.
518
+ *
519
+ * @returns The role string (e.g. `'admin'`, `'member'`), or `undefined`
520
+ * if no role was specified.
521
+ */
215
522
  get protocolRole() { return this._record.protocolRole; }
216
- /** Record's deleted state. */
523
+ /**
524
+ * Whether the record has been deleted.
525
+ *
526
+ * Once `true`, data accessors (`data.json()`, etc.) will throw. The
527
+ * record's metadata (ID, timestamps, etc.) remains accessible.
528
+ */
217
529
  get deleted() { return this._record.deleted; }
218
- /** Record's initial write if the record has been updated. */
530
+ /**
531
+ * The initial `RecordsWrite` message for this record, if it has been
532
+ * updated at least once.
533
+ *
534
+ * The DWN preserves the initial write message to allow other nodes to
535
+ * verify the full history chain. For records that have never been
536
+ * updated, this is `undefined`.
537
+ */
219
538
  get initialWrite() {
220
539
  return this._record.initialWrite;
221
540
  }
222
- /** The raw DWN message backing this record. */
541
+ /**
542
+ * The raw DWN message backing this record's current state.
543
+ *
544
+ * This is the full, unprocessed DWN message — either a `RecordsWrite`
545
+ * or `RecordsDelete` message depending on the record's state.
546
+ */
223
547
  get rawMessage() {
224
548
  return this._record.rawMessage;
225
549
  }
@@ -1 +1 @@
1
- {"version":3,"file":"typed-record.js","sourceRoot":"","sources":["../../src/typed-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;AA4DH,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAItB,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,4EAA4E;IAC5E,eAAe;IACf,4EAA4E;IAE5E,2EAA2E;IAC3E,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,4EAA4E;IAC5E,sBAAsB;IACtB,4EAA4E;IAE5E;;;;;;OAMG;IACH,IAAW,IAAI;QACb,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACrC,OAAO;YACL,IAAI,EAAK,GAAkB,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,CAAC;IAED;;;;;OAKG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IAClC,CAAC;IAED;;;;;;;;;OASG;IACH,IAAW,YAAY,KAAyB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnF;;;;;OAKG;IACH,IAAW,OAAO,KAAc,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9D;;;;;;;OAOG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACjC,CAAC;CACF"}
package/dist/esm/utils.js CHANGED
@@ -1,4 +1,29 @@
1
1
  import { Convert, universalTypeOf } from '@enbox/common';
2
+ /**
3
+ * Returns `true` if the DWN response status indicates success (2xx code).
4
+ *
5
+ * Use this instead of manually checking `status.code >= 200 && status.code <= 299`
6
+ * on every API call.
7
+ *
8
+ * @param response - Any object that conforms to {@link DwnResponseStatus}.
9
+ * @returns `true` for 2xx status codes, `false` otherwise.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const result = await proto.records.create('note', { data: { text: 'hello' } });
14
+ * if (!isOk(result)) {
15
+ * console.error('Create failed:', result.status.detail);
16
+ * return;
17
+ * }
18
+ * // result.record is safe to use here
19
+ * ```
20
+ *
21
+ * @beta
22
+ */
23
+ export function isOk(response) {
24
+ const code = response.status.code;
25
+ return code >= 200 && code <= 299;
26
+ }
2
27
  /**
3
28
  * Converts various data types to a `Blob` object, automatically detecting the data type or using
4
29
  * the specified `dataFormat` to set the Blob's MIME type.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":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C;QAC3B,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QACrC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC,cAAc,EAAE,CAAC;YAC/C,MAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YACxD,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;QACD,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3B,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxB,IAAI,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC,cAAc,EAAE,CAAC;YAChD,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YACpD,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;;AAhDD;;;EAGE;AACa,eAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;AAEtD;;;;GAIG;AACY,wBAAc,GAAG,GAAG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"vc-api.js","sourceRoot":"","sources":["../../src/vc-api.ts"],"names":[],"mappings":";;;;;;;;;AAEA;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAUhB,YAAY,OAAmD;QAC7D,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,CAAC;IAED;;OAEG;IACG,MAAM;;YACV,kBAAkB;YAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;KAAA;CACF"}
1
+ {"version":3,"file":"vc-api.js","sourceRoot":"","sources":["../../src/vc-api.ts"],"names":[],"mappings":";;;;;;;;;AAEA;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAUhB,YAAY,OAAoD;QAC9D,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,CAAC;IAED;;OAEG;IACG,MAAM;;YACV,kBAAkB;YAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;KAAA;CACF"}
@@ -2,7 +2,7 @@
2
2
  * Advanced API surface for power users who need direct access to
3
3
  * the underlying {@link DwnApi}.
4
4
  *
5
- * Most applications should use `web5.using(protocol)` instead.
5
+ * Most applications should use `enbox.using(protocol)` instead.
6
6
  * Import from `@enbox/api/advanced` to access these exports.
7
7
  *
8
8
  * @packageDocumentation
@@ -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 TypedWeb5} can provide
5
+ * compile-time type metadata so that {@link TypedEnbox} 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 `TypedWeb5`.
17
+ * type information through to `TypedEnbox`.
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
- * // TypedWeb5 infers paths like 'friend' | 'friend/message' and
32
+ * // TypedEnbox infers paths like 'friend' | 'friend/message' and
33
33
  * // data types from the schema map.
34
34
  * ```
35
35
  */