@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.
- package/LICENSE +21 -0
- package/audience.d.ts +14 -152
- package/cache/config.ts +35 -32
- package/cache/index.helpers.ts +1 -1
- package/cache/index.ts +73 -44
- package/cache/mounted-queries.ts +33 -0
- package/cache/persist.ts +10 -4
- package/cache/realtime-fence.ts +47 -0
- package/cache/realtime-live.ts +17 -0
- package/client/draft-persistence.ts +10 -39
- package/client/index.ts +2 -1
- package/client/request.ts +9 -34
- package/client/storage-asset.ts +58 -0
- package/gql/fragments/accountAuthFragments.ts +0 -4
- package/gql/fragments/agentNoteFragments.ts +8 -2
- package/gql/fragments/aiChatFragments.ts +0 -2
- package/gql/fragments/aiChatLinkFragments.ts +8 -0
- package/gql/fragments/audienceFragments.ts +1 -66
- package/gql/fragments/emailFragments.ts +27 -4
- package/gql/fragments/emailOutreachFragments.ts +281 -0
- package/gql/fragments/inboundContactFragments.ts +1 -1
- package/gql/fragments/libraryFragments.ts +120 -0
- package/gql/fragments/organizationFragments.ts +4 -2
- package/gql/fragments/scheduleFragments.ts +241 -324
- package/gql/fragments/sheetFragments.ts +4 -53
- package/gql/fragments/workWaitFragments.ts +13 -0
- package/gql/fragments/workflowFragments.ts +20 -4
- package/gql/mutations/agentNoteMutations.ts +2 -0
- package/gql/mutations/aiChatLinkMutations.ts +13 -0
- package/gql/mutations/aiChatMutations.ts +4 -6
- package/gql/mutations/audienceMutations.ts +0 -13
- package/gql/mutations/authMutations.ts +12 -60
- package/gql/mutations/emailMutations.ts +22 -0
- package/gql/mutations/emailOutreachMutations.ts +139 -0
- package/gql/mutations/index.ts +3 -1
- package/gql/mutations/organizationMutations.ts +2 -2
- package/gql/mutations/scheduleMutations.ts +61 -787
- package/gql/mutations/storageMutations.ts +1 -0
- package/gql/mutations/workflowMutations.ts +76 -0
- package/gql/queries/agentMemoryQueries.ts +6 -2
- package/gql/queries/agentNoteQueries.ts +26 -29
- package/gql/queries/aiChatQueries.ts +39 -40
- package/gql/queries/audienceQueries.ts +31 -55
- package/gql/queries/authQueries.ts +16 -6
- package/gql/queries/billingQueries.ts +26 -10
- package/gql/queries/dataTableQueries.ts +24 -15
- package/gql/queries/emailOutreachQueries.ts +282 -0
- package/gql/queries/emailQueries.ts +39 -12
- package/gql/queries/emailReplyReportQueries.ts +60 -9
- package/gql/queries/fieldDocQueries.ts +36 -14
- package/gql/queries/inboundContactQueries.ts +11 -4
- package/gql/queries/index.ts +2 -2
- package/gql/queries/libraryQueries.ts +112 -0
- package/gql/queries/logQueries.ts +31 -12
- package/gql/queries/organizationQueries.ts +31 -12
- package/gql/queries/qrCodeQueries.ts +11 -4
- package/gql/queries/scheduleQueries.ts +252 -505
- package/gql/queries/sheetQueries.ts +36 -14
- package/gql/queries/storageQueries.ts +11 -4
- package/gql/queries/workflowQueries.ts +53 -10
- package/gql/reactivity.ts +98 -0
- package/gql/recordReads.ts +171 -0
- package/hooks/index.ts +79 -52
- package/hooks/use-agentNote-mtn.ts +7 -0
- package/hooks/use-agentNote-qry.ts +30 -58
- package/hooks/use-agentNote-recovery.ts +6 -21
- package/hooks/use-aiChat-mtn.ts +9 -4
- package/hooks/use-aiChat-qry.ts +28 -7
- package/hooks/use-audience-mtn.ts +0 -24
- package/hooks/use-audience-qry.helpers.ts +0 -24
- package/hooks/use-audience-qry.ts +1 -86
- package/hooks/use-dataTable-mtn.ts +3 -3
- package/hooks/use-dataTable-qry.ts +7 -2
- package/hooks/use-email-mtn.ts +26 -0
- package/hooks/use-email-qry.helpers.ts +1 -1
- package/hooks/use-email-qry.ts +18 -3
- package/hooks/use-emailOutreach-mtn.ts +211 -0
- package/hooks/use-emailOutreach-qry.helpers.ts +25 -0
- package/hooks/use-emailOutreach-qry.ts +367 -0
- package/hooks/use-emailOutreachReplyReport-qry.ts +46 -0
- package/hooks/use-fieldDoc-qry.ts +1 -1
- package/hooks/use-library-qry.ts +233 -0
- package/hooks/use-qrCode-qry.ts +1 -1
- package/hooks/use-schedule-mtn.ts +10 -300
- package/hooks/use-schedule-qry.ts +168 -680
- package/hooks/use-schedule-reactive.ts +71 -339
- package/hooks/use-sheet-qry.ts +6 -1
- package/hooks/use-workflow-mtn.ts +45 -1
- package/hooks/use-workflow-qry.ts +22 -2
- package/libs/ai-chat-link-events.ts +78 -0
- package/libs/data-changes.helpers.ts +161 -0
- package/libs/data-changes.ts +382 -0
- package/libs/fragment-realtime-sequence.ts +3 -3
- package/libs/record-read.ts +327 -0
- package/libs/sheet-command-batch.ts +3 -2
- package/libs/sheet-realtime-packet.ts +53 -0
- package/loaders/emailPreference.ts +18 -24
- package/package.json +44 -17
- package/schedule.d.ts +267 -874
- package/types.d.ts +3 -1
- package/cache/index.chat-activity.test.ts +0 -119
- package/cache/index.chat.test.ts +0 -92
- package/cache/index.regression.test.ts +0 -149
- package/cache/index.test.ts +0 -1209
- package/deno.lock +0 -187
- package/deno.test.json +0 -12
- package/gql/fragments/campaignFragments.ts +0 -566
- package/gql/mutations/campaignMutations.ts +0 -258
- package/gql/queries/appQueries.ts +0 -14
- package/gql/queries/campaignQueries.ts +0 -236
- package/hooks/index.helpers.test.ts +0 -50
- package/hooks/use-agentNote-recovery.helpers.test.ts +0 -68
- package/hooks/use-aiChat-qry.helpers.test.ts +0 -63
- package/hooks/use-app-qry.ts +0 -22
- package/hooks/use-audience-qry.helpers.test.ts +0 -80
- package/hooks/use-campaign-generation-recovery.ts +0 -53
- package/hooks/use-campaign-mtn.ts +0 -436
- package/hooks/use-campaign-qry.helpers.ts +0 -40
- package/hooks/use-campaign-qry.ts +0 -834
- package/hooks/use-emailCampaignReplyReport-qry.ts +0 -27
- package/hooks/use-fieldDoc-qry.helpers.test.ts +0 -65
- package/hooks/use-publicFormEmail-mtn.ts +0 -27
- package/libs/fragment-recovery.test.ts +0 -326
- package/libs/fragment-recovery.ts +0 -325
- package/libs/orchestrator-realtime.helpers.test.ts +0 -229
- package/libs/orchestrator-realtime.helpers.ts +0 -317
- package/libs/orchestrator-realtime.ts +0 -433
- package/libs/request-cache-regression.test.ts +0 -122
- package/libs/request-managed-session.test.ts +0 -574
- package/libs/request-no-store.test.ts +0 -419
- package/libs/sheet-view-realtime-router.test.ts +0 -214
- package/libs/sse-ticket.test.ts +0 -26
- package/loaders/campaign.test.ts +0 -186
- package/loaders/campaign.ts +0 -110
- package/tests/agent-note-detail-cache.test.ts +0 -120
- package/tests/agent-note-search.test.ts +0 -444
- package/tsconfig.json +0 -13
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { getAudienceQueryOutput } from './use-audience-qry.helpers.ts';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Report the user-visible data or loading invariant that regressed.
|
|
5
|
-
*/
|
|
6
|
-
function assert(value: unknown, message: string): asserts value {
|
|
7
|
-
if (!value) throw new Error(message);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Deno.test('audience hooks hide retained results during organization, list, and page changes', () => {
|
|
11
|
-
const previous = {
|
|
12
|
-
data: {
|
|
13
|
-
audienceListMembers: [{ id: 'member-private', organizationId: 'org-a' }],
|
|
14
|
-
},
|
|
15
|
-
queryName: 'audienceListMembers',
|
|
16
|
-
queryKey:
|
|
17
|
-
'#audienceListMembers:$audiencelistid:list-a$limit:50$organizationid:org-a',
|
|
18
|
-
variablesKey: '$audiencelistid:list-a$limit:50$organizationid:org-a',
|
|
19
|
-
};
|
|
20
|
-
assert(
|
|
21
|
-
getAudienceQueryOutput(previous, false).data === previous.data,
|
|
22
|
-
'A matching response should remain usable.',
|
|
23
|
-
);
|
|
24
|
-
for (const variablesKey of [
|
|
25
|
-
'$audiencelistid:list-a$limit:50$organizationid:org-b',
|
|
26
|
-
'$audiencelistid:list-b$limit:50$organizationid:org-a',
|
|
27
|
-
'$afterid:member-previous$audiencelistid:list-a$limit:50$organizationid:org-a',
|
|
28
|
-
'$audiencelistid:list-a$limit:50$organizationid:org-a$subscriptionstatus:unsubscribed',
|
|
29
|
-
]) {
|
|
30
|
-
const result = getAudienceQueryOutput({ ...previous, variablesKey }, false);
|
|
31
|
-
assert(
|
|
32
|
-
result.data === null,
|
|
33
|
-
'Retained membership data leaked across the requested query scope.',
|
|
34
|
-
);
|
|
35
|
-
assert(
|
|
36
|
-
result.initialLoading,
|
|
37
|
-
'A changed scope without its own response should show initial loading.',
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
Deno.test('audience hooks hide cached data when disabled and stop loading on current empty results or errors', () => {
|
|
43
|
-
const source = {
|
|
44
|
-
data: { audienceLists: [] },
|
|
45
|
-
queryName: 'audienceLists',
|
|
46
|
-
queryKey: '#audienceLists:$organizationid:org-a',
|
|
47
|
-
variablesKey: '$organizationid:org-a',
|
|
48
|
-
};
|
|
49
|
-
const skipped = getAudienceQueryOutput(source, true);
|
|
50
|
-
assert(
|
|
51
|
-
skipped.data === null && !skipped.initialLoading,
|
|
52
|
-
'An explicit skip must hide even a complete matching cached result.',
|
|
53
|
-
);
|
|
54
|
-
const empty = getAudienceQueryOutput(source, false);
|
|
55
|
-
assert(
|
|
56
|
-
empty.data === source.data && !empty.initialLoading,
|
|
57
|
-
'An empty audience is a completed result, not an endless spinner.',
|
|
58
|
-
);
|
|
59
|
-
const unfetched = getAudienceQueryOutput({ ...source, data: {} }, false);
|
|
60
|
-
assert(
|
|
61
|
-
unfetched.initialLoading,
|
|
62
|
-
'The query client’s initial empty object has no resolved root field and must show loading.',
|
|
63
|
-
);
|
|
64
|
-
const resolvedNull = getAudienceQueryOutput(
|
|
65
|
-
{ ...source, data: { audienceLists: null } },
|
|
66
|
-
false,
|
|
67
|
-
);
|
|
68
|
-
assert(
|
|
69
|
-
!resolvedNull.initialLoading,
|
|
70
|
-
'An explicit null query result is resolved and must not show loading.',
|
|
71
|
-
);
|
|
72
|
-
const failed = getAudienceQueryOutput(
|
|
73
|
-
{ ...source, data: null, error: { errorCode: '20052' } },
|
|
74
|
-
false,
|
|
75
|
-
);
|
|
76
|
-
assert(
|
|
77
|
-
failed.data === null && !failed.initialLoading,
|
|
78
|
-
'A permission error must stop initial loading without restoring old data.',
|
|
79
|
-
);
|
|
80
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Recover a pending generation's atomic session when realtime settlement is missed.
|
|
5
|
-
* Keep requests sequential and stop checking when the session settles or unmounts.
|
|
6
|
-
*/
|
|
7
|
-
export function useCampaignGenerationRecovery(p: {
|
|
8
|
-
campaignId?: string | null;
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
generationStatus?: string | null;
|
|
11
|
-
reactiveGenerationStatus?: string | null;
|
|
12
|
-
refetch: () => Promise<unknown>;
|
|
13
|
-
}) {
|
|
14
|
-
const {
|
|
15
|
-
campaignId,
|
|
16
|
-
enabled,
|
|
17
|
-
generationStatus,
|
|
18
|
-
reactiveGenerationStatus,
|
|
19
|
-
refetch,
|
|
20
|
-
} = p;
|
|
21
|
-
const pending =
|
|
22
|
-
generationStatus === 'GENERATING' || generationStatus === 'GENERATED';
|
|
23
|
-
const settled =
|
|
24
|
-
reactiveGenerationStatus === 'GENERATED' ||
|
|
25
|
-
reactiveGenerationStatus === 'COMPLETE' ||
|
|
26
|
-
reactiveGenerationStatus === 'ERROR';
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (!enabled || !campaignId || !pending) return;
|
|
30
|
-
let active = true;
|
|
31
|
-
let timer: ReturnType<typeof setTimeout>;
|
|
32
|
-
|
|
33
|
-
/*
|
|
34
|
-
* Retry reads after settlement races or network failures without overlapping requests.
|
|
35
|
-
*/
|
|
36
|
-
const refresh = async () => {
|
|
37
|
-
try {
|
|
38
|
-
await refetch();
|
|
39
|
-
} catch {
|
|
40
|
-
// The query owns error presentation; keep recovery available while pending.
|
|
41
|
-
} finally {
|
|
42
|
-
if (active) timer = setTimeout(refresh, 10_000);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
if (settled) void refresh();
|
|
47
|
-
else timer = setTimeout(refresh, 10_000);
|
|
48
|
-
return () => {
|
|
49
|
-
active = false;
|
|
50
|
-
clearTimeout(timer);
|
|
51
|
-
};
|
|
52
|
-
}, [campaignId, enabled, pending, refetch, settled]);
|
|
53
|
-
}
|
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
-
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
-
import {
|
|
4
|
-
archiveCampaignTemplateMtn,
|
|
5
|
-
createCampaignMtn,
|
|
6
|
-
createCampaignTemplateMtn,
|
|
7
|
-
createEmailCampaignDraftMtn,
|
|
8
|
-
createFormCampaignDraftMtn,
|
|
9
|
-
editCampaignMtn,
|
|
10
|
-
editCampaignSettingsMtn,
|
|
11
|
-
editCampaignTemplateMtn,
|
|
12
|
-
finalizeCampaignElementImageUploadMtn,
|
|
13
|
-
finalizeCampaignHeaderImageUploadMtn,
|
|
14
|
-
retryCampaignGenerationMtn,
|
|
15
|
-
sendCampaignEmailMtn,
|
|
16
|
-
sendCampaignTestEmailMtn,
|
|
17
|
-
submitCampaignResponseMtn,
|
|
18
|
-
updateCampaignAccessMtn,
|
|
19
|
-
} from '../gql/mutations/campaignMutations.ts';
|
|
20
|
-
import { useMutation } from './index.ts';
|
|
21
|
-
|
|
22
|
-
/*
|
|
23
|
-
* Start one AI-generated campaign from an accessible template.
|
|
24
|
-
*
|
|
25
|
-
* Resolves as soon as the GENERATING campaign exists. A later GraphQL-only
|
|
26
|
-
* GENERATED websocket patch tells observers to refetch the finished draft.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
export function useCreateCampaign(
|
|
30
|
-
params: UseMutationParams = {},
|
|
31
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
32
|
-
) {
|
|
33
|
-
const { onCompleted, ...rest } = params;
|
|
34
|
-
const [createCampaign, mtnValues, mtnHandlers, updateObservers] = useMutation(
|
|
35
|
-
createCampaignMtn,
|
|
36
|
-
{
|
|
37
|
-
openModalPopUp,
|
|
38
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
39
|
-
onCompleted?.(data?.createCampaign, error, variables);
|
|
40
|
-
},
|
|
41
|
-
...rest,
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
createCampaign,
|
|
47
|
-
updateObservers,
|
|
48
|
-
...mtnValues,
|
|
49
|
-
...mtnHandlers,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/*
|
|
54
|
-
* Retry one failed generation. The row returns to GENERATING and settles again
|
|
55
|
-
* over the websocket.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export function useRetryCampaignGeneration(
|
|
59
|
-
params: UseMutationParams = {},
|
|
60
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
61
|
-
) {
|
|
62
|
-
const { onCompleted, ...rest } = params;
|
|
63
|
-
|
|
64
|
-
const [retryCampaignGeneration, mtnValues, mtnHandlers, updateObservers] =
|
|
65
|
-
useMutation(retryCampaignGenerationMtn, {
|
|
66
|
-
openModalPopUp,
|
|
67
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
68
|
-
onCompleted?.(data?.retryCampaignGeneration, error, variables);
|
|
69
|
-
},
|
|
70
|
-
...rest,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
retryCampaignGeneration,
|
|
75
|
-
updateObservers,
|
|
76
|
-
...mtnValues,
|
|
77
|
-
...mtnHandlers,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/*
|
|
82
|
-
* Apply a versioned editor patch to one reusable campaign template.
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
/*
|
|
86
|
-
* Create one empty, editable campaign template owned by the organization.
|
|
87
|
-
*/
|
|
88
|
-
export function useCreateCampaignTemplate(
|
|
89
|
-
params: UseMutationParams = {},
|
|
90
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
91
|
-
) {
|
|
92
|
-
const { onCompleted, ...rest } = params;
|
|
93
|
-
const [createCampaignTemplate, mtnValues, mtnHandlers, updateObservers] =
|
|
94
|
-
useMutation(createCampaignTemplateMtn, {
|
|
95
|
-
openModalPopUp,
|
|
96
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
97
|
-
onCompleted?.(data?.createCampaignTemplate, error, variables);
|
|
98
|
-
},
|
|
99
|
-
...rest,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
createCampaignTemplate,
|
|
104
|
-
updateObservers,
|
|
105
|
-
...mtnValues,
|
|
106
|
-
...mtnHandlers,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function useEditCampaignTemplate(
|
|
111
|
-
params: UseMutationParams = {},
|
|
112
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
113
|
-
) {
|
|
114
|
-
const { onCompleted, ...rest } = params;
|
|
115
|
-
|
|
116
|
-
const [editCampaignTemplate, mtnValues, mtnHandlers, updateObservers] =
|
|
117
|
-
useMutation(editCampaignTemplateMtn, {
|
|
118
|
-
openModalPopUp,
|
|
119
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
120
|
-
onCompleted?.(data?.editCampaignTemplate, error, variables);
|
|
121
|
-
},
|
|
122
|
-
...rest,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
editCampaignTemplate,
|
|
127
|
-
updateObservers,
|
|
128
|
-
...mtnValues,
|
|
129
|
-
...mtnHandlers,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/*
|
|
134
|
-
* Apply a versioned editor patch to one campaign.
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
export function useEditCampaign(
|
|
138
|
-
params: UseMutationParams = {},
|
|
139
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
140
|
-
) {
|
|
141
|
-
const { onCompleted, ...rest } = params;
|
|
142
|
-
|
|
143
|
-
const [editCampaign, mtnValues, mtnHandlers, updateObservers] = useMutation(
|
|
144
|
-
editCampaignMtn,
|
|
145
|
-
{
|
|
146
|
-
openModalPopUp,
|
|
147
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
148
|
-
const result = data?.editCampaign;
|
|
149
|
-
onCompleted?.(result, error, variables);
|
|
150
|
-
},
|
|
151
|
-
...rest,
|
|
152
|
-
},
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
editCampaign,
|
|
157
|
-
updateObservers,
|
|
158
|
-
...mtnValues,
|
|
159
|
-
...mtnHandlers,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/*
|
|
164
|
-
* Finalize one uploaded campaign header image before an editor links it.
|
|
165
|
-
*/
|
|
166
|
-
export function useFinalizeCampaignHeaderImageUpload(
|
|
167
|
-
params: UseMutationParams = {},
|
|
168
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
169
|
-
) {
|
|
170
|
-
const { onCompleted, ...rest } = params;
|
|
171
|
-
const [
|
|
172
|
-
finalizeCampaignHeaderImageUpload,
|
|
173
|
-
mtnValues,
|
|
174
|
-
mtnHandlers,
|
|
175
|
-
updateObservers,
|
|
176
|
-
] = useMutation(finalizeCampaignHeaderImageUploadMtn, {
|
|
177
|
-
openModalPopUp,
|
|
178
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
179
|
-
onCompleted?.(data?.finalizeCampaignHeaderImageUpload, error, variables);
|
|
180
|
-
},
|
|
181
|
-
...rest,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
finalizeCampaignHeaderImageUpload,
|
|
186
|
-
updateObservers,
|
|
187
|
-
...mtnValues,
|
|
188
|
-
...mtnHandlers,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/*
|
|
193
|
-
* Finalize one uploaded campaign element image before an editor links it.
|
|
194
|
-
*/
|
|
195
|
-
export function useFinalizeCampaignElementImageUpload(
|
|
196
|
-
params: UseMutationParams = {},
|
|
197
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
198
|
-
) {
|
|
199
|
-
const { onCompleted, ...rest } = params;
|
|
200
|
-
const [
|
|
201
|
-
finalizeCampaignElementImageUpload,
|
|
202
|
-
mtnValues,
|
|
203
|
-
mtnHandlers,
|
|
204
|
-
updateObservers,
|
|
205
|
-
] = useMutation(finalizeCampaignElementImageUploadMtn, {
|
|
206
|
-
openModalPopUp,
|
|
207
|
-
/*
|
|
208
|
-
* Unwrap the finalized element image payload for hook consumers.
|
|
209
|
-
*/
|
|
210
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
211
|
-
onCompleted?.(data?.finalizeCampaignElementImageUpload, error, variables);
|
|
212
|
-
},
|
|
213
|
-
...rest,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
return {
|
|
217
|
-
finalizeCampaignElementImageUpload,
|
|
218
|
-
updateObservers,
|
|
219
|
-
...mtnValues,
|
|
220
|
-
...mtnHandlers,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/*
|
|
225
|
-
* Apply one versioned public-form audience change.
|
|
226
|
-
*/
|
|
227
|
-
export function useUpdateCampaignAccess(
|
|
228
|
-
params: UseMutationParams = {},
|
|
229
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
230
|
-
) {
|
|
231
|
-
const { onCompleted, ...rest } = params;
|
|
232
|
-
const [updateCampaignAccess, mtnValues, mtnHandlers, updateObservers] =
|
|
233
|
-
useMutation(updateCampaignAccessMtn, {
|
|
234
|
-
openModalPopUp,
|
|
235
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
236
|
-
onCompleted?.(data?.updateCampaignAccess, error, variables);
|
|
237
|
-
},
|
|
238
|
-
...rest,
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
return {
|
|
242
|
-
updateCampaignAccess,
|
|
243
|
-
updateObservers,
|
|
244
|
-
...mtnValues,
|
|
245
|
-
...mtnHandlers,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/*
|
|
250
|
-
* Submit or replace one public campaign response and unwrap its acknowledgement payload.
|
|
251
|
-
*/
|
|
252
|
-
export function useSubmitCampaignResponse(
|
|
253
|
-
params: UseMutationParams = {},
|
|
254
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
255
|
-
) {
|
|
256
|
-
const { onCompleted, ...rest } = params;
|
|
257
|
-
const [submitCampaignResponse, mtnValues, mtnHandlers] = useMutation(
|
|
258
|
-
submitCampaignResponseMtn,
|
|
259
|
-
{
|
|
260
|
-
openModalPopUp,
|
|
261
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
262
|
-
onCompleted?.(data?.submitCampaignResponse, error, variables);
|
|
263
|
-
},
|
|
264
|
-
...rest,
|
|
265
|
-
},
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
return {
|
|
269
|
-
submitCampaignResponse,
|
|
270
|
-
...mtnValues,
|
|
271
|
-
...mtnHandlers,
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/*
|
|
276
|
-
* Create one editable public-form campaign draft.
|
|
277
|
-
*/
|
|
278
|
-
export function useCreateFormCampaignDraft(
|
|
279
|
-
params: UseMutationParams = {},
|
|
280
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
281
|
-
) {
|
|
282
|
-
const { onCompleted, ...rest } = params;
|
|
283
|
-
const [createFormCampaignDraft, mtnValues, mtnHandlers, updateObservers] =
|
|
284
|
-
useMutation(createFormCampaignDraftMtn, {
|
|
285
|
-
openModalPopUp,
|
|
286
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
287
|
-
onCompleted?.(data?.createFormCampaignDraft, error, variables);
|
|
288
|
-
},
|
|
289
|
-
...rest,
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
return {
|
|
293
|
-
createFormCampaignDraft,
|
|
294
|
-
updateObservers,
|
|
295
|
-
...mtnValues,
|
|
296
|
-
...mtnHandlers,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/*
|
|
301
|
-
* Create one editable email campaign draft from an active email template.
|
|
302
|
-
*/
|
|
303
|
-
export function useCreateEmailCampaignDraft(
|
|
304
|
-
params: UseMutationParams = {},
|
|
305
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
306
|
-
) {
|
|
307
|
-
const { onCompleted, ...rest } = params;
|
|
308
|
-
const [createEmailCampaignDraft, mtnValues, mtnHandlers, updateObservers] =
|
|
309
|
-
useMutation(createEmailCampaignDraftMtn, {
|
|
310
|
-
openModalPopUp,
|
|
311
|
-
/*
|
|
312
|
-
* Unwrap the created email draft payload for hook consumers.
|
|
313
|
-
*/
|
|
314
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
315
|
-
onCompleted?.(data?.createEmailCampaignDraft, error, variables);
|
|
316
|
-
},
|
|
317
|
-
...rest,
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
return {
|
|
321
|
-
createEmailCampaignDraft,
|
|
322
|
-
updateObservers,
|
|
323
|
-
...mtnValues,
|
|
324
|
-
...mtnHandlers,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/*
|
|
329
|
-
* Edit one campaign's versioned settings, draft reset, or lifecycle.
|
|
330
|
-
*/
|
|
331
|
-
export function useEditCampaignSettings(
|
|
332
|
-
params: UseMutationParams = {},
|
|
333
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
334
|
-
) {
|
|
335
|
-
const { onCompleted, ...rest } = params;
|
|
336
|
-
const [editCampaignSettings, mtnValues, mtnHandlers, updateObservers] =
|
|
337
|
-
useMutation(editCampaignSettingsMtn, {
|
|
338
|
-
openModalPopUp,
|
|
339
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
340
|
-
onCompleted?.(data?.editCampaignSettings, error, variables);
|
|
341
|
-
},
|
|
342
|
-
...rest,
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
return {
|
|
346
|
-
editCampaignSettings,
|
|
347
|
-
updateObservers,
|
|
348
|
-
...mtnValues,
|
|
349
|
-
...mtnHandlers,
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/*
|
|
354
|
-
* Archive one template. Campaigns published from it keep working.
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
|
-
export function useArchiveCampaignTemplate(
|
|
358
|
-
params: UseMutationParams = {},
|
|
359
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
360
|
-
) {
|
|
361
|
-
const { onCompleted, ...rest } = params;
|
|
362
|
-
|
|
363
|
-
const [archiveCampaignTemplate, mtnValues, mtnHandlers, updateObservers] =
|
|
364
|
-
useMutation(archiveCampaignTemplateMtn, {
|
|
365
|
-
openModalPopUp,
|
|
366
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
367
|
-
onCompleted?.(data?.archiveCampaignTemplate, error, variables);
|
|
368
|
-
},
|
|
369
|
-
...rest,
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
return {
|
|
373
|
-
archiveCampaignTemplate,
|
|
374
|
-
updateObservers,
|
|
375
|
-
...mtnValues,
|
|
376
|
-
...mtnHandlers,
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/*
|
|
381
|
-
* Send one test of an email campaign's saved content to a member of the
|
|
382
|
-
* organization. It freezes no recipients and uses no send limit.
|
|
383
|
-
*/
|
|
384
|
-
|
|
385
|
-
export function useSendCampaignTestEmail(
|
|
386
|
-
params: UseMutationParams = {},
|
|
387
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
388
|
-
) {
|
|
389
|
-
const { onCompleted, ...rest } = params;
|
|
390
|
-
const [sendCampaignTestEmail, mtnValues, mtnHandlers, updateObservers] =
|
|
391
|
-
useMutation(sendCampaignTestEmailMtn, {
|
|
392
|
-
openModalPopUp,
|
|
393
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
394
|
-
onCompleted?.(data?.sendCampaignTestEmail, error, variables);
|
|
395
|
-
},
|
|
396
|
-
...rest,
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
return {
|
|
400
|
-
sendCampaignTestEmail,
|
|
401
|
-
updateObservers,
|
|
402
|
-
...mtnValues,
|
|
403
|
-
...mtnHandlers,
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/*
|
|
408
|
-
* @deprecated Create an email campaign draft, select its audience lists, and use
|
|
409
|
-
* useEditCampaignSettings with command.sendEmail.
|
|
410
|
-
*
|
|
411
|
-
* Passing the same idempotency key again returns the original campaign rather than
|
|
412
|
-
* mailing anybody twice, so a retried click is safe.
|
|
413
|
-
*/
|
|
414
|
-
|
|
415
|
-
export function useSendCampaignEmail(
|
|
416
|
-
params: UseMutationParams = {},
|
|
417
|
-
openModalPopUp?: OpenModalPopUpFn,
|
|
418
|
-
) {
|
|
419
|
-
const { onCompleted, ...rest } = params;
|
|
420
|
-
|
|
421
|
-
const [sendCampaignEmail, mtnValues, mtnHandlers, updateObservers] =
|
|
422
|
-
useMutation(sendCampaignEmailMtn, {
|
|
423
|
-
openModalPopUp,
|
|
424
|
-
onCompleted: (data: any, error: any, variables: any) => {
|
|
425
|
-
onCompleted?.(data?.sendCampaignEmail, error, variables);
|
|
426
|
-
},
|
|
427
|
-
...rest,
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
return {
|
|
431
|
-
sendCampaignEmail,
|
|
432
|
-
updateObservers,
|
|
433
|
-
...mtnValues,
|
|
434
|
-
...mtnHandlers,
|
|
435
|
-
};
|
|
436
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Apply archive-only websocket state without mixing editor revisions or definitions.
|
|
3
|
-
* Tombstones disable existing editors immediately; list membership stays unchanged
|
|
4
|
-
* until the user refreshes. Never resurrect a tombstone from an older query result.
|
|
5
|
-
*/
|
|
6
|
-
export function applyCampaignArchive<
|
|
7
|
-
T extends { id: string; archivedAt?: string | null; __deleted?: boolean },
|
|
8
|
-
>(
|
|
9
|
-
source: T | null | undefined,
|
|
10
|
-
fragment:
|
|
11
|
-
| { id: string; archivedAt?: string | null; __deleted?: boolean }
|
|
12
|
-
| null
|
|
13
|
-
| undefined,
|
|
14
|
-
): T | null | undefined {
|
|
15
|
-
if (!source || source.id !== fragment?.id || !fragment.__deleted)
|
|
16
|
-
return source;
|
|
17
|
-
return {
|
|
18
|
-
...source,
|
|
19
|
-
__deleted: true,
|
|
20
|
-
...(fragment.archivedAt ? { archivedAt: fragment.archivedAt } : {}),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/*
|
|
24
|
-
* Keep recipient data scoped to the active campaign, organization, and filters
|
|
25
|
-
* while the shared query client retains an earlier response during navigation.
|
|
26
|
-
*/
|
|
27
|
-
export function getCampaignQueryData<T>(
|
|
28
|
-
result: {
|
|
29
|
-
data?: T | null;
|
|
30
|
-
queryKey: string;
|
|
31
|
-
queryName: string;
|
|
32
|
-
variablesKey: string;
|
|
33
|
-
},
|
|
34
|
-
skipped: boolean,
|
|
35
|
-
): T | null {
|
|
36
|
-
return !skipped &&
|
|
37
|
-
result.queryKey === `#${result.queryName}:${result.variablesKey}`
|
|
38
|
-
? (result.data ?? null)
|
|
39
|
-
: null;
|
|
40
|
-
}
|