Skip to content

Commit 1d1a13b

Browse files
committed
style: 💄 run Prettier
1 parent 5df2720 commit 1d1a13b

File tree

13 files changed

+107
-94
lines changed

13 files changed

+107
-94
lines changed

src/__demos__/json-crdt-server/routes/block/methods/del.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const del =
1414
const Response = t.Object(
1515
t.prop('success', t.bool).options({
1616
title: 'Success',
17-
description: 'Indicates whether the block was deleted successfully. Returns `false` if the block does not exist.',
17+
description:
18+
'Indicates whether the block was deleted successfully. Returns `false` if the block does not exist.',
1819
}),
1920
);
2021

src/__demos__/json-crdt-server/routes/block/methods/get.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export const get =
1212
}),
1313
);
1414

15-
const Response = t.Object(
16-
t.prop('block', BlockRef),
17-
);
15+
const Response = t.Object(t.prop('block', BlockRef));
1816

1917
const Func = t.Function(Request, Response).options({
2018
title: 'Read Block',

src/__demos__/json-crdt-server/routes/block/methods/listen.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export const listen =
1212
}),
1313
);
1414

15-
const Response = t.Object(
16-
t.prop('event', BlockEventRef),
17-
);
15+
const Response = t.Object(t.prop('event', BlockEventRef));
1816

