@messenger-box/platform-client 10.0.3-alpha.7 → 10.0.3-alpha.74
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 +92 -0
- package/lib/graphql/fragments/post-message.gql +36 -0
- package/lib/graphql/mutations/channel-mutation.gql +5 -0
- package/lib/graphql/mutations/messages-mutation.gql +37 -0
- package/lib/graphql/policies/channel-policies.d.ts.map +1 -1
- package/lib/graphql/policies/channel-policies.js +150 -2
- package/lib/graphql/policies/channel-policies.js.map +1 -1
- package/lib/graphql/policies/messages-policies.d.ts.map +1 -1
- package/lib/graphql/policies/messages-policies.js +229 -37
- package/lib/graphql/policies/messages-policies.js.map +1 -1
- package/lib/graphql/policies/post-thread-policies.d.ts.map +1 -1
- package/lib/graphql/policies/post-thread-policies.js +136 -31
- package/lib/graphql/policies/post-thread-policies.js.map +1 -1
- package/lib/graphql/policies/teams-policies.d.ts.map +1 -1
- package/lib/graphql/policies/teams-policies.js +13 -1
- package/lib/graphql/policies/teams-policies.js.map +1 -1
- package/lib/graphql/queries/channels-by-user.gql +26 -0
- package/lib/graphql/queries/messages.gql +2 -2
- package/lib/graphql/queries/organization-query.gql +78 -35
- package/lib/graphql/queries/post-thread-message.gql +4 -0
- package/lib/graphql/queries/teams-query.gql +79 -29
- package/lib/graphql/queries/user-account.gql +1 -1
- package/lib/graphql/queries/users.gql +1 -1
- package/lib/graphql/subscription/fileUpdated.gql +11 -0
- package/lib/graphql/subscription/fragmentUpdated.gql +7 -0
- package/lib/graphql/subscription/sandboxError.gql +17 -0
- package/lib/hooks/use-upload-file.hook.d.ts.map +1 -1
- package/lib/hooks/use-upload-file.hook.js +1 -1
- package/lib/hooks/use-upload-file.hook.js.map +1 -1
- package/lib/hooks/use-upload-file.hook.native.d.ts.map +1 -1
- package/lib/hooks/use-upload-file.hook.native.js +1 -1
- package/lib/hooks/use-upload-file.hook.native.js.map +1 -1
- package/lib/hooks/use-upload-files.hook.d.ts.map +1 -1
- package/lib/hooks/use-upload-files.hook.js +1 -1
- package/lib/hooks/use-upload-files.hook.js.map +1 -1
- package/lib/hooks/use-upload-files.hook.native.d.ts.map +1 -1
- package/lib/hooks/use-upload-files.hook.native.js +1 -1
- package/lib/hooks/use-upload-files.hook.native.js.map +1 -1
- package/package.json +4 -4
- package/src/graphql/fragments/post-message.gql +36 -0
- package/src/graphql/mutations/channel-mutation.gql +5 -0
- package/src/graphql/mutations/messages-mutation.gql +37 -0
- package/src/graphql/policies/channel-policies.ts +148 -2
- package/src/graphql/policies/messages-policies.ts +251 -39
- package/src/graphql/policies/post-thread-policies.ts +151 -31
- package/src/graphql/policies/teams-policies.ts +13 -1
- package/src/graphql/queries/channels-by-user.gql +26 -0
- package/src/graphql/queries/messages.gql +2 -2
- package/src/graphql/queries/organization-query.gql +78 -35
- package/src/graphql/queries/post-thread-message.gql +4 -0
- package/src/graphql/queries/teams-query.gql +79 -29
- package/src/graphql/queries/user-account.gql +1 -1
- package/src/graphql/queries/users.gql +1 -1
- package/src/graphql/subscription/fileUpdated.gql +11 -0
- package/src/graphql/subscription/fragmentUpdated.gql +7 -0
- package/src/graphql/subscription/sandboxError.gql +17 -0
- package/src/hooks/use-upload-file.hook.native.ts +1 -4
- package/src/hooks/use-upload-file.hook.ts +1 -4
- package/src/hooks/use-upload-files.hook.native.ts +1 -4
- package/src/hooks/use-upload-files.hook.ts +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,98 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.0.3-alpha.74](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.73...v10.0.3-alpha.74) (2025-09-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
9
|
+
|
|
10
|
+
## [10.0.3-alpha.72](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.71...v10.0.3-alpha.72) (2025-08-28)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
13
|
+
|
|
14
|
+
## [10.0.3-alpha.69](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.68...v10.0.3-alpha.69) (2025-08-11)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
17
|
+
|
|
18
|
+
## [10.0.3-alpha.67](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.66...v10.0.3-alpha.67) (2025-08-06)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
21
|
+
|
|
22
|
+
## [10.0.3-alpha.62](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.61...v10.0.3-alpha.62) (2025-07-30)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
25
|
+
|
|
26
|
+
## [10.0.3-alpha.61](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.60...v10.0.3-alpha.61) (2025-07-09)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
29
|
+
|
|
30
|
+
## [10.0.3-alpha.56](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.55...v10.0.3-alpha.56) (2025-06-30)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
33
|
+
|
|
34
|
+
## [10.0.3-alpha.54](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.53...v10.0.3-alpha.54) (2025-06-29)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
37
|
+
|
|
38
|
+
## [10.0.3-alpha.50](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.49...v10.0.3-alpha.50) (2025-06-05)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
41
|
+
|
|
42
|
+
## [10.0.3-alpha.48](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.47...v10.0.3-alpha.48) (2025-05-30)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
45
|
+
|
|
46
|
+
## [10.0.3-alpha.47](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.46...v10.0.3-alpha.47) (2025-05-26)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
49
|
+
|
|
50
|
+
## [10.0.3-alpha.46](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.45...v10.0.3-alpha.46) (2025-05-19)
|
|
51
|
+
|
|
52
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
53
|
+
|
|
54
|
+
## [10.0.3-alpha.43](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.42...v10.0.3-alpha.43) (2025-05-15)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
57
|
+
|
|
58
|
+
## [10.0.3-alpha.40](https://github.com/cdmbase/messenger-box/compare/v10.0.3-alpha.39...v10.0.3-alpha.40) (2025-05-14)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
61
|
+
|
|
62
|
+
## [10.0.3-alpha.38](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.37...v10.0.3-alpha.38) (2025-04-25)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
65
|
+
|
|
66
|
+
## [10.0.3-alpha.37](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.36...v10.0.3-alpha.37) (2025-04-25)
|
|
67
|
+
|
|
68
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
69
|
+
|
|
70
|
+
## [10.0.3-alpha.36](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.35...v10.0.3-alpha.36) (2025-04-23)
|
|
71
|
+
|
|
72
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
73
|
+
|
|
74
|
+
## [10.0.3-alpha.34](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.33...v10.0.3-alpha.34) (2025-04-22)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
77
|
+
|
|
78
|
+
## [10.0.3-alpha.33](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.32...v10.0.3-alpha.33) (2025-04-17)
|
|
79
|
+
|
|
80
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
81
|
+
|
|
82
|
+
## [10.0.3-alpha.31](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.30...v10.0.3-alpha.31) (2025-04-16)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
85
|
+
|
|
86
|
+
## [10.0.3-alpha.17](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.16...v10.0.3-alpha.17) (2025-04-08)
|
|
87
|
+
|
|
88
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
89
|
+
|
|
90
|
+
## [10.0.3-alpha.16](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.15...v10.0.3-alpha.16) (2025-03-28)
|
|
91
|
+
|
|
92
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
93
|
+
|
|
94
|
+
## [10.0.3-alpha.14](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.13...v10.0.3-alpha.14) (2025-03-27)
|
|
95
|
+
|
|
96
|
+
**Note:** Version bump only for package @messenger-box/platform-client
|
|
97
|
+
|
|
6
98
|
## [10.0.3-alpha.7](https://github.com/CDEBase/messenger-box/compare/v10.0.3-alpha.6...v10.0.3-alpha.7) (2025-02-27)
|
|
7
99
|
|
|
8
100
|
**Note:** Version bump only for package @messenger-box/platform-client
|
|
@@ -19,6 +19,18 @@ fragment Post on Post {
|
|
|
19
19
|
# propsConfiguration {
|
|
20
20
|
# ...Configuration
|
|
21
21
|
# }
|
|
22
|
+
propsConfiguration {
|
|
23
|
+
contents
|
|
24
|
+
id
|
|
25
|
+
keys
|
|
26
|
+
resource
|
|
27
|
+
target
|
|
28
|
+
overrides {
|
|
29
|
+
contents
|
|
30
|
+
identifiers
|
|
31
|
+
keys
|
|
32
|
+
}
|
|
33
|
+
}
|
|
22
34
|
props
|
|
23
35
|
files {
|
|
24
36
|
totalCount
|
|
@@ -58,6 +70,18 @@ fragment PostReplies on Messages {
|
|
|
58
70
|
# propsConfiguration {
|
|
59
71
|
# ...Configuration
|
|
60
72
|
# }
|
|
73
|
+
propsConfiguration {
|
|
74
|
+
contents
|
|
75
|
+
id
|
|
76
|
+
keys
|
|
77
|
+
resource
|
|
78
|
+
target
|
|
79
|
+
overrides {
|
|
80
|
+
contents
|
|
81
|
+
identifiers
|
|
82
|
+
keys
|
|
83
|
+
}
|
|
84
|
+
}
|
|
61
85
|
props
|
|
62
86
|
files {
|
|
63
87
|
totalCount
|
|
@@ -98,6 +122,18 @@ fragment PostWithoutReplies on Post {
|
|
|
98
122
|
# propsConfiguration {
|
|
99
123
|
# ...Configuration
|
|
100
124
|
# }
|
|
125
|
+
propsConfiguration {
|
|
126
|
+
contents
|
|
127
|
+
id
|
|
128
|
+
keys
|
|
129
|
+
resource
|
|
130
|
+
target
|
|
131
|
+
overrides {
|
|
132
|
+
contents
|
|
133
|
+
identifiers
|
|
134
|
+
keys
|
|
135
|
+
}
|
|
136
|
+
}
|
|
101
137
|
props
|
|
102
138
|
files {
|
|
103
139
|
totalCount
|
|
@@ -70,3 +70,8 @@ mutation saveMembersToChannel($membersIds:[String]!,$channelId:String!){
|
|
|
70
70
|
mutation DeleteChannel($ChannelId:ID!){
|
|
71
71
|
deleteChannel(id: $ChannelId)
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
mutation CreateChannelWithProjectId($projectId: String!, $channelInput: ChannelInput!) {
|
|
76
|
+
createChannelWithProjectId(projectId: $projectId, channelInput: $channelInput)
|
|
77
|
+
}
|
|
@@ -5,6 +5,7 @@ mutation SendMessages(
|
|
|
5
5
|
$postId: ID,
|
|
6
6
|
$createdBy: ID,
|
|
7
7
|
$notificationParams:ExpoNotificationData,
|
|
8
|
+
$extraProps:AnyObject
|
|
8
9
|
){
|
|
9
10
|
sendMessage(
|
|
10
11
|
channelId: $channelId,
|
|
@@ -13,6 +14,7 @@ mutation SendMessages(
|
|
|
13
14
|
files: $files,
|
|
14
15
|
createdBy: $createdBy
|
|
15
16
|
notificationParams: $notificationParams
|
|
17
|
+
extraProps: $extraProps
|
|
16
18
|
},
|
|
17
19
|
postId: $postId
|
|
18
20
|
){
|
|
@@ -95,6 +97,41 @@ mutation DeleteMessageFile($url:String!){
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
|
|
100
|
+
mutation GenerateAiCode($messageId: String!, $modelConfig: ModelConfigurationInput) {
|
|
101
|
+
generateAiCode(messageId: $messageId, modelConfig: $modelConfig) {
|
|
102
|
+
eventId
|
|
103
|
+
message
|
|
104
|
+
success
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
mutation RecreateSandbox($messageId: String!, $projectId: String!) {
|
|
109
|
+
recreateSandbox(messageId: $messageId, projectId: $projectId) {
|
|
110
|
+
eventId
|
|
111
|
+
message
|
|
112
|
+
success
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
mutation UpdateSandboxFile($projectId: String!, $messageId: String!, $filePath: String!, $content: String!) {
|
|
117
|
+
updateSandboxFile(projectId: $projectId, messageId: $messageId, filePath: $filePath, content: $content) {
|
|
118
|
+
success
|
|
119
|
+
message
|
|
120
|
+
filePath
|
|
121
|
+
timestamp
|
|
122
|
+
syncStatus
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
mutation RegenerateAiCode($messageId: String!, $modelConfig: ModelConfigurationInput) {
|
|
127
|
+
regenerateAiCode(messageId: $messageId, modelConfig: $modelConfig) {
|
|
128
|
+
eventId
|
|
129
|
+
message
|
|
130
|
+
success
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
98
135
|
#mutation PinMessage($messageId:String! , $messageInput:String! , $content:String!) {
|
|
99
136
|
# pinMessage(
|
|
100
137
|
# messageId: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-policies.d.ts","sourceRoot":"","sources":["../../../src/graphql/policies/channel-policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"channel-policies.d.ts","sourceRoot":"","sources":["../../../src/graphql/policies/channel-policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAO,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,eAAe,EAAE,YAsJ7B,CAAC"}
|
|
@@ -1,5 +1,153 @@
|
|
|
1
|
-
const channelPolicies = {
|
|
1
|
+
import {gql}from'@apollo/client/index.js';const channelPolicies = {
|
|
2
2
|
Query: {
|
|
3
|
-
fields: {
|
|
3
|
+
fields: {
|
|
4
|
+
channelsByUser: {
|
|
5
|
+
keyArgs: ['role', 'criteria', 'limit', 'skip', 'sort'],
|
|
6
|
+
merge(existing = [], incoming = [], {
|
|
7
|
+
readField
|
|
8
|
+
}) {
|
|
9
|
+
// If no existing data, just return incoming
|
|
10
|
+
if (!existing || existing.length === 0) {
|
|
11
|
+
return incoming;
|
|
12
|
+
}
|
|
13
|
+
// If no incoming data, keep existing
|
|
14
|
+
if (!incoming || incoming.length === 0) {
|
|
15
|
+
return existing;
|
|
16
|
+
}
|
|
17
|
+
// Create a map for efficient lookup
|
|
18
|
+
const channelMap = new Map();
|
|
19
|
+
// Add existing channels to map
|
|
20
|
+
for (let i = 0; i < existing.length; i++) {
|
|
21
|
+
const channel = existing[i];
|
|
22
|
+
if (channel) {
|
|
23
|
+
const id = readField('id', channel);
|
|
24
|
+
if (id) {
|
|
25
|
+
channelMap.set(id, channel);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Merge in incoming channels, overwriting existing ones
|
|
30
|
+
for (let i = 0; i < incoming.length; i++) {
|
|
31
|
+
const channel = incoming[i];
|
|
32
|
+
if (channel) {
|
|
33
|
+
const id = readField('id', channel);
|
|
34
|
+
if (id) {
|
|
35
|
+
channelMap.set(id, channel);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Convert map values back to array
|
|
40
|
+
return Array.from(channelMap.values());
|
|
41
|
+
},
|
|
42
|
+
// Add a read function for more control over cache reads
|
|
43
|
+
read(existing, {
|
|
44
|
+
args
|
|
45
|
+
}) {
|
|
46
|
+
// Return undefined to force a network request if data doesn't exist
|
|
47
|
+
if (!existing) return undefined;
|
|
48
|
+
return existing;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
Channel: {
|
|
54
|
+
keyFields: ['id'],
|
|
55
|
+
fields: {
|
|
56
|
+
members: {
|
|
57
|
+
merge(existing = [], incoming) {
|
|
58
|
+
return incoming;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
// Add field policies for other Channel fields if needed
|
|
62
|
+
title: {
|
|
63
|
+
read(title) {
|
|
64
|
+
return title || '';
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
displayName: {
|
|
68
|
+
read(displayName) {
|
|
69
|
+
return displayName || '';
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
// Add computed fields if needed
|
|
73
|
+
memberCount: {
|
|
74
|
+
read(_, {
|
|
75
|
+
readField
|
|
76
|
+
}) {
|
|
77
|
+
const members = readField('members');
|
|
78
|
+
return members && Array.isArray(members) ? members.length : 0;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
lastMessage: {
|
|
82
|
+
merge(existing, incoming, {
|
|
83
|
+
readField
|
|
84
|
+
}) {
|
|
85
|
+
// If no incoming message, keep existing
|
|
86
|
+
if (!incoming) return existing;
|
|
87
|
+
// If no existing message, use incoming
|
|
88
|
+
if (!existing) return incoming;
|
|
89
|
+
// Compare timestamps to determine which is newer
|
|
90
|
+
const existingCreatedAt = readField('createdAt', existing);
|
|
91
|
+
const incomingCreatedAt = readField('createdAt', incoming);
|
|
92
|
+
if (existingCreatedAt && incomingCreatedAt) {
|
|
93
|
+
// Use the more recent message
|
|
94
|
+
return new Date(incomingCreatedAt) > new Date(existingCreatedAt) ? incoming : existing;
|
|
95
|
+
}
|
|
96
|
+
// If timestamps are not available, prefer incoming
|
|
97
|
+
return incoming;
|
|
98
|
+
},
|
|
99
|
+
read(lastMessage, {
|
|
100
|
+
readField,
|
|
101
|
+
cache,
|
|
102
|
+
args
|
|
103
|
+
}) {
|
|
104
|
+
// If lastMessage is already available, return it
|
|
105
|
+
if (lastMessage) return lastMessage;
|
|
106
|
+
// Try to get the channel ID to reference messages cache
|
|
107
|
+
const channelId = readField('id');
|
|
108
|
+
if (!channelId) return null;
|
|
109
|
+
try {
|
|
110
|
+
// Read messages from cache for this channel
|
|
111
|
+
const messagesQuery = cache.readQuery({
|
|
112
|
+
query: gql`
|
|
113
|
+
query GetChannelMessages($channelId: String!) {
|
|
114
|
+
messages(channelId: $channelId, skip: 0, limit: 1) {
|
|
115
|
+
data {
|
|
116
|
+
id
|
|
117
|
+
content
|
|
118
|
+
createdAt
|
|
119
|
+
updatedAt
|
|
120
|
+
user {
|
|
121
|
+
id
|
|
122
|
+
username
|
|
123
|
+
displayName
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
`,
|
|
129
|
+
variables: {
|
|
130
|
+
channelId
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
// Return the first (latest) message if available
|
|
134
|
+
return messagesQuery?.messages?.data?.[0] || null;
|
|
135
|
+
} catch (error) {
|
|
136
|
+
// If messages query fails, return null
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
// Add policies for ChannelMember type
|
|
144
|
+
ChannelMember: {
|
|
145
|
+
keyFields: ['id'],
|
|
146
|
+
fields: {
|
|
147
|
+
user: {
|
|
148
|
+
// Ensure user references are properly merged
|
|
149
|
+
merge: true
|
|
150
|
+
}
|
|
151
|
+
}
|
|
4
152
|
}
|
|
5
153
|
};export{channelPolicies};//# sourceMappingURL=channel-policies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-policies.js","sources":["../../../src/graphql/policies/channel-policies.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channel-policies.js","sources":["../../../src/graphql/policies/channel-policies.ts"],"sourcesContent":[null],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-policies.d.ts","sourceRoot":"","sources":["../../../src/graphql/policies/messages-policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"messages-policies.d.ts","sourceRoot":"","sources":["../../../src/graphql/policies/messages-policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,gBAAgB,EAAE,YA8T9B,CAAC"}
|
|
@@ -27,29 +27,50 @@ const messagesPolicies = {
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
data: {
|
|
30
|
-
keyArgs:
|
|
30
|
+
keyArgs: ['channelId', 'parentId'],
|
|
31
31
|
merge: (existing = [], incoming = [], {
|
|
32
|
-
readField
|
|
33
|
-
mergeObjects
|
|
32
|
+
readField
|
|
34
33
|
}) => {
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
// Use a Map for O(1) lookups instead of array iterations
|
|
35
|
+
const existingMap = new Map();
|
|
36
|
+
// Populate map with existing messages
|
|
37
|
+
if (existing && existing.length > 0) {
|
|
38
|
+
for (let i = 0; i < existing.length; i++) {
|
|
39
|
+
const id = readField('id', existing[i]);
|
|
40
|
+
if (id) {
|
|
41
|
+
existingMap.set(id, existing[i]);
|
|
42
|
+
}
|
|
44
43
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
44
|
+
}
|
|
45
|
+
// Create result array with same capacity as total items
|
|
46
|
+
const result = [];
|
|
47
|
+
// Add incoming items, overwriting existing ones
|
|
48
|
+
if (incoming && incoming.length > 0) {
|
|
49
|
+
for (let i = 0; i < incoming.length; i++) {
|
|
50
|
+
const item = incoming[i];
|
|
51
|
+
const id = readField('id', item);
|
|
52
|
+
if (id) {
|
|
53
|
+
existingMap.set(id, item);
|
|
54
|
+
}
|
|
55
|
+
result.push(item);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Add remaining existing items not in incoming
|
|
59
|
+
if (existing && existing.length > 0) {
|
|
60
|
+
for (let i = 0; i < existing.length; i++) {
|
|
61
|
+
const id = readField('id', existing[i]);
|
|
62
|
+
if (id && !result.some(item => readField('id', item) === id)) {
|
|
63
|
+
result.push(existing[i]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
47
68
|
}
|
|
48
69
|
},
|
|
49
70
|
totalCount: {
|
|
50
|
-
keyArgs:
|
|
71
|
+
keyArgs: ['channelId', 'parentId'],
|
|
51
72
|
merge(existing, incoming) {
|
|
52
|
-
return
|
|
73
|
+
return incoming !== undefined ? incoming : existing;
|
|
53
74
|
}
|
|
54
75
|
}
|
|
55
76
|
// data: {
|
|
@@ -96,32 +117,203 @@ const messagesPolicies = {
|
|
|
96
117
|
Query: {
|
|
97
118
|
fields: {
|
|
98
119
|
messages: {
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
keyArgs: ['channelId', 'parentId'],
|
|
121
|
+
merge(existing, incoming, {
|
|
122
|
+
args,
|
|
123
|
+
readField
|
|
124
|
+
}) {
|
|
125
|
+
if (!incoming) return existing;
|
|
126
|
+
if (!existing) return incoming;
|
|
127
|
+
// Fast return if incoming has no data
|
|
128
|
+
if (!incoming.data || incoming.data.length === 0) {
|
|
129
|
+
return {
|
|
130
|
+
...existing,
|
|
131
|
+
totalCount: incoming.totalCount ?? existing.totalCount
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// Fast return if existing has no data
|
|
135
|
+
if (!existing.data || existing.data.length === 0) {
|
|
136
|
+
return incoming;
|
|
137
|
+
}
|
|
138
|
+
// Determine if this is likely a new message or pagination
|
|
139
|
+
const isNewMessage = args && args.skip === 0;
|
|
140
|
+
// Create a map for existing messages for fast lookups
|
|
141
|
+
const idSet = new Set();
|
|
142
|
+
const mergedData = [...existing.data];
|
|
143
|
+
// Mark all existing IDs
|
|
144
|
+
for (let i = 0; i < mergedData.length; i++) {
|
|
145
|
+
const id = readField('id', mergedData[i]);
|
|
146
|
+
if (id) idSet.add(id);
|
|
147
|
+
}
|
|
148
|
+
// Process incoming messages
|
|
149
|
+
for (let i = 0; i < incoming.data.length; i++) {
|
|
150
|
+
const incomingMsg = incoming.data[i];
|
|
151
|
+
const id = readField('id', incomingMsg);
|
|
152
|
+
if (!id) continue;
|
|
153
|
+
if (idSet.has(id)) {
|
|
154
|
+
// Replace existing message with same ID
|
|
155
|
+
const existingIndex = mergedData.findIndex(msg => readField('id', msg) === id);
|
|
156
|
+
if (existingIndex >= 0) {
|
|
157
|
+
mergedData[existingIndex] = incomingMsg;
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
// Add new message
|
|
161
|
+
if (isNewMessage) {
|
|
162
|
+
// Add to beginning for new messages
|
|
163
|
+
mergedData.unshift(incomingMsg);
|
|
164
|
+
} else {
|
|
165
|
+
// Add to end for pagination
|
|
166
|
+
mergedData.push(incomingMsg);
|
|
167
|
+
}
|
|
168
|
+
idSet.add(id);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
...existing,
|
|
173
|
+
totalCount: incoming.totalCount ?? existing.totalCount,
|
|
174
|
+
data: mergedData
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
FilesInfo: {
|
|
181
|
+
merge: true,
|
|
182
|
+
// Use default merging behavior for FilesInfo
|
|
183
|
+
fields: {
|
|
184
|
+
data: {
|
|
185
|
+
merge(existing = [], incoming = [], {
|
|
186
|
+
readField
|
|
187
|
+
}) {
|
|
188
|
+
// If no existing data, just return incoming
|
|
189
|
+
if (!existing || existing.length === 0) {
|
|
190
|
+
return incoming;
|
|
191
|
+
}
|
|
192
|
+
// If no incoming data, keep existing
|
|
193
|
+
if (!incoming || incoming.length === 0) {
|
|
194
|
+
return existing;
|
|
195
|
+
}
|
|
196
|
+
// Create a map for efficient lookup
|
|
197
|
+
const fileMap = new Map();
|
|
198
|
+
// Add existing files to map
|
|
199
|
+
for (let i = 0; i < existing.length; i++) {
|
|
200
|
+
const file = existing[i];
|
|
201
|
+
if (file) {
|
|
202
|
+
const id = readField('id', file);
|
|
203
|
+
if (id) {
|
|
204
|
+
fileMap.set(id, file);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Merge in incoming files, overwriting existing ones
|
|
209
|
+
for (let i = 0; i < incoming.length; i++) {
|
|
210
|
+
const file = incoming[i];
|
|
211
|
+
if (file) {
|
|
212
|
+
const id = readField('id', file);
|
|
213
|
+
if (id) {
|
|
214
|
+
fileMap.set(id, file);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Convert map values back to array
|
|
219
|
+
return Array.from(fileMap.values());
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
FileInfo: {
|
|
225
|
+
// Use ID as key field
|
|
226
|
+
keyFields: ['id'],
|
|
227
|
+
fields: {
|
|
228
|
+
url: {
|
|
229
|
+
// Ensure URL is always preserved and not normalized
|
|
101
230
|
merge(existing, incoming) {
|
|
231
|
+
return incoming ?? existing;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
Post: {
|
|
237
|
+
fields: {
|
|
238
|
+
replies: {
|
|
239
|
+
merge(existing, incoming) {
|
|
240
|
+
if (!incoming) return existing;
|
|
241
|
+
if (!existing) return incoming;
|
|
242
|
+
// Use a Set for fast duplicate checking
|
|
243
|
+
const uniqueIds = new Set();
|
|
244
|
+
const mergedData = [];
|
|
245
|
+
// Add all existing items to the result and track IDs
|
|
246
|
+
if (existing.data && existing.data.length > 0) {
|
|
247
|
+
for (let i = 0; i < existing.data.length; i++) {
|
|
248
|
+
const item = existing.data[i];
|
|
249
|
+
if (item && item.id && !uniqueIds.has(item.id)) {
|
|
250
|
+
uniqueIds.add(item.id);
|
|
251
|
+
mergedData.push(item);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Add incoming items that don't exist yet
|
|
256
|
+
if (incoming.data && incoming.data.length > 0) {
|
|
257
|
+
for (let i = 0; i < incoming.data.length; i++) {
|
|
258
|
+
const item = incoming.data[i];
|
|
259
|
+
if (item && item.id && !uniqueIds.has(item.id)) {
|
|
260
|
+
uniqueIds.add(item.id);
|
|
261
|
+
mergedData.push(item);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
102
265
|
return {
|
|
103
266
|
...incoming,
|
|
104
|
-
data:
|
|
267
|
+
data: mergedData
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
files: {
|
|
272
|
+
merge(existing, incoming, {
|
|
273
|
+
readField
|
|
274
|
+
}) {
|
|
275
|
+
if (!incoming) return existing;
|
|
276
|
+
if (!existing) return incoming;
|
|
277
|
+
// If either has no data or totalCount is 0, prefer the one with data
|
|
278
|
+
if (!existing.data || existing.data.length === 0) {
|
|
279
|
+
return incoming;
|
|
280
|
+
}
|
|
281
|
+
if (!incoming.data || incoming.data.length === 0) {
|
|
282
|
+
return existing;
|
|
283
|
+
}
|
|
284
|
+
// Create a map for efficient lookup
|
|
285
|
+
const fileMap = new Map();
|
|
286
|
+
// Add existing files to map
|
|
287
|
+
if (existing.data) {
|
|
288
|
+
for (let i = 0; i < existing.data.length; i++) {
|
|
289
|
+
const file = existing.data[i];
|
|
290
|
+
if (file) {
|
|
291
|
+
const id = readField('id', file);
|
|
292
|
+
if (id) {
|
|
293
|
+
fileMap.set(id, file);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// Merge in incoming files, overwriting existing ones
|
|
299
|
+
if (incoming.data) {
|
|
300
|
+
for (let i = 0; i < incoming.data.length; i++) {
|
|
301
|
+
const file = incoming.data[i];
|
|
302
|
+
if (file) {
|
|
303
|
+
const id = readField('id', file);
|
|
304
|
+
if (id) {
|
|
305
|
+
fileMap.set(id, file);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// Create merged result
|
|
311
|
+
return {
|
|
312
|
+
__typename: 'FilesInfo',
|
|
313
|
+
totalCount: Math.max(existing.totalCount || 0, incoming.totalCount || 0, fileMap.size),
|
|
314
|
+
data: Array.from(fileMap.values())
|
|
105
315
|
};
|
|
106
316
|
}
|
|
107
|
-
// merge(existing, incoming, { args, mergeObjects }) {
|
|
108
|
-
// console.log('existing length', existing?.data?.length);
|
|
109
|
-
// console.log('incoming length', incoming?.data?.length);
|
|
110
|
-
// // console.log('existing', JSON.stringify(existing), 'incoming', JSON.stringify(incoming));
|
|
111
|
-
// if (!incoming || incoming?.data?.length) return existing;
|
|
112
|
-
// if (!existing || existing?.data?.length) return incoming;
|
|
113
|
-
// //console.log('existing', JSON.stringify(existing), 'incoming', JSON.stringify(incoming));
|
|
114
|
-
// const mergedData = existing ? existing?.data?.slice(0) : [];
|
|
115
|
-
// // Insert the incoming elements in the right places, according to args.
|
|
116
|
-
// const end = args?.skip + Math.min(args?.limit, incoming?.data?.length);
|
|
117
|
-
// for (let i = args?.skip; i < end; ++i) {
|
|
118
|
-
// mergedData[i] = incoming?.data[i - args?.skip];
|
|
119
|
-
// }
|
|
120
|
-
// const merged = { ...incoming, data: mergedData };
|
|
121
|
-
// return merged;
|
|
122
|
-
// // return mergeObjects(existing, incoming);
|
|
123
|
-
// //return existing ? { ...existing, ...incoming } : incoming;
|
|
124
|
-
// },
|
|
125
317
|
}
|
|
126
318
|
}
|
|
127
319
|
}
|