@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,52 +0,0 @@
|
|
|
1
|
-
const FRAGMENT_REALTIME_SEQUENCES = new Map<string, string>();
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Compare two unsigned decimal sequence strings without narrowing them to
|
|
5
|
-
* JavaScript's unsafe integer range.
|
|
6
|
-
*/
|
|
7
|
-
function compareFragmentRealtimeSequences(left: string, right: string) {
|
|
8
|
-
const normalizedLeft = left.replace(/^0+(?=\d)/, '');
|
|
9
|
-
const normalizedRight = right.replace(/^0+(?=\d)/, '');
|
|
10
|
-
|
|
11
|
-
if (normalizedLeft.length !== normalizedRight.length) {
|
|
12
|
-
return normalizedLeft.length > normalizedRight.length ? 1 : -1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return normalizedLeft === normalizedRight
|
|
16
|
-
? 0
|
|
17
|
-
: normalizedLeft > normalizedRight
|
|
18
|
-
? 1
|
|
19
|
-
: -1;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/*
|
|
23
|
-
* Accept an unsequenced fragment or a sequenced fragment that is not older
|
|
24
|
-
* than the latest event already applied to the same cache key.
|
|
25
|
-
*/
|
|
26
|
-
export function shouldApplyFragmentRealtimeSequence(
|
|
27
|
-
fragmentKey: string,
|
|
28
|
-
sequence?: string,
|
|
29
|
-
) {
|
|
30
|
-
if (!sequence || !/^\d+$/.test(sequence)) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const currentSequence = FRAGMENT_REALTIME_SEQUENCES.get(fragmentKey);
|
|
35
|
-
if (
|
|
36
|
-
currentSequence &&
|
|
37
|
-
compareFragmentRealtimeSequences(sequence, currentSequence) < 0
|
|
38
|
-
) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
FRAGMENT_REALTIME_SEQUENCES.set(fragmentKey, sequence);
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/*
|
|
47
|
-
* Clear fragment sequence fences when authorization-bound cache state is
|
|
48
|
-
* discarded.
|
|
49
|
-
*/
|
|
50
|
-
export function clearFragmentRealtimeSequences() {
|
|
51
|
-
FRAGMENT_REALTIME_SEQUENCES.clear();
|
|
52
|
-
}
|
package/client/open-sheet.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SheetBootstrapGQL,
|
|
3
|
-
SheetGridViewportObj,
|
|
4
|
-
SheetTabBootstrapGQL,
|
|
5
|
-
} from '@jsb188/mday/types/sheet.d.ts';
|
|
6
|
-
import { openSheetQry, openSheetTabQry } from '../gql/queries/sheetQueries.ts';
|
|
7
|
-
import { graphqlRequestNoStore } from './request.ts';
|
|
8
|
-
|
|
9
|
-
export type FetchOpenSheetOnceParams = {
|
|
10
|
-
selectedTabId?: string | null;
|
|
11
|
-
sinceSeq?: string | null;
|
|
12
|
-
baseSnapshotSeq?: string | null;
|
|
13
|
-
baseSnapshotEncodingVersion?: number | null;
|
|
14
|
-
baseSnapshotChecksum?: string | null;
|
|
15
|
-
viewport?: SheetGridViewportObj | null;
|
|
16
|
-
authToken?: string | null;
|
|
17
|
-
signal?: AbortSignal | null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type FetchOpenSheetTabOnceParams = Omit<
|
|
21
|
-
FetchOpenSheetOnceParams,
|
|
22
|
-
'selectedTabId'
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
* Return canonical variables shared by mounted and imperative openSheet calls.
|
|
27
|
-
*/
|
|
28
|
-
export function getOpenSheetQueryVariables(
|
|
29
|
-
sheetId: string | null | undefined,
|
|
30
|
-
selectedTabId?: string | null,
|
|
31
|
-
sinceSeq?: string | null,
|
|
32
|
-
baseSnapshotSeq?: string | null,
|
|
33
|
-
baseSnapshotEncodingVersion?: number | null,
|
|
34
|
-
baseSnapshotChecksum?: string | null,
|
|
35
|
-
viewport?: SheetGridViewportObj | null,
|
|
36
|
-
) {
|
|
37
|
-
return {
|
|
38
|
-
sheetId,
|
|
39
|
-
selectedTabId: selectedTabId || null,
|
|
40
|
-
sinceSeq: sinceSeq ?? null,
|
|
41
|
-
baseSnapshotSeq: baseSnapshotSeq ?? null,
|
|
42
|
-
baseSnapshotEncodingVersion: baseSnapshotEncodingVersion ?? null,
|
|
43
|
-
baseSnapshotChecksum: baseSnapshotChecksum || null,
|
|
44
|
-
viewport: viewport || null,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/*
|
|
49
|
-
* Return canonical variables for one post-manifest tab-only negotiation.
|
|
50
|
-
*/
|
|
51
|
-
export function getOpenSheetTabQueryVariables(
|
|
52
|
-
sheetId: string | null | undefined,
|
|
53
|
-
sheetTabId: string | null | undefined,
|
|
54
|
-
sinceSeq?: string | null,
|
|
55
|
-
baseSnapshotSeq?: string | null,
|
|
56
|
-
baseSnapshotEncodingVersion?: number | null,
|
|
57
|
-
baseSnapshotChecksum?: string | null,
|
|
58
|
-
viewport?: SheetGridViewportObj | null,
|
|
59
|
-
) {
|
|
60
|
-
return {
|
|
61
|
-
sheetId,
|
|
62
|
-
sheetTabId,
|
|
63
|
-
sinceSeq: sinceSeq ?? null,
|
|
64
|
-
baseSnapshotSeq: baseSnapshotSeq ?? null,
|
|
65
|
-
baseSnapshotEncodingVersion: baseSnapshotEncodingVersion ?? null,
|
|
66
|
-
baseSnapshotChecksum: baseSnapshotChecksum || null,
|
|
67
|
-
viewport: viewport || null,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* Imperatively fetch one openSheet response exactly once without reading,
|
|
73
|
-
* writing, or joining the normalized GraphQL cache. Each invocation owns its
|
|
74
|
-
* network request and carries its authorization token only in request headers.
|
|
75
|
-
*/
|
|
76
|
-
export async function fetchOpenSheetOnce(
|
|
77
|
-
sheetId: string,
|
|
78
|
-
params: FetchOpenSheetOnceParams = {},
|
|
79
|
-
): Promise<SheetBootstrapGQL | null> {
|
|
80
|
-
const result = await graphqlRequestNoStore(
|
|
81
|
-
openSheetQry,
|
|
82
|
-
getOpenSheetQueryVariables(
|
|
83
|
-
sheetId,
|
|
84
|
-
params.selectedTabId,
|
|
85
|
-
params.sinceSeq,
|
|
86
|
-
params.baseSnapshotSeq,
|
|
87
|
-
params.baseSnapshotEncodingVersion,
|
|
88
|
-
params.baseSnapshotChecksum,
|
|
89
|
-
params.viewport,
|
|
90
|
-
),
|
|
91
|
-
{ authToken: params.authToken },
|
|
92
|
-
params.signal,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
if (result?.aborted) {
|
|
96
|
-
throw new DOMException('openSheet request was aborted.', 'AbortError');
|
|
97
|
-
}
|
|
98
|
-
if (result?.error) {
|
|
99
|
-
throw result.error;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return result?.openSheet || null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/*
|
|
106
|
-
* Imperatively fetch one lean post-manifest tab bootstrap without touching the
|
|
107
|
-
* normalized GraphQL cache.
|
|
108
|
-
*/
|
|
109
|
-
export async function fetchOpenSheetTabOnce(
|
|
110
|
-
sheetId: string,
|
|
111
|
-
sheetTabId: string,
|
|
112
|
-
params: FetchOpenSheetTabOnceParams = {},
|
|
113
|
-
): Promise<SheetTabBootstrapGQL | null> {
|
|
114
|
-
const result = await graphqlRequestNoStore(
|
|
115
|
-
openSheetTabQry,
|
|
116
|
-
getOpenSheetTabQueryVariables(
|
|
117
|
-
sheetId,
|
|
118
|
-
sheetTabId,
|
|
119
|
-
params.sinceSeq,
|
|
120
|
-
params.baseSnapshotSeq,
|
|
121
|
-
params.baseSnapshotEncodingVersion,
|
|
122
|
-
params.baseSnapshotChecksum,
|
|
123
|
-
params.viewport,
|
|
124
|
-
),
|
|
125
|
-
{ authToken: params.authToken },
|
|
126
|
-
params.signal,
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
if (result?.aborted) {
|
|
130
|
-
throw new DOMException('openSheetTab request was aborted.', 'AbortError');
|
|
131
|
-
}
|
|
132
|
-
if (result?.error) {
|
|
133
|
-
throw result.error;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return result?.openSheetTab || null;
|
|
137
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { registerENV } from '@jsb188/app';
|
|
2
|
-
import { makeVariablesKey } from '@jsb188/app/utils/logic.ts';
|
|
3
|
-
import { clearGraphQLClientCache, loadDataFromCache } from '../cache/index.ts';
|
|
4
|
-
import { graphqlRequestNoStore, graphqlServerRequest } from './request.ts';
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Build the smallest GraphQL document needed to prove root-cache isolation.
|
|
8
|
-
*/
|
|
9
|
-
function buildOpenSheetTestQuery() {
|
|
10
|
-
return {
|
|
11
|
-
definitions: [
|
|
12
|
-
{
|
|
13
|
-
kind: 'OperationDefinition',
|
|
14
|
-
name: { value: 'openSheet' },
|
|
15
|
-
operation: 'query',
|
|
16
|
-
selectionSet: {
|
|
17
|
-
selections: [
|
|
18
|
-
{
|
|
19
|
-
kind: 'Field',
|
|
20
|
-
name: { value: 'openSheet' },
|
|
21
|
-
selectionSet: {
|
|
22
|
-
selections: [
|
|
23
|
-
{
|
|
24
|
-
kind: 'Field',
|
|
25
|
-
name: { value: 'id' },
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
loc: { source: { body: 'query openSheet { openSheet { id } }' } },
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
Deno.test('graphqlRequestNoStore isolates auth flights and leaves root cache empty', async () => {
|
|
39
|
-
clearGraphQLClientCache();
|
|
40
|
-
registerENV({
|
|
41
|
-
GQL_SERVER: 'https://graphql.test/open-sheet',
|
|
42
|
-
IS_BROWSER: '',
|
|
43
|
-
});
|
|
44
|
-
const originalFetch = globalThis.fetch;
|
|
45
|
-
const authorizationHeaders: Array<string | null> = [];
|
|
46
|
-
globalThis.fetch = (async (_input: URL | RequestInfo, init?: RequestInit) => {
|
|
47
|
-
authorizationHeaders.push(new Headers(init?.headers).get('authorization'));
|
|
48
|
-
return new Response(
|
|
49
|
-
JSON.stringify({ data: { openSheet: { id: 'sheet-1' } } }),
|
|
50
|
-
{
|
|
51
|
-
status: 200,
|
|
52
|
-
headers: { 'content-type': 'application/json' },
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
}) as typeof fetch;
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const gqlQuery = buildOpenSheetTestQuery();
|
|
59
|
-
const variables = { sheetId: 'sheet-1' };
|
|
60
|
-
const [first, second] = await Promise.all([
|
|
61
|
-
graphqlRequestNoStore(gqlQuery, variables, {
|
|
62
|
-
authToken: 'auth-token-a',
|
|
63
|
-
}),
|
|
64
|
-
graphqlRequestNoStore(gqlQuery, variables, {
|
|
65
|
-
authToken: 'auth-token-b',
|
|
66
|
-
}),
|
|
67
|
-
]);
|
|
68
|
-
const cachedData = loadDataFromCache(
|
|
69
|
-
{},
|
|
70
|
-
gqlQuery,
|
|
71
|
-
makeVariablesKey(variables),
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
JSON.stringify(authorizationHeaders) !==
|
|
76
|
-
JSON.stringify(['auth-token-a', 'auth-token-b'])
|
|
77
|
-
) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
'No-store calls did not preserve independent auth headers.',
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
if (
|
|
83
|
-
first?.openSheet?.id !== 'sheet-1' ||
|
|
84
|
-
second?.openSheet?.id !== 'sheet-1'
|
|
85
|
-
) {
|
|
86
|
-
throw new Error('No-store responses were not returned independently.');
|
|
87
|
-
}
|
|
88
|
-
if (Object.keys(cachedData).length) {
|
|
89
|
-
throw new Error('No-store response entered the root query cache.');
|
|
90
|
-
}
|
|
91
|
-
} finally {
|
|
92
|
-
globalThis.fetch = originalFetch;
|
|
93
|
-
clearGraphQLClientCache();
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
Deno.test('graphqlServerRequest reuses results within one account cache scope', async () => {
|
|
98
|
-
registerENV({
|
|
99
|
-
GQL_SERVER: 'https://graphql.test/server-cache',
|
|
100
|
-
IS_BROWSER: '',
|
|
101
|
-
});
|
|
102
|
-
const originalFetch = globalThis.fetch;
|
|
103
|
-
let fetchCount = 0;
|
|
104
|
-
globalThis.fetch = (async (_input: URL | RequestInfo, init?: RequestInit) => {
|
|
105
|
-
fetchCount++;
|
|
106
|
-
return new Response(
|
|
107
|
-
JSON.stringify({
|
|
108
|
-
data: {
|
|
109
|
-
openSheet: {
|
|
110
|
-
id: new Headers(init?.headers).get('authorization'),
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
}),
|
|
114
|
-
{
|
|
115
|
-
status: 200,
|
|
116
|
-
headers: { 'content-type': 'application/json' },
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
}) as typeof fetch;
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
const gqlQuery = buildOpenSheetTestQuery();
|
|
123
|
-
const variables = { sheetId: 'server-cache-sheet' };
|
|
124
|
-
const [first, joined] = await Promise.all([
|
|
125
|
-
graphqlServerRequest(gqlQuery, variables, {
|
|
126
|
-
authToken: 'auth-token-a',
|
|
127
|
-
cacheAccountId: 'account-a',
|
|
128
|
-
}),
|
|
129
|
-
graphqlServerRequest(gqlQuery, variables, {
|
|
130
|
-
authToken: 'auth-token-a',
|
|
131
|
-
cacheAccountId: 'account-a',
|
|
132
|
-
}),
|
|
133
|
-
]);
|
|
134
|
-
const cached = await graphqlServerRequest(gqlQuery, variables, {
|
|
135
|
-
authToken: 'auth-token-a',
|
|
136
|
-
cacheAccountId: 'account-a',
|
|
137
|
-
});
|
|
138
|
-
const otherAccount = await graphqlServerRequest(gqlQuery, variables, {
|
|
139
|
-
authToken: 'auth-token-b',
|
|
140
|
-
cacheAccountId: 'account-b',
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
fetchCount !== 2 ||
|
|
145
|
-
first?.openSheet?.id !== 'auth-token-a' ||
|
|
146
|
-
joined?.openSheet?.id !== 'auth-token-a' ||
|
|
147
|
-
cached?.openSheet?.id !== 'auth-token-a' ||
|
|
148
|
-
otherAccount?.openSheet?.id !== 'auth-token-b'
|
|
149
|
-
) {
|
|
150
|
-
throw new Error(
|
|
151
|
-
'Server request cache did not preserve account-scoped reuse.',
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
} finally {
|
|
155
|
-
globalThis.fetch = originalFetch;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// NOTE: The selection set must stay exactly aligned with the server's
|
|
2
|
-
// realtime $agentDocFragment emit (mapDataToGraphQLFragment 'agent_docs' case
|
|
3
|
-
// in server/src/utils/graphql-data.ts) so useReactiveFragment merges cleanly.
|
|
4
|
-
// Viewer-specific facts (viewerPermission, viewerCanEditAccess) are never
|
|
5
|
-
// emitted over WS, so they are selected by the agentDoc query, not here.
|
|
6
|
-
|
|
7
|
-
export const agentDocFragment = `fragment agentDocFragment on AgentDoc {
|
|
8
|
-
id
|
|
9
|
-
organizationId
|
|
10
|
-
accountId
|
|
11
|
-
lastEditAccountId
|
|
12
|
-
folderId
|
|
13
|
-
|
|
14
|
-
title
|
|
15
|
-
content
|
|
16
|
-
position
|
|
17
|
-
deletedAt
|
|
18
|
-
|
|
19
|
-
access {
|
|
20
|
-
team
|
|
21
|
-
public
|
|
22
|
-
network
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
settings {
|
|
26
|
-
aiCannotEdit
|
|
27
|
-
aiCannotRead
|
|
28
|
-
pinned
|
|
29
|
-
hiddenSurfaces
|
|
30
|
-
reviewBy
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
files {
|
|
34
|
-
id
|
|
35
|
-
uri
|
|
36
|
-
size
|
|
37
|
-
contentType
|
|
38
|
-
at
|
|
39
|
-
intent
|
|
40
|
-
name
|
|
41
|
-
description
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
createdAt
|
|
45
|
-
updatedAt
|
|
46
|
-
}`;
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { gql } from 'graphql-tag';
|
|
2
|
-
import { agentDocFragment } from '../fragments/agentDocFragments.ts';
|
|
3
|
-
|
|
4
|
-
export const createAgentDocMtn = gql`
|
|
5
|
-
mutation createAgentDoc (
|
|
6
|
-
$organizationId: GenericID!
|
|
7
|
-
$title: String
|
|
8
|
-
$folderId: GenericID
|
|
9
|
-
$position: Float
|
|
10
|
-
) {
|
|
11
|
-
createAgentDoc (
|
|
12
|
-
organizationId: $organizationId
|
|
13
|
-
title: $title
|
|
14
|
-
folderId: $folderId
|
|
15
|
-
position: $position
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
// NOTE: content is the noteDoc document serialized as JSON text (the caller
|
|
21
|
-
// must JSON.stringify the sanitized doc), and imageStorageIds carries every
|
|
22
|
-
// image storageId still present in the doc so the server can reconcile
|
|
23
|
-
// agent_doc_storage_rels against it.
|
|
24
|
-
|
|
25
|
-
export const updateAgentDocMtn = gql`
|
|
26
|
-
mutation updateAgentDoc (
|
|
27
|
-
$organizationId: GenericID!
|
|
28
|
-
$agentDocId: GenericID!
|
|
29
|
-
$title: String
|
|
30
|
-
$content: String
|
|
31
|
-
$folderId: GenericID
|
|
32
|
-
$imageStorageIds: [GenericID!]
|
|
33
|
-
) {
|
|
34
|
-
updateAgentDoc (
|
|
35
|
-
organizationId: $organizationId
|
|
36
|
-
agentDocId: $agentDocId
|
|
37
|
-
title: $title
|
|
38
|
-
content: $content
|
|
39
|
-
folderId: $folderId
|
|
40
|
-
imageStorageIds: $imageStorageIds
|
|
41
|
-
) {
|
|
42
|
-
...agentDocFragment
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
${agentDocFragment}
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
export const deleteAgentDocMtn = gql`
|
|
50
|
-
mutation deleteAgentDoc (
|
|
51
|
-
$organizationId: GenericID!
|
|
52
|
-
$agentDocId: GenericID!
|
|
53
|
-
) {
|
|
54
|
-
deleteAgentDoc (
|
|
55
|
-
organizationId: $organizationId
|
|
56
|
-
agentDocId: $agentDocId
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
// NOTE: The selection is intentionally NOT agentDocFragment: the access
|
|
62
|
-
// record update returns the bare row (no rels attached), so selecting
|
|
63
|
-
// content/files here would merge rel-unfiltered content and an empty files
|
|
64
|
-
// list over the issuer's cached agentDoc fragment. Only the access-relevant
|
|
65
|
-
// fields update.
|
|
66
|
-
|
|
67
|
-
export const updateAgentDocAccessMtn = gql`
|
|
68
|
-
mutation updateAgentDocAccess (
|
|
69
|
-
$organizationId: GenericID!
|
|
70
|
-
$agentDocId: GenericID!
|
|
71
|
-
$access: DocAccessInput!
|
|
72
|
-
) {
|
|
73
|
-
updateAgentDocAccess (
|
|
74
|
-
organizationId: $organizationId
|
|
75
|
-
agentDocId: $agentDocId
|
|
76
|
-
access: $access
|
|
77
|
-
) {
|
|
78
|
-
id
|
|
79
|
-
organizationId
|
|
80
|
-
|
|
81
|
-
access {
|
|
82
|
-
team
|
|
83
|
-
public
|
|
84
|
-
network
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
updatedAt
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
91
|
-
|
|
92
|
-
// NOTE: Same bare-row rule as updateAgentDocAccess: the settings update
|
|
93
|
-
// returns the row without rels attached, so only the settings-relevant
|
|
94
|
-
// fields are selected to keep the issuer's cached content/files intact.
|
|
95
|
-
|
|
96
|
-
export const updateAgentDocSettingsMtn = gql`
|
|
97
|
-
mutation updateAgentDocSettings (
|
|
98
|
-
$organizationId: GenericID!
|
|
99
|
-
$agentDocId: GenericID!
|
|
100
|
-
$settings: AgentDocSettingsInput!
|
|
101
|
-
) {
|
|
102
|
-
updateAgentDocSettings (
|
|
103
|
-
organizationId: $organizationId
|
|
104
|
-
agentDocId: $agentDocId
|
|
105
|
-
settings: $settings
|
|
106
|
-
) {
|
|
107
|
-
id
|
|
108
|
-
organizationId
|
|
109
|
-
|
|
110
|
-
settings {
|
|
111
|
-
aiCannotEdit
|
|
112
|
-
aiCannotRead
|
|
113
|
-
pinned
|
|
114
|
-
hiddenSurfaces
|
|
115
|
-
reviewBy
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
updatedAt
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
|
-
export const createAgentDocFolderMtn = gql`
|
|
124
|
-
mutation createAgentDocFolder (
|
|
125
|
-
$organizationId: GenericID!
|
|
126
|
-
$name: String!
|
|
127
|
-
$position: Float
|
|
128
|
-
) {
|
|
129
|
-
createAgentDocFolder (
|
|
130
|
-
organizationId: $organizationId
|
|
131
|
-
name: $name
|
|
132
|
-
position: $position
|
|
133
|
-
) {
|
|
134
|
-
id
|
|
135
|
-
organizationId
|
|
136
|
-
name
|
|
137
|
-
position
|
|
138
|
-
createdAt
|
|
139
|
-
updatedAt
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
`;
|
|
143
|
-
|
|
144
|
-
export const updateAgentDocFolderMtn = gql`
|
|
145
|
-
mutation updateAgentDocFolder (
|
|
146
|
-
$organizationId: GenericID!
|
|
147
|
-
$folderId: GenericID!
|
|
148
|
-
$name: String
|
|
149
|
-
$position: Float
|
|
150
|
-
) {
|
|
151
|
-
updateAgentDocFolder (
|
|
152
|
-
organizationId: $organizationId
|
|
153
|
-
folderId: $folderId
|
|
154
|
-
name: $name
|
|
155
|
-
position: $position
|
|
156
|
-
) {
|
|
157
|
-
id
|
|
158
|
-
organizationId
|
|
159
|
-
name
|
|
160
|
-
position
|
|
161
|
-
createdAt
|
|
162
|
-
updatedAt
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
`;
|
|
166
|
-
|
|
167
|
-
export const deleteAgentDocFolderMtn = gql`
|
|
168
|
-
mutation deleteAgentDocFolder (
|
|
169
|
-
$organizationId: GenericID!
|
|
170
|
-
$folderId: GenericID!
|
|
171
|
-
) {
|
|
172
|
-
deleteAgentDocFolder (
|
|
173
|
-
organizationId: $organizationId
|
|
174
|
-
folderId: $folderId
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
`;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { gql } from 'graphql-tag';
|
|
2
|
-
import { agentDocFragment } from '../fragments/agentDocFragments.ts';
|
|
3
|
-
|
|
4
|
-
export const agentDocMetadataQry = gql`
|
|
5
|
-
query agentDocMetadata (
|
|
6
|
-
$agentDocId: GenericID!
|
|
7
|
-
) {
|
|
8
|
-
agentDoc (
|
|
9
|
-
agentDocId: $agentDocId
|
|
10
|
-
) {
|
|
11
|
-
id
|
|
12
|
-
title
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
// NOTE: viewerPermission and viewerCanEditAccess are per-viewer facts
|
|
18
|
-
// resolved by the server for the requesting account. They are selected
|
|
19
|
-
// outside agentDocFragment because realtime emits never carry them, and the
|
|
20
|
-
// fragment must stay aligned with the server's emit field list.
|
|
21
|
-
// The query takes no organizationId: the server resolves the owner org from
|
|
22
|
-
// the agent doc row (openSheet-style contract), so network-org members and
|
|
23
|
-
// grant holders outside the owner org can open a shared agent doc.
|
|
24
|
-
|
|
25
|
-
export const agentDocQry = gql`
|
|
26
|
-
query agentDoc (
|
|
27
|
-
$agentDocId: GenericID!
|
|
28
|
-
) {
|
|
29
|
-
agentDoc (
|
|
30
|
-
agentDocId: $agentDocId
|
|
31
|
-
) {
|
|
32
|
-
...agentDocFragment
|
|
33
|
-
|
|
34
|
-
viewerPermission
|
|
35
|
-
viewerCanEditAccess
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
${agentDocFragment}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
// NOTE: The list selection intentionally excludes content and files: the
|
|
43
|
-
// list screen only needs row metadata, and merging a content-free selection
|
|
44
|
-
// through the normalized cache must not clobber a full agentDoc fragment,
|
|
45
|
-
// so the heavy fields are simply never selected here.
|
|
46
|
-
|
|
47
|
-
export const agentDocsQry = gql`
|
|
48
|
-
query agentDocs (
|
|
49
|
-
$organizationId: GenericID!
|
|
50
|
-
$folderId: GenericID
|
|
51
|
-
$sort: GridItemSort
|
|
52
|
-
$cursor: Cursor
|
|
53
|
-
$after: Boolean!
|
|
54
|
-
$limit: Int!
|
|
55
|
-
) {
|
|
56
|
-
agentDocs (
|
|
57
|
-
organizationId: $organizationId
|
|
58
|
-
folderId: $folderId
|
|
59
|
-
sort: $sort
|
|
60
|
-
cursor: $cursor
|
|
61
|
-
after: $after
|
|
62
|
-
limit: $limit
|
|
63
|
-
) {
|
|
64
|
-
id
|
|
65
|
-
organizationId
|
|
66
|
-
folderId
|
|
67
|
-
title
|
|
68
|
-
|
|
69
|
-
settings {
|
|
70
|
-
aiCannotEdit
|
|
71
|
-
aiCannotRead
|
|
72
|
-
pinned
|
|
73
|
-
hiddenSurfaces
|
|
74
|
-
reviewBy
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
position
|
|
78
|
-
deletedAt
|
|
79
|
-
createdAt
|
|
80
|
-
updatedAt
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
`;
|
|
84
|
-
|
|
85
|
-
export const agentDocFoldersQry = gql`
|
|
86
|
-
query agentDocFolders (
|
|
87
|
-
$organizationId: GenericID!
|
|
88
|
-
) {
|
|
89
|
-
agentDocFolders (
|
|
90
|
-
organizationId: $organizationId
|
|
91
|
-
) {
|
|
92
|
-
id
|
|
93
|
-
organizationId
|
|
94
|
-
name
|
|
95
|
-
position
|
|
96
|
-
createdAt
|
|
97
|
-
updatedAt
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
// NOTE: agentDocAccessGrants is owner-org only: the access settings screen
|
|
103
|
-
// loads the grants list with it, on top of the base policy carried by the
|
|
104
|
-
// AgentDoc fragment's "access" selection.
|
|
105
|
-
|
|
106
|
-
export const agentDocAccessGrantsQry = gql`
|
|
107
|
-
query agentDocAccessGrants (
|
|
108
|
-
$organizationId: GenericID!
|
|
109
|
-
$agentDocId: GenericID!
|
|
110
|
-
) {
|
|
111
|
-
agentDocAccessGrants (
|
|
112
|
-
organizationId: $organizationId
|
|
113
|
-
agentDocId: $agentDocId
|
|
114
|
-
) {
|
|
115
|
-
granteeType
|
|
116
|
-
granteeId
|
|
117
|
-
permission
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
`;
|