@abraca/dabra 2.31.0 → 2.32.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/dist/index.d.ts CHANGED
@@ -1934,8 +1934,26 @@ interface SearchResult {
1934
1934
  interface DocSearchHit {
1935
1935
  doc_id: string;
1936
1936
  parent_id: string | null;
1937
- label: string | null;
1937
+ /**
1938
+ * Structural role tag (`space`/`page`/`channel`/…) — what the doc *is*,
1939
+ * not how it renders. See {@link doc_type} for the renderer/page type.
1940
+ */
1938
1941
  kind: string | null;
1942
+ label: string | null;
1943
+ /**
1944
+ * Renderer / page type (`kanban`/`graph`/`calendar`/…), surfaced by the
1945
+ * server from `documents.doc_type` or the CRDT-derived
1946
+ * `doc_meta_index.kind`. Use this as the renderer hint when opening a hit.
1947
+ * Absent from older servers and for plain docs.
1948
+ */
1949
+ doc_type?: string | null;
1950
+ /**
1951
+ * The top-level space (`kind: "space"`) that contains this hit, resolved
1952
+ * server-side by walking the CRDT tree. Lets a client jump straight to the
1953
+ * space without a client-side parent walk. Absent from older servers or
1954
+ * when no `kind="space"` ancestor was found.
1955
+ */
1956
+ space_id?: string | null;
1939
1957
  /** HTML-safe snippet with `<mark>` markers around the matched tokens. */
1940
1958
  snippet: string;
1941
1959
  rank: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/dabra",
3
- "version": "2.31.0",
3
+ "version": "2.32.0",
4
4
  "description": "abracadabra provider",
5
5
  "keywords": [
6
6
  "abracadabra",
@@ -41,7 +41,7 @@
41
41
  "yjs": "^13.6.8"
42
42
  },
43
43
  "devDependencies": {
44
- "@abraca/schema": "2.31.0"
44
+ "@abraca/schema": "2.32.0"
45
45
  },
46
46
  "scripts": {
47
47
  "test": "node --no-warnings --conditions=source --experimental-transform-types --test 'tests/*.test.ts'"
@@ -178,6 +178,14 @@ export class DeviceRegistrationService {
178
178
 
179
179
  const devicesMap = identityDoc.devicesMap;
180
180
 
181
+ // Pending revocations are collected during the (synchronous) scan and
182
+ // executed AFTER it — never fire-and-forget inside the forEach. The old
183
+ // code kicked off `client.revokeKey(...)` without awaiting, so reconcile
184
+ // resolved before the revoke landed: the caller's next request then
185
+ // raced the in-flight revoke and ran with a token the revoke had just
186
+ // invalidated server-side (revoke re-mints + bumps tokens_invalid_before).
187
+ const pendingRevocations: { devicePub: string; keyId: string }[] = [];
188
+
181
189
  // 1. Verify Y.Doc matches server reality
182
190
  devicesMap.forEach((yEntry, devicePub) => {
183
191
  const serversYMap = yEntry.get("servers") as
@@ -211,22 +219,28 @@ export class DeviceRegistrationService {
211
219
  });
212
220
  }
213
221
 
214
- // Execute pending revocation if we're a master device
222
+ // Queue revocation if we're a master device — executed (awaited)
223
+ // after the scan, below.
215
224
  if (revokedAt && isMaster) {
216
- client
217
- .revokeKey(serverKey.id)
218
- .then(() => {
219
- identityDoc.setDeviceServerStatus(
220
- devicePub,
221
- serverUrl,
222
- { registered: false },
223
- );
224
- })
225
- .catch(() => {});
225
+ pendingRevocations.push({ devicePub, keyId: serverKey.id });
226
226
  }
227
227
  }
228
228
  });
229
229
 
230
+ // Execute queued revocations serially so each `revokeKey` captures the
231
+ // re-minted token (revokeKey updates the client's token) before the next
232
+ // call — and so reconcile only resolves once they have actually landed.
233
+ for (const { devicePub, keyId } of pendingRevocations) {
234
+ try {
235
+ await client.revokeKey(keyId);
236
+ identityDoc.setDeviceServerStatus(devicePub, serverUrl, {
237
+ registered: false,
238
+ });
239
+ } catch {
240
+ // Leave Y.Doc as-is; the next reconcile retries.
241
+ }
242
+ }
243
+
230
244
  // 2. Import unknown server keys into Y.Doc (migration)
231
245
  for (const key of serverKeys) {
232
246
  if (key.revoked) continue;
package/src/types.ts CHANGED
@@ -421,8 +421,26 @@ export interface SearchResult {
421
421
  export interface DocSearchHit {
422
422
  doc_id: string;
423
423
  parent_id: string | null;
424
- label: string | null;
424
+ /**
425
+ * Structural role tag (`space`/`page`/`channel`/…) — what the doc *is*,
426
+ * not how it renders. See {@link doc_type} for the renderer/page type.
427
+ */
425
428
  kind: string | null;
429
+ label: string | null;
430
+ /**
431
+ * Renderer / page type (`kanban`/`graph`/`calendar`/…), surfaced by the
432
+ * server from `documents.doc_type` or the CRDT-derived
433
+ * `doc_meta_index.kind`. Use this as the renderer hint when opening a hit.
434
+ * Absent from older servers and for plain docs.
435
+ */
436
+ doc_type?: string | null;
437
+ /**
438
+ * The top-level space (`kind: "space"`) that contains this hit, resolved
439
+ * server-side by walking the CRDT tree. Lets a client jump straight to the
440
+ * space without a client-side parent walk. Absent from older servers or
441
+ * when no `kind="space"` ancestor was found.
442
+ */
443
+ space_id?: string | null;
426
444
  /** HTML-safe snippet with `<mark>` markers around the matched tokens. */
427
445
  snippet: string;
428
446
  rank: number;