@jsb188/graphql 1.1.12 → 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.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/audience.d.ts +14 -152
  3. package/cache/config.ts +35 -32
  4. package/cache/index.helpers.ts +1 -1
  5. package/cache/index.ts +73 -44
  6. package/cache/mounted-queries.ts +33 -0
  7. package/cache/persist.ts +10 -4
  8. package/cache/realtime-fence.ts +47 -0
  9. package/cache/realtime-live.ts +17 -0
  10. package/client/draft-persistence.ts +10 -39
  11. package/client/index.ts +2 -1
  12. package/client/request.ts +9 -34
  13. package/client/storage-asset.ts +58 -0
  14. package/gql/fragments/accountAuthFragments.ts +0 -4
  15. package/gql/fragments/agentNoteFragments.ts +8 -2
  16. package/gql/fragments/aiChatFragments.ts +0 -2
  17. package/gql/fragments/aiChatLinkFragments.ts +8 -0
  18. package/gql/fragments/audienceFragments.ts +1 -66
  19. package/gql/fragments/emailFragments.ts +27 -4
  20. package/gql/fragments/emailOutreachFragments.ts +281 -0
  21. package/gql/fragments/inboundContactFragments.ts +1 -1
  22. package/gql/fragments/libraryFragments.ts +120 -0
  23. package/gql/fragments/organizationFragments.ts +4 -2
  24. package/gql/fragments/scheduleFragments.ts +241 -324
  25. package/gql/fragments/sheetFragments.ts +4 -53
  26. package/gql/fragments/workWaitFragments.ts +13 -0
  27. package/gql/fragments/workflowFragments.ts +20 -4
  28. package/gql/mutations/agentNoteMutations.ts +2 -0
  29. package/gql/mutations/aiChatLinkMutations.ts +13 -0
  30. package/gql/mutations/aiChatMutations.ts +4 -6
  31. package/gql/mutations/audienceMutations.ts +0 -13
  32. package/gql/mutations/authMutations.ts +12 -60
  33. package/gql/mutations/emailMutations.ts +22 -0
  34. package/gql/mutations/emailOutreachMutations.ts +139 -0
  35. package/gql/mutations/index.ts +3 -1
  36. package/gql/mutations/organizationMutations.ts +2 -2
  37. package/gql/mutations/scheduleMutations.ts +61 -787
  38. package/gql/mutations/storageMutations.ts +1 -0
  39. package/gql/mutations/workflowMutations.ts +76 -0
  40. package/gql/queries/agentMemoryQueries.ts +6 -2
  41. package/gql/queries/agentNoteQueries.ts +26 -29
  42. package/gql/queries/aiChatQueries.ts +39 -40
  43. package/gql/queries/audienceQueries.ts +31 -55
  44. package/gql/queries/authQueries.ts +16 -6
  45. package/gql/queries/billingQueries.ts +26 -10
  46. package/gql/queries/dataTableQueries.ts +24 -15
  47. package/gql/queries/emailOutreachQueries.ts +282 -0
  48. package/gql/queries/emailQueries.ts +39 -12
  49. package/gql/queries/emailReplyReportQueries.ts +60 -9
  50. package/gql/queries/fieldDocQueries.ts +36 -14
  51. package/gql/queries/inboundContactQueries.ts +11 -4
  52. package/gql/queries/index.ts +2 -2
  53. package/gql/queries/libraryQueries.ts +112 -0
  54. package/gql/queries/logQueries.ts +31 -12
  55. package/gql/queries/organizationQueries.ts +31 -12
  56. package/gql/queries/qrCodeQueries.ts +11 -4
  57. package/gql/queries/scheduleQueries.ts +252 -505
  58. package/gql/queries/sheetQueries.ts +36 -14
  59. package/gql/queries/storageQueries.ts +11 -4
  60. package/gql/queries/workflowQueries.ts +53 -10
  61. package/gql/reactivity.ts +98 -0
  62. package/gql/recordReads.ts +171 -0
  63. package/hooks/index.ts +79 -52
  64. package/hooks/use-agentNote-mtn.ts +7 -0
  65. package/hooks/use-agentNote-qry.ts +30 -58
  66. package/hooks/use-agentNote-recovery.ts +6 -21
  67. package/hooks/use-aiChat-mtn.ts +9 -4
  68. package/hooks/use-aiChat-qry.ts +28 -7
  69. package/hooks/use-audience-mtn.ts +0 -24
  70. package/hooks/use-audience-qry.helpers.ts +0 -24
  71. package/hooks/use-audience-qry.ts +1 -86
  72. package/hooks/use-dataTable-mtn.ts +3 -3
  73. package/hooks/use-dataTable-qry.ts +7 -2
  74. package/hooks/use-email-mtn.ts +26 -0
  75. package/hooks/use-email-qry.helpers.ts +1 -1
  76. package/hooks/use-email-qry.ts +18 -3
  77. package/hooks/use-emailOutreach-mtn.ts +211 -0
  78. package/hooks/use-emailOutreach-qry.helpers.ts +25 -0
  79. package/hooks/use-emailOutreach-qry.ts +367 -0
  80. package/hooks/use-emailOutreachReplyReport-qry.ts +46 -0
  81. package/hooks/use-fieldDoc-qry.ts +1 -1
  82. package/hooks/use-library-qry.ts +233 -0
  83. package/hooks/use-qrCode-qry.ts +1 -1
  84. package/hooks/use-schedule-mtn.ts +10 -300
  85. package/hooks/use-schedule-qry.ts +168 -680
  86. package/hooks/use-schedule-reactive.ts +71 -339
  87. package/hooks/use-sheet-qry.ts +6 -1
  88. package/hooks/use-workflow-mtn.ts +45 -1
  89. package/hooks/use-workflow-qry.ts +22 -2
  90. package/libs/ai-chat-link-events.ts +78 -0
  91. package/libs/data-changes.helpers.ts +161 -0
  92. package/libs/data-changes.ts +382 -0
  93. package/libs/fragment-realtime-sequence.ts +3 -3
  94. package/libs/record-read.ts +327 -0
  95. package/libs/sheet-command-batch.ts +3 -2
  96. package/libs/sheet-realtime-packet.ts +53 -0
  97. package/loaders/emailPreference.ts +18 -24
  98. package/package.json +44 -17
  99. package/schedule.d.ts +267 -874
  100. package/types.d.ts +3 -1
  101. package/cache/index.chat-activity.test.ts +0 -119
  102. package/cache/index.chat.test.ts +0 -92
  103. package/cache/index.regression.test.ts +0 -149
  104. package/cache/index.test.ts +0 -1209
  105. package/deno.lock +0 -187
  106. package/deno.test.json +0 -12
  107. package/gql/fragments/campaignFragments.ts +0 -566
  108. package/gql/mutations/campaignMutations.ts +0 -258
  109. package/gql/queries/appQueries.ts +0 -14
  110. package/gql/queries/campaignQueries.ts +0 -236
  111. package/hooks/index.helpers.test.ts +0 -50
  112. package/hooks/use-agentNote-recovery.helpers.test.ts +0 -68
  113. package/hooks/use-aiChat-qry.helpers.test.ts +0 -63
  114. package/hooks/use-app-qry.ts +0 -22
  115. package/hooks/use-audience-qry.helpers.test.ts +0 -80
  116. package/hooks/use-campaign-generation-recovery.ts +0 -53
  117. package/hooks/use-campaign-mtn.ts +0 -436
  118. package/hooks/use-campaign-qry.helpers.ts +0 -40
  119. package/hooks/use-campaign-qry.ts +0 -834
  120. package/hooks/use-emailCampaignReplyReport-qry.ts +0 -27
  121. package/hooks/use-fieldDoc-qry.helpers.test.ts +0 -65
  122. package/hooks/use-publicFormEmail-mtn.ts +0 -27
  123. package/libs/fragment-recovery.test.ts +0 -326
  124. package/libs/fragment-recovery.ts +0 -325
  125. package/libs/orchestrator-realtime.helpers.test.ts +0 -229
  126. package/libs/orchestrator-realtime.helpers.ts +0 -317
  127. package/libs/orchestrator-realtime.ts +0 -433
  128. package/libs/request-cache-regression.test.ts +0 -122
  129. package/libs/request-managed-session.test.ts +0 -574
  130. package/libs/request-no-store.test.ts +0 -419
  131. package/libs/sheet-view-realtime-router.test.ts +0 -214
  132. package/libs/sse-ticket.test.ts +0 -26
  133. package/loaders/campaign.test.ts +0 -186
  134. package/loaders/campaign.ts +0 -110
  135. package/tests/agent-note-detail-cache.test.ts +0 -120
  136. package/tests/agent-note-search.test.ts +0 -444
  137. package/tsconfig.json +0 -13
