@abraca/dabra 2.5.0 → 2.7.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
@@ -821,6 +821,62 @@ declare class AbracadabraClient {
821
821
  role: string | null;
822
822
  }>;
823
823
  }>;
824
+ /**
825
+ * List `service`-role users (runners, demo seeders, automation
826
+ * identities). Requires Service role. Admins can see service users via
827
+ * `/admin/users` too but cannot mint or rotate them.
828
+ */
829
+ adminListServiceAccounts(): Promise<{
830
+ items: Array<{
831
+ id: string;
832
+ username: string;
833
+ public_key: string | null;
834
+ revoked: boolean;
835
+ display_name: string | null;
836
+ }>;
837
+ }>;
838
+ /**
839
+ * Create a new `service`-role user. When `public_key` is omitted the
840
+ * server generates a keypair and returns the private half in the
841
+ * response — show it to the operator **once** and discard; the server
842
+ * never persists it. Requires Service role.
843
+ */
844
+ adminCreateServiceAccount(body: {
845
+ username: string;
846
+ public_key?: string;
847
+ }): Promise<{
848
+ id: string;
849
+ username: string;
850
+ public_key: string;
851
+ role: string;
852
+ private_key?: string;
853
+ }>;
854
+ /**
855
+ * Rotate the active keypair on a service account. Old JWTs are
856
+ * invalidated; old device keys are marked revoked; the canonical
857
+ * `users.public_key` swaps to the new value. `users.id` stays put so
858
+ * existing permission rows keep matching. Returns the new pubkey (and
859
+ * private half when the server generated it). Requires Service role.
860
+ */
861
+ adminRotateServiceAccountKey(userId: string, body?: {
862
+ public_key?: string;
863
+ }): Promise<{
864
+ id: string;
865
+ public_key: string;
866
+ private_key?: string;
867
+ }>;
868
+ /**
869
+ * Lock a service account and revoke all of its device keys. Idempotent.
870
+ * Refuses targets whose `users.role` isn't `"service"`. Requires
871
+ * Service role.
872
+ */
873
+ adminRevokeServiceAccount(userId: string): Promise<void>;
874
+ /**
875
+ * Revoke a single device key on a user (any role). Bumps
876
+ * `tokens_invalid_before` so open WS sessions tied to the key must
877
+ * re-auth. Requires elevated role (Service or Admin@root).
878
+ */
879
+ adminRevokeDeviceKey(userId: string, keyId: string): Promise<void>;
824
880
  /**
825
881
  * Page through the audit log. Filters AND-combine; `limit` defaults to
826
882
  * 100 server-side. Requires elevated role.
@@ -4929,8 +4985,13 @@ declare class ContentManager {
4929
4985
  constructor(dm: DocumentManager);
4930
4986
  /**
4931
4987
  * Read document content as markdown.
4932
- * Returns the title extracted from the TipTap documentHeader, the markdown
4933
- * body, tree metadata, and immediate children.
4988
+ *
4989
+ * Returns the markdown body, tree-derived label/type/meta, and immediate
4990
+ * children. `title` mirrors `label` (the tree entry's display name) — it
4991
+ * is *not* derived from a TipTap `documentHeader`, and the markdown body
4992
+ * does NOT include YAML frontmatter. Callers that want frontmatter-style
4993
+ * round-tripping should serialise `meta`/`type` themselves on top of the
4994
+ * returned markdown.
4934
4995
  */
4935
4996
  read(docId: string): Promise<DocumentContent>;
4936
4997
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/dabra",
3
- "version": "2.5.0",
3
+ "version": "2.7.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.5.0"
44
+ "@abraca/schema": "2.7.0"
45
45
  },
46
46
  "scripts": {
47
47
  "test": "node --no-warnings --conditions=source --experimental-transform-types --test 'tests/*.test.ts'"
@@ -14,6 +14,7 @@ import { StatelessMessage } from "./OutgoingMessages/StatelessMessage.ts";
14
14
  import { RpcClient } from "./RpcClient.ts";
15
15
  import { QueryClient } from "./QueryClient.ts";
16
16
  import type { QuerySpec, QuerySubscriptionHandlers, QuerySubscriptionHandle } from "./QueryClient.ts";
17
+ import { QueryAwarenessMessage } from "./OutgoingMessages/QueryAwarenessMessage.ts";
17
18
  import { SyncStepOneMessage } from "./OutgoingMessages/SyncStepOneMessage.ts";
18
19
  import { UpdateMessage } from "./OutgoingMessages/UpdateMessage.ts";
19
20
  import type {
@@ -516,6 +517,20 @@ export class AbracadabraBaseProvider extends EventEmitter {
516
517
  documentName: this.configuration.name,
517
518
  });
518
519
  }
520
+
521
+ // Pull existing peers' awareness on (re)connect. The server keeps no
522
+ // awareness cache and never replays presence to a fresh joiner, so without
523
+ // this a late-joining client only learns about a peer once that peer next
524
+ // *changes* its own awareness — producing asymmetric presence ("A sees B
525
+ // but B can't see A"). The server re-broadcasts this query to all peers,
526
+ // who answer with their full state (MessageReceiver.applyQueryAwareness),
527
+ // and those replies fan back to us. Matches stock y-websocket on-open
528
+ // behaviour. Only meaningful when an awareness instance exists.
529
+ if (this.awareness) {
530
+ this.send(QueryAwarenessMessage, {
531
+ documentName: this.configuration.name,
532
+ });
533
+ }
519
534
  }
