@atproto/bsync 0.0.25 → 0.0.26-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/bin/migration-create.ts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -12
- package/dist/client.js.map +1 -1
- package/dist/config.js +16 -24
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +6 -6
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +8 -36
- package/dist/context.js.map +1 -1
- package/dist/db/index.d.ts +6 -4
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +26 -101
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations/20240108T220751294Z-init.js +4 -8
- package/dist/db/migrations/20240108T220751294Z-init.js.map +1 -1
- package/dist/db/migrations/20240717T224303472Z-notif-ops.js +4 -8
- package/dist/db/migrations/20240717T224303472Z-notif-ops.js.map +1 -1
- package/dist/db/migrations/20250527T022203400Z-add-operation.js +5 -9
- package/dist/db/migrations/20250527T022203400Z-add-operation.js.map +1 -1
- package/dist/db/migrations/20250603T163446567Z-alter-operation.js +2 -6
- package/dist/db/migrations/20250603T163446567Z-alter-operation.js.map +1 -1
- package/dist/db/migrations/index.d.ts +4 -4
- package/dist/db/migrations/index.d.ts.map +1 -1
- package/dist/db/migrations/index.js +4 -40
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/db/migrations/provider.js +2 -11
- package/dist/db/migrations/provider.js.map +1 -1
- package/dist/db/schema/index.d.ts +5 -5
- package/dist/db/schema/index.d.ts.map +1 -1
- package/dist/db/schema/index.js +1 -2
- package/dist/db/schema/index.js.map +1 -1
- package/dist/db/schema/mute_item.js +1 -4
- package/dist/db/schema/mute_item.js.map +1 -1
- package/dist/db/schema/mute_op.d.ts +1 -1
- package/dist/db/schema/mute_op.d.ts.map +1 -1
- package/dist/db/schema/mute_op.js +2 -5
- package/dist/db/schema/mute_op.js.map +1 -1
- package/dist/db/schema/notif_item.js +1 -4
- package/dist/db/schema/notif_item.js.map +1 -1
- package/dist/db/schema/notif_op.js +2 -5
- 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 +2 -5
- package/dist/db/schema/operation.js.map +1 -1
- package/dist/db/types.d.ts +3 -1
- package/dist/db/types.d.ts.map +1 -1
- package/dist/db/types.js +1 -2
- package/dist/db/types.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -88
- package/dist/index.js.map +1 -1
- package/dist/logger.js +8 -11
- package/dist/logger.js.map +1 -1
- package/dist/proto/bsync_connect.d.ts +1 -1
- package/dist/proto/bsync_connect.d.ts.map +1 -1
- package/dist/proto/bsync_connect.js +27 -30
- package/dist/proto/bsync_connect.js.map +1 -1
- package/dist/proto/bsync_pb.js +215 -747
- package/dist/proto/bsync_pb.js.map +1 -1
- package/dist/routes/add-mute-operation.d.ts +2 -2
- package/dist/routes/add-mute-operation.d.ts.map +1 -1
- package/dist/routes/add-mute-operation.js +28 -30
- package/dist/routes/add-mute-operation.js.map +1 -1
- package/dist/routes/add-notif-operation.d.ts +2 -2
- package/dist/routes/add-notif-operation.d.ts.map +1 -1
- package/dist/routes/add-notif-operation.js +14 -16
- package/dist/routes/add-notif-operation.js.map +1 -1
- package/dist/routes/auth.d.ts +1 -1
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/auth.js +4 -8
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/delete-operations.d.ts +2 -2
- package/dist/routes/delete-operations.d.ts.map +1 -1
- package/dist/routes/delete-operations.js +11 -13
- package/dist/routes/delete-operations.js.map +1 -1
- package/dist/routes/index.d.ts +1 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +19 -24
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/put-operation.d.ts +2 -2
- package/dist/routes/put-operation.d.ts.map +1 -1
- package/dist/routes/put-operation.js +25 -27
- package/dist/routes/put-operation.js.map +1 -1
- package/dist/routes/scan-mute-operations.d.ts +2 -2
- package/dist/routes/scan-mute-operations.d.ts.map +1 -1
- package/dist/routes/scan-mute-operations.js +13 -15
- package/dist/routes/scan-mute-operations.js.map +1 -1
- package/dist/routes/scan-notif-operations.d.ts +2 -2
- package/dist/routes/scan-notif-operations.d.ts.map +1 -1
- package/dist/routes/scan-notif-operations.js +13 -15
- package/dist/routes/scan-notif-operations.js.map +1 -1
- package/dist/routes/scan-operations.d.ts +2 -2
- package/dist/routes/scan-operations.d.ts.map +1 -1
- package/dist/routes/scan-operations.js +13 -15
- package/dist/routes/scan-operations.js.map +1 -1
- package/dist/routes/util.js +12 -20
- package/dist/routes/util.js.map +1 -1
- package/{jest.config.js → jest.config.cjs} +8 -1
- package/package.json +14 -9
- package/src/client.ts +1 -1
- package/src/context.ts +7 -7
- package/src/db/index.ts +12 -8
- package/src/db/migrations/index.ts +4 -4
- package/src/db/schema/index.ts +5 -5
- package/src/db/schema/mute_op.ts +1 -1
- package/src/db/schema/operation.ts +2 -2
- package/src/db/types.ts +3 -1
- package/src/index.ts +17 -13
- package/src/proto/bsync_connect.ts +1 -1
- package/src/routes/add-mute-operation.ts +10 -7
- package/src/routes/add-notif-operation.ts +7 -7
- package/src/routes/auth.ts +1 -1
- package/src/routes/delete-operations.ts +5 -5
- package/src/routes/index.ts +9 -9
- package/src/routes/put-operation.ts +11 -8
- package/src/routes/scan-mute-operations.ts +6 -6
- package/src/routes/scan-notif-operations.ts +6 -6
- package/src/routes/scan-operations.ts +6 -6
- package/tests/delete-operations.test.ts +2 -2
- package/tests/mutes.test.ts +2 -2
- package/tests/notifications.test.ts +2 -2
- package/tests/operations.test.ts +2 -2
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.tests.json +1 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.up = up;
|
|
4
|
-
exports.down = down;
|
|
5
|
-
const kysely_1 = require("kysely");
|
|
6
|
-
async function up(db) {
|
|
1
|
+
import { sql } from 'kysely';
|
|
2
|
+
export async function up(db) {
|
|
7
3
|
await db.schema
|
|
8
4
|
.createTable('operation')
|
|
9
5
|
.addColumn('id', 'bigserial', (col) => col.primaryKey())
|
|
@@ -11,11 +7,11 @@ async function up(db) {
|
|
|
11
7
|
.addColumn('actorDid', 'varchar', (col) => col.notNull())
|
|
12
8
|
.addColumn('rkey', 'varchar', (col) => col.notNull())
|
|
13
9
|
.addColumn('method', 'int2', (col) => col.notNull())
|
|
14
|
-
.addColumn('payload',
|
|
15
|
-
.addColumn('createdAt', 'timestamptz', (col) => col.notNull().defaultTo(
|
|
10
|
+
.addColumn('payload', sql `bytea`)
|
|
11
|
+
.addColumn('createdAt', 'timestamptz', (col) => col.notNull().defaultTo(sql `CURRENT_TIMESTAMP`))
|
|
16
12
|
.execute();
|
|
17
13
|
}
|
|
18
|
-
async function down(db) {
|
|
14
|
+
export async function down(db) {
|
|
19
15
|
await db.schema.dropTable('operation').execute();
|
|
20
16
|
}
|
|
21
17
|
//# sourceMappingURL=20250527T022203400Z-add-operation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250527T022203400Z-add-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"20250527T022203400Z-add-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250527T022203400Z-add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,GAAG,EAAE,MAAM,QAAQ,CAAA;AAEpC,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 { 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,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.up = up;
|
|
4
|
-
exports.down = down;
|
|
5
|
-
async function up(db) {
|
|
1
|
+
export async function up(db) {
|
|
6
2
|
await db.schema
|
|
7
3
|
.alterTable('operation')
|
|
8
4
|
.renameColumn('collection', 'namespace')
|
|
9
5
|
.execute();
|
|
10
6
|
await db.schema.alterTable('operation').renameColumn('rkey', 'key').execute();
|
|
11
7
|
}
|
|
12
|
-
async function down(db) {
|
|
8
|
+
export async function down(db) {
|
|
13
9
|
await db.schema
|
|
14
10
|
.alterTable('operation')
|
|
15
11
|
.renameColumn('namespace', 'collection')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20250603T163446567Z-alter-operation.js","sourceRoot":"","sources":["../../../src/db/migrations/20250603T163446567Z-alter-operation.ts"],"names":[],"mappings":"
|
|
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,5 +1,5 @@
|
|
|
1
|
-
export * as _20240108T220751294Z from './20240108T220751294Z-init';
|
|
2
|
-
export * as _20240717T224303472Z from './20240717T224303472Z-notif-ops';
|
|
3
|
-
export * as _20250527T022203400Z from './20250527T022203400Z-add-operation';
|
|
4
|
-
export * as _20250603T163446567Z from './20250603T163446567Z-alter-operation';
|
|
1
|
+
export * as _20240108T220751294Z from './20240108T220751294Z-init.js';
|
|
2
|
+
export * as _20240717T224303472Z from './20240717T224303472Z-notif-ops.js';
|
|
3
|
+
export * as _20250527T022203400Z from './20250527T022203400Z-add-operation.js';
|
|
4
|
+
export * as _20250603T163446567Z from './20250603T163446567Z-alter-operation.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,oBAAoB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,oCAAoC,CAAA;AAC1E,OAAO,KAAK,oBAAoB,MAAM,wCAAwC,CAAA;AAC9E,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA"}
|
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.
|
|
3
2
|
// It's important that every migration is exported from here with the proper name. We'd simplify
|
|
4
3
|
// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports._20250603T163446567Z = exports._20250527T022203400Z = exports._20240717T224303472Z = exports._20240108T220751294Z = void 0;
|
|
40
|
-
exports._20240108T220751294Z = __importStar(require("./20240108T220751294Z-init"));
|
|
41
|
-
exports._20240717T224303472Z = __importStar(require("./20240717T224303472Z-notif-ops"));
|
|
42
|
-
exports._20250527T022203400Z = __importStar(require("./20250527T022203400Z-add-operation"));
|
|
43
|
-
exports._20250603T163446567Z = __importStar(require("./20250603T163446567Z-alter-operation"));
|
|
4
|
+
export * as _20240108T220751294Z from './20240108T220751294Z-init.js';
|
|
5
|
+
export * as _20240717T224303472Z from './20240717T224303472Z-notif-ops.js';
|
|
6
|
+
export * as _20250527T022203400Z from './20250527T022203400Z-add-operation.js';
|
|
7
|
+
export * as _20250603T163446567Z from './20250603T163446567Z-alter-operation.js';
|
|
44
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/db/migrations/index.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,gGAAgG;AAChG,+FAA+F;AAE/F,OAAO,KAAK,oBAAoB,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,oBAAoB,MAAM,oCAAoC,CAAA;AAC1E,OAAO,KAAK,oBAAoB,MAAM,wCAAwC,CAAA;AAC9E,OAAO,KAAK,oBAAoB,MAAM,0CAA0C,CAAA","sourcesContent":["// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.\n// It's important that every migration is exported from here with the proper name. We'd simplify\n// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.\n\nexport * as _20240108T220751294Z from './20240108T220751294Z-init.js'\nexport * as _20240717T224303472Z from './20240717T224303472Z-notif-ops.js'\nexport * as _20250527T022203400Z from './20250527T022203400Z-add-operation.js'\nexport * as _20250603T163446567Z from './20250603T163446567Z-alter-operation.js'\n"]}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DbMigrationProvider = void 0;
|
|
4
|
-
class DbMigrationProvider {
|
|
1
|
+
export class DbMigrationProvider {
|
|
5
2
|
constructor(migrations) {
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
value: migrations
|
|
11
|
-
});
|
|
3
|
+
this.migrations = migrations;
|
|
12
4
|
}
|
|
13
5
|
async getMigrations() {
|
|
14
6
|
return this.migrations;
|
|
15
7
|
}
|
|
16
8
|
}
|
|
17
|
-
exports.DbMigrationProvider = DbMigrationProvider;
|
|
18
9
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/db/migrations/provider.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAC9B,YAAoB,UAAqC;QAArC,eAAU,GAAV,UAAU,CAA2B;IAAG,CAAC;IAC7D,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF","sourcesContent":["import { Migration, MigrationProvider } from 'kysely'\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,9 +1,9 @@
|
|
|
1
1
|
import { Kysely } from 'kysely';
|
|
2
|
-
import * as muteItem from './mute_item';
|
|
3
|
-
import * as muteOp from './mute_op';
|
|
4
|
-
import * as notifItem from './notif_item';
|
|
5
|
-
import * as notifOp from './notif_op';
|
|
6
|
-
import * as op from './operation';
|
|
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';
|
|
7
7
|
export type DatabaseSchemaType = muteItem.PartialDB & muteOp.PartialDB & notifItem.PartialDB & notifOp.PartialDB & op.PartialDB;
|
|
8
8
|
export type DatabaseSchema = Kysely<DatabaseSchemaType>;
|
|
9
9
|
export default DatabaseSchema;
|
|
@@ -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;AAC/B,OAAO,KAAK,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/db/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEpC,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;AAEvD,eAAe,cAAc,CAAA"}
|
package/dist/db/schema/index.js
CHANGED
|
@@ -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'\nimport * as muteOp from './mute_op'\nimport * as notifItem from './notif_item'\nimport * as notifOp from './notif_op'\nimport * as op from './operation'\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\nexport default DatabaseSchema\n"]}
|
|
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\nexport default DatabaseSchema\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mute_item.js","sourceRoot":"","sources":["../../../src/db/schema/mute_item.ts"],"names":[],"mappings":"
|
|
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 +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;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
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;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,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,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createMuteOpChannel = exports.tableName = void 0;
|
|
4
|
-
exports.tableName = 'mute_op';
|
|
5
|
-
exports.createMuteOpChannel = 'mute_op_create'; // used with listen/notify
|
|
1
|
+
export const tableName = 'mute_op';
|
|
2
|
+
export const createMuteOpChannel = 'mute_op_create'; // used with listen/notify
|
|
6
3
|
//# sourceMappingURL=mute_op.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mute_op.js","sourceRoot":"","sources":["../../../src/db/schema/mute_op.ts"],"names":[],"mappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notif_item.js","sourceRoot":"","sources":["../../../src/db/schema/notif_item.ts"],"names":[],"mappings":"
|
|
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,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createNotifOpChannel = exports.tableName = void 0;
|
|
4
|
-
exports.tableName = 'notif_op';
|
|
5
|
-
exports.createNotifOpChannel = 'notif_op_create'; // used with listen/notify
|
|
1
|
+
export const tableName = 'notif_op';
|
|
2
|
+
export const createNotifOpChannel = 'notif_op_create'; // used with listen/notify
|
|
6
3
|
//# sourceMappingURL=notif_op.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notif_op.js","sourceRoot":"","sources":["../../../src/db/schema/notif_op.ts"],"names":[],"mappings":"
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { GeneratedAlways } from 'kysely';
|
|
2
|
-
import { Method } from '../../proto/bsync_pb';
|
|
2
|
+
import { 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>;
|
|
@@ -7,7 +7,7 @@ export interface Operation {
|
|
|
7
7
|
namespace: string;
|
|
8
8
|
key: string;
|
|
9
9
|
method: OperationMethod;
|
|
10
|
-
payload: Uint8Array
|
|
10
|
+
payload: Uint8Array<ArrayBuffer>;
|
|
11
11
|
createdAt: GeneratedAlways<Date>;
|
|
12
12
|
}
|
|
13
13
|
export declare const tableName = "operation";
|
|
@@ -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;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,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,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createOperationChannel = exports.tableName = void 0;
|
|
4
|
-
exports.tableName = 'operation';
|
|
5
|
-
exports.createOperationChannel = 'operation_create'; // used with listen/notify
|
|
1
|
+
export const tableName = 'operation';
|
|
2
|
+
export const createOperationChannel = 'operation_create'; // used with listen/notify
|
|
6
3
|
//# sourceMappingURL=operation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/db/schema/operation.ts"],"names":[],"mappings":"
|
|
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"]}
|
package/dist/db/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, RawBuilder, SelectQueryBuilder } from 'kysely';
|
|
2
|
-
import
|
|
2
|
+
import pg from 'pg';
|
|
3
|
+
type PgPool = pg.Pool;
|
|
3
4
|
export type DbRef = RawBuilder | ReturnType<DynamicModule['ref']>;
|
|
4
5
|
export type AnyQb = SelectQueryBuilder<any, any, any>;
|
|
5
6
|
export type PgOptions = {
|
|
@@ -10,4 +11,5 @@ export type PgOptions = {
|
|
|
10
11
|
poolMaxUses?: number;
|
|
11
12
|
poolIdleTimeoutMs?: number;
|
|
12
13
|
};
|
|
14
|
+
export {};
|
|
13
15
|
//# sourceMappingURL=types.d.ts.map
|
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,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAEtE,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,KAAK,MAAM,GAAG,EAAE,CAAC,IAAI,CAAA;AAErB,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;AAEjE,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
CHANGED
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'\
|
|
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 = RawBuilder | ReturnType<DynamicModule['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,11 +1,11 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
|
-
import { ServerConfig } from './config';
|
|
3
|
-
import { AppContext, AppContextOptions } from './context';
|
|
4
|
-
export * from './config';
|
|
5
|
-
export * from './client';
|
|
6
|
-
export { Database } from './db';
|
|
7
|
-
export { AppContext } from './context';
|
|
8
|
-
export { httpLogger } from './logger';
|
|
2
|
+
import { ServerConfig } from './config.js';
|
|
3
|
+
import { AppContext, AppContextOptions } from './context.js';
|
|
4
|
+
export * from './config.js';
|
|
5
|
+
export * from './client.js';
|
|
6
|
+
export { Database } from './db/index.js';
|
|
7
|
+
export { AppContext } from './context.js';
|
|
8
|
+
export { httpLogger } from './logger.js';
|
|
9
9
|
export declare class BsyncService {
|
|
10
10
|
ctx: AppContext;
|
|
11
11
|
server: http.Server;
|
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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAO5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAO5D,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;AAExC,qBAAa,YAAY;IAChB,GAAG,EAAE,UAAU,CAAA;IACf,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;IAC1B,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,eAAe,CAAC,CAAgB;gBAE5B,IAAI,EAAE;QAChB,GAAG,EAAE,UAAU,CAAA;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;QACnB,EAAE,EAAE,eAAe,CAAA;KACpB;WAOY,MAAM,CACjB,GAAG,EAAE,YAAY,EACjB,SAAS,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC;IAmBlB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;IAqB7B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQxB,cAAc;CAqBrB;AAED,eAAe,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,87 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
exports.BsyncService = exports.httpLogger = exports.AppContext = exports.Database = void 0;
|
|
21
|
-
const node_events_1 = __importDefault(require("node:events"));
|
|
22
|
-
const node_http_1 = __importDefault(require("node:http"));
|
|
23
|
-
const connect_node_1 = require("@connectrpc/connect-node");
|
|
24
|
-
const http_terminator_1 = require("http-terminator");
|
|
25
|
-
const context_1 = require("./context");
|
|
26
|
-
const mute_op_1 = require("./db/schema/mute_op");
|
|
27
|
-
const notif_op_1 = require("./db/schema/notif_op");
|
|
28
|
-
const operation_1 = require("./db/schema/operation");
|
|
29
|
-
const logger_1 = require("./logger");
|
|
30
|
-
const routes_1 = __importDefault(require("./routes"));
|
|
31
|
-
__exportStar(require("./config"), exports);
|
|
32
|
-
__exportStar(require("./client"), exports);
|
|
33
|
-
var db_1 = require("./db");
|
|
34
|
-
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return db_1.Database; } });
|
|
35
|
-
var context_2 = require("./context");
|
|
36
|
-
Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return context_2.AppContext; } });
|
|
37
|
-
var logger_2 = require("./logger");
|
|
38
|
-
Object.defineProperty(exports, "httpLogger", { enumerable: true, get: function () { return logger_2.httpLogger; } });
|
|
39
|
-
class BsyncService {
|
|
1
|
+
import events from 'node:events';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import { connectNodeAdapter } from '@connectrpc/connect-node';
|
|
4
|
+
// eslint-disable-next-line import/default, import/no-named-as-default-member
|
|
5
|
+
import httpTerminator from 'http-terminator';
|
|
6
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
7
|
+
const { createHttpTerminator } = httpTerminator;
|
|
8
|
+
import { AppContext } from './context.js';
|
|
9
|
+
import { createMuteOpChannel } from './db/schema/mute_op.js';
|
|
10
|
+
import { createNotifOpChannel } from './db/schema/notif_op.js';
|
|
11
|
+
import { createOperationChannel } from './db/schema/operation.js';
|
|
12
|
+
import { dbLogger, loggerMiddleware } from './logger.js';
|
|
13
|
+
import routes from './routes/index.js';
|
|
14
|
+
export * from './config.js';
|
|
15
|
+
export * from './client.js';
|
|
16
|
+
export { Database } from './db/index.js';
|
|
17
|
+
export { AppContext } from './context.js';
|
|
18
|
+
export { httpLogger } from './logger.js';
|
|
19
|
+
export class BsyncService {
|
|
40
20
|
constructor(opts) {
|
|
41
|
-
Object.defineProperty(this, "ctx", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: void 0
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(this, "server", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "ac", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "terminator", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "dbStatsInterval", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: void 0
|
|
70
|
-
});
|
|
71
21
|
this.ctx = opts.ctx;
|
|
72
22
|
this.server = opts.server;
|
|
73
23
|
this.ac = opts.ac;
|
|
74
|
-
this.terminator =
|
|
24
|
+
this.terminator = createHttpTerminator({ server: this.server });
|
|
75
25
|
}
|
|
76
26
|
static async create(cfg, overrides) {
|
|
77
27
|
const ac = new AbortController();
|
|
78
|
-
const ctx = await
|
|
79
|
-
const handler =
|
|
80
|
-
routes: (
|
|
28
|
+
const ctx = await AppContext.fromConfig(cfg, ac.signal, overrides);
|
|
29
|
+
const handler = connectNodeAdapter({
|
|
30
|
+
routes: routes(ctx),
|
|
81
31
|
shutdownSignal: ac.signal,
|
|
82
32
|
});
|
|
83
|
-
const server =
|
|
84
|
-
|
|
33
|
+
const server = http.createServer((req, res) => {
|
|
34
|
+
loggerMiddleware(req, res);
|
|
85
35
|
if (isHealth(req.url)) {
|
|
86
36
|
res.statusCode = 200;
|
|
87
37
|
res.setHeader('content-type', 'application/json');
|
|
@@ -96,7 +46,7 @@ class BsyncService {
|
|
|
96
46
|
throw new Error(`${this.constructor.name} already started`);
|
|
97
47
|
}
|
|
98
48
|
this.dbStatsInterval = setInterval(() => {
|
|
99
|
-
|
|
49
|
+
dbLogger.info({
|
|
100
50
|
idleCount: this.ctx.db.pool.idleCount,
|
|
101
51
|
totalCount: this.ctx.db.pool.totalCount,
|
|
102
52
|
waitingCount: this.ctx.db.pool.waitingCount,
|
|
@@ -105,7 +55,7 @@ class BsyncService {
|
|
|
105
55
|
await this.setupAppEvents();
|
|
106
56
|
this.server.listen(this.ctx.cfg.service.port);
|
|
107
57
|
this.server.keepAliveTimeout = 90000;
|
|
108
|
-
await
|
|
58
|
+
await events.once(this.server, 'listening');
|
|
109
59
|
return this.server;
|
|
110
60
|
}
|
|
111
61
|
async destroy() {
|
|
@@ -121,24 +71,23 @@ class BsyncService {
|
|
|
121
71
|
once: true,
|
|
122
72
|
});
|
|
123
73
|
// if these error, unhandled rejection should cause process to exit
|
|
124
|
-
conn.query(`listen ${
|
|
125
|
-
conn.query(`listen ${
|
|
126
|
-
conn.query(`listen ${
|
|
74
|
+
conn.query(`listen ${createMuteOpChannel}`);
|
|
75
|
+
conn.query(`listen ${createNotifOpChannel}`);
|
|
76
|
+
conn.query(`listen ${createOperationChannel}`);
|
|
127
77
|
conn.on('notification', (notif) => {
|
|
128
|
-
if (notif.channel ===
|
|
129
|
-
this.ctx.events.emit(
|
|
78
|
+
if (notif.channel === createMuteOpChannel) {
|
|
79
|
+
this.ctx.events.emit(createMuteOpChannel);
|
|
130
80
|
}
|
|
131
|
-
if (notif.channel ===
|
|
132
|
-
this.ctx.events.emit(
|
|
81
|
+
if (notif.channel === createNotifOpChannel) {
|
|
82
|
+
this.ctx.events.emit(createNotifOpChannel);
|
|
133
83
|
}
|
|
134
|
-
if (notif.channel ===
|
|
135
|
-
this.ctx.events.emit(
|
|
84
|
+
if (notif.channel === createOperationChannel) {
|
|
85
|
+
this.ctx.events.emit(createOperationChannel);
|
|
136
86
|
}
|
|
137
87
|
});
|
|
138
88
|
}
|
|
139
89
|
}
|
|
140
|
-
|
|
141
|
-
exports.default = BsyncService;
|
|
90
|
+
export default BsyncService;
|
|
142
91
|
const isHealth = (urlStr) => {
|
|
143
92
|
if (!urlStr)
|
|
144
93
|
return false;
|