@jsb188/graphql 1.1.12 → 1.1.13

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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/audience.d.ts +14 -152
  3. package/cache/config.ts +35 -32
  4. package/cache/index.helpers.ts +1 -1
  5. package/cache/index.ts +73 -44
  6. package/cache/mounted-queries.ts +33 -0
  7. package/cache/persist.ts +10 -4
  8. package/cache/realtime-fence.ts +47 -0
  9. package/cache/realtime-live.ts +17 -0
  10. package/client/draft-persistence.ts +10 -39
  11. package/client/index.ts +2 -1
  12. package/client/request.ts +9 -34
  13. package/client/storage-asset.ts +58 -0
  14. package/gql/fragments/accountAuthFragments.ts +0 -4
  15. package/gql/fragments/agentNoteFragments.ts +8 -2
  16. package/gql/fragments/aiChatFragments.ts +0 -2
  17. package/gql/fragments/aiChatLinkFragments.ts +8 -0
  18. package/gql/fragments/audienceFragments.ts +1 -66
  19. package/gql/fragments/emailFragments.ts +27 -4
  20. package/gql/fragments/emailOutreachFragments.ts +281 -0
  21. package/gql/fragments/inboundContactFragments.ts +1 -1
  22. package/gql/fragments/libraryFragments.ts +120 -0
  23. package/gql/fragments/organizationFragments.ts +4 -2
  24. package/gql/fragments/scheduleFragments.ts +241 -324
  25. package/gql/fragments/sheetFragments.ts +4 -53
  26. package/gql/fragments/workWaitFragments.ts +13 -0
  27. package/gql/fragments/workflowFragments.ts +20 -4
  28. package/gql/mutations/agentNoteMutations.ts +2 -0
  29. package/gql/mutations/aiChatLinkMutations.ts +13 -0
  30. package/gql/mutations/aiChatMutations.ts +4 -6
  31. package/gql/mutations/audienceMutations.ts +0 -13
  32. package/gql/mutations/authMutations.ts +12 -60
  33. package/gql/mutations/emailMutations.ts +22 -0
  34. package/gql/mutations/emailOutreachMutations.ts +139 -0
  35. package/gql/mutations/index.ts +3 -1
  36. package/gql/mutations/organizationMutations.ts +2 -2
  37. package/gql/mutations/scheduleMutations.ts +61 -787
  38. package/gql/mutations/storageMutations.ts +1 -0
  39. package/gql/mutations/workflowMutations.ts +76 -0
  40. package/gql/queries/agentMemoryQueries.ts +6 -2
  41. package/gql/queries/agentNoteQueries.ts +26 -29
  42. package/gql/queries/aiChatQueries.ts +39 -40
  43. package/gql/queries/audienceQueries.ts +31 -55
  44. package/gql/queries/authQueries.ts +16 -6
  45. package/gql/queries/billingQueries.ts +26 -10
  46. package/gql/queries/dataTableQueries.ts +24 -15
  47. package/gql/queries/emailOutreachQueries.ts +282 -0
  48. package/gql/queries/emailQueries.ts +39 -12
  49. package/gql/queries/emailReplyReportQueries.ts +60 -9
  50. package/gql/queries/fieldDocQueries.ts +36 -14
  51. package/gql/queries/inboundContactQueries.ts +11 -4
  52. package/gql/queries/index.ts +2 -2
  53. package/gql/queries/libraryQueries.ts +112 -0
  54. package/gql/queries/logQueries.ts +31 -12
  55. package/gql/queries/organizationQueries.ts +31 -12
  56. package/gql/queries/qrCodeQueries.ts +11 -4
  57. package/gql/queries/scheduleQueries.ts +252 -505
  58. package/gql/queries/sheetQueries.ts +36 -14
  59. package/gql/queries/storageQueries.ts +11 -4
  60. package/gql/queries/workflowQueries.ts +53 -10
  61. package/gql/reactivity.ts +98 -0
  62. package/gql/recordReads.ts +171 -0
  63. package/hooks/index.ts +79 -52
  64. package/hooks/use-agentNote-mtn.ts +7 -0
  65. package/hooks/use-agentNote-qry.ts +30 -58
  66. package/hooks/use-agentNote-recovery.ts +6 -21
  67. package/hooks/use-aiChat-mtn.ts +9 -4
  68. package/hooks/use-aiChat-qry.ts +28 -7
  69. package/hooks/use-audience-mtn.ts +0 -24
  70. package/hooks/use-audience-qry.helpers.ts +0 -24
  71. package/hooks/use-audience-qry.ts +1 -86
  72. package/hooks/use-dataTable-mtn.ts +3 -3
  73. package/hooks/use-dataTable-qry.ts +7 -2
  74. package/hooks/use-email-mtn.ts +26 -0
  75. package/hooks/use-email-qry.helpers.ts +1 -1
  76. package/hooks/use-email-qry.ts +18 -3
  77. package/hooks/use-emailOutreach-mtn.ts +211 -0
  78. package/hooks/use-emailOutreach-qry.helpers.ts +25 -0
  79. package/hooks/use-emailOutreach-qry.ts +367 -0
  80. package/hooks/use-emailOutreachReplyReport-qry.ts +46 -0
  81. package/hooks/use-fieldDoc-qry.ts +1 -1
  82. package/hooks/use-library-qry.ts +233 -0
  83. package/hooks/use-qrCode-qry.ts +1 -1
  84. package/hooks/use-schedule-mtn.ts +10 -300
  85. package/hooks/use-schedule-qry.ts +168 -680
  86. package/hooks/use-schedule-reactive.ts +71 -339
  87. package/hooks/use-sheet-qry.ts +6 -1
  88. package/hooks/use-workflow-mtn.ts +45 -1
  89. package/hooks/use-workflow-qry.ts +22 -2
  90. package/libs/ai-chat-link-events.ts +78 -0
  91. package/libs/data-changes.helpers.ts +161 -0
  92. package/libs/data-changes.ts +382 -0
  93. package/libs/fragment-realtime-sequence.ts +3 -3
  94. package/libs/record-read.ts +327 -0
  95. package/libs/sheet-command-batch.ts +3 -2
  96. package/libs/sheet-realtime-packet.ts +53 -0
  97. package/loaders/emailPreference.ts +18 -24
  98. package/package.json +44 -17
  99. package/schedule.d.ts +267 -874
  100. package/types.d.ts +3 -1
  101. package/cache/index.chat-activity.test.ts +0 -119
  102. package/cache/index.chat.test.ts +0 -92
  103. package/cache/index.regression.test.ts +0 -149
  104. package/cache/index.test.ts +0 -1209
  105. package/deno.lock +0 -187
  106. package/deno.test.json +0 -12
  107. package/gql/fragments/campaignFragments.ts +0 -566
  108. package/gql/mutations/campaignMutations.ts +0 -258
  109. package/gql/queries/appQueries.ts +0 -14
  110. package/gql/queries/campaignQueries.ts +0 -236
  111. package/hooks/index.helpers.test.ts +0 -50
  112. package/hooks/use-agentNote-recovery.helpers.test.ts +0 -68
  113. package/hooks/use-aiChat-qry.helpers.test.ts +0 -63
  114. package/hooks/use-app-qry.ts +0 -22
  115. package/hooks/use-audience-qry.helpers.test.ts +0 -80
  116. package/hooks/use-campaign-generation-recovery.ts +0 -53
  117. package/hooks/use-campaign-mtn.ts +0 -436
  118. package/hooks/use-campaign-qry.helpers.ts +0 -40
  119. package/hooks/use-campaign-qry.ts +0 -834
  120. package/hooks/use-emailCampaignReplyReport-qry.ts +0 -27
  121. package/hooks/use-fieldDoc-qry.helpers.test.ts +0 -65
  122. package/hooks/use-publicFormEmail-mtn.ts +0 -27
  123. package/libs/fragment-recovery.test.ts +0 -326
  124. package/libs/fragment-recovery.ts +0 -325
  125. package/libs/orchestrator-realtime.helpers.test.ts +0 -229
  126. package/libs/orchestrator-realtime.helpers.ts +0 -317
  127. package/libs/orchestrator-realtime.ts +0 -433
  128. package/libs/request-cache-regression.test.ts +0 -122
  129. package/libs/request-managed-session.test.ts +0 -574
  130. package/libs/request-no-store.test.ts +0 -419
  131. package/libs/sheet-view-realtime-router.test.ts +0 -214
  132. package/libs/sse-ticket.test.ts +0 -26
  133. package/loaders/campaign.test.ts +0 -186
  134. package/loaders/campaign.ts +0 -110
  135. package/tests/agent-note-detail-cache.test.ts +0 -120
  136. package/tests/agent-note-search.test.ts +0 -444
  137. package/tsconfig.json +0 -13
