@atproto/bsync 0.0.34 → 0.0.36
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 +18 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +4 -4
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +0 -3
- package/dist/context.js.map +1 -1
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations/20240108T220751294Z-init.d.ts +1 -1
- package/dist/db/migrations/20240108T220751294Z-init.d.ts.map +1 -1
- package/dist/db/migrations/20240108T220751294Z-init.js.map +1 -1
- package/dist/db/migrations/20240717T224303472Z-notif-ops.d.ts +1 -1
- package/dist/db/migrations/20240717T224303472Z-notif-ops.d.ts.map +1 -1
- package/dist/db/migrations/20240717T224303472Z-notif-ops.js.map +1 -1
- package/dist/db/migrations/20250527T022203400Z-add-operation.d.ts +1 -1
- package/dist/db/migrations/20250527T022203400Z-add-operation.d.ts.map +1 -1
- package/dist/db/migrations/20250527T022203400Z-add-operation.js.map +1 -1
- package/dist/db/migrations/20250603T163446567Z-alter-operation.d.ts +1 -1
- package/dist/db/migrations/20250603T163446567Z-alter-operation.d.ts.map +1 -1
- package/dist/db/migrations/20250603T163446567Z-alter-operation.js.map +1 -1
- package/dist/db/migrations/provider.d.ts +1 -1
- package/dist/db/migrations/provider.d.ts.map +1 -1
- package/dist/db/migrations/provider.js.map +1 -1
- package/dist/db/schema/index.d.ts +6 -7
- package/dist/db/schema/index.d.ts.map +1 -1
- package/dist/db/schema/index.js.map +1 -1
- package/dist/db/schema/mute_item.d.ts +1 -1
- package/dist/db/schema/mute_item.d.ts.map +1 -1
- package/dist/db/schema/mute_item.js.map +1 -1
- package/dist/db/schema/mute_op.d.ts +2 -2
- package/dist/db/schema/mute_op.d.ts.map +1 -1
- package/dist/db/schema/mute_op.js.map +1 -1
- package/dist/db/schema/notif_item.d.ts +1 -1
- package/dist/db/schema/notif_item.d.ts.map +1 -1
- package/dist/db/schema/notif_item.js.map +1 -1
- package/dist/db/schema/notif_op.d.ts +1 -1
- package/dist/db/schema/notif_op.d.ts.map +1 -1
- package/dist/db/schema/notif_op.js.map +1 -1
- package/dist/db/schema/operation.d.ts +2 -2
- package/dist/db/schema/operation.d.ts.map +1 -1
- package/dist/db/schema/operation.js.map +1 -1
- package/dist/db/types.d.ts +2 -2
- package/dist/db/types.d.ts.map +1 -1
- package/dist/db/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/routes/add-mute-operation.d.ts +3 -3
- package/dist/routes/add-mute-operation.d.ts.map +1 -1
- package/dist/routes/add-mute-operation.js.map +1 -1
- package/dist/routes/add-notif-operation.d.ts +3 -3
- package/dist/routes/add-notif-operation.d.ts.map +1 -1
- package/dist/routes/add-notif-operation.js.map +1 -1
- package/dist/routes/auth.d.ts +2 -2
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/delete-operations.d.ts +3 -3
- package/dist/routes/delete-operations.d.ts.map +1 -1
- package/dist/routes/delete-operations.js.map +1 -1
- package/dist/routes/index.d.ts +2 -2
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/put-operation.d.ts +3 -3
- package/dist/routes/put-operation.d.ts.map +1 -1
- package/dist/routes/put-operation.js.map +1 -1
- package/dist/routes/scan-mute-operations.d.ts +3 -3
- package/dist/routes/scan-mute-operations.d.ts.map +1 -1
- package/dist/routes/scan-mute-operations.js.map +1 -1
- package/dist/routes/scan-notif-operations.d.ts +3 -3
- package/dist/routes/scan-notif-operations.d.ts.map +1 -1
- package/dist/routes/scan-notif-operations.js.map +1 -1
- package/dist/routes/scan-operations.d.ts +3 -3
- package/dist/routes/scan-operations.d.ts.map +1 -1
- package/dist/routes/scan-operations.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atproto/bsync
|
|
2
2
|
|
|
3
|
+
## 0.0.36
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`9e1da84`](https://github.com/bluesky-social/atproto/commit/9e1da84cc00a1cc5b453705539a2766403f3ee55)]:
|
|
8
|
+
- @atproto/syntax@0.7.2
|
|
9
|
+
- @atproto/common@0.7.2
|
|
10
|
+
|
|
11
|
+
## 0.0.35
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#5197](https://github.com/bluesky-social/atproto/pull/5197) [`a0c49d9`](https://github.com/bluesky-social/atproto/commit/a0c49d9e8bc685c5a747a8d3b2775c73c63fdb6f) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Rewrite import statements to be compatible with TypeScript's `verbatimModuleSyntax` config.
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`a0c49d9`](https://github.com/bluesky-social/atproto/commit/a0c49d9e8bc685c5a747a8d3b2775c73c63fdb6f)]:
|
|
18
|
+
- @atproto/common@0.7.1
|
|
19
|
+
- @atproto/syntax@0.7.1
|
|
20
|
+
|
|
3
21
|
## 0.0.34
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Interceptor, PromiseClient } from '@connectrpc/connect';
|
|
2
|
-
import { ConnectTransportOptions } from '@connectrpc/connect-node';
|
|
1
|
+
import { type Interceptor, type PromiseClient } from '@connectrpc/connect';
|
|
2
|
+
import { type ConnectTransportOptions } from '@connectrpc/connect-node';
|
|
3
3
|
import { Service } from './proto/bsync_connect.js';
|
|
4
4
|
export type BsyncClient = PromiseClient<typeof Service>;
|
|
5
5
|
export declare const createClient: (opts: ConnectTransportOptions) => BsyncClient;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAEnB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAElD,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,OAAO,CAAC,CAAA;AAEvD,eAAO,MAAM,YAAY,SAAU,uBAAuB,KAAG,WAG5D,CAAA;AAED,eAAO,MAAM,cAAc,WAChB,MAAM,KAAG,WAKjB,CAAA"}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,GACpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAEL,sBAAsB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAIlD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAA6B,EAAe,EAAE;IACzE,MAAM,SAAS,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAC9C,OAAO,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAChD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GACzB,CAAC,MAAc,EAAe,EAAE,CAChC,CAAC,IAAI,EAAE,EAAE,CACT,CAAC,GAAG,EAAE,EAAE;IACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,EAAE,CAAC,CAAA;IACnD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import {\n Interceptor,\n PromiseClient,\n createPromiseClient,\n} from '@connectrpc/connect'\nimport {\n ConnectTransportOptions,\n createConnectTransport,\n} from '@connectrpc/connect-node'\nimport { Service } from './proto/bsync_connect.js'\n\nexport type BsyncClient = PromiseClient<typeof Service>\n\nexport const createClient = (opts: ConnectTransportOptions): BsyncClient => {\n const transport = createConnectTransport(opts)\n return createPromiseClient(Service, transport)\n}\n\nexport const authWithApiKey =\n (apiKey: string): Interceptor =>\n (next) =>\n (req) => {\n req.header.set('authorization', `Bearer ${apiKey}`)\n return next(req)\n }\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,GACpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAEL,sBAAsB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAIlD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAA6B,EAAe,EAAE;IACzE,MAAM,SAAS,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAC9C,OAAO,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAChD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GACzB,CAAC,MAAc,EAAe,EAAE,CAChC,CAAC,IAAI,EAAE,EAAE,CACT,CAAC,GAAG,EAAE,EAAE;IACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,EAAE,CAAC,CAAA;IACnD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import {\n type Interceptor,\n type PromiseClient,\n createPromiseClient,\n} from '@connectrpc/connect'\nimport {\n type ConnectTransportOptions,\n createConnectTransport,\n} from '@connectrpc/connect-node'\nimport { Service } from './proto/bsync_connect.js'\n\nexport type BsyncClient = PromiseClient<typeof Service>\n\nexport const createClient = (opts: ConnectTransportOptions): BsyncClient => {\n const transport = createConnectTransport(opts)\n return createPromiseClient(Service, transport)\n}\n\nexport const authWithApiKey =\n (apiKey: string): Interceptor =>\n (next) =>\n (req) => {\n req.header.set('authorization', `Bearer ${apiKey}`)\n return next(req)\n }\n"]}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type TypedEmitter from 'typed-emitter';
|
|
2
|
-
import { ServerConfig } from './config.js';
|
|
2
|
+
import type { ServerConfig } from './config.js';
|
|
3
3
|
import { Database } from './db/index.js';
|
|
4
|
-
import { createMuteOpChannel } from './db/schema/mute_op.js';
|
|
5
|
-
import { createNotifOpChannel } from './db/schema/notif_op.js';
|
|
6
|
-
import { createOperationChannel } from './db/schema/operation.js';
|
|
4
|
+
import type { createMuteOpChannel } from './db/schema/mute_op.js';
|
|
5
|
+
import type { createNotifOpChannel } from './db/schema/notif_op.js';
|
|
6
|
+
import type { createOperationChannel } from './db/schema/operation.js';
|
|
7
7
|
export type AppContextOptions = {
|
|
8
8
|
db: Database;
|
|
9
9
|
cfg: ServerConfig;
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,QAAQ,CAAA;IACZ,GAAG,EAAE,YAAY,CAAA;IACjB,QAAQ,EAAE,WAAW,CAAA;CACtB,CAAA;AAED,qBAAa,UAAU;IACrB,EAAE,EAAE,QAAQ,CAAA;IACZ,GAAG,EAAE,YAAY,CAAA;IACjB,QAAQ,EAAE,WAAW,CAAA;IACrB,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAEvC,YAAY,IAAI,EAAE,iBAAiB,EAKlC;IAED,OAAa,UAAU,CACrB,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,WAAW,EACrB,SAAS,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACrC,OAAO,CAAC,UAAU,CAAC,CASrB;CACF;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAA;IACjC,CAAC,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAA;IAClC,CAAC,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAA;CACrC,CAAA"}
|
package/dist/context.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import { Database } from './db/index.js';
|
|
3
|
-
import { createMuteOpChannel } from './db/schema/mute_op.js';
|
|
4
|
-
import { createNotifOpChannel } from './db/schema/notif_op.js';
|
|
5
|
-
import { createOperationChannel } from './db/schema/operation.js';
|
|
6
3
|
export class AppContext {
|
|
7
4
|
constructor(opts) {
|
|
8
5
|
this.db = opts.db;
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAWxC,MAAM,OAAO,UAAU;IAMrB,YAAY,IAAuB;QACjC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;QACjB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,YAAY,EAAqC,CAAA;IACrE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,UAAU,CACrB,GAAiB,EACjB,QAAqB,EACrB,SAAsC;QAEtC,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC;YACtB,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG;YACf,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM;YACrB,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ;YACzB,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,WAAW;YAC/B,iBAAiB,EAAE,GAAG,CAAC,EAAE,CAAC,iBAAiB;SAC5C,CAAC,CAAA;QACF,OAAO,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC,CAAA;IAC5D,CAAC;CACF","sourcesContent":["import { EventEmitter } from 'node:events'\nimport type TypedEmitter from 'typed-emitter'\nimport type { ServerConfig } from './config.js'\nimport { Database } from './db/index.js'\nimport type { createMuteOpChannel } from './db/schema/mute_op.js'\nimport type { createNotifOpChannel } from './db/schema/notif_op.js'\nimport type { createOperationChannel } from './db/schema/operation.js'\n\nexport type AppContextOptions = {\n db: Database\n cfg: ServerConfig\n shutdown: AbortSignal\n}\n\nexport class AppContext {\n db: Database\n cfg: ServerConfig\n shutdown: AbortSignal\n events: TypedEmitter.default<AppEvents>\n\n constructor(opts: AppContextOptions) {\n this.db = opts.db\n this.cfg = opts.cfg\n this.shutdown = opts.shutdown\n this.events = new EventEmitter() as TypedEmitter.default<AppEvents>\n }\n\n static async fromConfig(\n cfg: ServerConfig,\n shutdown: AbortSignal,\n overrides?: Partial<AppContextOptions>,\n ): Promise<AppContext> {\n const db = new Database({\n url: cfg.db.url,\n schema: cfg.db.schema,\n poolSize: cfg.db.poolSize,\n poolMaxUses: cfg.db.poolMaxUses,\n poolIdleTimeoutMs: cfg.db.poolIdleTimeoutMs,\n })\n return new AppContext({ db, cfg, shutdown, ...overrides })\n }\n}\n\nexport type AppEvents = {\n [createMuteOpChannel]: () => void\n [createNotifOpChannel]: () => void\n [createOperationChannel]: () => void\n}\n"]}
|
package/dist/db/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Migrator } from 'kysely/migration';
|
|
|
2
2
|
declare const PgPool: typeof import("pg").Pool;
|
|
3
3
|
type PgPool = InstanceType<typeof PgPool>;
|
|
4
4
|
import type TypedEmitter from 'typed-emitter';
|
|
5
|
-
import { DatabaseSchema } from './schema/index.js';
|
|
6
|
-
import { PgOptions } from './types.js';
|
|
5
|
+
import type { DatabaseSchema } from './schema/index.js';
|
|
6
|
+
import type { PgOptions } from './types.js';
|
|
7
7
|
export declare class Database {
|
|
8
8
|
opts: PgOptions;
|
|
9
9
|
pool: PgPool;
|
package/dist/db/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names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xE,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAA;QAChE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,KAAK,CAAA;QACb,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAChE,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAED,eAAe,QAAQ,CAAA;AAEvB,MAAM,WAAW,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,CAAA;AAC5E,MAAM,aAAa,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAA;AAEhF,QAAQ;AACR,UAAU;AAEV,MAAM,aAAa;IAAnB;QACU,WAAM,GAAG,KAAK,CAAA;IAkBxB,CAAC;IAhBC,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IACpB,CAAC;IAED,cAAc,CAAC,IAA8B;QAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA+B;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AAQD,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE,GAAE,CAAC,CAAA","sourcesContent":["import assert from 'node:assert'\nimport { EventEmitter } from 'node:events'\nimport {\n Kysely,\n KyselyPlugin,\n PluginTransformQueryArgs,\n PluginTransformResultArgs,\n PostgresDialect,\n QueryResult,\n RootOperationNode,\n UnknownRow,\n} from 'kysely'\nimport { Migrator } from 'kysely/migration'\n// eslint-disable-next-line import/default\nimport pg from 'pg'\n// eslint-disable-next-line import/no-named-as-default-member\nconst { Pool: PgPool, types: pgTypes } = pg\ntype PgPool = InstanceType<typeof PgPool>\nimport type TypedEmitter from 'typed-emitter'\nimport { dbLogger } from '../logger.js'\nimport * as migrations from './migrations/index.js'\nimport { DbMigrationProvider } from './migrations/provider.js'\nimport { DatabaseSchema, DatabaseSchemaType } from './schema/index.js'\nimport { PgOptions } from './types.js'\n\nexport class Database {\n pool: PgPool\n db: DatabaseSchema\n migrator: Migrator\n txEvt = new EventEmitter() as TxnEmitter\n destroyed = false\n\n constructor(\n public opts: PgOptions,\n instances?: { db: DatabaseSchema; pool: PgPool },\n ) {\n // if instances are provided, use those\n if (instances) {\n this.db = instances.db\n this.pool = instances.pool\n } else {\n // else create a pool & connect\n const { schema, url } = opts\n const pool =\n opts.pool ??\n new PgPool({\n connectionString: url,\n max: opts.poolSize,\n maxUses: opts.poolMaxUses,\n idleTimeoutMillis: opts.poolIdleTimeoutMs,\n })\n\n // Select count(*) and other pg bigints as js integer\n pgTypes.setTypeParser(pgTypes.builtins.INT8, (n) => parseInt(n, 10))\n\n // Setup schema usage, primarily for test parallelism (each test suite runs in its own pg schema)\n if (schema && !/^[a-z_]+$/i.test(schema)) {\n throw new Error(\n `Postgres schema must only contain [A-Za-z_]: ${schema}`,\n )\n }\n\n pool.on('error', onPoolError)\n pool.on('connect', (client) => {\n client.on('error', onClientError)\n if (schema) {\n // Shared objects such as extensions will go in the public schema\n client.query(`SET search_path TO \"${schema}\",public;`)\n }\n })\n\n this.pool = pool\n this.db = new Kysely<DatabaseSchemaType>({\n dialect: new PostgresDialect({ pool }),\n })\n }\n\n this.migrator = new Migrator({\n db: this.db,\n migrationTableSchema: opts.schema,\n provider: new DbMigrationProvider(migrations),\n })\n }\n\n get schema(): string | undefined {\n return this.opts.schema\n }\n\n get isTransaction() {\n return this.db.isTransaction\n }\n\n assertTransaction() {\n assert(this.isTransaction, 'Transaction required')\n }\n\n assertNotTransaction() {\n assert(!this.isTransaction, 'Cannot be in a transaction')\n }\n\n async transaction<T>(fn: (db: Database) => Promise<T>): Promise<T> {\n const leakyTxPlugin = new LeakyTxPlugin()\n const { dbTxn, txRes } = await this.db\n .withPlugin(leakyTxPlugin)\n .transaction()\n .execute(async (txn) => {\n const dbTxn = new Database(this.opts, {\n db: txn,\n pool: this.pool,\n })\n const txRes = await fn(dbTxn)\n .catch(async (err) => {\n leakyTxPlugin.endTx()\n // ensure that all in-flight queries are flushed & the connection is open\n await dbTxn.db.getExecutor().provideConnection(noopAsync)\n throw err\n })\n .finally(() => leakyTxPlugin.endTx())\n return { dbTxn, txRes }\n })\n dbTxn?.txEvt.emit('commit')\n return txRes\n }\n\n onCommit(fn: () => void) {\n this.assertTransaction()\n this.txEvt.once('commit', fn)\n }\n\n async close(): Promise<void> {\n if (this.destroyed) return\n await this.db.destroy()\n this.destroyed = true\n }\n\n async migrateToOrThrow(migration: string) {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateTo(migration)\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n\n async migrateToLatestOrThrow() {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateToLatest()\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n}\n\nexport default Database\n\nconst onPoolError = (err: Error) => dbLogger.error({ err }, 'db pool error')\nconst onClientError = (err: Error) => dbLogger.error({ err }, 'db client error')\n\n// utils\n// -------\n\nclass LeakyTxPlugin implements KyselyPlugin {\n private txOver = false\n\n endTx() {\n this.txOver = true\n }\n\n transformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n if (this.txOver) {\n throw new Error('tx already failed')\n }\n return args.node\n }\n\n async transformResult(\n args: PluginTransformResultArgs,\n ): Promise<QueryResult<UnknownRow>> {\n return args.result\n }\n}\n\ntype TxnEmitter = TypedEmitter.default<TxnEvents>\n\ntype TxnEvents = {\n commit: () => void\n}\n\nconst noopAsync = async () => {}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EACL,MAAM,EAIN,eAAe,GAIhB,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,0CAA0C;AAC1C,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,6DAA6D;AAC7D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAA;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAI9D,MAAM,OAAO,QAAQ;IAOnB,YACS,IAAe,EACtB,SAAgD;QADzC,SAAI,GAAJ,IAAI,CAAW;QAJxB,UAAK,GAAG,IAAI,YAAY,EAAgB,CAAA;QACxC,cAAS,GAAG,KAAK,CAAA;QAMf,uCAAuC;QACvC,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAA;YACtB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC5B,CAAC;aAAM,CAAC;YACN,+BAA+B;YAC/B,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;YAC5B,MAAM,IAAI,GACR,IAAI,CAAC,IAAI;gBACT,IAAI,MAAM,CAAC;oBACT,gBAAgB,EAAE,GAAG;oBACrB,GAAG,EAA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AI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAChE,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAED,eAAe,QAAQ,CAAA;AAEvB,MAAM,WAAW,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,CAAA;AAC5E,MAAM,aAAa,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAA;AAEhF,QAAQ;AACR,UAAU;AAEV,MAAM,aAAa;IAAnB;QACU,WAAM,GAAG,KAAK,CAAA;IAkBxB,CAAC;IAhBC,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IACpB,CAAC;IAED,cAAc,CAAC,IAA8B;QAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA+B;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AAQD,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE,GAAE,CAAC,CAAA","sourcesContent":["import assert from 'node:assert'\nimport { EventEmitter } from 'node:events'\nimport {\n Kysely,\n type KyselyPlugin,\n type PluginTransformQueryArgs,\n type PluginTransformResultArgs,\n PostgresDialect,\n type QueryResult,\n type RootOperationNode,\n type UnknownRow,\n} from 'kysely'\nimport { Migrator } from 'kysely/migration'\n// eslint-disable-next-line import/default\nimport pg from 'pg'\n// eslint-disable-next-line import/no-named-as-default-member\nconst { Pool: PgPool, types: pgTypes } = pg\ntype PgPool = InstanceType<typeof PgPool>\nimport type TypedEmitter from 'typed-emitter'\nimport { dbLogger } from '../logger.js'\nimport * as migrations from './migrations/index.js'\nimport { DbMigrationProvider } from './migrations/provider.js'\nimport type { DatabaseSchema, DatabaseSchemaType } from './schema/index.js'\nimport type { PgOptions } from './types.js'\n\nexport class Database {\n pool: PgPool\n db: DatabaseSchema\n migrator: Migrator\n txEvt = new EventEmitter() as TxnEmitter\n destroyed = false\n\n constructor(\n public opts: PgOptions,\n instances?: { db: DatabaseSchema; pool: PgPool },\n ) {\n // if instances are provided, use those\n if (instances) {\n this.db = instances.db\n this.pool = instances.pool\n } else {\n // else create a pool & connect\n const { schema, url } = opts\n const pool =\n opts.pool ??\n new PgPool({\n connectionString: url,\n max: opts.poolSize,\n maxUses: opts.poolMaxUses,\n idleTimeoutMillis: opts.poolIdleTimeoutMs,\n })\n\n // Select count(*) and other pg bigints as js integer\n pgTypes.setTypeParser(pgTypes.builtins.INT8, (n) => parseInt(n, 10))\n\n // Setup schema usage, primarily for test parallelism (each test suite runs in its own pg schema)\n if (schema && !/^[a-z_]+$/i.test(schema)) {\n throw new Error(\n `Postgres schema must only contain [A-Za-z_]: ${schema}`,\n )\n }\n\n pool.on('error', onPoolError)\n pool.on('connect', (client) => {\n client.on('error', onClientError)\n if (schema) {\n // Shared objects such as extensions will go in the public schema\n client.query(`SET search_path TO \"${schema}\",public;`)\n }\n })\n\n this.pool = pool\n this.db = new Kysely<DatabaseSchemaType>({\n dialect: new PostgresDialect({ pool }),\n })\n }\n\n this.migrator = new Migrator({\n db: this.db,\n migrationTableSchema: opts.schema,\n provider: new DbMigrationProvider(migrations),\n })\n }\n\n get schema(): string | undefined {\n return this.opts.schema\n }\n\n get isTransaction() {\n return this.db.isTransaction\n }\n\n assertTransaction() {\n assert(this.isTransaction, 'Transaction required')\n }\n\n assertNotTransaction() {\n assert(!this.isTransaction, 'Cannot be in a transaction')\n }\n\n async transaction<T>(fn: (db: Database) => Promise<T>): Promise<T> {\n const leakyTxPlugin = new LeakyTxPlugin()\n const { dbTxn, txRes } = await this.db\n .withPlugin(leakyTxPlugin)\n .transaction()\n .execute(async (txn) => {\n const dbTxn = new Database(this.opts, {\n db: txn,\n pool: this.pool,\n })\n const txRes = await fn(dbTxn)\n .catch(async (err) => {\n leakyTxPlugin.endTx()\n // ensure that all in-flight queries are flushed & the connection is open\n await dbTxn.db.getExecutor().provideConnection(noopAsync)\n throw err\n })\n .finally(() => leakyTxPlugin.endTx())\n return { dbTxn, txRes }\n })\n dbTxn?.txEvt.emit('commit')\n return txRes\n }\n\n onCommit(fn: () => void) {\n this.assertTransaction()\n this.txEvt.once('commit', fn)\n }\n\n async close(): Promise<void> {\n if (this.destroyed) return\n await this.db.destroy()\n this.destroyed = true\n }\n\n async migrateToOrThrow(migration: string) {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateTo(migration)\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n\n async migrateToLatestOrThrow() {\n if (this.schema) {\n await this.db.schema.createSchema(this.schema).ifNotExists().execute()\n }\n const { error, results } = await this.migrator.migrateToLatest()\n if (error) {\n throw error\n }\n if (!results) {\n throw new Error('An unknown failure occurred while migrating')\n }\n return results\n }\n}\n\nexport default Database\n\nconst onPoolError = (err: Error) => dbLogger.error({ err }, 'db pool error')\nconst onClientError = (err: Error) => dbLogger.error({ err }, 'db client error')\n\n// utils\n// -------\n\nclass LeakyTxPlugin implements KyselyPlugin {\n private txOver = false\n\n endTx() {\n this.txOver = true\n }\n\n transformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n if (this.txOver) {\n throw new Error('tx already failed')\n }\n return args.node\n }\n\n async transformResult(\n args: PluginTransformResultArgs,\n ): Promise<QueryResult<UnknownRow>> {\n return args.result\n }\n}\n\ntype TxnEmitter = TypedEmitter.default<TxnEvents>\n\ntype TxnEvents = {\n commit: () => void\n}\n\nconst noopAsync = async () => {}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20240108T220751294Z-init.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20240108T220751294Z-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"20240108T220751294Z-init.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20240108T220751294Z-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAO,MAAM,QAAQ,CAAA;AAEzC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20240108T220751294Z-init.js","sourceRoot":"","sources":["../../../src/db/migrations/20240108T220751294Z-init.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"20240108T220751294Z-init.js","sourceRoot":"","sources":["../../../src/db/migrations/20240108T220751294Z-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,QAAQ,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,SAAS,CAAC;SACtB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SACvD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,4CAA4C;SAC9F,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACvD,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,mBAAmB,CAAC,CAChD;SACA,OAAO,EAAE,CAAA;IACZ,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,WAAW,CAAC;SACxB,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACvD,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACrD,uBAAuB,CAAC,gBAAgB,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;SAClE,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAA;IAChD,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAA;AAChD,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .createTable('mute_op')\n .addColumn('id', 'bigserial', (col) => col.primaryKey())\n .addColumn('type', 'int2', (col) => col.notNull()) // integer enum: 0->add, 1->remove, 2->clear\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('subject', 'varchar', (col) => col.notNull())\n .addColumn('createdAt', 'timestamptz', (col) =>\n col.notNull().defaultTo(sql`CURRENT_TIMESTAMP`),\n )\n .execute()\n await db.schema\n .createTable('mute_item')\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('subject', 'varchar', (col) => col.notNull())\n .addColumn('fromId', 'bigint', (col) => col.notNull())\n .addPrimaryKeyConstraint('mute_item_pkey', ['actorDid', 'subject'])\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropTable('mute_item').execute()\n await db.schema.dropTable('mute_op').execute()\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20240717T224303472Z-notif-ops.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20240717T224303472Z-notif-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"20240717T224303472Z-notif-ops.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20240717T224303472Z-notif-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAO,MAAM,QAAQ,CAAA;AAEzC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20240717T224303472Z-notif-ops.js","sourceRoot":"","sources":["../../../src/db/migrations/20240717T224303472Z-notif-ops.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"20240717T224303472Z-notif-ops.js","sourceRoot":"","sources":["../../../src/db/migrations/20240717T224303472Z-notif-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,QAAQ,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,UAAU,CAAC;SACvB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SACvD,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC;SAChC,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,mBAAmB,CAAC,CAChD;SACA,OAAO,EAAE,CAAA;IACZ,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,YAAY,CAAC;SACzB,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SAC3D,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACrD,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAA;IACjD,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAA;AACjD,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .createTable('notif_op')\n .addColumn('id', 'bigserial', (col) => col.primaryKey())\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('priority', 'boolean')\n .addColumn('createdAt', 'timestamptz', (col) =>\n col.notNull().defaultTo(sql`CURRENT_TIMESTAMP`),\n )\n .execute()\n await db.schema\n .createTable('notif_item')\n .addColumn('actorDid', 'varchar', (col) => col.primaryKey())\n .addColumn('priority', 'boolean', (col) => col.notNull())\n .addColumn('fromId', 'bigint', (col) => col.notNull())\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropTable('notif_item').execute()\n await db.schema.dropTable('notif_op').execute()\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kysely } from 'kysely';
|
|
1
|
+
import { type Kysely } from 'kysely';
|
|
2
2
|
export declare function up(db: Kysely<unknown>): Promise<void>;
|
|
3
3
|
export declare function down(db: Kysely<unknown>): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=20250527T022203400Z-add-operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250527T022203400Z-add-operation.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"20250527T022203400Z-add-operation.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAO,MAAM,QAAQ,CAAA;AAEzC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAa3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250527T022203400Z-add-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"20250527T022203400Z-add-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,QAAQ,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,WAAW,CAAC;SACxB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SACvD,SAAS,CAAC,YAAY,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SAC1D,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACxD,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACpD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACnD,SAAS,CAAC,SAAS,EAAE,GAAG,CAAA,OAAO,CAAC;SAChC,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC7C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,mBAAmB,CAAC,CAChD;SACA,OAAO,EAAE,CAAA;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAA;AAClD,CAAC","sourcesContent":["import { type Kysely, sql } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .createTable('operation')\n .addColumn('id', 'bigserial', (col) => col.primaryKey())\n .addColumn('collection', 'varchar', (col) => col.notNull())\n .addColumn('actorDid', 'varchar', (col) => col.notNull())\n .addColumn('rkey', 'varchar', (col) => col.notNull())\n .addColumn('method', 'int2', (col) => col.notNull())\n .addColumn('payload', sql`bytea`)\n .addColumn('createdAt', 'timestamptz', (col) =>\n col.notNull().defaultTo(sql`CURRENT_TIMESTAMP`),\n )\n .execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema.dropTable('operation').execute()\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kysely } from 'kysely';
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
2
|
export declare function up(db: Kysely<unknown>): Promise<void>;
|
|
3
3
|
export declare function down(db: Kysely<unknown>): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=20250603T163446567Z-alter-operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250603T163446567Z-alter-operation.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20250603T163446567Z-alter-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"20250603T163446567Z-alter-operation.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/20250603T163446567Z-alter-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAO7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250603T163446567Z-alter-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250603T163446567Z-alter-operation.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,YAAY,CAAC,YAAY,EAAE,WAAW,CAAC;SACvC,OAAO,EAAE,CAAA;IAEZ,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC;SACvC,OAAO,EAAE,CAAA;IAEZ,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/E,CAAC","sourcesContent":["import { Kysely } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('operation')\n .renameColumn('collection', 'namespace')\n .execute()\n\n await db.schema.alterTable('operation').renameColumn('rkey', 'key').execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('operation')\n .renameColumn('namespace', 'collection')\n .execute()\n\n await db.schema.alterTable('operation').renameColumn('key', 'rkey').execute()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"20250603T163446567Z-alter-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250603T163446567Z-alter-operation.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAmB;IAC1C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,YAAY,CAAC,YAAY,EAAE,WAAW,CAAC;SACvC,OAAO,EAAE,CAAA;IAEZ,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAmB;IAC5C,MAAM,EAAE,CAAC,MAAM;SACZ,UAAU,CAAC,WAAW,CAAC;SACvB,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC;SACvC,OAAO,EAAE,CAAA;IAEZ,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/E,CAAC","sourcesContent":["import type { Kysely } from 'kysely'\n\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('operation')\n .renameColumn('collection', 'namespace')\n .execute()\n\n await db.schema.alterTable('operation').renameColumn('rkey', 'key').execute()\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await db.schema\n .alterTable('operation')\n .renameColumn('namespace', 'collection')\n .execute()\n\n await db.schema.alterTable('operation').renameColumn('key', 'rkey').execute()\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Migration, MigrationProvider } from 'kysely/migration';
|
|
1
|
+
import type { Migration, MigrationProvider } from 'kysely/migration';
|
|
2
2
|
export declare class DbMigrationProvider implements MigrationProvider {
|
|
3
3
|
private migrations;
|
|
4
4
|
constructor(migrations: Record<string, Migration>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC/C,OAAO,CAAC,UAAU;IAA9B,YAAoB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAI;IACvD,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAExD;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAC9B,YAAoB,UAAqC;0BAArC,UAAU;IAA8B,CAAC;IAC7D,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF","sourcesContent":["import { Migration, MigrationProvider } from 'kysely/migration'\n\nexport class DbMigrationProvider implements MigrationProvider {\n constructor(private migrations: Record<string, Migration>) {}\n async getMigrations(): Promise<Record<string, Migration>> {\n return this.migrations\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAC9B,YAAoB,UAAqC;0BAArC,UAAU;IAA8B,CAAC;IAC7D,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF","sourcesContent":["import type { Migration, MigrationProvider } from 'kysely/migration'\n\nexport class DbMigrationProvider implements MigrationProvider {\n constructor(private migrations: Record<string, Migration>) {}\n async getMigrations(): Promise<Record<string, Migration>> {\n return this.migrations\n }\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Kysely } from 'kysely';
|
|
2
|
-
import * as muteItem from './mute_item.js';
|
|
3
|
-
import * as muteOp from './mute_op.js';
|
|
4
|
-
import * as notifItem from './notif_item.js';
|
|
5
|
-
import * as notifOp from './notif_op.js';
|
|
6
|
-
import * as op from './operation.js';
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import type * as muteItem from './mute_item.js';
|
|
3
|
+
import type * as muteOp from './mute_op.js';
|
|
4
|
+
import type * as notifItem from './notif_item.js';
|
|
5
|
+
import type * as notifOp from './notif_op.js';
|
|
6
|
+
import type * as op from './operation.js';
|
|
7
7
|
export type DatabaseSchemaType = muteItem.PartialDB & muteOp.PartialDB & notifItem.PartialDB & notifOp.PartialDB & op.PartialDB;
|
|
8
8
|
export type DatabaseSchema = Kysely<DatabaseSchemaType>;
|
|
9
|
-
export default DatabaseSchema;
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,SAAS,GACjD,MAAM,CAAC,SAAS,GAChB,SAAS,CAAC,SAAS,GACnB,OAAO,CAAC,SAAS,GACjB,EAAE,CAAC,SAAS,CAAA;AAEd,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"","sourcesContent":["import { Kysely } from 'kysely'\nimport * as muteItem from './mute_item.js'\nimport * as muteOp from './mute_op.js'\nimport * as notifItem from './notif_item.js'\nimport * as notifOp from './notif_op.js'\nimport * as op from './operation.js'\n\nexport type DatabaseSchemaType = muteItem.PartialDB &\n muteOp.PartialDB &\n notifItem.PartialDB &\n notifOp.PartialDB &\n op.PartialDB\n\nexport type DatabaseSchema = Kysely<DatabaseSchemaType>\n
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { Kysely } from 'kysely'\nimport type * as muteItem from './mute_item.js'\nimport type * as muteOp from './mute_op.js'\nimport type * as notifItem from './notif_item.js'\nimport type * as notifOp from './notif_op.js'\nimport type * as op from './operation.js'\n\nexport type DatabaseSchemaType = muteItem.PartialDB &\n muteOp.PartialDB &\n notifItem.PartialDB &\n notifOp.PartialDB &\n op.PartialDB\n\nexport type DatabaseSchema = Kysely<DatabaseSchemaType>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mute_item.d.ts","sourceRoot":"","sources":["../../../src/db/schema/mute_item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"mute_item.d.ts","sourceRoot":"","sources":["../../../src/db/schema/mute_item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAExC,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;AAEhD,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mute_item.js","sourceRoot":"","sources":["../../../src/db/schema/mute_item.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA","sourcesContent":["import { Selectable } from 'kysely'\n\nexport interface MuteItem {\n actorDid: string\n subject: string // did or aturi for list\n fromId: number\n}\n\nexport type MuteItemEntry = Selectable<MuteItem>\n\nexport const tableName = 'mute_item'\n\nexport type PartialDB = { [tableName]: MuteItem }\n"]}
|
|
1
|
+
{"version":3,"file":"mute_item.js","sourceRoot":"","sources":["../../../src/db/schema/mute_item.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA","sourcesContent":["import type { Selectable } from 'kysely'\n\nexport interface MuteItem {\n actorDid: string\n subject: string // did or aturi for list\n fromId: number\n}\n\nexport type MuteItemEntry = Selectable<MuteItem>\n\nexport const tableName = 'mute_item'\n\nexport type PartialDB = { [tableName]: MuteItem }\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GeneratedAlways, Selectable } from 'kysely';
|
|
2
|
-
import { MuteOperation_Type } from '../../proto/bsync_pb.js';
|
|
1
|
+
import type { GeneratedAlways, Selectable } from 'kysely';
|
|
2
|
+
import type { MuteOperation_Type } from '../../proto/bsync_pb.js';
|
|
3
3
|
export interface MuteOp {
|
|
4
4
|
id: GeneratedAlways<number>;
|
|
5
5
|
type: MuteOperation_Type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mute_op.d.ts","sourceRoot":"","sources":["../../../src/db/schema/mute_op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"mute_op.d.ts","sourceRoot":"","sources":["../../../src/db/schema/mute_op.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,kBAAkB,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;CACjC;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;AAE5C,eAAO,MAAM,SAAS,YAAY,CAAA;AAElC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/C,eAAO,MAAM,mBAAmB,mBAAmB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mute_op.js","sourceRoot":"","sources":["../../../src/db/schema/mute_op.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA;AAIlC,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAA,CAAC,0BAA0B","sourcesContent":["import { GeneratedAlways, Selectable } from 'kysely'\nimport { MuteOperation_Type } from '../../proto/bsync_pb.js'\n\nexport interface MuteOp {\n id: GeneratedAlways<number>\n type: MuteOperation_Type // integer enum: 0->add, 1->remove, 2->clear\n actorDid: string\n subject: string // did or aturi for list\n createdAt: GeneratedAlways<Date>\n}\n\nexport type MuteOpEntry = Selectable<MuteOp>\n\nexport const tableName = 'mute_op'\n\nexport type PartialDB = { [tableName]: MuteOp }\n\nexport const createMuteOpChannel = 'mute_op_create' // used with listen/notify\n"]}
|
|
1
|
+
{"version":3,"file":"mute_op.js","sourceRoot":"","sources":["../../../src/db/schema/mute_op.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA;AAIlC,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAA,CAAC,0BAA0B","sourcesContent":["import type { GeneratedAlways, Selectable } from 'kysely'\nimport type { MuteOperation_Type } from '../../proto/bsync_pb.js'\n\nexport interface MuteOp {\n id: GeneratedAlways<number>\n type: MuteOperation_Type // integer enum: 0->add, 1->remove, 2->clear\n actorDid: string\n subject: string // did or aturi for list\n createdAt: GeneratedAlways<Date>\n}\n\nexport type MuteOpEntry = Selectable<MuteOp>\n\nexport const tableName = 'mute_op'\n\nexport type PartialDB = { [tableName]: MuteOp }\n\nexport const createMuteOpChannel = 'mute_op_create' // used with listen/notify\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notif_item.d.ts","sourceRoot":"","sources":["../../../src/db/schema/notif_item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"notif_item.d.ts","sourceRoot":"","sources":["../../../src/db/schema/notif_item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAExC,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;AAElD,eAAO,MAAM,SAAS,eAAe,CAAA;AAErC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notif_item.js","sourceRoot":"","sources":["../../../src/db/schema/notif_item.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA","sourcesContent":["import { Selectable } from 'kysely'\n\nexport interface NotifItem {\n actorDid: string\n priority: boolean\n fromId: number\n}\n\nexport type NotifItemEntry = Selectable<NotifItem>\n\nexport const tableName = 'notif_item'\n\nexport type PartialDB = { [tableName]: NotifItem }\n"]}
|
|
1
|
+
{"version":3,"file":"notif_item.js","sourceRoot":"","sources":["../../../src/db/schema/notif_item.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA","sourcesContent":["import type { Selectable } from 'kysely'\n\nexport interface NotifItem {\n actorDid: string\n priority: boolean\n fromId: number\n}\n\nexport type NotifItemEntry = Selectable<NotifItem>\n\nexport const tableName = 'notif_item'\n\nexport type PartialDB = { [tableName]: NotifItem }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notif_op.d.ts","sourceRoot":"","sources":["../../../src/db/schema/notif_op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"notif_op.d.ts","sourceRoot":"","sources":["../../../src/db/schema/notif_op.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEzD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;CACjC;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;AAE9C,eAAO,MAAM,SAAS,aAAa,CAAA;AAEnC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAEhD,eAAO,MAAM,oBAAoB,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notif_op.js","sourceRoot":"","sources":["../../../src/db/schema/notif_op.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAA;AAInC,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAA,CAAC,0BAA0B","sourcesContent":["import { GeneratedAlways, Selectable } from 'kysely'\n\nexport interface NotifOp {\n id: GeneratedAlways<number>\n actorDid: string\n priority: boolean | null\n createdAt: GeneratedAlways<Date>\n}\n\nexport type NotifOpEntry = Selectable<NotifOp>\n\nexport const tableName = 'notif_op'\n\nexport type PartialDB = { [tableName]: NotifOp }\n\nexport const createNotifOpChannel = 'notif_op_create' // used with listen/notify\n"]}
|
|
1
|
+
{"version":3,"file":"notif_op.js","sourceRoot":"","sources":["../../../src/db/schema/notif_op.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAA;AAInC,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAA,CAAC,0BAA0B","sourcesContent":["import type { GeneratedAlways, Selectable } from 'kysely'\n\nexport interface NotifOp {\n id: GeneratedAlways<number>\n actorDid: string\n priority: boolean | null\n createdAt: GeneratedAlways<Date>\n}\n\nexport type NotifOpEntry = Selectable<NotifOp>\n\nexport const tableName = 'notif_op'\n\nexport type PartialDB = { [tableName]: NotifOp }\n\nexport const createNotifOpChannel = 'notif_op_create' // used with listen/notify\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GeneratedAlways } from 'kysely';
|
|
2
|
-
import { Method } from '../../proto/bsync_pb.js';
|
|
1
|
+
import type { GeneratedAlways } from 'kysely';
|
|
2
|
+
import type { Method } from '../../proto/bsync_pb.js';
|
|
3
3
|
export type OperationMethod = Method.CREATE | Method.UPDATE | Method.DELETE;
|
|
4
4
|
export interface Operation {
|
|
5
5
|
id: GeneratedAlways<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;AAE3E,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;IAChC,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;CACjC;AAED,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,CAAA;AAElD,eAAO,MAAM,sBAAsB,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AAIpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAA,CAAC,0BAA0B","sourcesContent":["import { GeneratedAlways } from 'kysely'\nimport { Method } from '../../proto/bsync_pb.js'\n\nexport type OperationMethod = Method.CREATE | Method.UPDATE | Method.DELETE\n\nexport interface Operation {\n id: GeneratedAlways<number>\n actorDid: string\n namespace: string\n key: string\n method: OperationMethod\n payload: Uint8Array<ArrayBuffer>\n createdAt: GeneratedAlways<Date>\n}\n\nexport const tableName = 'operation'\n\nexport type PartialDB = { [tableName]: Operation }\n\nexport const createOperationChannel = 'operation_create' // used with listen/notify\n"]}
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AAIpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAA,CAAC,0BAA0B","sourcesContent":["import type { GeneratedAlways } from 'kysely'\nimport type { Method } from '../../proto/bsync_pb.js'\n\nexport type OperationMethod = Method.CREATE | Method.UPDATE | Method.DELETE\n\nexport interface Operation {\n id: GeneratedAlways<number>\n actorDid: string\n namespace: string\n key: string\n method: OperationMethod\n payload: Uint8Array<ArrayBuffer>\n createdAt: GeneratedAlways<Date>\n}\n\nexport const tableName = 'operation'\n\nexport type PartialDB = { [tableName]: Operation }\n\nexport const createOperationChannel = 'operation_create' // used with listen/notify\n"]}
|
package/dist/db/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamicModule, RawBuilder, SelectQueryBuilder } from 'kysely';
|
|
2
|
-
import pg from 'pg';
|
|
1
|
+
import type { DynamicModule, RawBuilder, SelectQueryBuilder } from 'kysely';
|
|
2
|
+
import type pg from 'pg';
|
|
3
3
|
type PgPool = pg.Pool;
|
|
4
4
|
export type DbRef = RawBuilder<unknown> | ReturnType<DynamicModule<unknown>['ref']>;
|
|
5
5
|
export type AnyQb = SelectQueryBuilder<any, any, any>;
|
package/dist/db/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAE3E,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,KAAK,MAAM,GAAG,EAAE,CAAC,IAAI,CAAA;AAErB,MAAM,MAAM,KAAK,GACb,UAAU,CAAC,OAAO,CAAC,GACnB,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAE7C,MAAM,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAErD,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAA"}
|
package/dist/db/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"","sourcesContent":["import { DynamicModule, RawBuilder, SelectQueryBuilder } from 'kysely'\n// eslint-disable-next-line import/default\nimport pg from 'pg'\ntype PgPool = pg.Pool\n\nexport type DbRef =\n | RawBuilder<unknown>\n | ReturnType<DynamicModule<unknown>['ref']>\n\nexport type AnyQb = SelectQueryBuilder<any, any, any>\n\nexport type PgOptions = {\n url: string\n pool?: PgPool\n schema?: string\n poolSize?: number\n poolMaxUses?: number\n poolIdleTimeoutMs?: number\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DynamicModule, RawBuilder, SelectQueryBuilder } from 'kysely'\n// eslint-disable-next-line import/default\nimport type pg from 'pg'\ntype PgPool = pg.Pool\n\nexport type DbRef =\n | RawBuilder<unknown>\n | ReturnType<DynamicModule<unknown>['ref']>\n\nexport type AnyQb = SelectQueryBuilder<any, any, any>\n\nexport type PgOptions = {\n url: string\n pool?: PgPool\n schema?: string\n poolSize?: number\n poolMaxUses?: number\n poolIdleTimeoutMs?: number\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
|
-
import { ServerConfig } from './config.js';
|
|
3
|
-
import { AppContext, AppContextOptions } from './context.js';
|
|
2
|
+
import type { ServerConfig } from './config.js';
|
|
3
|
+
import { AppContext, type AppContextOptions } from './context.js';
|
|
4
4
|
export * from './config.js';
|
|
5
5
|
export * from './client.js';
|
|
6
6
|
export { Database } from './db/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAOjE,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,qBAAa,YAAY;IAChB,GAAG,EAAE,UAAU,CAAA;IACf,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;IAC1B,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,KAAK,CAAmC;IAEhD,YAAY,IAAI,EAAE;QAChB,GAAG,EAAE,UAAU,CAAA;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;QACnB,EAAE,EAAE,eAAe,CAAA;KACpB,EAKA;IAED,OAAa,MAAM,CACjB,GAAG,EAAE,YAAY,EACjB,SAAS,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC,CAmBvB;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CA0BlC;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAS7B;IAEK,cAAc,kBAoBnB;CACF;eAEc,YAAY"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,0CAA0C;AAC1C,OAAO,cAAc,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OA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I,CAAC,KAAK,CAAC,UAAU,mBAAmB,EAAE,CAAC,CAAA;QAC3C,IAAI,CAAC,KAAK,CAAC,UAAU,oBAAoB,EAAE,CAAC,CAAA;QAC5C,IAAI,CAAC,KAAK,CAAC,UAAU,sBAAsB,EAAE,CAAC,CAAA;QAC9C,IAAI,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE;YAChC,IAAI,KAAK,CAAC,OAAO,KAAK,mBAAmB,EAAE,CAAC;gBAC1C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;YAC3C,CAAC;YACD,IAAI,KAAK,CAAC,OAAO,KAAK,oBAAoB,EAAE,CAAC;gBAC3C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;YAC5C,CAAC;YACD,IAAI,KAAK,CAAC,OAAO,KAAK,sBAAsB,EAAE,CAAC;gBAC7C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;YAC9C,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,eAAe,YAAY,CAAA;AAE3B,MAAM,QAAQ,GAAG,CAAC,MAA0B,EAAE,EAAE;IAC9C,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACzB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC1C,OAAO,GAAG,CAAC,QAAQ,KAAK,UAAU,CAAA;AACpC,CAAC,CAAA","sourcesContent":["import events, { setMaxListeners } from 'node:events'\nimport http from 'node:http'\nimport { connectNodeAdapter } from '@connectrpc/connect-node'\n// eslint-disable-next-line import/default\nimport httpTerminator from 'http-terminator'\nimport type { ServerConfig } from './config.js'\nimport { AppContext, type AppContextOptions } from './context.js'\nimport { createMuteOpChannel } from './db/schema/mute_op.js'\nimport { createNotifOpChannel } from './db/schema/notif_op.js'\nimport { createOperationChannel } from './db/schema/operation.js'\nimport { dbLogger, loggerMiddleware } from './logger.js'\nimport routes from './routes/index.js'\n\nexport * from './config.js'\nexport * from './client.js'\nexport { Database } from './db/index.js'\nexport { AppContext } from './context.js'\nexport { httpLogger } from './logger.js'\n\ntype BsyncServiceState = 'initialized' | 'started' | 'destroyed'\n\nexport class BsyncService {\n public ctx: AppContext\n public server: http.Server\n private terminator: httpTerminator.HttpTerminator\n private ac: AbortController\n private state: BsyncServiceState = 'initialized'\n\n constructor(opts: {\n ctx: AppContext\n server: http.Server\n ac: AbortController\n }) {\n this.ctx = opts.ctx\n this.server = opts.server\n this.ac = opts.ac\n this.terminator = httpTerminator.createHttpTerminator(opts)\n }\n\n static async create(\n cfg: ServerConfig,\n overrides?: Partial<AppContextOptions>,\n ): Promise<BsyncService> {\n const ac = new AbortController()\n // Prevents unhelpful warnings.\n setMaxListeners(100, ac.signal)\n const ctx = await AppContext.fromConfig(cfg, ac.signal, overrides)\n const handler = connectNodeAdapter({\n routes: routes(ctx),\n shutdownSignal: ac.signal,\n })\n const server = http.createServer((req, res) => {\n loggerMiddleware(req, res)\n if (isHealth(req.url)) {\n res.statusCode = 200\n res.setHeader('content-type', 'application/json')\n return res.end(JSON.stringify({ version: cfg.service.version }))\n }\n handler(req, res)\n })\n return new BsyncService({ ctx, server, ac })\n }\n\n async start(): Promise<http.Server> {\n if (this.state !== 'initialized') {\n throw new Error(`${this.constructor.name} already started`)\n }\n this.state = 'started'\n\n const dbStatsInterval = setInterval(() => {\n dbLogger.info(\n {\n idleCount: this.ctx.db.pool.idleCount,\n totalCount: this.ctx.db.pool.totalCount,\n waitingCount: this.ctx.db.pool.waitingCount,\n },\n 'db pool stats',\n )\n }, 10000)\n\n this.ac.signal.addEventListener('abort', () => {\n clearInterval(dbStatsInterval)\n })\n\n await this.setupAppEvents()\n this.server.listen(this.ctx.cfg.service.port)\n this.server.keepAliveTimeout = 90000\n await events.once(this.server, 'listening')\n return this.server\n }\n\n async destroy(): Promise<void> {\n if (this.state === 'destroyed') return\n this.state = 'destroyed'\n this.ac.abort()\n try {\n await this.terminator.terminate()\n } finally {\n await this.ctx.db.close()\n }\n }\n\n async setupAppEvents() {\n const conn = await this.ctx.db.pool.connect()\n this.ac.signal.addEventListener('abort', () => conn.release(), {\n once: true,\n })\n // if these error, unhandled rejection should cause process to exit\n conn.query(`listen ${createMuteOpChannel}`)\n conn.query(`listen ${createNotifOpChannel}`)\n conn.query(`listen ${createOperationChannel}`)\n conn.on('notification', (notif) => {\n if (notif.channel === createMuteOpChannel) {\n this.ctx.events.emit(createMuteOpChannel)\n }\n if (notif.channel === createNotifOpChannel) {\n this.ctx.events.emit(createNotifOpChannel)\n }\n if (notif.channel === createOperationChannel) {\n this.ctx.events.emit(createOperationChannel)\n }\n })\n }\n}\n\nexport default BsyncService\n\nconst isHealth = (urlStr: string | undefined) => {\n if (!urlStr) return false\n const url = new URL(urlStr, 'http://host')\n return url.pathname === '/_health'\n}\n"]}
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IncomingMessage } from 'node:http';
|
|
2
2
|
import { subsystemLogger } from '@atproto/common';
|
|
3
3
|
export declare const dbLogger: ReturnType<typeof subsystemLogger>;
|
|
4
4
|
export declare const httpLogger: ReturnType<typeof subsystemLogger>;
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEhD,OAAO,EAAoB,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEnE,eAAO,MAAM,QAAQ,EAAE,UAAU,CAAC,OAAO,eAAe,CAC3B,CAAA;AAC7B,eAAO,MAAM,UAAU,EAAE,UAAU,CAAC,OAAO,eAAe,CAChC,CAAA;AAE1B,eAAO,MAAM,gBAAgB,wGAgB3B,CAAA"}
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEnE,MAAM,CAAC,MAAM,QAAQ,GACnB,eAAe,CAAC,UAAU,CAAC,CAAA;AAC7B,MAAM,CAAC,MAAM,UAAU,GACrB,eAAe,CAAC,OAAO,CAAC,CAAA;AAE1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,2BAA2B,CAAC;KACrC;IACD,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,CAAC;YAClB,IAAI,EAAE,GAAG,EAAE,IAAI;YACf,OAAO,EAAE,GAAG,EAAE,OAAO;SACtB,CAAC;QACF,GAAG,EAAE,CAAC,GAAoB,EAAE,EAAE;YAC5B,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC1C,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;YACpD,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,CAAA;QACnC,CAAC;KACF;CACF,CAAC,CAAA","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEnE,MAAM,CAAC,MAAM,QAAQ,GACnB,eAAe,CAAC,UAAU,CAAC,CAAA;AAC7B,MAAM,CAAC,MAAM,UAAU,GACrB,eAAe,CAAC,OAAO,CAAC,CAAA;AAE1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,2BAA2B,CAAC;KACrC;IACD,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,CAAC;YAClB,IAAI,EAAE,GAAG,EAAE,IAAI;YACf,OAAO,EAAE,GAAG,EAAE,OAAO;SACtB,CAAC;QACF,GAAG,EAAE,CAAC,GAAoB,EAAE,EAAE;YAC5B,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC1C,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;YACpD,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,CAAA;QACnC,CAAC;KACF;CACF,CAAC,CAAA","sourcesContent":["import type { IncomingMessage } from 'node:http'\nimport { pinoHttp, stdSerializers } from 'pino-http'\nimport { obfuscateHeaders, subsystemLogger } from '@atproto/common'\n\nexport const dbLogger: ReturnType<typeof subsystemLogger> =\n subsystemLogger('bsync:db')\nexport const httpLogger: ReturnType<typeof subsystemLogger> =\n subsystemLogger('bsync')\n\nexport const loggerMiddleware = pinoHttp({\n logger: httpLogger,\n redact: {\n paths: ['req.headers.authorization'],\n },\n serializers: {\n err: (err: any) => ({\n code: err?.code,\n message: err?.message,\n }),\n req: (req: IncomingMessage) => {\n const serialized = stdSerializers.req(req)\n const headers = obfuscateHeaders(serialized.headers)\n return { ...serialized, headers }\n },\n },\n})\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
3
|
-
import { Service } from '../proto/bsync_connect.js';
|
|
1
|
+
import { type ServiceImpl } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
|
+
import type { Service } from '../proto/bsync_connect.js';
|
|
4
4
|
declare const _default: (ctx: AppContext) => Partial<ServiceImpl<typeof Service>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=add-mute-operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-mute-operation.d.ts","sourceRoot":"","sources":["../../src/routes/add-mute-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"add-mute-operation.d.ts","sourceRoot":"","sources":["../../src/routes/add-mute-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAG1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;8BAQnC,UAAU,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-mute-operation.js","sourceRoot":"","sources":["../../src/routes/add-mute-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"add-mute-operation.js","sourceRoot":"","sources":["../../src/routes/add-mute-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAoB,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MA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,CAAC,eAAe,CACrB,CAAA;IACH,CAAC;IACD,IAAI,EAAE,CAAC,IAAI,KAAK,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,EAAE,CAAC,OAAO,KAAK,EAAE,EAAE,CAAC;YACtB,MAAM,IAAI,YAAY,CACpB,uCAAuC,EACvC,IAAI,CAAC,eAAe,CACrB,CAAA;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,WAAW;QACb,CAAC;aAAM,IAAI,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAA;YACjC,IACE,GAAG,CAAC,UAAU,KAAK,qBAAqB;gBACxC,GAAG,CAAC,UAAU,KAAK,oBAAoB,EACvC,CAAC;gBACD,MAAM,IAAI,YAAY,CACpB,qDAAqD,EACrD,IAAI,CAAC,eAAe,CACrB,CAAA;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,YAAY,CACpB,oDAAoD,EACpD,IAAI,CAAC,eAAe,CACrB,CAAA;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAqB,CAAA,CAAC,2BAA2B;AAC1D,CAAC,CAAA","sourcesContent":["import { Code, ConnectError, type ServiceImpl } from '@connectrpc/connect'\nimport { sql } from 'kysely'\nimport { AtUri } from '@atproto/syntax'\nimport type { AppContext } from '../context.js'\nimport type { Database } from '../db/index.js'\nimport { createMuteOpChannel } from '../db/schema/mute_op.js'\nimport type { Service } from '../proto/bsync_connect.js'\nimport {\n AddMuteOperationResponse,\n MuteOperation_Type,\n} from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { isValidAtUri, isValidDid } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async addMuteOperation(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db } = ctx\n const op = validMuteOp(req)\n const id = await db.transaction(async (txn) => {\n // create mute op\n const id = await createMuteOp(txn, op)\n // update mute state\n if (op.type === MuteOperation_Type.ADD) {\n await addMuteItem(txn, id, op)\n } else if (op.type === MuteOperation_Type.REMOVE) {\n await removeMuteItem(txn, op)\n } else if (op.type === MuteOperation_Type.CLEAR) {\n await clearMuteItems(txn, op)\n } else {\n const exhaustiveCheck: never = op.type\n throw new Error(`unreachable: ${exhaustiveCheck}`)\n }\n return id\n })\n return new AddMuteOperationResponse({\n operation: {\n id: String(id),\n type: op.type,\n actorDid: op.actorDid,\n subject: op.subject,\n },\n })\n },\n})\n\nconst createMuteOp = async (db: Database, op: MuteOpInfo) => {\n const { ref } = db.db.dynamic\n const { id } = await db.db\n .insertInto('mute_op')\n .values({\n type: op.type,\n actorDid: op.actorDid,\n subject: op.subject,\n })\n .returning('id')\n .executeTakeFirstOrThrow()\n await sql`notify ${ref(createMuteOpChannel)}`.execute(db.db) // emitted transactionally\n return id\n}\n\nconst addMuteItem = async (db: Database, fromId: number, op: MuteOpInfo) => {\n const { ref } = db.db.dynamic\n await db.db\n .insertInto('mute_item')\n .values({\n actorDid: op.actorDid,\n subject: op.subject,\n fromId,\n })\n .onConflict((oc) =>\n oc\n .constraint('mute_item_pkey')\n .doUpdateSet({ fromId: sql`${ref('excluded.fromId')}` }),\n )\n .execute()\n}\n\nconst removeMuteItem = async (db: Database, op: MuteOpInfo) => {\n await db.db\n .deleteFrom('mute_item')\n .where('actorDid', '=', op.actorDid)\n .where('subject', '=', op.subject)\n .execute()\n}\n\nconst clearMuteItems = async (db: Database, op: MuteOpInfo) => {\n await db.db\n .deleteFrom('mute_item')\n .where('actorDid', '=', op.actorDid)\n .execute()\n}\n\nconst validMuteOp = (op: MuteOpInfo): MuteOpInfoValid => {\n if (!Object.values(MuteOperation_Type).includes(op.type)) {\n throw new ConnectError('bad mute operation type', Code.InvalidArgument)\n }\n if (op.type === MuteOperation_Type.UNSPECIFIED) {\n throw new ConnectError(\n 'unspecified mute operation type',\n Code.InvalidArgument,\n )\n }\n if (!isValidDid(op.actorDid)) {\n throw new ConnectError(\n 'actor_did must be a valid did',\n Code.InvalidArgument,\n )\n }\n if (op.type === MuteOperation_Type.CLEAR) {\n if (op.subject !== '') {\n throw new ConnectError(\n 'subject must not be set on a clear op',\n Code.InvalidArgument,\n )\n }\n } else {\n if (isValidDid(op.subject)) {\n // all good\n } else if (isValidAtUri(op.subject)) {\n const uri = new AtUri(op.subject)\n if (\n uri.collection !== 'app.bsky.graph.list' &&\n uri.collection !== 'app.bsky.feed.post'\n ) {\n throw new ConnectError(\n 'subject aturis must reference a list or post record',\n Code.InvalidArgument,\n )\n }\n } else {\n throw new ConnectError(\n 'subject must be a did or aturi on add or remove op',\n Code.InvalidArgument,\n )\n }\n }\n return op as MuteOpInfoValid // op.type has been checked\n}\n\ntype MuteOpInfo = {\n type: MuteOperation_Type\n actorDid: string\n subject: string\n}\n\ntype MuteOpInfoValid = {\n type:\n | MuteOperation_Type.ADD\n | MuteOperation_Type.REMOVE\n | MuteOperation_Type.CLEAR\n actorDid: string\n subject: string\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
3
|
-
import { Service } from '../proto/bsync_connect.js';
|
|
1
|
+
import { type ServiceImpl } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
|
+
import type { Service } from '../proto/bsync_connect.js';
|
|
4
4
|
declare const _default: (ctx: AppContext) => Partial<ServiceImpl<typeof Service>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=add-notif-operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-notif-operation.d.ts","sourceRoot":"","sources":["../../src/routes/add-notif-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"add-notif-operation.d.ts","sourceRoot":"","sources":["../../src/routes/add-notif-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;8BAKnC,UAAU,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-notif-operation.js","sourceRoot":"","sources":["../../src/routes/add-notif-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"add-notif-operation.js","sourceRoot":"","sources":["../../src/routes/add-notif-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAoB,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAG5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,eAAe,CAAC,GAAe,EAAwC,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,iBAAiB,CAAC,GAAG,EAAE,UAAU;QACrC,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC/B,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAA;QAClB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;QAClC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YA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iB,EACjB,EAAE;IACF,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,CAAA;IAC7B,MAAM,EAAE,CAAC,EAAE;SACR,UAAU,CAAC,YAAY,CAAC;SACxB,MAAM,CAAC;QACN,QAAQ;QACR,QAAQ;QACR,MAAM;KACP,CAAC;SACD,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CACjB,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC;QAChC,QAAQ,EAAE,GAAG,CAAA,GAAG,GAAG,CAAC,mBAAmB,CAAC,EAAE;QAC1C,MAAM,EAAE,GAAG,CAAA,GAAG,GAAG,CAAC,iBAAiB,CAAC,EAAE;KACvC,CAAC,CACH;SACA,OAAO,EAAE,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { Code, ConnectError, type ServiceImpl } from '@connectrpc/connect'\nimport { sql } from 'kysely'\nimport type { AppContext } from '../context.js'\nimport type { Database } from '../db/index.js'\nimport { createNotifOpChannel } from '../db/schema/notif_op.js'\nimport type { Service } from '../proto/bsync_connect.js'\nimport { AddNotifOperationResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { isValidDid } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async addNotifOperation(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db } = ctx\n const { actorDid, priority } = req\n if (!isValidDid(actorDid)) {\n throw new ConnectError(\n 'actor_did must be a valid did',\n Code.InvalidArgument,\n )\n }\n const id = await db.transaction(async (txn) => {\n // create notif op\n const id = await createNotifOp(txn, actorDid, priority)\n // update notif state\n if (priority !== undefined) {\n await updateNotifItem(txn, id, actorDid, priority)\n }\n return id\n })\n return new AddNotifOperationResponse({\n operation: {\n id: String(id),\n actorDid,\n priority,\n },\n })\n },\n})\n\nconst createNotifOp = async (\n db: Database,\n actorDid: string,\n priority: boolean | undefined,\n) => {\n const { ref } = db.db.dynamic\n const { id } = await db.db\n .insertInto('notif_op')\n .values({\n actorDid,\n priority,\n })\n .returning('id')\n .executeTakeFirstOrThrow()\n await sql`notify ${ref(createNotifOpChannel)}`.execute(db.db) // emitted transactionally\n return id\n}\n\nconst updateNotifItem = async (\n db: Database,\n fromId: number,\n actorDid: string,\n priority: boolean,\n) => {\n const { ref } = db.db.dynamic\n await db.db\n .insertInto('notif_item')\n .values({\n actorDid,\n priority,\n fromId,\n })\n .onConflict((oc) =>\n oc.column('actorDid').doUpdateSet({\n priority: sql`${ref('excluded.priority')}`,\n fromId: sql`${ref('excluded.fromId')}`,\n }),\n )\n .execute()\n}\n"]}
|
package/dist/routes/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HandlerContext } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
1
|
+
import { type HandlerContext } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
3
|
export declare const authWithApiKey: (ctx: AppContext, handlerCtx: HandlerContext) => void;
|
|
4
4
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI/C,eAAO,MAAM,cAAc,QAAS,UAAU,cAAc,cAAc,SASzE,CAAA"}
|
package/dist/routes/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAuB,MAAM,qBAAqB,CAAA;AAG7E,MAAM,MAAM,GAAG,SAAS,CAAA;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAe,EAAE,UAA0B,EAAE,EAAE;IAC5E,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IACnE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;IAC9D,CAAC;IACD,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC9C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;IACjE,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { Code, ConnectError, type HandlerContext } from '@connectrpc/connect'\nimport type { AppContext } from '../context.js'\n\nconst BEARER = 'Bearer '\n\nexport const authWithApiKey = (ctx: AppContext, handlerCtx: HandlerContext) => {\n const authorization = handlerCtx.requestHeader.get('authorization')\n if (!authorization?.startsWith(BEARER)) {\n throw new ConnectError('missing auth', Code.Unauthenticated)\n }\n const key = authorization.slice(BEARER.length)\n if (!ctx.cfg.auth.apiKeys.has(key)) {\n throw new ConnectError('invalid api key', Code.Unauthenticated)\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
3
|
-
import { Service } from '../proto/bsync_connect.js';
|
|
1
|
+
import { type ServiceImpl } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
|
+
import type { Service } from '../proto/bsync_connect.js';
|
|
4
4
|
declare const _default: (ctx: AppContext) => Partial<ServiceImpl<typeof Service>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=delete-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-operations.d.ts","sourceRoot":"","sources":["../../src/routes/delete-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"delete-operations.d.ts","sourceRoot":"","sources":["../../src/routes/delete-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;8BAKnC,UAAU,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-operations.js","sourceRoot":"","sources":["../../src/routes/delete-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"delete-operations.js","sourceRoot":"","sources":["../../src/routes/delete-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAoB,MAAM,qBAAqB,CAAA;AAG1E,OAAO,EAAE,2CAA2C,EAAE,MAAM,sBAAsB,CAAA;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEzD,eAAe,CAAC,GAAe,EAAwC,EAAE,CAAC,CAAC;IACzE;;;;;;OAMG;IACH,KAAK,CAAC,mCAAmC,CAAC,GAAG,EAAE,UAAU;QACvD,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC/B,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAA;QAElB,IAAI,CAAC;YACH,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,YAAY,CACpB,kDAAkD,EAClD,IAAI,CAAC,eAAe,CACrB,CAAA;QACH,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,YAAY,CACpB,iDAAiD,EACjD,IAAI,CAAC,eAAe,CACrB,CAAA;QACH,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,EAAE;aAC5B,UAAU,CAAC,WAAW,CAAC;aACvB,KAAK,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC;aACpC,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC;aACtC,SAAS,CAAC,IAAI,CAAC;aACf,OAAO,EAAE,CAAA;QACZ,OAAO,IAAI,2CAA2C,CAAC;YACrD,YAAY,EAAE,WAAW,CAAC,MAAM;SACjC,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { Code, ConnectError, type ServiceImpl } from '@connectrpc/connect'\nimport type { AppContext } from '../context.js'\nimport type { Service } from '../proto/bsync_connect.js'\nimport { DeleteOperationsByActorAndNamespaceResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { isValidDid, validateNamespace } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n /**\n * This method is responsible for deleting log rows from the bsync db, it has\n * no other downstream effects. This method is called from the dataplane in\n * response to a data deletion request initiated by a moderator in Ozone.\n * It's the final step of the deletion process, basically cleaning up the\n * breadcrumbs that resulted in the state we store in the dataplane.\n */\n async deleteOperationsByActorAndNamespace(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db } = ctx\n\n try {\n validateNamespace(req.namespace)\n } catch (error) {\n throw new ConnectError(\n 'requested namespace for deletion is invalid NSID',\n Code.InvalidArgument,\n )\n }\n if (!isValidDid(req.actorDid)) {\n throw new ConnectError(\n 'requested actor_did for deletion is invalid DID',\n Code.InvalidArgument,\n )\n }\n\n const deletedRows = await db.db\n .deleteFrom('operation')\n .where('actorDid', '=', req.actorDid)\n .where('namespace', '=', req.namespace)\n .returning('id')\n .execute()\n return new DeleteOperationsByActorAndNamespaceResponse({\n deletedCount: deletedRows.length,\n })\n },\n})\n"]}
|
package/dist/routes/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConnectRouter } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
1
|
+
import type { ConnectRouter } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
3
|
declare const _default: (ctx: AppContext) => (router: ConnectRouter) => ConnectRouter;
|
|
4
4
|
export default _default;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;8BAU1B,UAAU,cAAc,aAAa"}
|
package/dist/routes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,iBAAiB,MAAM,0BAA0B,CAAA;AACxD,OAAO,gBAAgB,MAAM,wBAAwB,CAAA;AACrD,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAC7C,OAAO,kBAAkB,MAAM,2BAA2B,CAAA;AAC1D,OAAO,mBAAmB,MAAM,4BAA4B,CAAA;AAC5D,OAAO,cAAc,MAAM,sBAAsB,CAAA;AAEjD,eAAe,CAAC,GAAe,EAAE,EAAE,CAAC,CAAC,MAAqB,EAAE,EAAE;IAC5D,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7B,GAAG,gBAAgB,CAAC,GAAG,CAAC;QACxB,GAAG,kBAAkB,CAAC,GAAG,CAAC;QAC1B,GAAG,iBAAiB,CAAC,GAAG,CAAC;QACzB,GAAG,mBAAmB,CAAC,GAAG,CAAC;QAC3B,GAAG,YAAY,CAAC,GAAG,CAAC;QACpB,GAAG,cAAc,CAAC,GAAG,CAAC;QACtB,GAAG,gBAAgB,CAAC,GAAG,CAAC;QACxB,KAAK,CAAC,IAAI;YACR,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAA;YAClB,MAAM,GAAG,CAAA,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;YAClC,OAAO,EAAE,CAAA;QACX,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { ConnectRouter } from '@connectrpc/connect'\nimport { sql } from 'kysely'\nimport { AppContext } from '../context.js'\nimport { Service } from '../proto/bsync_connect.js'\nimport addMuteOperation from './add-mute-operation.js'\nimport addNotifOperation from './add-notif-operation.js'\nimport deleteOperations from './delete-operations.js'\nimport putOperation from './put-operation.js'\nimport scanMuteOperations from './scan-mute-operations.js'\nimport scanNotifOperations from './scan-notif-operations.js'\nimport scanOperations from './scan-operations.js'\n\nexport default (ctx: AppContext) => (router: ConnectRouter) => {\n return router.service(Service, {\n ...addMuteOperation(ctx),\n ...scanMuteOperations(ctx),\n ...addNotifOperation(ctx),\n ...scanNotifOperations(ctx),\n ...putOperation(ctx),\n ...scanOperations(ctx),\n ...deleteOperations(ctx),\n async ping() {\n const { db } = ctx\n await sql`select 1`.execute(db.db)\n return {}\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,iBAAiB,MAAM,0BAA0B,CAAA;AACxD,OAAO,gBAAgB,MAAM,wBAAwB,CAAA;AACrD,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAC7C,OAAO,kBAAkB,MAAM,2BAA2B,CAAA;AAC1D,OAAO,mBAAmB,MAAM,4BAA4B,CAAA;AAC5D,OAAO,cAAc,MAAM,sBAAsB,CAAA;AAEjD,eAAe,CAAC,GAAe,EAAE,EAAE,CAAC,CAAC,MAAqB,EAAE,EAAE;IAC5D,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7B,GAAG,gBAAgB,CAAC,GAAG,CAAC;QACxB,GAAG,kBAAkB,CAAC,GAAG,CAAC;QAC1B,GAAG,iBAAiB,CAAC,GAAG,CAAC;QACzB,GAAG,mBAAmB,CAAC,GAAG,CAAC;QAC3B,GAAG,YAAY,CAAC,GAAG,CAAC;QACpB,GAAG,cAAc,CAAC,GAAG,CAAC;QACtB,GAAG,gBAAgB,CAAC,GAAG,CAAC;QACxB,KAAK,CAAC,IAAI;YACR,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAA;YAClB,MAAM,GAAG,CAAA,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;YAClC,OAAO,EAAE,CAAA;QACX,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import type { ConnectRouter } from '@connectrpc/connect'\nimport { sql } from 'kysely'\nimport type { AppContext } from '../context.js'\nimport { Service } from '../proto/bsync_connect.js'\nimport addMuteOperation from './add-mute-operation.js'\nimport addNotifOperation from './add-notif-operation.js'\nimport deleteOperations from './delete-operations.js'\nimport putOperation from './put-operation.js'\nimport scanMuteOperations from './scan-mute-operations.js'\nimport scanNotifOperations from './scan-notif-operations.js'\nimport scanOperations from './scan-operations.js'\n\nexport default (ctx: AppContext) => (router: ConnectRouter) => {\n return router.service(Service, {\n ...addMuteOperation(ctx),\n ...scanMuteOperations(ctx),\n ...addNotifOperation(ctx),\n ...scanNotifOperations(ctx),\n ...putOperation(ctx),\n ...scanOperations(ctx),\n ...deleteOperations(ctx),\n async ping() {\n const { db } = ctx\n await sql`select 1`.execute(db.db)\n return {}\n },\n })\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
3
|
-
import { Service } from '../proto/bsync_connect.js';
|
|
1
|
+
import { type ServiceImpl } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
|
+
import type { Service } from '../proto/bsync_connect.js';
|
|
4
4
|
declare const _default: (ctx: AppContext) => Partial<ServiceImpl<typeof Service>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=put-operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"put-operation.d.ts","sourceRoot":"","sources":["../../src/routes/put-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"put-operation.d.ts","sourceRoot":"","sources":["../../src/routes/put-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAG1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;8BASnC,UAAU,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"put-operation.js","sourceRoot":"","sources":["../../src/routes/put-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"put-operation.js","sourceRoot":"","sources":["../../src/routes/put-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAoB,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAGtD,OAAO,EAEL,sBAAsB,GACvB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,MAAM,EAEN,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEzD,eAAe,CAAC,GAAe,EAAwC,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,UAAU;QAChC,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC/B,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,CAAA;QAClB,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;QAC1B,MAAM,EAAE,G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AC3D,MAAM,IAAI,YAAY,CACpB,gDAAgD,EAChD,IAAI,CAAC,eAAe,CACrB,CAAA;IACH,CAAC;IAED,OAAO,GAAgB,CAAA;AACzB,CAAC,CAAA","sourcesContent":["import { Code, ConnectError, type ServiceImpl } from '@connectrpc/connect'\nimport { sql } from 'kysely'\nimport { ensureValidRecordKey } from '@atproto/syntax'\nimport type { AppContext } from '../context.js'\nimport type { Database } from '../db/index.js'\nimport {\n type OperationMethod,\n createOperationChannel,\n} from '../db/schema/operation.js'\nimport type { Service } from '../proto/bsync_connect.js'\nimport {\n Method,\n type PutOperationRequest,\n PutOperationResponse,\n} from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { isValidDid, validateNamespace } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async putOperation(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db } = ctx\n const op = validateOp(req)\n const id = await db.transaction(async (txn) => {\n return putOp(txn, op)\n })\n return new PutOperationResponse({\n operation: {\n id: String(id),\n actorDid: op.actorDid,\n namespace: op.namespace,\n key: op.key,\n method: op.method,\n payload: op.payload,\n },\n })\n },\n})\n\nconst putOp = async (db: Database, op: Operation) => {\n const { ref } = db.db.dynamic\n const { id } = await db.db\n .insertInto('operation')\n .values({\n actorDid: op.actorDid,\n namespace: op.namespace,\n key: op.key,\n method: op.method,\n payload: op.payload,\n })\n .returning('id')\n .executeTakeFirstOrThrow()\n await sql`notify ${ref(createOperationChannel)}`.execute(db.db) // emitted transactionally\n return id\n}\n\nconst validateOp = (req: PutOperationRequest): Operation => {\n try {\n validateNamespace(req.namespace)\n } catch (error) {\n throw new ConnectError(\n 'operation namespace is invalid NSID',\n Code.InvalidArgument,\n )\n }\n\n if (!isValidDid(req.actorDid)) {\n throw new ConnectError(\n 'operation actor_did is invalid DID',\n Code.InvalidArgument,\n )\n }\n\n try {\n ensureValidRecordKey(req.key)\n } catch (error) {\n throw new ConnectError('operation key is required', Code.InvalidArgument)\n }\n\n if (\n req.method !== Method.CREATE &&\n req.method !== Method.UPDATE &&\n req.method !== Method.DELETE\n ) {\n throw new ConnectError('operation method is invalid', Code.InvalidArgument)\n }\n\n if (req.method === Method.CREATE || req.method === Method.UPDATE) {\n try {\n JSON.parse(new TextDecoder().decode(req.payload))\n } catch (error) {\n throw new ConnectError(\n 'payload must be a valid JSON when method is CREATE or UPDATE',\n Code.InvalidArgument,\n )\n }\n }\n\n if (req.method === Method.DELETE && req.payload.length > 0) {\n throw new ConnectError(\n 'cannot specify a payload when method is DELETE',\n Code.InvalidArgument,\n )\n }\n\n return req as Operation\n}\n\ntype Operation = {\n actorDid: string\n namespace: string\n key: string\n payload: Uint8Array<ArrayBuffer>\n method: OperationMethod\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
3
|
-
import { Service } from '../proto/bsync_connect.js';
|
|
1
|
+
import type { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
|
+
import type { Service } from '../proto/bsync_connect.js';
|
|
4
4
|
declare const _default: (ctx: AppContext) => Partial<ServiceImpl<typeof Service>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=scan-mute-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-mute-operations.d.ts","sourceRoot":"","sources":["../../src/routes/scan-mute-operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"scan-mute-operations.d.ts","sourceRoot":"","sources":["../../src/routes/scan-mute-operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,KAA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AC;CACF,CAAC,CAAA","sourcesContent":["import { once } from 'node:events'\nimport { ServiceImpl } from '@connectrpc/connect'\nimport { AppContext } from '../context.js'\nimport { createMuteOpChannel } from '../db/schema/mute_op.js'\nimport { Service } from '../proto/bsync_connect.js'\nimport { ScanMuteOperationsResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { combineSignals, validCursor } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async scanMuteOperations(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db, events } = ctx\n const limit = req.limit || 1000\n const cursor = validCursor(req.cursor)\n const nextMuteOpPromise = once(events, createMuteOpChannel, {\n signal: combineSignals(\n ctx.shutdown,\n AbortSignal.timeout(ctx.cfg.service.longPollTimeoutMs),\n ),\n })\n nextMuteOpPromise.catch(() => null) // ensure timeout is always handled\n\n const nextMuteOpPageQb = db.db\n .selectFrom('mute_op')\n .selectAll()\n .where('id', '>', cursor ?? -1)\n .orderBy('id', 'asc')\n .limit(limit)\n\n let ops = await nextMuteOpPageQb.execute()\n\n if (!ops.length) {\n // if there were no ops on the page, wait for an event then try again.\n try {\n await nextMuteOpPromise\n } catch (err) {\n ctx.shutdown.throwIfAborted()\n return new ScanMuteOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n ops = await nextMuteOpPageQb.execute()\n if (!ops.length) {\n return new ScanMuteOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n }\n\n const lastOp = ops[ops.length - 1]\n\n return new ScanMuteOperationsResponse({\n operations: ops.map((op) => ({\n id: op.id.toString(),\n type: op.type,\n actorDid: op.actorDid,\n subject: op.subject,\n })),\n cursor: lastOp.id.toString(),\n })\n },\n})\n"]}
|
|
1
|
+
{"version":3,"file":"scan-mute-operations.js","sourceRoot":"","sources":["../../src/routes/scan-mute-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGlC,O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,CAAC;gBACH,MAAM,iBAAiB,CAAA;YACzB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,GAAG,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAA;gBAC7B,OAAO,IAAI,0BAA0B,CAAC;oBACpC,UAAU,EAAE,EAAE;oBACd,MAAM,EAAE,GAAG,CAAC,MAAM;iBACnB,CAAC,CAAA;YACJ,CAAC;YACD,GAAG,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,CAAA;YACtC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;gBAChB,OAAO,IAAI,0BAA0B,CAAC;oBACpC,UAAU,EAAE,EAAE;oBACd,MAAM,EAAE,GAAG,CAAC,MAAM;iBACnB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAElC,OAAO,IAAI,0BAA0B,CAAC;YACpC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC3B,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE;gBACpB,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,QAAQ,EAAE,EAAE,CAAC,QAAQ;gBACrB,OAAO,EAAE,EAAE,CAAC,OAAO;aACpB,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { once } from 'node:events'\nimport type { ServiceImpl } from '@connectrpc/connect'\nimport type { AppContext } from '../context.js'\nimport { createMuteOpChannel } from '../db/schema/mute_op.js'\nimport type { Service } from '../proto/bsync_connect.js'\nimport { ScanMuteOperationsResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { combineSignals, validCursor } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async scanMuteOperations(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db, events } = ctx\n const limit = req.limit || 1000\n const cursor = validCursor(req.cursor)\n const nextMuteOpPromise = once(events, createMuteOpChannel, {\n signal: combineSignals(\n ctx.shutdown,\n AbortSignal.timeout(ctx.cfg.service.longPollTimeoutMs),\n ),\n })\n nextMuteOpPromise.catch(() => null) // ensure timeout is always handled\n\n const nextMuteOpPageQb = db.db\n .selectFrom('mute_op')\n .selectAll()\n .where('id', '>', cursor ?? -1)\n .orderBy('id', 'asc')\n .limit(limit)\n\n let ops = await nextMuteOpPageQb.execute()\n\n if (!ops.length) {\n // if there were no ops on the page, wait for an event then try again.\n try {\n await nextMuteOpPromise\n } catch (err) {\n ctx.shutdown.throwIfAborted()\n return new ScanMuteOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n ops = await nextMuteOpPageQb.execute()\n if (!ops.length) {\n return new ScanMuteOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n }\n\n const lastOp = ops[ops.length - 1]\n\n return new ScanMuteOperationsResponse({\n operations: ops.map((op) => ({\n id: op.id.toString(),\n type: op.type,\n actorDid: op.actorDid,\n subject: op.subject,\n })),\n cursor: lastOp.id.toString(),\n })\n },\n})\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
3
|
-
import { Service } from '../proto/bsync_connect.js';
|
|
1
|
+
import type { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
|
+
import type { Service } from '../proto/bsync_connect.js';
|
|
4
4
|
declare const _default: (ctx: AppContext) => Partial<ServiceImpl<typeof Service>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=scan-notif-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-notif-operations.d.ts","sourceRoot":"","sources":["../../src/routes/scan-notif-operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"scan-notif-operations.d.ts","sourceRoot":"","sources":["../../src/routes/scan-notif-operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;8BAKnC,UAAU,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-notif-operations.js","sourceRoot":"","sources":["../../src/routes/scan-notif-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvD,eAAe,CAAC,GAAe,EAAwC,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAE,UAAU;QACvC,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC/B,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;QAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,IAAI,CAAA;QAC/B,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACtC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE;YAC5D,MA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AG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC3B,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE;gBACpB,QAAQ,EAAE,EAAE,CAAC,QAAQ;gBACrB,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,SAAS;aACnC,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { once } from 'node:events'\nimport { ServiceImpl } from '@connectrpc/connect'\nimport { AppContext } from '../context.js'\nimport { createNotifOpChannel } from '../db/schema/notif_op.js'\nimport { Service } from '../proto/bsync_connect.js'\nimport { ScanNotifOperationsResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { combineSignals, validCursor } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async scanNotifOperations(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db, events } = ctx\n const limit = req.limit || 1000\n const cursor = validCursor(req.cursor)\n const nextNotifOpPromise = once(events, createNotifOpChannel, {\n signal: combineSignals(\n ctx.shutdown,\n AbortSignal.timeout(ctx.cfg.service.longPollTimeoutMs),\n ),\n })\n nextNotifOpPromise.catch(() => null) // ensure timeout is always handled\n\n const nextNotifOpPageQb = db.db\n .selectFrom('notif_op')\n .selectAll()\n .where('id', '>', cursor ?? -1)\n .orderBy('id', 'asc')\n .limit(limit)\n\n let ops = await nextNotifOpPageQb.execute()\n\n if (!ops.length) {\n // if there were no ops on the page, wait for an event then try again.\n try {\n await nextNotifOpPromise\n } catch (err) {\n ctx.shutdown.throwIfAborted()\n return new ScanNotifOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n ops = await nextNotifOpPageQb.execute()\n if (!ops.length) {\n return new ScanNotifOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n }\n\n const lastOp = ops[ops.length - 1]\n\n return new ScanNotifOperationsResponse({\n operations: ops.map((op) => ({\n id: op.id.toString(),\n actorDid: op.actorDid,\n priority: op.priority ?? undefined,\n })),\n cursor: lastOp.id.toString(),\n })\n },\n})\n"]}
|
|
1
|
+
{"version":3,"file":"scan-notif-operations.js","sourceRoot":"","sources":["../../src/routes/scan-notif-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvD,eAAe,CAAC,GAAe,EAAwC,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAE,UAAU;QACvC,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC/B,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;QAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,IAAI,CAAA;QAC/B,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACtC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE;YAC5D,MAAM,EAAE,cAAc,CACpB,GAAG,CAAC,QAAQ,EACZ,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CACvD;SACF,CAAC,CAAA;QACF,kBAAkB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA,CAAC,mCAAmC;QAExE,MAAM,iBAAiB,GAAG,EAAE,CAAC,EAAE;aAC5B,UAAU,CAAC,UAAU,CAAC;aAC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CAAC;CACF,CAAC,CAAA","sourcesContent":["import { once } from 'node:events'\nimport type { ServiceImpl } from '@connectrpc/connect'\nimport type { AppContext } from '../context.js'\nimport { createNotifOpChannel } from '../db/schema/notif_op.js'\nimport type { Service } from '../proto/bsync_connect.js'\nimport { ScanNotifOperationsResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { combineSignals, validCursor } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async scanNotifOperations(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db, events } = ctx\n const limit = req.limit || 1000\n const cursor = validCursor(req.cursor)\n const nextNotifOpPromise = once(events, createNotifOpChannel, {\n signal: combineSignals(\n ctx.shutdown,\n AbortSignal.timeout(ctx.cfg.service.longPollTimeoutMs),\n ),\n })\n nextNotifOpPromise.catch(() => null) // ensure timeout is always handled\n\n const nextNotifOpPageQb = db.db\n .selectFrom('notif_op')\n .selectAll()\n .where('id', '>', cursor ?? -1)\n .orderBy('id', 'asc')\n .limit(limit)\n\n let ops = await nextNotifOpPageQb.execute()\n\n if (!ops.length) {\n // if there were no ops on the page, wait for an event then try again.\n try {\n await nextNotifOpPromise\n } catch (err) {\n ctx.shutdown.throwIfAborted()\n return new ScanNotifOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n ops = await nextNotifOpPageQb.execute()\n if (!ops.length) {\n return new ScanNotifOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n }\n\n const lastOp = ops[ops.length - 1]\n\n return new ScanNotifOperationsResponse({\n operations: ops.map((op) => ({\n id: op.id.toString(),\n actorDid: op.actorDid,\n priority: op.priority ?? undefined,\n })),\n cursor: lastOp.id.toString(),\n })\n },\n})\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
-
import { AppContext } from '../context.js';
|
|
3
|
-
import { Service } from '../proto/bsync_connect.js';
|
|
1
|
+
import type { ServiceImpl } from '@connectrpc/connect';
|
|
2
|
+
import type { AppContext } from '../context.js';
|
|
3
|
+
import type { Service } from '../proto/bsync_connect.js';
|
|
4
4
|
declare const _default: (ctx: AppContext) => Partial<ServiceImpl<typeof Service>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=scan-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-operations.d.ts","sourceRoot":"","sources":["../../src/routes/scan-operations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"scan-operations.d.ts","sourceRoot":"","sources":["../../src/routes/scan-operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;8BAKnC,UAAU,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-operations.js","sourceRoot":"","sources":["../../src/routes/scan-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvD,eAAe,CAAC,GAAe,EAAwC,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU;QAClC,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC/B,MAAM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C;oBAChC,UAAU,EAAE,EAAE;oBACd,MAAM,EAAE,GAAG,CAAC,MAAM;iBACnB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAElC,OAAO,IAAI,sBAAsB,CAAC;YAChC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC3B,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE;gBACpB,QAAQ,EAAE,EAAE,CAAC,QAAQ;gBACrB,SAAS,EAAE,EAAE,CAAC,SAAS;gBACvB,GAAG,EAAE,EAAE,CAAC,GAAG;gBACX,MAAM,EAAE,EAAE,CAAC,MAAM;gBACjB,OAAO,EAAE,EAAE,CAAC,OAAO;aACpB,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { once } from 'node:events'\nimport { ServiceImpl } from '@connectrpc/connect'\nimport { AppContext } from '../context.js'\nimport { createOperationChannel } from '../db/schema/operation.js'\nimport { Service } from '../proto/bsync_connect.js'\nimport { ScanOperationsResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { combineSignals, validCursor } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async scanOperations(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db, events } = ctx\n const limit = req.limit || 1000\n const cursor = validCursor(req.cursor)\n const nextOpPromise = once(events, createOperationChannel, {\n signal: combineSignals(\n ctx.shutdown,\n AbortSignal.timeout(ctx.cfg.service.longPollTimeoutMs),\n ),\n })\n nextOpPromise.catch(() => null) // ensure timeout is always handled\n\n const nextOpPageQb = db.db\n .selectFrom('operation')\n .selectAll()\n .where('id', '>', cursor ?? -1)\n .orderBy('id', 'asc')\n .limit(limit)\n\n let ops = await nextOpPageQb.execute()\n\n if (!ops.length) {\n // if there were no ops on the page, wait for an event then try again.\n try {\n await nextOpPromise\n } catch (err) {\n ctx.shutdown.throwIfAborted()\n return new ScanOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n ops = await nextOpPageQb.execute()\n if (!ops.length) {\n return new ScanOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n }\n\n const lastOp = ops[ops.length - 1]\n\n return new ScanOperationsResponse({\n operations: ops.map((op) => ({\n id: op.id.toString(),\n actorDid: op.actorDid,\n namespace: op.namespace,\n key: op.key,\n method: op.method,\n payload: op.payload,\n })),\n cursor: lastOp.id.toString(),\n })\n },\n})\n"]}
|
|
1
|
+
{"version":3,"file":"scan-operations.js","sourceRoot":"","sources":["../../src/routes/scan-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvD,eAAe,CAAC,GAAe,EAAwC,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU;QAClC,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAC/B,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;QAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,IAAI,CAAA;QAC/B,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACtC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,sBAAsB,EAAE;YACzD,MAAM,EAAE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CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC3B,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE;gBACpB,QAAQ,EAAE,EAAE,CAAC,QAAQ;gBACrB,SAAS,EAAE,EAAE,CAAC,SAAS;gBACvB,GAAG,EAAE,EAAE,CAAC,GAAG;gBACX,MAAM,EAAE,EAAE,CAAC,MAAM;gBACjB,OAAO,EAAE,EAAE,CAAC,OAAO;aACpB,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { once } from 'node:events'\nimport type { ServiceImpl } from '@connectrpc/connect'\nimport type { AppContext } from '../context.js'\nimport { createOperationChannel } from '../db/schema/operation.js'\nimport type { Service } from '../proto/bsync_connect.js'\nimport { ScanOperationsResponse } from '../proto/bsync_pb.js'\nimport { authWithApiKey } from './auth.js'\nimport { combineSignals, validCursor } from './util.js'\n\nexport default (ctx: AppContext): Partial<ServiceImpl<typeof Service>> => ({\n async scanOperations(req, handlerCtx) {\n authWithApiKey(ctx, handlerCtx)\n const { db, events } = ctx\n const limit = req.limit || 1000\n const cursor = validCursor(req.cursor)\n const nextOpPromise = once(events, createOperationChannel, {\n signal: combineSignals(\n ctx.shutdown,\n AbortSignal.timeout(ctx.cfg.service.longPollTimeoutMs),\n ),\n })\n nextOpPromise.catch(() => null) // ensure timeout is always handled\n\n const nextOpPageQb = db.db\n .selectFrom('operation')\n .selectAll()\n .where('id', '>', cursor ?? -1)\n .orderBy('id', 'asc')\n .limit(limit)\n\n let ops = await nextOpPageQb.execute()\n\n if (!ops.length) {\n // if there were no ops on the page, wait for an event then try again.\n try {\n await nextOpPromise\n } catch (err) {\n ctx.shutdown.throwIfAborted()\n return new ScanOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n ops = await nextOpPageQb.execute()\n if (!ops.length) {\n return new ScanOperationsResponse({\n operations: [],\n cursor: req.cursor,\n })\n }\n }\n\n const lastOp = ops[ops.length - 1]\n\n return new ScanOperationsResponse({\n operations: ops.map((op) => ({\n id: op.id.toString(),\n actorDid: op.actorDid,\n namespace: op.namespace,\n key: op.key,\n method: op.method,\n payload: op.payload,\n })),\n cursor: lastOp.id.toString(),\n })\n },\n})\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/bsync",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Sychronizing service for app.bsky App View (Bluesky API)",
|
|
6
6
|
"keywords": [
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"pg": "^8.10.0",
|
|
38
38
|
"pino-http": "^11.0.0",
|
|
39
39
|
"typed-emitter": "^2.1.0",
|
|
40
|
-
"@atproto/common": "^0.7.
|
|
41
|
-
"@atproto/syntax": "^0.7.
|
|
40
|
+
"@atproto/common": "^0.7.2",
|
|
41
|
+
"@atproto/syntax": "^0.7.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@bufbuild/buf": "^1.28.1",
|