@messenger-box/platform-client 10.0.3-alpha.165 → 10.0.3-alpha.171

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 (83) hide show
  1. package/lib/graphql/mutations/messages-mutation.gql +0 -26
  2. package/package.json +3 -3
  3. package/CHANGELOG.md +0 -373
  4. package/jest.config.js +0 -25
  5. package/lib/graphql/subscription/sandboxError.gql +0 -17
  6. package/rollup.config.mjs +0 -36
  7. package/src/graphql/fragments/configuration.gql +0 -12
  8. package/src/graphql/fragments/extended-user-account.gql +0 -10
  9. package/src/graphql/fragments/file-info.gql +0 -12
  10. package/src/graphql/fragments/messenger-user.gql +0 -15
  11. package/src/graphql/fragments/minimal-user.gql +0 -9
  12. package/src/graphql/fragments/post-message.gql +0 -152
  13. package/src/graphql/fragments/post-thread-message.gql +0 -77
  14. package/src/graphql/fragments/user.gql +0 -11
  15. package/src/graphql/id-generation.ts +0 -8
  16. package/src/graphql/index.ts +0 -24
  17. package/src/graphql/mutations/channel-mutation.gql +0 -77
  18. package/src/graphql/mutations/expo-notification-token.gql +0 -13
  19. package/src/graphql/mutations/message-threads-mutation.gql +0 -44
  20. package/src/graphql/mutations/messages-mutation.gql +0 -113
  21. package/src/graphql/mutations/messages-mutation.gql.bk +0 -66
  22. package/src/graphql/mutations/organization-mutation.gql.bk +0 -14
  23. package/src/graphql/mutations/teams-mutation.gql.bk +0 -8
  24. package/src/graphql/policies/channel-policies.ts +0 -153
  25. package/src/graphql/policies/index.ts +0 -7
  26. package/src/graphql/policies/messages-policies.ts +0 -321
  27. package/src/graphql/policies/post-thread-policies.ts +0 -179
  28. package/src/graphql/policies/posts-policies.ts +0 -110
  29. package/src/graphql/policies/teams-policies.ts +0 -19
  30. package/src/graphql/policies/user-account-policies.ts +0 -15
  31. package/src/graphql/policies/user-policies.ts +0 -32
  32. package/src/graphql/queries/channel.gql +0 -57
  33. package/src/graphql/queries/channels-by-user.gql +0 -86
  34. package/src/graphql/queries/check-for-new-messages.gql +0 -5
  35. package/src/graphql/queries/file-url.gql +0 -5
  36. package/src/graphql/queries/get-device-token.gql +0 -8
  37. package/src/graphql/queries/messages.gql +0 -28
  38. package/src/graphql/queries/organization-query.gql +0 -125
  39. package/src/graphql/queries/post-message.gql +0 -8
  40. package/src/graphql/queries/post-thread-message.gql +0 -24
  41. package/src/graphql/queries/support-service-channels.gql +0 -18
  42. package/src/graphql/queries/teams-query.gql +0 -32
  43. package/src/graphql/queries/user-account.gql +0 -5
  44. package/src/graphql/queries/users.gql +0 -48
  45. package/src/graphql/schema/index.ts +0 -6
  46. package/src/graphql/schema/messages.graphql +0 -5
  47. package/src/graphql/schema/post.graphql +0 -44
  48. package/src/graphql/schema/services.graphql +0 -6
  49. package/src/graphql/schema/user-account.graphql +0 -3
  50. package/src/graphql/subscription/chat-message-added.gql +0 -6
  51. package/src/graphql/subscription/fileUpdated.gql +0 -11
  52. package/src/graphql/subscription/public-post-added.gql +0 -5
  53. package/src/graphql/subscription/thread-chat-message-added.gql +0 -5
  54. package/src/graphql/subscription/thread-created-updated.gql +0 -12
  55. package/src/hooks/index.ts +0 -4
  56. package/src/hooks/use-base-file-upload.hook.ts +0 -148
  57. package/src/hooks/use-upload-file.hook.native.ts +0 -22
  58. package/src/hooks/use-upload-file.hook.ts +0 -22
  59. package/src/hooks/use-upload-files.hook.native.ts +0 -22
  60. package/src/hooks/use-upload-files.hook.ts +0 -22
  61. package/src/index.ts +0 -3
  62. package/src/inversify-containers/index.ts +0 -1
  63. package/src/inversify-containers/module.ts +0 -4
  64. package/src/packages/constants/constants.ts +0 -1831
  65. package/src/packages/types/channels.ts +0 -194
  66. package/src/packages/types/emojis.ts +0 -41
  67. package/src/packages/types/files.ts +0 -43
  68. package/src/packages/types/posts.ts +0 -155
  69. package/src/packages/types/reactions.ts +0 -8
  70. package/src/packages/types/teams.ts +0 -109
  71. package/src/packages/types/utilities.ts +0 -30
  72. package/src/services/index.ts +0 -0
  73. package/src/tests/mutation/__snapshots__/set-device-token.test.ts.snap +0 -18
  74. package/src/tests/mutation/set-device-token.test.ts +0 -85
  75. package/src/utils/constants.tsx +0 -1120
  76. package/src/utils/i18n.tsx +0 -15
  77. package/src/utils/index.ts +0 -34
  78. package/src/utils/post_list.ts +0 -54
  79. package/src/utils/post_utils.ts +0 -33
  80. package/src/utils/user_agent.tsx +0 -153
  81. package/src/utils/utils.tsx +0 -54
  82. package/tsconfig.json +0 -14
  83. package/webpack.config.js +0 -58
