@jsb188/graphql 1.1.8 → 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 (122) hide show
  1. package/cache/config.ts +66 -42
  2. package/cache/index.test.ts +881 -0
  3. package/cache/index.ts +1815 -979
  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 +4 -2
  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 +973 -143
  16. package/client/sse-ticket.test.ts +26 -0
  17. package/deno.lock +170 -0
  18. package/deno.test.json +10 -0
  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 +1 -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 +17 -0
  28. package/gql/fragments/billingFragments.ts +0 -11
  29. package/gql/fragments/campaignFragments.ts +277 -0
  30. package/gql/fragments/dataTableFragments.ts +102 -0
  31. package/gql/fragments/emailFragments.ts +36 -0
  32. package/gql/fragments/fieldDocFragments.ts +82 -0
  33. package/gql/fragments/inboundContactFragments.ts +15 -0
  34. package/gql/fragments/integrationFragments.ts +22 -0
  35. package/gql/fragments/logFragments.ts +33 -64
  36. package/gql/fragments/organizationFragments.ts +94 -21
  37. package/gql/fragments/scheduleFragments.ts +155 -0
  38. package/gql/fragments/sheetFragments.ts +675 -0
  39. package/gql/fragments/storageFragments.ts +21 -1
  40. package/gql/fragments/workflowFragments.ts +67 -0
  41. package/gql/mutations/accountMutations.ts +24 -4
  42. package/gql/mutations/agentDocMutations.ts +177 -0
  43. package/gql/mutations/agentMemoryMutations.ts +36 -0
  44. package/gql/mutations/aiChatMutations.ts +43 -3
  45. package/gql/mutations/authMutations.ts +160 -19
  46. package/gql/mutations/campaignMutations.ts +215 -0
  47. package/gql/mutations/dataTableMutations.ts +106 -0
  48. package/gql/mutations/fieldDocMutations.ts +24 -0
  49. package/gql/mutations/inboundContactMutations.ts +24 -0
  50. package/gql/mutations/index.ts +17 -8
  51. package/gql/mutations/integrationMutations.ts +25 -0
  52. package/gql/mutations/logMutations.ts +10 -19
  53. package/gql/mutations/organizationMutations.ts +160 -2
  54. package/gql/mutations/scheduleMutations.ts +423 -0
  55. package/gql/mutations/sheetMutations.ts +385 -0
  56. package/gql/mutations/storageMutations.ts +21 -2
  57. package/gql/mutations/workflowMutations.ts +42 -0
  58. package/gql/queries/agentDocQueries.ts +120 -0
  59. package/gql/queries/agentMemoryQueries.ts +22 -0
  60. package/gql/queries/aiChatQueries.ts +18 -2
  61. package/gql/queries/authQueries.ts +41 -0
  62. package/gql/queries/billingQueries.ts +24 -1
  63. package/gql/queries/campaignQueries.ts +127 -0
  64. package/gql/queries/dataTableQueries.ts +134 -0
  65. package/gql/queries/emailQueries.ts +96 -0
  66. package/gql/queries/fieldDocQueries.ts +158 -0
  67. package/gql/queries/inboundContactQueries.ts +40 -0
  68. package/gql/queries/index.ts +17 -6
  69. package/gql/queries/logQueries.ts +42 -32
  70. package/gql/queries/organizationQueries.ts +113 -8
  71. package/gql/queries/scheduleQueries.ts +315 -0
  72. package/gql/queries/sheetQueries.ts +383 -0
  73. package/gql/queries/storageQueries.ts +38 -0
  74. package/gql/queries/workflowQueries.ts +99 -0
  75. package/hooks/index.ts +2104 -860
  76. package/hooks/use-account-mtn.ts +91 -48
  77. package/hooks/use-agentDoc-mtn.ts +285 -0
  78. package/hooks/use-agentDoc-qry.ts +208 -0
  79. package/hooks/use-agentMemory-mtn.ts +73 -0
  80. package/hooks/use-agentMemory-qry.ts +44 -0
  81. package/hooks/use-aiChat-mtn.ts +248 -97
  82. package/hooks/use-aiChat-qry.ts +501 -191
  83. package/hooks/use-app-qry.ts +14 -11
  84. package/hooks/use-auth-mtn.ts +410 -256
  85. package/hooks/use-auth-qry.ts +51 -0
  86. package/hooks/use-campaign-mtn.ts +377 -0
  87. package/hooks/use-campaign-qry.ts +257 -0
  88. package/hooks/use-dataTable-mtn.ts +170 -0
  89. package/hooks/use-dataTable-qry.ts +996 -0
  90. package/hooks/use-email-qry.ts +227 -0
  91. package/hooks/use-fieldDoc-mtn.ts +50 -0
  92. package/hooks/use-fieldDoc-qry.ts +180 -0
  93. package/hooks/use-inboundContact-mtn.ts +34 -0
  94. package/hooks/use-inboundContact-qry.ts +96 -0
  95. package/hooks/use-integration-mtn.ts +77 -0
  96. package/hooks/use-integration-qry.ts +30 -0
  97. package/hooks/use-log-mtn.ts +77 -61
  98. package/hooks/use-log-qry.ts +99 -72
  99. package/hooks/use-organization-mtn.ts +409 -80
  100. package/hooks/use-organization-qry.ts +211 -92
  101. package/hooks/use-schedule-mtn.ts +416 -0
  102. package/hooks/use-schedule-qry.ts +157 -0
  103. package/hooks/use-sheet-mtn.ts +367 -0
  104. package/hooks/use-sheet-qry.ts +440 -0
  105. package/hooks/use-storage-mtn.ts +83 -42
  106. package/hooks/use-storage-qry.ts +104 -13
  107. package/hooks/use-workflow-mtn.ts +55 -0
  108. package/hooks/use-workflow-qry.ts +230 -0
  109. package/loaders/campaign.ts +137 -0
  110. package/package.json +94 -52
  111. package/sse.ts +158 -105
  112. package/tsconfig.json +13 -0
  113. package/types.d.ts +60 -29
  114. package/utils.ts +77 -50
  115. package/gql/fragments/actionFragments.ts +0 -16
  116. package/gql/fragments/productFragments.ts +0 -63
  117. package/gql/fragments/reportFragments.ts +0 -48
  118. package/gql/mutations/billingMutations.ts +0 -34
  119. package/gql/queries/productQueries.ts +0 -70
  120. package/gql/queries/reportQueries.ts +0 -66
  121. package/hooks/use-product-qry.ts +0 -109
  122. package/hooks/use-report-qry.ts +0 -69
