@jsb188/graphql 1.1.10 → 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 (176) hide show
  1. package/audience.d.ts +343 -0
  2. package/cache/config.ts +98 -50
  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 +1017 -127
  8. package/cache/index.ts +1256 -1269
  9. package/cache/optimistic-ui-runtime.ts +46 -0
  10. package/cache/optimistic-ui.ts +401 -0
  11. package/cache/persist.ts +800 -0
  12. package/cache/store.ts +395 -0
  13. package/cache/value.helpers.ts +17 -0
  14. package/client/draft-persistence-indexed-db.ts +413 -0
  15. package/client/draft-persistence.ts +152 -0
  16. package/client/index.ts +3 -0
  17. package/client/request.helpers.ts +14 -0
  18. package/client/request.ts +870 -164
  19. package/deno.lock +187 -0
  20. package/deno.test.json +10 -4
  21. package/gql/eagerQueryMap.ts +12 -0
  22. package/gql/fragments/accountAuthFragments.ts +5 -0
  23. package/gql/fragments/accountFragments.ts +0 -3
  24. package/gql/fragments/accountSessionFragments.ts +16 -0
  25. package/gql/fragments/agentMemoryFragments.ts +23 -0
  26. package/gql/fragments/agentNoteFragments.ts +150 -0
  27. package/gql/fragments/aiChatFragments.ts +42 -0
  28. package/gql/fragments/audienceFragments.ts +141 -0
  29. package/gql/fragments/campaignFragments.ts +566 -0
  30. package/gql/fragments/dataTableFragments.ts +50 -192
  31. package/gql/fragments/emailFragments.ts +32 -17
  32. package/gql/fragments/fieldDocFragments.ts +264 -0
  33. package/gql/fragments/inboundContactFragments.ts +2 -0
  34. package/gql/fragments/logFragments.ts +101 -69
  35. package/gql/fragments/organizationFragments.ts +53 -5
  36. package/gql/fragments/qrCodeFragments.ts +29 -0
  37. package/gql/fragments/scheduleFragments.ts +667 -0
  38. package/gql/fragments/sheetFragments.ts +304 -63
  39. package/gql/fragments/storageFragments.ts +45 -0
  40. package/gql/fragments/workflowFragments.ts +41 -5
  41. package/gql/mutations/accountMutations.ts +0 -2
  42. package/gql/mutations/agentMemoryMutations.ts +68 -0
  43. package/gql/mutations/agentNoteMutations.ts +62 -0
  44. package/gql/mutations/aiChatMutations.ts +49 -4
  45. package/gql/mutations/audienceMutations.ts +71 -0
  46. package/gql/mutations/authMutations.ts +203 -18
  47. package/gql/mutations/billingMutations.ts +17 -27
  48. package/gql/mutations/campaignMutations.ts +258 -0
  49. package/gql/mutations/contactMutations.ts +23 -0
  50. package/gql/mutations/dataTableMutations.ts +19 -54
  51. package/gql/mutations/fieldDocMutations.ts +173 -0
  52. package/gql/mutations/index.ts +10 -2
  53. package/gql/mutations/logMutations.ts +6 -29
  54. package/gql/mutations/organizationMutations.ts +19 -4
  55. package/gql/mutations/qrCodeMutations.ts +20 -0
  56. package/gql/mutations/scheduleMutations.ts +1121 -0
  57. package/gql/mutations/sheetMutations.ts +221 -60
  58. package/gql/mutations/storageMutations.ts +19 -0
  59. package/gql/mutations/workflowMutations.ts +60 -0
  60. package/gql/queries/agentMemoryQueries.ts +28 -0
  61. package/gql/queries/agentNoteQueries.ts +89 -0
  62. package/gql/queries/aiChatQueries.ts +70 -2
  63. package/gql/queries/audienceQueries.ts +128 -0
  64. package/gql/queries/authQueries.ts +47 -0
  65. package/gql/queries/billingQueries.ts +118 -6
  66. package/gql/queries/campaignQueries.ts +236 -0
  67. package/gql/queries/dataTableQueries.ts +61 -13
  68. package/gql/queries/emailQueries.ts +26 -17
  69. package/gql/queries/emailReplyReportQueries.ts +76 -0
  70. package/gql/queries/fieldDocQueries.ts +166 -0
  71. package/gql/queries/inboundContactQueries.ts +4 -0
  72. package/gql/queries/index.ts +10 -2
  73. package/gql/queries/logQueries.ts +68 -30
  74. package/gql/queries/organizationQueries.ts +65 -1
  75. package/gql/queries/qrCodeQueries.ts +20 -0
  76. package/gql/queries/scheduleQueries.ts +691 -0
  77. package/gql/queries/sheetQueries.ts +244 -26
  78. package/gql/queries/storageQueries.ts +38 -0
  79. package/gql/queries/workflowQueries.ts +77 -2
  80. package/hooks/index.helpers.test.ts +50 -0
  81. package/hooks/index.helpers.ts +52 -0
  82. package/hooks/index.ts +2254 -982
  83. package/hooks/use-account-mtn.ts +76 -81
  84. package/hooks/use-agentMemory-mtn.ts +71 -0
  85. package/hooks/use-agentMemory-qry.ts +56 -0
  86. package/hooks/use-agentNote-mtn.ts +82 -0
  87. package/hooks/use-agentNote-qry.ts +190 -0
  88. package/hooks/use-agentNote-recovery.helpers.test.ts +68 -0
  89. package/hooks/use-agentNote-recovery.helpers.ts +58 -0
  90. package/hooks/use-agentNote-recovery.ts +72 -0
  91. package/hooks/use-aiChat-mtn.ts +220 -141
  92. package/hooks/use-aiChat-qry.helpers.test.ts +63 -0
  93. package/hooks/use-aiChat-qry.helpers.ts +124 -0
  94. package/hooks/use-aiChat-qry.ts +341 -237
  95. package/hooks/use-aiChat-stream-mtn.ts +14 -0
  96. package/hooks/use-app-qry.ts +12 -9
  97. package/hooks/use-audience-mtn.ts +194 -0
  98. package/hooks/use-audience-qry.helpers.test.ts +80 -0
  99. package/hooks/use-audience-qry.helpers.ts +63 -0
  100. package/hooks/use-audience-qry.ts +330 -0
  101. package/hooks/use-auth-mtn.ts +435 -252
  102. package/hooks/use-auth-qry.ts +51 -0
  103. package/hooks/use-billing-mtn.ts +31 -0
  104. package/hooks/use-billing-qry.ts +76 -0
  105. package/hooks/use-campaign-generation-recovery.ts +53 -0
  106. package/hooks/use-campaign-mtn.ts +436 -0
  107. package/hooks/use-campaign-qry.helpers.ts +40 -0
  108. package/hooks/use-campaign-qry.ts +834 -0
  109. package/hooks/use-dataTable-mtn.ts +37 -46
  110. package/hooks/use-dataTable-qry.ts +102 -128
  111. package/hooks/use-email-qry.helpers.ts +37 -0
  112. package/hooks/use-email-qry.ts +56 -86
  113. package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
  114. package/hooks/use-fieldDoc-mtn.ts +262 -0
  115. package/hooks/use-fieldDoc-qry.helpers.test.ts +65 -0
  116. package/hooks/use-fieldDoc-qry.helpers.ts +49 -0
  117. package/hooks/use-fieldDoc-qry.ts +212 -0
  118. package/hooks/use-inboundContact-mtn.ts +19 -16
  119. package/hooks/use-inboundContact-qry.ts +62 -56
  120. package/hooks/use-integration-mtn.ts +56 -38
  121. package/hooks/use-integration-qry.ts +24 -9
  122. package/hooks/use-log-mtn.ts +88 -59
  123. package/hooks/use-log-qry.ts +150 -73
  124. package/hooks/use-organization-mtn.ts +334 -277
  125. package/hooks/use-organization-qry.ts +155 -129
  126. package/hooks/use-publicFormEmail-mtn.ts +27 -0
  127. package/hooks/use-qrCode-mtn.ts +40 -0
  128. package/hooks/use-qrCode-qry.ts +78 -0
  129. package/hooks/use-schedule-mtn.ts +589 -0
  130. package/hooks/use-schedule-qry.ts +738 -0
  131. package/hooks/use-schedule-reactive.ts +486 -0
  132. package/hooks/use-sheet-mtn.ts +157 -79
  133. package/hooks/use-sheet-qry.ts +221 -92
  134. package/hooks/use-storage-mtn.ts +81 -41
  135. package/hooks/use-storage-qry.ts +128 -14
  136. package/hooks/use-workflow-mtn.ts +72 -0
  137. package/hooks/use-workflow-qry.ts +184 -47
  138. package/libs/ai-chat-outgoing.helpers.ts +153 -0
  139. package/libs/ai-chat-outgoing.ts +11 -0
  140. package/libs/ai-chat-outgoing.types.ts +25 -0
  141. package/libs/ai-chat-run-realtime.ts +20 -0
  142. package/libs/ai-chat-submission-realtime.ts +150 -0
  143. package/libs/fragment-realtime-sequence.ts +55 -0
  144. package/libs/fragment-recovery.test.ts +326 -0
  145. package/libs/fragment-recovery.ts +325 -0
  146. package/libs/open-sheet.ts +138 -0
  147. package/libs/orchestrator-realtime.helpers.test.ts +229 -0
  148. package/libs/orchestrator-realtime.helpers.ts +317 -0
  149. package/libs/orchestrator-realtime.ts +433 -0
  150. package/libs/request-cache-regression.test.ts +122 -0
  151. package/libs/request-managed-session.test.ts +574 -0
  152. package/libs/request-no-store.test.ts +419 -0
  153. package/libs/sheet-command-batch.ts +44 -0
  154. package/libs/sheet-view-realtime-router.test.ts +214 -0
  155. package/libs/sheet-view-realtime-router.ts +99 -0
  156. package/libs/sse-ticket.test.ts +26 -0
  157. package/loaders/campaign.test.ts +186 -0
  158. package/loaders/campaign.ts +110 -0
  159. package/loaders/emailPreference.ts +75 -0
  160. package/loaders/rest.ts +12 -0
  161. package/package.json +119 -71
  162. package/schedule.d.ts +1790 -0
  163. package/sse.helpers.ts +19 -0
  164. package/sse.ts +70 -106
  165. package/tests/agent-note-detail-cache.test.ts +120 -0
  166. package/tests/agent-note-search.test.ts +444 -0
  167. package/tsconfig.json +11 -10
  168. package/types.d.ts +77 -26
  169. package/utils.ts +78 -49
  170. package/gql/fragments/billingFragments.ts +0 -25
  171. package/gql/fragments/productFragments.ts +0 -39
  172. package/gql/fragments/reportFragments.ts +0 -90
  173. package/gql/queries/productQueries.ts +0 -31
  174. package/gql/queries/reportQueries.ts +0 -134
  175. package/hooks/use-product-qry.ts +0 -67
  176. package/hooks/use-report-qry.ts +0 -153
