@jsb188/graphql 1.1.8 → 1.1.11
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/cache/config.ts +66 -42
- package/cache/index.test.ts +881 -0
- package/cache/index.ts +1815 -979
- package/cache/persist.ts +721 -0
- package/cache/store.ts +437 -0
- package/client/data-table-realtime-subscriptions.test.ts +740 -0
- package/client/data-table-realtime-subscriptions.ts +955 -0
- package/client/data-table-realtime.test.ts +792 -0
- package/client/data-table-realtime.ts +1218 -0
- package/client/fragment-realtime-sequence.ts +52 -0
- package/client/index.ts +4 -2
- package/client/open-sheet.ts +137 -0
- package/client/request-managed-session.test.ts +574 -0
- package/client/request-no-store.test.ts +157 -0
- package/client/request.ts +973 -143
- package/client/sse-ticket.test.ts +26 -0
- package/deno.lock +170 -0
- package/deno.test.json +10 -0
- package/drafts/index.ts +149 -0
- package/drafts/store.ts +397 -0
- package/gql/eagerQueryMap.ts +12 -0
- package/gql/fragments/accountAuthFragments.ts +5 -0
- package/gql/fragments/accountFragments.ts +1 -3
- package/gql/fragments/accountSessionFragments.ts +16 -0
- package/gql/fragments/agentDocFragments.ts +46 -0
- package/gql/fragments/agentMemoryFragments.ts +19 -0
- package/gql/fragments/aiChatFragments.ts +17 -0
- package/gql/fragments/billingFragments.ts +0 -11
- package/gql/fragments/campaignFragments.ts +277 -0
- package/gql/fragments/dataTableFragments.ts +102 -0
- package/gql/fragments/emailFragments.ts +36 -0
- package/gql/fragments/fieldDocFragments.ts +82 -0
- package/gql/fragments/inboundContactFragments.ts +15 -0
- package/gql/fragments/integrationFragments.ts +22 -0
- package/gql/fragments/logFragments.ts +33 -64
- package/gql/fragments/organizationFragments.ts +94 -21
- package/gql/fragments/scheduleFragments.ts +155 -0
- package/gql/fragments/sheetFragments.ts +675 -0
- package/gql/fragments/storageFragments.ts +21 -1
- package/gql/fragments/workflowFragments.ts +67 -0
- package/gql/mutations/accountMutations.ts +24 -4
- package/gql/mutations/agentDocMutations.ts +177 -0
- package/gql/mutations/agentMemoryMutations.ts +36 -0
- package/gql/mutations/aiChatMutations.ts +43 -3
- package/gql/mutations/authMutations.ts +160 -19
- package/gql/mutations/campaignMutations.ts +215 -0
- package/gql/mutations/dataTableMutations.ts +106 -0
- package/gql/mutations/fieldDocMutations.ts +24 -0
- package/gql/mutations/inboundContactMutations.ts +24 -0
- package/gql/mutations/index.ts +17 -8
- package/gql/mutations/integrationMutations.ts +25 -0
- package/gql/mutations/logMutations.ts +10 -19
- package/gql/mutations/organizationMutations.ts +160 -2
- package/gql/mutations/scheduleMutations.ts +423 -0
- package/gql/mutations/sheetMutations.ts +385 -0
- package/gql/mutations/storageMutations.ts +21 -2
- package/gql/mutations/workflowMutations.ts +42 -0
- package/gql/queries/agentDocQueries.ts +120 -0
- package/gql/queries/agentMemoryQueries.ts +22 -0
- package/gql/queries/aiChatQueries.ts +18 -2
- package/gql/queries/authQueries.ts +41 -0
- package/gql/queries/billingQueries.ts +24 -1
- package/gql/queries/campaignQueries.ts +127 -0
- package/gql/queries/dataTableQueries.ts +134 -0
- package/gql/queries/emailQueries.ts +96 -0
- package/gql/queries/fieldDocQueries.ts +158 -0
- package/gql/queries/inboundContactQueries.ts +40 -0
- package/gql/queries/index.ts +17 -6
- package/gql/queries/logQueries.ts +42 -32
- package/gql/queries/organizationQueries.ts +113 -8
- package/gql/queries/scheduleQueries.ts +315 -0
- package/gql/queries/sheetQueries.ts +383 -0
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +99 -0
- package/hooks/index.ts +2104 -860
- package/hooks/use-account-mtn.ts +91 -48
- package/hooks/use-agentDoc-mtn.ts +285 -0
- package/hooks/use-agentDoc-qry.ts +208 -0
- package/hooks/use-agentMemory-mtn.ts +73 -0
- package/hooks/use-agentMemory-qry.ts +44 -0
- package/hooks/use-aiChat-mtn.ts +248 -97
- package/hooks/use-aiChat-qry.ts +501 -191
- package/hooks/use-app-qry.ts +14 -11
- package/hooks/use-auth-mtn.ts +410 -256
- package/hooks/use-auth-qry.ts +51 -0
- package/hooks/use-campaign-mtn.ts +377 -0
- package/hooks/use-campaign-qry.ts +257 -0
- package/hooks/use-dataTable-mtn.ts +170 -0
- package/hooks/use-dataTable-qry.ts +996 -0
- package/hooks/use-email-qry.ts +227 -0
- package/hooks/use-fieldDoc-mtn.ts +50 -0
- package/hooks/use-fieldDoc-qry.ts +180 -0
- package/hooks/use-inboundContact-mtn.ts +34 -0
- package/hooks/use-inboundContact-qry.ts +96 -0
- package/hooks/use-integration-mtn.ts +77 -0
- package/hooks/use-integration-qry.ts +30 -0
- package/hooks/use-log-mtn.ts +77 -61
- package/hooks/use-log-qry.ts +99 -72
- package/hooks/use-organization-mtn.ts +409 -80
- package/hooks/use-organization-qry.ts +211 -92
- package/hooks/use-schedule-mtn.ts +416 -0
- package/hooks/use-schedule-qry.ts +157 -0
- package/hooks/use-sheet-mtn.ts +367 -0
- package/hooks/use-sheet-qry.ts +440 -0
- package/hooks/use-storage-mtn.ts +83 -42
- package/hooks/use-storage-qry.ts +104 -13
- package/hooks/use-workflow-mtn.ts +55 -0
- package/hooks/use-workflow-qry.ts +230 -0
- package/loaders/campaign.ts +137 -0
- package/package.json +94 -52
- package/sse.ts +158 -105
- package/tsconfig.json +13 -0
- package/types.d.ts +60 -29
- package/utils.ts +77 -50
- package/gql/fragments/actionFragments.ts +0 -16
- package/gql/fragments/productFragments.ts +0 -63
- package/gql/fragments/reportFragments.ts +0 -48
- package/gql/mutations/billingMutations.ts +0 -34
- package/gql/queries/productQueries.ts +0 -70
- package/gql/queries/reportQueries.ts +0 -66
- package/hooks/use-product-qry.ts +0 -109
- package/hooks/use-report-qry.ts +0 -69
|
@@ -0,0 +1,157 @@
|
|
|
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
|
+
});
|