@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,55 @@
|
|
|
1
|
+
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
+
import { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
+
import {
|
|
4
|
+
cancelReminderMtn,
|
|
5
|
+
updateReminderMtn,
|
|
6
|
+
} from '../gql/mutations/workflowMutations.ts';
|
|
7
|
+
import { useMutation } from './index.ts';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Cancel one reminder (deactivates it and stops open runs);
|
|
11
|
+
* cache updates arrive via the server's realtime fragment emit
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export function useCancelReminder(
|
|
15
|
+
params: UseMutationParams = {},
|
|
16
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
17
|
+
) {
|
|
18
|
+
const [cancelReminder, mtnValues, mtnHandlers] = useMutation(
|
|
19
|
+
cancelReminderMtn,
|
|
20
|
+
{
|
|
21
|
+
openModalPopUp,
|
|
22
|
+
...params,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
cancelReminder,
|
|
28
|
+
...mtnValues,
|
|
29
|
+
...mtnHandlers,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Update one reminder's title/schedule;
|
|
35
|
+
* cache updates arrive via the server's realtime fragment emit
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export function useUpdateReminder(
|
|
39
|
+
params: UseMutationParams = {},
|
|
40
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
41
|
+
) {
|
|
42
|
+
const [updateReminder, mtnValues, mtnHandlers] = useMutation(
|
|
43
|
+
updateReminderMtn,
|
|
44
|
+
{
|
|
45
|
+
openModalPopUp,
|
|
46
|
+
...params,
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
updateReminder,
|
|
52
|
+
...mtnValues,
|
|
53
|
+
...mtnHandlers,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useQuery,
|
|
3
|
+
useReactiveFragment,
|
|
4
|
+
useReactiveFragmentMap,
|
|
5
|
+
} from '@jsb188/graphql/client';
|
|
6
|
+
import type {
|
|
7
|
+
WorkflowRunsFilterGQL,
|
|
8
|
+
WorkflowsFilterGQL,
|
|
9
|
+
} from '@jsb188/mday/types/workflow.d.ts';
|
|
10
|
+
import {
|
|
11
|
+
FRAGMENT_NAMES,
|
|
12
|
+
getFragmentBaseName,
|
|
13
|
+
makeFragmentKey,
|
|
14
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
15
|
+
import { useCallback } from 'react';
|
|
16
|
+
import {
|
|
17
|
+
workflowRunQry,
|
|
18
|
+
workflowRunsQry,
|
|
19
|
+
workflowsQry,
|
|
20
|
+
} from '../gql/queries/workflowQueries.ts';
|
|
21
|
+
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Constants
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const WORKFLOW_LISTS_LIMIT = 60;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Keep workflow list filters aligned with the WorkflowsFilter input shape
|
|
31
|
+
* (route table filters carry extra URL-only keys)
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function normalizeWorkflowsFilter(
|
|
35
|
+
filter?: Record<string, any> | null,
|
|
36
|
+
): WorkflowsFilterGQL {
|
|
37
|
+
return {
|
|
38
|
+
kind: filter?.kind || null,
|
|
39
|
+
startDate: filter?.startDate || null,
|
|
40
|
+
endDate: filter?.endDate || null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Keep run list filters aligned with the WorkflowRunsFilter input shape
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function normalizeWorkflowRunsFilter(
|
|
49
|
+
filter?: Record<string, any> | null,
|
|
50
|
+
): WorkflowRunsFilterGQL {
|
|
51
|
+
return {
|
|
52
|
+
workflowId: filter?.workflowId || null,
|
|
53
|
+
kind: filter?.kind || null,
|
|
54
|
+
statuses: filter?.statuses || null,
|
|
55
|
+
startDate: filter?.startDate || null,
|
|
56
|
+
endDate: filter?.endDate || null,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Wrap a query's fetchMore so pagination calls re-normalize route filters;
|
|
62
|
+
* the route table rebuilds fetchMore variables from the raw route filter state
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
function useNormalizedFilterFetchMore(
|
|
66
|
+
fetchMore: (options: any) => Promise<any>,
|
|
67
|
+
normalizeFilter: (filter?: Record<string, any> | null) => Record<string, any>,
|
|
68
|
+
) {
|
|
69
|
+
return useCallback(
|
|
70
|
+
(options: any) => {
|
|
71
|
+
if (!options?.variables?.filter) {
|
|
72
|
+
return fetchMore(options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return fetchMore({
|
|
76
|
+
...options,
|
|
77
|
+
variables: {
|
|
78
|
+
...options.variables,
|
|
79
|
+
filter: normalizeFilter(options.variables.filter),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
[fetchMore, normalizeFilter],
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Fetch the merged paginated workflows list (workflows + reminders) for an organization
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
export function useWorkflows(
|
|
92
|
+
variables: PaginationArgs & {
|
|
93
|
+
organizationId?: string | null;
|
|
94
|
+
filter?: WorkflowsFilterGQL | Record<string, any> | null;
|
|
95
|
+
sort?: string | null;
|
|
96
|
+
},
|
|
97
|
+
params: UseQueryParams = {},
|
|
98
|
+
) {
|
|
99
|
+
const { data, fetchMore, ...rest } = useQuery(workflowsQry, {
|
|
100
|
+
...params,
|
|
101
|
+
variables: {
|
|
102
|
+
...variables,
|
|
103
|
+
filter: normalizeWorkflowsFilter(variables.filter),
|
|
104
|
+
cursor: null,
|
|
105
|
+
after: true,
|
|
106
|
+
limit: variables.limit ?? WORKFLOW_LISTS_LIMIT,
|
|
107
|
+
},
|
|
108
|
+
skip: !variables.organizationId || params.skip,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const fetchMoreWorkflows = useNormalizedFilterFetchMore(
|
|
112
|
+
fetchMore,
|
|
113
|
+
normalizeWorkflowsFilter,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
workflows: data?.workflows,
|
|
118
|
+
fetchMore: fetchMoreWorkflows,
|
|
119
|
+
...rest,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Fetch the paginated runs list for an organization,
|
|
125
|
+
* optionally scoped to one workflow via filter.workflowId
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
export function useWorkflowRuns(
|
|
129
|
+
variables: PaginationArgs & {
|
|
130
|
+
organizationId?: string | null;
|
|
131
|
+
filter?: WorkflowRunsFilterGQL | Record<string, any> | null;
|
|
132
|
+
sort?: string | null;
|
|
133
|
+
},
|
|
134
|
+
params: UseQueryParams = {},
|
|
135
|
+
) {
|
|
136
|
+
const { data, fetchMore, ...rest } = useQuery(workflowRunsQry, {
|
|
137
|
+
...params,
|
|
138
|
+
variables: {
|
|
139
|
+
...variables,
|
|
140
|
+
filter: normalizeWorkflowRunsFilter(variables.filter),
|
|
141
|
+
cursor: null,
|
|
142
|
+
after: true,
|
|
143
|
+
limit: variables.limit ?? WORKFLOW_LISTS_LIMIT,
|
|
144
|
+
},
|
|
145
|
+
skip: !variables.organizationId || params.skip,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const fetchMoreWorkflowRuns = useNormalizedFilterFetchMore(
|
|
149
|
+
fetchMore,
|
|
150
|
+
normalizeWorkflowRunsFilter,
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
workflowRuns: data?.workflowRuns,
|
|
155
|
+
fetchMore: fetchMoreWorkflowRuns,
|
|
156
|
+
...rest,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Fetch one workflow run (for the run detail modal), merged with live fragment updates
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
export function useWorkflowRun(
|
|
165
|
+
variables: {
|
|
166
|
+
organizationId?: string | null;
|
|
167
|
+
workflowRunId?: string | null;
|
|
168
|
+
},
|
|
169
|
+
params: UseQueryParams = {},
|
|
170
|
+
) {
|
|
171
|
+
const { data, ...rest } = useQuery(workflowRunQry, {
|
|
172
|
+
...params,
|
|
173
|
+
variables,
|
|
174
|
+
skip: !variables.organizationId || !variables.workflowRunId || params.skip,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Always query; the cached list fragment does not carry the nested workflow
|
|
178
|
+
const reactiveWorkflowRun = useReactiveWorkflowRunFragment(
|
|
179
|
+
variables.workflowRunId || '',
|
|
180
|
+
data?.workflowRun ?? null,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
workflowRun: reactiveWorkflowRun || data?.workflowRun,
|
|
185
|
+
...rest,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Get reactive workflow fragment
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
export function useReactiveWorkflowFragment(
|
|
194
|
+
workflowId: string,
|
|
195
|
+
currentData?: any,
|
|
196
|
+
queryCount?: number,
|
|
197
|
+
) {
|
|
198
|
+
return useReactiveFragment(
|
|
199
|
+
currentData,
|
|
200
|
+
[makeFragmentKey(FRAGMENT_NAMES.workflow, workflowId)],
|
|
201
|
+
queryCount,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Get reactive workflow run fragment for a single run
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
export function useReactiveWorkflowRunFragment(
|
|
210
|
+
workflowRunId: string,
|
|
211
|
+
currentData?: any,
|
|
212
|
+
queryCount?: number,
|
|
213
|
+
) {
|
|
214
|
+
return useReactiveFragment(
|
|
215
|
+
currentData,
|
|
216
|
+
[makeFragmentKey(FRAGMENT_NAMES.workflowRun, workflowRunId)],
|
|
217
|
+
queryCount,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Get reactive workflow run fragments for a list of runs (run history)
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
export function useReactiveWorkflowRunFragmentMap(workflowRuns?: any[] | null) {
|
|
226
|
+
return useReactiveFragmentMap(
|
|
227
|
+
workflowRuns || null,
|
|
228
|
+
getFragmentBaseName(FRAGMENT_NAMES.workflowRun),
|
|
229
|
+
);
|
|
230
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { getENVVariable } from '@jsb188/app';
|
|
2
|
+
import type {
|
|
3
|
+
CampaignAnswersObj,
|
|
4
|
+
PublicCampaignObj,
|
|
5
|
+
} from '@jsb188/mday/types/campaign.d.ts';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* The public campaign surface is REST rather than GraphQL: it is loaded by a
|
|
9
|
+
* server loader for an anonymous visitor, so there is no viewer session to
|
|
10
|
+
* carry a GraphQL context.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function getRESTServer() {
|
|
14
|
+
return String(getENVVariable('GQL_SERVER') || '').replace(
|
|
15
|
+
/\/graphql\/?$/,
|
|
16
|
+
'',
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Read one campaign's REST payload, mapping transport failures onto the two
|
|
22
|
+
* outcomes a route error boundary can act on: 404 (no such campaign) and 500
|
|
23
|
+
* (anything else). A missing REST server or publicId returns null instead,
|
|
24
|
+
* because that is a configuration edge case with nothing to render.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
async function fetchCampaignREST<T>(
|
|
28
|
+
path: string,
|
|
29
|
+
headers?: Record<string, string>,
|
|
30
|
+
): Promise<T | null> {
|
|
31
|
+
const restServer = getRESTServer();
|
|
32
|
+
|
|
33
|
+
if (!restServer) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let response: Response;
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
response = await fetch(`${restServer}${path}`, {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
headers: {
|
|
43
|
+
'x-api-key': String(getENVVariable('GQL_API_KEY') || ''),
|
|
44
|
+
...(headers || {}),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
} catch {
|
|
48
|
+
// Network-level failure (server unreachable etc.) is an internal error
|
|
49
|
+
throw new Response(null, { status: 500 });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (response.status === 404) {
|
|
53
|
+
throw new Response(null, { status: 404 });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new Response(null, { status: 500 });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const json = await response.json();
|
|
62
|
+
return (json?.data as T) ?? null;
|
|
63
|
+
} catch (err) {
|
|
64
|
+
if (err instanceof Response) {
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
throw new Response(null, { status: 500 });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Fetch the sanitized public campaign definition for server rendering.
|
|
73
|
+
*
|
|
74
|
+
* A closed campaign still resolves, with metadata and `sections: null` - the
|
|
75
|
+
* page renders a closed notice rather than a 404, because the link is valid
|
|
76
|
+
* and the respondent should be told why they cannot answer.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
export async function fetchPublicCampaign(
|
|
80
|
+
publicId: string,
|
|
81
|
+
): Promise<PublicCampaignObj | null> {
|
|
82
|
+
if (!publicId) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const campaign = await fetchCampaignREST<PublicCampaignObj>(
|
|
87
|
+
`/api/campaigns/${encodeURIComponent(publicId)}`,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// A 200 with no payload means the campaign could not be resolved
|
|
91
|
+
if (!campaign) {
|
|
92
|
+
throw new Response(null, { status: 404 });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return campaign;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface CampaignRespondentContextData {
|
|
99
|
+
respondentName?: string | null;
|
|
100
|
+
childOrgId?: string | null;
|
|
101
|
+
responseId?: string | null;
|
|
102
|
+
status?: 'DRAFT' | 'SUBMITTED' | null;
|
|
103
|
+
answers?: CampaignAnswersObj;
|
|
104
|
+
submittedAt?: string | null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Fetch one respondent's saved answers so a partly filled form reopens where
|
|
109
|
+
* they left it.
|
|
110
|
+
*
|
|
111
|
+
* Only an account-authenticated viewer can be resolved server-side; a
|
|
112
|
+
* token-authenticated respondent is client-only, so a failure here degrades to
|
|
113
|
+
* null rather than failing the page.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
export async function fetchCampaignRespondentContext(
|
|
117
|
+
publicId: string,
|
|
118
|
+
options: { authToken?: string | null; childOrgId?: string | null },
|
|
119
|
+
): Promise<CampaignRespondentContextData | null> {
|
|
120
|
+
if (!publicId || !options.authToken) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const query = options.childOrgId
|
|
125
|
+
? `?childOrgId=${encodeURIComponent(options.childOrgId)}`
|
|
126
|
+
: '';
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
return await fetchCampaignREST<CampaignRespondentContextData>(
|
|
130
|
+
`/api/campaigns/${encodeURIComponent(publicId)}/respondent${query}`,
|
|
131
|
+
{ authorization: options.authToken },
|
|
132
|
+
);
|
|
133
|
+
} catch {
|
|
134
|
+
// The definition already loaded; a missing fill context is not fatal
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
package/package.json
CHANGED
|
@@ -1,54 +1,96 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
2
|
+
"name": "@jsb188/graphql",
|
|
3
|
+
"version": "1.1.11",
|
|
4
|
+
"description": "GraphQL client for react, using recoil",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "jsb188",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "types.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./fragments/account": "./gql/fragments/accountFragments.ts",
|
|
11
|
+
"./fragments/accountAuth": "./gql/fragments/accountAuthFragments.ts",
|
|
12
|
+
"./fragments/accountSession": "./gql/fragments/accountSessionFragments.ts",
|
|
13
|
+
"./fragments/aiChat": "./gql/fragments/aiChatFragments.ts",
|
|
14
|
+
"./fragments/billing": "./gql/fragments/billingFragments.ts",
|
|
15
|
+
"./fragments/email": "./gql/fragments/emailFragments.ts",
|
|
16
|
+
"./fragments/inboundContact": "./gql/fragments/inboundContactFragments.ts",
|
|
17
|
+
"./fragments/integration": "./gql/fragments/integrationFragments.ts",
|
|
18
|
+
"./fragments/log": "./gql/fragments/logFragments.ts",
|
|
19
|
+
"./fragments/schedule": "./gql/fragments/scheduleFragments.ts",
|
|
20
|
+
"./fragments/agentDoc": "./gql/fragments/agentDocFragments.ts",
|
|
21
|
+
"./fragments/organization": "./gql/fragments/organizationFragments.ts",
|
|
22
|
+
"./fragments/other": "./gql/fragments/otherFragments.ts",
|
|
23
|
+
"./fragments/fieldDoc": "./gql/fragments/fieldDocFragments.ts",
|
|
24
|
+
"./fragments/campaign": "./gql/fragments/campaignFragments.ts",
|
|
25
|
+
"./fragments/dataTable": "./gql/fragments/dataTableFragments.ts",
|
|
26
|
+
"./fragments/sheet": "./gql/fragments/sheetFragments.ts",
|
|
27
|
+
"./fragments/storage": "./gql/fragments/storageFragments.ts",
|
|
28
|
+
"./fragments/workflow": "./gql/fragments/workflowFragments.ts",
|
|
29
|
+
"./hooks": "./hooks/",
|
|
30
|
+
"./hooks/use-action-qry": "./hooks/use-action-qry.ts",
|
|
31
|
+
"./hooks/use-aiChat-qry": "./hooks/use-aiChat-qry.ts",
|
|
32
|
+
"./hooks/use-app-qry": "./hooks/use-app-qry.ts",
|
|
33
|
+
"./hooks/use-email-qry": "./hooks/use-email-qry.ts",
|
|
34
|
+
"./hooks/use-agentMemory-qry": "./hooks/use-agentMemory-qry.ts",
|
|
35
|
+
"./hooks/use-inboundContact-qry": "./hooks/use-inboundContact-qry.ts",
|
|
36
|
+
"./hooks/use-log-qry": "./hooks/use-log-qry.ts",
|
|
37
|
+
"./hooks/use-agentDoc-qry": "./hooks/use-agentDoc-qry.ts",
|
|
38
|
+
"./hooks/use-schedule-mtn": "./hooks/use-schedule-mtn.ts",
|
|
39
|
+
"./hooks/use-schedule-qry": "./hooks/use-schedule-qry.ts",
|
|
40
|
+
"./hooks/use-agentDoc-mtn": "./hooks/use-agentDoc-mtn.ts",
|
|
41
|
+
"./hooks/use-organization-qry": "./hooks/use-organization-qry.ts",
|
|
42
|
+
"./hooks/use-fieldDoc-qry": "./hooks/use-fieldDoc-qry.ts",
|
|
43
|
+
"./hooks/use-fieldDoc-mtn": "./hooks/use-fieldDoc-mtn.ts",
|
|
44
|
+
"./hooks/use-campaign-qry": "./hooks/use-campaign-qry.ts",
|
|
45
|
+
"./hooks/use-campaign-mtn": "./hooks/use-campaign-mtn.ts",
|
|
46
|
+
"./hooks/use-dataTable-mtn": "./hooks/use-dataTable-mtn.ts",
|
|
47
|
+
"./hooks/use-dataTable-qry": "./hooks/use-dataTable-qry.ts",
|
|
48
|
+
"./hooks/use-sheet-mtn": "./hooks/use-sheet-mtn.ts",
|
|
49
|
+
"./hooks/use-sheet-qry": "./hooks/use-sheet-qry.ts",
|
|
50
|
+
"./hooks/use-storage-qry": "./hooks/use-storage-qry.ts",
|
|
51
|
+
"./hooks/use-workflow-qry": "./hooks/use-workflow-qry.ts",
|
|
52
|
+
"./hooks/use-workflow-mtn": "./hooks/use-workflow-mtn.ts",
|
|
53
|
+
"./hooks/use-account-mtn": "./hooks/use-account-mtn.ts",
|
|
54
|
+
"./hooks/use-aiChat-mtn": "./hooks/use-aiChat-mtn.ts",
|
|
55
|
+
"./hooks/use-auth-mtn": "./hooks/use-auth-mtn.ts",
|
|
56
|
+
"./hooks/use-auth-qry": "./hooks/use-auth-qry.ts",
|
|
57
|
+
"./hooks/use-integration-qry": "./hooks/use-integration-qry.ts",
|
|
58
|
+
"./hooks/use-integration-mtn": "./hooks/use-integration-mtn.ts",
|
|
59
|
+
"./hooks/use-agentMemory-mtn": "./hooks/use-agentMemory-mtn.ts",
|
|
60
|
+
"./hooks/use-inboundContact-mtn": "./hooks/use-inboundContact-mtn.ts",
|
|
61
|
+
"./hooks/use-log-mtn": "./hooks/use-log-mtn.ts",
|
|
62
|
+
"./hooks/use-organization-mtn": "./hooks/use-organization-mtn.ts",
|
|
63
|
+
"./hooks/use-storage-mtn": "./hooks/use-storage-mtn.ts",
|
|
64
|
+
"./mutations/campaign": "./gql/mutations/campaignMutations.ts",
|
|
65
|
+
"./mutations/integration": "./gql/mutations/integrationMutations.ts",
|
|
66
|
+
"./mutations/dataTable": "./gql/mutations/dataTableMutations.ts",
|
|
67
|
+
"./mutations/schedule": "./gql/mutations/scheduleMutations.ts",
|
|
68
|
+
"./mutations/agentDoc": "./gql/mutations/agentDocMutations.ts",
|
|
69
|
+
"./mutations/fieldDoc": "./gql/mutations/fieldDocMutations.ts",
|
|
70
|
+
"./mutations/sheet": "./gql/mutations/sheetMutations.ts",
|
|
71
|
+
"./mutations": "./gql/mutations/index.ts",
|
|
72
|
+
"./queries": "./gql/queries/index.ts",
|
|
73
|
+
"./cache": "./cache/index.ts",
|
|
74
|
+
"./client": "./client/index.ts",
|
|
75
|
+
"./drafts": "./drafts/index.ts",
|
|
76
|
+
"./client/data-table-realtime": "./client/data-table-realtime.ts",
|
|
77
|
+
"./client/data-table-realtime-subscriptions": "./client/data-table-realtime-subscriptions.ts",
|
|
78
|
+
"./client/open-sheet": "./client/open-sheet.ts",
|
|
79
|
+
"./loaders/campaign": "./loaders/campaign.ts",
|
|
80
|
+
"./sse": "./sse.ts",
|
|
81
|
+
"./types.d": "./types.d.ts",
|
|
82
|
+
"./utils": "./utils.ts"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"test": "deno test --no-check --allow-env --allow-read --unstable-sloppy-imports --config ./deno.test.json ./cache/index.test.ts ./client/request-no-store.test.ts ./client/request-managed-session.test.ts ./client/data-table-realtime.test.ts ./client/data-table-realtime-subscriptions.test.ts ./client/sse-ticket.test.ts"
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"graphql": "^16.14.2",
|
|
89
|
+
"graphql-tag": "^2.12.7"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"@jsb188/app": "1.1.11",
|
|
93
|
+
"@jsb188/mday": "1.1.11",
|
|
94
|
+
"@jsb188/react": "1.1.11"
|
|
95
|
+
}
|
|
54
96
|
}
|