@@ -1,14 +1,20 @@
1
1
  import type { UseMutationParams } from '@jsb188/graphql/types.d';
2
- import { OpenModalPopUpFn } from '@jsb188/react/states';
2
+ import { FRAGMENT_NAMES, makeFragmentKey } from '@jsb188/mday/constants/graphqlReactivity.ts';
3
+ import type { OpenModalPopUpFn } from '@jsb188/react/states';
4
+ import { updateFragment } from '../cache/index.ts';
3
5
  import {
4
- clearSheetCellMtn,
5
6
  createSheetMtn,
6
- deleteSheetRangeMtn,
7
- deleteSheetRegionMtn,
8
- editSheetCellsMtn,
7
+ createSheetTabMtn,
8
+ deleteSheetMtn,
9
+ deleteSheetTabMtn,
10
+ editSheetCommandBatchMtn,
11
+ exportSheetToFileMtn,
12
+ importSheetFromFileMtn,
13
+ reorderSheetTabsMtn,
14
+ setSheetTabHiddenMtn,
15
+ updateSheetAccessMtn,
9
16
  updateSheetMtn,
10
- upsertSheetDataTableRegionMtn,
11
- upsertSheetRangeMtn,
17
+ updateSheetTabMtn,
12
18
  } from '../gql/mutations/sheetMutations.ts';