@@ -1,44 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- extend enum ClientCacheTypeNames {
2
- Post
3
- Channel
4
- ChannelMember
5
- UserAccount
6
- }
@@ -1,3 +0,0 @@
1
- extend type UserAccount {
2
- fullName: String
3
- }
@@ -1,6 +0,0 @@
1
-
2
- subscription onChatMessageAdded ($channelId: String, $directTo: String) {
3
- chatMessageAdded (channelId: $channelId, directTo: $directTo) {
4
- ...Post
5
- }
6
- }
@@ -1,11 +0,0 @@
1
- subscription FileUpdated($projectId: String!) {
2
- fileUpdated(projectId: $projectId) {
3
- projectId
4
- messageId
5
- filePath
6
- content
7
- operation
8
- timestamp
9
- syncStatus
10
- }
11
- }
@@ -1,5 +0,0 @@
1
- subscription onPublicPostAdded ($channelId: String!) {
2
- publicPostAdded(channelId: $channelId) {
3
- ...Post
4
- }
5
- }
@@ -1,5 +0,0 @@
1
- subscription onThreadChatMessageAdded($channelId: String, $postParentId: String) {
2
- threadChatMessageAdded(channelId: $channelId, postParentId: $postParentId) {
3
- ...Post
4
- }
5
- }
@@ -1,12 +0,0 @@
1
- subscription onThreadCreatedUpdated($channelId: String, $postParentId: String) {
2
- threadCreatedUpdated(channelId: $channelId, postParentId: $postParentId) {
3
- isCreated
4
- isUpdated
5
- lastMessage {
6
- ...PostWithoutReplies
7
- }
8
- data {
9
- ...PostThread
10
- }
11
- }
12
- }
@@ -1,4 +0,0 @@
1
- export { useUploadFile } from './use-upload-file.hook';
2
- export { useUploadFiles } from './use-upload-files.hook';
3
- export { useUploadFile as useUploadFileNative } from './use-upload-file.hook.native';
4
- export { useUploadFiles as useUploadFilesNative } from './use-upload-files.hook.native';
@@ -1,148 +0,0 @@
1
- import { ApolloError } from '@apollo/client';
2
- import { ImageInfo } from 'expo-image-picker';
3
- import { useCallback } from 'react';
4
- import { ApolloClient, NetworkStatus } from '@apollo/client/core';
5
- import { BaseMutationOptions } from '@apollo/client/react/types/types';
6
- import { IFileInfo, IUploadedFileInput } from 'common';
7
-
8
- export interface IStartUploadResponse<T = IFileInfo> {
9
- data?: Omit<T, 'createdAt' | 'updatedAt'>;
10
- urls?: string[];
11
- error: ApolloError;
12
- }
13
-
14
- export interface CustomBlob extends Blob {
15
- name: string;
16
- width: number;
17
- height: number;
18
- }
19
-
20
- export interface IStartUploadOptions<C, S> {
21
- file: ImageInfo | ImageInfo[];
22
- createUploadLink?: {
23
- variables: C;
24
- } & BaseMutationOptions<any, C>;
25
- saveUploadedFile?: {
26
- variables: S;
27
- } & BaseMutationOptions<any, S>;
28
- }
29
-
30
- export interface IUseUploadFileResponse<C, S> {
31
- startUpload: <T = IFileInfo>(options: IStartUploadOptions<C, S>) => Promise<IStartUploadResponse<T>>;
32
- loading: boolean;
33
- error: ApolloError;
34
- networkStatus: NetworkStatus;
35
- client: ApolloClient<any>;
36
- called: boolean;
37
- }
38
-
39
- export interface IUseUploadFileOptions<C, S> {
40
- createUploadLink: {
41
- name: string;
42
- mutation: any;
43
- processVariables: (file: CustomBlob | CustomBlob[], variables?: C) => Record<string, unknown>;
44
- };
45
- saveUploadedFile: {
46
- name: string;
47
- mutation: any;
48
- processVariables: (file: IUploadedFileInput | IUploadedFileInput[], variables?: S) => Record<string, unknown>;
49
- };
50
- }
51
-
52
- export const useBaseUploadFile = <C, S>(options: IUseUploadFileOptions<C, S>): IUseUploadFileResponse<C, S> => {
53
- const { createUploadLink: createLink, saveUploadedFile } = options;
54
- const [createUploadLink, { loading: linkLoading, error: linkError }] = createLink.mutation();
55
- const [attachFile, { loading: fileStoring, error: fileSaveError, ...rest }] = saveUploadedFile.mutation();
56
-
57
- const startUpload = useCallback(async (options: IStartUploadOptions<C, S>): Promise<IStartUploadResponse> => {
58
- try {
59
- const {
60
- file,
61
- createUploadLink: createUploadLinkOptions,
62
- saveUploadedFile: saveUploadedFileOptions,
63
- } = options;
64
-
65
- const blobs = await Promise.all(
66
- (Array.isArray(file) ? file : [file]).map(async ({ uri }) => {
67
- const res = await fetch(uri);
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- const blob: any = await res.blob();
70
- // eslint-disable-next-line no-underscore-dangle
71
- const { name, size, type: mimeType, width, height } = blob._data;
72
- blob.name = name;
73
- blob.width = width;
74
- blob.height = height;
75
- blob.mimeType = mimeType;
76
- blob.mimeType = size;
77
- return blob;
78
- }),
79
- );
80
- const { variables: createUploadLinkVariables, ...restCreateUploadLinkOptions } =
81
- createUploadLinkOptions || {};
82
- const { data: link, errors: linkErrors } = await createUploadLink({
83
- variables: createLink.processVariables(
84
- Array.isArray(file) ? blobs : blobs[0],
85
- createUploadLinkVariables,
86
- ),
87
- ...restCreateUploadLinkOptions,
88
- });
89
- if (linkErrors) {
90
- return { error: linkErrors[0] };
91
- }
92
- const uploadLinks: string[] = Array.isArray(link[createLink.name])
93
- ? link[createLink.name]
94
- : [link[createLink.name]];
95
- const urls = await Promise.all(
96
- uploadLinks.map(async (link, index) => {
97
- const response = await fetch(link, {
98
- method: 'PUT',
99
- body: blobs[index],
100
- });
101
- if (response.status !== 200) {
102
- return undefined;
103
- }
104
- return link;
105
- }),
106
- );
107
- const filesInfo: IUploadedFileInput[] = await Promise.all(
108
- blobs.map(async (i, index) => {
109
- // eslint-disable-next-line no-underscore-dangle
110
- const { name, size, type: mimeType, width, height } = (i as any)._data;
111
- const url = urls[index];
112
- return {
113
- name,
114
- size,
115
- mimeType,
116
- url,
117
- width,
118
- height,
119
- };
120
- }),
121
- );
122
- const { variables: saveUploadedFileVariables, ...restSaveUploadedFileOptions } =
123
- saveUploadedFileOptions || {};
124
- const { data: attachedFile, errors: attachFileErrors } = await attachFile({
125
- variables: saveUploadedFile.processVariables(
126
- Array.isArray(file) ? filesInfo : filesInfo[0],
127
- saveUploadedFileVariables,
128
- ),
129
- ...restSaveUploadedFileOptions,
130
- });
131
-
132
- return {
133
- data: attachedFile[saveUploadedFile.name],
134
- urls,
135
- error: attachFileErrors ? attachFileErrors[0] : null,
136
- };
137
- } catch (e) {
138
- console.error(e);
139
- }
140
- }, []);
141
-
142
- return {
143
- startUpload,
144
- loading: linkLoading || fileStoring,
145
- error: linkError || fileSaveError,
146
- ...rest,
147
- };
148
- };
@@ -1,22 +0,0 @@
1
- import { useUploadFile as useBaseUploadFile } from '@adminide-stack/file-info-client/lib/hooks/use-file-upload.native.js';
2
- import { useAttachUploadedFileToMessageMutation, useCreateMessageFileUploadLinkMutation } from 'common/graphql';
3
-
4
- export const useUploadFile = (): ReturnType<typeof useBaseUploadFile> =>
5
- useBaseUploadFile({
6
- createUploadLink: {
7
- name: 'createMessageFileUploadLink',
8
- mutation: useCreateMessageFileUploadLinkMutation,
9
- processVariables: (file, variables) => ({
10
- filename: Array.isArray(file) ? file[0]?.name : file.name,
11
- ...(typeof variables === 'object' ? variables : {}),
12
- }),
13
- },
14
- saveUploadedFile: {
15
- name: 'attachUploadedFileToMessage',
16
- mutation: useAttachUploadedFileToMessageMutation,
17
- processVariables: (file, variables) => ({
18
- file,
19
- ...(typeof variables === 'object' ? variables : {}),
20
- }),
21
- },
22
- });
@@ -1,22 +0,0 @@
1
- import { useUploadFile as useBaseUploadFile } from '@adminide-stack/file-info-client/lib/hooks/use-upload-file.js';
2
- import { useAttachUploadedFileToMessageMutation, useCreateMessageFileUploadLinkMutation } from 'common/graphql';
3
-
4
- export const useUploadFile = (): ReturnType<typeof useBaseUploadFile> =>
5
- useBaseUploadFile({
6
- createUploadLink: {
7
- name: 'createMessageFileUploadLink',
8
- mutation: useCreateMessageFileUploadLinkMutation,
9
- processVariables: (file, variables) => ({
10
- filename: Array.isArray(file) ? file[0]?.name : file.name,
11
- ...(typeof variables === 'object' ? variables : {}),
12
- }),
13
- },
14
- saveUploadedFile: {
15
- name: 'attachUploadedFileToMessage',
16
- mutation: useAttachUploadedFileToMessageMutation,
17
- processVariables: (file, variables) => ({
18
- file,
19
- ...(typeof variables === 'object' ? variables : {}),
20
- }),
21
- },
22
- });
@@ -1,22 +0,0 @@
1
- import { useUploadFile } from '@adminide-stack/file-info-client/lib/hooks/use-file-upload.native.js';
2
- import { useAttachUploadedFilesToMessageMutation, useCreateMessageFilesUploadLinkMutation } from 'common/graphql';
3
-
4
- export const useUploadFiles = (): ReturnType<typeof useUploadFile> =>
5
- useUploadFile({
6
- createUploadLink: {
7
- name: 'createMessageFilesUploadLink',
8
- mutation: useCreateMessageFilesUploadLinkMutation,
9
- processVariables: (files, variables) => ({
10
- filenames: Array.isArray(files) ? files.map((file) => file.name) : [files.name],
11
- ...(typeof variables === 'object' ? variables : {}),
12
- }),
13
- },
14
- saveUploadedFile: {
15
- name: 'attachUploadedFilesToMessage',
16
- mutation: useAttachUploadedFilesToMessageMutation,
17
- processVariables: (files, variables) => ({
18
- files,
19
- ...(typeof variables === 'object' ? variables : {}),
20
- }),
21
- },
22
- });
@@ -1,22 +0,0 @@
1
- import { useUploadFile } from '@adminide-stack/file-info-client/lib/hooks/use-upload-file.js';
2
- import { useAttachUploadedFilesToMessageMutation, useCreateMessageFilesUploadLinkMutation } from 'common/graphql';
3
-
4
- export const useUploadFiles = (): ReturnType<typeof useUploadFile> =>
5
- useUploadFile({
6
- createUploadLink: {
7
- name: 'createMessageFilesUploadLink',
8
- mutation: useCreateMessageFilesUploadLinkMutation,
9
- processVariables: (files, variables) => ({
10
- filenames: Array.isArray(files) ? files.map((file) => file.name) : [files.name],
11
- ...(typeof variables === 'object' ? variables : {}),
12
- }),
13
- },
14
- saveUploadedFile: {
15
- name: 'attachUploadedFilesToMessage',
16
- mutation: useAttachUploadedFilesToMessageMutation,
17
- processVariables: (files, variables) => ({
18
- files,
19
- ...(typeof variables === 'object' ? variables : {}),
20
- }),
21
- },
22
- });
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './graphql';
2
- export * from './utils';
3
- export * from './hooks';
@@ -1 +0,0 @@
1
- export * from './module';
@@ -1,4 +0,0 @@
1
- import { ContainerModule, interfaces, Container } from 'inversify';
2
-
3
- export const platformModule: () => interfaces.ContainerModule = () =>
4
- new ContainerModule((bind: interfaces.Bind) => {});