@builder6/rooms 3.0.5 → 3.0.7

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.
Files changed (54) hide show
  1. package/package.json +10 -7
  2. package/.prettierrc +0 -4
  3. package/src/emails/UnreadMention.tsx +0 -37
  4. package/src/emails/UnreadReplies.tsx +0 -49
  5. package/src/emails/_components/comment.tsx +0 -70
  6. package/src/emails/_components/header.tsx +0 -26
  7. package/src/emails/_components/headline.tsx +0 -20
  8. package/src/emails/_components/layout.tsx +0 -45
  9. package/src/emails/_lib/types.ts +0 -10
  10. package/src/emails/_styles/colors.ts +0 -7
  11. package/src/emails/_utils/cn.ts +0 -6
  12. package/src/emails/_utils/comments.ts +0 -61
  13. package/src/emails/_utils/getProps.ts +0 -7
  14. package/src/plugin.module.ts +0 -3
  15. package/src/rooms/app.controller.ts +0 -89
  16. package/src/rooms/dtos/inbox_notifications.dto.ts +0 -13
  17. package/src/rooms/dtos/notifications.dto.ts +0 -14
  18. package/src/rooms/dtos/room_members.dto.ts +0 -32
  19. package/src/rooms/dtos/rooms.dto.ts +0 -51
  20. package/src/rooms/emailNotification.service.tsx +0 -126
  21. package/src/rooms/emails/comment-body.tsx +0 -342
  22. package/src/rooms/emails/comment-with-body.ts +0 -24
  23. package/src/rooms/emails/index.ts +0 -25
  24. package/src/rooms/emails/lib/batch-users-resolver.ts +0 -120
  25. package/src/rooms/emails/lib/css-properties.ts +0 -123
  26. package/src/rooms/emails/lib/warning.ts +0 -25
  27. package/src/rooms/emails/thread-notification.tsx +0 -583
  28. package/src/rooms/globals/augmentation.ts +0 -89
  29. package/src/rooms/index.ts +0 -5
  30. package/src/rooms/lib/DateToString.ts +0 -9
  31. package/src/rooms/lib/Json.ts +0 -34
  32. package/src/rooms/lib/utils.ts +0 -240
  33. package/src/rooms/liveblocks.service.ts +0 -25
  34. package/src/rooms/notifications.service.ts +0 -235
  35. package/src/rooms/protocol/AuthToken.ts +0 -126
  36. package/src/rooms/protocol/Authentication.ts +0 -18
  37. package/src/rooms/protocol/BaseActivitiesData.ts +0 -5
  38. package/src/rooms/protocol/BaseRoomInfo.ts +0 -15
  39. package/src/rooms/protocol/BaseUserMeta.ts +0 -28
  40. package/src/rooms/protocol/ClientMsg.ts +0 -94
  41. package/src/rooms/protocol/Comments.ts +0 -202
  42. package/src/rooms/protocol/InboxNotifications.ts +0 -75
  43. package/src/rooms/protocol/Op.ts +0 -143
  44. package/src/rooms/protocol/SerializedCrdt.ts +0 -61
  45. package/src/rooms/protocol/ServerMsg.ts +0 -307
  46. package/src/rooms/protocol/VersionHistory.ts +0 -9
  47. package/src/rooms/rooms.controller.ts +0 -587
  48. package/src/rooms/rooms.gateway.ts +0 -267
  49. package/src/rooms/rooms.guard.ts +0 -52
  50. package/src/rooms/rooms.module.ts +0 -38
  51. package/src/rooms/rooms.moleculer.ts +0 -80
  52. package/src/rooms/rooms.service.ts +0 -723
  53. package/tsconfig.json +0 -10
  54. package/yarn-error.log +0 -17218
