@enbox/api 0.2.3 → 0.2.4

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 (73) hide show
  1. package/README.md +235 -35
  2. package/dist/browser.mjs +13 -13
  3. package/dist/browser.mjs.map +4 -4
  4. package/dist/esm/dwn-api.js +24 -10
  5. package/dist/esm/dwn-api.js.map +1 -1
  6. package/dist/esm/index.js +6 -0
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/live-query.js +34 -5
  9. package/dist/esm/live-query.js.map +1 -1
  10. package/dist/esm/permission-grant.js +3 -6
  11. package/dist/esm/permission-grant.js.map +1 -1
  12. package/dist/esm/permission-request.js +4 -7
  13. package/dist/esm/permission-request.js.map +1 -1
  14. package/dist/esm/record-data.js +131 -0
  15. package/dist/esm/record-data.js.map +1 -0
  16. package/dist/esm/record-types.js +9 -0
  17. package/dist/esm/record-types.js.map +1 -0
  18. package/dist/esm/record.js +58 -184
  19. package/dist/esm/record.js.map +1 -1
  20. package/dist/esm/repository-types.js +13 -0
  21. package/dist/esm/repository-types.js.map +1 -0
  22. package/dist/esm/repository.js +347 -0
  23. package/dist/esm/repository.js.map +1 -0
  24. package/dist/esm/typed-live-query.js +101 -0
  25. package/dist/esm/typed-live-query.js.map +1 -0
  26. package/dist/esm/typed-record.js +227 -0
  27. package/dist/esm/typed-record.js.map +1 -0
  28. package/dist/esm/typed-web5.js +134 -23
  29. package/dist/esm/typed-web5.js.map +1 -1
  30. package/dist/esm/web5.js +78 -20
  31. package/dist/esm/web5.js.map +1 -1
  32. package/dist/types/dwn-api.d.ts.map +1 -1
  33. package/dist/types/index.d.ts +6 -0
  34. package/dist/types/index.d.ts.map +1 -1
  35. package/dist/types/live-query.d.ts +43 -4
  36. package/dist/types/live-query.d.ts.map +1 -1
  37. package/dist/types/permission-grant.d.ts +1 -1
  38. package/dist/types/permission-grant.d.ts.map +1 -1
  39. package/dist/types/permission-request.d.ts +1 -1
  40. package/dist/types/permission-request.d.ts.map +1 -1
  41. package/dist/types/record-data.d.ts +49 -0
  42. package/dist/types/record-data.d.ts.map +1 -0
  43. package/dist/types/record-types.d.ts +145 -0
  44. package/dist/types/record-types.d.ts.map +1 -0
  45. package/dist/types/record.d.ts +13 -144
  46. package/dist/types/record.d.ts.map +1 -1
  47. package/dist/types/repository-types.d.ts +137 -0
  48. package/dist/types/repository-types.d.ts.map +1 -0
  49. package/dist/types/repository.d.ts +59 -0
  50. package/dist/types/repository.d.ts.map +1 -0
  51. package/dist/types/typed-live-query.d.ts +86 -0
  52. package/dist/types/typed-live-query.d.ts.map +1 -0
  53. package/dist/types/typed-record.d.ts +179 -0
  54. package/dist/types/typed-record.d.ts.map +1 -0
  55. package/dist/types/typed-web5.d.ts +55 -24
  56. package/dist/types/typed-web5.d.ts.map +1 -1
  57. package/dist/types/web5.d.ts +47 -2
  58. package/dist/types/web5.d.ts.map +1 -1
  59. package/package.json +8 -7
  60. package/src/dwn-api.ts +30 -13
  61. package/src/index.ts +6 -0
  62. package/src/live-query.ts +71 -7
  63. package/src/permission-grant.ts +2 -3
  64. package/src/permission-request.ts +3 -4
  65. package/src/record-data.ts +155 -0
  66. package/src/record-types.ts +188 -0
  67. package/src/record.ts +86 -389
  68. package/src/repository-types.ts +249 -0
  69. package/src/repository.ts +391 -0
  70. package/src/typed-live-query.ts +156 -0
  71. package/src/typed-record.ts +309 -0
  72. package/src/typed-web5.ts +202 -49
  73. package/src/web5.ts +150 -23
