@jsb188/graphql 1.1.11 → 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 +58 -24
- 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 +370 -42
- package/cache/index.ts +326 -799
- package/cache/optimistic-ui-runtime.ts +46 -0
- package/cache/optimistic-ui.ts +401 -0
- package/cache/persist.ts +98 -19
- package/cache/store.ts +22 -64
- package/cache/value.helpers.ts +17 -0
- package/{drafts/store.ts → client/draft-persistence-indexed-db.ts} +19 -3
- package/{drafts/index.ts → client/draft-persistence.ts} +5 -2
- package/client/index.ts +3 -2
- package/client/request.helpers.ts +14 -0
- package/client/request.ts +130 -215
- package/deno.lock +17 -0
- package/deno.test.json +2 -0
- package/gql/fragments/agentMemoryFragments.ts +5 -1
- package/gql/fragments/agentNoteFragments.ts +150 -0
- package/gql/fragments/aiChatFragments.ts +36 -10
- package/gql/fragments/audienceFragments.ts +141 -0
- package/gql/fragments/campaignFragments.ts +415 -126
- package/gql/fragments/dataTableFragments.ts +48 -80
- package/gql/fragments/emailFragments.ts +28 -23
- package/gql/fragments/fieldDocFragments.ts +222 -40
- package/gql/fragments/inboundContactFragments.ts +2 -0
- package/gql/fragments/logFragments.ts +93 -2
- package/gql/fragments/organizationFragments.ts +10 -0
- package/gql/fragments/qrCodeFragments.ts +29 -0
- package/gql/fragments/scheduleFragments.ts +652 -140
- package/gql/fragments/sheetFragments.ts +84 -373
- package/gql/fragments/storageFragments.ts +25 -1
- package/gql/fragments/workflowFragments.ts +13 -1
- package/gql/mutations/agentMemoryMutations.ts +32 -0
- package/gql/mutations/agentNoteMutations.ts +62 -0
- package/gql/mutations/aiChatMutations.ts +36 -4
- package/gql/mutations/audienceMutations.ts +71 -0
- package/gql/mutations/authMutations.ts +45 -1
- package/gql/mutations/billingMutations.ts +24 -0
- package/gql/mutations/campaignMutations.ts +170 -127
- package/gql/mutations/contactMutations.ts +23 -0
- package/gql/mutations/dataTableMutations.ts +18 -75
- package/gql/mutations/fieldDocMutations.ts +162 -13
- package/gql/mutations/index.ts +8 -5
- package/gql/mutations/organizationMutations.ts +6 -0
- package/gql/mutations/qrCodeMutations.ts +20 -0
- package/gql/mutations/scheduleMutations.ts +1052 -354
- package/gql/mutations/sheetMutations.ts +62 -118
- package/gql/mutations/storageMutations.ts +0 -1
- package/gql/mutations/workflowMutations.ts +18 -0
- package/gql/queries/agentMemoryQueries.ts +6 -0
- package/gql/queries/agentNoteQueries.ts +89 -0
- package/gql/queries/aiChatQueries.ts +56 -4
- package/gql/queries/audienceQueries.ts +128 -0
- package/gql/queries/authQueries.ts +6 -0
- package/gql/queries/billingQueries.ts +95 -6
- package/gql/queries/campaignQueries.ts +132 -23
- package/gql/queries/dataTableQueries.ts +24 -65
- package/gql/queries/emailQueries.ts +18 -61
- package/gql/queries/emailReplyReportQueries.ts +76 -0
- package/gql/queries/fieldDocQueries.ts +100 -92
- package/gql/queries/inboundContactQueries.ts +4 -0
- package/gql/queries/index.ts +3 -1
- package/gql/queries/logQueries.ts +62 -7
- package/gql/queries/organizationQueries.ts +13 -0
- package/gql/queries/qrCodeQueries.ts +20 -0
- package/gql/queries/scheduleQueries.ts +633 -257
- package/gql/queries/sheetQueries.ts +59 -152
- package/gql/queries/workflowQueries.ts +10 -4
- package/hooks/index.helpers.test.ts +50 -0
- package/hooks/index.helpers.ts +52 -0
- package/hooks/index.ts +863 -685
- package/hooks/use-agentMemory-mtn.ts +29 -31
- package/hooks/use-agentMemory-qry.ts +15 -3
- 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 +96 -112
- 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 +229 -383
- package/hooks/use-aiChat-stream-mtn.ts +14 -0
- 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 +30 -1
- 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 +224 -165
- package/hooks/use-campaign-qry.helpers.ts +40 -0
- package/hooks/use-campaign-qry.ts +631 -54
- package/hooks/use-dataTable-mtn.ts +23 -115
- package/hooks/use-dataTable-qry.ts +66 -916
- package/hooks/use-email-qry.helpers.ts +37 -0
- package/hooks/use-email-qry.ts +33 -178
- package/hooks/use-emailCampaignReplyReport-qry.ts +27 -0
- package/hooks/use-fieldDoc-mtn.ts +244 -32
- 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 +134 -102
- package/hooks/use-inboundContact-qry.ts +7 -9
- package/hooks/use-log-mtn.ts +25 -12
- package/hooks/use-log-qry.ts +99 -46
- package/hooks/use-organization-qry.ts +16 -60
- 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 +506 -333
- package/hooks/use-schedule-qry.ts +682 -101
- package/hooks/use-schedule-reactive.ts +486 -0
- package/hooks/use-sheet-mtn.ts +91 -199
- package/hooks/use-sheet-qry.ts +84 -238
- package/hooks/use-storage-qry.ts +84 -61
- package/hooks/use-workflow-mtn.ts +39 -22
- package/hooks/use-workflow-qry.ts +40 -61
- 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/{client → libs}/request-managed-session.test.ts +1 -1
- 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/loaders/campaign.test.ts +186 -0
- package/loaders/campaign.ts +56 -83
- package/loaders/emailPreference.ts +75 -0
- package/loaders/rest.ts +12 -0
- package/package.json +42 -17
- package/schedule.d.ts +1790 -0
- package/sse.helpers.ts +19 -0
- package/sse.ts +26 -115
- package/tests/agent-note-detail-cache.test.ts +120 -0
- package/tests/agent-note-search.test.ts +444 -0
- package/types.d.ts +46 -25
- package/client/data-table-realtime-subscriptions.test.ts +0 -740
- package/client/data-table-realtime-subscriptions.ts +0 -955
- package/client/data-table-realtime.test.ts +0 -792
- package/client/data-table-realtime.ts +0 -1218
- package/client/fragment-realtime-sequence.ts +0 -52
- package/client/open-sheet.ts +0 -137
- package/client/request-no-store.test.ts +0 -157
- package/gql/fragments/agentDocFragments.ts +0 -46
- package/gql/fragments/billingFragments.ts +0 -14
- package/gql/mutations/agentDocMutations.ts +0 -177
- package/gql/queries/agentDocQueries.ts +0 -120
- package/hooks/use-agentDoc-mtn.ts +0 -285
- package/hooks/use-agentDoc-qry.ts +0 -208
- /package/{client → libs}/sse-ticket.test.ts +0 -0
package/hooks/use-auth-mtn.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from '@jsb188/react/states';
|
|
10
10
|
import React, { useContext, useEffect, useState } from 'react';
|
|
11
11
|
import {
|
|
12
|
+
authenticateAsAgentMtn,
|
|
12
13
|
changeAccountPasswordMtn,
|
|
13
14
|
checkUsernameOrEmailMtn,
|
|
14
15
|
confirmPasswordMtn,
|
|
@@ -158,7 +159,7 @@ export function useChangeAccountPassword(
|
|
|
158
159
|
openModalPopUp?.({
|
|
159
160
|
name: 'password_changed',
|
|
160
161
|
props: {
|
|
161
|
-
title: i18n.t('
|
|
162
|
+
title: i18n.t('c.success'),
|
|
162
163
|
message: i18n.t('auth.password_changed_msg'),
|
|
163
164
|
iconName: 'lock-password-filled',
|
|
164
165
|
},
|
|
@@ -320,6 +321,34 @@ export function useConfirmPhoneVerificationCode(
|
|
|
320
321
|
};
|
|
321
322
|
}
|
|
322
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Development-only: sign in as any account without a password. The server
|
|
326
|
+
* mutation is inert outside a local development database.
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
export function useAuthenticateAsAgent(
|
|
330
|
+
params: UseMutationParams = {},
|
|
331
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
332
|
+
) {
|
|
333
|
+
const { onCompleted, onError } = params;
|
|
334
|
+
|
|
335
|
+
const [authenticateAsAgent, mtnValues, mtnHandlers] = useMutation(
|
|
336
|
+
authenticateAsAgentMtn,
|
|
337
|
+
{
|
|
338
|
+
checkMountedBeforeCallback: true,
|
|
339
|
+
openModalPopUp,
|
|
340
|
+
onCompleted,
|
|
341
|
+
onError,
|
|
342
|
+
},
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
return {
|
|
346
|
+
authenticateAsAgent,
|
|
347
|
+
...mtnValues,
|
|
348
|
+
...mtnHandlers,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
323
352
|
/**
|
|
324
353
|
* Sign in
|
|
325
354
|
*/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
+
import { startBillingSubscriptionMtn } from '../gql/mutations/billingMutations.ts';
|
|
3
|
+
import { useMutation } from './index.ts';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Start a self-serve subscription for an organization. The response carries a
|
|
7
|
+
* Stripe client secret, so it is never cached (no-store) and never retried.
|
|
8
|
+
* There is deliberately no openModalPopUp option: the payment pop-up renders
|
|
9
|
+
* errors inline, and opening another pop-up would replace it.
|
|
10
|
+
*/
|
|
11
|
+
export function useStartBillingSubscription(params: UseMutationParams = {}) {
|
|
12
|
+
const { onCompleted, onError } = params;
|
|
13
|
+
|
|
14
|
+
const [startBillingSubscription, mtnValues, mtnHandlers] = useMutation(
|
|
15
|
+
startBillingSubscriptionMtn,
|
|
16
|
+
{
|
|
17
|
+
cachePolicy: 'no-store',
|
|
18
|
+
retryCount: 0,
|
|
19
|
+
onCompleted: (data, error, variables) => {
|
|
20
|
+
onCompleted?.(data?.startBillingSubscription, error, variables);
|
|
21
|
+
},
|
|
22
|
+
onError,
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
startBillingSubscription,
|
|
28
|
+
...mtnValues,
|
|
29
|
+
...mtnHandlers,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useQuery } from '@jsb188/graphql/client';
|
|
2
|
+
import type { BillingAddressInputGQL } from '@jsb188/mday/types/billing.d.ts';
|
|
3
|
+
import {
|
|
4
|
+
billingClientConfigQry,
|
|
5
|
+
billingPlansQry,
|
|
6
|
+
billingPurchasePreviewQry,
|
|
7
|
+
organizationBillingQry,
|
|
8
|
+
} from '../gql/queries/billingQueries.ts';
|
|
9
|
+
import type { UseQueryParams } from '../types.d.ts';
|
|
10
|
+
|
|
11
|
+
export type BillingPurchasePreviewVariables = {
|
|
12
|
+
organizationId?: string | null;
|
|
13
|
+
priceId?: string | null;
|
|
14
|
+
address?: BillingAddressInputGQL | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Fetch the self-serve plans: Basic and Business with their public prices,
|
|
19
|
+
* and Enterprise as a contact-sales plan without prices.
|
|
20
|
+
*/
|
|
21
|
+
export function useBillingPlans(params: UseQueryParams = {}) {
|
|
22
|
+
// The public plan catalog can reuse fresh data; billing state still revalidates on entry.
|
|
23
|
+
const { data, ...rest } = useQuery(billingPlansQry, { revalidateOnMount: false, ...params });
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
billingPlans: data?.billingPlans,
|
|
27
|
+
...rest,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* Fetch the Stripe publishable key and payment method types the payment form
|
|
33
|
+
* must use. The server picks the key, so its mode always matches the secret key.
|
|
34
|
+
*/
|
|
35
|
+
export function useBillingClientConfig(params: UseQueryParams = {}) {
|
|
36
|
+
const { data, ...rest } = useQuery(billingClientConfigQry, params);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
billingClientConfig: data?.billingClientConfig,
|
|
40
|
+
...rest,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* Fetch an organization's billing status: access state, current subscription
|
|
46
|
+
* and recent invoices. Skipped until an organization id is known.
|
|
47
|
+
*/
|
|
48
|
+
export function useOrganizationBilling(organizationId: string | null | undefined, params: UseQueryParams = {}) {
|
|
49
|
+
const { data, ...rest } = useQuery(organizationBillingQry, {
|
|
50
|
+
...params,
|
|
51
|
+
variables: { organizationId },
|
|
52
|
+
skip: !organizationId || !!params.skip,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
organizationBilling: data?.organizationBilling,
|
|
57
|
+
...rest,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Preview the subtotal, tax and total of one plan price for a billing address.
|
|
63
|
+
* Skipped until the organization, price and address are all set.
|
|
64
|
+
*/
|
|
65
|
+
export function useBillingPurchasePreview(variables: BillingPurchasePreviewVariables, params: UseQueryParams = {}) {
|
|
66
|
+
const { data, ...rest } = useQuery(billingPurchasePreviewQry, {
|
|
67
|
+
...params,
|
|
68
|
+
variables,
|
|
69
|
+
skip: !variables.organizationId || !variables.priceId || !variables.address || !!params.skip,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
billingPurchasePreview: data?.billingPurchasePreview,
|
|
74
|
+
...rest,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
}
|