@jsb188/graphql 1.1.11 → 1.1.12

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 (165) hide show
  1. package/audience.d.ts +343 -0
  2. package/cache/config.ts +58 -24
  3. package/cache/index.chat-activity.test.ts +119 -0
  4. package/cache/index.chat.test.ts +92 -0
  5. package/cache/index.helpers.ts +96 -0
  6. package/cache/index.regression.test.ts +149 -0
  7. package/cache/index.test.ts +370 -42
  8. package/cache/index.ts +326 -799
  9. package/cache/optimistic-ui-runtime.ts +46 -0
  10. package/cache/optimistic-ui.ts +401 -0
  11. package/cache/persist.ts +98 -19
  12. package/cache/store.ts +22 -64
  13. package/cache/value.helpers.ts +17 -0
  14. package/{drafts/store.ts → client/draft-persistence-indexed-db.ts} +19 -3
  15. package/{drafts/index.ts → client/draft-persistence.ts} +5 -2
  16. package/client/index.ts +3 -2
  17. package/client/request.helpers.ts +14 -0
  18. package/client/request.ts +130 -215
  19. package/deno.lock +17 -0
  20. package/deno.test.json +2 -0
  21. package/gql/fragments/agentMemoryFragments.ts +5 -1
  22. package/gql/fragments/agentNoteFragments.ts +150 -0
  23. package/gql/fragments/aiChatFragments.ts +36 -10
  24. package/gql/fragments/audienceFragments.ts +141 -0
  25. package/gql/fragments/campaignFragments.ts +415 -126
  26. package/gql/fragments/dataTableFragments.ts +48 -80
  27. package/gql/fragments/emailFragments.ts +28 -23
  28. package/gql/fragments/fieldDocFragments.ts +222 -40
  29. package/gql/fragments/inboundContactFragments.ts +2 -0
  30. package/gql/fragments/logFragments.ts +93 -2
  31. package/gql/fragments/organizationFragments.ts +10 -0
  32. package/gql/fragments/qrCodeFragments.ts +29 -0
  33. package/gql/fragments/scheduleFragments.ts +652 -140
  34. package/gql/fragments/sheetFragments.ts +84 -373
  35. package/gql/fragments/storageFragments.ts +25 -1
  36. package/gql/fragments/workflowFragments.ts +13 -1
  37. package/gql/mutations/agentMemoryMutations.ts +32 -0
  38. package/gql/mutations/agentNoteMutations.ts +62 -0
  39. package/gql/mutations/aiChatMutations.ts +36 -4
  40. package/gql/mutations/audienceMutations.ts +71 -0
  41. package/gql/mutations/authMutations.ts +45 -1
  42. package/gql/mutations/billingMutations.ts +24 -0
  43. package/gql/mutations/campaignMutations.ts +170 -127
  44. package/gql/mutations/contactMutations.ts +23 -0
  45. package/gql/mutations/dataTableMutations.ts +18 -75
  46. package/gql/mutations/fieldDocMutations.ts +162 -13
  47. package/gql/mutations/index.ts +8 -5
  48. package/gql/mutations/organizationMutations.ts +6 -0
  49. package/gql/mutations/qrCodeMutations.ts +20 -0
  50. package/gql/mutations/scheduleMutations.ts +1052 -354
  51. package/gql/mutations/sheetMutations.ts +62 -118
  52. package/gql/mutations/storageMutations.ts +0 -1
  53. package/gql/mutations/workflowMutations.ts +18 -0
  54. package/gql/queries/agentMemoryQueries.ts +6 -0
  55. package/gql/queries/agentNoteQueries.ts +89 -0
  56. package/gql/queries/aiChatQueries.ts +56 -4
  57. package/gql/queries/audienceQueries.ts +128 -0
  58. package/gql/queries/authQueries.ts +6 -0
  59. package/gql/queries/billingQueries.ts +95 -6
  60. package/gql/queries/campaignQueries.ts +132 -23
  61. package/gql/queries/dataTableQueries.ts +24 -65
  62. package/gql/queries/emailQueries.ts +18 -61
  63. package/gql/queries/emailReplyReportQueries.ts +76 -0
  64. package/gql/queries/fieldDocQueries.ts +100 -92
  65. package/gql/queries/inboundContactQueries.ts +4 -0
  66. package/gql/queries/index.ts +3 -1
  67. package/gql/queries/logQueries.ts +62 -7
  68. package/gql/queries/organizationQueries.ts +13 -0
  69. package/gql/queries/qrCodeQueries.ts +20 -0
  70. package/gql/queries/scheduleQueries.ts +633 -257
  71. package/gql/queries/sheetQueries.ts +59 -152
  72. package/gql/queries/workflowQueries.ts +10 -4
  73. package/hooks/index.helpers.test.ts +50 -0
  74. package/hooks/index.helpers.ts +52 -0
  75. package/hooks/index.ts +863 -685
  76. package/hooks/use-agentMemory-mtn.ts +29 -31
  77. package/hooks/use-agentMemory-qry.ts +15 -3
  78. package/hooks/use-agentNote-mtn.ts +82 -0
  79. package/hooks/use-agentNote-qry.ts +190 -0
  80. package/hooks/use-agentNote-recovery.helpers.test.ts +68 -0
  81. package/hooks/use-agentNote-recovery.helpers.ts +58 -0
  82. package/hooks/use-agentNote-recovery.ts +72 -0
  83. package/hooks/use-aiChat-mtn.ts +96 -112
  84. package/hooks/use-aiChat-qry.helpers.test.ts +63 -0
  85. package/hooks/use-aiChat-qry.helpers.ts +124 -0
  86. package/hooks/use-aiChat-qry.ts +229 -383
  87. package/hooks/use-aiChat-stream-mtn.ts +14 -0
  88. package/hooks/use-audience-mtn.ts +194 -0
  89. package/hooks/use-audience-qry.helpers.test.ts +80 -0
  90. package/hooks/use-audience-qry.helpers.ts +63 -0
  91. package/hooks/use-audience-qry.ts +330 -0
  92. package/hooks/use-auth-mtn.ts +30 -1
  93. package/hooks/use-billing-mtn.ts +31 -0
  94. package/hooks/use-billing-qry.ts +76 -0
  95. package/hooks/use-campaign-generation-recovery.ts +53 -0
  96. package/hooks/use-campaign-mtn.ts +224 -165
  97. package/hooks/use-campaign-qry.helpers.ts +40 -0
  98. package/hooks/use-campaign-qry.ts +631 -54
  99. package/hooks/use-dataTable-mtn.ts +23 -115
  100. package/hooks/use-dataTable-qry.ts +66 -916
  101. package/hooks/use-email-qry.helpers.ts +37 -0
  102. package/hooks/use-email-qry.ts +33 -178
  103. package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
  104. package/hooks/use-fieldDoc-mtn.ts +244 -32
  105. package/hooks/use-fieldDoc-qry.helpers.test.ts +65 -0
  106. package/hooks/use-fieldDoc-qry.helpers.ts +49 -0
  107. package/hooks/use-fieldDoc-qry.ts +134 -102
  108. package/hooks/use-inboundContact-qry.ts +7 -9
  109. package/hooks/use-log-mtn.ts +25 -12
  110. package/hooks/use-log-qry.ts +99 -46
  111. package/hooks/use-organization-qry.ts +16 -60
  112. package/hooks/use-publicFormEmail-mtn.ts +27 -0
  113. package/hooks/use-qrCode-mtn.ts +40 -0
  114. package/hooks/use-qrCode-qry.ts +78 -0
  115. package/hooks/use-schedule-mtn.ts +506 -333
  116. package/hooks/use-schedule-qry.ts +682 -101
  117. package/hooks/use-schedule-reactive.ts +486 -0
  118. package/hooks/use-sheet-mtn.ts +91 -199
  119. package/hooks/use-sheet-qry.ts +84 -238
  120. package/hooks/use-storage-qry.ts +84 -61
  121. package/hooks/use-workflow-mtn.ts +39 -22
  122. package/hooks/use-workflow-qry.ts +40 -61
  123. package/libs/ai-chat-outgoing.helpers.ts +153 -0
  124. package/libs/ai-chat-outgoing.ts +11 -0
  125. package/libs/ai-chat-outgoing.types.ts +25 -0
  126. package/libs/ai-chat-run-realtime.ts +20 -0
  127. package/libs/ai-chat-submission-realtime.ts +150 -0
  128. package/libs/fragment-realtime-sequence.ts +55 -0
  129. package/libs/fragment-recovery.test.ts +326 -0
  130. package/libs/fragment-recovery.ts +325 -0
  131. package/libs/open-sheet.ts +138 -0
  132. package/libs/orchestrator-realtime.helpers.test.ts +229 -0
  133. package/libs/orchestrator-realtime.helpers.ts +317 -0
  134. package/libs/orchestrator-realtime.ts +433 -0
  135. package/libs/request-cache-regression.test.ts +122 -0
  136. package/{client → libs}/request-managed-session.test.ts +1 -1
  137. package/libs/request-no-store.test.ts +419 -0
  138. package/libs/sheet-command-batch.ts +44 -0
  139. package/libs/sheet-view-realtime-router.test.ts +214 -0
  140. package/libs/sheet-view-realtime-router.ts +99 -0
  141. package/loaders/campaign.test.ts +186 -0
  142. package/loaders/campaign.ts +56 -83
  143. package/loaders/emailPreference.ts +75 -0
  144. package/loaders/rest.ts +12 -0
  145. package/package.json +42 -17
  146. package/schedule.d.ts +1790 -0
  147. package/sse.helpers.ts +19 -0
  148. package/sse.ts +26 -115
  149. package/tests/agent-note-detail-cache.test.ts +120 -0
  150. package/tests/agent-note-search.test.ts +444 -0
  151. package/types.d.ts +46 -25
  152. package/client/data-table-realtime-subscriptions.test.ts +0 -740
  153. package/client/data-table-realtime-subscriptions.ts +0 -955
  154. package/client/data-table-realtime.test.ts +0 -792
  155. package/client/data-table-realtime.ts +0 -1218
  156. package/client/fragment-realtime-sequence.ts +0 -52
  157. package/client/open-sheet.ts +0 -137
  158. package/client/request-no-store.test.ts +0 -157
  159. package/gql/fragments/agentDocFragments.ts +0 -46
  160. package/gql/fragments/billingFragments.ts +0 -14
  161. package/gql/mutations/agentDocMutations.ts +0 -177
  162. package/gql/queries/agentDocQueries.ts +0 -120
  163. package/hooks/use-agentDoc-mtn.ts +0 -285
  164. package/hooks/use-agentDoc-qry.ts +0 -208
  165. /package/{client → libs}/sse-ticket.test.ts +0 -0
