@jsb188/graphql 1.1.10 → 1.1.11

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 (116) hide show
  1. package/cache/config.ts +64 -50
  2. package/cache/index.test.ts +671 -109
  3. package/cache/index.ts +1700 -1240
  4. package/cache/persist.ts +721 -0
  5. package/cache/store.ts +437 -0
  6. package/client/data-table-realtime-subscriptions.test.ts +740 -0
  7. package/client/data-table-realtime-subscriptions.ts +955 -0
  8. package/client/data-table-realtime.test.ts +792 -0
  9. package/client/data-table-realtime.ts +1218 -0
  10. package/client/fragment-realtime-sequence.ts +52 -0
  11. package/client/index.ts +2 -0
  12. package/client/open-sheet.ts +137 -0
  13. package/client/request-managed-session.test.ts +574 -0
  14. package/client/request-no-store.test.ts +157 -0
  15. package/client/request.ts +954 -163
  16. package/client/sse-ticket.test.ts +26 -0
  17. package/deno.lock +170 -0
  18. package/deno.test.json +8 -4
  19. package/drafts/index.ts +149 -0
  20. package/drafts/store.ts +397 -0
  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/agentDocFragments.ts +46 -0
  26. package/gql/fragments/agentMemoryFragments.ts +19 -0
  27. package/gql/fragments/aiChatFragments.ts +16 -0
  28. package/gql/fragments/billingFragments.ts +0 -11
  29. package/gql/fragments/campaignFragments.ts +277 -0
  30. package/gql/fragments/dataTableFragments.ts +18 -128
  31. package/gql/fragments/emailFragments.ts +19 -9
  32. package/gql/fragments/fieldDocFragments.ts +82 -0
  33. package/gql/fragments/logFragments.ts +20 -79
  34. package/gql/fragments/organizationFragments.ts +43 -5
  35. package/gql/fragments/scheduleFragments.ts +155 -0
  36. package/gql/fragments/sheetFragments.ts +552 -22
  37. package/gql/fragments/storageFragments.ts +21 -0
  38. package/gql/fragments/workflowFragments.ts +28 -4
  39. package/gql/mutations/accountMutations.ts +0 -2
  40. package/gql/mutations/agentDocMutations.ts +177 -0
  41. package/gql/mutations/agentMemoryMutations.ts +36 -0
  42. package/gql/mutations/aiChatMutations.ts +17 -4
  43. package/gql/mutations/authMutations.ts +158 -17
  44. package/gql/mutations/campaignMutations.ts +215 -0
  45. package/gql/mutations/dataTableMutations.ts +48 -26
  46. package/gql/mutations/fieldDocMutations.ts +24 -0
  47. package/gql/mutations/index.ts +6 -1
  48. package/gql/mutations/logMutations.ts +6 -29
  49. package/gql/mutations/organizationMutations.ts +13 -4
  50. package/gql/mutations/scheduleMutations.ts +423 -0
  51. package/gql/mutations/sheetMutations.ts +273 -56
  52. package/gql/mutations/storageMutations.ts +20 -0
  53. package/gql/mutations/workflowMutations.ts +42 -0
  54. package/gql/queries/agentDocQueries.ts +120 -0
  55. package/gql/queries/agentMemoryQueries.ts +22 -0
  56. package/gql/queries/aiChatQueries.ts +18 -2
  57. package/gql/queries/authQueries.ts +41 -0
  58. package/gql/queries/billingQueries.ts +23 -0
  59. package/gql/queries/campaignQueries.ts +127 -0
  60. package/gql/queries/dataTableQueries.ts +100 -11
  61. package/gql/queries/emailQueries.ts +55 -3
  62. package/gql/queries/fieldDocQueries.ts +158 -0
  63. package/gql/queries/index.ts +8 -2
  64. package/gql/queries/logQueries.ts +11 -28
  65. package/gql/queries/organizationQueries.ts +52 -1
  66. package/gql/queries/scheduleQueries.ts +315 -0
  67. package/gql/queries/sheetQueries.ts +336 -25
  68. package/gql/queries/storageQueries.ts +38 -0
  69. package/gql/queries/workflowQueries.ts +72 -3
  70. package/hooks/index.ts +2065 -971
  71. package/hooks/use-account-mtn.ts +76 -81
  72. package/hooks/use-agentDoc-mtn.ts +285 -0
  73. package/hooks/use-agentDoc-qry.ts +208 -0
  74. package/hooks/use-agentMemory-mtn.ts +73 -0
  75. package/hooks/use-agentMemory-qry.ts +44 -0
  76. package/hooks/use-aiChat-mtn.ts +232 -137
  77. package/hooks/use-aiChat-qry.ts +480 -222
  78. package/hooks/use-app-qry.ts +12 -9
  79. package/hooks/use-auth-mtn.ts +406 -252
  80. package/hooks/use-auth-qry.ts +51 -0
  81. package/hooks/use-campaign-mtn.ts +377 -0
  82. package/hooks/use-campaign-qry.ts +257 -0
  83. package/hooks/use-dataTable-mtn.ts +116 -33
  84. package/hooks/use-dataTable-qry.ts +859 -35
  85. package/hooks/use-email-qry.ts +194 -79
  86. package/hooks/use-fieldDoc-mtn.ts +50 -0
  87. package/hooks/use-fieldDoc-qry.ts +180 -0
  88. package/hooks/use-inboundContact-mtn.ts +19 -16
  89. package/hooks/use-inboundContact-qry.ts +63 -55
  90. package/hooks/use-integration-mtn.ts +56 -38
  91. package/hooks/use-integration-qry.ts +24 -9
  92. package/hooks/use-log-mtn.ts +72 -56
  93. package/hooks/use-log-qry.ts +93 -69
  94. package/hooks/use-organization-mtn.ts +334 -277
  95. package/hooks/use-organization-qry.ts +199 -129
  96. package/hooks/use-schedule-mtn.ts +416 -0
  97. package/hooks/use-schedule-qry.ts +157 -0
  98. package/hooks/use-sheet-mtn.ts +233 -47
  99. package/hooks/use-sheet-qry.ts +353 -70
  100. package/hooks/use-storage-mtn.ts +81 -41
  101. package/hooks/use-storage-qry.ts +104 -13
  102. package/hooks/use-workflow-mtn.ts +55 -0
  103. package/hooks/use-workflow-qry.ts +206 -48
  104. package/loaders/campaign.ts +137 -0
  105. package/package.json +94 -71
  106. package/sse.ts +157 -104
  107. package/tsconfig.json +11 -10
  108. package/types.d.ts +60 -30
  109. package/utils.ts +78 -49
  110. package/gql/fragments/productFragments.ts +0 -39
  111. package/gql/fragments/reportFragments.ts +0 -90
  112. package/gql/mutations/billingMutations.ts +0 -34
  113. package/gql/queries/productQueries.ts +0 -31
  114. package/gql/queries/reportQueries.ts +0 -134
  115. package/hooks/use-product-qry.ts +0 -67
  116. package/hooks/use-report-qry.ts +0 -153