@@ -0,0 +1,227 @@
1
+ /**
2
+ * A type-safe wrapper around {@link Record} that carries the data type `T`
3
+ * through its entire lifecycle — from write to read, query, update, and
4
+ * subscribe.
5
+ *
6
+ * `TypedRecord<T>` uses composition (not inheritance) to wrap the underlying
7
+ * untyped `Record` class. All read-only getters and lifecycle methods are
8
+ * forwarded, while data-access and mutation methods are enhanced with the
9
+ * generic `T`:
10
+ *
11
+ * - `.data.json()` returns `Promise<T>` instead of `Promise<unknown>`.
12
+ * - `.update({ data })` accepts `Partial<T>` for the data payload.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const { record } = await typed.records.write('friend', {
17
+ * data: { did: 'did:example:alice', alias: 'Alice' },
18
+ * });
19
+ *
20
+ * // record is TypedRecord<FriendData>
21
+ * const data = await record.data.json(); // FriendData — no manual cast
22
+ * ```
23
+ */
24
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
25
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
26
+ return new (P || (P = Promise))(function (resolve, reject) {
27
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
28
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
29
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
30
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31
+ });
32
+ };
33
+ // ---------------------------------------------------------------------------
34
+ // TypedRecord class
35
+ // ---------------------------------------------------------------------------
36
+ /**
37
+ * A type-safe wrapper around {@link Record} that preserves the data type `T`.
38
+ *
39
+ * Obtain instances through `TypedWeb5.records.write()`, `.query()`, `.read()`,
40
+ * or `.subscribe()` — never construct directly.
41
+ */
42
+ export class TypedRecord {
43
+ constructor(record) {
44
+ this._record = record;
45
+ }
46
+ // -------------------------------------------------------------------------
47
+ // Escape hatch
48
+ // -------------------------------------------------------------------------
49
+ /** Access the underlying untyped {@link Record} for advanced use cases. */
50
+ get rawRecord() {
51
+ return this._record;
52
+ }
53
+ // -------------------------------------------------------------------------
54
+ // Typed data accessor
55
+ // -------------------------------------------------------------------------
56
+ /**
57
+ * Returns the data of the current record with type-safe accessors.
58
+ *
59
+ * The `json()` method returns `Promise<T>` — no manual generic needed.
60
+ *
61
+ * @throws `Error` if the record has been deleted.
62
+ */
63
+ get data() {
64
+ const underlying = this._record.data;
65
+ return {
66
+ blob: () => underlying.blob(),
67
+ bytes: () => underlying.bytes(),
68
+ json: () => underlying.json(),
69
+ text: () => underlying.text(),
70
+ stream: () => underlying.stream(),
71
+ then: underlying.then.bind(underlying),
72
+ catch: underlying.catch.bind(underlying),
73
+ };
74
+ }
75
+ // -------------------------------------------------------------------------
76
+ // Typed mutation methods
77
+ // -------------------------------------------------------------------------
78
+ /**
79
+ * Update the current record on the DWN.
80
+ *
81
+ * @param params - Parameters including the typed `data` payload.
82
+ * @returns The status and an updated {@link TypedRecord}.
83
+ * @throws `Error` if the record has been deleted.
84
+ */
85
+ update(params) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const { status, record } = yield this._record.update(params);
88
+ return { status, record: new TypedRecord(record) };
89
+ });
90
+ }
91
+ /**
92
+ * Delete the current record on the DWN.
93
+ *
94
+ * @param params - Delete parameters.
95
+ * @returns The status and a {@link TypedRecord} reflecting the deleted state.
96
+ */
97
+ delete(params) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const { status, record } = yield this._record.delete(params);
100
+ return { status, record: new TypedRecord(record) };
101
+ });
102
+ }
103
+ // -------------------------------------------------------------------------
104
+ // Forwarded lifecycle methods
105
+ // -------------------------------------------------------------------------
106
+ /**
107
+ * Stores the current record state to the owner's DWN.
108
+ *
109
+ * @param importRecord - If true, sign as owner before storing. Defaults to false.
110
+ */
111
+ store() {
112
+ return __awaiter(this, arguments, void 0, function* (importRecord = false) {
113
+ return this._record.store(importRecord);
114
+ });
115
+ }
116
+ /**
117
+ * Signs and optionally stores the record to the owner's DWN.
118
+ * Useful when importing a record signed by someone else.
119
+ *
120
+ * @param store - If true, store after signing. Defaults to true.
121
+ */
122
+ import() {
123
+ return __awaiter(this, arguments, void 0, function* (store = true) {
124
+ return this._record.import(store);
125
+ });
126
+ }
127
+ /**
128
+ * Send the current record to a remote DWN.
129
+ *
130
+ * @param target - Optional DID of the target DWN. Defaults to the connected DID.
131
+ */
132
+ send(target) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ return this._record.send(target);
135
+ });
136
+ }
137
+ /**
138
+ * Returns a JSON representation of the Record instance.
139
+ */
140
+ toJSON() {
141
+ return this._record.toJSON();
142
+ }
143
+ /**
144
+ * Returns a string representation of the Record instance.
145
+ */
146
+ toString() {
147
+ return this._record.toString();
148
+ }
149
+ /**
150
+ * Returns a pagination cursor for the current record given a sort order.
151
+ */
152
+ paginationCursor(sort) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ return this._record.paginationCursor(sort);
155
+ });
156
+ }
157
+ // -------------------------------------------------------------------------
158
+ // Forwarded immutable property getters
159
+ // -------------------------------------------------------------------------
160
+ /** Record's ID. */
161
+ get id() { return this._record.id; }
162
+ /** Record's context ID. */
163
+ get contextId() { return this._record.contextId; }
164
+ /** Record's creation date. */
165
+ get dateCreated() { return this._record.dateCreated; }
166
+ /** Record's parent ID. */
167
+ get parentId() { return this._record.parentId; }
168
+ /** Record's protocol. */
169
+ get protocol() { return this._record.protocol; }
170
+ /** Record's protocol path. */
171
+ get protocolPath() { return this._record.protocolPath; }
172
+ /** Record's recipient. */
173
+ get recipient() { return this._record.recipient; }
174
+ /** Record's schema. */
175
+ get schema() { return this._record.schema; }
176
+ // -------------------------------------------------------------------------
177
+ // Forwarded mutable property getters
178
+ // -------------------------------------------------------------------------
179
+ /** Record's data format. */
180
+ get dataFormat() { return this._record.dataFormat; }
181
+ /** Record's data CID. */
182
+ get dataCid() { return this._record.dataCid; }
183
+ /** Record's data size. */
184
+ get dataSize() { return this._record.dataSize; }
185
+ /** Record's published date. */
186
+ get datePublished() { return this._record.datePublished; }
187
+ /** Record's published status. */
188
+ get published() { return this._record.published; }
189
+ /** Tags of the record. */
190
+ get tags() {
191
+ return this._record.tags;
192
+ }
193
+ // -------------------------------------------------------------------------
194
+ // Forwarded state-dependent property getters
195
+ // -------------------------------------------------------------------------
196
+ /** DID that is the logical author of the Record. */
197
+ get author() { return this._record.author; }
198
+ /** DID that is the original creator of the Record. */
199
+ get creator() { return this._record.creator; }
200
+ /** Record's message timestamp. */
201
+ get timestamp() { return this._record.timestamp; }
202
+ /** Record's encryption details. */
203
+ get encryption() {
204
+ return this._record.encryption;
205
+ }
206
+ /** Record's authorization. */
207
+ get authorization() {
208
+ return this._record.authorization;
209
+ }
210
+ /** Record's attestation. */
211
+ get attestation() {
212
+ return this._record.attestation;
213
+ }
214
+ /** Role under which the author is writing the record. */
215
+ get protocolRole() { return this._record.protocolRole; }
216
+ /** Record's deleted state. */
217
+ get deleted() { return this._record.deleted; }
218
+ /** Record's initial write if the record has been updated. */
219
+ get initialWrite() {
220
+ return this._record.initialWrite;
221
+ }
222
+ /** The raw DWN message backing this record. */
223
+ get rawMessage() {
224
+ return this._record.rawMessage;
225
+ }
226
+ }
227
+ //# sourceMappingURL=typed-record.js.map
@@ -0,0 +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,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE;YAC/C,KAAK,EAAI,GAAwB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE;YACtD,IAAI,EAAK,GAAe,EAAE,CAAC,UAAU,CAAC,IAAI,EAAK;YAC/C,IAAI,EAAK,GAAoB,EAAE,CAAC,UAAU,CAAC,IAAI,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O,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9D,6DAA6D;IAC7D,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;IACnC,CAAC;IAED,+CAA+C;IAC/C,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACjC,CAAC;CACF"}
@@ -6,6 +6,10 @@
6
6
  * and schema into every operation, and provides compile-time path
