@jsb188/graphql 1.1.10 → 1.1.12
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.
- package/audience.d.ts +343 -0
- package/cache/config.ts +98 -50
- package/cache/index.chat-activity.test.ts +119 -0
- package/cache/index.chat.test.ts +92 -0
- package/cache/index.helpers.ts +96 -0
- package/cache/index.regression.test.ts +149 -0
- package/cache/index.test.ts +1017 -127
- package/cache/index.ts +1256 -1269
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +800 -0
- package/cache/store.ts +395 -0
- package/cache/value.helpers.ts +17 -0
- package/client/draft-persistence-indexed-db.ts +413 -0
- package/client/draft-persistence.ts +152 -0
- package/client/index.ts +3 -0
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +870 -164
- package/deno.lock +187 -0
- package/deno.test.json +10 -4
- package/gql/eagerQueryMap.ts +12 -0
- package/gql/fragments/accountAuthFragments.ts +5 -0
- package/gql/fragments/accountFragments.ts +0 -3
- package/gql/fragments/accountSessionFragments.ts +16 -0
- package/gql/fragments/agentMemoryFragments.ts +23 -0
- package/gql/fragments/agentNoteFragments.ts +150 -0
- package/gql/fragments/aiChatFragments.ts +42 -0
- package/gql/fragments/audienceFragments.ts +141 -0
- package/gql/fragments/campaignFragments.ts +566 -0
- package/gql/fragments/dataTableFragments.ts +50 -192
- package/gql/fragments/emailFragments.ts +32 -17
- package/gql/fragments/fieldDocFragments.ts +264 -0
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/logFragments.ts +101 -69
- package/gql/fragments/organizationFragments.ts +53 -5
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +667 -0
- package/gql/fragments/sheetFragments.ts +304 -63
- package/gql/fragments/storageFragments.ts +45 -0
- package/gql/fragments/workflowFragments.ts +41 -5
- package/gql/mutations/accountMutations.ts +0 -2
- package/gql/mutations/agentMemoryMutations.ts +68 -0
- package/gql/mutations/agentNoteMutations.ts +62 -0
- package/gql/mutations/aiChatMutations.ts +49 -4
- package/gql/mutations/audienceMutations.ts +71 -0
- package/gql/mutations/authMutations.ts +203 -18
- package/gql/mutations/billingMutations.ts +17 -27
- package/gql/mutations/campaignMutations.ts +258 -0
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +19 -54
- package/gql/mutations/fieldDocMutations.ts +173 -0
- package/gql/mutations/index.ts +10 -2
- package/gql/mutations/logMutations.ts +6 -29
- package/gql/mutations/organizationMutations.ts +19 -4
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +1121 -0
- package/gql/mutations/sheetMutations.ts +221 -60
- package/gql/mutations/storageMutations.ts +19 -0
- package/gql/mutations/workflowMutations.ts +60 -0
- package/gql/queries/agentMemoryQueries.ts +28 -0
- package/gql/queries/agentNoteQueries.ts +89 -0
- package/gql/queries/aiChatQueries.ts +70 -2
- package/gql/queries/audienceQueries.ts +128 -0
- package/gql/queries/authQueries.ts +47 -0
- package/gql/queries/billingQueries.ts +118 -6
- package/gql/queries/campaignQueries.ts +236 -0
- package/gql/queries/dataTableQueries.ts +61 -13
- package/gql/queries/emailQueries.ts +26 -17
- package/gql/queries/emailReplyReportQueries.ts +76 -0
- package/gql/queries/fieldDocQueries.ts +166 -0
- package/gql/queries/inboundContactQueries.ts +4 -0
- package/gql/queries/index.ts +10 -2
- package/gql/queries/logQueries.ts +68 -30
- package/gql/queries/organizationQueries.ts +65 -1
- package/gql/queries/qrCodeQueries.ts +20 -0
- package/gql/queries/scheduleQueries.ts +691 -0
- package/gql/queries/sheetQueries.ts +244 -26
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +77 -2
- package/hooks/index.helpers.test.ts +50 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +2254 -982
- package/hooks/use-account-mtn.ts +76 -81
- package/hooks/use-agentMemory-mtn.ts +71 -0
- package/hooks/use-agentMemory-qry.ts +56 -0
- package/hooks/use-agentNote-mtn.ts +82 -0
- package/hooks/use-agentNote-qry.ts +190 -0
- package/hooks/use-agentNote-recovery.helpers.test.ts +68 -0
- package/hooks/use-agentNote-recovery.helpers.ts +58 -0
- package/hooks/use-agentNote-recovery.ts +72 -0
- package/hooks/use-aiChat-mtn.ts +220 -141
- package/hooks/use-aiChat-qry.helpers.test.ts +63 -0
- package/hooks/use-aiChat-qry.helpers.ts +124 -0
- package/hooks/use-aiChat-qry.ts +341 -237
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- package/hooks/use-app-qry.ts +12 -9
- package/hooks/use-audience-mtn.ts +194 -0
- package/hooks/use-audience-qry.helpers.test.ts +80 -0
- package/hooks/use-audience-qry.helpers.ts +63 -0
- package/hooks/use-audience-qry.ts +330 -0
- package/hooks/use-auth-mtn.ts +435 -252
- package/hooks/use-auth-qry.ts +51 -0
- package/hooks/use-billing-mtn.ts +31 -0
- package/hooks/use-billing-qry.ts +76 -0
- package/hooks/use-campaign-generation-recovery.ts +53 -0
- package/hooks/use-campaign-mtn.ts +436 -0
- package/hooks/use-campaign-qry.helpers.ts +40 -0
- package/hooks/use-campaign-qry.ts +834 -0
- package/hooks/use-dataTable-mtn.ts +37 -46
- package/hooks/use-dataTable-qry.ts +102 -128
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +56 -86
- package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
- package/hooks/use-fieldDoc-mtn.ts +262 -0
- package/hooks/use-fieldDoc-qry.helpers.test.ts +65 -0
- package/hooks/use-fieldDoc-qry.helpers.ts +49 -0
- package/hooks/use-fieldDoc-qry.ts +212 -0
- package/hooks/use-inboundContact-mtn.ts +19 -16
- package/hooks/use-inboundContact-qry.ts +62 -56
- package/hooks/use-integration-mtn.ts +56 -38
- package/hooks/use-integration-qry.ts +24 -9
- package/hooks/use-log-mtn.ts +88 -59
- package/hooks/use-log-qry.ts +150 -73
- package/hooks/use-organization-mtn.ts +334 -277
- package/hooks/use-organization-qry.ts +155 -129
- package/hooks/use-publicFormEmail-mtn.ts +27 -0
- package/hooks/use-qrCode-mtn.ts +40 -0
- package/hooks/use-qrCode-qry.ts +78 -0
- package/hooks/use-schedule-mtn.ts +589 -0
- package/hooks/use-schedule-qry.ts +738 -0
- package/hooks/use-schedule-reactive.ts +486 -0
- package/hooks/use-sheet-mtn.ts +157 -79
- package/hooks/use-sheet-qry.ts +221 -92
- package/hooks/use-storage-mtn.ts +81 -41
- package/hooks/use-storage-qry.ts +128 -14
- package/hooks/use-workflow-mtn.ts +72 -0
- package/hooks/use-workflow-qry.ts +184 -47
- package/libs/ai-chat-outgoing.helpers.ts +153 -0
- package/libs/ai-chat-outgoing.ts +11 -0
- package/libs/ai-chat-outgoing.types.ts +25 -0
- package/libs/ai-chat-run-realtime.ts +20 -0
- package/libs/ai-chat-submission-realtime.ts +150 -0
- package/libs/fragment-realtime-sequence.ts +55 -0
- package/libs/fragment-recovery.test.ts +326 -0
- package/libs/fragment-recovery.ts +325 -0
- package/libs/open-sheet.ts +138 -0
- package/libs/orchestrator-realtime.helpers.test.ts +229 -0
- package/libs/orchestrator-realtime.helpers.ts +317 -0
- package/libs/orchestrator-realtime.ts +433 -0
- package/libs/request-cache-regression.test.ts +122 -0
- package/libs/request-managed-session.test.ts +574 -0
- package/libs/request-no-store.test.ts +419 -0
- package/libs/sheet-command-batch.ts +44 -0
- package/libs/sheet-view-realtime-router.test.ts +214 -0
- package/libs/sheet-view-realtime-router.ts +99 -0
- package/libs/sse-ticket.test.ts +26 -0
- package/loaders/campaign.test.ts +186 -0
- package/loaders/campaign.ts +110 -0
- package/loaders/emailPreference.ts +75 -0
- package/loaders/rest.ts +12 -0
- package/package.json +119 -71
- package/schedule.d.ts +1790 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +70 -106
- package/tests/agent-note-detail-cache.test.ts +120 -0
- package/tests/agent-note-search.test.ts +444 -0
- package/tsconfig.json +11 -10
- package/types.d.ts +77 -26
- package/utils.ts +78 -49
- package/gql/fragments/billingFragments.ts +0 -25
- package/gql/fragments/productFragments.ts +0 -39
- package/gql/fragments/reportFragments.ts +0 -90
- package/gql/queries/productQueries.ts +0 -31
- package/gql/queries/reportQueries.ts +0 -134
- package/hooks/use-product-qry.ts +0 -67
- package/hooks/use-report-qry.ts +0 -153
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
+
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
+
import {
|
|
4
|
+
archiveFieldDocMtn,
|
|
5
|
+
createFieldDocProgramGroupMtn,
|
|
6
|
+
editFieldDocProgramGroupMtn,
|
|
7
|
+
deleteFieldDocProgramGroupMtn,
|
|
8
|
+
editFieldDocPlacementMtn,
|
|
9
|
+
createFieldDocProgramMtn,
|
|
10
|
+
deleteFieldDocSubmissionMtn,
|
|
11
|
+
editFieldDocCustomInstructionsMtn,
|
|
12
|
+
editFieldDocMtn,
|
|
13
|
+
editFieldDocProgramMtn,
|
|
14
|
+
editFieldDocSettingsMtn,
|
|
15
|
+
enrollFieldDocProgramMtn,
|
|
16
|
+
restoreFieldDocProgramEnrollmentMtn,
|
|
17
|
+
unenrollFieldDocProgramMtn,
|
|
18
|
+
} from '../gql/mutations/fieldDocMutations.ts';
|
|
19
|
+
import { useMutation } from './index.ts';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Enroll the organization in a catalog program (idempotent; an archived enrollment must be restored instead). The
|
|
23
|
+
* enrollment list updates through the server's fieldDocProgramEnrollments reset.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export function useEnrollFieldDocProgram(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
27
|
+
const [enrollFieldDocProgram, mtnValues, mtnHandlers, updateObservers] = useMutation(enrollFieldDocProgramMtn, {
|
|
28
|
+
openModalPopUp,
|
|
29
|
+
...params,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
enrollFieldDocProgram,
|
|
34
|
+
updateObservers,
|
|
35
|
+
...mtnValues,
|
|
36
|
+
...mtnHandlers,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Unenroll the organization from a program. The enrollment is archived and can be restored until the retention
|
|
42
|
+
* window purges it; the lists update through the server's resets.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
export function useUnenrollFieldDocProgram(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
46
|
+
const [unenrollFieldDocProgram, mtnValues, mtnHandlers, updateObservers] = useMutation(unenrollFieldDocProgramMtn, {
|
|
47
|
+
openModalPopUp,
|
|
48
|
+
...params,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
unenrollFieldDocProgram,
|
|
53
|
+
updateObservers,
|
|
54
|
+
...mtnValues,
|
|
55
|
+
...mtnHandlers,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Restore an archived enrollment before the retention window purges it, resuming the workflows its unenroll paused.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
export function useRestoreFieldDocProgramEnrollment(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
64
|
+
const [restoreFieldDocProgramEnrollment, mtnValues, mtnHandlers, updateObservers] = useMutation(
|
|
65
|
+
restoreFieldDocProgramEnrollmentMtn,
|
|
66
|
+
{
|
|
67
|
+
openModalPopUp,
|
|
68
|
+
...params,
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
restoreFieldDocProgramEnrollment,
|
|
74
|
+
updateObservers,
|
|
75
|
+
...mtnValues,
|
|
76
|
+
...mtnHandlers,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Create a custom program in the organization; the result is the new enrollment.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
export function useCreateFieldDocProgram(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
85
|
+
const [createFieldDocProgram, mtnValues, mtnHandlers, updateObservers] = useMutation(createFieldDocProgramMtn, {
|
|
86
|
+
openModalPopUp,
|
|
87
|
+
...params,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
createFieldDocProgram,
|
|
92
|
+
updateObservers,
|
|
93
|
+
...mtnValues,
|
|
94
|
+
...mtnHandlers,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Edit one of the organization's custom programs (catalog programs are read-only).
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export function useEditFieldDocProgram(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
103
|
+
const [editFieldDocProgram, mtnValues, mtnHandlers, updateObservers] = useMutation(editFieldDocProgramMtn, {
|
|
104
|
+
openModalPopUp,
|
|
105
|
+
...params,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
editFieldDocProgram,
|
|
110
|
+
updateObservers,
|
|
111
|
+
...mtnValues,
|
|
112
|
+
...mtnHandlers,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Save the organization's custom instructions for a program doc (last writer wins per key). The result is the edit
|
|
118
|
+
* session with the same selection and id, so it updates the cached session that useFieldDocEditSession reads.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
export function useEditFieldDocCustomInstructions(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
122
|
+
const { onCompleted, ...rest } = params;
|
|
123
|
+
const [editFieldDocCustomInstructions, mtnValues, mtnHandlers, updateObservers] = useMutation(editFieldDocCustomInstructionsMtn, {
|
|
124
|
+
openModalPopUp,
|
|
125
|
+
onCompleted: (data: any, error: any, variables: any) => {
|
|
126
|
+
onCompleted?.(data?.editFieldDocCustomInstructions, error, variables);
|
|
127
|
+
},
|
|
128
|
+
...rest,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
editFieldDocCustomInstructions,
|
|
133
|
+
updateObservers,
|
|
134
|
+
...mtnValues,
|
|
135
|
+
...mtnHandlers,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Archive a custom fieldDoc; it and its submissions leave every list, and the server deletes them permanently after
|
|
141
|
+
* the retention window. There is no restore.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
export function useArchiveFieldDoc(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
145
|
+
const [archiveFieldDoc, mtnValues, mtnHandlers, updateObservers] = useMutation(archiveFieldDocMtn, {
|
|
146
|
+
openModalPopUp,
|
|
147
|
+
...params,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
archiveFieldDoc,
|
|
152
|
+
updateObservers,
|
|
153
|
+
...mtnValues,
|
|
154
|
+
...mtnHandlers,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Permanently delete one fieldDoc submission.
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
export function useDeleteFieldDocSubmission(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
163
|
+
const [deleteFieldDocSubmission, mtnValues, mtnHandlers, updateObservers] = useMutation(deleteFieldDocSubmissionMtn, {
|
|
164
|
+
openModalPopUp,
|
|
165
|
+
...params,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
deleteFieldDocSubmission,
|
|
170
|
+
updateObservers,
|
|
171
|
+
...mtnValues,
|
|
172
|
+
...mtnHandlers,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Apply a versioned editor patch to one form's unpublished draft.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
export function useEditFieldDoc(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
181
|
+
const { onCompleted, ...rest } = params;
|
|
182
|
+
const [editFieldDoc, mtnValues, mtnHandlers, updateObservers] = useMutation(editFieldDocMtn, {
|
|
183
|
+
openModalPopUp,
|
|
184
|
+
onCompleted: (data: any, error: any, variables: any) => {
|
|
185
|
+
onCompleted?.(data?.editFieldDoc, error, variables);
|
|
186
|
+
},
|
|
187
|
+
...rest,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
editFieldDoc,
|
|
192
|
+
updateObservers,
|
|
193
|
+
...mtnValues,
|
|
194
|
+
...mtnHandlers,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Publish or discard one form's editor draft.
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
export function useEditFieldDocSettings(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
203
|
+
const { onCompleted, ...rest } = params;
|
|
204
|
+
const [editFieldDocSettings, mtnValues, mtnHandlers, updateObservers] = useMutation(editFieldDocSettingsMtn, {
|
|
205
|
+
openModalPopUp,
|
|
206
|
+
onCompleted: (data: any, error: any, variables: any) => {
|
|
207
|
+
onCompleted?.(data?.editFieldDocSettings, error, variables);
|
|
208
|
+
},
|
|
209
|
+
...rest,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
editFieldDocSettings,
|
|
214
|
+
updateObservers,
|
|
215
|
+
...mtnValues,
|
|
216
|
+
...mtnHandlers,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/*
|
|
221
|
+
* Create one group in an organization-owned program.
|
|
222
|
+
*/
|
|
223
|
+
export function useCreateFieldDocProgramGroup(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
224
|
+
const [createFieldDocProgramGroup, mtnValues, mtnHandlers, updateObservers] = useMutation(createFieldDocProgramGroupMtn, {
|
|
225
|
+
openModalPopUp,
|
|
226
|
+
...params,
|
|
227
|
+
});
|
|
228
|
+
return { createFieldDocProgramGroup, updateObservers, ...mtnValues, ...mtnHandlers };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/*
|
|
232
|
+
* Rename or reorder one group in an organization-owned program.
|
|
233
|
+
*/
|
|
234
|
+
export function useEditFieldDocProgramGroup(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
235
|
+
const [editFieldDocProgramGroup, mtnValues, mtnHandlers, updateObservers] = useMutation(editFieldDocProgramGroupMtn, {
|
|
236
|
+
openModalPopUp,
|
|
237
|
+
...params,
|
|
238
|
+
});
|
|
239
|
+
return { editFieldDocProgramGroup, updateObservers, ...mtnValues, ...mtnHandlers };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/*
|
|
243
|
+
* Delete a group and move its forms to ungrouped.
|
|
244
|
+
*/
|
|
245
|
+
export function useDeleteFieldDocProgramGroup(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
246
|
+
const [deleteFieldDocProgramGroup, mtnValues, mtnHandlers, updateObservers] = useMutation(deleteFieldDocProgramGroupMtn, {
|
|
247
|
+
openModalPopUp,
|
|
248
|
+
...params,
|
|
249
|
+
});
|
|
250
|
+
return { deleteFieldDocProgramGroup, updateObservers, ...mtnValues, ...mtnHandlers };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/*
|
|
254
|
+
* Change form placement without editing its published definition.
|
|
255
|
+
*/
|
|
256
|
+
export function useEditFieldDocPlacement(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
257
|
+
const [editFieldDocPlacement, mtnValues, mtnHandlers, updateObservers] = useMutation(editFieldDocPlacementMtn, {
|
|
258
|
+
openModalPopUp,
|
|
259
|
+
...params,
|
|
260
|
+
});
|
|
261
|
+
return { editFieldDocPlacement, updateObservers, ...mtnValues, ...mtnHandlers };
|
|
262
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getFieldDocSubmissionsVariables, normalizeFieldDocSubmissionsFilter } from './use-fieldDoc-qry.helpers.ts';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Throw one readable test failure when a condition is false.
|
|
5
|
+
*/
|
|
6
|
+
function expect(value: unknown, message: string) {
|
|
7
|
+
if (!value) {
|
|
8
|
+
throw new Error(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Deno.test('the submissions filter keeps only FieldDocSubmissionsFilter fields', () => {
|
|
13
|
+
const filter = normalizeFieldDocSubmissionsFilter({
|
|
14
|
+
fieldDocProgramId: 'P1',
|
|
15
|
+
fieldDocIds: ['D1', 'D2'],
|
|
16
|
+
statuses: ['OPEN'],
|
|
17
|
+
startPeriod: '2026-10-01',
|
|
18
|
+
siteId: '',
|
|
19
|
+
sort: 'PERIOD_DESC',
|
|
20
|
+
startDate: '2026-10-01',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
expect(
|
|
24
|
+
JSON.stringify(filter) ===
|
|
25
|
+
JSON.stringify({
|
|
26
|
+
fieldDocProgramId: 'P1',
|
|
27
|
+
fieldDocIds: ['D1', 'D2'],
|
|
28
|
+
siteId: null,
|
|
29
|
+
statuses: ['OPEN'],
|
|
30
|
+
startPeriod: '2026-10-01',
|
|
31
|
+
endPeriod: null,
|
|
32
|
+
}),
|
|
33
|
+
'URL-only keys are dropped and every input field is present in one fixed order.',
|
|
34
|
+
);
|
|
35
|
+
expect(
|
|
36
|
+
JSON.stringify(normalizeFieldDocSubmissionsFilter({ fieldDocProgramId: 'P1' })) ===
|
|
37
|
+
JSON.stringify(normalizeFieldDocSubmissionsFilter({ fieldDocProgramId: 'P1', preset: 'x' })),
|
|
38
|
+
'Equal filters build equal variables, so every consumer shares one cache entry.',
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
Deno.test('the first page and fetchMore follow the logEntries cursor contract', () => {
|
|
43
|
+
const first = getFieldDocSubmissionsVariables({ organizationId: 'O1', filter: { fieldDocProgramId: 'P1' } });
|
|
44
|
+
expect(
|
|
45
|
+
first.cursor === null && first.after === true && first.limit === 100 && first.organizationId === 'O1',
|
|
46
|
+
'The first page has no cursor, after true and the fixed limit.',
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const next = getFieldDocSubmissionsVariables({
|
|
50
|
+
organizationId: 'O1',
|
|
51
|
+
filter: { fieldDocProgramId: 'P1' },
|
|
52
|
+
cursor: 'C1',
|
|
53
|
+
after: false,
|
|
54
|
+
limit: 40,
|
|
55
|
+
sort: 'PERIOD_DESC',
|
|
56
|
+
} as any);
|
|
57
|
+
expect(
|
|
58
|
+
next.cursor === 'C1' && next.after === false && next.limit === 40,
|
|
59
|
+
'fetchMore keeps the row cursor, the direction and the requested page size.',
|
|
60
|
+
);
|
|
61
|
+
expect(
|
|
62
|
+
JSON.stringify(Object.keys(next)) === JSON.stringify(['organizationId', 'filter', 'cursor', 'after', 'limit']),
|
|
63
|
+
'Only the declared query variables are sent; the route table sort is dropped.',
|
|
64
|
+
);
|
|
65
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { FieldDocSubmissionsFilterArgs } from '@jsb188/mday/types/fieldDoc.d.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Types
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface FieldDocSubmissionsVariables {
|
|
8
|
+
organizationId: string | null;
|
|
9
|
+
filter: FieldDocSubmissionsFilterArgs;
|
|
10
|
+
cursor: string | null;
|
|
11
|
+
after: boolean;
|
|
12
|
+
limit: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Keep a list filter aligned with the FieldDocSubmissionsFilter input shape. Route table filters can carry
|
|
17
|
+
* URL-only keys, and one unknown input field fails the whole query.
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeFieldDocSubmissionsFilter(filter?: Record<string, any> | null): FieldDocSubmissionsFilterArgs {
|
|
20
|
+
return {
|
|
21
|
+
fieldDocProgramId: filter?.fieldDocProgramId || null,
|
|
22
|
+
fieldDocIds: filter?.fieldDocIds || null,
|
|
23
|
+
siteId: filter?.siteId || null,
|
|
24
|
+
statuses: filter?.statuses || null,
|
|
25
|
+
startPeriod: filter?.startPeriod || null,
|
|
26
|
+
endPeriod: filter?.endPeriod || null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Build the fieldDocSubmissions variables with the logEntries cursor contract: the first page has no cursor and
|
|
32
|
+
* after true, and fetchMore sends the last row's cursor with after false for the next older page. The first page
|
|
33
|
+
* limit is fixed at 100 because the limit is part of the query cache key, so every consumer shares one cache entry.
|
|
34
|
+
*/
|
|
35
|
+
export function getFieldDocSubmissionsVariables(p: {
|
|
36
|
+
organizationId?: string | null;
|
|
37
|
+
filter?: Record<string, any> | null;
|
|
38
|
+
cursor?: string | null;
|
|
39
|
+
after?: boolean;
|
|
40
|
+
limit?: number;
|
|
41
|
+
}): FieldDocSubmissionsVariables {
|
|
42
|
+
return {
|
|
43
|
+
organizationId: p.organizationId || null,
|
|
44
|
+
filter: normalizeFieldDocSubmissionsFilter(p.filter),
|
|
45
|
+
cursor: p.cursor ?? null,
|
|
46
|
+
after: p.after ?? true,
|
|
47
|
+
limit: p.limit ?? 100,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FieldDocEditSessionGQL,
|
|
3
|
+
FieldDocProgramEnrollmentGQL,
|
|
4
|
+
FieldDocProgramGQL,
|
|
5
|
+
FieldDocSubmissionDocumentGQL,
|
|
6
|
+
FieldDocSubmissionGQL,
|
|
7
|
+
FieldDocSubmissionsFilterArgs,
|
|
8
|
+
} from '@jsb188/mday/types/fieldDoc.d.ts';
|
|
9
|
+
import { FRAGMENT_NAMES, getFragmentBaseName, makeFragmentKey } from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
10
|
+
import { getFieldDocOrganizationScopedId } from '@jsb188/mday/utils/fieldDoc.ts';
|
|
11
|
+
import { useQuery, useReactiveFragment, useReactiveFragmentMap } from '../client/index.ts';
|
|
12
|
+
import {
|
|
13
|
+
fieldDocEditSessionQry,
|
|
14
|
+
fieldDocProgramCatalogQry,
|
|
15
|
+
fieldDocProgramEnrollmentsQry,
|
|
16
|
+
fieldDocSubmissionDocumentQry,
|
|
17
|
+
fieldDocSubmissionsQry,
|
|
18
|
+
} from '../gql/queries/fieldDocQueries.ts';
|
|
19
|
+
import type { UseQueryParams } from '../types.d.ts';
|
|
20
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
21
|
+
import { getFieldDocSubmissionsVariables } from './use-fieldDoc-qry.helpers.ts';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get reactive fieldDoc program fragment (org-agnostic program fields)
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export function useReactiveFieldDocProgramFragment(fieldDocProgramId: string, currentData?: any, queryCount?: number) {
|
|
28
|
+
return useReactiveFragment(currentData, [makeFragmentKey(FRAGMENT_NAMES.fieldDocProgram, fieldDocProgramId)], queryCount);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get reactive fieldDoc submission fragment; list rows and the document header share it
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export function useReactiveFieldDocSubmissionFragment(fieldDocSubmissionId: string, currentData?: any, queryCount?: number) {
|
|
36
|
+
return useReactiveFragment(currentData, [makeFragmentKey(FRAGMENT_NAMES.fieldDocSubmission, fieldDocSubmissionId)], queryCount);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get reactive answer fragments for a document's answers. The document returns one answer for every answer-bearing
|
|
41
|
+
* key (UNANSWERED included), so every key of the definition is observed.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
export function useReactiveFieldDocAnswerFragmentMap(currentData?: any[] | null) {
|
|
45
|
+
return useReactiveFragmentMap(currentData || null, getFragmentBaseName(FRAGMENT_NAMES.fieldDocAnswer));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Fetch the organization's program enrollments: active ones plus archived ones that can still be restored, each with
|
|
50
|
+
* its program and forms. An optional program scope avoids loading unrelated enrollments. Uses the shared query
|
|
51
|
+
* freshness window; database notifications refresh active queries.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
export function useFieldDocProgramEnrollments(
|
|
55
|
+
organizationId: string | null | undefined,
|
|
56
|
+
params: UseQueryParams & { fieldDocProgramId?: string | null } = {},
|
|
57
|
+
) {
|
|
58
|
+
const { skip, fieldDocProgramId, ...restParams } = params;
|
|
59
|
+
const { data, ...rest } = useQuery(fieldDocProgramEnrollmentsQry, {
|
|
60
|
+
...restParams,
|
|
61
|
+
variables: {
|
|
62
|
+
organizationId,
|
|
63
|
+
...(fieldDocProgramId ? { fieldDocProgramId } : {}),
|
|
64
|
+
},
|
|
65
|
+
skip: skip || !organizationId,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
fieldDocProgramEnrollments: data?.fieldDocProgramEnrollments as FieldDocProgramEnrollmentGQL[] | null | undefined,
|
|
70
|
+
...rest,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Fetch the catalog programs offered to the organization's operation. Enrolled state comes from
|
|
76
|
+
* useFieldDocProgramEnrollments. Revalidates on entry to recover changes missed while disconnected.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
export function useFieldDocProgramCatalog(organizationId: string | null | undefined, params: UseQueryParams = {}) {
|
|
80
|
+
const { skip, ...restParams } = params;
|
|
81
|
+
const { data, ...rest } = useQuery(fieldDocProgramCatalogQry, {
|
|
82
|
+
...restParams,
|
|
83
|
+
persistTime: params.persistTime ?? 0,
|
|
84
|
+
variables: {
|
|
85
|
+
organizationId,
|
|
86
|
+
},
|
|
87
|
+
skip: skip || !organizationId,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
fieldDocProgramCatalog: data?.fieldDocProgramCatalog as FieldDocProgramGQL[] | null | undefined,
|
|
92
|
+
...rest,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Fetch one owner organization's submissions, newest period first, with the logEntries cursor contract
|
|
98
|
+
* (getFieldDocSubmissionsVariables). fetchMore rebuilds its variables the same way, so route table extras
|
|
99
|
+
* (sort, URL-only filter keys) never reach the query.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export function useFieldDocSubmissions(
|
|
103
|
+
variables: {
|
|
104
|
+
organizationId?: string | null;
|
|
105
|
+
filter?: FieldDocSubmissionsFilterArgs | Record<string, any> | null;
|
|
106
|
+
},
|
|
107
|
+
params: UseQueryParams = {},
|
|
108
|
+
) {
|
|
109
|
+
const { organizationId, filter } = variables;
|
|
110
|
+
const { skip, ...restParams } = params;
|
|
111
|
+
const { data, fetchMore, ...rest } = useQuery(fieldDocSubmissionsQry, {
|
|
112
|
+
...restParams,
|
|
113
|
+
variables: getFieldDocSubmissionsVariables({ organizationId, filter }),
|
|
114
|
+
skip: skip || !organizationId || !filter,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Request one more page with the same declared variables as the first page; omitted ones keep the hook's values.
|
|
119
|
+
*/
|
|
120
|
+
const fetchMoreSubmissions = useCallback(
|
|
121
|
+
(options: any) => {
|
|
122
|
+
return fetchMore({
|
|
123
|
+
...options,
|
|
124
|
+
variables: getFieldDocSubmissionsVariables({ organizationId, filter, ...options?.variables }),
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
[fetchMore, filter, organizationId],
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
fieldDocSubmissions: data?.fieldDocSubmissions as FieldDocSubmissionGQL[] | null | undefined,
|
|
132
|
+
fetchMore: fetchMoreSubmissions,
|
|
133
|
+
...rest,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Fetch one submission's document: the submission, its pinned definition, every answer and the aside
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
export function useFieldDocSubmissionDocument(fieldDocSubmissionId: string | null | undefined, params: UseQueryParams = {}) {
|
|
142
|
+
const { skip, ...restParams } = params;
|
|
143
|
+
const { data, ...rest } = useQuery(fieldDocSubmissionDocumentQry, {
|
|
144
|
+
...restParams,
|
|
145
|
+
variables: {
|
|
146
|
+
fieldDocSubmissionId,
|
|
147
|
+
},
|
|
148
|
+
skip: skip || !fieldDocSubmissionId,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
fieldDocSubmissionDocument: data?.fieldDocSubmissionDocument as FieldDocSubmissionDocumentGQL | null | undefined,
|
|
153
|
+
...rest,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Fetch one form's web editor session for an organization. The session is read through its fragment, so an
|
|
159
|
+
* editFieldDocCustomInstructions result (same selection, same id) updates it without a refetch. Reconnects refetch
|
|
160
|
+
* it, since realtime resets sent while offline are lost. editable means the viewer can change the form's structure:
|
|
161
|
+
* a custom doc and an organization manager.
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
export function useFieldDocEditSession(
|
|
165
|
+
variables: {
|
|
166
|
+
organizationId?: string | null;
|
|
167
|
+
fieldDocId?: string | null;
|
|
168
|
+
},
|
|
169
|
+
params: UseQueryParams = {},
|
|
170
|
+
) {
|
|
171
|
+
const { organizationId, fieldDocId } = variables;
|
|
172
|
+
const enabled = !params.skip && !!organizationId && !!fieldDocId;
|
|
173
|
+
const { data, refetch, ...rest } = useQuery(fieldDocEditSessionQry, {
|
|
174
|
+
retryTransientErrors: true,
|
|
175
|
+
...params,
|
|
176
|
+
variables: {
|
|
177
|
+
organizationId,
|
|
178
|
+
fieldDocId,
|
|
179
|
+
},
|
|
180
|
+
skip: !enabled,
|
|
181
|
+
});
|
|
182
|
+
const wasConnected = useRef(rest.connectedToServer);
|
|
183
|
+
const sessionId = organizationId && fieldDocId ? getFieldDocOrganizationScopedId(organizationId, fieldDocId) : '';
|
|
184
|
+
const fieldDocEditSession = useReactiveFragment(
|
|
185
|
+
data?.fieldDocEditSession || null,
|
|
186
|
+
sessionId ? [makeFragmentKey(FRAGMENT_NAMES.fieldDocEditSession, sessionId)] : [],
|
|
187
|
+
rest.updatedCount,
|
|
188
|
+
) as FieldDocEditSessionGQL | null;
|
|
189
|
+
|
|
190
|
+
/*
|
|
191
|
+
* Refetch once after the realtime connection comes back.
|
|
192
|
+
*/
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
const reconnected = rest.connectedToServer && !wasConnected.current;
|
|
195
|
+
wasConnected.current = rest.connectedToServer;
|
|
196
|
+
if (enabled && reconnected) {
|
|
197
|
+
void refetch().catch(() => {
|
|
198
|
+
// Query state owns the load error; do not create an unhandled reconnect rejection.
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}, [enabled, refetch, rest.connectedToServer]);
|
|
202
|
+
|
|
203
|
+
const manageable = Boolean(fieldDocEditSession?.manageable);
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
fieldDocEditSession,
|
|
207
|
+
editable: manageable && fieldDocEditSession?.fieldDoc?.isProgramDoc === false,
|
|
208
|
+
manageable,
|
|
209
|
+
refetch,
|
|
210
|
+
...rest,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -8,24 +8,27 @@ import { useMutation } from './index.ts';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export function useEditInboundContact(
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
params: UseMutationParams = {},
|
|
12
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
13
13
|
) {
|
|
14
|
-
|
|
14
|
+
const { onCompleted, ...rest } = params;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const [editInboundContact, mtnValues, mtnHandlers] = useMutation(
|
|
17
|
+
editInboundContactMtn,
|
|
18
|
+
{
|
|
19
|
+
openModalPopUp,
|
|
20
|
+
onCompleted: (data, error, variables) => {
|
|
21
|
+
const updatedInboundContact = data?.editInboundContact;
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
onCompleted?.(updatedInboundContact, error, variables);
|
|
24
|
+
},
|
|
25
|
+
...rest,
|
|
26
|
+
},
|
|
27
|
+
);
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
return {
|
|
30
|
+
editInboundContact,
|
|
31
|
+
...mtnValues,
|
|
32
|
+
...mtnHandlers,
|
|
33
|
+
};
|
|
31
34
|
}
|