@@ -0,0 +1,367 @@
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 { updateFragment } from '../cache/index.ts';
8
+ import {
9
+ createSheetMtn,
10
+ createSheetTabMtn,
11
+ deleteSheetMtn,
12
+ deleteSheetTabMtn,
13
+ editSheetCommandBatchMtn,
14
+ editSheetRegionCommandMtn,
15
+ editSheetStructureCommandMtn,
16
+ exportSheetToFileMtn,
17
+ importSheetFromFileMtn,
18
+ reorderSheetTabsMtn,
19
+ updateSheetAccessMtn,
20
+ updateSheetMtn,
21
+ updateSheetTabMtn,
22
+ } from '../gql/mutations/sheetMutations.ts';
23
+ import { useMutation } from './index.ts';
24
+
25
+ /*
26
+ * Create a sheet.
27
+ */
28
+
29
+ export function useCreateSheet(
30
+ params: UseMutationParams = {},
31
+ openModalPopUp?: OpenModalPopUpFn,
32
+ ) {
33
+ const [createSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(
34
+ createSheetMtn,
35
+ {
36
+ openModalPopUp,
37
+ ...params,
38
+ },
39
+ );
40
+
41
+ return {
42
+ createSheet,
43
+ updateObservers,
44
+ ...mtnValues,
45
+ ...mtnHandlers,
46
+ };
47
+ }
48
+
49
+ /*
50
+ * Update a sheet.
51
+ */
52
+
53
+ export function useUpdateSheet(
54
+ params: UseMutationParams = {},
55
+ openModalPopUp?: OpenModalPopUpFn,
56
+ ) {
57
+ const [updateSheet, mtnValues, mtnHandlers, updateObservers] = useMutation(
58
+ updateSheetMtn,
59
+ {
60
+ openModalPopUp,
61
+ ...params,
62
+ },
63
+ );
64
+
65
+ return {
66
+ updateSheet,
67
+ updateObservers,
68
+ ...mtnValues,
69
+ ...mtnHandlers,
70
+ };
71
+ }
72
+
73
+ /*
74
+ * Update a sheet's access settings.
75
+ */
76
+
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,
125
+ {
126
+ openModalPopUp,
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,
142
+ },
143
+ );
144
+
145
+ return {
146
+ deleteSheet,
147
+ updateObservers,
148
+ ...mtnValues,
149
+ ...mtnHandlers,
150
+ };
151
+ }
152
+
153
+ /*
154
+ * Create a sheet tab.
155
+ */
156
+
157
+ export function useCreateSheetTab(
158
+ params: UseMutationParams = {},
159
+ openModalPopUp?: OpenModalPopUpFn,
160
+ ) {
161
+ const [createSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(
162
+ createSheetTabMtn,
163
+ {
164
+ openModalPopUp,
165
+ ...params,
166
+ },
167
+ );
168
+
169
+ return {
170
+ createSheetTab,
171
+ updateObservers,
172
+ ...mtnValues,
173
+ ...mtnHandlers,
174
+ };
175
+ }
176
+
177
+ /*
178
+ * Import a spreadsheet file into a new or existing sheet.
179
+ */
180
+
181
+ export function useImportSheetFromFile(
182
+ params: UseMutationParams = {},
183
+ openModalPopUp?: OpenModalPopUpFn,
184
+ ) {
185
+ const [importSheetFromFile, mtnValues, mtnHandlers, updateObservers] =
186
+ useMutation(importSheetFromFileMtn, {
187
+ openModalPopUp,
188
+ ...params,
189
+ });
190
+
191
+ return {
192
+ importSheetFromFile,
193
+ updateObservers,
194
+ ...mtnValues,
195
+ ...mtnHandlers,
196
+ };
197
+ }
198
+
199
+ /*
200
+ * Export a spreadsheet to a downloadable file (CSV/TSV/PDF for one tab, XLSX
201
+ * for the whole workbook).
202
+ */
203
+
204
+ export function useExportSheetToFile(
205
+ params: UseMutationParams = {},
206
+ openModalPopUp?: OpenModalPopUpFn,
207
+ ) {
208
+ const [exportSheetToFile, mtnValues, mtnHandlers, updateObservers] =
209
+ useMutation(exportSheetToFileMtn, {
210
+ openModalPopUp,
211
+ ...params,
212
+ });
213
+
214
+ return {
215
+ exportSheetToFile,
216
+ updateObservers,
217
+ ...mtnValues,
218
+ ...mtnHandlers,
219
+ };
220
+ }
221
+
222
+ /*
223
+ * Update a sheet tab.
224
+ */
225
+
226
+ export function useUpdateSheetTab(
227
+ params: UseMutationParams = {},
228
+ openModalPopUp?: OpenModalPopUpFn,
229
+ ) {
230
+ const [updateSheetTab, mtnValues, mtnHandlers, updateObservers] = useMutation(
231
+ updateSheetTabMtn,
232
+ {
233
+ openModalPopUp,
234
+ ...params,
235
+ },
236
+ );
237
+
238
+ return {
239
+ updateSheetTab,
240
+ updateObservers,
241
+ ...mtnValues,
242
+ ...mtnHandlers,
243
+ };
244
+ }
245
+
246
+ /*
247
+ * Reorder sheet tabs.
248
+ */
249
+
250
+ export function useReorderSheetTabs(
251
+ params: UseMutationParams = {},
252
+ openModalPopUp?: OpenModalPopUpFn,
253
+ ) {
254
+ const [reorderSheetTabs, mtnValues, mtnHandlers, updateObservers] =
255
+ useMutation(reorderSheetTabsMtn, {
256
+ openModalPopUp,
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,
295
+ },
296
+ );
297
+
298
+ return {
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,
363
+ updateObservers,
364
+ ...mtnValues,
365
+ ...mtnHandlers,
366
+ };
367
+ }