13
19
  import { useMutation } from './index.ts';
14
20
 
@@ -17,13 +23,10 @@ import { useMutation } from './index.ts';
17
23
  */
18
24
 
19
25
  export function useCreateSheet(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
20
- const [createSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(
21
- createSheetMtn,
22
- {
23
- openModalPopUp,
24
- ...params,
25
- },
26
- );
26
+ const [createSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(createSheetMtn, {
27
+ openModalPopUp,
28
+ ...params,
29
+ });
27
30
 
28
31
  return {
29
32
  createSheet,
@@ -38,13 +41,10 @@ export function useCreateSheet(params: UseMutationParams = {}, openModalPopUp?:
38
41
  */
39
42
 
40
43
  export function useUpdateSheet(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
41
- const [updateSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(
42
- updateSheetMtn,
43
- {
44
- openModalPopUp,
45
- ...params,
46
- },
47
- );
44
+ const [updateSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(updateSheetMtn, {
45
+ openModalPopUp,
46
+ ...params,
47
+ });
48
48
 
49
49
  return {
50
50
  updateSheet,
@@ -55,20 +55,30 @@ export function useUpdateSheet(params: UseMutationParams = {}, openModalPopUp?:
55
55
  }
56
56
 
57
57
  /*
58
- * Edit multiple sheet cells.
58
+ * Update a sheet's access settings.
59
59
  */
60
60
 
61
- export function useEditSheetCells(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
62
- const [editSheetCells, mtnValues, mtnHandlers, updateObservers] = useMutation(
63
- editSheetCellsMtn,
64
- {
65
- openModalPopUp,
66
- ...params,
61
+ export function useUpdateSheetAccess(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
62
+ const { onCompleted, ...rest } = params;
63
+
64
+ const [updateSheetAccess, mtnValues, mtnHandlers, updateObservers] = useMutation(updateSheetAccessMtn, {
65
+ openModalPopUp,
66
+ onCompleted: (data, error, variables) => {
67
+ const updatedSheet = data?.updateSheetAccess;
68
+
69
+ if (updatedSheet?.id) {
70
+ // The origin socket is excluded from the server's realtime emit,
71
+ // so the mutation issuer refreshes its own cached fragment here
72
+ updateFragment(makeFragmentKey(FRAGMENT_NAMES.sheet, updatedSheet.id), updatedSheet, null, false, updateObservers);
73
+ }
74
+
75
+ onCompleted?.(updatedSheet, error, variables);
67
76
  },
68
- );
77
+ ...rest,
78
+ });
69
79
 
70
80
  return {
71
- editSheetCells,
81
+ updateSheetAccess,
72
82
  updateObservers,
73
83
  ...mtnValues,
74
84
  ...mtnHandlers,
@@ -76,20 +86,26 @@ export function useEditSheetCells(params: UseMutationParams = {}, openModalPopUp
76
86
  }
77
87
 
78
88
  /*
79
- * Clear one sheet cell.
89
+ * Delete a sheet.
80
90
  */
81
91
 
82
- export function useClearSheetCell(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
83
- const [clearSheetCell, mtnValues, mtnHandlers, updateObservers] = useMutation(
84
- clearSheetCellMtn,
85
- {
86
- openModalPopUp,
87
- ...params,
92
+ export function useDeleteSheet(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
93
+ const { onCompleted, ...rest } = params;
94
+ const [deleteSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(deleteSheetMtn, {
95
+ openModalPopUp,
96
+ onCompleted: (data, error, variables) => {
97
+ const deletedSheetId = data?.deleteSheet;
98
+ if (deletedSheetId) {
99
+ updateFragment(makeFragmentKey(FRAGMENT_NAMES.sheet, deletedSheetId), { __deleted: true }, null, false, updateObservers);
100
+ }
101
+
102
+ onCompleted?.(data, error, variables);
88
103
  },
89
- );
104
+ ...rest,
105
+ });
90
106
 
91
107
  return {
92
- clearSheetCell,
108
+ deleteSheet,
93
109
  updateObservers,
94
110
  ...mtnValues,
95
111
  ...mtnHandlers,
@@ -97,20 +113,17 @@ export function useClearSheetCell(params: UseMutationParams = {}, openModalPopUp
97
113
  }
98
114
 
99
115
  /*
100
- * Create or update one sheet range.
116
+ * Create a sheet tab.
101
117
  */
102
118
 
103
- export function useUpsertSheetRange(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
104
- const [upsertSheetRange, mtnValues, mtnHandlers, updateObservers] = useMutation(
105
- upsertSheetRangeMtn,
106
- {
107
- openModalPopUp,
108
- ...params,
109
- },
110
- );
119
+ export function useCreateSheetTab(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
120
+ const [createSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(createSheetTabMtn, {
121
+ openModalPopUp,
122
+ ...params,
123
+ });
111
124
 
112
125
  return {
113
- upsertSheetRange,
126
+ createSheetTab,
114
127
  updateObservers,
115
128
  ...mtnValues,
116
129
  ...mtnHandlers,
@@ -118,20 +131,17 @@ export function useUpsertSheetRange(params: UseMutationParams = {}, openModalPop
118
131
  }
119
132
 
120
133
  /*
121
- * Delete one sheet range.
134
+ * Import a spreadsheet file into a new or existing sheet.
122
135
  */
123
136
 
124
- export function useDeleteSheetRange(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
125
- const [deleteSheetRange, mtnValues, mtnHandlers, updateObservers] = useMutation(
126
- deleteSheetRangeMtn,
127
- {
128
- openModalPopUp,
129
- ...params,
130
- },
131
- );
137
+ export function useImportSheetFromFile(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
138
+ const [importSheetFromFile, mtnValues, mtnHandlers, updateObservers] = useMutation(importSheetFromFileMtn, {
139
+ openModalPopUp,
140
+ ...params,
141
+ });
132
142
 
133
143
  return {
134
- deleteSheetRange,
144
+ importSheetFromFile,
135
145
  updateObservers,
136
146
  ...mtnValues,
137
147
  ...mtnHandlers,
@@ -139,20 +149,18 @@ export function useDeleteSheetRange(params: UseMutationParams = {}, openModalPop
139
149
  }
140
150
 
141
151
  /*
142
- * Create or update one Data Table-backed sheet region.
152
+ * Export a spreadsheet to a downloadable file (CSV/TSV/PDF for one tab, XLSX
153
+ * for the whole workbook).
143
154
  */
144
155
 
145
- export function useUpsertSheetDataTableRegion(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
146
- const [upsertSheetDataTableRegion, mtnValues, mtnHandlers, updateObservers] = useMutation(
147
- upsertSheetDataTableRegionMtn,
148
- {
149
- openModalPopUp,
150
- ...params,
151
- },
152
- );
156
+ export function useExportSheetToFile(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
157
+ const [exportSheetToFile, mtnValues, mtnHandlers, updateObservers] = useMutation(exportSheetToFileMtn, {
158
+ openModalPopUp,
159
+ ...params,
160
+ });
153
161
 
154
162
  return {
155
- upsertSheetDataTableRegion,
163
+ exportSheetToFile,
156
164
  updateObservers,
157
165
  ...mtnValues,
158
166
  ...mtnHandlers,
@@ -160,20 +168,90 @@ export function useUpsertSheetDataTableRegion(params: UseMutationParams = {}, op
160
168
  }
161
169
 
162
170
  /*
163
- * Delete one sheet region.
171
+ * Update a sheet tab.
164
172
  */
165
173
 
166
- export function useDeleteSheetRegion(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
167
- const [deleteSheetRegion, mtnValues, mtnHandlers, updateObservers] = useMutation(
168
- deleteSheetRegionMtn,
169
- {
170
- openModalPopUp,
171
- ...params,
172
- },
173
- );
174
+ export function useUpdateSheetTab(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
175
+ const [updateSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(updateSheetTabMtn, {
176
+ openModalPopUp,
177
+ ...params,
178
+ });
179
+
180
+ return {
181
+ updateSheetTab,
182
+ updateObservers,
183
+ ...mtnValues,
184
+ ...mtnHandlers,
185
+ };
186
+ }
187
+
188
+ /*
189
+ * Set whether a sheet tab is hidden from the collapsed tab strip.
190
+ */
191
+ export function useSetSheetTabHidden(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
192
+ const [setSheetTabHidden, mtnValues, mtnHandlers, updateObservers] = useMutation(setSheetTabHiddenMtn, {
193
+ openModalPopUp,
194
+ ...params,
195
+ });
196
+
197
+ return {
198
+ setSheetTabHidden,
199
+ updateObservers,
200
+ ...mtnValues,
201
+ ...mtnHandlers,
202
+ };
203
+ }
204
+
205
+ /*
206
+ * Reorder sheet tabs.
207
+ */
208
+
209
+ export function useReorderSheetTabs(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
210
+ const [reorderSheetTabs, mtnValues, mtnHandlers, updateObservers] = useMutation(reorderSheetTabsMtn, {
211
+ openModalPopUp,
212
+ ...params,
213
+ });
214
+
215
+ return {
216
+ reorderSheetTabs,
217
+ updateObservers,
218
+ ...mtnValues,
219
+ ...mtnHandlers,
220
+ };
221
+ }
222
+
223
+ /*
224
+ * Delete a sheet tab.
225
+ */
226
+
227
+ export function useDeleteSheetTab(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
228
+ const [deleteSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(deleteSheetTabMtn, {
229
+ openModalPopUp,
230
+ ...params,
231
+ });
232
+
233
+ return {
234
+ deleteSheetTab,
235
+ updateObservers,
236
+ ...mtnValues,
237
+ ...mtnHandlers,
238
+ };
239
+ }
240
+
241
+ /*
242
+ * Send one sealed Sheet command envelope. The mutation is always no-store:
243
+ * its authoritative patches belong to the client's tab stores, never to the
244
+ * normalized fragment cache.
245
+ */
246
+ export function useEditSheetCommandBatch(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
247
+ const [editSheetCommandBatch, mtnValues, mtnHandlers, updateObservers] = useMutation(editSheetCommandBatchMtn, {
248
+ openModalPopUp,
249
+ ...params,
250
+ cachePolicy: 'no-store',
251
+ });
174
252
 
175
253
  return {
176
- deleteSheetRegion,
254
+ editSheetCommandBatch,
177
255
  updateObservers,
178
256
  ...mtnValues,
179
257
  ...mtnHandlers,