MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / serializer

Function serializer

packages/typesense/src/utils/serializer.ts:4–38  ·  view source on GitHub ↗
({
  thread,
  is_public,
  is_restrict,
  accessible_to,
}: {
  thread: SerializedThread;
  is_public: boolean;
  is_restrict: boolean;
  accessible_to: string[];
})

Source from the content-addressed store, hash-verified

2import { TypesenseThread } from './types';
3
4export function serializer({
5 thread,
6 is_public,
7 is_restrict,
8 accessible_to,
9}: {
10 thread: SerializedThread;
11 is_public: boolean;
12 is_restrict: boolean;
13 accessible_to: string[];
14}): TypesenseThread {
15 return {
16 author_name: thread.messages.at(0)?.author?.displayName!,
17 body: thread.messages
18 .map((m) => m.body)
19 .filter((e) => !!e)
20 .join('\n'),
21 channel_name: thread.channel?.channelName!,
22 id: thread.id,
23 last_reply_at: Number(thread.lastReplyAt),
24 mentions_name: [
25 ...new Set(
26 thread.messages
27 .map((m) => m.mentions.map((me) => me.displayName!).flat())
28 .flat()
29 ),
30 ],
31 accountId: thread.channel?.accountId!,
32 is_public,
33 accessible_to,
34 is_restrict,
35 // on disk
36 thread: JSON.stringify(thread),
37 };
38}

Callers 1

pushToTypesenseFunction · 0.90

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected