@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,23 +1,28 @@
|
|
|
1
1
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
-
import { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
-
import {
|
|
2
|
+
import type { OpenModalPopUpFn } from '@jsb188/react/states';
|
|
3
|
+
import {
|
|
4
|
+
deleteDataTableMtn,
|
|
5
|
+
exportDataTableToFileMtn,
|
|
6
|
+
renameDataTableMtn,
|
|
7
|
+
} from '../gql/mutations/dataTableMutations.ts';
|
|
4
8
|
import { useMutation } from './index.ts';
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* Rename a data table. The response updates the shared data table fragment.
|
|
8
12
|
*/
|
|
9
13
|
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
export function useRenameDataTable(
|
|
15
|
+
params: UseMutationParams = {},
|
|
16
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
17
|
+
) {
|
|
18
|
+
const [renameDataTable, mtnValues, mtnHandlers, updateObservers] =
|
|
19
|
+
useMutation(renameDataTableMtn, {
|
|
14
20
|
openModalPopUp,
|
|
15
21
|
...params,
|
|
16
|
-
}
|
|
17
|
-
);
|
|
22
|
+
});
|
|
18
23
|
|
|
19
24
|
return {
|
|
20
|
-
|
|
25
|
+
renameDataTable,
|
|
21
26
|
updateObservers,
|
|
22
27
|
...mtnValues,
|
|
23
28
|
...mtnHandlers,
|
|
@@ -25,20 +30,23 @@ export function useEditDataTableCell(params: UseMutationParams = {}, openModalPo
|
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
|
-
*
|
|
33
|
+
* Delete (archive) a standalone data table. A table that AI notes read or
|
|
34
|
+
* workflows write needs confirmReferenceDependents: true (error 20248 carries
|
|
35
|
+
* their count); a table an AI note owns is refused (error 20243).
|
|
29
36
|
*/
|
|
30
37
|
|
|
31
|
-
export function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
export function useDeleteDataTable(
|
|
39
|
+
params: UseMutationParams = {},
|
|
40
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
41
|
+
) {
|
|
42
|
+
const [deleteDataTable, mtnValues, mtnHandlers, updateObservers] =
|
|
43
|
+
useMutation(deleteDataTableMtn, {
|
|
35
44
|
openModalPopUp,
|
|
36
45
|
...params,
|
|
37
|
-
}
|
|
38
|
-
);
|
|
46
|
+
});
|
|
39
47
|
|
|
40
48
|
return {
|
|
41
|
-
|
|
49
|
+
deleteDataTable,
|
|
42
50
|
updateObservers,
|
|
43
51
|
...mtnValues,
|
|
44
52
|
...mtnHandlers,
|
|
@@ -46,40 +54,23 @@ export function useEditDataTableCells(params: UseMutationParams = {}, openModalP
|
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
/**
|
|
49
|
-
*
|
|
57
|
+
* Export a data table's live rows to a CSV file the client downloads (the
|
|
58
|
+
* same file shape as a sheet export). A table with more rows than one export
|
|
59
|
+
* holds is refused (error 20249 carries the row cap).
|
|
50
60
|
*/
|
|
51
61
|
|
|
52
|
-
export function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
export function useExportDataTableToFile(
|
|
63
|
+
params: UseMutationParams = {},
|
|
64
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
65
|
+
) {
|
|
66
|
+
const [exportDataTableToFile, mtnValues, mtnHandlers, updateObservers] =
|
|
67
|
+
useMutation(exportDataTableToFileMtn, {
|
|
56
68
|
openModalPopUp,
|
|
57
69
|
...params,
|
|
58
|
-
}
|
|
59
|
-
);
|
|
70
|
+
});
|
|
60
71
|
|
|
61
72
|
return {
|
|
62
|
-
|
|
63
|
-
...mtnValues,
|
|
64
|
-
...mtnHandlers,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Edit the saved design object for one dataTable.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
export function useEditDataTableDesign(params: UseMutationParams = {}, openModalPopUp?: OpenModalPopUpFn) {
|
|
73
|
-
const [editDataTableDesign, mtnValues, mtnHandlers, updateObservers] = useMutation(
|
|
74
|
-
editDataTableDesignMtn,
|
|
75
|
-
{
|
|
76
|
-
openModalPopUp,
|
|
77
|
-
...params,
|
|
78
|
-
},
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
editDataTableDesign,
|
|
73
|
+
exportDataTableToFile,
|
|
83
74
|
updateObservers,
|
|
84
75
|
...mtnValues,
|
|
85
76
|
...mtnHandlers,
|
|
@@ -1,172 +1,146 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { FRAGMENT_NAMES, getFragmentBaseName, makeFragmentKey } from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
2
|
+
import { GRID_ITEM_LIST_LIMIT } from '@jsb188/mday/constants/sheet.ts';
|
|
3
|
+
import type { DtSortDirectionEnum } from '@jsb188/mday/types/dt.d.ts';
|
|
4
|
+
import type { GridItemSortEnum } from '@jsb188/mday/types/sheet.d.ts';
|
|
5
|
+
import { dataTableQry, dataTableRowsQry, dataTableRunsQry, dataTablesQry } from '../gql/queries/dataTableQueries.ts';
|
|
6
|
+
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
7
|
+
import { useQuery, useReactiveFragment, useReactiveFragmentMap } from './index.ts';
|
|
8
|
+
|
|
9
|
+
export type DataTablesFilterVariables = {
|
|
10
|
+
search?: string | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type DataTablesVariables = PaginationArgs & {
|
|
14
|
+
filter?: DataTablesFilterVariables | null;
|
|
15
|
+
organizationId?: string | null;
|
|
16
|
+
sort?: GridItemSortEnum | null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type DataTableRowsVariables = {
|
|
20
|
+
organizationId?: string | null;
|
|
21
|
+
dataTableId?: string | null;
|
|
22
|
+
sort?: { column: string; direction: DtSortDirectionEnum } | null;
|
|
23
|
+
cursor?: string | null;
|
|
24
|
+
limit?: number | null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type DataTableRunsVariables = {
|
|
28
|
+
organizationId?: string | null;
|
|
29
|
+
dataTableId?: string | null;
|
|
30
|
+
limit?: number | null;
|
|
31
|
+
};
|
|
11
32
|
|
|
12
33
|
/*
|
|
13
|
-
* Return
|
|
34
|
+
* Return whether one useDataTables input is the paginated variables object.
|
|
14
35
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return dataTableRows?.flatMap((row) => row.cells || []) || null;
|
|
36
|
+
function isDataTablesVariables(value: string | null | undefined | DataTablesVariables): value is DataTablesVariables {
|
|
37
|
+
return !!value && typeof value === 'object';
|
|
18
38
|
}
|
|
19
39
|
|
|
20
40
|
/*
|
|
21
|
-
*
|
|
41
|
+
* Return GraphQL variables for the paginated dataTables query.
|
|
22
42
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const nextCell = cellMap.get(cell.id) || cell;
|
|
36
|
-
if (nextCell !== cell) {
|
|
37
|
-
changedCells = true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return nextCell;
|
|
41
|
-
}) || [];
|
|
42
|
-
|
|
43
|
-
if (!changedCells) {
|
|
44
|
-
return row;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
changedRows = true;
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
...row,
|
|
51
|
-
cells: nextCells,
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return changedRows ? nextRows : dataTableRows;
|
|
43
|
+
function getDataTablesQueryVariables(organizationIdOrVariables?: string | null | DataTablesVariables): DataTablesVariables {
|
|
44
|
+
const variables = isDataTablesVariables(organizationIdOrVariables)
|
|
45
|
+
? organizationIdOrVariables
|
|
46
|
+
: { organizationId: organizationIdOrVariables };
|
|
47
|
+
return {
|
|
48
|
+
...variables,
|
|
49
|
+
after: variables.after ?? true,
|
|
50
|
+
cursor: variables.cursor ?? null,
|
|
51
|
+
filter: variables.filter ?? null,
|
|
52
|
+
limit: variables.limit ?? GRID_ITEM_LIST_LIMIT,
|
|
53
|
+
sort: variables.sort || 'UPDATED_AT_DESC',
|
|
54
|
+
};
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
*
|
|
57
|
+
/**
|
|
58
|
+
* Fetch the listed data tables of an organization the viewer may read, newest first.
|
|
60
59
|
*/
|
|
60
|
+
export function useDataTables(organizationId?: string | null | DataTablesVariables, params: UseQueryParams = {}) {
|
|
61
|
+
const variables = getDataTablesQueryVariables(organizationId);
|
|
62
|
+
const { data, ...rest } = useQuery(dataTablesQry, {
|
|
63
|
+
variables,
|
|
64
|
+
...params,
|
|
65
|
+
skip: !variables.organizationId || !!params.skip,
|
|
66
|
+
});
|
|
67
|
+
const dataTables = useReactiveFragmentMap(data?.dataTables || null, getFragmentBaseName(FRAGMENT_NAMES.dataTable));
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return mergeReactiveCellsIntoRows(reactiveRows || dataTableRows, reactiveCells);
|
|
69
|
+
return {
|
|
70
|
+
dataTables,
|
|
71
|
+
...rest,
|
|
72
|
+
};
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
/*
|
|
70
|
-
*
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
function getDataTableRowsQueryKey(variables: Record<string, unknown>) {
|
|
74
|
-
return `#dataTableRows:${makeVariablesKey(variables)}`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Fetch dataTables for an organization.
|
|
76
|
+
* Fetch one data table (metadata, columns, sync state and owner note).
|
|
79
77
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
organizationId?: string | null,
|
|
83
|
-
active?: boolean | null,
|
|
84
|
-
params: UseQueryParams = {},
|
|
85
|
-
) {
|
|
86
|
-
const { data, ...rest } = useQuery(dataTablesQry, {
|
|
78
|
+
export function useDataTable(dataTableId?: string | null, organizationId?: string | null, params: UseQueryParams = {}) {
|
|
79
|
+
const { data, ...rest } = useQuery(dataTableQry, {
|
|
87
80
|
variables: {
|
|
88
81
|
organizationId,
|
|
89
|
-
|
|
82
|
+
dataTableId,
|
|
90
83
|
},
|
|
91
|
-
skip: !organizationId,
|
|
92
84
|
...params,
|
|
85
|
+
skip: !organizationId || !dataTableId || !!params.skip,
|
|
93
86
|
});
|
|
87
|
+
const dataTable = useReactiveDataTableFragment(dataTableId || '', data?.dataTable || null, rest.updatedCount);
|
|
94
88
|
|
|
95
89
|
return {
|
|
96
|
-
|
|
90
|
+
dataTable: dataTable?.id === dataTableId ? dataTable : null,
|
|
97
91
|
...rest,
|
|
98
92
|
};
|
|
99
93
|
}
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
* Fetch rows
|
|
95
|
+
/*
|
|
96
|
+
* Fetch one keyset page of a data table's live rows (100 by default), in id
|
|
97
|
+
* order or sorted by one column. The server resets this query (RESET_ONLY)
|
|
98
|
+
* when the table's rows change.
|
|
103
99
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
viewId?: string | null;
|
|
112
|
-
} | null,
|
|
113
|
-
params: UseQueryParams = {},
|
|
114
|
-
) {
|
|
115
|
-
const variables = {
|
|
116
|
-
dataTableId,
|
|
117
|
-
organizationId,
|
|
118
|
-
cursor,
|
|
119
|
-
limit,
|
|
120
|
-
filter,
|
|
100
|
+
export function useDataTableRows(variables: DataTableRowsVariables, params: UseQueryParams = {}) {
|
|
101
|
+
const queryVariables = {
|
|
102
|
+
organizationId: variables.organizationId,
|
|
103
|
+
dataTableId: variables.dataTableId,
|
|
104
|
+
sort: variables.sort ?? null,
|
|
105
|
+
cursor: variables.cursor ?? null,
|
|
106
|
+
limit: variables.limit ?? 100,
|
|
121
107
|
};
|
|
122
108
|
const { data, ...rest } = useQuery(dataTableRowsQry, {
|
|
123
|
-
variables,
|
|
124
|
-
skip: !organizationId || !dataTableId,
|
|
109
|
+
variables: queryVariables,
|
|
125
110
|
...params,
|
|
111
|
+
skip: !queryVariables.organizationId || !queryVariables.dataTableId || !!params.skip,
|
|
126
112
|
});
|
|
127
113
|
|
|
128
|
-
const queryMatchesVariables = rest.queryKey === getDataTableRowsQueryKey(variables) ||
|
|
129
|
-
rest.variablesKey === makeVariablesKey(variables);
|
|
130
|
-
const dataTableRows = useReactiveDataTableRows(queryMatchesVariables ? data?.dataTableRows : null);
|
|
131
|
-
|
|
132
114
|
return {
|
|
133
|
-
dataTableRows:
|
|
115
|
+
dataTableRows: data?.dataTableRows || null,
|
|
134
116
|
...rest,
|
|
135
117
|
};
|
|
136
118
|
}
|
|
137
119
|
|
|
138
|
-
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
export function useReactiveDataTableFragment(dataTableId: string, currentData?: any, queryCount?: number) {
|
|
143
|
-
return useReactiveFragment(
|
|
144
|
-
currentData,
|
|
145
|
-
[`$dataTableFragment:${dataTableId}`],
|
|
146
|
-
queryCount,
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Get reactive dataTable row fragment.
|
|
120
|
+
/*
|
|
121
|
+
* Fetch the newest change batches (runs) of a data table.
|
|
152
122
|
*/
|
|
123
|
+
export function useDataTableRuns(variables: DataTableRunsVariables, params: UseQueryParams = {}) {
|
|
124
|
+
const queryVariables = {
|
|
125
|
+
organizationId: variables.organizationId,
|
|
126
|
+
dataTableId: variables.dataTableId,
|
|
127
|
+
limit: variables.limit ?? 10,
|
|
128
|
+
};
|
|
129
|
+
const { data, ...rest } = useQuery(dataTableRunsQry, {
|
|
130
|
+
variables: queryVariables,
|
|
131
|
+
...params,
|
|
132
|
+
skip: !queryVariables.organizationId || !queryVariables.dataTableId || !!params.skip,
|
|
133
|
+
});
|
|
153
134
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
queryCount,
|
|
159
|
-
);
|
|
135
|
+
return {
|
|
136
|
+
dataTableRuns: data?.dataTableRuns || null,
|
|
137
|
+
...rest,
|
|
138
|
+
};
|
|
160
139
|
}
|
|
161
140
|
|
|
162
141
|
/**
|
|
163
|
-
* Get reactive
|
|
142
|
+
* Get the reactive data table fragment.
|
|
164
143
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return useReactiveFragment(
|
|
168
|
-
currentData,
|
|
169
|
-
[`$dataTableCellFragment:${dataTableCellId}`],
|
|
170
|
-
queryCount,
|
|
171
|
-
);
|
|
144
|
+
export function useReactiveDataTableFragment(dataTableId: string, currentData?: any, queryCount?: number) {
|
|
145
|
+
return useReactiveFragment(currentData, dataTableId ? [makeFragmentKey(FRAGMENT_NAMES.dataTable, dataTableId)] : [], queryCount);
|
|
172
146
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EmailMessagesFilterInput } from '@jsb188/mday/types/email.d.ts';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Whitelist GraphQL input fields, trim searches, and preserve false observation filters.
|
|
5
|
+
*/
|
|
6
|
+
export function normalizeEmailMessagesFilter(filter?: EmailMessagesFilterInput | null): EmailMessagesFilterInput | null {
|
|
7
|
+
return filter
|
|
8
|
+
? {
|
|
9
|
+
startDate: filter.startDate || null,
|
|
10
|
+
endDate: filter.endDate || null,
|
|
11
|
+
query: filter.query?.trim() || null,
|
|
12
|
+
directions: filter.directions?.length ? filter.directions : null,
|
|
13
|
+
kinds: filter.kinds?.length ? filter.kinds : null,
|
|
14
|
+
statusGroups: filter.statusGroups?.length ? filter.statusGroups : null,
|
|
15
|
+
statuses: filter.statuses?.length ? filter.statuses : null,
|
|
16
|
+
campaignId: filter.campaignId || null,
|
|
17
|
+
emailAddress: filter.emailAddress?.trim() || null,
|
|
18
|
+
fromEmail: filter.fromEmail?.trim() || null,
|
|
19
|
+
toEmail: filter.toEmail?.trim() || null,
|
|
20
|
+
subject: filter.subject?.trim() || null,
|
|
21
|
+
delivered: filter.delivered ?? null,
|
|
22
|
+
opened: filter.opened ?? null,
|
|
23
|
+
}
|
|
24
|
+
: null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Keep detail cache records inside the currently requested organization and email.
|
|
29
|
+
*/
|
|
30
|
+
export function getScopedEmailRecord<T extends { id: string; organizationId: string }>(
|
|
31
|
+
email: T | null | undefined,
|
|
32
|
+
organizationId: string | null | undefined,
|
|
33
|
+
emailId: string | null | undefined,
|
|
34
|
+
skip: boolean,
|
|
35
|
+
): T | null {
|
|
36
|
+
return !skip && organizationId && emailId && email?.organizationId === organizationId && email.id === emailId ? email : null;
|
|
37
|
+
}
|
package/hooks/use-email-qry.ts
CHANGED
|
@@ -1,112 +1,82 @@
|
|
|
1
1
|
import { useQuery, useReactiveFragment } from '@jsb188/graphql/client';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
import { inboundEmailQry, inboundEmailsQry } from '../gql/queries/emailQueries.ts';
|
|
2
|
+
import type { EmailMessageGQL, EmailMessagesFilterInput, EmailMessagesSortEnum } from '@jsb188/mday/types/email.d.ts';
|
|
3
|
+
import { emailMessageQry, emailMessagesQry } from '../gql/queries/emailQueries.ts';
|
|
5
4
|
import type { PaginationArgs, UseQueryParams } from '../types.d.ts';
|
|
5
|
+
import { getScopedEmailRecord, normalizeEmailMessagesFilter } from './use-email-qry.helpers.ts';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Constants
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Keep inbound email list filters aligned with the GraphQL input shape.
|
|
15
|
-
*/
|
|
16
|
-
function normalizeInboundEmailsFilter(filter?: {
|
|
17
|
-
startDate?: string | null;
|
|
18
|
-
endDate?: string | null;
|
|
19
|
-
query?: string | null;
|
|
20
|
-
statuses?: string[] | null;
|
|
21
|
-
} | null) {
|
|
22
|
-
return filter
|
|
23
|
-
? {
|
|
24
|
-
startDate: filter.startDate || null,
|
|
25
|
-
endDate: filter.endDate || null,
|
|
26
|
-
query: filter.query || null,
|
|
27
|
-
statuses: filter.statuses || null,
|
|
28
|
-
}
|
|
29
|
-
: null;
|
|
30
|
-
}
|
|
11
|
+
const EMAIL_MESSAGES_LIST_LIMIT = 250;
|
|
31
12
|
|
|
32
13
|
/*
|
|
33
|
-
* Fetch one inbound email.
|
|
14
|
+
* Fetch one inbound or outbound email message.
|
|
34
15
|
*/
|
|
35
16
|
|
|
36
|
-
export function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
export function useEmailMessage(
|
|
18
|
+
variables: {
|
|
19
|
+
organizationId?: string | null;
|
|
20
|
+
emailMessageId?: string | null;
|
|
21
|
+
},
|
|
22
|
+
params: UseQueryParams = {},
|
|
42
23
|
) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
24
|
+
const skip = !variables.organizationId || !variables.emailMessageId || !!params.skip;
|
|
25
|
+
const cachedEmailMessage = useReactiveEmailMessageFragment(variables.emailMessageId || '', null);
|
|
26
|
+
// Keep the query active so list-row fragments cannot hide the detail fields.
|
|
27
|
+
const { data, ...rest } = useQuery(emailMessageQry, {
|
|
28
|
+
...params,
|
|
29
|
+
variables,
|
|
30
|
+
skip,
|
|
31
|
+
});
|
|
32
|
+
const currentData = rest.queryKey === `#${rest.queryName}:${rest.variablesKey}` ? data : null;
|
|
33
|
+
const emailMessage =
|
|
34
|
+
currentData?.emailMessage === null
|
|
35
|
+
? null
|
|
36
|
+
: getScopedEmailRecord<EmailMessageGQL>(currentData?.emailMessage, variables.organizationId, variables.emailMessageId, skip) ||
|
|
37
|
+
getScopedEmailRecord<EmailMessageGQL>(cachedEmailMessage, variables.organizationId, variables.emailMessageId, skip);
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
return {
|
|
40
|
+
emailMessage,
|
|
41
|
+
initialLoading: !skip && !emailMessage && !rest.error && currentData?.emailMessage === undefined,
|
|
42
|
+
...rest,
|
|
43
|
+
};
|
|
63
44
|
}
|
|
64
45
|
|
|
65
46
|
/**
|
|
66
|
-
* Fetch inbound
|
|
47
|
+
* Fetch inbound and outbound email messages as one list.
|
|
67
48
|
*/
|
|
68
49
|
|
|
69
|
-
export function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
statuses?: string[] | null;
|
|
77
|
-
} | null;
|
|
78
|
-
sort?: InboundEmailsSortEnum | null;
|
|
79
|
-
},
|
|
80
|
-
params: UseQueryParams = {},
|
|
50
|
+
export function useEmailMessages(
|
|
51
|
+
variables: PaginationArgs & {
|
|
52
|
+
organizationId?: string | null;
|
|
53
|
+
filter?: EmailMessagesFilterInput | null;
|
|
54
|
+
sort?: EmailMessagesSortEnum | null;
|
|
55
|
+
},
|
|
56
|
+
params: UseQueryParams = {},
|
|
81
57
|
) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
58
|
+
const { data, ...rest } = useQuery(emailMessagesQry, {
|
|
59
|
+
...params,
|
|
60
|
+
variables: {
|
|
61
|
+
...variables,
|
|
62
|
+
filter: normalizeEmailMessagesFilter(variables.filter),
|
|
63
|
+
cursor: variables.cursor ?? null,
|
|
64
|
+
after: variables.after ?? true,
|
|
65
|
+
limit: variables.limit ?? EMAIL_MESSAGES_LIST_LIMIT,
|
|
66
|
+
},
|
|
67
|
+
skip: !variables.organizationId || params.skip,
|
|
68
|
+
});
|
|
93
69
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
70
|
+
return {
|
|
71
|
+
emailMessages: data?.emailMessages,
|
|
72
|
+
...rest,
|
|
73
|
+
};
|
|
98
74
|
}
|
|
99
75
|
|
|
100
76
|
/**
|
|
101
|
-
* Get reactive
|
|
77
|
+
* Get reactive email message fragment.
|
|
102
78
|
*/
|
|
103
79
|
|
|
104
|
-
export function
|
|
105
|
-
|
|
106
|
-
currentData,
|
|
107
|
-
[
|
|
108
|
-
`$inboundEmailFragment:${inboundEmailId}`,
|
|
109
|
-
],
|
|
110
|
-
queryCount,
|
|
111
|
-
);
|
|
80
|
+
export function useReactiveEmailMessageFragment(emailMessageId: string, currentData?: any, queryCount?: number) {
|
|
81
|
+
return useReactiveFragment(currentData, [`$emailMessageFragment:${emailMessageId}`], queryCount);
|
|
112
82
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EmailCampaignReplyReportGQL } from '@jsb188/mday/types/emailReplyReport.d.ts';
|
|
2
|
+
import { useQuery } from '../client/index.ts';
|
|
3
|
+
import { emailCampaignReplyReportQry } from '../gql/queries/emailReplyReportQueries.ts';
|
|
4
|
+
import type { UseQueryParams } from '../types.d.ts';
|
|
5
|
+
import { getCampaignQueryData } from './use-campaign-qry.helpers.ts';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Read one complete campaign report into mounted query state, hiding retained
|
|
9
|
+
* output after scope changes or read errors. RESET_ONLY preserves the displayed
|
|
10
|
+
* snapshot until the ordinary query refresh action is acknowledged.
|
|
11
|
+
*/
|
|
12
|
+
export function useEmailCampaignReplyReport(
|
|
13
|
+
variables: { organizationId?: string | null; campaignId?: string | null },
|
|
14
|
+
params: UseQueryParams = {},
|
|
15
|
+
) {
|
|
16
|
+
const skipped = !variables.organizationId || !variables.campaignId || !!params.skip;
|
|
17
|
+
const { data, ...rest } = useQuery(emailCampaignReplyReportQry, {
|
|
18
|
+
...params,
|
|
19
|
+
variables,
|
|
20
|
+
skip: skipped,
|
|
21
|
+
});
|
|
22
|
+
const currentData = getCampaignQueryData({ data, ...rest }, skipped || !!rest.error);
|
|
23
|
+
return {
|
|
24
|
+
...rest,
|
|
25
|
+
report: (currentData?.emailCampaignReplyReport ?? null) as EmailCampaignReplyReportGQL | null,
|
|
26
|
+
};
|
|
27
|
+
}
|