@@ -1,738 +1,226 @@
1
1
  import { useQuery } from '@jsb188/graphql/client';
2
+ import type { DocumentNode } from 'graphql';
2
3
  import * as documents from '../gql/queries/scheduleQueries.ts';
3
4
  import type * as Schedule from '../schedule.d.ts';
4
5
  import type { UseQueryParams } from '../types.d.ts';
5
6
 
6
- /*
7
- * Read scheduleWorkCalendars with top-level variables aligned to server reset targets.
8
- */
9
- export function useScheduleWorkCalendars(
10
- p:
11
- | Partial<Schedule.ScheduleWorkCalendarsVariables>
12
- | string
13
- | null
14
- | undefined,
15
- params: UseQueryParams = {},
16
- ) {
17
- const variables: Partial<Schedule.ScheduleWorkCalendarsVariables> =
18
- typeof p === 'string' ? { organizationId: p } : p || {};
19
- const { data, ...rest } = useQuery(documents.scheduleWorkCalendarsQry, {
20
- ...params,
21
- variables: { ...variables, ...params.variables },
22
- skip: !variables.organizationId || !!params.skip,
23
- });
24
- return {
25
- ...rest,
26
- scheduleWorkCalendars: (data?.scheduleWorkCalendars ??
27
- null) as Array<Schedule.ScheduleWorkCalendarGQL> | null,
28
- };
29
- }
30
-
31
- /*
32
- * Read scheduleResources with top-level variables aligned to server reset targets.
33
- */
34
- export function useScheduleResources(
35
- p: Partial<Schedule.ScheduleResourcesVariables>,
36
- params: UseQueryParams = {},
37
- ) {
38
- const variables: Partial<Schedule.ScheduleResourcesVariables> = p;
39
- const { data, ...rest } = useQuery(documents.scheduleResourcesQry, {
40
- ...params,
41
- variables: { ...variables, ...params.variables },
42
- skip: !variables.organizationId || !!params.skip,
43
- });
44
- return {
45
- ...rest,
46
- scheduleResources: (data?.scheduleResources ??
47
- null) as Array<Schedule.ScheduleResourceGQL> | null,
48
- };
49
- }
50
-
51
- /*
52
- * Read scheduleCodeTypes with top-level variables aligned to server reset targets.
53
- */
54
- export function useScheduleCodeTypes(
55
- p: Partial<Schedule.ScheduleCodeTypesVariables> | string | null | undefined,
56
- params: UseQueryParams = {},
57
- ) {
58
- const variables: Partial<Schedule.ScheduleCodeTypesVariables> =
59
- typeof p === 'string' ? { organizationId: p } : p || {};
60
- const { data, ...rest } = useQuery(documents.scheduleCodeTypesQry, {
61
- ...params,
62
- variables: { ...variables, ...params.variables },
63
- skip: !variables.organizationId || !!params.skip,
64
- });
65
- return {
66
- ...rest,
67
- scheduleCodeTypes: (data?.scheduleCodeTypes ??
68
- null) as Array<Schedule.ScheduleCodeTypeGQL> | null,
69
- };
70
- }
71
-
72
- /*
73
- * Read scheduleResourceUsage with top-level variables aligned to server reset targets.
74
- */
75
- export function useScheduleResourceUsage(
76
- p: Partial<Schedule.ScheduleResourceUsageVariables>,
77
- params: UseQueryParams = {},
78
- ) {
79
- const variables: Partial<Schedule.ScheduleResourceUsageVariables> = p;
80
- const { data, ...rest } = useQuery(documents.scheduleResourceUsageQry, {
81
- ...params,
82
- variables: { ...variables, ...params.variables },
83
- skip:
84
- !variables.organizationId ||
85
- !variables.projectId ||
86
- !variables.from ||
87
- !variables.to ||
88
- !!params.skip,
89
- });
90
- return {
91
- ...rest,
92
- scheduleResourceUsage: (data?.scheduleResourceUsage ??
93
- null) as Array<Schedule.ScheduleResourceUsageDayGQL> | null,
94
- };
95
- }
96
-
97
- /*
98
- * Read scheduleCalendars with top-level variables aligned to server reset targets.
99
- */
100
- export function useScheduleCalendars(
101
- p: Partial<Schedule.ScheduleCalendarsVariables> | string | null | undefined,
102
- params: UseQueryParams = {},
103
- ) {
104
- const variables: Partial<Schedule.ScheduleCalendarsVariables> =
105
- typeof p === 'string' ? { organizationId: p } : p || {};
106
- const { data, ...rest } = useQuery(documents.scheduleCalendarsQry, {
107
- ...params,
108
- variables: { ...variables, ...params.variables },
109
- skip: !variables.organizationId || !!params.skip,
110
- });
111
- return {
112
- ...rest,
113
- scheduleCalendars: (data?.scheduleCalendars ??
114
- null) as Array<Schedule.ScheduleCalendarGQL> | null,
115
- };
116
- }
117
-
118
- /*
119
- * Read scheduleCalendar with top-level variables aligned to server reset targets.
120
- */
121
- export function useScheduleCalendar(
122
- p: Partial<Schedule.ScheduleCalendarVariables>,
123
- params: UseQueryParams = {},
124
- ) {
125
- const variables: Partial<Schedule.ScheduleCalendarVariables> = p;
126
- const { data, ...rest } = useQuery(documents.scheduleCalendarQry, {
127
- ...params,
128
- variables: { ...variables, ...params.variables },
129
- skip: !variables.calendarId || !!params.skip,
130
- });
131
- return {
132
- ...rest,
133
- scheduleCalendar: (data?.scheduleCalendar ??
134
- null) as Schedule.ScheduleCalendarGQL | null,
135
- };
136
- }
137
-
138
- /*
139
- * Read scheduleOccurrences with top-level variables aligned to server reset targets.
140
- */
141
- export function useScheduleOccurrences(
142
- p: Partial<Schedule.ScheduleOccurrencesVariables>,
143
- params: UseQueryParams = {},
144
- ) {
145
- const variables: Partial<Schedule.ScheduleOccurrencesVariables> = p;
146
- const { data, ...rest } = useQuery(documents.scheduleOccurrencesQry, {
147
- ...params,
148
- variables: { ...variables, ...params.variables },
149
- skip:
150
- !variables.organizationId ||
151
- !variables.calendarId ||
152
- !variables.from ||
153
- !variables.to ||
154
- !!params.skip,
155
- });
156
- return {
157
- ...rest,
158
- scheduleOccurrences: (data?.scheduleOccurrences ??
159
- null) as Schedule.ScheduleOccurrenceWindowGQL | null,
160
- };
161
- }
162
-
163
- /*
164
- * Read scheduleOccurrence with top-level variables aligned to server reset targets.
165
- */
166
- export function useScheduleOccurrence(
167
- p: Partial<Schedule.ScheduleOccurrenceVariables>,
168
- params: UseQueryParams = {},
169
- ) {
170
- const variables: Partial<Schedule.ScheduleOccurrenceVariables> = p;
171
- const { data, ...rest } = useQuery(documents.scheduleOccurrenceQry, {
172
- ...params,
173
- variables: { ...variables, ...params.variables },
174
- skip: !variables.organizationId || !variables.occurrenceId || !!params.skip,
175
- });
176
- return {
177
- ...rest,
178
- scheduleOccurrence: (data?.scheduleOccurrence ??
179
- null) as Schedule.ScheduleOccurrenceGQL | null,
180
- };
181
- }
182
-
183
- /*
184
- * Read scheduleMyShifts with top-level variables aligned to server reset targets.
185
- */
186
- export function useScheduleMyShifts(
187
- p: Partial<Schedule.ScheduleMyShiftsVariables>,
188
- params: UseQueryParams = {},
189
- ) {
190
- const variables: Partial<Schedule.ScheduleMyShiftsVariables> = p;
191
- const { data, ...rest } = useQuery(documents.scheduleMyShiftsQry, {
192
- ...params,
193
- variables: { ...variables, ...params.variables },
194
- skip:
195
- !variables.organizationId ||
196
- !variables.from ||
197
- !variables.to ||
198
- !!params.skip,
199
- });
200
- return {
201
- ...rest,
202
- scheduleMyShifts: (data?.scheduleMyShifts ??
203
- null) as Schedule.ScheduleOccurrenceWindowGQL | null,
204
- };
205
- }
206
-
207
- /*
208
- * Read scheduleOpenShifts with top-level variables aligned to server reset targets.
209
- */
210
- export function useScheduleOpenShifts(
211
- p: Partial<Schedule.ScheduleOpenShiftsVariables>,
212
- params: UseQueryParams = {},
213
- ) {
214
- const variables: Partial<Schedule.ScheduleOpenShiftsVariables> = p;
215
- const { data, ...rest } = useQuery(documents.scheduleOpenShiftsQry, {
216
- ...params,
217
- variables: { ...variables, ...params.variables },
218
- skip:
219
- !variables.organizationId ||
220
- !variables.from ||
221
- !variables.to ||
222
- !!params.skip,
223
- });
224
- return {
225
- ...rest,
226
- scheduleOpenShifts: (data?.scheduleOpenShifts ??
227
- null) as Array<Schedule.ScheduleOpenShiftGQL> | null,
228
- };
229
- }
230
-
231
- /*
232
- * Read scheduleShiftEligibility with top-level variables aligned to server reset targets.
233
- */
234
- export function useScheduleShiftEligibility(
235
- p: Partial<Schedule.ScheduleShiftEligibilityVariables>,
236
- params: UseQueryParams = {},
237
- ) {
238
- const variables: Partial<Schedule.ScheduleShiftEligibilityVariables> = p;
239
- const { data, ...rest } = useQuery(documents.scheduleShiftEligibilityQry, {
240
- ...params,
241
- variables: { ...variables, ...params.variables },
242
- skip: !variables.organizationId || !variables.occurrenceId || !!params.skip,
243
- });
244
- return {
245
- ...rest,
246
- scheduleShiftEligibility: (data?.scheduleShiftEligibility ??
247
- null) as Schedule.ScheduleEligibilityGQL | null,
248
- };
249
- }
250
-
251
- /*
252
- * Read scheduleShiftCandidates with top-level variables aligned to server reset targets.
253
- */
254
- export function useScheduleShiftCandidates(
255
- p: Partial<Schedule.ScheduleShiftCandidatesVariables>,
256
- params: UseQueryParams = {},
257
- ) {
258
- const variables: Partial<Schedule.ScheduleShiftCandidatesVariables> = p;
259
- const { data, ...rest } = useQuery(documents.scheduleShiftCandidatesQry, {
260
- ...params,
261
- variables: { ...variables, ...params.variables },
262
- skip: !variables.organizationId || !variables.occurrenceId || !!params.skip,
263
- });
264
- return {
265
- ...rest,
266
- scheduleShiftCandidates: (data?.scheduleShiftCandidates ??
267
- null) as Array<Schedule.ScheduleShiftCandidateGQL> | null,
268
- };
269
- }
270
-
271
- /*
272
- * Read scheduleSeriesList with top-level variables aligned to server reset targets.
273
- */
274
- export function useScheduleSeriesList(
275
- p: Partial<Schedule.ScheduleSeriesListVariables>,
276
- params: UseQueryParams = {},
277
- ) {
278
- const variables: Partial<Schedule.ScheduleSeriesListVariables> = p;
279
- const { data, ...rest } = useQuery(documents.scheduleSeriesListQry, {
280
- ...params,
281
- variables: { ...variables, ...params.variables },
282
- skip: !variables.organizationId || !variables.calendarId || !!params.skip,
283
- });
284
- return {
285
- ...rest,
286
- scheduleSeriesList: (data?.scheduleSeriesList ??
287
- null) as Array<Schedule.ScheduleSeriesGQL> | null,
288
- };
289
- }
290
-
291
- /*
292
- * Read scheduleDemands with top-level variables aligned to server reset targets.
293
- */
294
- export function useScheduleDemands(
295
- p: Partial<Schedule.ScheduleDemandsVariables>,
296
- params: UseQueryParams = {},
297
- ) {
298
- const variables: Partial<Schedule.ScheduleDemandsVariables> = p;
299
- const { data, ...rest } = useQuery(documents.scheduleDemandsQry, {
300
- ...params,
301
- variables: { ...variables, ...params.variables },
302
- skip:
303
- !variables.organizationId ||
304
- !variables.calendarId ||
305
- !variables.from ||
306
- !variables.to ||
307
- !!params.skip,
308
- });
309
- return {
310
- ...rest,
311
- scheduleDemands: (data?.scheduleDemands ??
312
- null) as Array<Schedule.ScheduleDemandGQL> | null,
7
+ type ScheduleQueryResult<K extends string, R> = Omit<
8
+ ReturnType<typeof useQuery>,
9
+ 'data'
10
+ > &
11
+ Record<K, R | null>;
12
+
13
+ /*
14
+ * Compose one schedule read hook. Variables stay top-level so they line up
15
+ * with the scope keys of the server's changes; the query is skipped until every
16
+ * required variable is set. A string argument fills the first required variable.
17
+ */
18
+ function composeScheduleQueryHook<V extends object, R, K extends string>(
19
+ document: DocumentNode,
20
+ resultKey: K,
21
+ requiredKeys: Array<keyof V & string>,
22
+ ) {
23
+ /*
24
+ * Read one schedule query and return its result under the query's name.
25
+ */
26
+ return function useScheduleQuery(
27
+ p: Partial<V> | string | null | undefined,
28
+ params: UseQueryParams = {},
29
+ ): ScheduleQueryResult<K, R> {
30
+ const variables = (
31
+ typeof p === 'string' ? { [requiredKeys[0]]: p } : p || {}
32
+ ) as Partial<V>;
33
+ const { data, ...rest } = useQuery(document, {
34
+ ...params,
35
+ variables: { ...variables, ...params.variables },
36
+ skip: requiredKeys.some((key) => !variables[key]) || !!params.skip,
37
+ });
38
+ return {
39
+ ...rest,
40
+ [resultKey]: (data?.[resultKey] ?? null) as R | null,
41
+ } as ScheduleQueryResult<K, R>;
313
42
  };
314
43
  }
315
44
 
316
45
  /*
317
- * Read scheduleRules with top-level variables aligned to server reset targets.
46
+ * Read the organization's work calendars with their dated exceptions.
318
47
  */
319
- export function useScheduleRules(
320
- p: Partial<Schedule.ScheduleRulesVariables> | string | null | undefined,
321
- params: UseQueryParams = {},
322
- ) {
323
- const variables: Partial<Schedule.ScheduleRulesVariables> =
324
- typeof p === 'string' ? { organizationId: p } : p || {};
325
- const { data, ...rest } = useQuery(documents.scheduleRulesQry, {
326
- ...params,
327
- variables: { ...variables, ...params.variables },
328
- skip: !variables.organizationId || !!params.skip,
329
- });
330
- return {
331
- ...rest,
332
- scheduleRules: (data?.scheduleRules ??
333
- null) as Array<Schedule.ScheduleRuleGQL> | null,
334
- };
335
- }
48
+ export const useScheduleWorkCalendars = composeScheduleQueryHook<
49
+ Schedule.ScheduleWorkCalendarsVariables,
50
+ Array<Schedule.ScheduleWorkCalendarGQL>,
51
+ 'scheduleWorkCalendars'
52
+ >(documents.scheduleWorkCalendarsQry, 'scheduleWorkCalendars', [
53
+ 'organizationId',
54
+ ]);
336
55
 
337
56
  /*
338
- * Read scheduleViolations with top-level variables aligned to server reset targets.
57
+ * Read one work calendar with its dated exceptions.
339
58
  */
340
- export function useScheduleViolations(
341
- p: Partial<Schedule.ScheduleViolationsVariables>,
342
- params: UseQueryParams = {},
343
- ) {
344
- const variables: Partial<Schedule.ScheduleViolationsVariables> = p;
345
- const { data, ...rest } = useQuery(documents.scheduleViolationsQry, {
346
- ...params,
347
- variables: { ...variables, ...params.variables },
348
- skip:
349
- !variables.organizationId ||
350
- !variables.calendarId ||
351
- !variables.from ||
352
- !variables.to ||
353
- !!params.skip,
354
- });
355
- return {
356
- ...rest,
357
- scheduleViolations: (data?.scheduleViolations ??
358
- null) as Array<Schedule.ScheduleViolationGQL> | null,
359
- };
360
- }
59
+ export const useScheduleWorkCalendar = composeScheduleQueryHook<
60
+ Schedule.ScheduleWorkCalendarVariables,
61
+ Schedule.ScheduleWorkCalendarGQL,
62
+ 'scheduleWorkCalendar'
63
+ >(documents.scheduleWorkCalendarQry, 'scheduleWorkCalendar', [
64
+ 'organizationId',
65
+ 'workCalendarId',
66
+ ]);
361
67
 
362
68
  /*
363
- * Read schedulePublishPreflight with top-level variables aligned to server reset targets.
69
+ * Read the organization's resources, optionally of some kinds only.
364
70
  */
365
- export function useSchedulePublishPreflight(
366
- p: Partial<Schedule.SchedulePublishPreflightVariables>,
367
- params: UseQueryParams = {},
368
- ) {
369
- const variables: Partial<Schedule.SchedulePublishPreflightVariables> = p;
370
- const { data, ...rest } = useQuery(documents.schedulePublishPreflightQry, {
371
- ...params,
372
- variables: { ...variables, ...params.variables },
373
- skip:
374
- !variables.organizationId ||
375
- !variables.calendarId ||
376
- !variables.from ||
377
- !variables.to ||
378
- !!params.skip,
379
- });
380
- return {
381
- ...rest,
382
- schedulePublishPreflight: (data?.schedulePublishPreflight ??
383
- null) as Schedule.SchedulePublishPreflightGQL | null,
384
- };
385
- }
71
+ export const useScheduleResources = composeScheduleQueryHook<
72
+ Schedule.ScheduleResourcesVariables,
73
+ Array<Schedule.ScheduleResourceGQL>,
74
+ 'scheduleResources'
75
+ >(documents.scheduleResourcesQry, 'scheduleResources', ['organizationId']);
386
76
 
387
77
  /*
388
- * Read schedulePublications with top-level variables aligned to server reset targets.
78
+ * Read one resource with its capacity periods and the viewer's own channels.
389
79
  */
390
- export function useSchedulePublications(
391
- p: Partial<Schedule.SchedulePublicationsVariables>,
392
- params: UseQueryParams = {},
393
- ) {
394
- const variables: Partial<Schedule.SchedulePublicationsVariables> = p;
395
- const { data, ...rest } = useQuery(documents.schedulePublicationsQry, {
396
- ...params,
397
- variables: { ...variables, ...params.variables },
398
- skip: !variables.organizationId || !variables.calendarId || !!params.skip,
399
- });
400
- return {
401
- ...rest,
402
- schedulePublications: (data?.schedulePublications ??
403
- null) as Array<Schedule.SchedulePublicationGQL> | null,
404
- };
405
- }
80
+ export const useScheduleResource = composeScheduleQueryHook<
81
+ Schedule.ScheduleResourceVariables,
82
+ Schedule.ScheduleResourceGQL,
83
+ 'scheduleResource'
84
+ >(documents.scheduleResourceQry, 'scheduleResource', [
85
+ 'organizationId',
86
+ 'resourceId',
87
+ ]);
406
88
 
407
89
  /*
408
- * Read scheduleRequests with top-level variables aligned to server reset targets.
90
+ * Read the activity code types of an organization or one project.
409
91
  */
410
- export function useScheduleRequests(
411
- p: Partial<Schedule.ScheduleRequestsVariables>,
412
- params: UseQueryParams = {},
413
- ) {
414
- const variables: Partial<Schedule.ScheduleRequestsVariables> = p;
415
- const { data, ...rest } = useQuery(documents.scheduleRequestsQry, {
416
- ...params,
417
- variables: { ...variables, ...params.variables },
418
- skip: !variables.organizationId || !!params.skip,
419
- });
420
- return {
421
- ...rest,
422
- scheduleRequests: (data?.scheduleRequests ??
423
- null) as Array<Schedule.ScheduleRequestGQL> | null,
424
- };
425
- }
92
+ export const useScheduleCodeTypes = composeScheduleQueryHook<
93
+ Schedule.ScheduleCodeTypesVariables,
94
+ Array<Schedule.ScheduleCodeTypeGQL>,
95
+ 'scheduleCodeTypes'
96
+ >(documents.scheduleCodeTypesQry, 'scheduleCodeTypes', ['organizationId']);
426
97
 
427
98
  /*
428
- * Read scheduleRequest with top-level variables aligned to server reset targets.
99
+ * Read per-day resource demand and availability for a project histogram.
429
100
  */
430
- export function useScheduleRequest(
431
- p: Partial<Schedule.ScheduleRequestVariables>,
432
- params: UseQueryParams = {},
433
- ) {
434
- const variables: Partial<Schedule.ScheduleRequestVariables> = p;
435
- const { data, ...rest } = useQuery(documents.scheduleRequestQry, {
436
- ...params,
437
- variables: { ...variables, ...params.variables },
438
- skip: !variables.organizationId || !variables.requestId || !!params.skip,
439
- });
440
- return {
441
- ...rest,
442
- scheduleRequest: (data?.scheduleRequest ??
443
- null) as Schedule.ScheduleRequestGQL | null,
444
- };
445
- }
101
+ export const useScheduleResourceUsage = composeScheduleQueryHook<
102
+ Schedule.ScheduleResourceUsageVariables,
103
+ Array<Schedule.ScheduleResourceUsageDayGQL>,
104
+ 'scheduleResourceUsage'
105
+ >(documents.scheduleResourceUsageQry, 'scheduleResourceUsage', [
106
+ 'organizationId',
107
+ 'projectId',
108
+ 'from',
109
+ 'to',
110
+ ]);
446
111
 
447
112
  /*
448
- * Read scheduleTimeOffList with top-level variables aligned to server reset targets.
113
+ * Read the schedule calendars (locations) the viewer can see.
449
114
  */
450
- export function useScheduleTimeOffList(
451
- p: Partial<Schedule.ScheduleTimeOffListVariables>,
452
- params: UseQueryParams = {},
453
- ) {
454
- const variables: Partial<Schedule.ScheduleTimeOffListVariables> = p;
455
- const { data, ...rest } = useQuery(documents.scheduleTimeOffListQry, {
456
- ...params,
457
- variables: { ...variables, ...params.variables },
458
- skip: !variables.organizationId || !!params.skip,
459
- });
460
- return {
461
- ...rest,
462
- scheduleTimeOffList: (data?.scheduleTimeOffList ??
463
- null) as Array<Schedule.ScheduleTimeOffGQL> | null,
464
- };
465
- }
115
+ export const useScheduleCalendars = composeScheduleQueryHook<
116
+ Schedule.ScheduleCalendarsVariables,
117
+ Array<Schedule.ScheduleCalendarGQL>,
118
+ 'scheduleCalendars'
119
+ >(documents.scheduleCalendarsQry, 'scheduleCalendars', ['organizationId']);
466
120
 
467
121
  /*
468
- * Read scheduleProjects with top-level variables aligned to server reset targets.
122
+ * Read one calendar's roster window for calendar-local dates fromDate..toDate:
123
+ * its seats with the roles, rooms and people they name.
469
124
  */
470
- export function useScheduleProjects(
471
- p: Partial<Schedule.ScheduleProjectsVariables> | string | null | undefined,
472
- params: UseQueryParams = {},
473
- ) {
474
- const variables: Partial<Schedule.ScheduleProjectsVariables> =
475
- typeof p === 'string' ? { organizationId: p } : p || {};
476
- const { data, ...rest } = useQuery(documents.scheduleProjectsQry, {
477
- ...params,
478
- variables: { ...variables, ...params.variables },
479
- skip: !variables.organizationId || !!params.skip,
480
- });
481
- return {
482
- ...rest,
483
- scheduleProjects: (data?.scheduleProjects ??
484
- null) as Array<Schedule.ScheduleProjectGQL> | null,
485
- };
486
- }
125
+ export const useScheduleShifts = composeScheduleQueryHook<
126
+ Schedule.ScheduleShiftsVariables,
127
+ Schedule.ScheduleRosterWindowGQL,
128
+ 'scheduleShifts'
129
+ >(documents.scheduleShiftsQry, 'scheduleShifts', [
130
+ 'organizationId',
131
+ 'calendarId',
132
+ 'fromDate',
133
+ 'toDate',
134
+ ]);
487
135
 
488
136
  /*
489
- * Read scheduleProject with top-level variables aligned to server reset targets.
137
+ * Read the viewer's own seats across calendars (identity-authorized).
490
138
  */
491
- export function useScheduleProject(
492
- p: Partial<Schedule.ScheduleProjectVariables> | string | null | undefined,
493
- params: UseQueryParams = {},
494
- ) {
495
- const variables: Partial<Schedule.ScheduleProjectVariables> =
496
- typeof p === 'string' ? { projectId: p } : p || {};
497
- const { data, ...rest } = useQuery(documents.scheduleProjectQry, {
498
- ...params,
499
- variables: { ...variables, ...params.variables },
500
- skip: !variables.projectId || !!params.skip,
501
- });
502
- return {
503
- ...rest,
504
- scheduleProject: (data?.scheduleProject ??
505
- null) as Schedule.ScheduleProjectGQL | null,
506
- };
507
- }
139
+ export const useScheduleMyShifts = composeScheduleQueryHook<
140
+ Schedule.ScheduleMyShiftsVariables,
141
+ Schedule.ScheduleShiftWindowGQL,
142
+ 'scheduleMyShifts'
143
+ >(documents.scheduleMyShiftsQry, 'scheduleMyShifts', [
144
+ 'organizationId',
145
+ 'fromDate',
146
+ 'toDate',
147
+ ]);
508
148
 
509
149
  /*
510
- * Read scheduleProjectNetwork with top-level variables aligned to server reset targets.
150
+ * Read one calendar's stored rule findings for fromDate..toDate.
511
151
  */
512
- export function useScheduleProjectNetwork(
513
- p:
514
- | Partial<Schedule.ScheduleProjectNetworkVariables>
515
- | string
516
- | null
517
- | undefined,
518
- params: UseQueryParams = {},
519
- ) {
520
- const variables: Partial<Schedule.ScheduleProjectNetworkVariables> =
521
- typeof p === 'string' ? { projectId: p } : p || {};
522
- const { data, ...rest } = useQuery(documents.scheduleProjectNetworkQry, {
523
- ...params,
524
- variables: { ...variables, ...params.variables },
525
- skip: !variables.projectId || !!params.skip,
526
- });
527
- return {
528
- ...rest,
529
- scheduleProjectNetwork: (data?.scheduleProjectNetwork ??
530
- null) as Schedule.ScheduleProjectNetworkGQL | null,
531
- };
532
- }
152
+ export const useScheduleViolations = composeScheduleQueryHook<
153
+ Schedule.ScheduleViolationsVariables,
154
+ Array<Schedule.ScheduleViolationGQL>,
155
+ 'scheduleViolations'
156
+ >(documents.scheduleViolationsQry, 'scheduleViolations', [
157
+ 'organizationId',
158
+ 'calendarId',
159
+ 'fromDate',
160
+ 'toDate',
161
+ ]);
533
162
 
534
163
  /*
535
- * Read scheduleProjectRuns with top-level variables aligned to server reset targets.
164
+ * Read time off the viewer may see.
536
165
  */
537
- export function useScheduleProjectRuns(
538
- p: Partial<Schedule.ScheduleProjectRunsVariables> | string | null | undefined,
539
- params: UseQueryParams = {},
540
- ) {
541
- const variables: Partial<Schedule.ScheduleProjectRunsVariables> =
542
- typeof p === 'string' ? { projectId: p } : p || {};
543
- const { data, ...rest } = useQuery(documents.scheduleProjectRunsQry, {
544
- ...params,
545
- variables: { ...variables, ...params.variables },
546
- skip: !variables.projectId || !!params.skip,
547
- });
548
- return {
549
- ...rest,
550
- scheduleProjectRuns: (data?.scheduleProjectRuns ??
551
- null) as Array<Schedule.ScheduleProjectRunGQL> | null,
552
- };
553
- }
166
+ export const useScheduleTimeOffList = composeScheduleQueryHook<
167
+ Schedule.ScheduleTimeOffListVariables,
168
+ Array<Schedule.ScheduleTimeOffGQL>,
169
+ 'scheduleTimeOffList'
170
+ >(documents.scheduleTimeOffListQry, 'scheduleTimeOffList', ['organizationId']);
554
171
 
555
172
  /*
556
- * Read scheduleProjectRun with top-level variables aligned to server reset targets.
173
+ * Read the to-dos of one location (calendarId) or one project (projectId): name
174
+ * exactly one. Default statuses: the open ones.
557
175
  */
558
- export function useScheduleProjectRun(
559
- p: Partial<Schedule.ScheduleProjectRunVariables>,
560
- params: UseQueryParams = {},
561
- ) {
562
- const variables: Partial<Schedule.ScheduleProjectRunVariables> = p;
563
- const { data, ...rest } = useQuery(documents.scheduleProjectRunQry, {
564
- ...params,
565
- variables: { ...variables, ...params.variables },
566
- skip: !variables.projectId || !variables.runId || !!params.skip,
567
- });
568
- return {
569
- ...rest,
570
- scheduleProjectRun: (data?.scheduleProjectRun ??
571
- null) as Schedule.ScheduleProjectRunGQL | null,
572
- };
573
- }
574
-
575
- /*
576
- * Read scheduleBaselines with top-level variables aligned to server reset targets.
577
- */
578
- export function useScheduleBaselines(
579
- p: Partial<Schedule.ScheduleBaselinesVariables> | string | null | undefined,
580
- params: UseQueryParams = {},
581
- ) {
582
- const variables: Partial<Schedule.ScheduleBaselinesVariables> =
583
- typeof p === 'string' ? { projectId: p } : p || {};
584
- const { data, ...rest } = useQuery(documents.scheduleBaselinesQry, {
585
- ...params,
586
- variables: { ...variables, ...params.variables },
587
- skip: !variables.projectId || !!params.skip,
588
- });
589
- return {
590
- ...rest,
591
- scheduleBaselines: (data?.scheduleBaselines ??
592
- null) as Array<Schedule.ScheduleBaselineGQL> | null,
593
- };
594
- }
595
-
596
- /*
597
- * Read scheduleBaselineActivities with top-level variables aligned to server reset targets.
598
- */
599
- export function useScheduleBaselineActivities(
600
- p: Partial<Schedule.ScheduleBaselineActivitiesVariables>,
601
- params: UseQueryParams = {},
602
- ) {
603
- const variables: Partial<Schedule.ScheduleBaselineActivitiesVariables> = p;
604
- const { data, ...rest } = useQuery(documents.scheduleBaselineActivitiesQry, {
605
- ...params,
606
- variables: { ...variables, ...params.variables },
607
- skip: !variables.projectId || !variables.baselineId || !!params.skip,
608
- });
609
- return {
610
- ...rest,
611
- scheduleBaselineActivities: (data?.scheduleBaselineActivities ??
612
- null) as Array<Schedule.ScheduleBaselineActivityGQL> | null,
613
- };
614
- }
615
-
616
- /*
617
- * Read scheduleBaselineVariance with top-level variables aligned to server reset targets.
618
- */
619
- export function useScheduleBaselineVariance(
620
- p: Partial<Schedule.ScheduleBaselineVarianceVariables>,
621
- params: UseQueryParams = {},
622
- ) {
623
- const variables: Partial<Schedule.ScheduleBaselineVarianceVariables> = p;
624
- const { data, ...rest } = useQuery(documents.scheduleBaselineVarianceQry, {
625
- ...params,
626
- variables: { ...variables, ...params.variables },
627
- skip: !variables.projectId || !!params.skip,
628
- });
629
- return {
630
- ...rest,
631
- scheduleBaselineVariance: (data?.scheduleBaselineVariance ??
632
- null) as Schedule.ScheduleBaselineVarianceGQL | null,
633
- };
634
- }
176
+ export const useScheduleTasks = composeScheduleQueryHook<
177
+ Schedule.ScheduleTasksVariables,
178
+ Array<Schedule.ScheduleTaskGQL>,
179
+ 'scheduleTasks'
180
+ >(documents.scheduleTasksQry, 'scheduleTasks', ['organizationId']);
635
181
 
636
182
  /*
637
- * Read scheduleWorkCalendar with top-level variables aligned to server reset targets.
183
+ * Read the viewer's own to-dos across the organization (by their own PERSON).
184
+ * Default statuses: the open ones.
638
185
  */
639
- export function useScheduleWorkCalendar(
640
- p: Partial<Schedule.ScheduleWorkCalendarVariables>,
641
- params: UseQueryParams = {},
642
- ) {
643
- const variables: Partial<Schedule.ScheduleWorkCalendarVariables> = p;
644
- const { data, ...rest } = useQuery(documents.scheduleWorkCalendarQry, {
645
- ...params,
646
- variables: { ...variables, ...params.variables },
647
- skip:
648
- !variables.organizationId || !variables.workCalendarId || !!params.skip,
649
- });
650
- return {
651
- ...rest,
652
- scheduleWorkCalendar: (data?.scheduleWorkCalendar ??
653
- null) as Schedule.ScheduleWorkCalendarGQL | null | null,
654
- };
655
- }
186
+ export const useScheduleMyTasks = composeScheduleQueryHook<
187
+ Schedule.ScheduleMyTasksVariables,
188
+ Array<Schedule.ScheduleTaskGQL>,
189
+ 'scheduleMyTasks'
190
+ >(documents.scheduleMyTasksQry, 'scheduleMyTasks', ['organizationId']);
656
191
 
657
192
  /*
658
- * Read scheduleResource with top-level variables aligned to server reset targets.
193
+ * Read the organization's projects.
659
194
  */
660
- export function useScheduleResource(
661
- p: Partial<Schedule.ScheduleResourceVariables>,
662
- params: UseQueryParams = {},
663
- ) {
664
- const variables: Partial<Schedule.ScheduleResourceVariables> = p;
665
- const { data, ...rest } = useQuery(documents.scheduleResourceQry, {
666
- ...params,
667
- variables: { ...variables, ...params.variables },
668
- skip: !variables.organizationId || !variables.resourceId || !!params.skip,
669
- });
670
- return {
671
- ...rest,
672
- scheduleResource: (data?.scheduleResource ??
673
- null) as Schedule.ScheduleResourceGQL | null | null,
674
- };
675
- }
195
+ export const useScheduleProjects = composeScheduleQueryHook<
196
+ Schedule.ScheduleProjectsVariables,
197
+ Array<Schedule.ScheduleProjectGQL>,
198
+ 'scheduleProjects'
199
+ >(documents.scheduleProjectsQry, 'scheduleProjects', ['organizationId']);
676
200
 
677
201
  /*
678
- * Read scheduleSeries with top-level variables aligned to server reset targets.
202
+ * Read one project's network: WBS, activities, links, assignments and inputs.
679
203
  */
680
- export function useScheduleSeries(
681
- p: Partial<Schedule.ScheduleSeriesVariables>,
682
- params: UseQueryParams = {},
683
- ) {
684
- const variables: Partial<Schedule.ScheduleSeriesVariables> = p;
685
- const { data, ...rest } = useQuery(documents.scheduleSeriesQry, {
686
- ...params,
687
- variables: { ...variables, ...params.variables },
688
- skip: !variables.organizationId || !variables.seriesId || !!params.skip,
689
- });
690
- return {
691
- ...rest,
692
- scheduleSeries: (data?.scheduleSeries ??
693
- null) as Schedule.ScheduleSeriesGQL | null | null,
694
- };
695
- }
204
+ export const useScheduleProjectNetwork = composeScheduleQueryHook<
205
+ Schedule.ScheduleProjectNetworkVariables,
206
+ Schedule.ScheduleProjectNetworkGQL,
207
+ 'scheduleProjectNetwork'
208
+ >(documents.scheduleProjectNetworkQry, 'scheduleProjectNetwork', ['projectId']);
696
209
 
697
210
  /*
698
- * Read scheduleCalendarAccessGrants with top-level variables aligned to server reset targets.
211
+ * Read one project's schedule runs, newest first.
699
212
  */
700
- export function useScheduleCalendarAccessGrants(
701
- p: Partial<Schedule.ScheduleCalendarAccessGrantsVariables>,
702
- params: UseQueryParams = {},
703
- ) {
704
- const variables: Partial<Schedule.ScheduleCalendarAccessGrantsVariables> = p;
705
- const { data, ...rest } = useQuery(
706
- documents.scheduleCalendarAccessGrantsQry,
707
- {
708
- ...params,
709
- variables: { ...variables, ...params.variables },
710
- skip: !variables.organizationId || !variables.calendarId || !!params.skip,
711
- },
712
- );
713
- return {
714
- ...rest,
715
- scheduleCalendarAccessGrants: (data?.scheduleCalendarAccessGrants ??
716
- null) as Array<Schedule.ScheduleDocAccessGrantGQL> | null,
717
- };
718
- }
213
+ export const useScheduleProjectRuns = composeScheduleQueryHook<
214
+ Schedule.ScheduleProjectRunsVariables,
215
+ Array<Schedule.ScheduleProjectRunGQL>,
216
+ 'scheduleProjectRuns'
217
+ >(documents.scheduleProjectRunsQry, 'scheduleProjectRuns', ['projectId']);
719
218
 
720
219
  /*
721
- * Read scheduleProjectAccessGrants with top-level variables aligned to server reset targets.
220
+ * Read one project's baselines.
722
221
  */
723
- export function useScheduleProjectAccessGrants(
724
- p: Partial<Schedule.ScheduleProjectAccessGrantsVariables>,
725
- params: UseQueryParams = {},
726
- ) {
727
- const variables: Partial<Schedule.ScheduleProjectAccessGrantsVariables> = p;
728
- const { data, ...rest } = useQuery(documents.scheduleProjectAccessGrantsQry, {
729
- ...params,
730
- variables: { ...variables, ...params.variables },
731
- skip: !variables.organizationId || !variables.projectId || !!params.skip,
732
- });
733
- return {
734
- ...rest,
735
- scheduleProjectAccessGrants: (data?.scheduleProjectAccessGrants ??
736
- null) as Array<Schedule.ScheduleDocAccessGrantGQL> | null,
737
- };
738
- }
222
+ export const useScheduleBaselines = composeScheduleQueryHook<
223
+ Schedule.ScheduleBaselinesVariables,
224
+ Array<Schedule.ScheduleBaselineGQL>,
225
+ 'scheduleBaselines'
226
+ >(documents.scheduleBaselinesQry, 'scheduleBaselines', ['projectId']);