7
7
  * autocompletion plus typed data payloads via the schema map.
8
8
  *
9
+ * All record-returning methods wrap the underlying `Record` instances in
10
+ * {@link TypedRecord} so that type information flows through reads, queries,
11
+ * updates, and subscriptions without manual casts.
12
+ *
9
13
  * @example
10
14
  * ```ts
11
15
  * const social = web5.using(SocialProtocol);
@@ -13,17 +17,23 @@
13
17
  * // Install the protocol
14
18
  * await social.configure();
15
19
  *
16
- * // Write — path and data type are checked at compile time
17
- * const { record } = await social.records.write('thread', {
20
+ * // Create — path and data type are checked at compile time
21
+ * const { record } = await social.records.create('thread', {
18
22
  * data: { title: 'Hello World', body: '...' },
19
23
  * });
24
+ * // record is TypedRecord<ThreadData>
25
+ *
26
+ * const data = await record.data.json(); // ThreadData — no cast needed
20
27
  *
21
28
  * // Query — protocol and protocolPath are auto-injected
22
29
  * const { records } = await social.records.query('thread');
30
+ * // records is TypedRecord<ThreadData>[]
23
31
  *
24
- * // Subscribe — real-time changes via LiveQuery
32
+ * // Subscribe — real-time changes via TypedLiveQuery
25
33
  * const { liveQuery } = await social.records.subscribe('thread/reply');
26
- * liveQuery.on('create', (record) => { ... });
34
+ * liveQuery.on('create', (record) => {
35
+ * // record is TypedRecord<ReplyData>
36
+ * });
27
37
  * ```