@@ -1,285 +0,0 @@
1
- import type { UseMutationParams } from '@jsb188/graphql/types.d';
2
- import type { OpenModalPopUpFn } from '@jsb188/react/states';
3
- import {
4
- FRAGMENT_NAMES,
5
- makeFragmentKey,
6
- } from '@jsb188/mday/constants/graphqlReactivity.ts';
7
- import { addFragmentToCache, updateFragment } from '../cache/index.ts';
8
- import {
9
- createAgentDocFolderMtn,
10
- createAgentDocMtn,
11
- deleteAgentDocFolderMtn,
12
- deleteAgentDocMtn,
13
- updateAgentDocAccessMtn,
14
- updateAgentDocFolderMtn,
15
- updateAgentDocMtn,
16
- updateAgentDocSettingsMtn,
17
- } from '../gql/mutations/agentDocMutations.ts';
18
- import { useMutation } from './index.ts';
19
-
20
- /*
21
- * Create an agent doc.
22
- */
23
-
24
- export function useCreateAgentDoc(
25
- params: UseMutationParams = {},
26
- openModalPopUp?: OpenModalPopUpFn,
27
- ) {
28
- const [createAgentDoc, mtnValues, mtnHandlers, updateObservers] = useMutation(
29
- createAgentDocMtn,
30
- {
31
- openModalPopUp,
32
- ...params,
33
- },
34
- );
35
-
36
- return {
37
- createAgentDoc,
38
- updateObservers,
39
- ...mtnValues,
40
- ...mtnHandlers,
41
- };
42
- }
43
-
44
- /*
45
- * Update an agent doc (the editor autosave path; also moves it between folders).
46
- */
47
-
48
- export function useUpdateAgentDoc(
49
- params: UseMutationParams = {},
50
- openModalPopUp?: OpenModalPopUpFn,
51
- ) {
52
- const { onCompleted, ...rest } = params;
53
-
54
- const [updateAgentDoc, mtnValues, mtnHandlers, updateObservers] = useMutation(
55
- updateAgentDocMtn,
56
- {
57
- openModalPopUp,
58
- onCompleted: (data, error, variables) => {
59
- const updatedAgentDoc = data?.updateAgentDoc;
60
-
61
- if (updatedAgentDoc?.id) {
62
- // The origin socket is excluded from the server's realtime emit,
63
- // so the mutation issuer refreshes its own cached fragment here
64
- updateFragment(
65
- makeFragmentKey(FRAGMENT_NAMES.agentDoc, updatedAgentDoc.id),
66
- updatedAgentDoc,
67
- null,
68
- false,
69
- updateObservers,
70
- );
71
- }
72
-
73
- onCompleted?.(updatedAgentDoc, error, variables);
74
- },
75
- ...rest,
76
- },
77
- );
78
-
79
- return {
80
- updateAgentDoc,
81
- updateObservers,
82
- ...mtnValues,
83
- ...mtnHandlers,
84
- };
85
- }
86
-
87
- /*
88
- * Delete an agent doc (soft delete; the server hard-deletes after the retention window).
89
- */
90
-
91
- export function useDeleteAgentDoc(
92
- params: UseMutationParams = {},
93
- openModalPopUp?: OpenModalPopUpFn,
94
- ) {
95
- const { onCompleted, ...rest } = params;
96
- const [deleteAgentDoc, mtnValues, mtnHandlers, updateObservers] = useMutation(
97
- deleteAgentDocMtn,
98
- {
99
- openModalPopUp,
100
- onCompleted: (data, error, variables) => {
101
- const deletedAgentDocId = data?.deleteAgentDoc;
102
- if (deletedAgentDocId) {
103
- updateFragment(
104
- makeFragmentKey(FRAGMENT_NAMES.agentDoc, deletedAgentDocId),
105
- { __deleted: true },
106
- null,
107
- false,
108
- updateObservers,
109
- );
110
- }
111
-
112
- onCompleted?.(data, error, variables);
113
- },
114
- ...rest,
115
- },
116
- );
117
-
118
- return {
119
- deleteAgentDoc,
120
- updateObservers,
121
- ...mtnValues,
122
- ...mtnHandlers,
123
- };
124
- }
125
-
126
- /*
127
- * Update an agent doc's access settings.
128
- */
129
-
130
- export function useUpdateAgentDocAccess(
131
- params: UseMutationParams = {},
132
- openModalPopUp?: OpenModalPopUpFn,
133
- ) {
134
- const { onCompleted, ...rest } = params;
135
-
136
- const [updateAgentDocAccess, mtnValues, mtnHandlers, updateObservers] =
137
- useMutation(updateAgentDocAccessMtn, {
138
- openModalPopUp,
139
- onCompleted: (data, error, variables) => {
140
- const updatedAgentDoc = data?.updateAgentDocAccess;
141
-
142
- if (updatedAgentDoc?.id) {
143
- // The origin socket is excluded from the server's realtime emit,
144
- // so the mutation issuer refreshes its own cached fragment here
145
- updateFragment(
146
- makeFragmentKey(FRAGMENT_NAMES.agentDoc, updatedAgentDoc.id),
147
- updatedAgentDoc,
148
- null,
149
- false,
150
- updateObservers,
151
- );
152
- }
153
-
154
- onCompleted?.(updatedAgentDoc, error, variables);
155
- },
156
- ...rest,
157
- });
158
-
159
- return {
160
- updateAgentDocAccess,
161
- updateObservers,
162
- ...mtnValues,
163
- ...mtnHandlers,
164
- };
165
- }
166
-
167
- /*
168
- * Update an agent doc's per-document AI settings.
169
- */
170
-
171
- export function useUpdateAgentDocSettings(
172
- params: UseMutationParams = {},
173
- openModalPopUp?: OpenModalPopUpFn,
174
- ) {
175
- const { onCompleted, ...rest } = params;
176
-
177
- const [updateAgentDocSettings, mtnValues, mtnHandlers, updateObservers] =
178
- useMutation(updateAgentDocSettingsMtn, {
179
- openModalPopUp,
180
- onCompleted: (data, error, variables) => {
181
- const updatedAgentDoc = data?.updateAgentDocSettings;
182
-
183
- if (updatedAgentDoc?.id) {
184
- // The origin socket is excluded from the server's realtime emit,
185
- // so the mutation issuer refreshes its own cached fragment here.
186
- // From surfaces where the fragment is not cached yet (the list
187
- // page), updateFragment is a no-op — seed the cache instead so
188
- // the saved settings render and a re-opened modal reads them.
189
- const fragmentKey = makeFragmentKey(
190
- FRAGMENT_NAMES.agentDoc,
191
- updatedAgentDoc.id,
192
- );
193
- const updatedFragmentKey = updateFragment(
194
- fragmentKey,
195
- updatedAgentDoc,
196
- null,
197
- false,
198
- updateObservers,
199
- );
200
- if (!updatedFragmentKey) {
201
- addFragmentToCache(fragmentKey, updatedAgentDoc);
202
- updateObservers({ fragmentIds: [fragmentKey] });
203
- }
204
- }
205
-
206
- onCompleted?.(updatedAgentDoc, error, variables);
207
- },
208
- ...rest,
209
- });
210
-
211
- return {
212
- updateAgentDocSettings,
213
- updateObservers,
214
- ...mtnValues,
215
- ...mtnHandlers,
216
- };
217
- }
218
-
219
- /*
220
- * Create an agent doc folder. The server keeps other sessions fresh through
221
- * agentDocFolders query resets; the issuer refetches through onCompleted.
222
- */
223
-
224
- export function useCreateAgentDocFolder(
225
- params: UseMutationParams = {},
226
- openModalPopUp?: OpenModalPopUpFn,
227
- ) {
228
- const [createAgentDocFolder, mtnValues, mtnHandlers, updateObservers] =
229
- useMutation(createAgentDocFolderMtn, {
230
- openModalPopUp,
231
- ...params,
232
- });
233
-
234
- return {
235
- createAgentDocFolder,
236
- updateObservers,
237
- ...mtnValues,
238
- ...mtnHandlers,
239
- };
240
- }
241
-
242
- /*
243
- * Update an agent doc folder (rename / reorder).
244
- */
245
-
246
- export function useUpdateAgentDocFolder(
247
- params: UseMutationParams = {},
248
- openModalPopUp?: OpenModalPopUpFn,
249
- ) {
250
- const [updateAgentDocFolder, mtnValues, mtnHandlers, updateObservers] =
251
- useMutation(updateAgentDocFolderMtn, {
252
- openModalPopUp,
253
- ...params,
254
- });
255
-
256
- return {
257
- updateAgentDocFolder,
258
- updateObservers,
259
- ...mtnValues,
260
- ...mtnHandlers,
261
- };
262
- }
263
-
264
- /*
265
- * Delete an agent doc folder (hard delete; docs inside survive with folderId
266
- * cleared by the server).
267
- */
268
-
269
- export function useDeleteAgentDocFolder(
270
- params: UseMutationParams = {},
271
- openModalPopUp?: OpenModalPopUpFn,
272
- ) {
273
- const [deleteAgentDocFolder, mtnValues, mtnHandlers, updateObservers] =
274
- useMutation(deleteAgentDocFolderMtn, {
275
- openModalPopUp,
276
- ...params,
277
- });
278
-
279
- return {
280
- deleteAgentDocFolder,
281
- updateObservers,
282
- ...mtnValues,
283
- ...mtnHandlers,
284
- };
285
- }
@@ -1,208 +0,0 @@
1
- import {
2
- useQuery,
3
- useReactiveFragment,
4
- useReactiveFragmentMap,
5
- } from '@jsb188/graphql/client';
6
- import { GRID_ITEM_LIST_LIMIT } from '@jsb188/mday/constants/sheet.ts';
7
- import type { GridItemSortEnum } from '@jsb188/mday/types/sheet.d.ts';
8
- import {
9
- FRAGMENT_NAMES,
10
- getFragmentBaseName,
11
- makeFragmentKey,
12
- } from '@jsb188/mday/constants/graphqlReactivity.ts';
13
- import { useMemo } from 'react';
14
- import {
15
- agentDocAccessGrantsQry,
16
- agentDocFoldersQry,
17
- agentDocQry,
18
- agentDocsQry,
19
- } from '../gql/queries/agentDocQueries.ts';
20
- import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
21
-
22
- export type AgentDocsVariables = PaginationArgs & {
23
- organizationId?: string | null;
24
- folderId?: string | null;
25
- sort?: GridItemSortEnum | null;
26
- };
27
-
28
- /*
29
- * Add front-end deleted status to trashed AgentDoc records.
30
- */
31
-
32
- function mapAgentDocDeletedStatus(agentDoc: any) {
33
- if (!agentDoc || agentDoc.__deleted || !agentDoc.deletedAt) {
34
- return agentDoc;
35
- }
36
-
37
- return {
38
- ...agentDoc,
39
- __deleted: true,
40
- };
41
- }
42
-
43
- /*
44
- * Fetch one agent doc by id. No organizationId argument: the server resolves
45
- * the owner org from the agent doc row and evaluates the viewer's access
46
- * against it, so viewers outside the owner org (network orgs, grant holders)
47
- * can load an agent doc shared with them.
48
- */
49
-
50
- export function useAgentDoc(
51
- agentDocId?: string | null,
52
- params: UseQueryParams = {},
53
- ) {
54
- const { data, ...rest } = useQuery(agentDocQry, {
55
- variables: {
56
- agentDocId,
57
- },
58
- ...params,
59
- skip: !agentDocId || !!params.skip,
60
- });
61
-
62
- // IMPORTANT: Keep `|| data?.agentDoc` here -- this prevents an incorrect !agentDoc state and `loading` state mismatch
63
- // It's either that or we have to NOT use useMemo() here, both are valid options.
64
- const queryAgentDoc =
65
- useMemo(() => mapAgentDocDeletedStatus(data?.agentDoc), [data?.agentDoc]) ||
66
- data?.agentDoc;
67
- const agentDoc = useReactiveAgentDocFragment(agentDocId || '', queryAgentDoc);
68
-
69
- return {
70
- agentDoc,
71
- ...rest,
72
- };
73
- }
74
-
75
- /*
76
- * Return whether one useAgentDocs input is the paginated variables object.
77
- */
78
- function isAgentDocsVariables(
79
- value: string | null | undefined | AgentDocsVariables,
80
- ): value is AgentDocsVariables {
81
- return !!value && typeof value === 'object';
82
- }
83
-
84
- /*
85
- * Return GraphQL variables for the paginated agentDocs query. The folderId
86
- * argument is OMITTED (not null) when no folder filter is set: the server
87
- * treats an explicit null as "docs outside every folder", while an absent
88
- * argument means the unfiltered list.
89
- */
90
- function getAgentDocsQueryVariables(
91
- organizationIdOrVariables?: string | null | AgentDocsVariables,
92
- ): AgentDocsVariables {
93
- if (isAgentDocsVariables(organizationIdOrVariables)) {
94
- const { folderId, ...variables } = organizationIdOrVariables;
95
-
96
- return {
97
- ...variables,
98
- after: variables.after ?? true,
99
- cursor: variables.cursor ?? null,
100
- limit: variables.limit ?? GRID_ITEM_LIST_LIMIT,
101
- sort: variables.sort || 'UPDATED_AT_DESC',
102
- ...(folderId ? { folderId } : {}),
103
- };
104
- }
105
-
106
- return {
107
- organizationId: organizationIdOrVariables,
108
- after: true,
109
- cursor: null,
110
- limit: GRID_ITEM_LIST_LIMIT,
111
- sort: 'UPDATED_AT_DESC',
112
- };
113
- }
114
-
115
- /*
116
- * Fetch agent docs for an organization (optionally scoped to one folder).
117
- */
118
-
119
- export function useAgentDocs(
120
- organizationId?: string | null | AgentDocsVariables,
121
- params: UseQueryParams = {},
122
- ) {
123
- const variables = getAgentDocsQueryVariables(organizationId);
124
- const { data, ...rest } = useQuery(agentDocsQry, {
125
- variables,
126
- skip: !variables.organizationId,
127
- ...params,
128
- });
129
- const agentDocs = useReactiveFragmentMap(
130
- data?.agentDocs || null,
131
- getFragmentBaseName(FRAGMENT_NAMES.agentDoc),
132
- );
133
- const agentDocsWithDeletedStatus = useMemo(
134
- () => agentDocs?.map(mapAgentDocDeletedStatus) || agentDocs,
135
- [agentDocs],
136
- );
137
-
138
- return {
139
- agentDocs: agentDocsWithDeletedStatus,
140
- ...rest,
141
- };
142
- }
143
-
144
- /*
145
- * Fetch an organization's agent doc folders (single-level; the server keeps
146
- * this list fresh through agentDocFolders query resets over the org room).
147
- */
148
-
149
- export function useAgentDocFolders(
150
- organizationId?: string | null,
151
- params: UseQueryParams = {},
152
- ) {
153
- const { data, ...rest } = useQuery(agentDocFoldersQry, {
154
- variables: {
155
- organizationId,
156
- },
157
- ...params,
158
- skip: !organizationId || !!params.skip,
159
- });
160
-
161
- return {
162
- agentDocFolders: data?.agentDocFolders || null,
163
- ...rest,
164
- };
165
- }
166
-
167
- /*
168
- * Fetch one agent doc's access grants list (owner-org members only), used by
169
- * the access settings screen alongside the AgentDoc fragment's base policy.
170
- */
171
-
172
- export function useAgentDocAccessGrants(
173
- organizationId?: string | null,
174
- agentDocId?: string | null,
175
- params: UseQueryParams = {},
176
- ) {
177
- const { data, ...rest } = useQuery(agentDocAccessGrantsQry, {
178
- variables: {
179
- organizationId,
180
- agentDocId,
181
- },
182
- ...params,
183
- skip: !organizationId || !agentDocId || !!params.skip,
184
- });
185
-
186
- return {
187
- agentDocAccessGrants: data?.agentDocAccessGrants || null,
188
- ...rest,
189
- };
190
- }
191
-
192
- /*
193
- * Get reactive AgentDoc fragment.
194
- */
195
-
196
- export function useReactiveAgentDocFragment(
197
- agentDocId: string,
198
- currentData?: any,
199
- queryCount?: number,
200
- ) {
201
- const agentDoc = useReactiveFragment(
202
- currentData,
203
- agentDocId ? [makeFragmentKey(FRAGMENT_NAMES.agentDoc, agentDocId)] : [],
204
- queryCount,
205
- );
206
-
207
- return useMemo(() => mapAgentDocDeletedStatus(agentDoc), [agentDoc]);
208
- }
File without changes