@atproto/dev-env 0.5.20 → 0.5.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atproto/dev-env
2
2
 
3
+ ## 0.5.22
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4179](https://github.com/bluesky-social/atproto/pull/4179) [`85c25ef`](https://github.com/bluesky-social/atproto/commit/85c25efde14c1d0383f32bba21b21bdad2ae2619) Thanks [@rafaeleyng](https://github.com/rafaeleyng)! - Subscribe to the real bsync service in dev-env instead of using a mock, with a `BsyncSubscription` on the bsky dataplane that consumes the mute, notif, and operation streams. Supports immediate shutdown (aborting in-flight long-polls) and cursor-based draining so tests stay fast.
8
+
9
+ - Updated dependencies [[`f2a0efe`](https://github.com/bluesky-social/atproto/commit/f2a0efe11140c8bebe488ac1f737e242d7f23f0b), [`7f88ef3`](https://github.com/bluesky-social/atproto/commit/7f88ef3a37b81a35cdb727c1daee00dfe89db6ca), [`45278fd`](https://github.com/bluesky-social/atproto/commit/45278fd367ee50654ac5d09bd6da1451c8b0cd98), [`f2a0efe`](https://github.com/bluesky-social/atproto/commit/f2a0efe11140c8bebe488ac1f737e242d7f23f0b), [`85c25ef`](https://github.com/bluesky-social/atproto/commit/85c25efde14c1d0383f32bba21b21bdad2ae2619)]:
10
+ - @atproto/xrpc-server@0.11.4
11
+ - @atproto/bsky@0.0.250
12
+ - @atproto/api@0.20.23
13
+ - @atproto/bsync@0.0.32
14
+ - @atproto/ozone@0.2.8
15
+ - @atproto/pds@0.5.11
16
+ - @atproto/sync@0.3.5
17
+
18
+ ## 0.5.21
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies []:
23
+ - @atproto/pds@0.5.10
24
+
3
25
  ## 0.5.20
4
26
 
5
27
  ### Patch Changes
package/dist/bin.js CHANGED
@@ -42,6 +42,7 @@ const run = async () => {
42
42
  console.log(`šŸ”Ø Lexicon authority DID ${network.pds.ctx.cfg.lexicon.didAuthority}`);
43
43
  console.log(`šŸ—¼ Ozone server http://localhost:${network.ozone.port}`);
44
44
  console.log(`šŸ—¼ Ozone service DID ${network.ozone.ctx.cfg.service.did}`);
45
+ console.log(`šŸ”„ Bsync server http://localhost:${network.bsync.port}`);
45
46
  console.log(`šŸŒ… Bsky Appview http://localhost:${network.bsky.port}`);
46
47
  console.log(`šŸŒ… Bsky Appview DID ${network.bsky.serverDid}`);
47
48
  for (const fg of network.feedGens) {
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,CAAA;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE;IACrB,OAAO,CAAC,GAAG,CAAC;;;;;;;;uBAQS,CAAC,CAAA;IAEtB,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC;QACvC,GAAG,EAAE;YACH,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,WAAW;YACrB,uBAAuB,EAAE,IAAI;SAC9B;QACD,IAAI,EAAE;YACJ,gBAAgB,EAAE,MAAM;YACxB,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,uBAAuB;SACnC;QACD,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACnB,KAAK,EAAE;YACL,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,uBAAuB,EAAE,iCAAiC;YACnE,OAAO,EAAE,kBAAkB;YAC3B,mCAAmC,EAAE,MAAM;SAC5C;QACD,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KAC3B,CAAC,CAAA;IACF,UAAU,CAAC,OAAO,CAAC,GA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ChC,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAA;AAC/C,CAAC,CAAA;AAED,GAAG,EAAE,CAAA","sourcesContent":["import './env.js'\nimport { generateMockSetup } from './mock/index.js'\nimport { TestNetwork } from './network.js'\nimport { mockMailer } from './util.js'\n\nconst run = async () => {\n console.log(`\nā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā•—\nā–ˆā–ˆā•”ā•ā•ā•ā–ˆā–ˆā•—\nā–ˆā–ˆā•‘ā–ˆā–ˆā•—ā–ˆā–ˆā•‘\nā–ˆā–ˆā•‘ā–ˆā–ˆā•‘ā–ˆā–ˆā•‘\nā•šā–ˆā•‘ā–ˆā–ˆā–ˆā–ˆā•”ā•\n ā•šā•ā•šā•ā•ā•ā• protocol\n\n[ created by Bluesky ]`)\n\n const network = await TestNetwork.create({\n pds: {\n port: 2583,\n hostname: 'localhost',\n enableDidDocWithSession: true,\n },\n bsky: {\n dbPostgresSchema: 'bsky',\n port: 2584,\n publicUrl: 'http://localhost:2584',\n },\n plc: { port: 2582 },\n ozone: {\n port: 2587,\n chatUrl: 'http://localhost:2590', // must run separate chat service\n chatDid: 'did:example:chat',\n dbMaterializedViewRefreshIntervalMs: 30_000,\n },\n introspect: { port: 2581 },\n })\n mockMailer(network.pds)\n\n if (network.introspect) {\n console.log(\n `šŸ” Dev-env introspection server http://localhost:${network.introspect.port}`,\n )\n }\n console.log(`šŸ‘¤ DID Placeholder server http://localhost:${network.plc.port}`)\n console.log(`šŸŒž Main PDS http://localhost:${network.pds.port}`)\n console.log(`šŸŒž Main PDS account DB`, network.pds.ctx.cfg.db.accountDbLoc)\n console.log(\n `šŸ”Ø Lexicon authority DID ${network.pds.ctx.cfg.lexicon.didAuthority}`,\n )\n console.log(`šŸ—¼ Ozone server http://localhost:${network.ozone.port}`)\n console.log(`šŸ—¼ Ozone service DID ${network.ozone.ctx.cfg.service.did}`)\n console.log(`šŸŒ… Bsky Appview http://localhost:${network.bsky.port}`)\n console.log(`šŸŒ… Bsky Appview DID ${network.bsky.serverDid}`)\n for (const fg of network.feedGens) {\n console.log(`šŸ¤– Feed Generator (${fg.did}) http://localhost:${fg.port}`)\n }\n\n console.time('āœ… Dev environment is ready')\n await generateMockSetup(network)\n console.timeEnd('āœ… Dev environment is ready')\n}\n\nrun()\n"]}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,CAAA;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE;IACrB,OAAO,CAAC,GAAG,CAAC;;;;;;;;uBAQS,CAAC,CAAA;IAEtB,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC;QACvC,GAAG,EAAE;YACH,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,WAAW;YACrB,uBAAuB,EAAE,IAAI;SAC9B;QACD,IAAI,EAAE;YACJ,gBAAgB,EAAE,MAAM;YACxB,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,uBAAuB;SACnC;QACD,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QACnB,KAAK,EAAE;YACL,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,uBAAuB,EAAE,iCAAiC;YACnE,OAAO,EAAE,kBAAkB;YAC3B,mCAAmC,EAAE,MAAM;SAC5C;QACD,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KAC3B,CAAC,CAAA;IACF,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAEvB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CACT,oDAAoD,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAC9E,CAAA;IACH,CAAC;I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,GAAG,EAAE,CAAA","sourcesContent":["import './env.js'\nimport { generateMockSetup } from './mock/index.js'\nimport { TestNetwork } from './network.js'\nimport { mockMailer } from './util.js'\n\nconst run = async () => {\n console.log(`\nā–ˆā–ˆā–ˆā–ˆā–ˆā–ˆā•—\nā–ˆā–ˆā•”ā•ā•ā•ā–ˆā–ˆā•—\nā–ˆā–ˆā•‘ā–ˆā–ˆā•—ā–ˆā–ˆā•‘\nā–ˆā–ˆā•‘ā–ˆā–ˆā•‘ā–ˆā–ˆā•‘\nā•šā–ˆā•‘ā–ˆā–ˆā–ˆā–ˆā•”ā•\n ā•šā•ā•šā•ā•ā•ā• protocol\n\n[ created by Bluesky ]`)\n\n const network = await TestNetwork.create({\n pds: {\n port: 2583,\n hostname: 'localhost',\n enableDidDocWithSession: true,\n },\n bsky: {\n dbPostgresSchema: 'bsky',\n port: 2584,\n publicUrl: 'http://localhost:2584',\n },\n plc: { port: 2582 },\n ozone: {\n port: 2587,\n chatUrl: 'http://localhost:2590', // must run separate chat service\n chatDid: 'did:example:chat',\n dbMaterializedViewRefreshIntervalMs: 30_000,\n },\n introspect: { port: 2581 },\n })\n mockMailer(network.pds)\n\n if (network.introspect) {\n console.log(\n `šŸ” Dev-env introspection server http://localhost:${network.introspect.port}`,\n )\n }\n console.log(`šŸ‘¤ DID Placeholder server http://localhost:${network.plc.port}`)\n console.log(`šŸŒž Main PDS http://localhost:${network.pds.port}`)\n console.log(`šŸŒž Main PDS account DB`, network.pds.ctx.cfg.db.accountDbLoc)\n console.log(\n `šŸ”Ø Lexicon authority DID ${network.pds.ctx.cfg.lexicon.didAuthority}`,\n )\n console.log(`šŸ—¼ Ozone server http://localhost:${network.ozone.port}`)\n console.log(`šŸ—¼ Ozone service DID ${network.ozone.ctx.cfg.service.did}`)\n console.log(`šŸ”„ Bsync server http://localhost:${network.bsync.port}`)\n console.log(`šŸŒ… Bsky Appview http://localhost:${network.bsky.port}`)\n console.log(`šŸŒ… Bsky Appview DID ${network.bsky.serverDid}`)\n for (const fg of network.feedGens) {\n console.log(`šŸ¤– Feed Generator (${fg.did}) http://localhost:${fg.port}`)\n }\n\n console.time('āœ… Dev environment is ready')\n await generateMockSetup(network)\n console.timeEnd('āœ… Dev environment is ready')\n}\n\nrun()\n"]}
package/dist/bsky.d.ts CHANGED
@@ -9,10 +9,10 @@ export declare class TestBsky {
9
9
  db: bsky.Database;
10
10
  server: bsky.BskyAppView;
11
11
  dataplane: bsky.DataPlaneServer;
12
- bsync: bsky.MockBsync;
12
+ bsyncSub: bsky.BsyncSubscription;
13
13
  sub: bsky.RepoSubscription;
14
14
  serverDid: string;
15
- constructor(url: string, port: number, db: bsky.Database, server: bsky.BskyAppView, dataplane: bsky.DataPlaneServer, bsync: bsky.MockBsync, sub: bsky.RepoSubscription, serverDid: string);
15
+ constructor(url: string, port: number, db: bsky.Database, server: bsky.BskyAppView, dataplane: bsky.DataPlaneServer, bsyncSub: bsky.BsyncSubscription, sub: bsky.RepoSubscription, serverDid: string);
16
16
  static create(cfg: BskyConfig): Promise<TestBsky>;
17
17
  get ctx(): bsky.AppContext;
18
18
  getAgent(): AtpAgent;
@@ -1 +1 @@
1
- {"version":3,"file":"bsky.d.ts","sourceRoot":"","sources":["../src/bsky.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGrC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,cAAc,eAAe,CAAA;AAE7B,qBAAa,QAAQ;IAEV,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI,CAAC,QAAQ;IACjB,MAAM,EAAE,IAAI,CAAC,WAAW;IACxB,SAAS,EAAE,IAAI,CAAC,eAAe;IAC/B,KAAK,EAAE,IAAI,CAAC,SAAS;IACrB,GAAG,EAAE,I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MAAM,EACX,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,IAAI,CAAC,QAAQ,EACjB,MAAM,EAAE,IAAI,CAAC,WAAW,EACxB,SAAS,EAAE,IAAI,CAAC,eAAe,EAC/B,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAChC,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAC1B,SAAS,EAAE,MAAM,EACtB;IAEJ,OAAa,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoHtD;IAED,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAEzB;IAED,QAAQ,IAAI,QAAQ,CAInB;IAED,SAAS,IAAI,MAAM,CAIlB;IAED,SAAS,IAAI,MAAM,CAMlB;IAED,gBAAgB;QAEZ,aAAa;MAEhB;IAEK,KAAK,kBAmBV;IAEK,CAAC,MAAM,CAAC,YAAY,CAAC,kBAE1B;CACF"}
package/dist/bsky.js CHANGED
@@ -8,13 +8,13 @@ import { Client } from '@atproto/lex';
8
8
  import { ADMIN_PASSWORD, EXAMPLE_LABELER } from './const.js';
9
9
  export * from '@atproto/bsky';
10
10
  export class TestBsky {
11
- constructor(url, port, db, server, dataplane, bsync, sub, serverDid) {
11
+ constructor(url, port, db, server, dataplane, bsyncSub, sub, serverDid) {
12
12
  this.url = url;
13
13
  this.port = port;
14
14
  this.db = db;
15
15
  this.server = server;
16
16
  this.dataplane = dataplane;
17
- this.bsync = bsync;
17
+ this.bsyncSub = bsyncSub;
18
18
  this.sub = sub;
19
19
  this.serverDid = serverDid;
20
20
  }
@@ -52,8 +52,6 @@ export class TestBsky {
52
52
  });
53
53
  const dataplanePort = await getPort();
54
54
  const dataplane = await bsky.DataPlaneServer.create(db, dataplanePort, cfg.plcUrl);
55
- const bsyncPort = await getPort();
56
- const bsync = await bsky.MockBsync.create(db, bsyncPort);
57
55
  const config = new bsky.ServerConfig({
58
56
  version: 'unknown',
59
57
  port,
@@ -63,8 +61,8 @@ export class TestBsky {
63
61
  alternateAudienceDids: [],
64
62
  dataplaneUrls: [`http://localhost:${dataplanePort}`],
65
63
  dataplaneHttpVersion: '1.1',
66
- bsyncUrl: `http://localhost:${bsyncPort}`,
67
64
  bsyncHttpVersion: '1.1',
65
+ bsyncApiKey: 'bsync-api-key',
68
66
  modServiceDid: cfg.modServiceDid ?? 'did:example:invalidMod',
69
67
  labelsFromIssuerDids: [EXAMPLE_LABELER],
70
68
  bigThreadUris: new Set(),
@@ -98,14 +96,19 @@ export class TestBsky {
98
96
  config,
99
97
  signingKey: serviceKeypair,
100
98
  });
99
+ const bsyncSub = new bsky.BsyncSubscription({
100
+ config,
101
+ db,
102
+ });
101
103
  const sub = new bsky.RepoSubscription({
102
104
  service: cfg.repoProvider,
103
105
  db,
104
106
  idResolver: dataplane.idResolver,
105
107
  });
106
108
  await server.start();
109
+ bsyncSub.start();
107
110
  void sub.start();
108
- return new TestBsky(url, port, db, server, dataplane, bsync, sub, serverDid);
111
+ return new TestBsky(url, port, db, server, dataplane, bsyncSub, sub, serverDid);
109
112
  }
110
113
  get ctx() {
111
114
  return this.server.ctx;
@@ -137,7 +140,7 @@ export class TestBsky {
137
140
  }
138
141
  finally {
139
142
  try {
140
- await this.bsync.destroy();
143
+ await this.bsyncSub.destroy();
141
144
  }
142
145
  finally {
143
146
  try {
package/dist/bsky.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bsky.js","sourceRoot":"","sources":["../src/bsky.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE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O,EAAE,CAAA;oBAC1B,CAAC;4BAAS,CAAC;wBACT,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;oBACvB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF","sourcesContent":["import { Client as PlcClient } from '@did-plc/lib'\nimport getPort from 'get-port'\nimport * as ui8 from 'uint8arrays'\nimport { AtpAgent } from '@atproto/api'\nimport * as bsky from '@atproto/bsky'\nimport { Secp256k1Keypair } from '@atproto/crypto'\nimport { Client } from '@atproto/lex'\nimport type { DidString } from '@atproto/syntax'\nimport { ADMIN_PASSWORD, EXAMPLE_LABELER } from './const.js'\nimport { BskyConfig } from './types.js'\nexport * from '@atproto/bsky'\n\nexport class TestBsky {\n constructor(\n public url: string,\n public port: number,\n public db: bsky.Database,\n public server: bsky.BskyAppView,\n public dataplane: bsky.DataPlaneServer,\n public bsync: bsky.MockBsync,\n public sub: bsky.RepoSubscription,\n public serverDid: string,\n ) {}\n\n static async create(cfg: BskyConfig): Promise<TestBsky> {\n const serviceKeypair = cfg.privateKey\n ? await Secp256k1Keypair.import(cfg.privateKey)\n : await Secp256k1Keypair.create()\n const plcClient = new PlcClient(cfg.plcUrl)\n\n const port = cfg.port || (await getPort())\n const url = `http://localhost:${port}`\n const serverDid = (await plcClient.createDid({\n signingKey: serviceKeypair.did(),\n rotationKeys: [serviceKeypair.did()],\n handle: 'bsky.test',\n pds: `http://localhost:${port}`,\n signer: serviceKeypair,\n })) as DidString\n\n const endpoint = `http://localhost:${port}`\n\n await plcClient.updateData(serverDid, serviceKeypair, (x) => {\n x.services['bsky_notif'] = {\n type: 'BskyNotificationService',\n endpoint,\n }\n x.services['bsky_appview'] = {\n type: 'BskyAppView',\n endpoint,\n }\n return x\n })\n\n // shared across server, ingester, and indexer in order to share pool, avoid too many pg connections.\n const db = new bsky.Database({\n url: cfg.dbPostgresUrl,\n schema: cfg.dbPostgresSchema,\n poolSize: 10,\n })\n\n const dataplanePort = await getPort()\n const dataplane = await bsky.DataPlaneServer.create(\n db,\n dataplanePort,\n cfg.plcUrl,\n )\n\n const bsyncPort = await getPort()\n const bsync = await bsky.MockBsync.create(db, bsyncPort)\n\n const config = new bsky.ServerConfig({\n version: 'unknown',\n port,\n didPlcUrl: cfg.plcUrl,\n publicUrl: 'https://bsky.public.url',\n serverDid,\n alternateAudienceDids: [],\n dataplaneUrls: [`http://localhost:${dataplanePort}`],\n dataplaneHttpVersion: '1.1',\n bsyncUrl: `http://localhost:${bsyncPort}`,\n bsyncHttpVersion: '1.1',\n modServiceDid: cfg.modServiceDid ?? 'did:example:invalidMod',\n labelsFromIssuerDids: [EXAMPLE_LABELER],\n bigThreadUris: new Set(),\n maxThreadParents: cfg.maxThreadParents ?? 50,\n disableSsrfProtection: true,\n searchTagsHide: new Set(),\n threadTagsBumpDown: new Set(),\n threadTagsHide: new Set(),\n visibilityTagHide: '',\n visibilityTagRankPrefix: '',\n debugFieldAllowedDids: new Set(),\n draftsLimit: 500,\n ...cfg,\n adminPasswords: [ADMIN_PASSWORD],\n etcdHosts: [],\n })\n\n // Separate migration db in case migration changes some connection state that we need in the tests, e.g. \"alter database ... set ...\"\n const migrationDb = new bsky.Database({\n url: cfg.dbPostgresUrl,\n schema: cfg.dbPostgresSchema,\n })\n if (cfg.migration) {\n await migrationDb.migrateToOrThrow(cfg.migration)\n } else {\n await migrationDb.migrateToLatestOrThrow()\n }\n await migrationDb.close()\n\n // api server\n const server = bsky.BskyAppView.create({\n config,\n signingKey: serviceKeypair,\n })\n\n const sub = new bsky.RepoSubscription({\n service: cfg.repoProvider,\n db,\n idResolver: dataplane.idResolver,\n })\n\n await server.start()\n\n void sub.start()\n\n return new TestBsky(url, port, db, server, dataplane, bsync, sub, serverDid)\n }\n\n get ctx(): bsky.AppContext {\n return this.server.ctx\n }\n\n getAgent(): AtpAgent {\n const agent = new AtpAgent({ service: this.url })\n agent.configureLabelers([EXAMPLE_LABELER])\n return agent\n }\n\n getClient(): Client {\n const client = new Client({ service: this.url })\n client.setLabelers([EXAMPLE_LABELER])\n return client\n }\n\n adminAuth(): string {\n const [password] = this.ctx.cfg.adminPasswords\n return (\n 'Basic ' +\n ui8.toString(ui8.fromString(`admin:${password}`, 'utf8'), 'base64pad')\n )\n }\n\n adminAuthHeaders() {\n return {\n authorization: this.adminAuth(),\n }\n }\n\n async close() {\n // @TODO Use disposable stack when it becomes available (Node24+)\n try {\n await this.server.destroy()\n } finally {\n try {\n await this.bsync.destroy()\n } finally {\n try {\n await this.dataplane.destroy()\n } finally {\n try {\n await this.sub.destroy()\n } finally {\n await this.db.close()\n }\n }\n }\n }\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n"]}
1
+ {"version":3,"file":"bsky.js","sourceRoot":"","sources":["../src/bsky.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5D,cAAc,eAAe,CAAA;AAE7B,MAAM,OAAO,QAAQ;IACnB,YACS,GAAW,EACX,IAAY,EACZ,EAAiB,EACjB,MAAwB,EACxB,SAA+B,EAC/B,QAAgC,EAChC,GAA0B,EAC1B,SAAiB;mBAPjB,GAAG;oBACH,IAAI;kBACJ,EAAE;sBACF,MAAM;yBACN,SAAS;wBACT,QAAQ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M,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;QAChD,MAAM,CAAC,WAAW,CAAC,CAAC,eAAe,CAAC,CAAC,CAAA;QACrC,OAAO,MAAM,CAAA;IACf,CAAC;IAED,SAAS;QACP,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAA;QAC9C,OAAO,CACL,QAAQ;YACR,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,QAAQ,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,CAAC,CACvE,CAAA;IACH,CAAC;IAED,gBAAgB;QACd,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE;SAChC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,iEAAiE;QACjE,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;YAC/B,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;gBAChC,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC;wBACH,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;oBAC1B,CAAC;4BAAS,CAAC;wBACT,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;oBACvB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF","sourcesContent":["import { Client as PlcClient } from '@did-plc/lib'\nimport getPort from 'get-port'\nimport * as ui8 from 'uint8arrays'\nimport { AtpAgent } from '@atproto/api'\nimport * as bsky from '@atproto/bsky'\nimport { Secp256k1Keypair } from '@atproto/crypto'\nimport { Client } from '@atproto/lex'\nimport type { DidString } from '@atproto/syntax'\nimport { ADMIN_PASSWORD, EXAMPLE_LABELER } from './const.js'\nimport { BskyConfig } from './types.js'\nexport * from '@atproto/bsky'\n\nexport class TestBsky {\n constructor(\n public url: string,\n public port: number,\n public db: bsky.Database,\n public server: bsky.BskyAppView,\n public dataplane: bsky.DataPlaneServer,\n public bsyncSub: bsky.BsyncSubscription,\n public sub: bsky.RepoSubscription,\n public serverDid: string,\n ) {}\n\n static async create(cfg: BskyConfig): Promise<TestBsky> {\n const serviceKeypair = cfg.privateKey\n ? await Secp256k1Keypair.import(cfg.privateKey)\n : await Secp256k1Keypair.create()\n const plcClient = new PlcClient(cfg.plcUrl)\n\n const port = cfg.port || (await getPort())\n const url = `http://localhost:${port}`\n const serverDid = (await plcClient.createDid({\n signingKey: serviceKeypair.did(),\n rotationKeys: [serviceKeypair.did()],\n handle: 'bsky.test',\n pds: `http://localhost:${port}`,\n signer: serviceKeypair,\n })) as DidString\n\n const endpoint = `http://localhost:${port}`\n\n await plcClient.updateData(serverDid, serviceKeypair, (x) => {\n x.services['bsky_notif'] = {\n type: 'BskyNotificationService',\n endpoint,\n }\n x.services['bsky_appview'] = {\n type: 'BskyAppView',\n endpoint,\n }\n return x\n })\n\n // shared across server, ingester, and indexer in order to share pool, avoid too many pg connections.\n const db = new bsky.Database({\n url: cfg.dbPostgresUrl,\n schema: cfg.dbPostgresSchema,\n poolSize: 10,\n })\n\n const dataplanePort = await getPort()\n const dataplane = await bsky.DataPlaneServer.create(\n db,\n dataplanePort,\n cfg.plcUrl,\n )\n\n const config = new bsky.ServerConfig({\n version: 'unknown',\n port,\n didPlcUrl: cfg.plcUrl,\n publicUrl: 'https://bsky.public.url',\n serverDid,\n alternateAudienceDids: [],\n dataplaneUrls: [`http://localhost:${dataplanePort}`],\n dataplaneHttpVersion: '1.1',\n bsyncHttpVersion: '1.1',\n bsyncApiKey: 'bsync-api-key',\n modServiceDid: cfg.modServiceDid ?? 'did:example:invalidMod',\n labelsFromIssuerDids: [EXAMPLE_LABELER],\n bigThreadUris: new Set(),\n maxThreadParents: cfg.maxThreadParents ?? 50,\n disableSsrfProtection: true,\n searchTagsHide: new Set(),\n threadTagsBumpDown: new Set(),\n threadTagsHide: new Set(),\n visibilityTagHide: '',\n visibilityTagRankPrefix: '',\n debugFieldAllowedDids: new Set(),\n draftsLimit: 500,\n ...cfg,\n adminPasswords: [ADMIN_PASSWORD],\n etcdHosts: [],\n })\n\n // Separate migration db in case migration changes some connection state that we need in the tests, e.g. \"alter database ... set ...\"\n const migrationDb = new bsky.Database({\n url: cfg.dbPostgresUrl,\n schema: cfg.dbPostgresSchema,\n })\n if (cfg.migration) {\n await migrationDb.migrateToOrThrow(cfg.migration)\n } else {\n await migrationDb.migrateToLatestOrThrow()\n }\n await migrationDb.close()\n\n // api server\n const server = bsky.BskyAppView.create({\n config,\n signingKey: serviceKeypair,\n })\n\n const bsyncSub = new bsky.BsyncSubscription({\n config,\n db,\n })\n\n const sub = new bsky.RepoSubscription({\n service: cfg.repoProvider,\n db,\n idResolver: dataplane.idResolver,\n })\n\n await server.start()\n\n bsyncSub.start()\n void sub.start()\n\n return new TestBsky(\n url,\n port,\n db,\n server,\n dataplane,\n bsyncSub,\n sub,\n serverDid,\n )\n }\n\n get ctx(): bsky.AppContext {\n return this.server.ctx\n }\n\n getAgent(): AtpAgent {\n const agent = new AtpAgent({ service: this.url })\n agent.configureLabelers([EXAMPLE_LABELER])\n return agent\n }\n\n getClient(): Client {\n const client = new Client({ service: this.url })\n client.setLabelers([EXAMPLE_LABELER])\n return client\n }\n\n adminAuth(): string {\n const [password] = this.ctx.cfg.adminPasswords\n return (\n 'Basic ' +\n ui8.toString(ui8.fromString(`admin:${password}`, 'utf8'), 'base64pad')\n )\n }\n\n adminAuthHeaders() {\n return {\n authorization: this.adminAuth(),\n }\n }\n\n async close() {\n // @TODO Use disposable stack when it becomes available (Node24+)\n try {\n await this.server.destroy()\n } finally {\n try {\n await this.bsyncSub.destroy()\n } finally {\n try {\n await this.dataplane.destroy()\n } finally {\n try {\n await this.sub.destroy()\n } finally {\n await this.db.close()\n }\n }\n }\n }\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n"]}
package/dist/bsync.d.ts CHANGED
@@ -7,6 +7,16 @@ export declare class TestBsync {
7
7
  constructor(url: string, port: number, service: bsync.BsyncService);
8
8
  static create(cfg: BsyncConfig): Promise<TestBsync>;
9
9
  get ctx(): bsync.AppContext;
10
+ /**
11
+ * Current head (max id) of each operation stream. Used to wait for the bsky
12
+ * bsync subscription to catch up in tests, without waiting for the long-poll
13
+ * timeout.
14
+ */
15
+ getStreamHeads(): Promise<{
16
+ op?: string;
17
+ mute?: string;
18
+ notif?: string;
19
+ }>;
10
20
  close(): Promise<void>;
11
21
  }
12
22
  //# sourceMappingURL=bsync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bsync.d.ts","sourceRoot":"","sources":["../src/bsync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,qBAAa,SAAS;IAEX,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK,CAAC,YAAY;IAHpC,YACS,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,KAAK,CAAC,YAAY,EAChC;IAEJ,OAAa,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAexD;IAED,IAAI,GAAG,IAAI,KAAK,CAAC,UAAU,CAE1B;IAEK,KAAK,kBAEV;CACF"}
1
+ {"version":3,"file":"bsync.d.ts","sourceRoot":"","sources":["../src/bsync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,qBAAa,SAAS;IAEX,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK,CAAC,YAAY;IAHpC,YACS,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,KAAK,CAAC,YAAY,EAChC;IAEJ,OAAa,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAmBxD;IAED,IAAI,GAAG,IAAI,KAAK,CAAC,UAAU,CAE1B;IAED;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC;QAC9B,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAC,CAeD;IAEK,KAAK,kBAEV;CACF"}
package/dist/bsync.js CHANGED
@@ -12,6 +12,10 @@ export class TestBsync {
12
12
  const config = bsync.envToCfg({
13
13
  port,
14
14
  apiKeys: cfg.apiKeys ?? ['api-key'],
15
+ dbSchema: 'bsync',
16
+ // Keep the pool small: a bsync runs alongside every test network, so a
17
+ // default-sized pool per network quickly exhausts postgres connections.
18
+ dbPoolSize: cfg.dbPoolSize ?? 5,
15
19
  ...cfg,
16
20
  });
17
21
  const service = await bsync.BsyncService.create(config);
@@ -22,6 +26,27 @@ export class TestBsync {
22
26
  get ctx() {
23
27
  return this.service.ctx;
24
28
  }
29
+ /**
30
+ * Current head (max id) of each operation stream. Used to wait for the bsky
31
+ * bsync subscription to catch up in tests, without waiting for the long-poll
32
+ * timeout.
33
+ */
34
+ async getStreamHeads() {
35
+ const db = this.ctx.db.db;
36
+ const max = async (table) => {
37
+ const row = await db
38
+ .selectFrom(table)
39
+ .select((eb) => eb.fn.max('id').as('id'))
40
+ .executeTakeFirst();
41
+ return row?.id != null ? String(row.id) : undefined;
42
+ };
43
+ const [op, mute, notif] = await Promise.all([
44
+ max('operation'),
45
+ max('mute_op'),
46
+ max('notif_op'),
47
+ ]);
48
+ return { op, mute, notif };
49
+ }
25
50
  async close() {
26
51
  await this.service.destroy();
27
52
  }
package/dist/bsync.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bsync.js","sourceRoot":"","sources":["../src/bsync.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AAGvC,MAAM,OAAO,SAAS;IACpB,YACS,GAAW,EACX,IAAY,EACZ,OAA2B;mBAF3B,GAAG;oBACH,IAAI;uBACJ,OAAO;IACb,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAgB;QAClC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,OAAO,EAAE,CAAC,CAAA;QAC1C,MAAM,GAAG,GAAG,oBAAoB,IAAI,EAAE,CAAA;QAEtC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC;YAC5B,IAAI;YACJ,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC;YACnC,GAAG,GAAG;SACP,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACvD,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,sBAAsB,EAAE,CAAA;QAC7C,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;QAErB,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import getPort from 'get-port'\nimport * as bsync from '@atproto/bsync'\nimport { BsyncConfig } from './types.js'\n\nexport class TestBsync {\n constructor(\n public url: string,\n public port: number,\n public service: bsync.BsyncService,\n ) {}\n\n static async create(cfg: BsyncConfig): Promise<TestBsync> {\n const port = cfg.port || (await getPort())\n const url = `http://localhost:${port}`\n\n const config = bsync.envToCfg({\n port,\n apiKeys: cfg.apiKeys ?? ['api-key'],\n ...cfg,\n })\n\n const service = await bsync.BsyncService.create(config)\n await service.ctx.db.migrateToLatestOrThrow()\n await service.start()\n\n return new TestBsync(url, port, service)\n }\n\n get ctx(): bsync.AppContext {\n return this.service.ctx\n }\n\n async close() {\n await this.service.destroy()\n }\n}\n"]}
1
+ {"version":3,"file":"bsync.js","sourceRoot":"","sources":["../src/bsync.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AAGvC,MAAM,OAAO,SAAS;IACpB,YACS,GAAW,EACX,IAAY,EACZ,OAA2B;mBAF3B,GAAG;oBACH,IAAI;uBACJ,OAAO;IACb,CAAC;IAEJ,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAgB;QAClC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,OAAO,EAAE,CAAC,CAAA;QAC1C,MAAM,GAAG,GAAG,oBAAoB,IAAI,EAAE,CAAA;QAEtC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC;YAC5B,IAAI;YACJ,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC;YACnC,QAAQ,EAAE,OAAO;YACjB,uEAAuE;YACvE,wEAAwE;YACxE,UAAU,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC;YAC/B,GAAG,GAAG;SACP,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,M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to/bsync'\nimport { BsyncConfig } from './types.js'\n\nexport class TestBsync {\n constructor(\n public url: string,\n public port: number,\n public service: bsync.BsyncService,\n ) {}\n\n static async create(cfg: BsyncConfig): Promise<TestBsync> {\n const port = cfg.port || (await getPort())\n const url = `http://localhost:${port}`\n\n const config = bsync.envToCfg({\n port,\n apiKeys: cfg.apiKeys ?? ['api-key'],\n dbSchema: 'bsync',\n // Keep the pool small: a bsync runs alongside every test network, so a\n // default-sized pool per network quickly exhausts postgres connections.\n dbPoolSize: cfg.dbPoolSize ?? 5,\n ...cfg,\n })\n\n const service = await bsync.BsyncService.create(config)\n await service.ctx.db.migrateToLatestOrThrow()\n await service.start()\n\n return new TestBsync(url, port, service)\n }\n\n get ctx(): bsync.AppContext {\n return this.service.ctx\n }\n\n /**\n * Current head (max id) of each operation stream. Used to wait for the bsky\n * bsync subscription to catch up in tests, without waiting for the long-poll\n * timeout.\n */\n async getStreamHeads(): Promise<{\n op?: string\n mute?: string\n notif?: string\n }> {\n const db = this.ctx.db.db\n const max = async (table: 'operation' | 'mute_op' | 'notif_op') => {\n const row = await db\n .selectFrom(table)\n .select((eb) => eb.fn.max('id').as('id'))\n .executeTakeFirst()\n return row?.id != null ? String(row.id) : undefined\n }\n const [op, mute, notif] = await Promise.all([\n max('operation'),\n max('mute_op'),\n max('notif_op'),\n ])\n return { op, mute, notif }\n }\n\n async close() {\n await this.service.destroy()\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import http from 'node:http';
2
2
  import { TestBsky } from './bsky.js';
3
+ import { TestBsync } from './bsync.js';
3
4
  import { TestOzone } from './ozone.js';
4
5
  import { TestPds } from './pds.js';
5
6
  import { TestPlc } from './plc.js';
@@ -8,7 +9,7 @@ export declare class IntrospectServer {
8
9
  server: http.Server;
9
10
  private terminator;
10
11
  constructor(port: number, server: http.Server);
11
- static start(port: number, plc: TestPlc, pds: TestPds, bsky: TestBsky, ozone: TestOzone): Promise<IntrospectServer>;
12
+ static start(port: number, plc: TestPlc, pds: TestPds, bsync: TestBsync, bsky: TestBsky, ozone: TestOzone): Promise<IntrospectServer>;
12
13
  close(): Promise<void>;
13
14
  }
14
15
  //# sourceMappingURL=introspect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,qBAAa,gBAAgB;IAGlB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,IAAI,CAAC,MAAM;IAH5B,OAAO,CAAC,UAAU,CAA+B;IACjD,YACS,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,IAAI,CAAC,MAAM,EAG3B;IAED,OAAa,KAAK,CAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,6BA4BjB;IAEK,KAAK,kBAEV;CACF"}
1
+ {"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,qBAAa,gBAAgB;IAGlB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,IAAI,CAAC,MAAM;IAH5B,OAAO,CAAC,UAAU,CAA+B;IACjD,YACS,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,IAAI,CAAC,MAAM,EAG3B;IAED,OAAa,KAAK,CAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,6BA+BjB;IAEK,KAAK,kBAEV;CACF"}
@@ -8,7 +8,7 @@ export class IntrospectServer {
8
8
  this.server = server;
9
9
  this.terminator = httpTerminator.createHttpTerminator({ server });
10
10
  }
11
- static async start(port, plc, pds, bsky, ozone) {
11
+ static async start(port, plc, pds, bsync, bsky, ozone) {
12
12
  const app = express();
13
13
  app.get('/', (_req, res) => {
14
14
  res.status(200).send({
@@ -19,6 +19,9 @@ export class IntrospectServer {
19
19
  url: pds.url,
20
20
  did: pds.ctx.cfg.service.did,
21
21
  },
22
+ bsync: {
23
+ url: bsync.url,
24
+ },
22
25
  bsky: {
23
26
  url: bsky.url,
24
27
  did: bsky.ctx.cfg.serverDid,
@@ -1 +1 @@
1
- {"version":3,"file":"introspect.js","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,0CAA0C;AAC1C,OAAO,cAAc,MAAM,iBAAiB,CAAA;AAM5C,MAAM,OAAO,gBAAgB;IAE3B,YACS,IAAY,EACZ,MAAmB;oBADnB,IAAI;sBACJ,MAAM;QAEb,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IACnE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAChB,IAAY,EACZ,GAAY,EACZ,GAAY,EACZ,IAAc,EACd,KAAgB;QAEhB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAA;QACrB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YACzB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,GAAG,EAAE;oBACH,GAAG,EAAE,GAAG,CAAC,GAAG;iBACb;gBACD,GAAG,EAAE;oBACH,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG;iBAC7B;gBACD,IAAI,EAAE;oBACJ,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS;iBAC5B;gBACD,KAAK,EAAE;oBACL,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG;iBAC/B;gBACD,EAAE,EAAE;oBACF,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW;iBAClC;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QACtC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAA;IACnC,CAAC;CACF","sourcesContent":["import events from 'node:events'\nimport http from 'node:http'\nimport express from 'express'\n// eslint-disable-next-line import/default\nimport httpTerminator from 'http-terminator'\nimport { TestBsky } from './bsky.js'\nimport { TestOzone } from './ozone.js'\nimport { TestPds } from './pds.js'\nimport { TestPlc } from './plc.js'\n\nexport class IntrospectServer {\n private terminator: httpTerminator.HttpTerminator\n constructor(\n public port: number,\n public server: http.Server,\n ) {\n this.terminator = httpTerminator.createHttpTerminator({ server })\n }\n\n static async start(\n port: number,\n plc: TestPlc,\n pds: TestPds,\n bsky: TestBsky,\n ozone: TestOzone,\n ) {\n const app = express()\n app.get('/', (_req, res) => {\n res.status(200).send({\n plc: {\n url: plc.url,\n },\n pds: {\n url: pds.url,\n did: pds.ctx.cfg.service.did,\n },\n bsky: {\n url: bsky.url,\n did: bsky.ctx.cfg.serverDid,\n },\n ozone: {\n url: ozone.url,\n did: ozone.ctx.cfg.service.did,\n },\n db: {\n url: ozone.ctx.cfg.db.postgresUrl,\n },\n })\n })\n const server = app.listen(port)\n await events.once(server, 'listening')\n return new IntrospectServer(port, server)\n }\n\n async close() {\n await this.terminator.terminate()\n }\n}\n"]}
1
+ {"version":3,"file":"introspect.js","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,0CAA0C;AAC1C,OAAO,cAAc,MAAM,iBAAiB,CAAA;AAO5C,MAAM,OAAO,gBAAgB;IAE3B,YACS,IAAY,EACZ,MAAmB;oBADnB,IAAI;sBACJ,MAAM;QAEb,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IACnE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAChB,IAAY,EACZ,GAAY,EACZ,GAAY,EACZ,KAAgB,EAChB,IAAc,EACd,KAAgB;QAEhB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAA;QACrB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YACzB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,GAAG,EAAE;oBACH,GAAG,EAAE,GAAG,CAAC,GAAG;iBACb;gBACD,GAAG,EAAE;oBACH,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG;iBAC7B;gBACD,KAAK,EAAE;oBACL,GAAG,EAAE,KAAK,CAAC,GAAG;iBACf;gBACD,IAAI,EAAE;oBACJ,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS;iBAC5B;gBACD,KAAK,EAAE;oBACL,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG;iBAC/B;gBACD,EAAE,EAAE;oBACF,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW;iBAClC;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QACtC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAA;IACnC,CAAC;CACF","sourcesContent":["import events from 'node:events'\nimport http from 'node:http'\nimport express from 'express'\n// eslint-disable-next-line import/default\nimport httpTerminator from 'http-terminator'\nimport { TestBsky } from './bsky.js'\nimport { TestBsync } from './bsync.js'\nimport { TestOzone } from './ozone.js'\nimport { TestPds } from './pds.js'\nimport { TestPlc } from './plc.js'\n\nexport class IntrospectServer {\n private terminator: httpTerminator.HttpTerminator\n constructor(\n public port: number,\n public server: http.Server,\n ) {\n this.terminator = httpTerminator.createHttpTerminator({ server })\n }\n\n static async start(\n port: number,\n plc: TestPlc,\n pds: TestPds,\n bsync: TestBsync,\n bsky: TestBsky,\n ozone: TestOzone,\n ) {\n const app = express()\n app.get('/', (_req, res) => {\n res.status(200).send({\n plc: {\n url: plc.url,\n },\n pds: {\n url: pds.url,\n did: pds.ctx.cfg.service.did,\n },\n bsync: {\n url: bsync.url,\n },\n bsky: {\n url: bsky.url,\n did: bsky.ctx.cfg.serverDid,\n },\n ozone: {\n url: ozone.url,\n did: ozone.ctx.cfg.service.did,\n },\n db: {\n url: ozone.ctx.cfg.db.postgresUrl,\n },\n })\n })\n const server = app.listen(port)\n await events.once(server, 'listening')\n return new IntrospectServer(port, server)\n }\n\n async close() {\n await this.terminator.terminate()\n }\n}\n"]}
package/dist/network.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { TestBsky } from './bsky.js';
2
+ import { TestBsync } from './bsync.js';
2
3
  import { IntrospectServer } from './introspect.js';
3
4
  import { TestNetworkNoAppView } from './network-no-appview.js';
4
5
  import { TestOzone } from './ozone.js';
@@ -8,10 +9,11 @@ import { TestServerParams } from './types.js';
8
9
  export declare class TestNetwork extends TestNetworkNoAppView {
9
10
  plc: TestPlc;
10
11
  pds: TestPds;
12
+ bsync: TestBsync;
11
13
  bsky: TestBsky;
12
14
  ozone: TestOzone;
13
15
  introspect?: IntrospectServer | undefined;
14
- constructor(plc: TestPlc, pds: TestPds, bsky: TestBsky, ozone: TestOzone, introspect?: IntrospectServer | undefined);
16
+ constructor(plc: TestPlc, pds: TestPds, bsync: TestBsync, bsky: TestBsky, ozone: TestOzone, introspect?: IntrospectServer | undefined);
15
17
  static create(params?: Partial<TestServerParams>): Promise<TestNetwork>;
16
18
  processFullSubscription(timeout?: number): Promise<void>;
17
19
  processAll(timeout?: number): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,gBAA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@ import * as uint8arrays from 'uint8arrays';
4
4
  import { allFulfilled, wait } from '@atproto/common-web';
5
5
  import { createServiceJwt } from '@atproto/xrpc-server';
6
6
  import { TestBsky } from './bsky.js';
7
+ import { TestBsync } from './bsync.js';
7
8
  import { EXAMPLE_LABELER } from './const.js';
8
9
  import { IntrospectServer } from './introspect.js';
9
10
  import { TestNetworkNoAppView } from './network-no-appview.js';
@@ -16,10 +17,11 @@ import { mockNetworkUtilities } from './util.js';
16
17
  const ADMIN_USERNAME = 'admin';
17
18
  const ADMIN_PASSWORD = 'admin-pass';
18
19
  export class TestNetwork extends TestNetworkNoAppView {
19
- constructor(plc, pds, bsky, ozone, introspect) {
20
+ constructor(plc, pds, bsync, bsky, ozone, introspect) {
20
21
  super(plc, pds);
21
22
  this.plc = plc;
22
23
  this.pds = pds;
24
+ this.bsync = bsync;
23
25
  this.bsky = bsky;
24
26
  this.ozone = ozone;
25
27
  this.introspect = introspect;
@@ -45,10 +47,17 @@ export class TestNetwork extends TestNetworkNoAppView {
45
47
  // requiring to migrate to the main PDS
46
48
  const ozoneServiceProfile = await OzoneServiceProfile.create(thirdPartyPds, ozoneUrl);
47
49
  const lexiconAuthorityProfile = await LexiconAuthorityProfile.create(thirdPartyPds);
50
+ const bsyncApiKey = 'bsync-api-key';
51
+ const bsync = await TestBsync.create({
52
+ apiKeys: [bsyncApiKey],
53
+ dbUrl: dbPostgresUrl,
54
+ });
48
55
  const bsky = await TestBsky.create({
49
56
  port: bskyPort,
50
57
  plcUrl: plc.url,
51
58
  pdsPort,
59
+ bsyncApiKey,
60
+ bsyncUrl: bsync.url,
52
61
  rolodexUrl: process.env.BSKY_ROLODEX_URL,
53
62
  rolodexIgnoreBadTls: true,
54
63
  repoProvider: `ws://localhost:${pdsPort}`,
@@ -100,6 +109,7 @@ export class TestNetwork extends TestNetworkNoAppView {
100
109
  await pds.processAll();
101
110
  await ozone.processAll();
102
111
  await bsky.sub.processAll();
112
+ await bsky.bsyncSub.processAll(await bsync.getStreamHeads());
103
113
  await thirdPartyPds.close();
104
114
  // Weird but if we do this before pds.processAll() somehow appview loses this user and tests in different parts fail because appview doesn't return this user in various contexts anymore
105
115
  const ozoneVerifierPassword = await ozoneServiceProfile.createAppPasswordForVerification();
@@ -108,9 +118,9 @@ export class TestNetwork extends TestNetworkNoAppView {
108
118
  }
109
119
  let introspect = undefined;
110
120
  if (params.introspect?.port) {
111
- introspect = await IntrospectServer.start(params.introspect.port, plc, pds, bsky, ozone);
121
+ introspect = await IntrospectServer.start(params.introspect.port, plc, pds, bsync, bsky, ozone);
112
122
  }
113
- return new TestNetwork(plc, pds, bsky, ozone, introspect);
123
+ return new TestNetwork(plc, pds, bsync, bsky, ozone, introspect);
114
124
  }
115
125
  async processFullSubscription(timeout = 5000) {
116
126
  const sub = this.bsky.sub;
@@ -137,6 +147,8 @@ export class TestNetwork extends TestNetworkNoAppView {
137
147
  async processAll(timeout) {
138
148
  await this.pds.processAll();
139
149
  await this.ozone.processAll();
150
+ await this.bsky.sub.processAll();
151
+ await this.bsky.bsyncSub.processAll(await this.bsync.getStreamHeads(), timeout);
140
152
  await this.processFullSubscription(timeout);
141
153
  }
142
154
  async serviceHeaders(did, lxm, aud) {
@@ -164,6 +176,7 @@ export class TestNetwork extends TestNetworkNoAppView {
164
176
  ...this.feedGens.map(async (fg) => fg.close()),
165
177
  this.ozone.close(),
166
178
  this.bsky.close(),
179
+ this.bsync.close(),
167
180
  this.pds.close(),
168
181
  this.plc.close(),
169
182
  this.introspect?.close(),
@@ -1 +1 @@
1
- {"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,KAAK,WAAW,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAs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E,UAAU,GAAG,EAAE,EAAE,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EACjB,QAAQ,GAAG,cAAc,EACzB,QAAQ,GAAG,cAAc,GAI1B;QACC,OAAO;YACL,aAAa,EACX,QAAQ;gBACR,WAAW,CAAC,QAAQ,CAClB,WAAW,CAAC,UAAU,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,EACzD,WAAW,CACZ;SACJ,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;QACzB,CAAC;gBAAS,CAAC;YACT,MAAM,YAAY,CAAC;gBACjB,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;gBAC9C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;gBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACjB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBAChB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBAChB,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE;aACzB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF","sourcesContent":["import assert from 'node:assert'\nimport getPort from 'get-port'\nimport * as uint8arrays from 'uint8arrays'\nimport { allFulfilled, wait } from '@atproto/common-web'\nimport { createServiceJwt } from '@atproto/xrpc-server'\nimport { TestBsky } from './bsky.js'\nimport { EXAMPLE_LABELER } from './const.js'\nimport { IntrospectServer } from './introspect.js'\nimport { TestNetworkNoAppView } from './network-no-appview.js'\nimport { TestOzone } from './ozone.js'\nimport { TestPds } from './pds.js'\nimport { TestPlc } from './plc.js'\nimport { LexiconAuthorityProfile } from './service-profile-lexicon.js'\nimport { OzoneServiceProfile } from './service-profile-ozone.js'\nimport { TestServerParams } from './types.js'\nimport { mockNetworkUtilities } from './util.js'\n\nconst ADMIN_USERNAME = 'admin'\nconst ADMIN_PASSWORD = 'admin-pass'\n\nexport class TestNetwork extends TestNetworkNoAppView {\n constructor(\n public plc: TestPlc,\n public pds: TestPds,\n public bsky: TestBsky,\n public ozone: TestOzone,\n public introspect?: IntrospectServer,\n ) {\n super(plc, pds)\n }\n\n static async create(\n params: Partial<TestServerParams> = {},\n ): Promise<TestNetwork> {\n const redisHost = process.env.REDIS_HOST\n const dbPostgresUrl = params.dbPostgresUrl || process.env.DB_POSTGRES_URL\n assert(dbPostgresUrl, 'Missing postgres url for tests')\n assert(redisHost, 'Missing redis host for tests')\n const dbPostgresSchema =\n params.dbPostgresSchema || process.env.DB_POSTGRES_SCHEMA\n\n const plc = await TestPlc.create(params.plc ?? {})\n\n const bskyPort = params.bsky?.port ?? (await getPort())\n const pdsPort = params.pds?.port ?? (await getPort())\n const ozonePort = params.ozone?.port ?? (await getPort())\n\n const thirdPartyPds = await TestPds.create({\n didPlcUrl: plc.url,\n ...params.pds,\n inviteRequired: false,\n port: await getPort(),\n })\n\n const ozoneUrl = `http://localhost:${ozonePort}`\n\n // @TODO (?) rework the ServiceProfile to live on a separate PDS instead of\n // requiring to migrate to the main PDS\n const ozoneServiceProfile = await OzoneServiceProfile.create(\n thirdPartyPds,\n ozoneUrl,\n )\n const lexiconAuthorityProfile =\n await LexiconAuthorityProfile.create(thirdPartyPds)\n\n const bsky = await TestBsky.create({\n port: bskyPort,\n plcUrl: plc.url,\n pdsPort,\n rolodexUrl: process.env.BSKY_ROLODEX_URL,\n rolodexIgnoreBadTls: true,\n repoProvider: `ws://localhost:${pdsPort}`,\n dbPostgresSchema: `appview_${dbPostgresSchema}`,\n dbPostgresUrl,\n redisHost,\n modServiceDid: ozoneServiceProfile.did,\n labelsFromIssuerDids: [ozoneServiceProfile.did, EXAMPLE_LABELER],\n // Using a static private key results in a static DID, which is useful for e2e tests with the social-app repo.\n privateKey:\n '3f916c70dc69e4c5e83877f013325b11ecac31742e6a42f5c4fb240d0703d9d5=',\n ...params.bsky,\n })\n\n const pds = await TestPds.create({\n port: pdsPort,\n didPlcUrl: plc.url,\n bskyAppViewUrl: bsky.url,\n bskyAppViewDid: bsky.ctx.cfg.serverDid,\n modServiceUrl: ozoneUrl,\n modServiceDid: ozoneServiceProfile.did,\n lexiconDidAuthority: lexiconAuthorityProfile.did,\n ...params.pds,\n })\n\n // mock before any events start flowing from pds so that we don't miss e.g. any handle resolutions.\n mockNetworkUtilities(pds, bsky)\n\n const ozone = await TestOzone.create({\n port: ozonePort,\n plcUrl: plc.url,\n signingKey: ozoneServiceProfile.key,\n serverDid: ozoneServiceProfile.did,\n dbPostgresSchema: `ozone_${dbPostgresSchema || 'db'}`,\n dbPostgresUrl,\n appviewUrl: bsky.url,\n appviewDid: bsky.ctx.cfg.serverDid,\n appviewPushEvents: true,\n pdsUrl: pds.url,\n pdsDid: pds.ctx.cfg.service.did,\n verifierDid: ozoneServiceProfile.did,\n verifierUrl: pds.url,\n verifierPassword: 'temp',\n ...params.ozone,\n })\n\n await ozoneServiceProfile.migrateTo(pds)\n await ozoneServiceProfile.createRecords()\n\n await lexiconAuthorityProfile.migrateTo(pds)\n await lexiconAuthorityProfile.createRecords()\n\n await ozone.addAdminDid(ozoneServiceProfile.did)\n await ozone.createPolicies()\n\n await thirdPartyPds.processAll()\n await pds.processAll()\n await ozone.processAll()\n await bsky.sub.processAll()\n await thirdPartyPds.close()\n\n // Weird but if we do this before pds.processAll() somehow appview loses this user and tests in different parts fail because appview doesn't return this user in various contexts anymore\n const ozoneVerifierPassword =\n await ozoneServiceProfile.createAppPasswordForVerification()\n if (ozone.daemon.ctx.cfg.verifier) {\n ozone.daemon.ctx.cfg.verifier.password = ozoneVerifierPassword\n }\n\n let introspect: IntrospectServer | undefined = undefined\n if (params.introspect?.port) {\n introspect = await IntrospectServer.start(\n params.introspect.port,\n plc,\n pds,\n bsky,\n ozone,\n )\n }\n\n return new TestNetwork(plc, pds, bsky, ozone, introspect)\n }\n\n async processFullSubscription(timeout = 5000) {\n const sub = this.bsky.sub\n // If the subscription is not running, there is no point in\n // waiting for it to process events\n if (!sub.running) return\n const start = Date.now()\n const lastSeq = await this.pds.ctx.sequencer.curr()\n if (!lastSeq) return\n while (Date.now() - start < timeout) {\n await sub.processAll()\n const runnerCursor = await sub.getCursor()\n // if subscription claims to be done, ensure we are at the most recent cursor from PDS, else wait to process again\n // (the subscription may claim to be finished before the PDS has even emitted it's event)\n if (runnerCursor && runnerCursor >= lastSeq) {\n return\n }\n await wait(5)\n }\n throw new Error(`Sequence was not processed within ${timeout}ms`)\n }\n\n async processAll(timeout?: number) {\n await this.pds.processAll()\n await this.ozone.processAll()\n await this.processFullSubscription(timeout)\n }\n\n async serviceHeaders(did: string, lxm: string, aud?: string) {\n const keypair = await this.pds.ctx.actorStore.keypair(did)\n const jwt = await createServiceJwt({\n iss: did,\n aud: aud ?? this.bsky.ctx.cfg.serverDid,\n lxm,\n keypair,\n })\n return { authorization: `Bearer ${jwt}` }\n }\n\n async adminHeaders({\n username = ADMIN_USERNAME,\n password = ADMIN_PASSWORD,\n }: {\n username?: string\n password?: string\n }) {\n return {\n authorization:\n 'Basic ' +\n uint8arrays.toString(\n uint8arrays.fromString(`${username}:${password}`, 'utf8'),\n 'base64pad',\n ),\n }\n }\n\n async close() {\n try {\n await this.processAll()\n } finally {\n await allFulfilled([\n ...this.feedGens.map(async (fg) => fg.close()),\n this.ozone.close(),\n this.bsky.close(),\n this.pds.close(),\n this.plc.close(),\n this.introspect?.close(),\n ])\n }\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n"]}
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,OAAO,MAAM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Q,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;gBAC9C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;gBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACjB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;gBAClB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBAChB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE;gBAChB,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE;aACzB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF","sourcesContent":["import assert from 'node:assert'\nimport getPort from 'get-port'\nimport * as uint8arrays from 'uint8arrays'\nimport { allFulfilled, wait } from '@atproto/common-web'\nimport { createServiceJwt } from '@atproto/xrpc-server'\nimport { TestBsky } from './bsky.js'\nimport { TestBsync } from './bsync.js'\nimport { EXAMPLE_LABELER } from './const.js'\nimport { IntrospectServer } from './introspect.js'\nimport { TestNetworkNoAppView } from './network-no-appview.js'\nimport { TestOzone } from './ozone.js'\nimport { TestPds } from './pds.js'\nimport { TestPlc } from './plc.js'\nimport { LexiconAuthorityProfile } from './service-profile-lexicon.js'\nimport { OzoneServiceProfile } from './service-profile-ozone.js'\nimport { TestServerParams } from './types.js'\nimport { mockNetworkUtilities } from './util.js'\n\nconst ADMIN_USERNAME = 'admin'\nconst ADMIN_PASSWORD = 'admin-pass'\n\nexport class TestNetwork extends TestNetworkNoAppView {\n constructor(\n public plc: TestPlc,\n public pds: TestPds,\n public bsync: TestBsync,\n public bsky: TestBsky,\n public ozone: TestOzone,\n public introspect?: IntrospectServer,\n ) {\n super(plc, pds)\n }\n\n static async create(\n params: Partial<TestServerParams> = {},\n ): Promise<TestNetwork> {\n const redisHost = process.env.REDIS_HOST\n const dbPostgresUrl = params.dbPostgresUrl || process.env.DB_POSTGRES_URL\n assert(dbPostgresUrl, 'Missing postgres url for tests')\n assert(redisHost, 'Missing redis host for tests')\n const dbPostgresSchema =\n params.dbPostgresSchema || process.env.DB_POSTGRES_SCHEMA\n\n const plc = await TestPlc.create(params.plc ?? {})\n\n const bskyPort = params.bsky?.port ?? (await getPort())\n const pdsPort = params.pds?.port ?? (await getPort())\n const ozonePort = params.ozone?.port ?? (await getPort())\n\n const thirdPartyPds = await TestPds.create({\n didPlcUrl: plc.url,\n ...params.pds,\n inviteRequired: false,\n port: await getPort(),\n })\n\n const ozoneUrl = `http://localhost:${ozonePort}`\n\n // @TODO (?) rework the ServiceProfile to live on a separate PDS instead of\n // requiring to migrate to the main PDS\n const ozoneServiceProfile = await OzoneServiceProfile.create(\n thirdPartyPds,\n ozoneUrl,\n )\n const lexiconAuthorityProfile =\n await LexiconAuthorityProfile.create(thirdPartyPds)\n\n const bsyncApiKey = 'bsync-api-key'\n const bsync = await TestBsync.create({\n apiKeys: [bsyncApiKey],\n dbUrl: dbPostgresUrl,\n })\n\n const bsky = await TestBsky.create({\n port: bskyPort,\n plcUrl: plc.url,\n pdsPort,\n bsyncApiKey,\n bsyncUrl: bsync.url,\n rolodexUrl: process.env.BSKY_ROLODEX_URL,\n rolodexIgnoreBadTls: true,\n repoProvider: `ws://localhost:${pdsPort}`,\n dbPostgresSchema: `appview_${dbPostgresSchema}`,\n dbPostgresUrl,\n redisHost,\n modServiceDid: ozoneServiceProfile.did,\n labelsFromIssuerDids: [ozoneServiceProfile.did, EXAMPLE_LABELER],\n // Using a static private key results in a static DID, which is useful for e2e tests with the social-app repo.\n privateKey:\n '3f916c70dc69e4c5e83877f013325b11ecac31742e6a42f5c4fb240d0703d9d5=',\n ...params.bsky,\n })\n\n const pds = await TestPds.create({\n port: pdsPort,\n didPlcUrl: plc.url,\n bskyAppViewUrl: bsky.url,\n bskyAppViewDid: bsky.ctx.cfg.serverDid,\n modServiceUrl: ozoneUrl,\n modServiceDid: ozoneServiceProfile.did,\n lexiconDidAuthority: lexiconAuthorityProfile.did,\n ...params.pds,\n })\n\n // mock before any events start flowing from pds so that we don't miss e.g. any handle resolutions.\n mockNetworkUtilities(pds, bsky)\n\n const ozone = await TestOzone.create({\n port: ozonePort,\n plcUrl: plc.url,\n signingKey: ozoneServiceProfile.key,\n serverDid: ozoneServiceProfile.did,\n dbPostgresSchema: `ozone_${dbPostgresSchema || 'db'}`,\n dbPostgresUrl,\n appviewUrl: bsky.url,\n appviewDid: bsky.ctx.cfg.serverDid,\n appviewPushEvents: true,\n pdsUrl: pds.url,\n pdsDid: pds.ctx.cfg.service.did,\n verifierDid: ozoneServiceProfile.did,\n verifierUrl: pds.url,\n verifierPassword: 'temp',\n ...params.ozone,\n })\n\n await ozoneServiceProfile.migrateTo(pds)\n await ozoneServiceProfile.createRecords()\n\n await lexiconAuthorityProfile.migrateTo(pds)\n await lexiconAuthorityProfile.createRecords()\n\n await ozone.addAdminDid(ozoneServiceProfile.did)\n await ozone.createPolicies()\n\n await thirdPartyPds.processAll()\n await pds.processAll()\n await ozone.processAll()\n await bsky.sub.processAll()\n await bsky.bsyncSub.processAll(await bsync.getStreamHeads())\n await thirdPartyPds.close()\n\n // Weird but if we do this before pds.processAll() somehow appview loses this user and tests in different parts fail because appview doesn't return this user in various contexts anymore\n const ozoneVerifierPassword =\n await ozoneServiceProfile.createAppPasswordForVerification()\n if (ozone.daemon.ctx.cfg.verifier) {\n ozone.daemon.ctx.cfg.verifier.password = ozoneVerifierPassword\n }\n\n let introspect: IntrospectServer | undefined = undefined\n if (params.introspect?.port) {\n introspect = await IntrospectServer.start(\n params.introspect.port,\n plc,\n pds,\n bsync,\n bsky,\n ozone,\n )\n }\n\n return new TestNetwork(plc, pds, bsync, bsky, ozone, introspect)\n }\n\n async processFullSubscription(timeout = 5000) {\n const sub = this.bsky.sub\n // If the subscription is not running, there is no point in\n // waiting for it to process events\n if (!sub.running) return\n const start = Date.now()\n const lastSeq = await this.pds.ctx.sequencer.curr()\n if (!lastSeq) return\n while (Date.now() - start < timeout) {\n await sub.processAll()\n const runnerCursor = await sub.getCursor()\n // if subscription claims to be done, ensure we are at the most recent cursor from PDS, else wait to process again\n // (the subscription may claim to be finished before the PDS has even emitted it's event)\n if (runnerCursor && runnerCursor >= lastSeq) {\n return\n }\n await wait(5)\n }\n throw new Error(`Sequence was not processed within ${timeout}ms`)\n }\n\n async processAll(timeout?: number) {\n await this.pds.processAll()\n await this.ozone.processAll()\n await this.bsky.sub.processAll()\n await this.bsky.bsyncSub.processAll(\n await this.bsync.getStreamHeads(),\n timeout,\n )\n await this.processFullSubscription(timeout)\n }\n\n async serviceHeaders(did: string, lxm: string, aud?: string) {\n const keypair = await this.pds.ctx.actorStore.keypair(did)\n const jwt = await createServiceJwt({\n iss: did,\n aud: aud ?? this.bsky.ctx.cfg.serverDid,\n lxm,\n keypair,\n })\n return { authorization: `Bearer ${jwt}` }\n }\n\n async adminHeaders({\n username = ADMIN_USERNAME,\n password = ADMIN_PASSWORD,\n }: {\n username?: string\n password?: string\n }) {\n return {\n authorization:\n 'Basic ' +\n uint8arrays.toString(\n uint8arrays.fromString(`${username}:${password}`, 'utf8'),\n 'base64pad',\n ),\n }\n }\n\n async close() {\n try {\n await this.processAll()\n } finally {\n await allFulfilled([\n ...this.feedGens.map(async (fg) => fg.close()),\n this.ozone.close(),\n this.bsky.close(),\n this.bsync.close(),\n this.pds.close(),\n this.plc.close(),\n this.introspect?.close(),\n ])\n }\n }\n\n async [Symbol.asyncDispose]() {\n await this.close()\n }\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -15,6 +15,7 @@ export type PdsConfig = Partial<pds.ServerEnvironment> & {
15
15
  migration?: string;
16
16
  };
17
17
  export type BskyConfig = Partial<bsky.ServerConfig> & {
18
+ bsyncUrl: string;
18
19
  plcUrl: string;
19
20
  repoProvider: string;
20
21
  dbPostgresUrl: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.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SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,OAAO,CAAA;CACb,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as bsky from '@atproto/bsky'\nimport * as bsync from '@atproto/bsync'\nimport { ExportableKeypair, Keypair } from '@atproto/crypto'\nimport * as ozone from '@atproto/ozone'\nimport * as pds from '@atproto/pds'\n\nexport type IntrospectConfig = {\n port?: number\n}\n\nexport type PlcConfig = {\n port?: number\n version?: string\n}\n\nexport type PdsConfig = Partial<pds.ServerEnvironment> & {\n didPlcUrl: string\n migration?: string\n}\n\nexport type BskyConfig = Partial<bsky.ServerConfig> & {\n plcUrl: string\n repoProvider: string\n dbPostgresUrl: string\n dbPostgresSchema: string\n redisHost: string\n pdsPort: number\n migration?: string\n privateKey?: string\n}\n\nexport type BsyncConfig = Partial<bsync.ServerEnvironment> & {\n dbUrl: string\n}\n\nexport type OzoneConfig = Partial<ozone.OzoneEnvironment> & {\n plcUrl: string\n appviewUrl: string\n appviewDid: string\n dbPostgresUrl: string\n migration?: string\n signingKey?: ExportableKeypair\n imgInvalidator?: ozone.ImageInvalidator\n}\n\nexport type TestServerParams = {\n dbPostgresUrl: string\n dbPostgresSchema: string\n pds: Partial<PdsConfig>\n plc: Partial<PlcConfig>\n bsky: Partial<BskyConfig>\n ozone: Partial<OzoneConfig>\n introspect: Partial<IntrospectConfig>\n}\n\nexport type DidAndKey = {\n did: string\n key: Keypair\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as bsky from '@atproto/bsky'\nimport * as bsync from '@atproto/bsync'\nimport { ExportableKeypair, Keypair } from '@atproto/crypto'\nimport * as ozone from '@atproto/ozone'\nimport * as pds from '@atproto/pds'\n\nexport type IntrospectConfig = {\n port?: number\n}\n\nexport type PlcConfig = {\n port?: number\n version?: string\n}\n\nexport type PdsConfig = Partial<pds.ServerEnvironment> & {\n didPlcUrl: string\n migration?: string\n}\n\nexport type BskyConfig = Partial<bsky.ServerConfig> & {\n bsyncUrl: string\n plcUrl: string\n repoProvider: string\n dbPostgresUrl: string\n dbPostgresSchema: string\n redisHost: string\n pdsPort: number\n migration?: string\n privateKey?: string\n}\n\nexport type BsyncConfig = Partial<bsync.ServerEnvironment> & {\n dbUrl: string\n}\n\nexport type OzoneConfig = Partial<ozone.OzoneEnvironment> & {\n plcUrl: string\n appviewUrl: string\n appviewDid: string\n dbPostgresUrl: string\n migration?: string\n signingKey?: ExportableKeypair\n imgInvalidator?: ozone.ImageInvalidator\n}\n\nexport type TestServerParams = {\n dbPostgresUrl: string\n dbPostgresSchema: string\n pds: Partial<PdsConfig>\n plc: Partial<PlcConfig>\n bsky: Partial<BskyConfig>\n ozone: Partial<OzoneConfig>\n introspect: Partial<IntrospectConfig>\n}\n\nexport type DidAndKey = {\n did: string\n key: Keypair\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/dev-env",
3
- "version": "0.5.20",
3
+ "version": "0.5.22",
4
4
  "license": "MIT",
5
5
  "description": "Local development environment helper for atproto development",
6
6
  "keywords": [
@@ -25,19 +25,19 @@
25
25
  "multiformats": "^13.0.0",
26
26
  "uint8arrays": "^5.0.0",
27
27
  "undici": "^8.5.0",
28
- "@atproto/api": "^0.20.22",
29
- "@atproto/bsync": "^0.0.31",
30
- "@atproto/crypto": "^0.5.2",
28
+ "@atproto/api": "^0.20.23",
29
+ "@atproto/bsky": "^0.0.250",
30
+ "@atproto/bsync": "^0.0.32",
31
31
  "@atproto/common-web": "^0.5.2",
32
- "@atproto/bsky": "^0.0.249",
33
- "@atproto/lexicon": "^0.7.3",
32
+ "@atproto/identity": "^0.5.2",
34
33
  "@atproto/lex": "^0.1.5",
35
- "@atproto/ozone": "^0.2.7",
36
- "@atproto/sync": "^0.3.4",
34
+ "@atproto/lexicon": "^0.7.3",
35
+ "@atproto/crypto": "^0.5.2",
36
+ "@atproto/ozone": "^0.2.8",
37
+ "@atproto/pds": "^0.5.11",
37
38
  "@atproto/syntax": "^0.6.3",
38
- "@atproto/identity": "^0.5.2",
39
- "@atproto/xrpc-server": "^0.11.3",
40
- "@atproto/pds": "^0.5.9"
39
+ "@atproto/xrpc-server": "^0.11.4",
40
+ "@atproto/sync": "^0.3.5"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/express": "^4.17.13"
package/src/bin.ts CHANGED
@@ -49,6 +49,7 @@ const run = async () => {
49
49
  )
50
50
  console.log(`šŸ—¼ Ozone server http://localhost:${network.ozone.port}`)
51
51
  console.log(`šŸ—¼ Ozone service DID ${network.ozone.ctx.cfg.service.did}`)
52
+ console.log(`šŸ”„ Bsync server http://localhost:${network.bsync.port}`)
52
53
  console.log(`šŸŒ… Bsky Appview http://localhost:${network.bsky.port}`)
53
54
  console.log(`šŸŒ… Bsky Appview DID ${network.bsky.serverDid}`)
54
55
  for (const fg of network.feedGens) {
package/src/bsky.ts CHANGED
@@ -17,7 +17,7 @@ export class TestBsky {
17
17
  public db: bsky.Database,
18
18
  public server: bsky.BskyAppView,
19
19
  public dataplane: bsky.DataPlaneServer,
20
- public bsync: bsky.MockBsync,
20
+ public bsyncSub: bsky.BsyncSubscription,
21
21
  public sub: bsky.RepoSubscription,
22
22
  public serverDid: string,
23
23
  ) {}
@@ -66,9 +66,6 @@ export class TestBsky {
66
66
  cfg.plcUrl,
67
67
  )
68
68
 
69
- const bsyncPort = await getPort()
70
- const bsync = await bsky.MockBsync.create(db, bsyncPort)
71
-
72
69
  const config = new bsky.ServerConfig({
73
70
  version: 'unknown',
74
71
  port,
@@ -78,8 +75,8 @@ export class TestBsky {
78
75
  alternateAudienceDids: [],
79
76
  dataplaneUrls: [`http://localhost:${dataplanePort}`],
80
77
  dataplaneHttpVersion: '1.1',
81
- bsyncUrl: `http://localhost:${bsyncPort}`,
82
78
  bsyncHttpVersion: '1.1',
79
+ bsyncApiKey: 'bsync-api-key',
83
80
  modServiceDid: cfg.modServiceDid ?? 'did:example:invalidMod',
84
81
  labelsFromIssuerDids: [EXAMPLE_LABELER],
85
82
  bigThreadUris: new Set(),
@@ -115,6 +112,11 @@ export class TestBsky {
115
112
  signingKey: serviceKeypair,
116
113
  })
117
114
 
115
+ const bsyncSub = new bsky.BsyncSubscription({
116
+ config,
117
+ db,
118
+ })
119
+
118
120
  const sub = new bsky.RepoSubscription({
119
121
  service: cfg.repoProvider,
120
122
  db,
@@ -123,9 +125,19 @@ export class TestBsky {
123
125
 
124
126
  await server.start()
125
127
 
128
+ bsyncSub.start()
126
129
  void sub.start()
127
130
 
128
- return new TestBsky(url, port, db, server, dataplane, bsync, sub, serverDid)
131
+ return new TestBsky(
132
+ url,
133
+ port,
134
+ db,
135
+ server,
136
+ dataplane,
137
+ bsyncSub,
138
+ sub,
139
+ serverDid,
140
+ )
129
141
  }
130
142
 
131
143
  get ctx(): bsky.AppContext {
@@ -164,7 +176,7 @@ export class TestBsky {
164
176
  await this.server.destroy()
165
177
  } finally {
166
178
  try {
167
- await this.bsync.destroy()
179
+ await this.bsyncSub.destroy()
168
180
  } finally {
169
181
  try {
170
182
  await this.dataplane.destroy()
package/src/bsync.ts CHANGED
@@ -16,6 +16,10 @@ export class TestBsync {
16
16
  const config = bsync.envToCfg({
17
17
  port,
18
18
  apiKeys: cfg.apiKeys ?? ['api-key'],
19
+ dbSchema: 'bsync',
20
+ // Keep the pool small: a bsync runs alongside every test network, so a
21
+ // default-sized pool per network quickly exhausts postgres connections.
22
+ dbPoolSize: cfg.dbPoolSize ?? 5,
19
23
  ...cfg,
20
24
  })
21
25
 
@@ -30,6 +34,32 @@ export class TestBsync {
30
34
  return this.service.ctx
31
35
  }
32
36
 
37
+ /**
38
+ * Current head (max id) of each operation stream. Used to wait for the bsky
39
+ * bsync subscription to catch up in tests, without waiting for the long-poll
40
+ * timeout.
41
+ */
42
+ async getStreamHeads(): Promise<{
43
+ op?: string
44
+ mute?: string
45
+ notif?: string
46
+ }> {
47
+ const db = this.ctx.db.db
48
+ const max = async (table: 'operation' | 'mute_op' | 'notif_op') => {
49
+ const row = await db
50
+ .selectFrom(table)
51
+ .select((eb) => eb.fn.max('id').as('id'))
52
+ .executeTakeFirst()
53
+ return row?.id != null ? String(row.id) : undefined
54
+ }
55
+ const [op, mute, notif] = await Promise.all([
56
+ max('operation'),
57
+ max('mute_op'),
58
+ max('notif_op'),
59
+ ])
60
+ return { op, mute, notif }
61
+ }
62
+
33
63
  async close() {
34
64
  await this.service.destroy()
35
65
  }
package/src/introspect.ts CHANGED
@@ -4,6 +4,7 @@ import express from 'express'
4
4
  // eslint-disable-next-line import/default
5
5
  import httpTerminator from 'http-terminator'
6
6
  import { TestBsky } from './bsky.js'
7
+ import { TestBsync } from './bsync.js'
7
8
  import { TestOzone } from './ozone.js'
8
9
  import { TestPds } from './pds.js'
9
10
  import { TestPlc } from './plc.js'
@@ -21,6 +22,7 @@ export class IntrospectServer {
21
22
  port: number,
22
23
  plc: TestPlc,
23
24
  pds: TestPds,
25
+ bsync: TestBsync,
24
26
  bsky: TestBsky,
25
27
  ozone: TestOzone,
26
28
  ) {
@@ -34,6 +36,9 @@ export class IntrospectServer {
34
36
  url: pds.url,
35
37
  did: pds.ctx.cfg.service.did,
36
38
  },
39
+ bsync: {
40
+ url: bsync.url,
41
+ },
37
42
  bsky: {
38
43
  url: bsky.url,
39
44
  did: bsky.ctx.cfg.serverDid,
package/src/network.ts CHANGED
@@ -4,6 +4,7 @@ import * as uint8arrays from 'uint8arrays'
4
4
  import { allFulfilled, wait } from '@atproto/common-web'
5
5
  import { createServiceJwt } from '@atproto/xrpc-server'
6
6
  import { TestBsky } from './bsky.js'
7
+ import { TestBsync } from './bsync.js'
7
8
  import { EXAMPLE_LABELER } from './const.js'
8
9
  import { IntrospectServer } from './introspect.js'
9
10
  import { TestNetworkNoAppView } from './network-no-appview.js'
@@ -22,6 +23,7 @@ export class TestNetwork extends TestNetworkNoAppView {
22
23
  constructor(
23
24
  public plc: TestPlc,
24
25
  public pds: TestPds,
26
+ public bsync: TestBsync,
25
27
  public bsky: TestBsky,
26
28
  public ozone: TestOzone,
27
29
  public introspect?: IntrospectServer,
@@ -63,10 +65,18 @@ export class TestNetwork extends TestNetworkNoAppView {
63
65
  const lexiconAuthorityProfile =
64
66
  await LexiconAuthorityProfile.create(thirdPartyPds)
65
67
 
68
+ const bsyncApiKey = 'bsync-api-key'
69
+ const bsync = await TestBsync.create({
70
+ apiKeys: [bsyncApiKey],
71
+ dbUrl: dbPostgresUrl,
72
+ })
73
+
66
74
  const bsky = await TestBsky.create({
67
75
  port: bskyPort,
68
76
  plcUrl: plc.url,
69
77
  pdsPort,
78
+ bsyncApiKey,
79
+ bsyncUrl: bsync.url,
70
80
  rolodexUrl: process.env.BSKY_ROLODEX_URL,
71
81
  rolodexIgnoreBadTls: true,
72
82
  repoProvider: `ws://localhost:${pdsPort}`,
@@ -126,6 +136,7 @@ export class TestNetwork extends TestNetworkNoAppView {
126
136
  await pds.processAll()
127
137
  await ozone.processAll()
128
138
  await bsky.sub.processAll()
139
+ await bsky.bsyncSub.processAll(await bsync.getStreamHeads())
129
140
  await thirdPartyPds.close()
130
141
 
131
142
  // Weird but if we do this before pds.processAll() somehow appview loses this user and tests in different parts fail because appview doesn't return this user in various contexts anymore
@@ -141,12 +152,13 @@ export class TestNetwork extends TestNetworkNoAppView {
141
152
  params.introspect.port,
142
153
  plc,
143
154
  pds,
155
+ bsync,
144
156
  bsky,
145
157
  ozone,
146
158
  )
147
159
  }
148
160
 
149
- return new TestNetwork(plc, pds, bsky, ozone, introspect)
161
+ return new TestNetwork(plc, pds, bsync, bsky, ozone, introspect)
150
162
  }
151
163
 
152
164
  async processFullSubscription(timeout = 5000) {
@@ -173,6 +185,11 @@ export class TestNetwork extends TestNetworkNoAppView {
173
185
  async processAll(timeout?: number) {
174
186
  await this.pds.processAll()
175
187
  await this.ozone.processAll()
188
+ await this.bsky.sub.processAll()
189
+ await this.bsky.bsyncSub.processAll(
190
+ await this.bsync.getStreamHeads(),
191
+ timeout,
192
+ )
176
193
  await this.processFullSubscription(timeout)
177
194
  }
178
195
 
@@ -212,6 +229,7 @@ export class TestNetwork extends TestNetworkNoAppView {
212
229
  ...this.feedGens.map(async (fg) => fg.close()),
213
230
  this.ozone.close(),
214
231
  this.bsky.close(),
232
+ this.bsync.close(),
215
233
  this.pds.close(),
216
234
  this.plc.close(),
217
235
  this.introspect?.close(),
package/src/types.ts CHANGED
@@ -19,6 +19,7 @@ export type PdsConfig = Partial<pds.ServerEnvironment> & {
19
19
  }
20
20
 
21
21
  export type BskyConfig = Partial<bsky.ServerConfig> & {
22
+ bsyncUrl: string
22
23
  plcUrl: string
23
24
  repoProvider: string
24
25
  dbPostgresUrl: string