520
535
 
521
536
  send(message: ConstructableOutgoingMessage, args: any) {
@@ -1194,6 +1194,84 @@ export class AbracadabraClient {
1194
1194
  );
1195
1195
  }
1196
1196
 
1197
+ /**
1198
+ * List `service`-role users (runners, demo seeders, automation
1199
+ * identities). Requires Service role. Admins can see service users via
1200
+ * `/admin/users` too but cannot mint or rotate them.
1201
+ */
1202
+ async adminListServiceAccounts(): Promise<{
1203
+ items: Array<{
1204
+ id: string;
1205
+ username: string;
1206
+ public_key: string | null;
1207
+ revoked: boolean;
1208
+ display_name: string | null;
1209
+ }>;
1210
+ }> {
1211
+ return this.request("GET", "/admin/service-accounts");
1212
+ }
1213
+
1214
+ /**
1215
+ * Create a new `service`-role user. When `public_key` is omitted the
1216
+ * server generates a keypair and returns the private half in the
1217
+ * response — show it to the operator **once** and discard; the server
1218
+ * never persists it. Requires Service role.
1219
+ */
1220
+ async adminCreateServiceAccount(body: {
1221
+ username: string;
1222
+ public_key?: string;
1223
+ }): Promise<{
1224
+ id: string;
1225
+ username: string;
1226
+ public_key: string;
1227
+ role: string;
1228
+ private_key?: string;
1229
+ }> {
1230
+ return this.request("POST", "/admin/service-accounts", { body });
1231
+ }
1232
+
1233
+ /**
1234
+ * Rotate the active keypair on a service account. Old JWTs are
1235
+ * invalidated; old device keys are marked revoked; the canonical
1236
+ * `users.public_key` swaps to the new value. `users.id` stays put so
1237
+ * existing permission rows keep matching. Returns the new pubkey (and
1238
+ * private half when the server generated it). Requires Service role.
1239
+ */
1240
+ async adminRotateServiceAccountKey(
1241
+ userId: string,
1242
+ body: { public_key?: string } = {},
1243
+ ): Promise<{ id: string; public_key: string; private_key?: string }> {
1244
+ return this.request(
1245
+ "POST",
1246
+ `/admin/service-accounts/${encodeURIComponent(userId)}/rotate-key`,
1247
+ { body },
1248
+ );
1249
+ }
1250
+
1251
+ /**
1252
+ * Lock a service account and revoke all of its device keys. Idempotent.
1253
+ * Refuses targets whose `users.role` isn't `"service"`. Requires
1254
+ * Service role.
1255
+ */
1256
+ async adminRevokeServiceAccount(userId: string): Promise<void> {
1257
+ await this.request(
1258
+ "DELETE",
1259
+ `/admin/service-accounts/${encodeURIComponent(userId)}`,
1260
+ );
1261
+ }
1262
+
1263
+ /**
1264
+ * Revoke a single device key on a user (any role). Bumps
1265
+ * `tokens_invalid_before` so open WS sessions tied to the key must
1266
+ * re-auth. Requires elevated role (Service or Admin@root).
1267
+ */
1268
+ async adminRevokeDeviceKey(userId: string, keyId: string): Promise<void> {
1269
+ await this.request(
1270
+ "POST",
1271
+ `/admin/users/${encodeURIComponent(userId)}/device-keys/${encodeURIComponent(keyId)}/revoke`,
1272
+ );
1273
+ }
1274
+
1197
1275
  /**
1198
1276
  * Page through the audit log. Filters AND-combine; `limit` defaults to
1199
1277
  * 100 server-side. Requires elevated role.
@@ -44,8 +44,13 @@ export class ContentManager {
44
44
 
45
45
  /**
46
46
  * Read document content as markdown.
47
- * Returns the title extracted from the TipTap documentHeader, the markdown
48
- * body, tree metadata, and immediate children.
47
+ *
48
+ * Returns the markdown body, tree-derived label/type/meta, and immediate
49
+ * children. `title` mirrors `label` (the tree entry's display name) — it
50
+ * is *not* derived from a TipTap `documentHeader`, and the markdown body
51
+ * does NOT include YAML frontmatter. Callers that want frontmatter-style
52
+ * round-tripping should serialise `meta`/`type` themselves on top of the
53
+ * returned markdown.
49
54
  */
50
55
  async read(docId: string): Promise<DocumentContent> {
51
56
  const provider = await this.dm.getChildProvider(docId);
@@ -95,10 +100,7 @@ export class ContentManager {
95
100
  meta,
96
101
  }));
97
102
 
98
- // yjsToMarkdown returns a string and takes the resolved label/meta/type
99
- // so frontmatter round-trips. (Older code destructured an object and
100
- // passed only the fragment — that silently produced `undefined`.)
101
- const markdown = yjsToMarkdown(fragment, label, meta, type);
103
+ const { markdown } = yjsToMarkdown(fragment);
102
104
  const title = label;
103
105
 
104
106
  return { label, type, meta, title, markdown, children };