@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,9 +1,9 @@
|
|
|
1
1
|
import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
|
|
2
|
-
import type { InboundContactsSortEnum } from '@jsb188/mday/types/inboundContact.d.ts';
|
|
3
2
|
import {
|
|
4
3
|
FRAGMENT_NAMES,
|
|
5
4
|
makeFragmentKey,
|
|
6
5
|
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
6
|
+
import type { InboundContactsQueryArgs } from '@jsb188/mday/types/inboundContact.d.ts';
|
|
7
7
|
import {
|
|
8
8
|
inboundContactQry,
|
|
9
9
|
inboundContactsQry,
|
|
@@ -54,21 +54,19 @@ export function useInboundContact(
|
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
56
|
export function useInboundContacts(
|
|
57
|
-
variables: PaginationArgs &
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
57
|
+
variables: PaginationArgs &
|
|
58
|
+
InboundContactsQueryArgs & {
|
|
59
|
+
organizationId?: string | null;
|
|
60
|
+
},
|
|
62
61
|
params: UseQueryParams = {},
|
|
63
62
|
) {
|
|
64
|
-
const { filter: _filter, ...queryVariables } = variables;
|
|
65
63
|
const { data, ...rest } = useQuery(inboundContactsQry, {
|
|
66
64
|
...params,
|
|
67
65
|
variables: {
|
|
68
|
-
...
|
|
66
|
+
...variables,
|
|
69
67
|
cursor: null,
|
|
70
68
|
after: true,
|
|
71
|
-
limit: INBOUND_CONTACTS_LIMIT,
|
|
69
|
+
limit: variables.limit ?? INBOUND_CONTACTS_LIMIT,
|
|
72
70
|
},
|
|
73
71
|
skip: !variables.organizationId || params.skip,
|
|
74
72
|
});
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { normalizeServerError } from '@jsb188/app/utils/api.ts';
|
|
2
|
+
import { makeGraphQLVariablesKey } from '@jsb188/app/utils/logic.ts';
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { FRAGMENT_NAMES, getFragmentBaseName, makeFragmentKey } from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
5
|
+
import type {
|
|
6
|
+
LibraryFileCitationGQL,
|
|
7
|
+
LibraryFileCitationSelection,
|
|
8
|
+
LibraryFileContentGQL,
|
|
9
|
+
LibraryFileNoteGQL,
|
|
10
|
+
LibraryFileObjectGQL,
|
|
11
|
+
LibraryFileGQL,
|
|
12
|
+
LibraryFolderGQL,
|
|
13
|
+
LibraryFilePublishedAnalysis,
|
|
14
|
+
} from '@jsb188/mday/types/library.d.ts';
|
|
15
|
+
import { getGraphQLCacheEpoch, getQueryLastFetchedAt } from '../cache/index.ts';
|
|
16
|
+
import { graphqlRequest, useQuery, useReactiveFragment, useReactiveFragmentMap } from '../client/index.ts';
|
|
17
|
+
import {
|
|
18
|
+
libraryFileBriefQry,
|
|
19
|
+
libraryFileCitationQry,
|
|
20
|
+
libraryFileNotesQry,
|
|
21
|
+
libraryFilesQry,
|
|
22
|
+
libraryFoldersQry,
|
|
23
|
+
libraryFileContentQry,
|
|
24
|
+
libraryFileQry,
|
|
25
|
+
} from '../gql/queries/libraryQueries.ts';
|
|
26
|
+
import type { UpdateObserversFn, UseQueryParams } from '../types.d.ts';
|
|
27
|
+
|
|
28
|
+
/* Check whether the retained query output belongs to the currently requested variables. */
|
|
29
|
+
function isCurrentLibraryQuery(query: Pick<ReturnType<typeof useQuery>, 'queryName' | 'queryKey' | 'variablesKey'>) {
|
|
30
|
+
return query.queryKey === `#${query.queryName}:${query.variablesKey}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Withhold a settled error when its variables belong to the previous file, folder or organization. */
|
|
34
|
+
function getLibraryQueryError(query: Pick<ReturnType<typeof useQuery>, 'error' | 'variables' | 'variablesKey'>, skipped: boolean) {
|
|
35
|
+
return !skipped && query.error && makeGraphQLVariablesKey(query.variables) === query.variablesKey ? query.error : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* Read authorized library file metadata and observe the shared identity, withholding deleted
|
|
40
|
+
* records and cached data after an access error or while changing file ids.
|
|
41
|
+
*/
|
|
42
|
+
export function useLibraryFile(id?: string | null, params: UseQueryParams = {}) {
|
|
43
|
+
const skipped = !id || !!params.skip;
|
|
44
|
+
const { data, ...rest } = useQuery(libraryFileQry, {
|
|
45
|
+
...params,
|
|
46
|
+
variables: { libraryFileId: id },
|
|
47
|
+
skip: skipped,
|
|
48
|
+
persistTime: 60_000,
|
|
49
|
+
});
|
|
50
|
+
const record: LibraryFileGQL | null = data?.libraryFile?.id === id ? data.libraryFile : null;
|
|
51
|
+
const doc = useReactiveLibraryFileFragment(id, record, rest.updatedCount);
|
|
52
|
+
const error = getLibraryQueryError(rest, skipped);
|
|
53
|
+
const loaded = !skipped && isCurrentLibraryQuery(rest) && data?.libraryFile !== undefined;
|
|
54
|
+
return { ...rest, error, loaded, libraryFile: skipped || error || !record || doc?.__deleted ? null : doc };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Observe only the requested library file's light metadata fragment. */
|
|
58
|
+
export function useReactiveLibraryFileFragment(id?: string | null, currentData?: LibraryFileGQL | null, queryCount?: number) {
|
|
59
|
+
const doc: LibraryFileGQL | null = useReactiveFragment(
|
|
60
|
+
currentData,
|
|
61
|
+
id ? [makeFragmentKey(FRAGMENT_NAMES.libraryFile, id)] : [],
|
|
62
|
+
queryCount,
|
|
63
|
+
);
|
|
64
|
+
return doc?.id === id ? doc : null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
* Read the library file's text and its original files. A `touched` libraryFileContent change refetches
|
|
69
|
+
* this operation when content changes; a short freshness window revalidates on focus or revisit.
|
|
70
|
+
*/
|
|
71
|
+
export function useLibraryFileContent(libraryFileId?: string | null, params: UseQueryParams = {}) {
|
|
72
|
+
const skipped = !libraryFileId || !!params.skip;
|
|
73
|
+
const { data, ...rest } = useQuery(libraryFileContentQry, {
|
|
74
|
+
...params,
|
|
75
|
+
variables: { libraryFileId },
|
|
76
|
+
skip: skipped,
|
|
77
|
+
persistTime: 60_000,
|
|
78
|
+
});
|
|
79
|
+
const withheld = skipped || !!rest.error || !isCurrentLibraryQuery(rest);
|
|
80
|
+
const content: LibraryFileContentGQL | null = data?.libraryFileContent?.id === libraryFileId ? data.libraryFileContent : null;
|
|
81
|
+
return {
|
|
82
|
+
...rest,
|
|
83
|
+
content: withheld ? null : content,
|
|
84
|
+
files: withheld ? null : ((data?.libraryFileObjects ?? null) as LibraryFileObjectGQL[] | null),
|
|
85
|
+
loaded: !withheld && data?.libraryFileObjects != null,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Read the saved brief and protected original links together, withholding cached results when the requested file changes. */
|
|
90
|
+
export function useLibraryFileBrief(libraryFileId: string) {
|
|
91
|
+
const { data, ...rest } = useQuery(libraryFileBriefQry, { variables: { libraryFileId }, persistTime: 60_000 });
|
|
92
|
+
const current = !rest.error && isCurrentLibraryQuery(rest) ? data : null;
|
|
93
|
+
const analysis: { id: string; revision: string; stale: boolean; data: LibraryFilePublishedAnalysis } | null =
|
|
94
|
+
current?.libraryFileAnalysis?.id === libraryFileId ? current.libraryFileAnalysis : null;
|
|
95
|
+
return {
|
|
96
|
+
...rest,
|
|
97
|
+
analysis,
|
|
98
|
+
files: current?.libraryFileObjects as LibraryFileObjectGQL[] | undefined,
|
|
99
|
+
loaded: current?.libraryFileObjects != null,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* Read the window of one cited chunk, or nothing while no citation is open. A result or an error that belongs to an
|
|
105
|
+
* earlier selection is withheld, so switching citations while a read is in flight shows only the active one.
|
|
106
|
+
*/
|
|
107
|
+
export function useLibraryFileCitation(selection: LibraryFileCitationSelection | null) {
|
|
108
|
+
// A page-level citation leaves both offsets out
|
|
109
|
+
const variables = selection && {
|
|
110
|
+
libraryFileId: selection.libraryFileId,
|
|
111
|
+
analysisId: selection.analysisId,
|
|
112
|
+
ref: selection.ref,
|
|
113
|
+
...(selection.start === null || selection.end === null ? {} : { start: selection.start, end: selection.end }),
|
|
114
|
+
};
|
|
115
|
+
const { data, ...rest } = useQuery(libraryFileCitationQry, { variables, skip: !selection });
|
|
116
|
+
const current = !!selection && isCurrentLibraryQuery(rest);
|
|
117
|
+
// The error belongs to the variables of the request that settled it
|
|
118
|
+
const error = getLibraryQueryError(rest, !selection);
|
|
119
|
+
const citation: LibraryFileCitationGQL | null = current && !error ? (data?.libraryFileCitation ?? null) : null;
|
|
120
|
+
return { ...rest, citation, error };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* Read what team members said about a file, oldest first, withholding cached notes when the requested file changes. */
|
|
124
|
+
export function useLibraryFileNotes(libraryFileId: string) {
|
|
125
|
+
const { data, ...rest } = useQuery(libraryFileNotesQry, { variables: { libraryFileId } });
|
|
126
|
+
const current = !rest.error && isCurrentLibraryQuery(rest);
|
|
127
|
+
const notes: LibraryFileNoteGQL[] | null = current ? (data?.libraryFileNotes ?? null) : null;
|
|
128
|
+
return { ...rest, notes };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
type LibraryFilesVariables = { organizationId: string; limit: number; filter?: { folderId: string } };
|
|
132
|
+
|
|
133
|
+
/* Fetch the rest of a directory without competing with the first page's query state or cancellation signal. */
|
|
134
|
+
async function fetchLibraryFilePages(
|
|
135
|
+
variables: LibraryFilesVariables,
|
|
136
|
+
firstCursor: string,
|
|
137
|
+
signal: AbortSignal,
|
|
138
|
+
updateObservers: UpdateObserversFn,
|
|
139
|
+
) {
|
|
140
|
+
const rows: LibraryFileGQL[] = [];
|
|
141
|
+
const visited = new Set<string>();
|
|
142
|
+
let cursor = firstCursor;
|
|
143
|
+
while (!signal.aborted && cursor && !visited.has(cursor)) {
|
|
144
|
+
visited.add(cursor);
|
|
145
|
+
const result = await graphqlRequest(libraryFilesQry, { ...variables, cursor }, undefined, signal, updateObservers);
|
|
146
|
+
if (signal.aborted) return { rows: [], error: null };
|
|
147
|
+
if (result.error) return { rows: [], error: result.error };
|
|
148
|
+
const page: LibraryFileGQL[] | undefined = result.libraryFiles;
|
|
149
|
+
if (!Array.isArray(page)) break;
|
|
150
|
+
rows.push(...page);
|
|
151
|
+
if (page.length < variables.limit) return { rows, error: null };
|
|
152
|
+
cursor = page[page.length - 1].cursor;
|
|
153
|
+
}
|
|
154
|
+
// An invalid or repeated cursor must surface a retryable error.
|
|
155
|
+
return { rows: [], error: normalizeServerError() };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* Join the first page to its matching cursor pages, retaining completed pages during a refresh of the same directory. */
|
|
159
|
+
function useLibraryDirectoryFiles(organizationId: string, folderId: string | undefined, skip: boolean) {
|
|
160
|
+
const variables = useMemo(
|
|
161
|
+
() => ({ organizationId, limit: 100, ...(folderId && { filter: { folderId } }) }),
|
|
162
|
+
[organizationId, folderId],
|
|
163
|
+
);
|
|
164
|
+
const files = useQuery(libraryFilesQry, { variables, skip, persistTime: 15 * 60_000 });
|
|
165
|
+
const error = getLibraryQueryError(files, skip);
|
|
166
|
+
const first: LibraryFileGQL[] | undefined = !skip && !error && isCurrentLibraryQuery(files) ? files.data?.libraryFiles : undefined;
|
|
167
|
+
const cursor = first?.length === variables.limit ? first[first.length - 1].cursor : null;
|
|
168
|
+
const cacheEpoch = getGraphQLCacheEpoch();
|
|
169
|
+
const fetchedAt = getQueryLastFetchedAt(files.queryKey);
|
|
170
|
+
const { updateObservers } = files;
|
|
171
|
+
const [tail, setTail] = useState<{
|
|
172
|
+
variables: LibraryFilesVariables;
|
|
173
|
+
cursor: string;
|
|
174
|
+
cacheEpoch: number;
|
|
175
|
+
fetchedAt: number | undefined;
|
|
176
|
+
rows: LibraryFileGQL[];
|
|
177
|
+
error: ReturnType<typeof normalizeServerError> | null;
|
|
178
|
+
} | null>(null);
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (!cursor) return;
|
|
181
|
+
const controller = new AbortController();
|
|
182
|
+
/* Install results only while this directory and its authenticated cache still own the request. */
|
|
183
|
+
const loadPages = async () => {
|
|
184
|
+
const result = await fetchLibraryFilePages(variables, cursor, controller.signal, updateObservers);
|
|
185
|
+
if (!controller.signal.aborted && getGraphQLCacheEpoch() === cacheEpoch) {
|
|
186
|
+
setTail({ variables, cursor, cacheEpoch, fetchedAt, ...result });
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
void loadPages();
|
|
190
|
+
return () => controller.abort();
|
|
191
|
+
}, [variables, cursor, cacheEpoch, fetchedAt, updateObservers]);
|
|
192
|
+
|
|
193
|
+
const matchingTail = tail && tail.variables === variables && tail.cursor === cursor && tail.cacheEpoch === cacheEpoch ? tail : null;
|
|
194
|
+
const tailRows = matchingTail?.error ? null : matchingTail?.rows;
|
|
195
|
+
const rows = useMemo(() => (first && tailRows ? first.concat(tailRows) : (first ?? null)), [first, tailRows]);
|
|
196
|
+
const records: LibraryFileGQL[] | null = useReactiveFragmentMap(
|
|
197
|
+
rows,
|
|
198
|
+
getFragmentBaseName(FRAGMENT_NAMES.libraryFile),
|
|
199
|
+
files.updatedCount,
|
|
200
|
+
);
|
|
201
|
+
return {
|
|
202
|
+
files: records,
|
|
203
|
+
loadingMore: !!cursor && !tailRows,
|
|
204
|
+
error: error || (matchingTail?.fetchedAt === fetchedAt ? matchingTail?.error : null),
|
|
205
|
+
refetch: files.refetch,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* Read the visible folder tree and fetch only the requested folder's files. Unknown folder URLs can be legacy file bookmarks. */
|
|
210
|
+
export function useLibraryDirectory(organizationId: string, folderId?: string) {
|
|
211
|
+
const folders = useQuery(libraryFoldersQry, { variables: { organizationId }, skip: !organizationId });
|
|
212
|
+
const folderError = getLibraryQueryError(folders, !organizationId);
|
|
213
|
+
const tree: LibraryFolderGQL[] | undefined =
|
|
214
|
+
organizationId && !folderError && isCurrentLibraryQuery(folders) ? folders.data?.libraryFolders : undefined;
|
|
215
|
+
const folderExists = !!folderId && tree?.some((folder) => folder.id === folderId);
|
|
216
|
+
const directory = useLibraryDirectoryFiles(organizationId, folderId, !organizationId || (!!folderId && !folderExists));
|
|
217
|
+
const legacyId = tree && !folderExists ? folderId : undefined;
|
|
218
|
+
const validLegacyId = legacyId && /^\d+$/.test(legacyId) ? legacyId : undefined;
|
|
219
|
+
const legacy = useLibraryFile(validLegacyId);
|
|
220
|
+
const legacyPending = validLegacyId && !legacy.loaded && !legacy.error;
|
|
221
|
+
const legacyError = legacy.error?.statusCode === 404 ? null : legacy.error;
|
|
222
|
+
const source = legacyId ? legacy : directory;
|
|
223
|
+
// A by-id read uses the same visibility rules as the list, but also finds archived files and files from another organization.
|
|
224
|
+
const file = legacy.libraryFile;
|
|
225
|
+
return {
|
|
226
|
+
files: legacyId && !legacyPending ? [] : directory.files,
|
|
227
|
+
legacyFileId: file?.organizationId === organizationId && !file.archivedAt ? file.id : null,
|
|
228
|
+
folders: tree,
|
|
229
|
+
loadingMore: directory.loadingMore,
|
|
230
|
+
error: folderError || (legacyId ? legacyError : directory.error),
|
|
231
|
+
refetch: () => Promise.all([source.refetch(), folders.refetch()]),
|
|
232
|
+
};
|
|
233
|
+
}
|
package/hooks/use-log-mtn.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { checkACLPermission } from '@jsb188/mday/utils/organization.ts';
|
|
2
1
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
3
|
-
import { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
4
2
|
import {
|
|
5
3
|
FRAGMENT_NAMES,
|
|
6
4
|
makeFragmentKey,
|
|
7
5
|
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
6
|
+
import { checkACLPermission } from '@jsb188/mday/utils/organization.ts';
|
|
7
|
+
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
8
8
|
import { useMemo } from 'react';
|
|
9
9
|
import { updateFragment } from '../cache/index.ts';
|
|
10
10
|
import {
|
|
@@ -15,6 +15,26 @@ import { useMutation } from './index.ts';
|
|
|
15
15
|
import { useReactiveLogFragment } from './use-log-qry.ts';
|
|
16
16
|
import { useOrgRelFromMyOrganizations } from './use-organization-qry.ts';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Prepare the shared edit-log mutation command without subscribing to one log row.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export function useEditLogEntryMutation(
|
|
23
|
+
params: UseMutationParams = {},
|
|
24
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
25
|
+
) {
|
|
26
|
+
const [editLogEntry, mtnValues, mtnHandlers] = useMutation(editLogEntryMtn, {
|
|
27
|
+
openModalPopUp,
|
|
28
|
+
...params,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
editLogEntry,
|
|
33
|
+
...mtnValues,
|
|
34
|
+
...mtnHandlers,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
/**
|
|
19
39
|
* Fetch a single log entry,
|
|
20
40
|
* from cache first; only check server if cache is not found.
|
|
@@ -30,17 +50,12 @@ export function useEditLogEntry(
|
|
|
30
50
|
const { organizationRelationship } =
|
|
31
51
|
useOrgRelFromMyOrganizations(organizationId);
|
|
32
52
|
const notReady = !organizationRelationship;
|
|
33
|
-
|
|
34
|
-
const [editLogEntry, mtnValues, mtnHandlers] = useMutation(editLogEntryMtn, {
|
|
35
|
-
// checkMountedBeforeCallback: true,
|
|
36
|
-
openModalPopUp,
|
|
37
|
-
...params,
|
|
38
|
-
});
|
|
53
|
+
const mutation = useEditLogEntryMutation(params, openModalPopUp);
|
|
39
54
|
|
|
40
55
|
const logEntry = useReactiveLogFragment(
|
|
41
56
|
logEntryId,
|
|
42
57
|
null,
|
|
43
|
-
|
|
58
|
+
mutation.mutationCount,
|
|
44
59
|
);
|
|
45
60
|
|
|
46
61
|
const isMyDocument =
|
|
@@ -55,11 +70,9 @@ export function useEditLogEntry(
|
|
|
55
70
|
|
|
56
71
|
return {
|
|
57
72
|
logEntry,
|
|
58
|
-
editLogEntry,
|
|
59
73
|
notReady,
|
|
60
74
|
allowEdit,
|
|
61
|
-
...
|
|
62
|
-
...mtnHandlers,
|
|
75
|
+
...mutation,
|
|
63
76
|
};
|
|
64
77
|
}
|
|
65
78
|
|
package/hooks/use-log-qry.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
LogSortEnum,
|
|
4
|
-
} from '@jsb188/mday/types/log.d.ts';
|
|
5
|
-
import {
|
|
6
|
-
FRAGMENT_NAMES,
|
|
7
|
-
makeFragmentKey,
|
|
8
|
-
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
1
|
+
import { FRAGMENT_NAMES, makeFragmentKey } from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
2
|
+
import type { FilterLogEntriesArgs, LogSortEnum } from '@jsb188/mday/types/log.d.ts';
|
|
9
3
|
import { useQuery, useReactiveFragment } from '../client/index.ts';
|
|
10
4
|
import {
|
|
11
|
-
|
|
5
|
+
fieldDocSubmissionLogsQry,
|
|
12
6
|
logEntriesQry,
|
|
13
7
|
logEntryQry,
|
|
8
|
+
logRevisionProofDownloadUrlQry,
|
|
9
|
+
logRevisionQry,
|
|
10
|
+
logRevisionsQry,
|
|
14
11
|
} from '../gql/queries/logQueries.ts';
|
|
15
12
|
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
16
13
|
|
|
@@ -22,9 +19,20 @@ import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
|
22
19
|
// Having less data is better for performance for iPads and low-end devices, because it might reduce brief rendering mishaps,
|
|
23
20
|
// But a decent amount of visual load size is needed for Virtualized List to work well.
|
|
24
21
|
const LOG_ENTRIES_LIMIT = 250;
|
|
22
|
+
const LOG_REVISIONS_LIMIT = 50;
|
|
23
|
+
|
|
24
|
+
export type LogRevisionsVariables = PaginationArgs & {
|
|
25
|
+
organizationId?: string | null;
|
|
26
|
+
logEntryId?: string | null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type LogRevisionVariables = {
|
|
30
|
+
organizationId?: string | null;
|
|
31
|
+
revisionId?: string | null;
|
|
32
|
+
};
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
|
-
*
|
|
35
|
+
* Reuse the requested reactive log from cache and only query when it is absent.
|
|
28
36
|
*/
|
|
29
37
|
|
|
30
38
|
export function useLogEntry(
|
|
@@ -35,22 +43,23 @@ export function useLogEntry(
|
|
|
35
43
|
params: UseQueryParams = {},
|
|
36
44
|
) {
|
|
37
45
|
const { logEntryId, organizationId } = variables;
|
|
46
|
+
// Read the reactive fragment first; it already loads and observes the log and details in cache.
|
|
47
|
+
// A separate loadFragment() call would duplicate that cache lookup.
|
|
48
|
+
const observedLogEntry = useReactiveLogFragment(logEntryId || '');
|
|
49
|
+
// The observer can retain the previous log until its effect runs after an ID change.
|
|
50
|
+
// Only the requested log may satisfy this read or prevent its query from running.
|
|
51
|
+
const reactiveLogEntry = observedLogEntry?.id === logEntryId ? observedLogEntry : null;
|
|
52
|
+
// Always call the query hook to preserve hook order, but skip its automatic request when
|
|
53
|
+
// the requested log is cached, required IDs are absent, or the caller explicitly skips.
|
|
38
54
|
const { data, ...rest } = useQuery(logEntryQry, {
|
|
39
55
|
...params,
|
|
40
|
-
// A log can be changed outside the websocket mutation path, such as by a
|
|
41
|
-
// database repair. Revalidate it whenever the detail modal is opened.
|
|
42
|
-
persistTime: params.persistTime ?? 0,
|
|
43
56
|
variables,
|
|
44
|
-
skip: !organizationId || !logEntryId || params.skip,
|
|
57
|
+
skip: !!reactiveLogEntry || !organizationId || !logEntryId || params.skip,
|
|
45
58
|
});
|
|
46
|
-
const reactiveLogEntry = useReactiveLogFragment(
|
|
47
|
-
logEntryId || '',
|
|
48
|
-
data?.logEntry,
|
|
49
|
-
rest.updatedCount,
|
|
50
|
-
);
|
|
51
59
|
|
|
52
60
|
return {
|
|
53
|
-
|
|
61
|
+
// Prefer the reactive cache; otherwise use a matching query result while the cache observer catches up.
|
|
62
|
+
logEntry: reactiveLogEntry || (data?.logEntry?.id === logEntryId ? data.logEntry : null),
|
|
54
63
|
...rest,
|
|
55
64
|
};
|
|
56
65
|
}
|
|
@@ -87,30 +96,81 @@ export function useLogEntries(
|
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
/**
|
|
90
|
-
* Fetch
|
|
99
|
+
* Fetch every log linked to one field doc submission (the document page loads it beside the document).
|
|
91
100
|
*/
|
|
92
101
|
|
|
93
|
-
export function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
export function useFieldDocSubmissionLogs(fieldDocSubmissionId: string | null | undefined, params: UseQueryParams = {}) {
|
|
103
|
+
const { data, ...rest } = useQuery(fieldDocSubmissionLogsQry, {
|
|
104
|
+
...params,
|
|
105
|
+
variables: {
|
|
106
|
+
fieldDocSubmissionId,
|
|
107
|
+
},
|
|
108
|
+
skip: !fieldDocSubmissionId || params.skip,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
fieldDocSubmissionLogs: data?.fieldDocSubmissionLogs,
|
|
113
|
+
...rest,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Reuse cached revision-history pages without automatically revalidating them on each modal open.
|
|
119
|
+
*/
|
|
120
|
+
export function useLogRevisions(variables: LogRevisionsVariables, params: UseQueryParams = {}) {
|
|
121
|
+
const { data, ...rest } = useQuery(logRevisionsQry, {
|
|
122
|
+
...params,
|
|
123
|
+
// useQuery already reads its normalized cache for these exact log and pagination variables.
|
|
124
|
+
// Keep cached pages fresh indefinitely and disable mount revalidation so reopening does not refetch them.
|
|
125
|
+
revalidateOnMount: params.revalidateOnMount ?? false,
|
|
126
|
+
persistTime: params.persistTime ?? Infinity,
|
|
127
|
+
variables: {
|
|
128
|
+
...variables,
|
|
129
|
+
cursor: variables.cursor ?? null,
|
|
130
|
+
after: variables.after ?? false,
|
|
131
|
+
limit: variables.limit ?? LOG_REVISIONS_LIMIT,
|
|
132
|
+
},
|
|
133
|
+
// Unlike the single-log read, a cached page must not set skip: true: useQuery also gates
|
|
134
|
+
// fetchMore() and refetch() on skip. Only missing IDs or an explicit caller skip disable those requests.
|
|
135
|
+
skip: !variables.organizationId || !variables.logEntryId || params.skip,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
// Return the cache-backed page from useQuery; a missing page is populated by its normal server request.
|
|
140
|
+
logRevisions: data?.logRevisions,
|
|
141
|
+
...rest,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Fetch one full immutable log revision.
|
|
147
|
+
*/
|
|
148
|
+
export function useLogRevision(variables: LogRevisionVariables, params: UseQueryParams = {}) {
|
|
149
|
+
const { data, ...rest } = useQuery(logRevisionQry, {
|
|
150
|
+
...params,
|
|
151
|
+
variables,
|
|
152
|
+
skip: !variables.organizationId || !variables.revisionId || params.skip,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
logRevision: data?.logRevision,
|
|
157
|
+
...rest,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Request a fresh short-lived download URL for one archived proof.
|
|
163
|
+
*/
|
|
164
|
+
export function useLogRevisionProofDownloadUrl(variables: LogRevisionVariables, params: UseQueryParams = {}) {
|
|
165
|
+
const { data, ...rest } = useQuery(logRevisionProofDownloadUrlQry, {
|
|
103
166
|
...params,
|
|
167
|
+
persistTime: params.persistTime ?? 0,
|
|
104
168
|
variables,
|
|
105
|
-
skip:
|
|
106
|
-
!organizationId ||
|
|
107
|
-
!fieldDocSourceId ||
|
|
108
|
-
!fieldDocSubmissionId ||
|
|
109
|
-
params.skip,
|
|
169
|
+
skip: !variables.organizationId || !variables.revisionId || params.skip,
|
|
110
170
|
});
|
|
111
171
|
|
|
112
172
|
return {
|
|
113
|
-
|
|
173
|
+
logRevisionProofDownloadUrl: data?.logRevisionProofDownloadUrl,
|
|
114
174
|
...rest,
|
|
115
175
|
};
|
|
116
176
|
}
|
|
@@ -119,17 +179,10 @@ export function useLogEntriesForFieldDoc(
|
|
|
119
179
|
* Get reactive log fragment
|
|
120
180
|
*/
|
|
121
181
|
|
|
122
|
-
export function useReactiveLogFragment(
|
|
123
|
-
logEntryId: string,
|
|
124
|
-
currentData?: any,
|
|
125
|
-
queryCount?: number,
|
|
126
|
-
) {
|
|
182
|
+
export function useReactiveLogFragment(logEntryId: string, currentData?: any, queryCount?: number) {
|
|
127
183
|
return useReactiveFragment(
|
|
128
184
|
currentData,
|
|
129
|
-
[
|
|
130
|
-
makeFragmentKey(FRAGMENT_NAMES.logEntry, logEntryId),
|
|
131
|
-
[makeFragmentKey(FRAGMENT_NAMES.logEntryDetails, logEntryId), 'details'],
|
|
132
|
-
],
|
|
185
|
+
[makeFragmentKey(FRAGMENT_NAMES.logEntry, logEntryId), [makeFragmentKey(FRAGMENT_NAMES.logEntryDetails, logEntryId), 'details']],
|
|
133
186
|
queryCount,
|
|
134
187
|
);
|
|
135
188
|
}
|
|
@@ -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: {
|