28
38
  */
29
39
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -35,6 +45,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
35
45
  step((generator = generator.apply(thisArg, _arguments || [])).next());
36
46
  });
37
47
  };
48
+ import { TypedLiveQuery } from './typed-live-query.js';
49
+ import { TypedRecord } from './typed-record.js';
38
50
  // ---------------------------------------------------------------------------
39
51
  // TypedWeb5 class
40
52
  // ---------------------------------------------------------------------------
@@ -42,6 +54,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42
54
  * A protocol-scoped API that auto-injects `protocol`, `protocolPath`, and
43
55
  * `schema` into every DWN operation.
44
56
  *
57
+ * All record-returning methods wrap results in {@link TypedRecord} so that
58
+ * the data type `T` (resolved from the schema map) flows end-to-end — from
59
+ * write through read, query, update, and subscribe — without manual casts.
60
+ *
45
61
  * Obtain an instance via `web5.using(typedProtocol)`.
46
62
  *
47
63
  * @example
@@ -50,19 +66,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
50
66
  *
51
67
  * await social.configure();
52
68
  *
53
- * const { record } = await social.records.write('friend', {
69
+ * const { record } = await social.records.create('friend', {
54
70
  * data: { did: 'did:example:alice', alias: 'Alice' },
55
71
  * });
72
+ * const data = await record.data.json(); // FriendData — no cast
56
73
  *
57
74
  * const { records } = await social.records.query('friend', {
58
75
  * filter: { tags: { did: 'did:example:alice' } },
59
76
  * });
77
+ * for (const r of records) {
78
+ * const d = await r.data.json(); // FriendData
79
+ * }
60
80
  * ```
61
81
  */
62
82
  export class TypedWeb5 {
63
83
  constructor(dwn, protocol) {
84
+ this._configured = false;
64
85
  this._dwn = dwn;
65
86
  this._definition = protocol.definition;
87
+ this._validPaths = collectPaths(this._definition.structure);
66
88
  }
67
89
  /** The protocol URI. */
68
90
  get protocol() {
@@ -92,36 +114,71 @@ export class TypedWeb5 {
92
114
  if (protocols.length > 0) {
93
115
  const existing = protocols[0];
94
116
  if (definitionsEqual(existing.definition, this._definition)) {
117
+ this._configured = true;
95
118
  return { status: { code: 200, detail: 'OK' }, protocol: existing };
96
119
  }
97
120
  }
98
121
  // Not installed or definition has changed — configure the new version.
99
- return this._dwn.protocols.configure({
122
+ const result = yield this._dwn.protocols.configure({
100
123
  definition: this._definition,
101
124
  encryption: options === null || options === void 0 ? void 0 : options.encryption,
102
125
  });
126
+ if (result.status.code === 202) {
127
+ this._configured = true;
128
+ }
129
+ return result;
103
130
  });
104
131
  }
132
+ /** Whether the protocol has been configured (installed) on the local DWN. */
133
+ get isConfigured() {
134
+ return this._configured;
135
+ }
136
+ /**
137
+ * Validates that the protocol has been configured and that the path is
138
+ * recognized. Throws a descriptive error if either check fails.
139
+ */
140
+ _assertReady(path) {
141
+ if (!this._configured) {
142
+ throw new Error(`TypedWeb5: protocol '${this._definition.protocol}' has not been configured. ` +
143
+ 'Call configure() before performing record operations.');
144
+ }
145
+ if (!this._validPaths.has(path)) {
146
+ throw new Error(`TypedWeb5: invalid protocol path '${path}'. ` +
147
+ `Valid paths are: ${[...this._validPaths].join(', ')}.`);
148
+ }
149
+ }
105
150
  /**
106
151
  * Protocol-scoped record operations.
107
152
  *
108
153
  * Every method auto-injects the protocol URI, protocolPath, and schema
109
154
  * from the protocol definition. Path parameters provide compile-time
110
155
  * autocompletion via `ProtocolPaths<D>`.
156
+ *
157
+ * All methods return {@link TypedRecord} or {@link TypedLiveQuery} instances
158
+ * that carry the resolved data type from the schema map.
111
159
  */
112
160
  get records() {
113
- return {
161
+ if (this._records !== undefined) {
162
+ return this._records;
163
+ }
164
+ const cached = {
114
165
  /**
115
- * Write a record at the given protocol path.
166
+ * Create a new record at the given protocol path.
116
167
  *
117
168
  * @param path - The protocol path (e.g. `'friend'`, `'group/member'`).
118
- * @param request - Write options including typed `data`.
169
+ * @param request - Create options including typed `data`.
119
170
  */
120
- write: (path, request) => __awaiter(this, void 0, void 0, function* () {
171
+ create: (path, request) => __awaiter(this, void 0, void 0, function* () {
121
172
  var _a, _b;
122
- const typeName = lastSegment(path);
173
+ const normalizedPath = normalizePath(path);
174
+ this._assertReady(normalizedPath);
175
+ const typeName = lastSegment(normalizedPath);
123
176
  const typeEntry = this._definition.types[typeName];
124
- return this._dwn.records.write(Object.assign(Object.assign({ data: request.data, store: request.store, encryption: request.encryption, parentContextId: request.parentContextId, published: request.published, datePublished: request.datePublished, recipient: request.recipient, protocolRole: request.protocolRole, tags: request.tags, protocol: this._definition.protocol, protocolPath: path }, ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})), { dataFormat: (_a = request.dataFormat) !== null && _a !== void 0 ? _a : (_b = typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.dataFormats) === null || _b === void 0 ? void 0 : _b[0] }));
177
+ const { status, record } = yield this._dwn.records.write(Object.assign(Object.assign({ data: request.data, store: request.store, encryption: request.encryption, parentContextId: request.parentContextId, published: request.published, datePublished: request.datePublished, recipient: request.recipient, protocolRole: request.protocolRole, tags: request.tags, protocol: this._definition.protocol, protocolPath: normalizedPath }, ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})), { dataFormat: (_a = request.dataFormat) !== null && _a !== void 0 ? _a : (_b = typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.dataFormats) === null || _b === void 0 ? void 0 : _b[0] }));
178
+ return {
179
+ status,
180
+ record: new TypedRecord(record),
181
+ };
125
182
  }),
126
183
  /**
127
184
  * Query records at the given protocol path.
@@ -130,16 +187,23 @@ export class TypedWeb5 {
130
187
  * @param request - Optional filter, sort, and pagination.
131
188
  */
132
189
  query: (path, request) => __awaiter(this, void 0, void 0, function* () {
133
- const typeName = lastSegment(path);
190
+ const normalizedPath = normalizePath(path);
191
+ this._assertReady(normalizedPath);
192
+ const typeName = lastSegment(normalizedPath);
134
193
  const typeEntry = this._definition.types[typeName];
135
- return this._dwn.records.query({
194
+ const { status, records, cursor } = yield this._dwn.records.query({
136
195
  from: request === null || request === void 0 ? void 0 : request.from,
137
196
  encryption: request === null || request === void 0 ? void 0 : request.encryption,
138
- filter: Object.assign(Object.assign(Object.assign({}, request === null || request === void 0 ? void 0 : request.filter), { protocol: this._definition.protocol, protocolPath: path }), ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})),
197
+ filter: Object.assign(Object.assign(Object.assign({}, request === null || request === void 0 ? void 0 : request.filter), { protocol: this._definition.protocol, protocolPath: normalizedPath }), ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})),
139
198
  dateSort: request === null || request === void 0 ? void 0 : request.dateSort,
140
199
  pagination: request === null || request === void 0 ? void 0 : request.pagination,
141
200
  protocolRole: request === null || request === void 0 ? void 0 : request.protocolRole,
142
201
  });
202
+ return {
203
+ status,
204
+ records: records.map((r) => new TypedRecord(r)),
205
+ cursor,
206
+ };
143
207
  }),
144
208
  /**
145
209
  * Read a single record at the given protocol path.
@@ -148,14 +212,20 @@ export class TypedWeb5 {
148
212
  * @param request - Read options including a filter to identify the record.
149
213
  */
150
214
  read: (path, request) => __awaiter(this, void 0, void 0, function* () {
151
- const typeName = lastSegment(path);
215
+ const normalizedPath = normalizePath(path);
216
+ this._assertReady(normalizedPath);
217
+ const typeName = lastSegment(normalizedPath);
152
218
  const typeEntry = this._definition.types[typeName];
153
- return this._dwn.records.read({
219
+ const { status, record } = yield this._dwn.records.read({
154
220
  from: request.from,
155
221
  encryption: request.encryption,
156
222
  protocol: this._definition.protocol,
157
- filter: Object.assign(Object.assign(Object.assign({}, request.filter), { protocol: this._definition.protocol, protocolPath: path }), ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})),
223
+ filter: Object.assign(Object.assign(Object.assign({}, request.filter), { protocol: this._definition.protocol, protocolPath: normalizedPath }), ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})),
158
224
  });
225
+ return {
226
+ status,
227
+ record: new TypedRecord(record),
228
+ };
159
229
  }),
160
230
  /**
161
231
  * Delete a record at the given protocol path.
@@ -164,6 +234,7 @@ export class TypedWeb5 {
164
234
  * @param request - Delete options including the `recordId`.
165
235
  */
166
236
  delete: (_path, request) => __awaiter(this, void 0, void 0, function* () {
237
+ this._assertReady(normalizePath(_path));
167
238
  return this._dwn.records.delete({
168
239
  from: request.from,
169
240
  protocol: this._definition.protocol,
@@ -173,22 +244,31 @@ export class TypedWeb5 {
173
244
  /**
174
245
  * Subscribe to records at the given protocol path.
175
246
  *
176
- * Returns a {@link LiveQuery} that atomically provides an initial snapshot
177
- * and a real-time stream of deduplicated change events.
247
+ * Returns a {@link TypedLiveQuery} that atomically provides an initial
248
+ * snapshot and a real-time stream of deduplicated change events, with
249
+ * all records typed as `TypedRecord<T>`.
178
250
  *
179
251
  * @param path - The protocol path to subscribe to.
180
252
  * @param request - Optional filter and role.
181
253
  */
182
254
  subscribe: (path, request) => __awaiter(this, void 0, void 0, function* () {
183
- const typeName = lastSegment(path);
255
+ const normalizedPath = normalizePath(path);
256
+ this._assertReady(normalizedPath);
257
+ const typeName = lastSegment(normalizedPath);
184
258
  const typeEntry = this._definition.types[typeName];
185
- return this._dwn.records.subscribe({
259
+ const { status, liveQuery } = yield this._dwn.records.subscribe({
186
260
  from: request === null || request === void 0 ? void 0 : request.from,
187
- filter: Object.assign(Object.assign(Object.assign({}, request === null || request === void 0 ? void 0 : request.filter), { protocol: this._definition.protocol, protocolPath: path }), ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})),
261
+ filter: Object.assign(Object.assign(Object.assign({}, request === null || request === void 0 ? void 0 : request.filter), { protocol: this._definition.protocol, protocolPath: normalizedPath }), ((typeEntry === null || typeEntry === void 0 ? void 0 : typeEntry.schema) !== undefined ? { schema: typeEntry.schema } : {})),
188
262
  protocolRole: request === null || request === void 0 ? void 0 : request.protocolRole,
189
263
  });
264
+ return {
265
+ status,
266
+ liveQuery: liveQuery ? new TypedLiveQuery(liveQuery) : undefined,
267
+ };
190
268
  }),
191
269
  };
270
+ this._records = cached;
271
+ return cached;
192
272
  }
193
273
  }
194
274
  // ---------------------------------------------------------------------------
@@ -204,6 +284,14 @@ export class TypedWeb5 {
204
284
  function definitionsEqual(a, b) {
205
285
  return stableStringify(a) === stableStringify(b);
206
286
  }
287
+ /**
288
+ * Strips leading and trailing slashes from a path.
289
+ *
290
+ * `'friend/'` → `'friend'`, `'/group/member/'` → `'group/member'`.
291
+ */
292
+ function normalizePath(path) {
293
+ return path.replace(/^\/+|\/+$/g, '');
294
+ }
207
295
  /**
208
296
  * Returns the last segment of a slash-delimited path.
209
297
  */
@@ -211,6 +299,29 @@ function lastSegment(path) {
211
299
  const parts = path.split('/');
212
300
  return parts[parts.length - 1];
213
301
  }
302
+ /**
303
+ * Recursively collects all valid protocol path strings from a structure object.
304
+ *
305
+ * Given `{ foo: { bar: { $actions: [...] } } }`, returns `Set(['foo', 'foo/bar'])`.
306
+ * Keys starting with `$` are skipped.
307
+ */
308
+ function collectPaths(structure, prefix = '') {
309
+ const paths = new Set();
310
+ for (const key of Object.keys(structure)) {
311
+ if (key.startsWith('$')) {
312
+ continue;
313
+ }
314
+ const fullPath = prefix ? `${prefix}/${key}` : key;
315
+ paths.add(fullPath);
316
+ const child = structure[key];
317
+ if (child !== null && typeof child === 'object') {
318
+ for (const nested of collectPaths(child, fullPath)) {
319
+ paths.add(nested);
320
+ }
321
+ }
322
+ }
323
+ return paths;
324
+ }
214
325
  /**
215
326
  * Deterministic JSON serialization with sorted keys.
216
327
  */
@@ -1 +1 @@
1
- {"version":3,"file":"typed-web5.js","sourceRoot":"","sources":["../../src/typed-web5.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;AAwJH,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,SAAS;IAOpB,YAAY,GAAW,EAAE,QAA6B;QACpD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;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