@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,7 +1,21 @@
1
1
  import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
2
2
  import type { ChildOrgsFilterArgs } from '@jsb188/mday/types/organization.d.ts';
3
- export { useInboundContact, useInboundContacts, useReactiveInboundContactFragment } from './use-inboundContact-qry.ts';
4
- import { childOrganizationsQry, myOrganizationsQry, organizationMembersQry, organizationSitesQry } from '../gql/queries/organizationQueries.ts';
3
+ import {
4
+ FRAGMENT_NAMES,
5
+ makeFragmentKey,
6
+ } from '@jsb188/mday/constants/graphqlReactivity.ts';
7
+ export {
8
+ useInboundContact,
9
+ useInboundContacts,
10
+ useReactiveInboundContactFragment,
11
+ } from './use-inboundContact-qry.ts';
12
+ import {
13
+ childOrganizationsQry,
14
+ myOrganizationsQry,
15
+ organizationMembersQry,
16
+ organizationSitesQry,
17
+ pageRoutesQry,
18
+ } from '../gql/queries/organizationQueries.ts';
5
19
  import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
6
20
 
7
21
  const ORG_CHILDREN_LIMIT = 250;
@@ -11,12 +25,15 @@ const ORG_CHILDREN_LIMIT = 250;
11
25
  */
12
26
 
13
27
  export function useMyOrganizations(params: UseQueryParams = {}) {
14
- const { data, ...rest } = useQuery(myOrganizationsQry, params);
28
+ const { data, ...rest } = useQuery(myOrganizationsQry, {
29
+ ...params,
30
+ persistTime: params.persistTime ?? 15 * 60 * 1000,
31
+ });
15
32
 
16
- return {
17
- myOrganizations: data?.myOrganizations,
18
- ...rest
19
- };
33
+ return {
34
+ myOrganizations: data?.myOrganizations,
35
+ ...rest,
36
+ };
20
37
  }
21
38
 
22
39
  /**
@@ -24,26 +41,28 @@ export function useMyOrganizations(params: UseQueryParams = {}) {
24
41
  */
25
42
 
26
43
  export function useOrganizationMembers(
27
- organizationId: string | null,
28
- paramsOrShowGuests: UseQueryParams | boolean = {},
29
- showGuests_: boolean = false,
44
+ organizationId: string | null,
45
+ paramsOrShowGuests: UseQueryParams | boolean = {},
46
+ showGuests_: boolean = false,
30
47
  ) {
31
- const params = typeof paramsOrShowGuests === 'boolean' ? {} : paramsOrShowGuests;
32
- const showGuests = typeof paramsOrShowGuests === 'boolean' ? paramsOrShowGuests : showGuests_;
33
-
34
- const { data, ...rest } = useQuery(organizationMembersQry, {
35
- variables: {
36
- organizationId,
37
- showGuests,
38
- },
39
- skip: !organizationId || params.skip,
40
- ...params,
41
- });
42
-
43
- return {
44
- organizationMembers: data?.organizationMembers,
45
- ...rest
46
- };
48
+ const params =
49
+ typeof paramsOrShowGuests === 'boolean' ? {} : paramsOrShowGuests;
50
+ const showGuests =
51
+ typeof paramsOrShowGuests === 'boolean' ? paramsOrShowGuests : showGuests_;
52
+
53
+ const { data, ...rest } = useQuery(organizationMembersQry, {
54
+ variables: {
55
+ organizationId,
56
+ showGuests,
57
+ },
58
+ skip: !organizationId || params.skip,
59
+ ...params,
60
+ });
61
+
62
+ return {
63
+ organizationMembers: data?.organizationMembers,
64
+ ...rest,
65
+ };
47
66
  }
48
67
 
49
68
  /**
@@ -51,45 +70,53 @@ export function useOrganizationMembers(
51
70
  */
52
71
 
53
72
  export function useOrganizationSites(
54
- organizationId: string | null,
55
- parentId: string | null,
56
- params: UseQueryParams = {},
73
+ organizationId: string | null,
74
+ parentId: string | null,
75
+ params: UseQueryParams = {},
57
76
  ) {
58
- const { data, ...rest } = useQuery(organizationSitesQry, {
59
- variables: {
60
- organizationId,
61
- parentId,
62
- },
63
- skip: !organizationId || params.skip,
64
- ...params,
65
- });
66
-
67
- return {
68
- organizationSites: data?.organizationSites,
69
- ...rest
70
- };
77
+ const { data, ...rest } = useQuery(organizationSitesQry, {
78
+ variables: {
79
+ organizationId,
80
+ parentId,
81
+ },
82
+ skip: !organizationId || params.skip,
83
+ ...params,
84
+ });
85
+
86
+ return {
87
+ organizationSites: data?.organizationSites,
88
+ ...rest,
89
+ };
71
90
  }