package/package.json CHANGED
@@ -1,21 +1,24 @@
1
1
  {
2
2
  "name": "@builder6/rooms",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
7
7
  "main": "dist/plugin.module.js",
8
+ "files": [
9
+ "dist"
10
+ ],
8
11
  "scripts": {
9
12
  "format": "prettier --write \"src/**/*.ts\"",
10
13
  "build": "rimraf dist && tsc",
11
14
  "build:watch": "rimraf dist && tsc --watch"
12
15
  },
13
16
  "dependencies": {
14
- "@builder6/core": "3.0.5",
15
- "@builder6/email": "3.0.5",
16
- "@builder6/files": "3.0.5",
17
- "@builder6/moleculer": "3.0.5",
18
- "@builder6/pages": "3.0.5",
17
+ "@builder6/core": "3.0.7",
18
+ "@builder6/email": "3.0.7",
19
+ "@builder6/files": "3.0.7",
20
+ "@builder6/moleculer": "3.0.7",
21
+ "@builder6/pages": "3.0.7",
19
22
  "@liveblocks/emails": "2.12.0",
20
23
  "@liveblocks/node": "2.12.0",
21
24
  "@react-email/components": "^0.0.31",
@@ -54,5 +57,5 @@
54
57
  "devDependencies": {
55
58
  "@types/lodash": "^4.17.13"
56
59
  },
57
- "gitHead": "6ec7bdd489b9b2be5271e2142f3cf08ca3c156ae"
60
+ "gitHead": "eb1dd820e3365f743ee927bb2d178256b6ec36d2"
58
61
  }
package/.prettierrc DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all"
4
- }
@@ -1,37 +0,0 @@
1
- import { Section, Text } from '@react-email/components';
2
- import type { CommentEmailAsReactData } from '@liveblocks/emails';
3
-
4
- import type { CompanyInfo, RoomInfo } from './_lib/types';
5
-
6
- import { Layout } from './_components/layout';
7
- import { Header } from './_components/header';
8
- import { Headline } from './_components/headline';
9
- import { Comment } from './_components/comment';
10
- import {
11
- getUnreadMentionHeadlineParts,
12
- getUnreadMentionPreviewText,
13
- } from './_utils/comments';
14
- import * as React from 'react';
15
-
16
- type UnreadMentionEmailProps = {
17
- company: CompanyInfo;
18
- room: RoomInfo;
19
- comment: CommentEmailAsReactData;
20
- };
21
-
22
- export default function UnreadMentionEmail(props: UnreadMentionEmailProps) {
23
- const { company, room, comment } = props;
24
-
25
- const previewText = getUnreadMentionPreviewText(comment, room.name);
26
- const headlineParts = getUnreadMentionHeadlineParts(comment, room.name);
27
-
28
- return (
29
- <Layout preview={previewText}>
30
- <Header {...company} />
31
- <Section>
32
- <Headline className="mb-4" parts={headlineParts} />
33
- <Comment {...comment} isHighlighted />
34
- </Section>
35
- </Layout>
36
- );
37
- }
@@ -1,49 +0,0 @@
1
- import { Section, Text } from '@react-email/components';
2
- import type { CommentEmailAsReactData } from '@liveblocks/emails';
3
-
4
- import type { CompanyInfo, RoomInfo } from './_lib/types';
5
- import { getProps } from './_utils/getProps';
6
- import { Layout } from './_components/layout';
7
- import { Header } from './_components/header';
8
- import { Headline } from './_components/headline';
9
- import { Comment } from './_components/comment';
10
- import {
11
- getUnreadRepliesHeadlineParts,
12
- getUnreadRepliesPreviewText,
13
- } from './_utils/comments';
14
-
15
- type UnreadRepliesEmailProps = {
16
- company: CompanyInfo;
17
- room: RoomInfo;
18
- comments: CommentEmailAsReactData[];
19
- };
20
- import * as React from 'react';
21
-
22
-
23
- const UnreadRepliesEmail = (
24
- props: UnreadRepliesEmailProps,
25
- ): React.ReactElement => {
26
- const { company, room, comments } = props;
27
-
28
- const previewText = getUnreadRepliesPreviewText(comments, room.name);
29
- const headlineParts = getUnreadRepliesHeadlineParts(comments, room.name);
30
-
31
- return (
32
- <Layout preview={previewText}>
33
- <Header {...company} />
34
- <Section>
35
- <Headline className="mb-4" parts={headlineParts} />
36
- {comments.map((comment, index) => (
37
- <Comment
38
- key={comment.id}
39
- className={index > 0 ? 'mt-3' : undefined}
40
- {...comment}
41
- isHighlighted={comments.length === 1}
42
- />
43
- ))}
44
- </Section>
45
- </Layout>
46
- );
47
- };
48
-
49
- export default UnreadRepliesEmail;
@@ -1,70 +0,0 @@
1
- import { CommentEmailAsReactData } from "@liveblocks/emails";
2
- import { Section, Row, Column, Img, Button } from "@react-email/components";
3
- import { cn } from "../_utils/cn";
4
- import * as React from "react";
5
-
6
- type CommentProps = CommentEmailAsReactData & {
7
- isHighlighted?: boolean;
8
- className?: string;
9
- };
10
-
11
- export function Comment({
12
- id,
13
- author,
14
- createdAt,
15
- reactBody,
16
- url,
17
- isHighlighted,
18
- className,
19
- }: any) {
20
- const creationDate = createdAt
21
- .toLocaleString("en-US", {
22
- year: "numeric",
23
- month: "short",
24
- day: "numeric",
25
- hour: "numeric",
26
- minute: "2-digit",
27
- hour12: true,
28
- })
29
- .replace(",", "");
30
-
31
- return (
32
- <Section
33
- key={id}
34
- className={cn("rounded-md py-4 pl-4 pr-8", className)}
35
- // NOTE: `react-email` do not interpret correctly borders
36
- // in `className` attribute w/ `tailwindcss`.
37
- style={{ border: "solid 1px rgba(23, 23, 23, 0.10)" }}
38
- >
39
- <Row>
40
- <Column className="w-10">
41
- <Img
42
- className="rounded-full bg-black/5"
43
- width={28}
44
- height={28}
45
- src={author.info.avatar}
46
- />
47
- </Column>
48
- <Column className="text-black">
49
- <span className="text-sm font-medium">{author.info.name}</span>
50
- <span className="ml-1.5 opacity-60 text-xs">{creationDate}</span>
51
- </Column>
52
- </Row>
53
- <Row>
54
- <Column className="w-10" />
55
- <Column>
56
- {reactBody}
57
- <Button
58
- className={cn(
59
- "rounded px-3.5 py-2 text-sm font-medium w-max mt-4",
60
- isHighlighted ? "bg-black text-white" : "bg-black/5 text-black"
61
- )}
62
- href={url}
63
- >
64
- View comment
65
- </Button>
66
- </Column>
67
- </Row>
68
- </Section>
69
- );
70
- }
@@ -1,26 +0,0 @@
1
- import { Row, Column, Heading, Img, Link } from "@react-email/components";
2
- import { CompanyInfo } from "../_lib/types";
3
- import * as React from "react";
4
-
5
- export function Header(company: CompanyInfo) {
6
- return (
7
- <Row className="mb-10">
8
- <Column className="w-10">
9
- <Link href={company.url} target="_blank">
10
- {/* TODO: Update img name by creating a new one for this specific example to work without to deploy this example. */}
11
- <Img
12
- src={company.logoUrl}
13
- alt="Company logo"
14
- className="rounded-md"
15
- height={28}
16
- />
17
- </Link>
18
- </Column>
19
- <Column>
20
- <Heading as="h1" className="m-0 text-lg text-black">
21
- {company.name}
22
- </Heading>
23
- </Column>
24
- </Row>
25
- );
26
- }
@@ -1,20 +0,0 @@
1
- import { Text } from "@react-email/components";
2
- import { cn } from "../_utils/cn";
3
- import type { HeadlineParts } from "../_utils/comments";
4
- import * as React from "react";
5
-
6
- export function Headline({
7
- parts,
8
- className,
9
- }: {
10
- parts: HeadlineParts;
11
- className?: string;
12
- }) {
13
- const [start, middle, end] = parts;
14
-
15
- return (
16
- <Text className={cn("text-sm text-black font-medium m-0", className)}>
17
- {start} <span className="font-normal">{middle}</span> {end}
18
- </Text>
19
- );
20
- }
@@ -1,45 +0,0 @@
1
- import {
2
- Body,
3
- Container,
4
- Head,
5
- Html,
6
- Preview,
7
- Tailwind,
8
- } from "@react-email/components";
9
- import { emailColors } from "../_styles/colors";
10
- import * as React from "react";
11
-
12
- export function Layout({
13
- preview,
14
- children,
15
- }: {
16
- preview: string;
17
- children?: React.ReactNode;
18
- }) {
19
- return (
20
- <Html lang="en">
21
- <Head />
22
- <Preview>{preview}</Preview>
23
- {/**
24
- * This component wraps emails with `TailwindCSS`.
25
- * Import your shared config here to make common tw classes usable at email's html generation
26
- * and usable in your code editor.
27
- */}
28
- <Tailwind
29
- config={{
30
- theme: {
31
- extend: {
32
- colors: {
33
- email: { ...emailColors },
34
- },
35
- },
36
- },
37
- }}
38
- >
39
- <Body className="bg-white my-auto mx-auto font-sans antialiased px-5">
40
- <Container className="py-8">{children}</Container>
41
- </Body>
42
- </Tailwind>
43
- </Html>
44
- );
45
- }
@@ -1,10 +0,0 @@
1
- export type RoomInfo = {
2
- name?: string;
3
- url?: string;
4
- };
5
-
6
- export type CompanyInfo = {
7
- name: string;
8
- url: string;
9
- logoUrl?: string;
10
- };
@@ -1,7 +0,0 @@
1
- import type { RecursiveKeyValuePair } from "tailwindcss/types/config";
2
-
3
- // Export config specific to emails and define them to make them
4
- // usable in your code editor.
5
- export const emailColors: RecursiveKeyValuePair = {
6
- accent: "#1667FF",
7
- };
@@ -1,6 +0,0 @@
1
- import { type ClassValue, clsx } from "clsx";
2
- import { twMerge } from "tailwind-merge";
3
-
4
- export function cn(...inputs: ClassValue[]) {
5
- return twMerge(clsx(inputs));
6
- }
@@ -1,61 +0,0 @@
1
- import type { CommentEmailAsReactData } from "@liveblocks/emails";
2
- import { RoomInfo } from "../_lib/types";
3
-
4
- const UNKNOWN_ROOM = "Unknown room" as const;
5
-
6
- export type HeadlineParts = [string, string, string];
7
-
8
- const getDisplayName = (author: CommentEmailAsReactData["author"]): string =>
9
- author.info.name;
10
-
11
- const getRoomName = (roomName: RoomInfo["name"]): string =>
12
- roomName ?? UNKNOWN_ROOM;
13
-
14
- const createMentionPreview = (authorName: string, roomName: string): string =>
15
- `${authorName} mentioned you in ${roomName}`;
16
-
17
- const createRepliesPreview = (
18
- commentCount: number,
19
- authorName: string,
20
- roomName: string
21
- ): string =>
22
- commentCount === 1
23
- ? `${authorName} left a comment in ${roomName}`
24
- : `${commentCount} new comments in ${roomName}`;
25
-
26
- export const getUnreadMentionPreviewText = (
27
- comment: CommentEmailAsReactData,
28
- roomName: RoomInfo["name"]
29
- ): string =>
30
- createMentionPreview(getDisplayName(comment.author), getRoomName(roomName));
31
-
32
- export const getUnreadMentionHeadlineParts = (
33
- comment: CommentEmailAsReactData,
34
- roomName: RoomInfo["name"]
35
- ): HeadlineParts => [
36
- getDisplayName(comment.author),
37
- "mentioned you in",
38
- getRoomName(roomName),
39
- ];
40
-
41
- export const getUnreadRepliesPreviewText = (
42
- comments: CommentEmailAsReactData[],
43
- roomName: RoomInfo["name"]
44
- ): string =>
45
- createRepliesPreview(
46
- comments.length,
47
- getDisplayName(comments[0].author),
48
- getRoomName(roomName)
49
- );
50
-
51
- export const getUnreadRepliesHeadlineParts = (
52
- comments: CommentEmailAsReactData[],
53
- roomName: RoomInfo["name"]
54
- ): HeadlineParts => {
55
- const commentCount = comments.length;
56
- const displayRoomName = getRoomName(roomName);
57
-
58
- return commentCount === 1
59
- ? [getDisplayName(comments[0].author), "left a comment in", displayRoomName]
60
- : [`${commentCount} new comments`, "in", displayRoomName];
61
- };
@@ -1,7 +0,0 @@
1
- export const getProps = <P>(external: P, preview: P): P => {
2
- if (!external || Object.keys(external).length <= 0) {
3
- return preview;
4
- }
5
-
6
- return external;
7
- };
@@ -1,3 +0,0 @@
1
- export { RoomsModule as default } from './rooms/rooms.module';
2
-
3
- export * from './rooms';
@@ -1,89 +0,0 @@
1
- import {
2
- Controller,
3
- Get,
4
- Param,
5
- Res,
6
- Query,
7
- UseGuards,
8
- Req,
9
- } from '@nestjs/common';
10
- import { Response } from 'express';
11
- import { ConfigService } from '@nestjs/config';
12
- import { AuthGuard } from '@builder6/core';
13
- import { PagesService } from '@builder6/pages';
14
- import { RoomsService } from './rooms.service';
15
- import { ApiBearerAuth, ApiBody, ApiTags } from '@nestjs/swagger';
16
-
17
- // 兼容 Steedos OpenAPI v1 格式的 api
18
- @ApiTags('Rooms')
19
- @Controller('b6/rooms/')
20
- @UseGuards(AuthGuard)
21
- export class RoomsAppController {
22
- constructor(
23
- private readonly pagesService: PagesService,
24
- private readonly roomsService: RoomsService,
25
- private configService: ConfigService,
26
- ) {}
27
-
28
- @Get(':roomId')
29
- async getRooms(
30
- @Param('roomId') roomId: string = 'test',
31
- @Query() query: Record<string, any>,
32
- @Req() req: Request,
33
- @Res() res: Response,
34
- ) {
35
- const user = req['user'];
36
- const room = await this.roomsService.resolveRoomInfo({ roomId });
37
- const roomName = room?.name || roomId;
38
- try {
39
- const schema = {
40
- type: 'page',
41
- title: roomName,
42
- regions: ['body', 'toolbar', 'header'],
43
- toolbar: [
44
- {
45
- type: 'rooms-provider',
46
- baseUrl: '',
47
- body: {
48
- type: 'wrapper',
49
- className: 'p-4',
50
- body: {
51
- type: 'rooms-inbox-popover',
52
- },
53
- },
54
- },
55
- ],
56
- body: [
57
- {
58
- type: 'rooms-provider',
59
- baseUrl: '',
60
- body: [
61
- {
62
- type: 'rooms-comments',
63
- className: 'flex flex-col m-3 gap-3',
64
- roomId: `${roomId}`,
65
- },
66
- ],
67
- },
68
- ],
69
- };
70
- const data = {};
71
- const env = {
72
- assetUrls: [
73
- `https://unpkg.com/@steedos-widgets/liveblocks@6.3.12-beta.6/dist/assets.json`,
74
- ],
75
- };
76
- const rendered = await this.pagesService.renderAmis(
77
- schema,
78
- data,
79
- env,
80
- user,
81
- );
82
-
83
- res.status(200).send(rendered); // 返回渲染后的字符串
84
- } catch (error) {
85
- console.log(error);
86
- return { error: 'Rooms rendering failed', details: error.message };
87
- }
88
- }
89
- }
@@ -1,13 +0,0 @@
1
- export class InboxNotificationDTO {
2
- _id?: string;
3
- userId: string;
4
- kind: string;
5
- notifiedAt?: Date;
6
- readAt?: Date;
7
- roomId: string;
8
- threadId: string;
9
- created?: Date;
10
- created_by?: string;
11
- modified?: Date;
12
- modified_by?: string;
13
- }
@@ -1,14 +0,0 @@
1
- export class NotificationDTO {
2
- _id?: string;
3
- name: string;
4
- body: string;
5
- related_to: {
6
- o: string;
7
- ids: string[];
8
- };
9
- related_name: string;
10
- from: string;
11
- space: string;
12
- owner: string;
13
- is_read: boolean;
14
- }
@@ -1,32 +0,0 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
- import { FULL_ACCESS } from './rooms.dto';
3
-
4
- export class RoomMemberDTO {
5
- @ApiProperty()
6
- _id?: string;
7
-
8
- @ApiProperty()
9
- userId: string;
10
-
11
- @ApiProperty()
12
- roomId: string;
13
-
14
- // 可选范围为:['owner']
15
- @ApiProperty({
16
- enum: ['owner'],
17
- default: [],
18
- })
19
- roles?: string[] = [];
20
-
21
- @ApiProperty({
22
- enum: ['all', 'replies', 'mentions'],
23
- default: ['replies', 'mentions'],
24
- })
25
- notifications?: string[] = ['replies', 'mentions'];
26
-
27
- @ApiProperty({
28
- enum: ['room:read', 'room:write'],
29
- default: FULL_ACCESS,
30
- })
31
- scopes?: string[] = FULL_ACCESS;
32
- }
@@ -1,51 +0,0 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
- import { RoomMemberDTO } from './room_members.dto';
3
-
4
- /**
5
- * Assign this to a room (or wildcard pattern) if you want to grant the user
6
- * read permissions to the storage and comments data for this room. (Note that
7
- * the user will still have permissions to update their own presence.)
8
- */
9
- export const READ_ACCESS = [
10
- 'room:read',
11
- 'room:presence:write',
12
- 'comments:read',
13
- ];
14
-
15
- /**
16
- * Assign this to a room (or wildcard pattern) if you want to grant the user
17
- * permissions to read and write to the room's storage and comments.
18
- */
19
- export const FULL_ACCESS = ['room:write', 'comments:write'];
20
-
21
- export class RoomDTO {
22
- @ApiProperty()
23
- _id?: string;
24
-
25
- @ApiProperty()
26
- name: string;
27
-
28
- @ApiProperty()
29
- description?: string;
30
-
31
- // https://learn.microsoft.com/en-us/microsoftteams/teams-channels-overview
32
- @ApiProperty({
33
- enum: ['standard', 'private', 'shared'],
34
- default: 'standard',
35
- })
36
- membershipType?: string;
37
-
38
- members?: RoomMemberDTO[];
39
-
40
- @ApiProperty({
41
- enum: ['room:read', 'room:write'],
42
- default: FULL_ACCESS,
43
- })
44
- defaultScopes?: string[] = FULL_ACCESS;
45
-
46
- @ApiProperty({
47
- enum: ['all', 'replies', 'mentions'],
48
- default: ['replies', 'mentions'],
49
- })
50
- defaultNotifications?: string[];
51
- }