@jsb188/graphql 1.1.11 → 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 +58 -24
- 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 +370 -42
- package/cache/index.ts +326 -799
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +98 -19
- 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} +5 -2
- package/client/index.ts +3 -2
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +130 -215
- package/deno.lock +17 -0
- package/deno.test.json +2 -0
- package/gql/fragments/agentMemoryFragments.ts +5 -1
- package/gql/fragments/agentNoteFragments.ts +150 -0
- package/gql/fragments/aiChatFragments.ts +36 -10
- package/gql/fragments/audienceFragments.ts +141 -0
- package/gql/fragments/campaignFragments.ts +415 -126
- package/gql/fragments/dataTableFragments.ts +48 -80
- package/gql/fragments/emailFragments.ts +28 -23
- package/gql/fragments/fieldDocFragments.ts +222 -40
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/logFragments.ts +93 -2
- package/gql/fragments/organizationFragments.ts +10 -0
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +652 -140
- package/gql/fragments/sheetFragments.ts +84 -373
- package/gql/fragments/storageFragments.ts +25 -1
- package/gql/fragments/workflowFragments.ts +13 -1
- package/gql/mutations/agentMemoryMutations.ts +32 -0
- package/gql/mutations/agentNoteMutations.ts +62 -0
- package/gql/mutations/aiChatMutations.ts +36 -4
- package/gql/mutations/audienceMutations.ts +71 -0
- package/gql/mutations/authMutations.ts +45 -1
- package/gql/mutations/billingMutations.ts +24 -0
- package/gql/mutations/campaignMutations.ts +170 -127
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +18 -75
- package/gql/mutations/fieldDocMutations.ts +162 -13
- package/gql/mutations/index.ts +8 -5
- package/gql/mutations/organizationMutations.ts +6 -0
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +1052 -354
- package/gql/mutations/sheetMutations.ts +62 -118
- package/gql/mutations/storageMutations.ts +0 -1
- package/gql/mutations/workflowMutations.ts +18 -0
- package/gql/queries/agentMemoryQueries.ts +6 -0
- package/gql/queries/agentNoteQueries.ts +89 -0
- package/gql/queries/aiChatQueries.ts +56 -4
- package/gql/queries/audienceQueries.ts +128 -0
- package/gql/queries/authQueries.ts +6 -0
- package/gql/queries/billingQueries.ts +95 -6
- package/gql/queries/campaignQueries.ts +132 -23
- package/gql/queries/dataTableQueries.ts +24 -65
- package/gql/queries/emailQueries.ts +18 -61
- package/gql/queries/emailReplyReportQueries.ts +76 -0
- package/gql/queries/fieldDocQueries.ts +100 -92
- package/gql/queries/inboundContactQueries.ts +4 -0
- package/gql/queries/index.ts +3 -1
- package/gql/queries/logQueries.ts +62 -7
- package/gql/queries/organizationQueries.ts +13 -0
- package/gql/queries/qrCodeQueries.ts +20 -0
- package/gql/queries/scheduleQueries.ts +633 -257
- package/gql/queries/sheetQueries.ts +59 -152
- package/gql/queries/workflowQueries.ts +10 -4
- package/hooks/index.helpers.test.ts +50 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +863 -685
- package/hooks/use-agentMemory-mtn.ts +29 -31
- package/hooks/use-agentMemory-qry.ts +15 -3
- 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 +96 -112
- 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 +229 -383
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- 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 +30 -1
- 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 +224 -165
- package/hooks/use-campaign-qry.helpers.ts +40 -0
- package/hooks/use-campaign-qry.ts +631 -54
- package/hooks/use-dataTable-mtn.ts +23 -115
- package/hooks/use-dataTable-qry.ts +66 -916
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +33 -178
- package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
- package/hooks/use-fieldDoc-mtn.ts +244 -32
- 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 +134 -102
- package/hooks/use-inboundContact-qry.ts +7 -9
- 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-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 +506 -333
- package/hooks/use-schedule-qry.ts +682 -101
- package/hooks/use-schedule-reactive.ts +486 -0
- package/hooks/use-sheet-mtn.ts +91 -199
- package/hooks/use-sheet-qry.ts +84 -238
- package/hooks/use-storage-qry.ts +84 -61
- package/hooks/use-workflow-mtn.ts +39 -22
- package/hooks/use-workflow-qry.ts +40 -61
- 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/{client → libs}/request-managed-session.test.ts +1 -1
- 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/loaders/campaign.test.ts +186 -0
- package/loaders/campaign.ts +56 -83
- package/loaders/emailPreference.ts +75 -0
- package/loaders/rest.ts +12 -0
- package/package.json +42 -17
- package/schedule.d.ts +1790 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +26 -115
- package/tests/agent-note-detail-cache.test.ts +120 -0
- package/tests/agent-note-search.test.ts +444 -0
- package/types.d.ts +46 -25
- 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-no-store.test.ts +0 -157
- package/gql/fragments/agentDocFragments.ts +0 -46
- package/gql/fragments/billingFragments.ts +0 -14
- package/gql/mutations/agentDocMutations.ts +0 -177
- package/gql/queries/agentDocQueries.ts +0 -120
- package/hooks/use-agentDoc-mtn.ts +0 -285
- package/hooks/use-agentDoc-qry.ts +0 -208
- /package/{client → libs}/sse-ticket.test.ts +0 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
|
|
2
2
|
import type { ChildOrgsFilterArgs } from '@jsb188/mday/types/organization.d.ts';
|
|
3
|
-
import {
|
|
4
|
-
FRAGMENT_NAMES,
|
|
5
|
-
makeFragmentKey,
|
|
6
|
-
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
3
|
+
import { FRAGMENT_NAMES, makeFragmentKey } from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
7
4
|
export {
|
|
8
5
|
useInboundContact,
|
|
9
6
|
useInboundContacts,
|
|
@@ -27,6 +24,8 @@ const ORG_CHILDREN_LIMIT = 250;
|
|
|
27
24
|
export function useMyOrganizations(params: UseQueryParams = {}) {
|
|
28
25
|
const { data, ...rest } = useQuery(myOrganizationsQry, {
|
|
29
26
|
...params,
|
|
27
|
+
// Reuse fresh organization data when another modal mounts; refresh once the freshness window expires.
|
|
28
|
+
revalidateOnMount: params.revalidateOnMount ?? false,
|
|
30
29
|
persistTime: params.persistTime ?? 15 * 60 * 1000,
|
|
31
30
|
});
|
|
32
31
|
|
|
@@ -45,10 +44,8 @@ export function useOrganizationMembers(
|
|
|
45
44
|
paramsOrShowGuests: UseQueryParams | boolean = {},
|
|
46
45
|
showGuests_: boolean = false,
|
|
47
46
|
) {
|
|
48
|
-
const params =
|
|
49
|
-
|
|
50
|
-
const showGuests =
|
|
51
|
-
typeof paramsOrShowGuests === 'boolean' ? paramsOrShowGuests : showGuests_;
|
|
47
|
+
const params = typeof paramsOrShowGuests === 'boolean' ? {} : paramsOrShowGuests;
|
|
48
|
+
const showGuests = typeof paramsOrShowGuests === 'boolean' ? paramsOrShowGuests : showGuests_;
|
|
52
49
|
|
|
53
50
|
const { data, ...rest } = useQuery(organizationMembersQry, {
|
|
54
51
|
variables: {
|
|
@@ -69,11 +66,7 @@ export function useOrganizationMembers(
|
|
|
69
66
|
* Fetch organization sites
|
|
70
67
|
*/
|
|
71
68
|
|
|
72
|
-
export function useOrganizationSites(
|
|
73
|
-
organizationId: string | null,
|
|
74
|
-
parentId: string | null,
|
|
75
|
-
params: UseQueryParams = {},
|
|
76
|
-
) {
|
|
69
|
+
export function useOrganizationSites(organizationId: string | null, parentId: string | null, params: UseQueryParams = {}) {
|
|
77
70
|
const { data, ...rest } = useQuery(organizationSitesQry, {
|
|
78
71
|
variables: {
|
|
79
72
|
organizationId,
|
|
@@ -89,26 +82,14 @@ export function useOrganizationSites(
|
|
|
89
82
|
};
|
|
90
83
|
}
|
|
91
84
|
|
|
92
|
-
export function useReactiveOrganization(
|
|
93
|
-
orgId
|
|
94
|
-
currentData?: any,
|
|
95
|
-
queryCount?: number,
|
|
96
|
-
) {
|
|
97
|
-
return useReactiveFragment(
|
|
98
|
-
currentData,
|
|
99
|
-
[makeFragmentKey(FRAGMENT_NAMES.organization, orgId)],
|
|
100
|
-
queryCount,
|
|
101
|
-
);
|
|
85
|
+
export function useReactiveOrganization(orgId: string, currentData?: any, queryCount?: number) {
|
|
86
|
+
return useReactiveFragment(currentData, [makeFragmentKey(FRAGMENT_NAMES.organization, orgId)], queryCount);
|
|
102
87
|
}
|
|
103
88
|
|
|
104
89
|
/*
|
|
105
90
|
* Get reactive organization settings fragment data.
|
|
106
91
|
*/
|
|
107
|
-
export function useReactiveOrganizationSettings(
|
|
108
|
-
orgId: string | null | undefined,
|
|
109
|
-
currentData?: any,
|
|
110
|
-
queryCount?: number,
|
|
111
|
-
) {
|
|
92
|
+
export function useReactiveOrganizationSettings(orgId: string | null | undefined, currentData?: any, queryCount?: number) {
|
|
112
93
|
return useReactiveFragment(
|
|
113
94
|
currentData,
|
|
114
95
|
orgId ? [makeFragmentKey(FRAGMENT_NAMES.organizationSettings, orgId)] : [],
|
|
@@ -128,18 +109,9 @@ export function useOrgRelFromMyOrganizations(organizationId: string | null) {
|
|
|
128
109
|
skip: !organizationId,
|
|
129
110
|
});
|
|
130
111
|
|
|
131
|
-
const orgRel =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
) || null;
|
|
135
|
-
const reactiveOrganization = useReactiveOrganization(
|
|
136
|
-
orgRel?.organization?.id,
|
|
137
|
-
orgRel?.organization,
|
|
138
|
-
);
|
|
139
|
-
const reactiveSettings = useReactiveOrganizationSettings(
|
|
140
|
-
reactiveOrganization?.id,
|
|
141
|
-
reactiveOrganization?.settings,
|
|
142
|
-
);
|
|
112
|
+
const orgRel = myOrganizations?.find((orgRel: any) => orgRel.organization?.id === organizationId) || null;
|
|
113
|
+
const reactiveOrganization = useReactiveOrganization(orgRel?.organization?.id, orgRel?.organization);
|
|
114
|
+
const reactiveSettings = useReactiveOrganizationSettings(reactiveOrganization?.id, reactiveOrganization?.settings);
|
|
143
115
|
const organization =
|
|
144
116
|
reactiveOrganization && reactiveSettings
|
|
145
117
|
? {
|
|
@@ -207,12 +179,7 @@ export function useReactiveOrganizationChildFragment(
|
|
|
207
179
|
currentData,
|
|
208
180
|
[
|
|
209
181
|
makeFragmentKey(FRAGMENT_NAMES.organizationChild, childId),
|
|
210
|
-
organizationId
|
|
211
|
-
? [
|
|
212
|
-
makeFragmentKey(FRAGMENT_NAMES.organization, organizationId),
|
|
213
|
-
'organization',
|
|
214
|
-
]
|
|
215
|
-
: null,
|
|
182
|
+
organizationId ? [makeFragmentKey(FRAGMENT_NAMES.organization, organizationId), 'organization'] : null,
|
|
216
183
|
].filter(Boolean) as Array<string | [string, string | null]>,
|
|
217
184
|
queryCount,
|
|
218
185
|
undefined,
|
|
@@ -224,26 +191,15 @@ export function useReactiveOrganizationChildFragment(
|
|
|
224
191
|
* Get reactive organization compliance document fragment
|
|
225
192
|
*/
|
|
226
193
|
|
|
227
|
-
export function useReactiveOrganizationComplianceFragment(
|
|
228
|
-
complianceId
|
|
229
|
-
currentData?: any,
|
|
230
|
-
queryCount?: number,
|
|
231
|
-
) {
|
|
232
|
-
return useReactiveFragment(
|
|
233
|
-
currentData,
|
|
234
|
-
[makeFragmentKey(FRAGMENT_NAMES.organizationCompliance, complianceId)],
|
|
235
|
-
queryCount,
|
|
236
|
-
);
|
|
194
|
+
export function useReactiveOrganizationComplianceFragment(complianceId: string, currentData?: any, queryCount?: number) {
|
|
195
|
+
return useReactiveFragment(currentData, [makeFragmentKey(FRAGMENT_NAMES.organizationCompliance, complianceId)], queryCount);
|
|
237
196
|
}
|
|
238
197
|
|
|
239
198
|
/**
|
|
240
199
|
* Fetch custom page routes for organization
|
|
241
200
|
*/
|
|
242
201
|
|
|
243
|
-
export function usePageRoutes(
|
|
244
|
-
organizationId: string | null,
|
|
245
|
-
params: UseQueryParams = {},
|
|
246
|
-
) {
|
|
202
|
+
export function usePageRoutes(organizationId: string | null, params: UseQueryParams = {}) {
|
|
247
203
|
const { skip, ...restParams } = params;
|
|
248
204
|
const { data, ...rest } = useQuery(pageRoutesQry, {
|
|
249
205
|
variables: {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
+
import { confirmPublicFormEmailCodeMtn, sendPublicFormEmailCodeMtn } from '../gql/mutations/authMutations.ts';
|
|
3
|
+
import { useMutation } from './index.ts';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Request a numeric email code for temporary public-form respondent access.
|
|
7
|
+
*/
|
|
8
|
+
export function useSendPublicFormEmailCode(params: UseMutationParams = {}) {
|
|
9
|
+
const [sendPublicFormEmailCode, mutation, handlers] = useMutation(sendPublicFormEmailCodeMtn, {
|
|
10
|
+
...params,
|
|
11
|
+
checkMountedBeforeCallback: true,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return { sendPublicFormEmailCode, ...mutation, ...handlers };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Verify a public-form email code without adopting an account session.
|
|
19
|
+
*/
|
|
20
|
+
export function useConfirmPublicFormEmailCode(params: UseMutationParams = {}) {
|
|
21
|
+
const [confirmPublicFormEmailCode, mutation, handlers] = useMutation(confirmPublicFormEmailCodeMtn, {
|
|
22
|
+
...params,
|
|
23
|
+
checkMountedBeforeCallback: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return { confirmPublicFormEmailCode, ...mutation, ...handlers };
|
|
27
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
+
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
+
import { createQrCodeMtn, editQrCodeMtn } from '../gql/mutations/qrCodeMutations.ts';
|
|
4
|
+
import { useMutation } from './index.ts';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Issue a QR code and report its full saved record through the completion callback.
|
|
8
|
+
*/
|
|
9
|
+
export function useCreateQrCode(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
10
|
+
const { onCompleted, ...rest } = params;
|
|
11
|
+
const [createQrCode, mtnValues, mtnHandlers] = useMutation(createQrCodeMtn, {
|
|
12
|
+
openModalPopUp,
|
|
13
|
+
/*
|
|
14
|
+
* Expose the created record while shared mutation handling caches its complete fragment.
|
|
15
|
+
*/
|
|
16
|
+
onCompleted: (data, error, variables) => {
|
|
17
|
+
onCompleted?.(data?.createQrCode, error, variables);
|
|
18
|
+
},
|
|
19
|
+
...rest,
|
|
20
|
+
});
|
|
21
|
+
return { createQrCode, ...mtnValues, ...mtnHandlers };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Rename, archive, or restore QR metadata; server events refresh affected lists.
|
|
26
|
+
*/
|
|
27
|
+
export function useEditQrCode(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
28
|
+
const { onCompleted, ...rest } = params;
|
|
29
|
+
const [editQrCode, mtnValues, mtnHandlers] = useMutation(editQrCodeMtn, {
|
|
30
|
+
openModalPopUp,
|
|
31
|
+
/*
|
|
32
|
+
* Expose the updated record without manually mutating query or fragment caches.
|
|
33
|
+
*/
|
|
34
|
+
onCompleted: (data, error, variables) => {
|
|
35
|
+
onCompleted?.(data?.editQrCode, error, variables);
|
|
36
|
+
},
|
|
37
|
+
...rest,
|
|
38
|
+
});
|
|
39
|
+
return { editQrCode, ...mtnValues, ...mtnHandlers };
|
|
40
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useQuery, useReactiveFragment, useReactiveFragmentMap } from '@jsb188/graphql/client';
|
|
2
|
+
import { FRAGMENT_NAMES, getFragmentBaseName, makeFragmentKey } from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
3
|
+
import type { QrCodeGQL, QrCodesQueryArgs } from '@jsb188/mday/types/qrCode.d.ts';
|
|
4
|
+
import { qrCodeQry, qrCodesQry } from '../gql/queries/qrCodeQueries.ts';
|
|
5
|
+
import type { UseQueryParams } from '../types.d.ts';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Fetch one authorized code by exactly one identifier and observe metadata under its returned GraphQL identity.
|
|
9
|
+
*/
|
|
10
|
+
export function useQrCode(
|
|
11
|
+
variables: { organizationId?: string | null; qrCodeId?: string | null; publicId?: string | null },
|
|
12
|
+
params: UseQueryParams = {},
|
|
13
|
+
) {
|
|
14
|
+
const { organizationId = null, qrCodeId = null, publicId = null } = variables;
|
|
15
|
+
const skipped = !organizationId || (qrCodeId === null) === (publicId === null) || !!params.skip;
|
|
16
|
+
const { data, ...rest } = useQuery(qrCodeQry, {
|
|
17
|
+
...params,
|
|
18
|
+
variables: { organizationId, qrCodeId, publicId },
|
|
19
|
+
skip: skipped,
|
|
20
|
+
});
|
|
21
|
+
const current = !skipped && rest.queryKey === `#${rest.queryName}:${rest.variablesKey}`;
|
|
22
|
+
const candidate = (current && !rest.error ? data?.qrCode : null) as QrCodeGQL | null;
|
|
23
|
+
const record =
|
|
24
|
+
candidate?.organizationId === organizationId && (qrCodeId !== null ? candidate?.id === qrCodeId : candidate?.publicId === publicId)
|
|
25
|
+
? candidate
|
|
26
|
+
: null;
|
|
27
|
+
const reactive = useReactiveQrCodeFragment(record?.id, record, rest.updatedCount);
|
|
28
|
+
return {
|
|
29
|
+
...rest,
|
|
30
|
+
qrCode:
|
|
31
|
+
record && reactive?.organizationId === organizationId && (publicId === null || reactive.publicId === publicId) ? reactive : null,
|
|
32
|
+
initialLoading: !skipped && !rest.error && !record,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* Read newest-first QR pages; organization-scoped server resets refresh list membership.
|
|
38
|
+
*/
|
|
39
|
+
export function useQrCodes(variables: QrCodesQueryArgs, params: UseQueryParams = {}) {
|
|
40
|
+
const skipped = !variables.organizationId || !!params.skip;
|
|
41
|
+
const { data, ...rest } = useQuery(qrCodesQry, {
|
|
42
|
+
...params,
|
|
43
|
+
variables: {
|
|
44
|
+
...variables,
|
|
45
|
+
filter: variables.filter ?? null,
|
|
46
|
+
cursor: variables.cursor ?? null,
|
|
47
|
+
limit: variables.limit ?? 100,
|
|
48
|
+
},
|
|
49
|
+
skip: skipped,
|
|
50
|
+
});
|
|
51
|
+
const current = !skipped && rest.queryKey === `#${rest.queryName}:${rest.variablesKey}`;
|
|
52
|
+
const records = (current ? (data?.qrCodes ?? null) : null) as QrCodeGQL[] | null;
|
|
53
|
+
const reactive = useReactiveQrCodeFragmentMap(records, rest.updatedCount);
|
|
54
|
+
return {
|
|
55
|
+
...rest,
|
|
56
|
+
qrCodes: records ? reactive : null,
|
|
57
|
+
initialLoading: !skipped && !rest.error && !records,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Observe the full shared QR fragment without returning a previous record after an identity change.
|
|
63
|
+
*/
|
|
64
|
+
export function useReactiveQrCodeFragment(
|
|
65
|
+
qrCodeId?: string | null,
|
|
66
|
+
currentData?: QrCodeGQL | null,
|
|
67
|
+
queryCount?: number,
|
|
68
|
+
): QrCodeGQL | null {
|
|
69
|
+
const code = useReactiveFragment(currentData, qrCodeId ? [makeFragmentKey(FRAGMENT_NAMES.qrCode, qrCodeId)] : [], queryCount);
|
|
70
|
+
return code?.id === qrCodeId ? code : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
* Observe QR rows by their canonical fragment identity for lists and virtualized tables.
|
|
75
|
+
*/
|
|
76
|
+
export function useReactiveQrCodeFragmentMap(codes?: QrCodeGQL[] | null, queryCount?: number): QrCodeGQL[] | null {
|
|
77
|
+
return useReactiveFragmentMap(codes || null, getFragmentBaseName(FRAGMENT_NAMES.qrCode), queryCount);
|
|
78
|
+
}
|