72
91
 
73
- export function useReactiveOrganization(orgId: string, currentData?: any, queryCount?: number) {
74
- return useReactiveFragment(
75
- currentData,
76
- [`$organizationFragment:${orgId}`],
77
- queryCount,
78
- );
92
+ export function useReactiveOrganization(
93
+ orgId: string,
94
+ currentData?: any,
95
+ queryCount?: number,
96
+ ) {
97
+ return useReactiveFragment(
98
+ currentData,
99
+ [makeFragmentKey(FRAGMENT_NAMES.organization, orgId)],
100
+ queryCount,
101
+ );
79
102
  }
80
103
 
81
104
  /*
82
105
  * Get reactive organization settings fragment data.
83
106
  */
84
- export function useReactiveOrganizationSettings(orgId: string | null | undefined, currentData?: any, queryCount?: number) {
85
- return useReactiveFragment(
86
- currentData,
87
- orgId ? [`$organizationSettingsFragment:${orgId}`] : [],
88
- queryCount,
89
- undefined,
90
- undefined,
91
- true,
92
- );
107
+ export function useReactiveOrganizationSettings(
108
+ orgId: string | null | undefined,
109
+ currentData?: any,
110
+ queryCount?: number,
111
+ ) {
112
+ return useReactiveFragment(
113
+ currentData,
114
+ orgId ? [makeFragmentKey(FRAGMENT_NAMES.organizationSettings, orgId)] : [],
115
+ queryCount,
116
+ undefined,
117
+ undefined,
118
+ true,
119
+ );
93
120
  }
94
121
 
95
122
  /**
@@ -97,94 +124,137 @@ export function useReactiveOrganizationSettings(orgId: string | null | undefined
97
124
  */
98
125
 
99
126
  export function useOrgRelFromMyOrganizations(organizationId: string | null) {
100
- const { myOrganizations, ...rest } = useMyOrganizations({
101
- skip: !organizationId,
102
- });
103
-
104
- const orgRel = myOrganizations?.find((orgRel: any) => orgRel.organization?.id === organizationId) || null;
105
- const reactiveOrganization = useReactiveOrganization(orgRel?.organization?.id, orgRel?.organization);
106
- const reactiveSettings = useReactiveOrganizationSettings(reactiveOrganization?.id, reactiveOrganization?.settings);
107
- const organization = reactiveOrganization && reactiveSettings
108
- ? {
109
- ...reactiveOrganization,
110
- settings: reactiveSettings,
111
- }
112
- : reactiveOrganization;
113
- const organizationRelationship = orgRel && organization
114
- ? {
115
- ...orgRel,
116
- organization,
117
- }
118
- : orgRel;
119
-
120
- return {
121
- organizationRelationship,
122
- organization,
123
- myOrganizations,
124
- ...rest
125
- };
127
+ const { myOrganizations, ...rest } = useMyOrganizations({
128
+ skip: !organizationId,
129
+ });
130
+
131
+ const orgRel =
132
+ myOrganizations?.find(
133
+ (orgRel: any) => orgRel.organization?.id === organizationId,
134
+ ) || null;
135
+ const reactiveOrganization = useReactiveOrganization(
136
+ orgRel?.organization?.id,
137
+ orgRel?.organization,
138
+ );
139
+ const reactiveSettings = useReactiveOrganizationSettings(
140
+ reactiveOrganization?.id,
141
+ reactiveOrganization?.settings,
142
+ );
143
+ const organization =
144
+ reactiveOrganization && reactiveSettings
145
+ ? {
146
+ ...reactiveOrganization,
147
+ settings: reactiveSettings,
148
+ }
149
+ : reactiveOrganization;
150
+ const organizationRelationship =
151
+ orgRel && organization
152
+ ? {
153
+ ...orgRel,
154
+ organization,
155
+ }
156
+ : orgRel;
157
+
158
+ return {
159
+ organizationRelationship,
160
+ organization,
161
+ myOrganizations,
162
+ ...rest,
163
+ };
126
164
  }
127
165
 
128
166
  /**
129
167
  * Fetch child organizations
130
168
  */
131
169
 
132
- export function useChildOrganizations(variables: PaginationArgs & {
133
- organizationId?: string | null;
134
- filter?: ChildOrgsFilterArgs;
135
- }, params: UseQueryParams = {}) {
136
- const { data, ...rest } = useQuery(childOrganizationsQry, {
137
- variables: {
138
- ...variables,
139
- cursor: null,
140
- after: true,
141
- limit: ORG_CHILDREN_LIMIT
142
- },
143
- skip: !variables.organizationId,
144
- ...params,
145
- });
146
-
147
- return {
148
- childOrganizations: data?.childOrganizations,
149
- ...rest
150
- };
170
+ export function useChildOrganizations(
171
+ variables: PaginationArgs & {
172
+ organizationId?: string | null;
173
+ filter?: ChildOrgsFilterArgs;
174
+ },
175
+ params: UseQueryParams = {},
176
+ ) {
177
+ const { data, ...rest } = useQuery(childOrganizationsQry, {
178
+ variables: {
179
+ ...variables,
180
+ cursor: null,
181
+ after: true,
182
+ limit: ORG_CHILDREN_LIMIT,
183
+ },
184
+ skip: !variables.organizationId,
185
+ ...params,
186
+ });
187
+
188
+ return {
189
+ childOrganizations: data?.childOrganizations,
190
+ ...rest,
191
+ };
151
192
  }
152
193
 
153
194
  /**
154
195
  * Get reactive organization fragment
155
196
  */
156
197
 
157
- export function useReactiveOrganizationChildFragment(childId: string, currentData?: any, queryCount?: number, mainPrioritizedFields?: string[]) {
158
- const organizationId = currentData?.organization?.id;
159
-
160
- return useReactiveFragment(
161
- currentData,
162
- [
163
- `$organizationChildFragment:${childId}`,
164
- organizationId ? [`$organizationFragment:${organizationId}`, 'organization'] : null,
165
- // [`$organizationChildArableFragment:${childId}`, null],
166
- // By having the second paramter as null, we only observe the reactive changes without setting the data
167
- // [`$logArableFragment:${logEntryId}`, null],
168
- ].filter(Boolean) as Array<string | [string, string | null]>,
169
- queryCount,
170
- undefined,
171
- mainPrioritizedFields,
172
- );
198
+ export function useReactiveOrganizationChildFragment(
199
+ childId: string,
200
+ currentData?: any,
201
+ queryCount?: number,
202
+ mainPrioritizedFields?: string[],
203
+ ) {
204
+ const organizationId = currentData?.organization?.id;
205
+
206
+ return useReactiveFragment(
207
+ currentData,
208
+ [
209
+ makeFragmentKey(FRAGMENT_NAMES.organizationChild, childId),
210
+ organizationId
211
+ ? [
212
+ makeFragmentKey(FRAGMENT_NAMES.organization, organizationId),
213
+ 'organization',
214
+ ]
215
+ : null,
216
+ ].filter(Boolean) as Array<string | [string, string | null]>,
217
+ queryCount,
218
+ undefined,
219
+ mainPrioritizedFields,
220
+ );
173
221
  }
174
222
 
175
223
  /**
176
224
  * Get reactive organization compliance document fragment
177
225
  */
178
226
 
179
- export function useReactiveOrganizationComplianceFragment(complianceId: string, currentData?: any, queryCount?: number) {
180
- return useReactiveFragment(
181
- currentData,
182
- [
183
- `$organizationComplianceFragment:${complianceId}`,
184
- // [`$organizationChildArableFragment:${organizationId}`, null],
185
- // By having the second paramter as null, we only observe the reactive changes without setting the data
186
- // [`$logArableFragment:${logEntryId}`, null],
187
- ],
188
- queryCount,
189
- );
227
+ export function useReactiveOrganizationComplianceFragment(
228
+ complianceId: string,
229
+ currentData?: any,
230
+ queryCount?: number,
231
+ ) {
232
+ return useReactiveFragment(
233
+ currentData,
234
+ [makeFragmentKey(FRAGMENT_NAMES.organizationCompliance, complianceId)],
235
+ queryCount,
236
+ );
237
+ }
238
+
239
+ /**
240
+ * Fetch custom page routes for organization
241
+ */
242
+
243
+ export function usePageRoutes(
244
+ organizationId: string | null,
245
+ params: UseQueryParams = {},
246
+ ) {
247
+ const { skip, ...restParams } = params;
248
+ const { data, ...rest } = useQuery(pageRoutesQry, {
249
+ variables: {
250
+ organizationId,
251
+ },
252
+ skip: skip || !organizationId,
253
+ ...restParams,
254
+ });
255
+
256
+ return {
257
+ pageRoutes: data?.pageRoutes,
258
+ ...rest,
259
+ };
190
260
  }