Skip to content

Commit e1343ac

Browse files
committed
style: 💄 run Prettier
1 parent 2dcdad5 commit e1343ac

File tree

6 files changed

+49
-34
lines changed

6 files changed

+49
-34
lines changed

src/json-crdt-repo/remote/RemoteHistoryDemoServer.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {CallerToMethods, TypedRpcClient} from '../../reactive-rpc/common';
22
import type {JsonJoyDemoRpcCaller} from '../../server';
3-
import type {RemoteHistory, RemoteModel, RemotePatch} from "./types";
3+
import type {RemoteHistory, RemoteModel, RemotePatch} from './types';
44

55
type Methods = CallerToMethods<JsonJoyDemoRpcCaller>;
66

@@ -17,7 +17,7 @@ export interface RemoteServerPatch extends RemotePatch {
1717
}
1818

1919
export class RemoteHistoryDemoServer implements RemoteHistory<Cursor, RemoteServerModel, RemoteServerPatch> {
20-
constructor (protected readonly client: TypedRpcClient<Methods>) {}
20+
constructor(protected readonly client: TypedRpcClient<Methods>) {}
2121

2222
public async create(id: string, patches: RemotePatch[]): Promise<void> {
2323
await this.client.call('block.new', {
@@ -35,7 +35,7 @@ export class RemoteHistoryDemoServer implements RemoteHistory<Cursor, RemoteServ
3535
* Load latest state of the model, and any unmerged "tip" of patches
3636
* it might have.
3737
*/
38-
public async read(id: string): Promise<{cursor: Cursor, model: RemoteServerModel, patches: RemoteServerPatch[]}> {
38+
public async read(id: string): Promise<{cursor: Cursor; model: RemoteServerModel; patches: RemoteServerPatch[]}> {
3939
const {block, patches} = await this.client.call('block.get', {id});
4040
return {
4141
cursor: block.seq,
@@ -44,7 +44,7 @@ export class RemoteHistoryDemoServer implements RemoteHistory<Cursor, RemoteServ
4444
};
4545
}
4646

47-
public async scanFwd(id: string, cursor: Cursor): Promise<{cursor: Cursor, patches: RemoteServerPatch[]}> {
47+
public async scanFwd(id: string, cursor: Cursor): Promise<{cursor: Cursor; patches: RemoteServerPatch[]}> {
4848
const limit = 100;
4949
const res = await this.client.call('block.scan', {
5050
id,
@@ -63,12 +63,18 @@ export class RemoteHistoryDemoServer implements RemoteHistory<Cursor, RemoteServ
6363
};
6464
}
6565

66-
public async scanBwd(id: string, cursor: Cursor): Promise<{cursor: Cursor, model: RemoteServerModel, patches: RemoteServerPatch[]}> {
66+
public async scanBwd(
67+
id: string,
68+
cursor: Cursor,
69+
): Promise<{cursor: Cursor; model: RemoteServerModel; patches: RemoteServerPatch[]}> {
6770
throw new Error('The "blocks.history" should be able to return starting model.');
6871
}
6972

70-
public async update(id: string, cursor: Cursor, patches: RemotePatch[]): Promise<{cursor: Cursor, patches: RemoteServerPatch[]}> {
71-
73+
public async update(
74+
id: string,
75+
cursor: Cursor,
76+
patches: RemotePatch[],
77+
): Promise<{cursor: Cursor; patches: RemoteServerPatch[]}> {
7278
const res = await this.client.call('block.upd', {
7379
id,
7480
patches: patches.map((patch, seq) => ({

src/json-crdt-repo/remote/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export interface RemoteHistory<Cursor, M extends RemoteModel = RemoteModel, P ex
1212
*
1313
* @todo Maybe `state` and `tip` should be serialized to JSON?
1414
*/
15-
read(id: string): Promise<{cursor: Cursor, model: M, patches: P[]}>;
15+
read(id: string): Promise<{cursor: Cursor; model: M; patches: P[]}>;
1616

17-
scanFwd(id: string, cursor: Cursor): Promise<{cursor: Cursor, patches: P[]}>;
17+
scanFwd(id: string, cursor: Cursor): Promise<{cursor: Cursor; patches: P[]}>;
1818

19-
scanBwd(id: string, cursor: Cursor): Promise<{cursor: Cursor, model: M, patches: P[]}>;
19+
scanBwd(id: string, cursor: Cursor): Promise<{cursor: Cursor; model: M; patches: P[]}>;
2020

21-
update(id: string, cursor: Cursor, patches: RemotePatch[]): Promise<{cursor: Cursor, patches: P[]}>;
21+
update(id: string, cursor: Cursor, patches: RemotePatch[]): Promise<{cursor: Cursor; patches: P[]}>;
2222

2323
delete?(id: string): Promise<void>;
2424

src/reactive-rpc/common/types.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import type {Observable} from "rxjs";
2-
import type {FunctionStreamingType, FunctionType, ResolveType} from "../../json-type";
3-
import type {ObjectValue, ObjectValueToTypeMap, UnObjectType} from "../../json-type-value/ObjectValue";
4-
import type {TypeRouter} from "../../json-type/system/TypeRouter";
5-
import type {ObjectValueCaller} from "./rpc/caller/ObjectValueCaller";
6-
import type {RpcCaller} from "./rpc/caller/RpcCaller";
7-
import type {TypeRouterCaller} from "./rpc/caller/TypeRouterCaller";
1+
import type {Observable} from 'rxjs';
2+
import type {FunctionStreamingType, FunctionType, ResolveType} from '../../json-type';
3+
import type {ObjectValue, ObjectValueToTypeMap, UnObjectType} from '../../json-type-value/ObjectValue';
4+
import type {TypeRouter} from '../../json-type/system/TypeRouter';
5+
import type {ObjectValueCaller} from './rpc/caller/ObjectValueCaller';
6+
import type {RpcCaller} from './rpc/caller/RpcCaller';
7+
import type {TypeRouterCaller} from './rpc/caller/TypeRouterCaller';
88

9-
export type CallerToMethods<Caller extends RpcCaller<any>> = {[K in keyof UnTypeRouter<UnTypeRouterCaller<Caller>>]: UnwrapFunction<UnTypeRouter<UnTypeRouterCaller<Caller>>[K]>};
9+
export type CallerToMethods<Caller extends RpcCaller<any>> = {
10+
[K in keyof UnTypeRouter<UnTypeRouterCaller<Caller>>]: UnwrapFunction<UnTypeRouter<UnTypeRouterCaller<Caller>>[K]>;
11+
};
1012

1113
type UnTypeRouterCaller<T> = T extends TypeRouterCaller<infer R> ? R : T extends ObjectValueCaller<infer R> ? R : never;
1214
type UnTypeRouter<T> =

src/server/routes/block/methods/listen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const listen =
2525
title: 'Latest Patches',
2626
description: 'Patches that have been applied to the block.',
2727
}),
28-
)
28+
),
2929
),
3030
);
3131

src/server/routes/block/methods/scan.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ export const scan =
1515
}),
1616
t.propOpt('limit', t.num.options({format: 'u32'})).options({
1717
title: 'Number of Patches',
18-
description: 'The minimum number of patches to return. Defaults to 10. ' +
19-
'When positive, returns the patches ahead of the starting sequence number. ' +
20-
'When negative, returns the patches behind the starting sequence number.',
18+
description:
19+
'The minimum number of patches to return. Defaults to 10. ' +
20+
'When positive, returns the patches ahead of the starting sequence number. ' +
21+
'When negative, returns the patches behind the starting sequence number.',
22+
}),
23+
t.propOpt('model', t.bool).options({
24+
title: 'With Model',
25+
description:
26+
'Whether to include the model in the response. ' +
27+
'Defaults to `false`, when `len` is positive; and, defaults to `true`, when `len` is negative.',
2128
}),
22-
t.propOpt('model', t.bool)
23-
.options({
24-
title: 'With Model',
25-
description: 'Whether to include the model in the response. ' +
26-
'Defaults to `false`, when `len` is positive; and, defaults to `true`, when `len` is negative.',
27-
}),
2829
);
2930

3031
const Response = t.Object(

src/server/services/blocks/BlocksServices.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class BlocksServices {
5252
created: now,
5353
updated: now,
5454
};
55-
return await this.__create(id, model, patches);;
55+
return await this.__create(id, model, patches);
5656
}
5757

5858
private async __create(id: string, model: StoreModel, patches: StorePatch[]) {
@@ -89,11 +89,17 @@ export class BlocksServices {
8989
});
9090
}
9191

92-
public async scan(id: string, offset: number | undefined, limit: number | undefined = 10, returnStartModel: boolean = limit < 0) {
92+
public async scan(
93+
id: string,
94+
offset: number | undefined,
95+
limit: number | undefined = 10,
96+
returnStartModel: boolean = limit < 0,
97+
) {
9398
const {store} = this;
9499
if (typeof offset !== 'number') offset = await store.seq(id);
95-
let min: number = 0, max: number = 0;
96-
if (!limit || (Math.round(limit) !== limit)) throw RpcError.badRequest('INVALID_LIMIT');
100+
let min: number = 0,
101+
max: number = 0;
102+
if (!limit || Math.round(limit) !== limit) throw RpcError.badRequest('INVALID_LIMIT');
97103
if (limit > 0) {
98104
min = Number(offset) || 0;
99105
max = min + limit;
@@ -110,7 +116,7 @@ export class BlocksServices {
110116
if (returnStartModel) {
111117
const startPatches = await store.history(id, 0, min);
112118
if (startPatches.length) {
113-
model = Model.fromPatches(startPatches.map(p => Patch.fromBinary(p.blob)));
119+
model = Model.fromPatches(startPatches.map((p) => Patch.fromBinary(p.blob)));
114120
}
115121
}
116122
return {patches, model};

0 commit comments

Comments
 (0)