@jsb188/graphql 1.1.11 → 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.
- package/LICENSE +21 -0
- package/audience.d.ts +205 -0
- package/cache/config.ts +65 -28
- package/cache/index.helpers.ts +96 -0
- package/cache/index.ts +364 -808
- package/cache/mounted-queries.ts +33 -0
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +107 -22
- package/cache/realtime-fence.ts +47 -0
- package/cache/realtime-live.ts +17 -0
- package/cache/store.ts +22 -64
- package/cache/value.helpers.ts +17 -0
- package/{drafts/store.ts → client/draft-persistence-indexed-db.ts} +19 -3
- package/{drafts/index.ts → client/draft-persistence.ts} +13 -39
- package/client/index.ts +4 -2
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +122 -232
- package/client/storage-asset.ts +58 -0
- package/gql/fragments/accountAuthFragments.ts +0 -4
- package/gql/fragments/agentMemoryFragments.ts +5 -1
- package/gql/fragments/agentNoteFragments.ts +156 -0
- package/gql/fragments/aiChatFragments.ts +35 -11
- package/gql/fragments/aiChatLinkFragments.ts +8 -0
- package/gql/fragments/audienceFragments.ts +76 -0
- package/gql/fragments/dataTableFragments.ts +48 -80
- package/gql/fragments/emailFragments.ts +49 -21
- package/gql/fragments/emailOutreachFragments.ts +281 -0
- package/gql/fragments/fieldDocFragments.ts +222 -40
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/libraryFragments.ts +120 -0
- package/gql/fragments/logFragments.ts +93 -2
- package/gql/fragments/organizationFragments.ts +12 -0
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +574 -145
- package/gql/fragments/sheetFragments.ts +86 -424
- package/gql/fragments/storageFragments.ts +25 -1
- package/gql/fragments/workWaitFragments.ts +13 -0
- package/gql/fragments/workflowFragments.ts +32 -4
- package/gql/mutations/agentMemoryMutations.ts +32 -0
- package/gql/mutations/agentNoteMutations.ts +64 -0
- package/gql/mutations/aiChatLinkMutations.ts +13 -0
- package/gql/mutations/aiChatMutations.ts +34 -4
- package/gql/mutations/audienceMutations.ts +58 -0
- package/gql/mutations/authMutations.ts +24 -28
- package/gql/mutations/billingMutations.ts +24 -0
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +18 -75
- package/gql/mutations/emailMutations.ts +22 -0
- package/gql/mutations/emailOutreachMutations.ts +139 -0
- package/gql/mutations/fieldDocMutations.ts +162 -13
- package/gql/mutations/index.ts +10 -5
- package/gql/mutations/organizationMutations.ts +6 -0
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +389 -417
- package/gql/mutations/sheetMutations.ts +62 -118
- package/gql/mutations/storageMutations.ts +1 -1
- package/gql/mutations/workflowMutations.ts +94 -0
- package/gql/queries/agentMemoryQueries.ts +12 -2
- package/gql/queries/agentNoteQueries.ts +86 -0
- package/gql/queries/aiChatQueries.ts +63 -12
- package/gql/queries/audienceQueries.ts +104 -0
- package/gql/queries/authQueries.ts +20 -4
- package/gql/queries/billingQueries.ts +114 -9
- package/gql/queries/dataTableQueries.ts +43 -75
- package/gql/queries/emailOutreachQueries.ts +282 -0
- package/gql/queries/emailQueries.ts +48 -64
- package/gql/queries/emailReplyReportQueries.ts +127 -0
- package/gql/queries/fieldDocQueries.ts +128 -98
- package/gql/queries/inboundContactQueries.ts +15 -4
- package/gql/queries/index.ts +5 -3
- package/gql/queries/libraryQueries.ts +112 -0
- package/gql/queries/logQueries.ts +86 -12
- package/gql/queries/organizationQueries.ts +44 -12
- package/gql/queries/qrCodeQueries.ts +27 -0
- package/gql/queries/scheduleQueries.ts +401 -278
- package/gql/queries/sheetQueries.ts +94 -165
- package/gql/queries/storageQueries.ts +11 -4
- package/gql/queries/workflowQueries.ts +61 -12
- package/gql/reactivity.ts +98 -0
- package/gql/recordReads.ts +171 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +920 -715
- package/hooks/use-agentMemory-mtn.ts +29 -31
- package/hooks/use-agentMemory-qry.ts +15 -3
- package/hooks/use-agentNote-mtn.ts +89 -0
- package/hooks/use-agentNote-qry.ts +162 -0
- package/hooks/use-agentNote-recovery.helpers.ts +58 -0
- package/hooks/use-agentNote-recovery.ts +57 -0
- package/hooks/use-aiChat-mtn.ts +104 -115
- package/hooks/use-aiChat-qry.helpers.ts +124 -0
- package/hooks/use-aiChat-qry.ts +254 -387
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- package/hooks/use-audience-mtn.ts +170 -0
- package/hooks/use-audience-qry.helpers.ts +39 -0
- package/hooks/use-audience-qry.ts +245 -0
- package/hooks/use-auth-mtn.ts +30 -1
- package/hooks/use-billing-mtn.ts +31 -0
- package/hooks/use-billing-qry.ts +76 -0
- package/hooks/use-dataTable-mtn.ts +23 -115
- package/hooks/use-dataTable-qry.ts +69 -914
- package/hooks/use-email-mtn.ts +26 -0
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +44 -174
- package/hooks/use-emailOutreach-mtn.ts +211 -0
- package/hooks/use-emailOutreach-qry.helpers.ts +25 -0
- package/hooks/use-emailOutreach-qry.ts +367 -0
- package/hooks/use-emailOutreachReplyReport-qry.ts +46 -0
- package/hooks/use-fieldDoc-mtn.ts +244 -32
- package/hooks/use-fieldDoc-qry.helpers.ts +49 -0
- package/hooks/use-fieldDoc-qry.ts +134 -102
- package/hooks/use-inboundContact-qry.ts +7 -9
- package/hooks/use-library-qry.ts +233 -0
- package/hooks/use-log-mtn.ts +25 -12
- package/hooks/use-log-qry.ts +99 -46
- package/hooks/use-organization-qry.ts +16 -60
- package/hooks/use-qrCode-mtn.ts +40 -0
- package/hooks/use-qrCode-qry.ts +78 -0
- package/hooks/use-schedule-mtn.ts +231 -348
- package/hooks/use-schedule-qry.ts +208 -139
- package/hooks/use-schedule-reactive.ts +218 -0
- package/hooks/use-sheet-mtn.ts +91 -199
- package/hooks/use-sheet-qry.ts +88 -237
- package/hooks/use-storage-qry.ts +84 -61
- package/hooks/use-workflow-mtn.ts +84 -23
- package/hooks/use-workflow-qry.ts +60 -61
- package/libs/ai-chat-link-events.ts +78 -0
- 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/data-changes.helpers.ts +161 -0
- package/libs/data-changes.ts +382 -0
- package/libs/fragment-realtime-sequence.ts +55 -0
- package/libs/open-sheet.ts +138 -0
- package/libs/record-read.ts +327 -0
- package/libs/sheet-command-batch.ts +45 -0
- package/libs/sheet-realtime-packet.ts +53 -0
- package/libs/sheet-view-realtime-router.ts +99 -0
- package/loaders/emailPreference.ts +69 -0
- package/loaders/rest.ts +12 -0
- package/package.json +77 -25
- package/schedule.d.ts +1183 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +26 -115
- package/types.d.ts +48 -25
- package/cache/index.test.ts +0 -881
- package/client/data-table-realtime-subscriptions.test.ts +0 -740
- package/client/data-table-realtime-subscriptions.ts +0 -955
- package/client/data-table-realtime.test.ts +0 -792
- package/client/data-table-realtime.ts +0 -1218
- package/client/fragment-realtime-sequence.ts +0 -52
- package/client/open-sheet.ts +0 -137
- package/client/request-managed-session.test.ts +0 -574
- package/client/request-no-store.test.ts +0 -157
- package/client/sse-ticket.test.ts +0 -26
- package/deno.lock +0 -170
- package/deno.test.json +0 -10
- package/gql/fragments/agentDocFragments.ts +0 -46
- package/gql/fragments/billingFragments.ts +0 -14
- package/gql/fragments/campaignFragments.ts +0 -277
- package/gql/mutations/agentDocMutations.ts +0 -177
- package/gql/mutations/campaignMutations.ts +0 -215
- package/gql/queries/agentDocQueries.ts +0 -120
- package/gql/queries/appQueries.ts +0 -14
- package/gql/queries/campaignQueries.ts +0 -127
- package/hooks/use-agentDoc-mtn.ts +0 -285
- package/hooks/use-agentDoc-qry.ts +0 -208
- package/hooks/use-app-qry.ts +0 -22
- package/hooks/use-campaign-mtn.ts +0 -377
- package/hooks/use-campaign-qry.ts +0 -257
- package/loaders/campaign.ts +0 -137
- package/tsconfig.json +0 -13
|
@@ -1,50 +1,262 @@
|
|
|
1
1
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
2
|
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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';
|
|
9
19
|
import { useMutation } from './index.ts';
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
*
|
|
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.
|
|
13
24
|
*/
|
|
14
25
|
|
|
15
|
-
export function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
*/
|
|
20
44
|
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
{
|
|
23
67
|
openModalPopUp,
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
*/
|
|
26
179
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
*/
|
|
38
201
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
});
|
|
43
211
|
|
|
44
212
|
return {
|
|
45
|
-
|
|
213
|
+
editFieldDocSettings,
|
|
46
214
|
updateObservers,
|
|
47
215
|
...mtnValues,
|
|
48
216
|
...mtnHandlers,
|
|
49
217
|
};
|
|
50
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,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
|
+
}
|
|
@@ -1,180 +1,212 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
FieldDocEditSessionGQL,
|
|
3
|
+
FieldDocProgramEnrollmentGQL,
|
|
4
|
+
FieldDocProgramGQL,
|
|
5
|
+
FieldDocSubmissionDocumentGQL,
|
|
6
|
+
FieldDocSubmissionGQL,
|
|
7
|
+
FieldDocSubmissionsFilterArgs,
|
|
4
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';
|
|
5
12
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
useQuery,
|
|
12
|
-
useReactiveFragment,
|
|
13
|
-
useReactiveFragmentMap,
|
|
14
|
-
} from '../client/index.ts';
|
|
15
|
-
import {
|
|
16
|
-
fieldDocGroupsQry,
|
|
17
|
-
fieldDocQry,
|
|
18
|
-
fieldDocsQry,
|
|
13
|
+
fieldDocEditSessionQry,
|
|
14
|
+
fieldDocProgramCatalogQry,
|
|
15
|
+
fieldDocProgramEnrollmentsQry,
|
|
16
|
+
fieldDocSubmissionDocumentQry,
|
|
19
17
|
fieldDocSubmissionsQry,
|
|
20
18
|
} from '../gql/queries/fieldDocQueries.ts';
|
|
21
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
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Get reactive fieldDoc fragment
|
|
24
|
+
* Get reactive fieldDoc program fragment (org-agnostic program fields)
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
export function
|
|
28
|
-
|
|
29
|
-
currentData?: any,
|
|
30
|
-
queryCount?: number,
|
|
31
|
-
) {
|
|
32
|
-
return useReactiveFragment(
|
|
33
|
-
currentData,
|
|
34
|
-
[makeFragmentKey(FRAGMENT_NAMES.fieldDoc, fieldDocId)],
|
|
35
|
-
queryCount,
|
|
36
|
-
);
|
|
27
|
+
export function useReactiveFieldDocProgramFragment(fieldDocProgramId: string, currentData?: any, queryCount?: number) {
|
|
28
|
+
return useReactiveFragment(currentData, [makeFragmentKey(FRAGMENT_NAMES.fieldDocProgram, fieldDocProgramId)], queryCount);
|
|
37
29
|
}
|
|
38
30
|
|
|
39
31
|
/**
|
|
40
|
-
* Get reactive fieldDoc submission fragment
|
|
32
|
+
* Get reactive fieldDoc submission fragment; list rows and the document header share it
|
|
41
33
|
*/
|
|
42
34
|
|
|
43
|
-
export function useReactiveFieldDocSubmissionFragment(
|
|
44
|
-
fieldDocSubmissionId
|
|
45
|
-
currentData?: any,
|
|
46
|
-
queryCount?: number,
|
|
47
|
-
) {
|
|
48
|
-
return useReactiveFragment(
|
|
49
|
-
currentData,
|
|
50
|
-
[makeFragmentKey(FRAGMENT_NAMES.fieldDocSubmission, fieldDocSubmissionId)],
|
|
51
|
-
queryCount,
|
|
52
|
-
);
|
|
35
|
+
export function useReactiveFieldDocSubmissionFragment(fieldDocSubmissionId: string, currentData?: any, queryCount?: number) {
|
|
36
|
+
return useReactiveFragment(currentData, [makeFragmentKey(FRAGMENT_NAMES.fieldDocSubmission, fieldDocSubmissionId)], queryCount);
|
|
53
37
|
}
|
|
54
38
|
|
|
55
39
|
/**
|
|
56
|
-
* Get reactive
|
|
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.
|
|
57
42
|
*/
|
|
58
43
|
|
|
59
|
-
export function
|
|
60
|
-
currentData
|
|
61
|
-
) {
|
|
62
|
-
return useReactiveFragmentMap(
|
|
63
|
-
currentData || null,
|
|
64
|
-
getFragmentBaseName(FRAGMENT_NAMES.fieldDocElementData),
|
|
65
|
-
);
|
|
44
|
+
export function useReactiveFieldDocAnswerFragmentMap(currentData?: any[] | null) {
|
|
45
|
+
return useReactiveFragmentMap(currentData || null, getFragmentBaseName(FRAGMENT_NAMES.fieldDocAnswer));
|
|
66
46
|
}
|
|
67
47
|
|
|
68
48
|
/**
|
|
69
|
-
* Fetch
|
|
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.
|
|
70
52
|
*/
|
|
71
53
|
|
|
72
|
-
export function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
filter: FieldDocsFilterArgs;
|
|
76
|
-
sort?: FieldDocsSortEnum;
|
|
77
|
-
},
|
|
78
|
-
params: UseQueryParams = {},
|
|
54
|
+
export function useFieldDocProgramEnrollments(
|
|
55
|
+
organizationId: string | null | undefined,
|
|
56
|
+
params: UseQueryParams & { fieldDocProgramId?: string | null } = {},
|
|
79
57
|
) {
|
|
80
|
-
const {
|
|
81
|
-
const {
|
|
82
|
-
const { data, ...rest } = useQuery(fieldDocsQry, {
|
|
83
|
-
variables,
|
|
84
|
-
skip:
|
|
85
|
-
skip ||
|
|
86
|
-
!organizationId ||
|
|
87
|
-
!filter?.fieldDocGroupId ||
|
|
88
|
-
!(filter?.startPeriod || filter?.endPeriod),
|
|
58
|
+
const { skip, fieldDocProgramId, ...restParams } = params;
|
|
59
|
+
const { data, ...rest } = useQuery(fieldDocProgramEnrollmentsQry, {
|
|
89
60
|
...restParams,
|
|
61
|
+
variables: {
|
|
62
|
+
organizationId,
|
|
63
|
+
...(fieldDocProgramId ? { fieldDocProgramId } : {}),
|
|
64
|
+
},
|
|
65
|
+
skip: skip || !organizationId,
|
|
90
66
|
});
|
|
91
67
|
|
|
92
68
|
return {
|
|
93
|
-
|
|
69
|
+
fieldDocProgramEnrollments: data?.fieldDocProgramEnrollments as FieldDocProgramEnrollmentGQL[] | null | undefined,
|
|
94
70
|
...rest,
|
|
95
71
|
};
|
|
96
72
|
}
|
|
97
73
|
|
|
98
74
|
/**
|
|
99
|
-
* Fetch
|
|
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.
|
|
100
77
|
*/
|
|
101
78
|
|
|
102
|
-
export function
|
|
103
|
-
organizationId: string | null,
|
|
104
|
-
fieldDocSourceId: string | null,
|
|
105
|
-
params: UseQueryParams = {},
|
|
106
|
-
) {
|
|
79
|
+
export function useFieldDocProgramCatalog(organizationId: string | null | undefined, params: UseQueryParams = {}) {
|
|
107
80
|
const { skip, ...restParams } = params;
|
|
108
|
-
const { data, ...rest } = useQuery(
|
|
81
|
+
const { data, ...rest } = useQuery(fieldDocProgramCatalogQry, {
|
|
82
|
+
...restParams,
|
|
83
|
+
persistTime: params.persistTime ?? 0,
|
|
109
84
|
variables: {
|
|
110
85
|
organizationId,
|
|
111
|
-
fieldDocSourceId,
|
|
112
86
|
},
|
|
113
|
-
skip: skip || !organizationId
|
|
114
|
-
...restParams,
|
|
87
|
+
skip: skip || !organizationId,
|
|
115
88
|
});
|
|
116
89
|
|
|
117
90
|
return {
|
|
118
|
-
|
|
91
|
+
fieldDocProgramCatalog: data?.fieldDocProgramCatalog as FieldDocProgramGQL[] | null | undefined,
|
|
119
92
|
...rest,
|
|
120
93
|
};
|
|
121
94
|
}
|
|
122
95
|
|
|
123
96
|
/**
|
|
124
|
-
* Fetch
|
|
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.
|
|
125
100
|
*/
|
|
126
101
|
|
|
127
|
-
export function
|
|
128
|
-
|
|
102
|
+
export function useFieldDocSubmissions(
|
|
103
|
+
variables: {
|
|
104
|
+
organizationId?: string | null;
|
|
105
|
+
filter?: FieldDocSubmissionsFilterArgs | Record<string, any> | null;
|
|
106
|
+
},
|
|
129
107
|
params: UseQueryParams = {},
|
|
130
108
|
) {
|
|
109
|
+
const { organizationId, filter } = variables;
|
|
131
110
|
const { skip, ...restParams } = params;
|
|
132
|
-
const { data, ...rest } = useQuery(
|
|
133
|
-
|
|
134
|
-
|
|
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
|
+
});
|
|
135
126
|
},
|
|
136
|
-
|
|
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, {
|
|
137
144
|
...restParams,
|
|
145
|
+
variables: {
|
|
146
|
+
fieldDocSubmissionId,
|
|
147
|
+
},
|
|
148
|
+
skip: skip || !fieldDocSubmissionId,
|
|
138
149
|
});
|
|
139
150
|
|
|
140
151
|
return {
|
|
141
|
-
|
|
152
|
+
fieldDocSubmissionDocument: data?.fieldDocSubmissionDocument as FieldDocSubmissionDocumentGQL | null | undefined,
|
|
142
153
|
...rest,
|
|
143
154
|
};
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
/**
|
|
147
|
-
* Fetch
|
|
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 changes sent while offline are lost. editable means the viewer can change the form's structure:
|
|
161
|
+
* a custom doc and an organization manager.
|
|
148
162
|
*/
|
|
149
163
|
|
|
150
|
-
export function
|
|
164
|
+
export function useFieldDocEditSession(
|
|
151
165
|
variables: {
|
|
152
|
-
organizationId
|
|
153
|
-
|
|
154
|
-
sort?: FieldDocsSortEnum;
|
|
155
|
-
limit?: number;
|
|
166
|
+
organizationId?: string | null;
|
|
167
|
+
fieldDocId?: string | null;
|
|
156
168
|
},
|
|
157
169
|
params: UseQueryParams = {},
|
|
158
170
|
) {
|
|
159
|
-
const {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} = variables;
|
|
165
|
-
const { skip, ...restParams } = params;
|
|
166
|
-
const { data, ...rest } = useQuery(fieldDocSubmissionsQry, {
|
|
171
|
+
const { organizationId, fieldDocId } = variables;
|
|
172
|
+
const enabled = !params.skip && !!organizationId && !!fieldDocId;
|
|
173
|
+
const { data, refetch, ...rest } = useQuery(fieldDocEditSessionQry, {
|
|
174
|
+
retryTransientErrors: true,
|
|
175
|
+
...params,
|
|
167
176
|
variables: {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
limit,
|
|
177
|
+
organizationId,
|
|
178
|
+
fieldDocId,
|
|
171
179
|
},
|
|
172
|
-
skip:
|
|
173
|
-
...restParams,
|
|
180
|
+
skip: !enabled,
|
|
174
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);
|
|
175
204
|
|
|
176
205
|
return {
|
|
177
|
-
|
|
206
|
+
fieldDocEditSession,
|
|
207
|
+
editable: manageable && fieldDocEditSession?.fieldDoc?.isProgramDoc === false,
|
|
208
|
+
manageable,
|
|
209
|
+
refetch,
|
|
178
210
|
...rest,
|
|
179
211
|
};
|
|
180
212
|
}
|