@messenger-box/platform-client 0.0.1-alpha.134
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/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/jest.config.js +24 -0
- package/lib/graphql/id-generation.d.ts +14 -0
- package/lib/graphql/index.d.ts +4 -0
- package/lib/graphql/policies/channel-policies.d.ts +2 -0
- package/lib/graphql/policies/index.d.ts +3 -0
- package/lib/graphql/policies/posts-policies.d.ts +2 -0
- package/lib/graphql/policies/user-policies.d.ts +2 -0
- package/lib/graphql/schema/index.d.ts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +500 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/index.d.ts +3 -0
- package/package.json +60 -0
- package/src/graphql/fragments/configuration.gql +12 -0
- package/src/graphql/fragments/post-message.gql +42 -0
- package/src/graphql/id-generation.ts +8 -0
- package/src/graphql/index.ts +7 -0
- package/src/graphql/mutations/channel-mutation.gql +44 -0
- package/src/graphql/mutations/messages-mutation.gql +66 -0
- package/src/graphql/policies/channel-policies.ts +7 -0
- package/src/graphql/policies/index.ts +3 -0
- package/src/graphql/policies/posts-policies.ts +110 -0
- package/src/graphql/policies/user-policies.ts +32 -0
- package/src/graphql/queries/channel.gql +28 -0
- package/src/graphql/queries/post-message.gql +8 -0
- package/src/graphql/queries/users.gql +32 -0
- package/src/graphql/schema/index.ts +4 -0
- package/src/graphql/schema/post.graphql +44 -0
- package/src/graphql/schema/services.graphql +6 -0
- package/src/index.tsx +3 -0
- package/src/inversify-containers/index.ts +1 -0
- package/src/inversify-containers/module.ts +4 -0
- package/src/packages/constants/constants.ts +1831 -0
- package/src/packages/types/channels.ts +194 -0
- package/src/packages/types/emojis.ts +41 -0
- package/src/packages/types/files.ts +43 -0
- package/src/packages/types/posts.ts +155 -0
- package/src/packages/types/reactions.ts +8 -0
- package/src/packages/types/teams.ts +108 -0
- package/src/packages/types/utilities.ts +30 -0
- package/src/services/index.ts +0 -0
- package/src/utils/constants.tsx +1120 -0
- package/src/utils/i18n.tsx +15 -0
- package/src/utils/index.ts +34 -0
- package/src/utils/post_list.ts +54 -0
- package/src/utils/post_utils.ts +33 -0
- package/src/utils/user_agent.tsx +153 -0
- package/src/utils/utils.tsx +54 -0
- package/tsconfig.json +18 -0
- package/webpack.config.js +58 -0
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@messenger-box/platform-client",
|
|
3
|
+
"version": "0.0.1-alpha.134",
|
|
4
|
+
"description": "Sample core for higher packages to depend on",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "CDMBase LLC",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"typings": "lib/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "yarn build:clean && yarn build:lib",
|
|
11
|
+
"build:clean": "rimraf lib",
|
|
12
|
+
"build:lib": "webpack",
|
|
13
|
+
"build:lib:watch": "yarn build:lib -- --watch",
|
|
14
|
+
"jest": "./node_modules/.bin/jest",
|
|
15
|
+
"prepublish": "yarn build",
|
|
16
|
+
"test": "jest",
|
|
17
|
+
"test:debug": "npm test -- --runInBand",
|
|
18
|
+
"test:watch": "npm test -- --watch",
|
|
19
|
+
"watch": "yarn build:lib:watch"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@chakra-ui/icons": "^1.0.16",
|
|
23
|
+
"@chakra-ui/react": "~1.6.12",
|
|
24
|
+
"@emotion/react": "^11",
|
|
25
|
+
"@emotion/styled": "^11",
|
|
26
|
+
"@messenger-box/core": "0.0.1-alpha.127",
|
|
27
|
+
"bootstrap": "3.4.1",
|
|
28
|
+
"css-vars-ponyfill": "2.4.5",
|
|
29
|
+
"dynamic-virtualized-list": "github:mattermost/dynamic-virtualized-list#119db968c96643c7106d4d2c965f05b2e251bc83",
|
|
30
|
+
"emoji-mart": "^3.0.1",
|
|
31
|
+
"font-awesome": "4.7.0",
|
|
32
|
+
"framer-motion": "^4",
|
|
33
|
+
"jasny-bootstrap": "3.1.3",
|
|
34
|
+
"key-mirror": "1.0.1",
|
|
35
|
+
"moment-timezone": "0.5.33",
|
|
36
|
+
"react-bootstrap": "github:mattermost/react-bootstrap#c6957962364e0818a51bbfd13e89919903b422d6",
|
|
37
|
+
"react-icons": "^4.2.0",
|
|
38
|
+
"react-intl": "5.20.4",
|
|
39
|
+
"react-select": "5.2.0",
|
|
40
|
+
"react-virtualized-auto-sizer": "1.0.5",
|
|
41
|
+
"reselect": "4.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/bootstrap": "4.5.0",
|
|
45
|
+
"@types/moment-timezone": "0.5.30",
|
|
46
|
+
"@types/react-bootstrap": "0.32.22",
|
|
47
|
+
"@types/react-virtualized-auto-sizer": "1.0.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@apollo/client": "*",
|
|
51
|
+
"lodash": "*"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"typescript": {
|
|
57
|
+
"definition": "lib/index.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "c573ab335ea48becde0a1efe8ffd3edac7848e72"
|
|
60
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
fragment PostProps on Post {
|
|
2
|
+
author{
|
|
3
|
+
username
|
|
4
|
+
}
|
|
5
|
+
id
|
|
6
|
+
message
|
|
7
|
+
createdAt
|
|
8
|
+
editedBy {
|
|
9
|
+
alias
|
|
10
|
+
}
|
|
11
|
+
updatedAt
|
|
12
|
+
propsConfiguration {
|
|
13
|
+
...Configuration
|
|
14
|
+
}
|
|
15
|
+
files{
|
|
16
|
+
totalCount
|
|
17
|
+
data{
|
|
18
|
+
id
|
|
19
|
+
name
|
|
20
|
+
extension
|
|
21
|
+
mimeType
|
|
22
|
+
height
|
|
23
|
+
width
|
|
24
|
+
size
|
|
25
|
+
url
|
|
26
|
+
refType
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
isPinned @client
|
|
30
|
+
center @client
|
|
31
|
+
compactDisplay @client
|
|
32
|
+
isFirstReply @client
|
|
33
|
+
shouldHighlight @client
|
|
34
|
+
consecutivePostByUser @client
|
|
35
|
+
previousPostIsComment @client
|
|
36
|
+
isCommentMention @client
|
|
37
|
+
hasReplies @client
|
|
38
|
+
isLastPost @client
|
|
39
|
+
channelArchived @client
|
|
40
|
+
isFlagged @client
|
|
41
|
+
isCollapsedThreadsEnabled @client
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IClientCacheTypeNames } from '@messenger-box/core';
|
|
2
|
+
|
|
3
|
+
export const dataIdFromObject = {
|
|
4
|
+
[IClientCacheTypeNames.Post]: ({ id }) => `${IClientCacheTypeNames.Post}:${id}`,
|
|
5
|
+
[IClientCacheTypeNames.Channel]: ({ id }) => `${IClientCacheTypeNames.Channel}:${id}`,
|
|
6
|
+
[IClientCacheTypeNames.ChannelMember]: ({ id }) => `${IClientCacheTypeNames.ChannelMember}:${id}`,
|
|
7
|
+
[IClientCacheTypeNames.UserAccount]: ({ id }) => `${IClientCacheTypeNames.UserAccount}:${id}`,
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { merge } from 'lodash';
|
|
2
|
+
import { postPolicies, userPolicies, channelPolicies } from './policies';
|
|
3
|
+
import { schema } from './schema';
|
|
4
|
+
|
|
5
|
+
const typePolicies = merge({}, postPolicies, userPolicies, channelPolicies);
|
|
6
|
+
export { schema, typePolicies };
|
|
7
|
+
export * from './id-generation';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
mutation AddChannel($name:String!, $description:String!){
|
|
2
|
+
createChannel(
|
|
3
|
+
name:$name,
|
|
4
|
+
description:$description
|
|
5
|
+
){
|
|
6
|
+
id
|
|
7
|
+
title
|
|
8
|
+
type
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
mutation AddDirectChannel($receiver:[ID]!, $displayName:String!){
|
|
13
|
+
createDirectChannel(
|
|
14
|
+
receiver: $receiver
|
|
15
|
+
displayName: $displayName
|
|
16
|
+
){
|
|
17
|
+
id
|
|
18
|
+
displayName
|
|
19
|
+
title
|
|
20
|
+
type
|
|
21
|
+
members{
|
|
22
|
+
user
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
mutation AddMemberToChannel($channelId:String!, $memberId:String!){
|
|
28
|
+
addMemberToChannel(
|
|
29
|
+
channelId: $channelId,
|
|
30
|
+
memberId: $memberId
|
|
31
|
+
){
|
|
32
|
+
id
|
|
33
|
+
displayName
|
|
34
|
+
title
|
|
35
|
+
type
|
|
36
|
+
members{
|
|
37
|
+
user
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
mutation DeleteChannel($ChannelId:ID!){
|
|
43
|
+
deleteChannel(id: $ChannelId)
|
|
44
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
mutation SendMessages(
|
|
2
|
+
$channelId:String!,
|
|
3
|
+
$content:String!,
|
|
4
|
+
$files:[Upload!]!
|
|
5
|
+
){
|
|
6
|
+
sendMessage(
|
|
7
|
+
channelId: $channelId,
|
|
8
|
+
messageInput: {
|
|
9
|
+
content: $content,
|
|
10
|
+
files: $files
|
|
11
|
+
},
|
|
12
|
+
){
|
|
13
|
+
id
|
|
14
|
+
message
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
mutation DeleteMessage(
|
|
19
|
+
$messageId:String!,
|
|
20
|
+
$channelId:String!
|
|
21
|
+
){
|
|
22
|
+
deleteMessage(
|
|
23
|
+
messageId: {
|
|
24
|
+
messageId: $messageId,
|
|
25
|
+
channelId: $channelId
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
mutation EditMessage(
|
|
31
|
+
$messageId:String!,
|
|
32
|
+
$channelId:String!,
|
|
33
|
+
$content:String!,
|
|
34
|
+
$files:[Upload!]!
|
|
35
|
+
){
|
|
36
|
+
editMessage(
|
|
37
|
+
messageId: {
|
|
38
|
+
messageId: $messageId,
|
|
39
|
+
channelId: $channelId
|
|
40
|
+
},
|
|
41
|
+
messageInput: {
|
|
42
|
+
content: $content,
|
|
43
|
+
files: $files
|
|
44
|
+
}
|
|
45
|
+
){
|
|
46
|
+
id
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
mutation UploadImg($files:[Upload!]!, $postId: String!){
|
|
51
|
+
uploadFile(files: $files, postId: $postId)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#mutation PinMessage($messageId:String! , $messageInput:String! , $content:String!) {
|
|
55
|
+
# pinMessage(
|
|
56
|
+
# messageId: {
|
|
57
|
+
# messageId: $messageId,
|
|
58
|
+
# channelId: $channelId
|
|
59
|
+
# },
|
|
60
|
+
# messageInput:{
|
|
61
|
+
# content: $content
|
|
62
|
+
# }
|
|
63
|
+
# ){
|
|
64
|
+
# id
|
|
65
|
+
# }
|
|
66
|
+
#}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { TypePolicies } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const postPolicies: TypePolicies = {
|
|
4
|
+
Post: {
|
|
5
|
+
fields: {
|
|
6
|
+
isPinned: {
|
|
7
|
+
read() {
|
|
8
|
+
return false;
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
center: {
|
|
12
|
+
merge(existing = [], incoming: []) {
|
|
13
|
+
return incoming;
|
|
14
|
+
},
|
|
15
|
+
read() {
|
|
16
|
+
return true;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
compactDisplay: {
|
|
20
|
+
merge(existing = [], incoming: []) {
|
|
21
|
+
return incoming;
|
|
22
|
+
},
|
|
23
|
+
read() {
|
|
24
|
+
return '';
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
isFirstReply: {
|
|
28
|
+
merge(existing = [], incoming: []) {
|
|
29
|
+
return incoming;
|
|
30
|
+
},
|
|
31
|
+
read() {
|
|
32
|
+
return '';
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
shouldHighlight: {
|
|
36
|
+
merge(existing = [], incoming: []) {
|
|
37
|
+
return incoming;
|
|
38
|
+
},
|
|
39
|
+
read() {
|
|
40
|
+
return '';
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
consecutivePostByUser: {
|
|
44
|
+
merge(existing = [], incoming: []) {
|
|
45
|
+
return incoming;
|
|
46
|
+
},
|
|
47
|
+
read() {
|
|
48
|
+
return '';
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
previousPostIsComment: {
|
|
52
|
+
read(_, { readField, toReference, }) {
|
|
53
|
+
const dt = readField('created_at');
|
|
54
|
+
return '';
|
|
55
|
+
},
|
|
56
|
+
merge(existing = [], incoming: []) {
|
|
57
|
+
return incoming;
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
isCommentMention: {
|
|
61
|
+
merge(existing = [], incoming: []) {
|
|
62
|
+
return incoming;
|
|
63
|
+
},
|
|
64
|
+
read() {
|
|
65
|
+
return '';
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
hasReplies: {
|
|
69
|
+
merge(existing = [], incoming: []) {
|
|
70
|
+
return incoming;
|
|
71
|
+
},
|
|
72
|
+
read() {
|
|
73
|
+
return '';
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
isLastPost: {
|
|
77
|
+
merge(existing = [], incoming: []) {
|
|
78
|
+
return incoming;
|
|
79
|
+
},
|
|
80
|
+
read() {
|
|
81
|
+
return '';
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
channelArchived: {
|
|
85
|
+
merge(existing = [], incoming: []) {
|
|
86
|
+
return incoming;
|
|
87
|
+
},
|
|
88
|
+
read() {
|
|
89
|
+
return '';
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
isFlagged: {
|
|
93
|
+
merge(existing = [], incoming: []) {
|
|
94
|
+
return incoming;
|
|
95
|
+
},
|
|
96
|
+
read() {
|
|
97
|
+
return '';
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
isCollapsedThreadsEnabled: {
|
|
101
|
+
merge(existing = [], incoming: []) {
|
|
102
|
+
return incoming;
|
|
103
|
+
},
|
|
104
|
+
read() {
|
|
105
|
+
return '';
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TypePolicies } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const userPolicies: TypePolicies = {
|
|
4
|
+
Query: {
|
|
5
|
+
fields: {
|
|
6
|
+
usersToChat: {
|
|
7
|
+
read(existing, { readField, args }) {
|
|
8
|
+
const allUsers: any = readField('getUsers');
|
|
9
|
+
return allUsers?.filter((usr) => {
|
|
10
|
+
const temp: any = readField('alias', usr);
|
|
11
|
+
if (temp.includes(args.auth0Id)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
currentUser: {
|
|
19
|
+
read(existing, { readField, args }) {
|
|
20
|
+
const allUsers: any = readField('getUsers');
|
|
21
|
+
return allUsers?.filter((usr) => {
|
|
22
|
+
const temp: any = readField('alias', usr);
|
|
23
|
+
if (temp.includes(args.auth0Id)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
})[0];
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
query GetChannelsByUser{
|
|
2
|
+
channelsByUser{
|
|
3
|
+
id
|
|
4
|
+
title
|
|
5
|
+
description
|
|
6
|
+
type
|
|
7
|
+
displayName
|
|
8
|
+
members{
|
|
9
|
+
id
|
|
10
|
+
user
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
query GetAllChannel{
|
|
17
|
+
channels{
|
|
18
|
+
id
|
|
19
|
+
title
|
|
20
|
+
description
|
|
21
|
+
type
|
|
22
|
+
displayName
|
|
23
|
+
members{
|
|
24
|
+
id
|
|
25
|
+
user
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
query GetAllUsers{
|
|
2
|
+
getUsers{
|
|
3
|
+
id
|
|
4
|
+
username
|
|
5
|
+
email
|
|
6
|
+
alias
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
query GetUserById($userId: String!){
|
|
11
|
+
getUserAccount(userId: $userId){
|
|
12
|
+
username
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
query UsersToChat($auth0Id: String!){
|
|
17
|
+
usersToChat(auth0Id:$auth0Id) {
|
|
18
|
+
id
|
|
19
|
+
username
|
|
20
|
+
email
|
|
21
|
+
alias
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
query CurrentUser($auth0Id: String!){
|
|
26
|
+
currentUser(auth0Id:$auth0Id) {
|
|
27
|
+
id
|
|
28
|
+
username
|
|
29
|
+
email
|
|
30
|
+
alias
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
extend type Post {
|
|
4
|
+
isPinned: Boolean @client
|
|
5
|
+
disableGroupHighlight: Boolean @client
|
|
6
|
+
fromBot: Boolean @client
|
|
7
|
+
|
|
8
|
+
""" Set to center the post """
|
|
9
|
+
center: Boolean @client
|
|
10
|
+
|
|
11
|
+
""" Set to render post compactly """
|
|
12
|
+
compactDisplay: Boolean @client
|
|
13
|
+
|
|
14
|
+
""" Set to render a preview of the parent post above this reply """
|
|
15
|
+
isFirstReply: Boolean @client
|
|
16
|
+
|
|
17
|
+
""" Set to highlight the background of the post """
|
|
18
|
+
shouldHighlight: Boolean @client
|
|
19
|
+
|
|
20
|
+
""" Set to render this post as if it was attached to the previous post """
|
|
21
|
+
consecutivePostByUser: Boolean @client
|
|
22
|
+
|
|
23
|
+
""" Set if the previous post is a comment """
|
|
24
|
+
previousPostIsComment: Boolean @client
|
|
25
|
+
|
|
26
|
+
togglePostMenu: Boolean @client
|
|
27
|
+
|
|
28
|
+
""" Set to render this comment as a mention """
|
|
29
|
+
isCommentMention: Boolean @client
|
|
30
|
+
|
|
31
|
+
""" If the post has replies """
|
|
32
|
+
hasReplies: Boolean @client
|
|
33
|
+
|
|
34
|
+
""" To check if the current post is last in the list """
|
|
35
|
+
isLastPost: Boolean @client
|
|
36
|
+
|
|
37
|
+
""" Whether or not the channel that contains this post is archived """
|
|
38
|
+
channelArchived: Boolean @client
|
|
39
|
+
|
|
40
|
+
""" Set to mark the post as flagged """
|
|
41
|
+
isFlagged: Boolean @client
|
|
42
|
+
|
|
43
|
+
isCollapsedThreadsEnabled: Boolean @client
|
|
44
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './module';
|