@jsb188/graphql 1.1.10 → 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 +98 -50
- 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 +1017 -127
- package/cache/index.ts +1256 -1269
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +800 -0
- package/cache/store.ts +395 -0
- package/cache/value.helpers.ts +17 -0
- package/client/draft-persistence-indexed-db.ts +413 -0
- package/client/draft-persistence.ts +152 -0
- package/client/index.ts +3 -0
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +870 -164
- package/deno.lock +187 -0
- package/deno.test.json +10 -4
- package/gql/eagerQueryMap.ts +12 -0
- package/gql/fragments/accountAuthFragments.ts +5 -0
- package/gql/fragments/accountFragments.ts +0 -3
- package/gql/fragments/accountSessionFragments.ts +16 -0
- package/gql/fragments/agentMemoryFragments.ts +23 -0
- package/gql/fragments/agentNoteFragments.ts +150 -0
- package/gql/fragments/aiChatFragments.ts +42 -0
- package/gql/fragments/audienceFragments.ts +141 -0
- package/gql/fragments/campaignFragments.ts +566 -0
- package/gql/fragments/dataTableFragments.ts +50 -192
- package/gql/fragments/emailFragments.ts +32 -17
- package/gql/fragments/fieldDocFragments.ts +264 -0
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/logFragments.ts +101 -69
- package/gql/fragments/organizationFragments.ts +53 -5
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +667 -0
- package/gql/fragments/sheetFragments.ts +304 -63
- package/gql/fragments/storageFragments.ts +45 -0
- package/gql/fragments/workflowFragments.ts +41 -5
- package/gql/mutations/accountMutations.ts +0 -2
- package/gql/mutations/agentMemoryMutations.ts +68 -0
- package/gql/mutations/agentNoteMutations.ts +62 -0
- package/gql/mutations/aiChatMutations.ts +49 -4
- package/gql/mutations/audienceMutations.ts +71 -0
- package/gql/mutations/authMutations.ts +203 -18
- package/gql/mutations/billingMutations.ts +17 -27
- package/gql/mutations/campaignMutations.ts +258 -0
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +19 -54
- package/gql/mutations/fieldDocMutations.ts +173 -0
- package/gql/mutations/index.ts +10 -2
- package/gql/mutations/logMutations.ts +6 -29
- package/gql/mutations/organizationMutations.ts +19 -4
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +1121 -0
- package/gql/mutations/sheetMutations.ts +221 -60
- package/gql/mutations/storageMutations.ts +19 -0
- package/gql/mutations/workflowMutations.ts +60 -0
- package/gql/queries/agentMemoryQueries.ts +28 -0
- package/gql/queries/agentNoteQueries.ts +89 -0
- package/gql/queries/aiChatQueries.ts +70 -2
- package/gql/queries/audienceQueries.ts +128 -0
- package/gql/queries/authQueries.ts +47 -0
- package/gql/queries/billingQueries.ts +118 -6
- package/gql/queries/campaignQueries.ts +236 -0
- package/gql/queries/dataTableQueries.ts +61 -13
- package/gql/queries/emailQueries.ts +26 -17
- package/gql/queries/emailReplyReportQueries.ts +76 -0
- package/gql/queries/fieldDocQueries.ts +166 -0
- package/gql/queries/inboundContactQueries.ts +4 -0
- package/gql/queries/index.ts +10 -2
- package/gql/queries/logQueries.ts +68 -30
- package/gql/queries/organizationQueries.ts +65 -1
- package/gql/queries/qrCodeQueries.ts +20 -0
- package/gql/queries/scheduleQueries.ts +691 -0
- package/gql/queries/sheetQueries.ts +244 -26
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +77 -2
- package/hooks/index.helpers.test.ts +50 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +2254 -982
- package/hooks/use-account-mtn.ts +76 -81
- package/hooks/use-agentMemory-mtn.ts +71 -0
- package/hooks/use-agentMemory-qry.ts +56 -0
- 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 +220 -141
- 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 +341 -237
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- package/hooks/use-app-qry.ts +12 -9
- 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 +435 -252
- package/hooks/use-auth-qry.ts +51 -0
- 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 +436 -0
- package/hooks/use-campaign-qry.helpers.ts +40 -0
- package/hooks/use-campaign-qry.ts +834 -0
- package/hooks/use-dataTable-mtn.ts +37 -46
- package/hooks/use-dataTable-qry.ts +102 -128
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +56 -86
- package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
- package/hooks/use-fieldDoc-mtn.ts +262 -0
- 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 +212 -0
- package/hooks/use-inboundContact-mtn.ts +19 -16
- package/hooks/use-inboundContact-qry.ts +62 -56
- package/hooks/use-integration-mtn.ts +56 -38
- package/hooks/use-integration-qry.ts +24 -9
- package/hooks/use-log-mtn.ts +88 -59
- package/hooks/use-log-qry.ts +150 -73
- package/hooks/use-organization-mtn.ts +334 -277
- package/hooks/use-organization-qry.ts +155 -129
- 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 +589 -0
- package/hooks/use-schedule-qry.ts +738 -0
- package/hooks/use-schedule-reactive.ts +486 -0
- package/hooks/use-sheet-mtn.ts +157 -79
- package/hooks/use-sheet-qry.ts +221 -92
- package/hooks/use-storage-mtn.ts +81 -41
- package/hooks/use-storage-qry.ts +128 -14
- package/hooks/use-workflow-mtn.ts +72 -0
- package/hooks/use-workflow-qry.ts +184 -47
- 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/libs/request-managed-session.test.ts +574 -0
- 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/libs/sse-ticket.test.ts +26 -0
- package/loaders/campaign.test.ts +186 -0
- package/loaders/campaign.ts +110 -0
- package/loaders/emailPreference.ts +75 -0
- package/loaders/rest.ts +12 -0
- package/package.json +119 -71
- package/schedule.d.ts +1790 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +70 -106
- package/tests/agent-note-detail-cache.test.ts +120 -0
- package/tests/agent-note-search.test.ts +444 -0
- package/tsconfig.json +11 -10
- package/types.d.ts +77 -26
- package/utils.ts +78 -49
- package/gql/fragments/billingFragments.ts +0 -25
- package/gql/fragments/productFragments.ts +0 -39
- package/gql/fragments/reportFragments.ts +0 -90
- package/gql/queries/productQueries.ts +0 -31
- package/gql/queries/reportQueries.ts +0 -134
- package/hooks/use-product-qry.ts +0 -67
- package/hooks/use-report-qry.ts +0 -153
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { gql } from 'graphql-tag';
|
|
2
|
-
import {
|
|
2
|
+
import { sheetFragment, sheetMetadataFragment, sheetTabFragment, sheetTabSummaryFragment } from '../fragments/sheetFragments.ts';
|
|
3
3
|
|
|
4
4
|
export const sheetsQry = gql`
|
|
5
5
|
query sheets (
|
|
6
6
|
$organizationId: GenericID!
|
|
7
|
-
$
|
|
7
|
+
$sort: GridItemSort
|
|
8
|
+
$cursor: Cursor
|
|
9
|
+
$after: Boolean!
|
|
10
|
+
$limit: Int!
|
|
8
11
|
) {
|
|
9
12
|
sheets (
|
|
10
13
|
organizationId: $organizationId
|
|
11
|
-
|
|
14
|
+
sort: $sort
|
|
15
|
+
cursor: $cursor
|
|
16
|
+
after: $after
|
|
17
|
+
limit: $limit
|
|
12
18
|
) {
|
|
13
19
|
...sheetFragment
|
|
14
20
|
}
|
|
@@ -17,56 +23,268 @@ query sheets (
|
|
|
17
23
|
${sheetFragment}
|
|
18
24
|
`;
|
|
19
25
|
|
|
20
|
-
export const
|
|
21
|
-
query
|
|
22
|
-
$organizationId: GenericID!
|
|
26
|
+
export const publicSheetMetadataQry = gql`
|
|
27
|
+
query publicSheetMetadata (
|
|
23
28
|
$sheetId: GenericID!
|
|
24
29
|
) {
|
|
25
|
-
|
|
26
|
-
organizationId: $organizationId
|
|
30
|
+
publicSheetMetadata (
|
|
27
31
|
sheetId: $sheetId
|
|
28
32
|
) {
|
|
29
|
-
...
|
|
33
|
+
...sheetMetadataFragment
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
${
|
|
37
|
+
${sheetMetadataFragment}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
// NOTE: sheetAccess is viewer-specific and works signed out: the public
|
|
41
|
+
// sheet route uses it to learn the owner org and view/edit facts, and the
|
|
42
|
+
// in-app Sheet page uses it for the viewer's effective edit fact (grants
|
|
43
|
+
// are per-viewer overrides, so the base policy alone cannot decide it).
|
|
44
|
+
|
|
45
|
+
export const sheetAccessQry = gql`
|
|
46
|
+
query sheetAccess (
|
|
47
|
+
$sheetId: GenericID!
|
|
48
|
+
) {
|
|
49
|
+
sheetAccess (
|
|
50
|
+
sheetId: $sheetId
|
|
51
|
+
) {
|
|
52
|
+
sheetId
|
|
53
|
+
organizationId
|
|
54
|
+
canView
|
|
55
|
+
canEdit
|
|
56
|
+
signInRequired
|
|
57
|
+
}
|
|
58
|
+
}
|
|
34
59
|
`;
|
|
35
60
|
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
// NOTE: sheetAccessGrants is owner-org only: the access settings screen
|
|
62
|
+
// loads the grants list with it, on top of the base policy carried by the
|
|
63
|
+
// Sheet fragment's "access" selection.
|
|
64
|
+
|
|
65
|
+
export const sheetAccessGrantsQry = gql`
|
|
66
|
+
query sheetAccessGrants (
|
|
38
67
|
$organizationId: GenericID!
|
|
39
68
|
$sheetId: GenericID!
|
|
40
|
-
$viewport: SheetGridViewportInput!
|
|
41
69
|
) {
|
|
42
|
-
|
|
70
|
+
sheetAccessGrants (
|
|
43
71
|
organizationId: $organizationId
|
|
44
72
|
sheetId: $sheetId
|
|
45
|
-
viewport: $viewport
|
|
46
73
|
) {
|
|
47
|
-
|
|
74
|
+
granteeType
|
|
75
|
+
granteeId
|
|
76
|
+
permission
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
// NOTE: openSheet is the page-bootstrap contract (contract 4). It derives the
|
|
82
|
+
// owner org from sheetId, folds viewer access into the response, and serves a
|
|
83
|
+
// DELTA after the client's applied sinceSeq or a SNAPSHOT plus its tail (with
|
|
84
|
+
// the topology rows the image absorbed after sinceSeq, so pending work
|
|
85
|
+
// re-maps through them).
|
|
86
|
+
|
|
87
|
+
export const openSheetQry = gql`
|
|
88
|
+
query openSheet (
|
|
89
|
+
$sheetId: GenericID!
|
|
90
|
+
$selectedTabId: GenericID
|
|
91
|
+
$sinceSeq: BigInt
|
|
92
|
+
$requireSnapshot: Boolean
|
|
93
|
+
) {
|
|
94
|
+
openSheet (
|
|
95
|
+
sheetId: $sheetId
|
|
96
|
+
selectedTabId: $selectedTabId
|
|
97
|
+
sinceSeq: $sinceSeq
|
|
98
|
+
requireSnapshot: $requireSnapshot
|
|
99
|
+
) {
|
|
100
|
+
access {
|
|
101
|
+
sheetId
|
|
102
|
+
organizationId
|
|
103
|
+
canView
|
|
104
|
+
canEdit
|
|
105
|
+
signInRequired
|
|
106
|
+
}
|
|
48
107
|
|
|
108
|
+
contractVersion
|
|
109
|
+
realtimeToken
|
|
110
|
+
status
|
|
111
|
+
unavailableReason
|
|
49
112
|
sheet {
|
|
50
113
|
...sheetFragment
|
|
51
114
|
}
|
|
52
115
|
|
|
53
|
-
|
|
54
|
-
...
|
|
116
|
+
tabs {
|
|
117
|
+
...sheetTabSummaryFragment
|
|
55
118
|
}
|
|
56
119
|
|
|
57
|
-
|
|
58
|
-
...
|
|
120
|
+
selectedTab {
|
|
121
|
+
...sheetTabFragment
|
|
59
122
|
}
|
|
60
123
|
|
|
61
|
-
|
|
62
|
-
|
|
124
|
+
mode
|
|
125
|
+
currentSeq
|
|
126
|
+
servedViewport {
|
|
127
|
+
startRowIndex
|
|
128
|
+
startColumnIndex
|
|
129
|
+
rowCount
|
|
130
|
+
columnCount
|
|
63
131
|
}
|
|
132
|
+
|
|
133
|
+
snapshot {
|
|
134
|
+
seq
|
|
135
|
+
encodingVersion
|
|
136
|
+
viewport {
|
|
137
|
+
startRowIndex
|
|
138
|
+
startColumnIndex
|
|
139
|
+
rowCount
|
|
140
|
+
columnCount
|
|
141
|
+
}
|
|
142
|
+
payload
|
|
143
|
+
checksum
|
|
144
|
+
cellCount
|
|
145
|
+
payloadBytes
|
|
146
|
+
createdAt
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
changes {
|
|
150
|
+
sheetTabId
|
|
151
|
+
seq
|
|
152
|
+
kind
|
|
153
|
+
payload
|
|
154
|
+
commandId
|
|
155
|
+
causationId
|
|
156
|
+
sessionId
|
|
157
|
+
commandType
|
|
158
|
+
createdAt
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
topologyChanges {
|
|
162
|
+
sheetTabId
|
|
163
|
+
seq
|
|
164
|
+
kind
|
|
165
|
+
payload
|
|
166
|
+
commandId
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
topologyComplete
|
|
64
170
|
}
|
|
65
171
|
}
|
|
66
172
|
|
|
67
|
-
${sheetGridFragment}
|
|
68
173
|
${sheetFragment}
|
|
69
|
-
${
|
|
70
|
-
${
|
|
71
|
-
|
|
174
|
+
${sheetTabFragment}
|
|
175
|
+
${sheetTabSummaryFragment}
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
// NOTE: renewSheetRealtimeCapability re-runs openSheet's authorization over a
|
|
179
|
+
// fence-only read and returns fresh signed capabilities, never workbook data.
|
|
180
|
+
// It is fetched no-store only: bearer tokens must stay out of the cache.
|
|
181
|
+
|
|
182
|
+
export const renewSheetRealtimeCapabilityQry = gql`
|
|
183
|
+
query renewSheetRealtimeCapability (
|
|
184
|
+
$sheetId: GenericID!
|
|
185
|
+
) {
|
|
186
|
+
renewSheetRealtimeCapability (
|
|
187
|
+
sheetId: $sheetId
|
|
188
|
+
) {
|
|
189
|
+
access {
|
|
190
|
+
sheetId
|
|
191
|
+
organizationId
|
|
192
|
+
canView
|
|
193
|
+
canEdit
|
|
194
|
+
signInRequired
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
status
|
|
198
|
+
unavailableReason
|
|
199
|
+
realtimeToken
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
`;
|
|
203
|
+
|
|
204
|
+
// NOTE: syncSheetTab is the tab-only snapshot/delta negotiation (contract 3)
|
|
205
|
+
// used once the workbook manifest is known: a gap, a selection or a
|
|
206
|
+
// watermark catch-up asks for the rows after the tab's applied sinceSeq.
|
|
207
|
+
|
|
208
|
+
export const syncSheetTabQry = gql`
|
|
209
|
+
query syncSheetTab (
|
|
210
|
+
$sheetId: GenericID!
|
|
211
|
+
$sheetTabId: GenericID!
|
|
212
|
+
$sinceSeq: BigInt
|
|
213
|
+
$requireSnapshot: Boolean
|
|
214
|
+
$minimumCellsRevision: BigInt
|
|
215
|
+
$minimumDesignRevision: BigInt
|
|
216
|
+
) {
|
|
217
|
+
syncSheetTab (
|
|
218
|
+
sheetId: $sheetId
|
|
219
|
+
sheetTabId: $sheetTabId
|
|
220
|
+
sinceSeq: $sinceSeq
|
|
221
|
+
requireSnapshot: $requireSnapshot
|
|
222
|
+
minimumCellsRevision: $minimumCellsRevision
|
|
223
|
+
minimumDesignRevision: $minimumDesignRevision
|
|
224
|
+
) {
|
|
225
|
+
access {
|
|
226
|
+
sheetId
|
|
227
|
+
organizationId
|
|
228
|
+
canView
|
|
229
|
+
canEdit
|
|
230
|
+
signInRequired
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
contractVersion
|
|
234
|
+
status
|
|
235
|
+
unavailableReason
|
|
236
|
+
selectedTab {
|
|
237
|
+
...sheetTabFragment
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
mode
|
|
241
|
+
currentSeq
|
|
242
|
+
servedViewport {
|
|
243
|
+
startRowIndex
|
|
244
|
+
startColumnIndex
|
|
245
|
+
rowCount
|
|
246
|
+
columnCount
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
snapshot {
|
|
250
|
+
seq
|
|
251
|
+
encodingVersion
|
|
252
|
+
viewport {
|
|
253
|
+
startRowIndex
|
|
254
|
+
startColumnIndex
|
|
255
|
+
rowCount
|
|
256
|
+
columnCount
|
|
257
|
+
}
|
|
258
|
+
payload
|
|
259
|
+
checksum
|
|
260
|
+
cellCount
|
|
261
|
+
payloadBytes
|
|
262
|
+
createdAt
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
changes {
|
|
266
|
+
sheetTabId
|
|
267
|
+
seq
|
|
268
|
+
kind
|
|
269
|
+
payload
|
|
270
|
+
commandId
|
|
271
|
+
causationId
|
|
272
|
+
sessionId
|
|
273
|
+
commandType
|
|
274
|
+
createdAt
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
topologyChanges {
|
|
278
|
+
sheetTabId
|
|
279
|
+
seq
|
|
280
|
+
kind
|
|
281
|
+
payload
|
|
282
|
+
commandId
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
topologyComplete
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
${sheetTabFragment}
|
|
72
290
|
`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { generatedFileFragment } from '../fragments/storageFragments.ts';
|
|
3
|
+
|
|
4
|
+
export const generatedFilesQry = gql`
|
|
5
|
+
query generatedFiles (
|
|
6
|
+
$organizationId: GenericID!
|
|
7
|
+
$cursor: Cursor
|
|
8
|
+
$after: Boolean!
|
|
9
|
+
$limit: Int!
|
|
10
|
+
) {
|
|
11
|
+
generatedFiles (
|
|
12
|
+
organizationId: $organizationId
|
|
13
|
+
cursor: $cursor
|
|
14
|
+
after: $after
|
|
15
|
+
limit: $limit
|
|
16
|
+
) {
|
|
17
|
+
...generatedFileFragment
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
${generatedFileFragment}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export const generatedFileQry = gql`
|
|
25
|
+
query generatedFile (
|
|
26
|
+
$organizationId: GenericID!
|
|
27
|
+
$code: String!
|
|
28
|
+
) {
|
|
29
|
+
generatedFile (
|
|
30
|
+
organizationId: $organizationId
|
|
31
|
+
code: $code
|
|
32
|
+
) {
|
|
33
|
+
...generatedFileFragment
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
${generatedFileFragment}
|
|
38
|
+
`;
|
|
@@ -1,28 +1,103 @@
|
|
|
1
1
|
import { gql } from 'graphql-tag';
|
|
2
2
|
import { workflowFragment, workflowRunFragment } from '../fragments/workflowFragments.ts';
|
|
3
3
|
|
|
4
|
+
export const workflowQry = gql`
|
|
5
|
+
query workflow ($workflowId: GenericID!) {
|
|
6
|
+
workflow (workflowId: $workflowId) {
|
|
7
|
+
...workflowFragment
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
${workflowFragment}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const workflowMetadataQry = gql`
|
|
14
|
+
query workflowMetadata (
|
|
15
|
+
$workflowId: GenericID!
|
|
16
|
+
) {
|
|
17
|
+
workflowMetadata (
|
|
18
|
+
workflowId: $workflowId
|
|
19
|
+
) {
|
|
20
|
+
id
|
|
21
|
+
title
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
4
26
|
export const workflowsQry = gql`
|
|
5
27
|
query workflows (
|
|
6
28
|
$organizationId: GenericID!
|
|
29
|
+
$filter: WorkflowsFilter!
|
|
30
|
+
$sort: WorkflowsSort
|
|
31
|
+
$cursor: Cursor
|
|
32
|
+
$after: Boolean!
|
|
33
|
+
$limit: Int!
|
|
7
34
|
) {
|
|
8
35
|
workflows (
|
|
9
36
|
organizationId: $organizationId
|
|
37
|
+
filter: $filter
|
|
38
|
+
sort: $sort
|
|
39
|
+
cursor: $cursor
|
|
40
|
+
after: $after
|
|
41
|
+
limit: $limit
|
|
10
42
|
) {
|
|
11
43
|
...workflowFragment
|
|
44
|
+
|
|
45
|
+
latestRun {
|
|
46
|
+
...workflowRunFragment
|
|
47
|
+
}
|
|
12
48
|
}
|
|
13
49
|
}
|
|
14
50
|
|
|
15
51
|
${workflowFragment}
|
|
52
|
+
${workflowRunFragment}
|
|
16
53
|
`;
|
|
17
54
|
|
|
18
55
|
export const workflowRunsQry = gql`
|
|
19
56
|
query workflowRuns (
|
|
20
|
-
$
|
|
57
|
+
$organizationId: GenericID!
|
|
58
|
+
$filter: WorkflowRunsFilter!
|
|
59
|
+
$sort: WorkflowRunsSort
|
|
60
|
+
$cursor: Cursor
|
|
61
|
+
$after: Boolean!
|
|
62
|
+
$limit: Int!
|
|
21
63
|
) {
|
|
22
64
|
workflowRuns (
|
|
23
|
-
|
|
65
|
+
organizationId: $organizationId
|
|
66
|
+
filter: $filter
|
|
67
|
+
sort: $sort
|
|
68
|
+
cursor: $cursor
|
|
69
|
+
after: $after
|
|
70
|
+
limit: $limit
|
|
71
|
+
) {
|
|
72
|
+
...workflowRunFragment
|
|
73
|
+
|
|
74
|
+
workflow {
|
|
75
|
+
id
|
|
76
|
+
kind
|
|
77
|
+
title
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
${workflowRunFragment}
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
export const workflowRunQry = gql`
|
|
86
|
+
query workflowRun (
|
|
87
|
+
$organizationId: GenericID!
|
|
88
|
+
$workflowRunId: GenericID!
|
|
89
|
+
) {
|
|
90
|
+
workflowRun (
|
|
91
|
+
organizationId: $organizationId
|
|
92
|
+
workflowRunId: $workflowRunId
|
|
24
93
|
) {
|
|
25
94
|
...workflowRunFragment
|
|
95
|
+
|
|
96
|
+
workflow {
|
|
97
|
+
id
|
|
98
|
+
kind
|
|
99
|
+
title
|
|
100
|
+
}
|
|
26
101
|
}
|
|
27
102
|
}
|
|
28
103
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { claimQueryActivation, getQueryActivation, type QueryActivation } from './index.helpers.ts';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Fail a lifecycle regression with its expected behavior rather than an opaque boolean mismatch.
|
|
5
|
+
*/
|
|
6
|
+
function assert(value: boolean, message: string) {
|
|
7
|
+
if (!value) throw new Error(message);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Deno.test('a fresh cached query is checked once per mount, including Strict Mode effect replay', () => {
|
|
11
|
+
let activation: QueryActivation = { queryKey: null, checked: false };
|
|
12
|
+
activation = getQueryActivation(activation, 'logs:org1', false);
|
|
13
|
+
assert(claimQueryActivation(activation, 'logs:org1'), 'A mounted cached list must get an entry check');
|
|
14
|
+
activation = getQueryActivation(activation, 'logs:org1', false);
|
|
15
|
+
assert(!claimQueryActivation(activation, 'logs:org1'), 'Renders and effect replay must not start another request');
|
|
16
|
+
const remounted = getQueryActivation({ queryKey: null, checked: false }, 'logs:org1', false);
|
|
17
|
+
assert(claimQueryActivation(remounted, 'logs:org1'), 'Reopening the page must check even a fresh cached result');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
Deno.test('a cold load satisfies the entry check when its response populates the cache', () => {
|
|
21
|
+
const activation = getQueryActivation({ queryKey: null, checked: false }, 'emails:org1', false);
|
|
22
|
+
claimQueryActivation(activation, 'emails:org1');
|
|
23
|
+
assert(!claimQueryActivation(activation, 'emails:org1'), 'A successful cold load must not cause a second warm load');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
Deno.test('changing variables and returning to a previous scope each start a new activation', () => {
|
|
27
|
+
let activation = getQueryActivation({ queryKey: null, checked: false }, 'logs:org1', false);
|
|
28
|
+
claimQueryActivation(activation, 'logs:org1');
|
|
29
|
+
activation = getQueryActivation(activation, 'logs:org2', false);
|
|
30
|
+
assert(!claimQueryActivation(activation, 'logs:org1'), 'An old scope request must not consume the new scope check');
|
|
31
|
+
assert(claimQueryActivation(activation, 'logs:org2'), 'Changed filters or organization must check cached data');
|
|
32
|
+
activation = getQueryActivation(activation, 'logs:org1', false);
|
|
33
|
+
assert(claimQueryActivation(activation, 'logs:org1'), 'Returning to a previously visited scope must check again');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
Deno.test('skipped queries wait and reactivation checks the same variables again', () => {
|
|
37
|
+
let activation = getQueryActivation({ queryKey: null, checked: false }, 'shifts:org1', false);
|
|
38
|
+
claimQueryActivation(activation, 'shifts:org1');
|
|
39
|
+
activation = getQueryActivation(activation, 'shifts:org1', true);
|
|
40
|
+
assert(!claimQueryActivation(activation, 'shifts:org1'), 'Skipped queries must not claim a request');
|
|
41
|
+
activation = getQueryActivation(activation, 'shifts:org1', false);
|
|
42
|
+
assert(claimQueryActivation(activation, 'shifts:org1'), 'Opening a previously hidden query must check again');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
Deno.test('waiting for hydration or connection preserves an unclaimed activation', () => {
|
|
46
|
+
let activation = getQueryActivation({ queryKey: null, checked: false }, 'runs:org1', false);
|
|
47
|
+
activation = getQueryActivation(activation, 'runs:org1', false);
|
|
48
|
+
assert(!activation.checked, 'Readiness changes must not consume the pending check');
|
|
49
|
+
assert(claimQueryActivation(activation, 'runs:org1'), 'The query must still check when ready');
|
|
50
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { QUERY_EXPIRE_TIMES } from '../cache/config.ts';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Apply the same freshness boundary on mount, prefetch, focus and reconnect.
|
|
5
|
+
* Zero always refreshes; Infinity never expires a known timestamp. Missing,
|
|
6
|
+
* invalid or future timestamps require validation against the server.
|
|
7
|
+
*/
|
|
8
|
+
export function isQueryDataStale(queryName: string, fetchedAt: number | undefined, persistTime?: number, now = Date.now()): boolean {
|
|
9
|
+
if (fetchedAt === undefined || !Number.isFinite(fetchedAt) || fetchedAt > now) return true;
|
|
10
|
+
const configured = persistTime ?? QUERY_EXPIRE_TIMES[queryName] ?? QUERY_EXPIRE_TIMES.__default;
|
|
11
|
+
const freshnessWindow = Number.isNaN(configured) ? QUERY_EXPIRE_TIMES.__default : Math.max(0, configured);
|
|
12
|
+
return now - fetchedAt >= freshnessWindow;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface QueryActivation {
|
|
16
|
+
queryKey: string | null;
|
|
17
|
+
checked: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Start a new activation when a hook changes query scope or resumes after being skipped.
|
|
22
|
+
*/
|
|
23
|
+
export function getQueryActivation(current: QueryActivation, queryKey: string, skipped: boolean): QueryActivation {
|
|
24
|
+
const activeKey = skipped ? null : queryKey;
|
|
25
|
+
return current.queryKey === activeKey ? current : { queryKey: activeKey, checked: false };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Claim one entry-time cache check before starting or joining a request. Cache writes,
|
|
30
|
+
* rerenders and Strict Mode effect replay must not repeatedly refresh the same activation.
|
|
31
|
+
*/
|
|
32
|
+
export function claimQueryActivation(activation: QueryActivation, queryKey: string): boolean {
|
|
33
|
+
if (activation.queryKey !== queryKey || activation.checked) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
activation.checked = true;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* Bound an opted-in query's network lifetime so a hung request cannot occupy
|
|
42
|
+
* its shared in-flight slot forever. Owners clear the timer after settlement.
|
|
43
|
+
*/
|
|
44
|
+
export function startQueryRequestTimeout(controller: AbortController, timeoutMs?: number): () => void {
|
|
45
|
+
if (!timeoutMs || !Number.isFinite(timeoutMs) || timeoutMs <= 0) return () => {};
|
|
46
|
+
const timeout = globalThis.setTimeout(() => {
|
|
47
|
+
controller.abort(new DOMException('The GraphQL query exceeded its request deadline.', 'AbortError'));
|
|
48
|
+
}, timeoutMs);
|
|
49
|
+
return () => {
|
|
50
|
+
globalThis.clearTimeout(timeout);
|
|
51
|
+
};
|
|
52
|
+
}
|