1917
const Func = t.Function$(Request, Response).options({
2018
title: 'Listen for block changes',

src/__demos__/json-crdt-server/routes/block/methods/new.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import {BlockIdRef, BlockPatchPartialRef, BlockPatchPartialReturnRef, BlockNewRef, NewBlockSnapshotResponseRef} from '../schema';
1+
import {
2+
BlockIdRef,
3+
BlockPatchPartialRef,
4+
BlockPatchPartialReturnRef,
5+
BlockNewRef,
6+
NewBlockSnapshotResponseRef,
7+
} from '../schema';
28
import type {RouteDeps, Router, RouterBase} from '../../types';
39

410
export const new_ =
@@ -7,30 +13,35 @@ export const new_ =
713
const Request = t.Object(
814
t.prop('id', BlockIdRef).options({
915
title: 'New block ID',
10-
description: 'The ID of the new block. Must be a unique ID, if the block already exists it will return an error.',
16+
description:
17+
'The ID of the new block. Must be a unique ID, if the block already exists it will return an error.',
1118
}),
1219
t.prop('patches', t.Array(BlockPatchPartialRef)).options({
1320
title: 'Patches',
1421
description: 'The patches to apply to the document.',
1522
}),
1623
);
1724

18-
const Response = t.Object(
19-
t.prop('block', BlockNewRef),
20-
t.prop('snapshot', NewBlockSnapshotResponseRef),
21-
t.prop('patches', t.Array(BlockPatchPartialReturnRef)).options({
22-
title: 'Patches',
23-
description: 'The list of patches to apply to the newly created block.',
24-
}),
25-
).options({
26-
title: 'New block creation response',
27-
description: 'The response object for the new block creation, contains server generated metadata without blobs supplied by the client.',
28-
});
25+
const Response = t
26+
.Object(
27+
t.prop('block', BlockNewRef),
28+
t.prop('snapshot', NewBlockSnapshotResponseRef),
29+
t.prop('patches', t.Array(BlockPatchPartialReturnRef)).options({
30+
title: 'Patches',
31+
description: 'The list of patches to apply to the newly created block.',
32+
}),
33+
)
34+
.options({
35+
title: 'New block creation response',
36+
description:
37+
'The response object for the new block creation, contains server generated metadata without blobs supplied by the client.',
38+
});
2939

3040
const Func = t.Function(Request, Response).options({
3141
title: 'Create Block',
3242
intro: 'Creates a new block out of patches.',
33-
description: 'Creates a new block out of supplied patches. A block starts empty with an `undefined` state, and patches are applied to it.',
43+
description:
44+
'Creates a new block out of supplied patches. A block starts empty with an `undefined` state, and patches are applied to it.',
3445
});
3546

3647
return r.prop('block.new', Func, async ({id, patches}) => {

src/__demos__/json-crdt-server/routes/block/methods/scan.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ export const scan =
3737

3838
return r.prop('block.scan', Func, async ({id, cur, limit = 10}) => {
3939
const {patches} = await services.blocks.scan(id, cur, limit);
40-
return {patches: patches.map(p => ({
41-
blob: p.blob,
42-
ts: p.created,
43-
}))};
40+
return {
41+
patches: patches.map((p) => ({
42+
blob: p.blob,
43+
ts: p.created,
44+
})),
45+
};
4446
});
4547
};

src/__demos__/json-crdt-server/routes/block/methods/upd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const upd =
3131

3232
return r.prop('block.upd', Func, async ({id, patches}) => {
3333
const res = await services.blocks.edit(id, patches);
34-
const patchesReturn: ResolveType<typeof BlockPatchPartialReturnRef>[] = res.patches.map(patch => ({
34+
const patchesReturn: ResolveType<typeof BlockPatchPartialReturnRef>[] = res.patches.map((patch) => ({
3535
ts: patch.created,
3636
}));
3737
return {

src/__demos__/json-crdt-server/routes/block/schema.ts

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,25 @@ export const BlockPatchRef = t.Ref<typeof BlockPatch>('BlockPatch');
4444

4545
// ------------------------------------------------------------------- Snapshot
4646

47-
export const BlockSnapshot = t.Object(
48-
t.prop('blob', t.bin)
49-
.options({
47+
export const BlockSnapshot = t
48+
.Object(
49+
t.prop('blob', t.bin).options({
5050
title: 'Snapshot Blob',
5151
description: 'A serialized JSON CRDT model.',
5252
}),
53-
t.prop('cur', BlockCurRef)
54-
.options({
53+
t.prop('cur', BlockCurRef).options({
5554
title: 'Snapshot Cursor',
5655
description: 'The cursor of the snapshot, representing the position in the history.',
5756
}),
58-
t.prop('ts', t.num.options({format: 'u'}))
59-
.options({
57+
t.prop('ts', t.num.options({format: 'u'})).options({
6058
title: 'Snapshot Creation Time',
6159
description: 'The time when the snapshot was created, in milliseconds since the Unix epoch.',
6260
}),
63-
).options({
64-
title: 'Block Snapshot',
65-
description: 'A snapshot of the block\'s state at a certain point in time.',
66-
});
61+
)
62+
.options({
63+
title: 'Block Snapshot',
64+
description: "A snapshot of the block's state at a certain point in time.",
65+
});
6766
export const BlockSnapshotRef = t.Ref<typeof BlockSnapshot>('BlockSnapshot');
6867

6968
export const NewBlockSnapshotResponse = BlockSnapshot.omit('blob');
@@ -78,32 +77,32 @@ export const BlockNew = t.Object(
7877
);
7978
export const BlockNewRef = t.Ref<typeof BlockNew>('BlockNew');
8079

81-
export const Block = BlockNew.extend(t.Object(
82-
t.prop('snapshot', BlockSnapshotRef),
83-
t.prop('tip', t.Array(BlockPatchRef)),
84-
));
80+
export const Block = BlockNew.extend(
81+
t.Object(t.prop('snapshot', BlockSnapshotRef), t.prop('tip', t.Array(BlockPatchRef))),
82+
);
8583
export const BlockRef = t.Ref<typeof Block>('Block');
8684

8785
// --------------------------------------------------------------------- Events
8886

89-
export const BlockDeleteEvent = t.Tuple(
90-
t.Const(<const>'del').options({title: 'Event Type'}),
91-
).options({title: 'Delete Event'});
92-
93-
export const BlockUpdateEvent = t.Tuple(
94-
t.Const(<const>'upd').options({title: 'Event Type'}),
95-
t.Object(
96-
t.prop('patches', t.Array(BlockPatchRef)).options({
97-
title: 'Latest Patches',
98-
description: 'Patches that have been applied to the block.',
99-
}),
100-
).options({title: 'Event Data'}),
101-
).options({title: 'Update Event'});
102-
103-
export const BlockEvent = t.Or(
104-
BlockUpdateEvent,
105-
BlockDeleteEvent,
106-
).options({
87+
export const BlockDeleteEvent = t
88+
.Tuple(t.Const(<const>'del').options({title: 'Event Type'}))
89+
.options({title: 'Delete Event'});
90+
91+
export const BlockUpdateEvent = t
92+
.Tuple(
93+
t.Const(<const>'upd').options({title: 'Event Type'}),
94+
t
95+
.Object(
96+
t.prop('patches', t.Array(BlockPatchRef)).options({
97+
title: 'Latest Patches',
98+
description: 'Patches that have been applied to the block.',
99+
}),
100+
)
101+
.options({title: 'Event Data'}),
102+
)
103+
.options({title: 'Update Event'});
104+
105+
export const BlockEvent = t.Or(BlockUpdateEvent, BlockDeleteEvent).options({
107106
title: 'Block Event',
108107
description: 'A collection of possible events that can happen to a block.',
109108
});

src/__demos__/json-crdt-server/services/blocks/BlocksServices.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ export class BlocksServices {
6666
}
6767

6868
private __emitUpd(id: string, patches: StorePatch[]) {
69-
const msg: TBlockUpdateEvent = ['upd', {patches: patches.map(patch => ({
70-
blob: patch.blob,
71-
ts: patch.created,
72-
}))}];
69+
const msg: TBlockUpdateEvent = [
70+
'upd',
71+
{
72+
patches: patches.map((patch) => ({
73+
blob: patch.blob,
74+
ts: patch.created,
75+
})),
76+
},
77+
];
7378
this.services.pubsub.publish(`__block:${id}`, msg).catch((error) => {
7479
// tslint:disable-next-line:no-console
7580
console.error('Error publishing block patches', error);
@@ -93,11 +98,7 @@ export class BlocksServices {
9398
return deleted;
9499
}
95100

96-
public async scan(
97-
id: string,
98-
offset: number | undefined,
99-
limit: number | undefined = 10,
100-
) {
101+
public async scan(id: string, offset: number | undefined, limit: number | undefined = 10) {
101102
const {store} = this;
102103
if (typeof offset !== 'number') offset = await store.seq(id);
103104
let min: number = 0,

src/__tests__/json-crdt-server/block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export const runBlockTests = (_setup: ApiTestSetup, params: {staticOnly?: true}
436436
cur: 2,
437437
ts: expect.any(Number),
438438
},
439-
}
439+
},
440440
});
441441
stop();
442442
});

src/common/rpc/caller/ObjectValueCaller.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,7 @@ export class ObjectValueCaller<V extends ObjectValue<ObjectType<any>>, Ctx = unk
136136
public toString(tab: string = ''): string {
137137
return (
138138
`${this.constructor.name}` +
139-
printTree(tab,
140-
[
141-
tab => this.router.toString(tab),
142-
tab => this.system.toString(tab),
143-
]
144-
)
139+
printTree(tab, [(tab) => this.router.toString(tab), (tab) => this.system.toString(tab)])
145140
);
146141
}
147142
}

0 commit comments

Comments
 (0)