@@ -1,258 +0,0 @@
1
- import { gql } from 'graphql-tag';
2
- import {
3
- campaignAccessFragment,
4
- campaignFragment,
5
- campaignGenerationLifecycleFragment,
6
- campaignSettingsFragment,
7
- campaignTemplateFragment,
8
- campaignTemplateLifecycleFragment,
9
- } from '../fragments/campaignFragments.ts';
10
- import { storageFileFragment } from '../fragments/storageFragments.ts';
11
-
12
- /**
13
- * Returns a GENERATING campaign immediately. The draft is written by a
14
- * durable job, then a GraphQL-only GENERATED websocket patch tells observers
15
- * to refetch the persisted COMPLETE or ERROR result.
16
- */
17
-
18
- export const createCampaignMtn = gql`
19
- mutation createCampaign (
20
- $organizationId: GenericID!
21
- $templateId: GenericID!
22
- $instructions: String
23
- $sourceStorageIds: [GenericID!]
24
- $title: String
25
- ) {
26
- createCampaign (
27
- organizationId: $organizationId
28
- templateId: $templateId
29
- instructions: $instructions
30
- sourceStorageIds: $sourceStorageIds
31
- title: $title
32
- ) {
33
- ...campaignFragment
34
- }
35
- }
36
- ${campaignFragment}
37
- `;
38
-
39
- export const retryCampaignGenerationMtn = gql`
40
- mutation retryCampaignGeneration (
41
- $organizationId: GenericID!
42
- $campaignId: GenericID!
43
- ) {
44
- retryCampaignGeneration (
45
- organizationId: $organizationId
46
- campaignId: $campaignId
47
- ) {
48
- ...campaignGenerationLifecycleFragment
49
- }
50
- }
51
- ${campaignGenerationLifecycleFragment}
52
- `;
53
-
54
- /**
55
- * Create one empty, editable campaign template owned by the organization.
56
- */
57
-
58
- export const createCampaignTemplateMtn = gql`
59
- mutation createCampaignTemplate (
60
- $input: CreateCampaignTemplateInput!
61
- ) {
62
- createCampaignTemplate (input: $input) {
63
- ...campaignTemplateFragment
64
- }
65
- }
66
- ${campaignTemplateFragment}
67
- `;
68
-
69
- /**
70
- * Apply one optimistic-concurrency editor patch to a reusable template.
71
- */
72
-
73
- export const editCampaignTemplateMtn = gql`
74
- mutation editCampaignTemplate (
75
- $input: EditCampaignTemplateInput!
76
- ) {
77
- editCampaignTemplate (input: $input) {
78
- editVersion
79
- }
80
- }
81
- `;
82
-
83
- /**
84
- * Apply one optimistic-concurrency editor patch to a campaign.
85
- */
86
-
87
- export const editCampaignMtn = gql`
88
- mutation editCampaign (
89
- $input: EditCampaignInput!
90
- ) {
91
- editCampaign (input: $input) {
92
- editVersion
93
- }
94
- }
95
- `;
96
-
97
- /**
98
- * Finalize a direct header-image upload before linking it through an editor
99
- * patch. The ordinary GCS webhook remains the idempotent fallback.
100
- */
101
- export const finalizeCampaignHeaderImageUploadMtn = gql`
102
- mutation finalizeCampaignHeaderImageUpload (
103
- $organizationId: GenericID!
104
- $storageId: GenericID!
105
- ) {
106
- finalizeCampaignHeaderImageUpload (
107
- organizationId: $organizationId
108
- storageId: $storageId
109
- ) {
110
- ...storageFileFragment
111
- }
112
- }
113
- ${storageFileFragment}
114
- `;
115
-
116
- /**
117
- * Finalize a direct campaign-element image upload before linking it through
118
- * an editor patch. The ordinary GCS webhook remains the idempotent fallback.
119
- */
120
- export const finalizeCampaignElementImageUploadMtn = gql`
121
- mutation finalizeCampaignElementImageUpload (
122
- $organizationId: GenericID!
123
- $storageId: GenericID!
124
- ) {
125
- finalizeCampaignElementImageUpload (
126
- organizationId: $organizationId
127
- storageId: $storageId
128
- ) {
129
- ...storageFileFragment
130
- }
131
- }
132
- ${storageFileFragment}
133
- `;
134
-
135
- /**
136
- * Apply one versioned public-form audience change.
137
- */
138
-
139
- export const updateCampaignAccessMtn = gql`
140
- mutation updateCampaignAccess (
141
- $input: UpdateCampaignAccessInput!
142
- ) {
143
- updateCampaignAccess (input: $input) {
144
- ...campaignAccessFragment
145
- }
146
- }
147
- ${campaignAccessFragment}
148
- `;
149
-
150
- /*
151
- * Submit or replace one complete response against the publication currently
152
- * shown to the respondent.
153
- */
154
- export const submitCampaignResponseMtn = gql`
155
- mutation submitCampaignResponse (
156
- $publicId: String!
157
- $childOrgId: GenericID
158
- $expectedPublicationVersion: Int!
159
- $answers: [SubmitCampaignAnswerInput!]!
160
- $sendResponseCopyToEmail: Boolean
161
- ) {
162
- submitCampaignResponse (
163
- publicId: $publicId
164
- childOrgId: $childOrgId
165
- expectedPublicationVersion: $expectedPublicationVersion
166
- answers: $answers
167
- sendResponseCopyToEmail: $sendResponseCopyToEmail
168
- ) {
169
- responseId
170
- submittedAt
171
- }
172
- }
173
- `;
174
-
175
- /**
176
- * Create one editable public-form campaign draft from an active template.
177
- */
178
- export const createFormCampaignDraftMtn = gql`
179
- mutation createFormCampaignDraft (
180
- $input: CreateFormCampaignDraftInput!
181
- ) {
182
- createFormCampaignDraft (input: $input) {
183
- ...campaignFragment
184
- }
185
- }
186
- ${campaignFragment}
187
- `;
188
-
189
- /**
190
- * Create one editable email campaign draft from an active email template.
191
- */
192
- export const createEmailCampaignDraftMtn = gql`
193
- mutation createEmailCampaignDraft (
194
- $input: CreateEmailCampaignDraftInput!
195
- ) {
196
- createEmailCampaignDraft (input: $input) {
197
- ...campaignFragment
198
- }
199
- }
200
- ${campaignFragment}
201
- `;
202
-
203
- /**
204
- * Edit one campaign's versioned settings, draft reset, or lifecycle.
205
- */
206
- export const editCampaignSettingsMtn = gql`
207
- mutation editCampaignSettings (
208
- $input: EditCampaignSettingsInput!
209
- ) {
210
- editCampaignSettings (input: $input) {
211
- ...campaignSettingsFragment
212
- }
213
- }
214
- ${campaignSettingsFragment}
215
- `;
216
-
217
- /*
218
- * Send one test of an email campaign's saved content to a member of the organization.
219
- */
220
- export const sendCampaignTestEmailMtn = gql`
221
- mutation sendCampaignTestEmail (
222
- $input: SendCampaignTestEmailInput!
223
- ) {
224
- sendCampaignTestEmail (input: $input) {
225
- toEmail
226
- }
227
- }
228
- `;
229
-
230
- export const archiveCampaignTemplateMtn = gql`
231
- mutation archiveCampaignTemplate (
232
- $organizationId: GenericID!
233
- $templateId: GenericID!
234
- ) {
235
- archiveCampaignTemplate (
236
- organizationId: $organizationId
237
- templateId: $templateId
238
- ) {
239
- ...campaignTemplateLifecycleFragment
240
- }
241
- }
242
- ${campaignTemplateLifecycleFragment}
243
- `;
244
-
245
- /**
246
- * @deprecated Create an email campaign draft, select its audience lists, and use
247
- * editCampaignSettings with command.sendEmail.
248
- */
249
- export const sendCampaignEmailMtn = gql`
250
- mutation sendCampaignEmail (
251
- $input: SendCampaignEmailInput!
252
- ) {
253
- sendCampaignEmail (input: $input) {
254
- ...campaignFragment
255
- }
256
- }
257
- ${campaignFragment}
258
- `;
@@ -1,14 +0,0 @@
1
- import { gql } from 'graphql-tag';
2
-
3
- export const updateNoteQry = gql`
4
- query updateNote {
5
- updateNote {
6
- webVersion
7
- mobileVersion
8
- emoji
9
- title
10
- at
11
- text
12
- }
13
- }
14
- `;
@@ -1,236 +0,0 @@
1
- import { gql } from 'graphql-tag';
2
- import {
3
- campaignEditorFieldsSelection,
4
- campaignFieldsSelection,
5
- campaignRecipientFragment,
6
- campaignRecipientOverviewFragment,
7
- campaignResponseFragment,
8
- campaignResponseOverviewFragment,
9
- campaignResponseSummaryFragment,
10
- campaignSummaryFragment,
11
- campaignTemplateFieldsSelection,
12
- campaignTemplateSummaryFragment,
13
- } from '../fragments/campaignFragments.ts';
14
-
15
- export const campaignTemplatesQry = gql`
16
- query campaignTemplates (
17
- $organizationId: GenericID!
18
- $filter: CampaignTemplatesFilter!
19
- $cursor: Cursor
20
- $after: Boolean!
21
- $limit: Int!
22
- ) {
23
- campaignTemplates (
24
- organizationId: $organizationId
25
- filter: $filter
26
- cursor: $cursor
27
- after: $after
28
- limit: $limit
29
- ) {
30
- ...campaignTemplateSummaryFragment
31
- }
32
- }
33
- ${campaignTemplateSummaryFragment}
34
- `;
35
-
36
- /**
37
- * Every current system template (no owning organization). Not paginated.
38
- */
39
- export const systemCampaignTemplatesQry = gql`
40
- query systemCampaignTemplates (
41
- $filter: SystemCampaignTemplatesFilter!
42
- ) {
43
- systemCampaignTemplates (filter: $filter) {
44
- ...campaignTemplateSummaryFragment
45
- }
46
- }
47
- ${campaignTemplateSummaryFragment}
48
- `;
49
-
50
- export const campaignTemplateEditSessionQry = gql`
51
- query campaignTemplateEditSession (
52
- $templateId: GenericID!
53
- ) {
54
- campaignTemplateEditSession (
55
- templateId: $templateId
56
- ) {
57
- organizationId
58
- status
59
- template {
60
- ${campaignTemplateFieldsSelection}
61
- }
62
- editor {
63
- ${campaignEditorFieldsSelection}
64
- }
65
- editable
66
- }
67
- }
68
- `;
69
-
70
- export const campaignsQry = gql`
71
- query campaigns (
72
- $organizationId: GenericID
73
- $filter: CampaignsFilter!
74
- $sort: CampaignsSort
75
- $cursor: Cursor
76
- $after: Boolean!
77
- $limit: Int!
78
- ) {
79
- campaigns (
80
- organizationId: $organizationId
81
- filter: $filter
82
- sort: $sort
83
- cursor: $cursor
84
- after: $after
85
- limit: $limit
86
- ) {
87
- ...campaignSummaryFragment
88
- }
89
- }
90
- ${campaignSummaryFragment}
91
- `;
92
-
93
- export const campaignEditSessionQry = gql`
94
- query campaignEditSession (
95
- $campaignId: GenericID!
96
- ) {
97
- campaignEditSession (
98
- campaignId: $campaignId
99
- ) {
100
- organizationId
101
- status
102
- campaign {
103
- ${campaignFieldsSelection}
104
- }
105
- editor {
106
- ${campaignEditorFieldsSelection}
107
- }
108
- editable
109
- manageable
110
- }
111
- }
112
- `;
113
-
114
- /**
115
- * Fetch the latest organization overrides and picker targets for one form.
116
- */
117
- export const campaignFormAccessSessionQry = gql`
118
- query campaignFormAccessSession (
119
- $organizationId: GenericID!
120
- $campaignId: GenericID!
121
- ) {
122
- campaignFormAccessSession (
123
- organizationId: $organizationId
124
- campaignId: $campaignId
125
- ) {
126
- campaignId
127
- organizationId
128
- editVersion
129
- audience
130
- editable
131
- publicId
132
- grants {
133
- granteeType
134
- granteeId
135
- permission
136
- }
137
- organizations {
138
- id
139
- name
140
- operation
141
- inNetwork
142
- available
143
- }
144
- }
145
- }
146
- `;
147
-
148
- export const campaignResponsesQry = gql`
149
- query campaignResponses (
150
- $organizationId: GenericID!
151
- $filter: CampaignResponsesFilter!
152
- $cursor: Cursor
153
- $after: Boolean!
154
- $limit: Int!
155
- ) {
156
- campaignResponses (
157
- organizationId: $organizationId
158
- filter: $filter
159
- cursor: $cursor
160
- after: $after
161
- limit: $limit
162
- ) {
163
- ...campaignResponseSummaryFragment
164
- }
165
- }
166
- ${campaignResponseSummaryFragment}
167
- `;
168
-
169
- export const campaignResponseQry = gql`
170
- query campaignResponse (
171
- $organizationId: GenericID!
172
- $responseId: GenericID!
173
- ) {
174
- campaignResponse (
175
- organizationId: $organizationId
176
- responseId: $responseId
177
- ) {
178
- ...campaignResponseFragment
179
- }
180
- }
181
- ${campaignResponseFragment}
182
- `;
183
-
184
- export const campaignResponseOverviewQry = gql`
185
- query campaignResponseOverview (
186
- $organizationId: GenericID!
187
- $campaignId: GenericID!
188
- ) {
189
- campaignResponseOverview (
190
- organizationId: $organizationId
191
- campaignId: $campaignId
192
- ) {
193
- ...campaignResponseOverviewFragment
194
- }
195
- }
196
- ${campaignResponseOverviewFragment}
197
- `;
198
-
199
- export const campaignRecipientsQry = gql`
200
- query campaignRecipients (
201
- $organizationId: GenericID!
202
- $filter: CampaignRecipientsFilter!
203
- $cursor: Cursor
204
- $after: Boolean!
205
- $limit: Int!
206
- ) {
207
- campaignRecipients (
208
- organizationId: $organizationId
209
- filter: $filter
210
- cursor: $cursor
211
- after: $after
212
- limit: $limit
213
- ) {
214
- ...campaignRecipientFragment
215
- }
216
- }
217
- ${campaignRecipientFragment}
218
- `;
219
-
220
- /**
221
- * Fetch aggregate delivery and engagement metrics for one email campaign.
222
- */
223
- export const campaignRecipientOverviewQry = gql`
224
- query campaignRecipientOverview (
225
- $organizationId: GenericID!
226
- $campaignId: GenericID!
227
- ) {
228
- campaignRecipientOverview (
229
- organizationId: $organizationId
230
- campaignId: $campaignId
231
- ) {
232
- ...campaignRecipientOverviewFragment
233
- }
234
- }
235
- ${campaignRecipientOverviewFragment}
236
- `;
@@ -1,50 +0,0 @@
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
- });
@@ -1,68 +0,0 @@
1
- import {
2
- agentNoteRecoveryReadSucceeded,
3
- getAgentNoteResponseRevision,
4
- getVisibleAgentNote,
5
- } from './use-agentNote-recovery.helpers.ts';
6
-
7
- /* Fail note response regressions with the expected user-visible behavior. */
8
- function assert(value: unknown, message: string): asserts value {
9
- if (!value) throw new Error(message);
10
- }
11
-
12
- Deno.test('missing details are successful authoritative reads but partial errors cannot acknowledge freshness', () => {
13
- assert(
14
- agentNoteRecoveryReadSucceeded({ agentNote: null, error: { errorCode: 20232, statusCode: 404 } }, 'agentNote'),
15
- 'The exact server missing-note response is authoritative absence',
16
- );
17
- assert(
18
- !agentNoteRecoveryReadSucceeded({ agentNote: null, error: { errorCode: '20052', statusCode: 404 } }, 'agentNote'),
19
- 'A different authorization error cannot acknowledge note freshness',
20
- );
21
- assert(
22
- !agentNoteRecoveryReadSucceeded({ error: { errorCode: '20232', statusCode: 404 } }, 'agentNote'),
23
- 'A missing response field cannot acknowledge a detail snapshot',
24
- );
25
- assert(
26
- !agentNoteRecoveryReadSucceeded({ agentNote: { id: 'stale' }, error: { errorCode: '20232', statusCode: 404 } }, 'agentNote'),
27
- 'A partial object is not authoritative absence',
28
- );
29
- assert(
30
- agentNoteRecoveryReadSucceeded({ agentNote: null }, 'agentNote'),
31
- 'Deletion while offline must settle to an authoritative missing result',
32
- );
33
- assert(
34
- !agentNoteRecoveryReadSucceeded({ agentNote: null, error: { errorCode: '30000' } }, 'agentNote'),
35
- 'Partial data with an error must retry',
36
- );
37
- assert(
38
- !agentNoteRecoveryReadSucceeded({ agentNotes: [] }, 'agentNote'),
39
- 'A response for another query cannot establish the baseline',
40
- );
41
- });
42
-
43
- Deno.test('search freshness requires valid items and revision in the same successful response', () => {
44
- for (const result of [
45
- { searchAgentNotes: null },
46
- { searchAgentNotes: { items: [], revision: 4 } },
47
- { searchAgentNotes: { items: null, revision: '4' } },
48
- { searchAgentNotes: { items: [], revision: '-1' } },
49
- { searchAgentNotes: { items: [], revision: '4' }, __clientResultRejected: true },
50
- { searchAgentNotes: { items: [], revision: '4' }, aborted: true },
51
- ]) {
52
- assert(!agentNoteRecoveryReadSucceeded(result, 'searchAgentNotes'), 'Malformed or rejected searches remain pending');
53
- assert(getAgentNoteResponseRevision(result, 'searchAgentNotes') === null, 'Invalid snapshots have no accepted revision');
54
- }
55
- assert(
56
- getAgentNoteResponseRevision({ searchAgentNotes: { items: [], revision: '9007199254740993' } }, 'searchAgentNotes') ===
57
- '9007199254740993',
58
- 'Bigint revisions must retain text precision',
59
- );
60
- });
61
-
62
- Deno.test('a fragment tombstone hides retained detail content without a query refetch', () => {
63
- const note = { id: 'note-1', body: 'Old content' };
64
- assert(
65
- getVisibleAgentNote({ agentNote: note }, { ...note, __deleted: true }, null) === null,
66
- 'Deleted fragments must disappear immediately',
67
- );
68
- });
@@ -1,63 +0,0 @@
1
- import {
2
- mergeLocalAIChatMessages,
3
- mergeSSEPayloadToLocalAIChatMessages,
4
- upsertLocalAIChatMessage,
5
- } from './use-aiChat-qry.helpers.ts';
6
-
7
- Deno.test('reconnected chat checkpoints ignore stale revisions without bigint precision loss', () => {
8
- const latest = {
9
- id: 'message',
10
- revision: '9007199254740993',
11
- text: 'Complete answer',
12
- finished: true,
13
- };
14
- const stale = {
15
- ...latest,
16
- revision: '9007199254740992',
17
- text: 'Complete',
18
- finished: false,
19
- };
20
- const rows = [latest];
21
- if (upsertLocalAIChatMessage(rows, stale) !== rows)
22
- throw new Error('Old reconnect must not overwrite completed text');
23
- const merged = mergeSSEPayloadToLocalAIChatMessages(rows, {
24
- __type: 'DATA_UPDATE',
25
- fragmentKey: '$aiChatMessageFragment:message',
26
- data: stale,
27
- });
28
- if (merged[0].text !== latest.text)
29
- throw new Error('Stale stream update must be ignored');
30
- const cached = mergeLocalAIChatMessages({ messages: [latest] }, [stale]);
31
- if (cached.messages.length !== 1 || cached.messages[0].text !== latest.text)
32
- throw new Error('Stale local draft must not mask fresher database data');
33
- });
34
-
35
- Deno.test('replaying a full checkpoint does not duplicate message rows or append its text twice', () => {
36
- const payload = {
37
- __type: 'QUERY_APPEND',
38
- fragmentKey: '#aiChat:chat',
39
- dataFragmentKey: '$aiChatMessageFragment:message',
40
- data: { id: 'message', revision: '8', text: 'Hello' },
41
- } as const;
42
- const first = mergeSSEPayloadToLocalAIChatMessages([], payload);
43
- const second = mergeSSEPayloadToLocalAIChatMessages(first, payload);
44
- if (second.length !== 1 || second[0].text !== 'Hello')
45
- throw new Error('Full checkpoints must be idempotent');
46
- });
47
-
48
- Deno.test('a terminal checkpoint cannot be reopened by an equal-revision streaming snapshot', () => {
49
- const terminal = {
50
- id: 'message',
51
- revision: '12',
52
- generationStatus: 'INCOMPLETE',
53
- finished: true,
54
- };
55
- const rows = [terminal];
56
- const streaming = {
57
- ...terminal,
58
- generationStatus: 'STREAMING',
59
- finished: false,
60
- };
61
- if (upsertLocalAIChatMessage(rows, streaming) !== rows)
62
- throw new Error('Terminal checkpoint must win a same-revision tie');
63
- });
@@ -1,22 +0,0 @@
1
- import { useQuery } from '@jsb188/graphql/client';
2
- import { updateNoteQry } from '../gql/queries/appQueries.ts';
3
- import type { UseQueryParams } from '../types.d.ts';
4
-
5
- /**
6
- * Fetch update notes
7
- */
8
-
9
- export function useUpdateNote(
10
- accountId?: string | null,
11
- params: UseQueryParams = {},
12
- ) {
13
- const { data, ...other } = useQuery(updateNoteQry, {
14
- skip: !accountId,
15
- ...params,
16
- });
17
-
18
- return {
19
- updateNote: data?.updateNote,
20
- ...other,
21
- };
22
- }