@atproto/bsync 0.0.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/LICENSE.txt +7 -0
- package/README.md +15 -0
- package/babel.config.js +3 -0
- package/bin/migration-create.ts +38 -0
- package/buf.gen.yaml +13 -0
- package/build.js +18 -0
- package/dist/client.d.ts +6 -0
- package/dist/config.d.ts +36 -0
- package/dist/context.d.ts +19 -0
- package/dist/db/index.d.ts +31 -0
- package/dist/db/migrations/20240108T220751294Z-init.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/migrations/provider.d.ts +6 -0
- package/dist/db/schema/index.d.ts +6 -0
- package/dist/db/schema/mute_item.d.ts +11 -0
- package/dist/db/schema/mute_op.d.ts +15 -0
- package/dist/db/types.d.ts +12 -0
- package/dist/gen/bsync_connect.d.ts +25 -0
- package/dist/gen/bsync_pb.d.ts +90 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +76455 -0
- package/dist/index.js.map +7 -0
- package/dist/logger.d.ts +4 -0
- package/dist/routes/add-mute-operation.d.ts +5 -0
- package/dist/routes/auth.d.ts +3 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/scan-mute-operations.d.ts +5 -0
- package/jest.config.js +6 -0
- package/package.json +49 -0
- package/proto/bsync.proto +55 -0
- package/src/client.ts +25 -0
- package/src/config.ts +90 -0
- package/src/context.ts +42 -0
- package/src/db/index.ts +194 -0
- package/src/db/migrations/20240108T220751294Z-init.ts +26 -0
- package/src/db/migrations/index.ts +5 -0
- package/src/db/migrations/provider.ts +8 -0
- package/src/db/schema/index.ts +9 -0
- package/src/db/schema/mute_item.ts +13 -0
- package/src/db/schema/mute_op.ts +18 -0
- package/src/db/types.ts +15 -0
- package/src/gen/bsync_connect.ts +54 -0
- package/src/gen/bsync_pb.ts +459 -0
- package/src/index.ts +91 -0
- package/src/logger.ts +22 -0
- package/src/routes/add-mute-operation.ts +173 -0
- package/src/routes/auth.ts +15 -0
- package/src/routes/index.ts +18 -0
- package/src/routes/scan-mute-operations.ts +69 -0
- package/tests/mutes.test.ts +350 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +14 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Dual MIT/Apache-2.0 License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-2023 Bluesky PBC, and Contributors
|
|
4
|
+
|
|
5
|
+
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
|
6
|
+
|
|
7
|
+
Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @atproto/bsync: Synchronizing Service for the Bluesky AppView
|
|
2
|
+
|
|
3
|
+
This is an optional service that may be used to synchronize certain state between otherwise independent AppViews.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@atproto/bsync)
|
|
6
|
+
[](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)
|
|
7
|
+
|
|
8
|
+
## License
|
|
9
|
+
|
|
10
|
+
This project is dual-licensed under MIT and Apache 2.0 terms:
|
|
11
|
+
|
|
12
|
+
- MIT license ([LICENSE-MIT.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)
|
|
13
|
+
- Apache License, Version 2.0, ([LICENSE-APACHE.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-APACHE.txt) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
14
|
+
|
|
15
|
+
Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
|
|
3
|
+
import * as fs from 'fs/promises'
|
|
4
|
+
import * as path from 'path'
|
|
5
|
+
|
|
6
|
+
export async function main() {
|
|
7
|
+
const now = new Date()
|
|
8
|
+
const prefix = now.toISOString().replace(/[^a-z0-9]/gi, '') // Order of migrations matches alphabetical order of their names
|
|
9
|
+
const name = process.argv[2]
|
|
10
|
+
if (!name || !name.match(/^[a-z0-9-]+$/)) {
|
|
11
|
+
process.exitCode = 1
|
|
12
|
+
return console.error(
|
|
13
|
+
'Must pass a migration name consisting of lowercase digits, numbers, and dashes.',
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
const filename = `${prefix}-${name}`
|
|
17
|
+
const dir = path.join(__dirname, '..', 'src', 'db', 'migrations')
|
|
18
|
+
|
|
19
|
+
await fs.writeFile(path.join(dir, `${filename}.ts`), template, { flag: 'wx' })
|
|
20
|
+
await fs.writeFile(
|
|
21
|
+
path.join(dir, 'index.ts'),
|
|
22
|
+
`export * as _${prefix} from './${filename}'\n`,
|
|
23
|
+
{ flag: 'a' },
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const template = `import { Kysely } from 'kysely'
|
|
28
|
+
|
|
29
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
30
|
+
// Migration code
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
34
|
+
// Migration code
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
main()
|
package/buf.gen.yaml
ADDED
package/build.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { nodeExternalsPlugin } = require('esbuild-node-externals')
|
|
2
|
+
|
|
3
|
+
const buildShallow =
|
|
4
|
+
process.argv.includes('--shallow') || process.env.ATP_BUILD_SHALLOW === 'true'
|
|
5
|
+
|
|
6
|
+
require('esbuild').build({
|
|
7
|
+
logLevel: 'info',
|
|
8
|
+
entryPoints: ['src/index.ts'],
|
|
9
|
+
bundle: true,
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
outdir: 'dist',
|
|
12
|
+
platform: 'node',
|
|
13
|
+
external: [
|
|
14
|
+
// Referenced in pg driver, but optional and we don't use it
|
|
15
|
+
'pg-native',
|
|
16
|
+
],
|
|
17
|
+
plugins: buildShallow ? [nodeExternalsPlugin()] : [],
|
|
18
|
+
})
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Interceptor, PromiseClient } from '@connectrpc/connect';
|
|
2
|
+
import { ConnectTransportOptions } from '@connectrpc/connect-node';
|
|
3
|
+
import { Service } from './gen/bsync_connect';
|
|
4
|
+
export type BsyncClient = PromiseClient<typeof Service>;
|
|
5
|
+
export declare const createClient: (opts: ConnectTransportOptions) => BsyncClient;
|
|
6
|
+
export declare const authWithApiKey: (apiKey: string) => Interceptor;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const envToCfg: (env: ServerEnvironment) => ServerConfig;
|
|
2
|
+
export type ServerConfig = {
|
|
3
|
+
service: ServiceConfig;
|
|
4
|
+
db: DatabaseConfig;
|
|
5
|
+
auth: AuthConfig;
|
|
6
|
+
};
|
|
7
|
+
type ServiceConfig = {
|
|
8
|
+
port: number;
|
|
9
|
+
version?: string;
|
|
10
|
+
longPollTimeoutMs: number;
|
|
11
|
+
};
|
|
12
|
+
type DatabaseConfig = {
|
|
13
|
+
url: string;
|
|
14
|
+
schema?: string;
|
|
15
|
+
poolSize?: number;
|
|
16
|
+
poolMaxUses?: number;
|
|
17
|
+
poolIdleTimeoutMs?: number;
|
|
18
|
+
migrate?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type AuthConfig = {
|
|
21
|
+
apiKeys: Set<string>;
|
|
22
|
+
};
|
|
23
|
+
export declare const readEnv: () => ServerEnvironment;
|
|
24
|
+
export type ServerEnvironment = {
|
|
25
|
+
port?: number;
|
|
26
|
+
version?: string;
|
|
27
|
+
longPollTimeoutMs?: number;
|
|
28
|
+
dbUrl?: string;
|
|
29
|
+
dbSchema?: string;
|
|
30
|
+
dbPoolSize?: number;
|
|
31
|
+
dbPoolMaxUses?: number;
|
|
32
|
+
dbPoolIdleTimeoutMs?: number;
|
|
33
|
+
dbMigrate?: boolean;
|
|
34
|
+
apiKeys: string[];
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import TypedEventEmitter from 'typed-emitter';
|
|
2
|
+
import { ServerConfig } from './config';
|
|
3
|
+
import Database from './db';
|
|
4
|
+
import { createMuteOpChannel } from './db/schema/mute_op';
|
|
5
|
+
export type AppContextOptions = {
|
|
6
|
+
db: Database;
|
|
7
|
+
cfg: ServerConfig;
|
|
8
|
+
};
|
|
9
|
+
export declare class AppContext {
|
|
10
|
+
db: Database;
|
|
11
|
+
cfg: ServerConfig;
|
|
12
|
+
events: TypedEventEmitter<AppEvents>;
|
|
13
|
+
constructor(opts: AppContextOptions);
|
|
14
|
+
static fromConfig(cfg: ServerConfig, overrides?: Partial<AppContextOptions>): Promise<AppContext>;
|
|
15
|
+
}
|
|
16
|
+
export default AppContext;
|
|
17
|
+
export type AppEvents = {
|
|
18
|
+
[createMuteOpChannel]: () => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Migrator } from 'kysely';
|
|
2
|
+
import TypedEmitter from 'typed-emitter';
|
|
3
|
+
import { Pool as PgPool } from 'pg';
|
|
4
|
+
import DatabaseSchema from './schema';
|
|
5
|
+
import { PgOptions } from './types';
|
|
6
|
+
export declare class Database {
|
|
7
|
+
opts: PgOptions;
|
|
8
|
+
pool: PgPool;
|
|
9
|
+
db: DatabaseSchema;
|
|
10
|
+
migrator: Migrator;
|
|
11
|
+
txEvt: TxnEmitter;
|
|
12
|
+
destroyed: boolean;
|
|
13
|
+
constructor(opts: PgOptions, instances?: {
|
|
14
|
+
db: DatabaseSchema;
|
|
15
|
+
pool: PgPool;
|
|
16
|
+
});
|
|
17
|
+
get schema(): string | undefined;
|
|
18
|
+
get isTransaction(): boolean;
|
|
19
|
+
assertTransaction(): void;
|
|
20
|
+
assertNotTransaction(): void;
|
|
21
|
+
transaction<T>(fn: (db: Database) => Promise<T>): Promise<T>;
|
|
22
|
+
onCommit(fn: () => void): void;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
migrateToOrThrow(migration: string): Promise<import("kysely").MigrationResult[]>;
|
|
25
|
+
migrateToLatestOrThrow(): Promise<import("kysely").MigrationResult[]>;
|
|
26
|
+
}
|
|
27
|
+
export default Database;
|
|
28
|
+
type TxnEmitter = TypedEmitter<TxnEvents>;
|
|
29
|
+
type TxnEvents = {
|
|
30
|
+
commit: () => void;
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as _20240108T220751294Z from './20240108T220751294Z-init';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Kysely } from 'kysely';
|
|
2
|
+
import * as muteOp from './mute_op';
|
|
3
|
+
import * as muteItem from './mute_item';
|
|
4
|
+
export type DatabaseSchemaType = muteItem.PartialDB & muteOp.PartialDB;
|
|
5
|
+
export type DatabaseSchema = Kysely<DatabaseSchemaType>;
|
|
6
|
+
export default DatabaseSchema;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Selectable } from 'kysely';
|
|
2
|
+
export interface MuteItem {
|
|
3
|
+
actorDid: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
fromId: number;
|
|
6
|
+
}
|
|
7
|
+
export type MuteItemEntry = Selectable<MuteItem>;
|
|
8
|
+
export declare const tableName = "mute_item";
|
|
9
|
+
export type PartialDB = {
|
|
10
|
+
[tableName]: MuteItem;
|
|
11
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GeneratedAlways, Selectable } from 'kysely';
|
|
2
|
+
import { MuteOperation_Type } from '../../gen/bsync_pb';
|
|
3
|
+
export interface MuteOp {
|
|
4
|
+
id: GeneratedAlways<number>;
|
|
5
|
+
type: MuteOperation_Type;
|
|
6
|
+
actorDid: string;
|
|
7
|
+
subject: string;
|
|
8
|
+
createdAt: GeneratedAlways<Date>;
|
|
9
|
+
}
|
|
10
|
+
export type MuteOpEntry = Selectable<MuteOp>;
|
|
11
|
+
export declare const tableName = "mute_op";
|
|
12
|
+
export type PartialDB = {
|
|
13
|
+
[tableName]: MuteOp;
|
|
14
|
+
};
|
|
15
|
+
export declare const createMuteOpChannel = "mute_op_create";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Pool as PgPool } from 'pg';
|
|
2
|
+
import { DynamicModule, RawBuilder, SelectQueryBuilder } from 'kysely';
|
|
3
|
+
export type DbRef = RawBuilder | ReturnType<DynamicModule['ref']>;
|
|
4
|
+
export type AnyQb = SelectQueryBuilder<any, any, any>;
|
|
5
|
+
export type PgOptions = {
|
|
6
|
+
url: string;
|
|
7
|
+
pool?: PgPool;
|
|
8
|
+
schema?: string;
|
|
9
|
+
poolSize?: number;
|
|
10
|
+
poolMaxUses?: number;
|
|
11
|
+
poolIdleTimeoutMs?: number;
|
|
12
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AddMuteOperationRequest, AddMuteOperationResponse, PingRequest, PingResponse, ScanMuteOperationsRequest, ScanMuteOperationsResponse } from './bsync_pb.ts';
|
|
2
|
+
import { MethodKind } from '@bufbuild/protobuf';
|
|
3
|
+
export declare const Service: {
|
|
4
|
+
readonly typeName: "bsync.Service";
|
|
5
|
+
readonly methods: {
|
|
6
|
+
readonly addMuteOperation: {
|
|
7
|
+
readonly name: "AddMuteOperation";
|
|
8
|
+
readonly I: typeof AddMuteOperationRequest;
|
|
9
|
+
readonly O: typeof AddMuteOperationResponse;
|
|
10
|
+
readonly kind: MethodKind.Unary;
|
|
11
|
+
};
|
|
12
|
+
readonly scanMuteOperations: {
|
|
13
|
+
readonly name: "ScanMuteOperations";
|
|
14
|
+
readonly I: typeof ScanMuteOperationsRequest;
|
|
15
|
+
readonly O: typeof ScanMuteOperationsResponse;
|
|
16
|
+
readonly kind: MethodKind.Unary;
|
|
17
|
+
};
|
|
18
|
+
readonly ping: {
|
|
19
|
+
readonly name: "Ping";
|
|
20
|
+
readonly I: typeof PingRequest;
|
|
21
|
+
readonly O: typeof PingResponse;
|
|
22
|
+
readonly kind: MethodKind.Unary;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from '@bufbuild/protobuf';
|
|
2
|
+
import { Message, proto3 } from '@bufbuild/protobuf';
|
|
3
|
+
export declare class MuteOperation extends Message<MuteOperation> {
|
|
4
|
+
id: string;
|
|
5
|
+
type: MuteOperation_Type;
|
|
6
|
+
actorDid: string;
|
|
7
|
+
subject: string;
|
|
8
|
+
constructor(data?: PartialMessage<MuteOperation>);
|
|
9
|
+
static readonly runtime: typeof proto3;
|
|
10
|
+
static readonly typeName = "bsync.MuteOperation";
|
|
11
|
+
static readonly fields: FieldList;
|
|
12
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MuteOperation;
|
|
13
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MuteOperation;
|
|
14
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MuteOperation;
|
|
15
|
+
static equals(a: MuteOperation | PlainMessage<MuteOperation> | undefined, b: MuteOperation | PlainMessage<MuteOperation> | undefined): boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare enum MuteOperation_Type {
|
|
18
|
+
UNSPECIFIED = 0,
|
|
19
|
+
ADD = 1,
|
|
20
|
+
REMOVE = 2,
|
|
21
|
+
CLEAR = 3
|
|
22
|
+
}
|
|
23
|
+
export declare class AddMuteOperationRequest extends Message<AddMuteOperationRequest> {
|
|
24
|
+
type: MuteOperation_Type;
|
|
25
|
+
actorDid: string;
|
|
26
|
+
subject: string;
|
|
27
|
+
constructor(data?: PartialMessage<AddMuteOperationRequest>);
|
|
28
|
+
static readonly runtime: typeof proto3;
|
|
29
|
+
static readonly typeName = "bsync.AddMuteOperationRequest";
|
|
30
|
+
static readonly fields: FieldList;
|
|
31
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): AddMuteOperationRequest;
|
|
32
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): AddMuteOperationRequest;
|
|
33
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): AddMuteOperationRequest;
|
|
34
|
+
static equals(a: AddMuteOperationRequest | PlainMessage<AddMuteOperationRequest> | undefined, b: AddMuteOperationRequest | PlainMessage<AddMuteOperationRequest> | undefined): boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare class AddMuteOperationResponse extends Message<AddMuteOperationResponse> {
|
|
37
|
+
operation?: MuteOperation;
|
|
38
|
+
constructor(data?: PartialMessage<AddMuteOperationResponse>);
|
|
39
|
+
static readonly runtime: typeof proto3;
|
|
40
|
+
static readonly typeName = "bsync.AddMuteOperationResponse";
|
|
41
|
+
static readonly fields: FieldList;
|
|
42
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): AddMuteOperationResponse;
|
|
43
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): AddMuteOperationResponse;
|
|
44
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): AddMuteOperationResponse;
|
|
45
|
+
static equals(a: AddMuteOperationResponse | PlainMessage<AddMuteOperationResponse> | undefined, b: AddMuteOperationResponse | PlainMessage<AddMuteOperationResponse> | undefined): boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare class ScanMuteOperationsRequest extends Message<ScanMuteOperationsRequest> {
|
|
48
|
+
cursor: string;
|
|
49
|
+
limit: number;
|
|
50
|
+
constructor(data?: PartialMessage<ScanMuteOperationsRequest>);
|
|
51
|
+
static readonly runtime: typeof proto3;
|
|
52
|
+
static readonly typeName = "bsync.ScanMuteOperationsRequest";
|
|
53
|
+
static readonly fields: FieldList;
|
|
54
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ScanMuteOperationsRequest;
|
|
55
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ScanMuteOperationsRequest;
|
|
56
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ScanMuteOperationsRequest;
|
|
57
|
+
static equals(a: ScanMuteOperationsRequest | PlainMessage<ScanMuteOperationsRequest> | undefined, b: ScanMuteOperationsRequest | PlainMessage<ScanMuteOperationsRequest> | undefined): boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare class ScanMuteOperationsResponse extends Message<ScanMuteOperationsResponse> {
|
|
60
|
+
operations: MuteOperation[];
|
|
61
|
+
cursor: string;
|
|
62
|
+
constructor(data?: PartialMessage<ScanMuteOperationsResponse>);
|
|
63
|
+
static readonly runtime: typeof proto3;
|
|
64
|
+
static readonly typeName = "bsync.ScanMuteOperationsResponse";
|
|
65
|
+
static readonly fields: FieldList;
|
|
66
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ScanMuteOperationsResponse;
|
|
67
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ScanMuteOperationsResponse;
|
|
68
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ScanMuteOperationsResponse;
|
|
69
|
+
static equals(a: ScanMuteOperationsResponse | PlainMessage<ScanMuteOperationsResponse> | undefined, b: ScanMuteOperationsResponse | PlainMessage<ScanMuteOperationsResponse> | undefined): boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare class PingRequest extends Message<PingRequest> {
|
|
72
|
+
constructor(data?: PartialMessage<PingRequest>);
|
|
73
|
+
static readonly runtime: typeof proto3;
|
|
74
|
+
static readonly typeName = "bsync.PingRequest";
|
|
75
|
+
static readonly fields: FieldList;
|
|
76
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PingRequest;
|
|
77
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PingRequest;
|
|
78
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PingRequest;
|
|
79
|
+
static equals(a: PingRequest | PlainMessage<PingRequest> | undefined, b: PingRequest | PlainMessage<PingRequest> | undefined): boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare class PingResponse extends Message<PingResponse> {
|
|
82
|
+
constructor(data?: PartialMessage<PingResponse>);
|
|
83
|
+
static readonly runtime: typeof proto3;
|
|
84
|
+
static readonly typeName = "bsync.PingResponse";
|
|
85
|
+
static readonly fields: FieldList;
|
|
86
|
+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PingResponse;
|
|
87
|
+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PingResponse;
|
|
88
|
+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PingResponse;
|
|
89
|
+
static equals(a: PingResponse | PlainMessage<PingResponse> | undefined, b: PingResponse | PlainMessage<PingResponse> | undefined): boolean;
|
|
90
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import AppContext, { AppContextOptions } from './context';
|
|
4
|
+
import { ServerConfig } from './config';
|
|
5
|
+
export * from './config';
|
|
6
|
+
export * from './client';
|
|
7
|
+
export { Database } from './db';
|
|
8
|
+
export { AppContext } from './context';
|
|
9
|
+
export { httpLogger } from './logger';
|
|
10
|
+
export declare class BsyncService {
|
|
11
|
+
ctx: AppContext;
|
|
12
|
+
server: http.Server;
|
|
13
|
+
private ac;
|
|
14
|
+
private terminator;
|
|
15
|
+
private dbStatsInterval;
|
|
16
|
+
constructor(opts: {
|
|
17
|
+
ctx: AppContext;
|
|
18
|
+
server: http.Server;
|
|
19
|
+
ac: AbortController;
|
|
20
|
+
});
|
|
21
|
+
static create(cfg: ServerConfig, overrides?: Partial<AppContextOptions>): Promise<BsyncService>;
|
|
22
|
+
start(): Promise<http.Server>;
|
|
23
|
+
destroy(): Promise<void>;
|
|
24
|
+
setupAppEvents(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export default BsyncService;
|