@@ -1,14 +1,24 @@
1
1
  import type { UseMutationParams } from '@jsb188/graphql/types.d';
2
- import { OpenModalPopUpFn } from '@jsb188/react/states';
2
+ import type { OpenModalPopUpFn } from '@jsb188/react/states';
3
+ import {
4
+ FRAGMENT_NAMES,
5
+ makeFragmentKey,
6
+ } from '@jsb188/mday/constants/graphqlReactivity.ts';
7
+ import { updateFragment } from '../cache/index.ts';
3
8
  import {
4
- clearSheetCellMtn,
5
9
  createSheetMtn,
6
- deleteSheetRangeMtn,
7
- deleteSheetRegionMtn,
8
- editSheetCellsMtn,
10
+ createSheetTabMtn,
11
+ deleteSheetMtn,
12
+ deleteSheetTabMtn,
13
+ editSheetCommandBatchMtn,
14
+ editSheetRegionCommandMtn,
15
+ editSheetStructureCommandMtn,
16
+ exportSheetToFileMtn,
17
+ importSheetFromFileMtn,
18
+ reorderSheetTabsMtn,
19
+ updateSheetAccessMtn,
9
20
  updateSheetMtn,
10
- upsertSheetDataTableRegionMtn,
11
- upsertSheetRangeMtn,
21
+ updateSheetTabMtn,
12
22
  } from '../gql/mutations/sheetMutations.ts';
13
23
  import { useMutation } from './index.ts';
14
24
 
