@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,170 @@
1
+ import type { UseMutationParams } from '@jsb188/graphql/types.d';
2
+ import type { OpenModalPopUpFn } from '@jsb188/react/states';
3
+ import { useCallback } from 'react';
4
+ import {
5
+ createDataTableMtn,
6
+ deleteDataTableMtn,
7
+ deleteDataTableRowsMtn,
8
+ editDataTableCellsMtn,
9
+ editDataTableDesignMtn,
10
+ } from '../gql/mutations/dataTableMutations.ts';
11
+ import { type GraphQLMutationFn, useMutation } from './index.ts';
12
+
13
+ /*
14
+ * Add one UUID to a logical DataTable mutation invocation. The lower-level
15
+ * mutation hook reuses this same variables object for every transport retry.
16
+ */
17
+ function useDataTableCommandMutation(mutate: GraphQLMutationFn) {
18
+ return useCallback<GraphQLMutationFn>(
19
+ (graphqlOptions, triedCount) => {
20
+ const commandId =
21
+ graphqlOptions?.variables?.commandId ?? crypto.randomUUID();
22
+
23
+ return mutate(
24
+ {
25
+ ...graphqlOptions,
26
+ variables: {
27
+ ...(graphqlOptions?.variables || {}),
28
+ commandId,
29
+ },
30
+ },
31
+ triedCount,
32
+ );
33
+ },
34
+ [mutate],
35
+ );
36
+ }
37
+
38
+ /*
39
+ * Keep authoritative DataTable mutation responses out of normalized cache so
40
+ * a delayed HTTP response cannot overwrite a newer sequenced websocket event.
41
+ */
42
+ function useAuthoritativeDataTableMutation(
43
+ mutation: any,
44
+ params: UseMutationParams,
45
+ openModalPopUp?: OpenModalPopUpFn,
46
+ ) {
47
+ return useMutation(mutation, {
48
+ openModalPopUp,
49
+ ...params,
50
+ cachePolicy: 'no-store',
51
+ });
52
+ }
53
+
54
+ /**
55
+ * Create a dataTable.
56
+ */
57
+
58
+ export function useCreateDataTable(
59
+ params: UseMutationParams = {},
60
+ openModalPopUp?: OpenModalPopUpFn,
61
+ ) {
62
+ const [createDataTable, mtnValues, mtnHandlers, updateObservers] =
63
+ useMutation(createDataTableMtn, {
64
+ openModalPopUp,
65
+ ...params,
66
+ });
67
+
68
+ return {
69
+ createDataTable,
70
+ updateObservers,
71
+ ...mtnValues,
72
+ ...mtnHandlers,
73
+ };
74
+ }
75
+
76
+ /**
77
+ * Delete a dataTable.
78
+ */
79
+
80
+ export function useDeleteDataTable(
81
+ params: UseMutationParams = {},
82
+ openModalPopUp?: OpenModalPopUpFn,
83
+ ) {
84
+ const [deleteDataTable, mtnValues, mtnHandlers, updateObservers] =
85
+ useAuthoritativeDataTableMutation(
86
+ deleteDataTableMtn,
87
+ params,
88
+ openModalPopUp,
89
+ );
90
+
91
+ return {
92
+ deleteDataTable,
93
+ updateObservers,
94
+ ...mtnValues,
95
+ ...mtnHandlers,
96
+ };
97
+ }
98
+
99
+ /**
100
+ * Edit multiple dataTable cell values.
101
+ */
102
+
103
+ export function useEditDataTableCells(
104
+ params: UseMutationParams = {},
105
+ openModalPopUp?: OpenModalPopUpFn,
106
+ ) {
107
+ const [mutateDataTableCells, mtnValues, mtnHandlers, updateObservers] =
108
+ useAuthoritativeDataTableMutation(
109
+ editDataTableCellsMtn,
110
+ params,
111
+ openModalPopUp,
112
+ );
113
+ const editDataTableCells = useDataTableCommandMutation(mutateDataTableCells);
114
+
115
+ return {
116
+ editDataTableCells,
117
+ updateObservers,
118
+ ...mtnValues,
119
+ ...mtnHandlers,
120
+ };
121
+ }
122
+
123
+ /**
124
+ * Delete source dataTable rows.
125
+ */
126
+
127
+ export function useDeleteDataTableRows(
128
+ params: UseMutationParams = {},
129
+ openModalPopUp?: OpenModalPopUpFn,
130
+ ) {
131
+ const [mutateDataTableRows, mtnValues, mtnHandlers] =
132
+ useAuthoritativeDataTableMutation(
133
+ deleteDataTableRowsMtn,
134
+ params,
135
+ openModalPopUp,
136
+ );
137
+ const deleteDataTableRows = useDataTableCommandMutation(mutateDataTableRows);
138
+
139
+ return {
140
+ deleteDataTableRows,
141
+ ...mtnValues,
142
+ ...mtnHandlers,
143
+ };
144
+ }
145
+
146
+ /**
147
+ * Edit the saved design object for one dataTable.
148
+ */
149
+
150
+ export function useEditDataTableDesign(
151
+ params: UseMutationParams = {},
152
+ openModalPopUp?: OpenModalPopUpFn,
153
+ ) {
154
+ const [mutateDataTableDesign, mtnValues, mtnHandlers, updateObservers] =
155
+ useAuthoritativeDataTableMutation(
156
+ editDataTableDesignMtn,
157
+ params,
158
+ openModalPopUp,
159
+ );
160
+ const editDataTableDesign = useDataTableCommandMutation(
161
+ mutateDataTableDesign,
162
+ );
163
+
164
+ return {
165
+ editDataTableDesign,
166
+ updateObservers,
167
+ ...mtnValues,
168
+ ...mtnHandlers,
169
+ };
170
+ }