@@ -16,7 +26,10 @@ import { useMutation } from './index.ts';
16
26
  * Create a sheet.
17
27
  */
18
28
 
19
- export function useCreateSheet(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
29
+ export function useCreateSheet(
30
+ params: UseMutationParams = {},
31
+ openModalPopUp?: OpenModalPopUpFn,
32
+ ) {
20
33
  const [createSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(
21
34
  createSheetMtn,
22
35
  {
@@ -37,7 +50,10 @@ export function useCreateSheet(params: UseMutationParams = {}, openModalPopUp?:
37
50
  * Update a sheet.
38
51
  */
39
52
 
40
- export function useUpdateSheet(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
53
+ export function useUpdateSheet(
54
+ params: UseMutationParams = {},
55
+ openModalPopUp?: OpenModalPopUpFn,
56
+ ) {
41
57
  const [updateSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(
42
58
  updateSheetMtn,
43
59
  {
@@ -55,20 +71,79 @@ export function useUpdateSheet(params: UseMutationParams = {}, openModalPopUp?:
55
71
  }
56
72
 
57
73
  /*
58
- * Edit multiple sheet cells.
74
+ * Update a sheet's access settings.
59
75
  */
60
76
 
61
- export function useEditSheetCells(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
62
- const [editSheetCells, mtnValues, mtnHandlers, updateObservers] = useMutation(
63
- editSheetCellsMtn,
77
+ export function useUpdateSheetAccess(
78
+ params: UseMutationParams = {},
79
+ openModalPopUp?: OpenModalPopUpFn,
80
+ ) {
81
+ const { onCompleted, ...rest } = params;
82
+
83
+ const [updateSheetAccess, mtnValues, mtnHandlers, updateObservers] =
84
+ useMutation(updateSheetAccessMtn, {
85
+ openModalPopUp,
86
+ onCompleted: (data, error, variables) => {
87
+ const updatedSheet = data?.updateSheetAccess;
88
+
89
+ if (updatedSheet?.id) {
90
+ // The origin socket is excluded from the server's realtime emit,
91
+ // so the mutation issuer refreshes its own cached fragment here
92
+ updateFragment(
93
+ makeFragmentKey(FRAGMENT_NAMES.sheet, updatedSheet.id),
94
+ updatedSheet,
95
+ null,
96
+ false,
97
+ updateObservers,
98
+ );
99
+ }
100
+
101
+ onCompleted?.(updatedSheet, error, variables);
102
+ },
103
+ ...rest,
104
+ });
105
+
106
+ return {
107
+ updateSheetAccess,
108
+ updateObservers,
109
+ ...mtnValues,
110
+ ...mtnHandlers,
111
+ };
112
+ }
113
+
114
+ /*
115
+ * Delete a sheet.
116
+ */
117
+
118
+ export function useDeleteSheet(
119
+ params: UseMutationParams = {},
120
+ openModalPopUp?: OpenModalPopUpFn,
121
+ ) {
122
+ const { onCompleted, ...rest } = params;
123
+ const [deleteSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(
124
+ deleteSheetMtn,
64
125
  {
65
126
  openModalPopUp,
66
- ...params,
127
+ onCompleted: (data, error, variables) => {
128
+ const deletedSheetId = data?.deleteSheet;
129
+ if (deletedSheetId) {
130
+ updateFragment(
131
+ makeFragmentKey(FRAGMENT_NAMES.sheet, deletedSheetId),
132
+ { __deleted: true },
133
+ null,
134
+ false,
135
+ updateObservers,
136
+ );
137
+ }
138
+
139
+ onCompleted?.(data, error, variables);
140
+ },
141
+ ...rest,
67
142
  },
68
143
  );
69
144
 
70
145
  return {
71
- editSheetCells,
146
+ deleteSheet,
72
147
  updateObservers,
73
148
  ...mtnValues,
74
149
  ...mtnHandlers,
@@ -76,12 +151,15 @@ export function useEditSheetCells(params: UseMutationParams = {}, openModalPopUp
76
151
  }
77
152
 
78
153
  /*
79
- * Clear one sheet cell.
154
+ * Create a sheet tab.
80
155
  */
81
156
 
82
- export function useClearSheetCell(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
83
- const [clearSheetCell, mtnValues, mtnHandlers, updateObservers] = useMutation(
84
- clearSheetCellMtn,
157
+ export function useCreateSheetTab(
158
+ params: UseMutationParams = {},
159
+ openModalPopUp?: OpenModalPopUpFn,
160
+ ) {
161
+ const [createSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(
162
+ createSheetTabMtn,
85
163
  {
86
164
  openModalPopUp,
87
165
  ...params,
@@ -89,7 +167,7 @@ export function useClearSheetCell(params: UseMutationParams = {}, openModalPopUp
89
167
  );
90
168
 
91
169
  return {
92
- clearSheetCell,
170
+ createSheetTab,
93
171
  updateObservers,
94
172
  ...mtnValues,
95
173
  ...mtnHandlers,
@@ -97,20 +175,21 @@ export function useClearSheetCell(params: UseMutationParams = {}, openModalPopUp
97
175
  }
98
176
 
99
177
  /*
100
- * Create or update one sheet range.
178
+ * Import a spreadsheet file into a new or existing sheet.
101
179
  */
102
180
 
103
- export function useUpsertSheetRange(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
104
- const [upsertSheetRange, mtnValues, mtnHandlers, updateObservers] = useMutation(
105
- upsertSheetRangeMtn,
106
- {
181
+ export function useImportSheetFromFile(
182
+ params: UseMutationParams = {},
183
+ openModalPopUp?: OpenModalPopUpFn,
184
+ ) {
185
+ const [importSheetFromFile, mtnValues, mtnHandlers, updateObservers] =
186
+ useMutation(importSheetFromFileMtn, {
107
187
  openModalPopUp,
108
188
  ...params,
109
- },
110
- );
189
+ });
111
190
 
112
191
  return {
113
- upsertSheetRange,
192
+ importSheetFromFile,
114
193
  updateObservers,
115
194
  ...mtnValues,
116
195
  ...mtnHandlers,
@@ -118,20 +197,22 @@ export function useUpsertSheetRange(params: UseMutationParams = {}, openModalPop
118
197
  }
119
198
 
120
199
  /*
121
- * Delete one sheet range.
200
+ * Export a spreadsheet to a downloadable file (CSV/TSV/PDF for one tab, XLSX
201
+ * for the whole workbook).
122
202
  */
123
203
 
124
- export function useDeleteSheetRange(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
125
- const [deleteSheetRange, mtnValues, mtnHandlers, updateObservers] = useMutation(
126
- deleteSheetRangeMtn,
127
- {
204
+ export function useExportSheetToFile(
205
+ params: UseMutationParams = {},
206
+ openModalPopUp?: OpenModalPopUpFn,
207
+ ) {
208
+ const [exportSheetToFile, mtnValues, mtnHandlers, updateObservers] =
209
+ useMutation(exportSheetToFileMtn, {
128
210
  openModalPopUp,
129
211
  ...params,
130
- },
131
- );
212
+ });
132
213
 
133
214
  return {
134
- deleteSheetRange,
215
+ exportSheetToFile,
135
216
  updateObservers,
136
217
  ...mtnValues,
137
218
  ...mtnHandlers,
@@ -139,12 +220,15 @@ export function useDeleteSheetRange(params: UseMutationParams = {}, openModalPop
139
220
  }
140
221
 
141
222
  /*
142
- * Create or update one Data Table-backed sheet region.
223
+ * Update a sheet tab.
143
224
  */
144
225
 
145
- export function useUpsertSheetDataTableRegion(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
146
- const [upsertSheetDataTableRegion, mtnValues, mtnHandlers, updateObservers] = useMutation(
147
- upsertSheetDataTableRegionMtn,
226
+ export function useUpdateSheetTab(
227
+ params: UseMutationParams = {},
228
+ openModalPopUp?: OpenModalPopUpFn,
229
+ ) {
230
+ const [updateSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(
231
+ updateSheetTabMtn,
148
232
  {
149
233
  openModalPopUp,
150
234
  ...params,
@@ -152,7 +236,7 @@ export function useUpsertSheetDataTableRegion(params: UseMutationParams = {}, op
152
236
  );
153
237
 
154
238
  return {
155
- upsertSheetDataTableRegion,
239
+ updateSheetTab,
156
240
  updateObservers,
157
241
  ...mtnValues,
158
242
  ...mtnHandlers,
@@ -160,20 +244,122 @@ export function useUpsertSheetDataTableRegion(params: UseMutationParams = {}, op
160
244
  }
161
245
 
162
246
  /*
163
- * Delete one sheet region.
247
+ * Reorder sheet tabs.
164
248
  */
165
249
 
166
- export function useDeleteSheetRegion(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
167
- const [deleteSheetRegion, mtnValues, mtnHandlers, updateObservers] = useMutation(
168
- deleteSheetRegionMtn,
169
- {
250
+ export function useReorderSheetTabs(
251
+ params: UseMutationParams = {},
252
+ openModalPopUp?: OpenModalPopUpFn,
253
+ ) {
254
+ const [reorderSheetTabs, mtnValues, mtnHandlers, updateObservers] =
255
+ useMutation(reorderSheetTabsMtn, {
170
256
  openModalPopUp,
171
257
  ...params,
258
+ });
259
+
260
+ return {
261
+ reorderSheetTabs,
262
+ updateObservers,
263
+ ...mtnValues,
264
+ ...mtnHandlers,
265
+ };
266
+ }
267
+
268
+ /*
269
+ * Delete a sheet tab.
270
+ */
271
+
272
+ export function useDeleteSheetTab(
273
+ params: UseMutationParams = {},
274
+ openModalPopUp?: OpenModalPopUpFn,
275
+ ) {
276
+ const { onCompleted, ...rest } = params;
277
+ const [deleteSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(
278
+ deleteSheetTabMtn,
279
+ {
280
+ openModalPopUp,
281
+ onCompleted: (data, error, variables) => {
282
+ if (data?.deleteSheetTab && variables?.sheetTabId) {
283
+ updateFragment(
284
+ makeFragmentKey(FRAGMENT_NAMES.sheetTab, variables.sheetTabId),
285
+ { __deleted: true },
286
+ null,
287
+ false,
288
+ updateObservers,
289
+ );
290
+ }
291
+
292
+ onCompleted?.(data, error, variables);
293
+ },
294
+ ...rest,
172
295
  },
173
296
  );
174
297
 
175
298
  return {
176
- deleteSheetRegion,
299
+ deleteSheetTab,
300
+ updateObservers,
301
+ ...mtnValues,
302
+ ...mtnHandlers,
303
+ };
304
+ }
305
+
306
+ /*
307
+ * Apply an ordered batch of Sheet edit and history commands in one mutation.
308
+ */
309
+ export function useEditSheetCommandBatch(
310
+ params: UseMutationParams = {},
311
+ openModalPopUp?: OpenModalPopUpFn,
312
+ ) {
313
+ const [editSheetCommandBatch, mtnValues, mtnHandlers, updateObservers] =
314
+ useMutation(editSheetCommandBatchMtn, {
315
+ openModalPopUp,
316
+ ...params,
317
+ });
318
+
319
+ return {
320
+ editSheetCommandBatch,
321
+ updateObservers,
322
+ ...mtnValues,
323
+ ...mtnHandlers,
324
+ };
325
+ }
326
+
327
+ /*
328
+ * Upsert or delete one Sheet region through the durable command contract.
329
+ */
330
+ export function useEditSheetRegionCommand(
331
+ params: UseMutationParams = {},
332
+ openModalPopUp?: OpenModalPopUpFn,
333
+ ) {
334
+ const [editSheetRegionCommand, mtnValues, mtnHandlers, updateObservers] =
335
+ useMutation(editSheetRegionCommandMtn, {
336
+ openModalPopUp,
337
+ ...params,
338
+ });
339
+
340
+ return {
341
+ editSheetRegionCommand,
342
+ updateObservers,
343
+ ...mtnValues,
344
+ ...mtnHandlers,
345
+ };
346
+ }
347
+
348
+ /*
349
+ * Insert or delete one Sheet row or column through durable command history.
350
+ */
351
+ export function useEditSheetStructureCommand(
352
+ params: UseMutationParams = {},
353
+ openModalPopUp?: OpenModalPopUpFn,
354
+ ) {
355
+ const [editSheetStructureCommand, mtnValues, mtnHandlers, updateObservers] =
356
+ useMutation(editSheetStructureCommandMtn, {
357
+ openModalPopUp,
358
+ ...params,
359
+ });
360
+
361
+ return {
362
+ editSheetStructureCommand,
177
363
  updateObservers,
178
364
  ...mtnValues,
179
365
  ...mtnHandlers,