@sudobility/wildduck_client 1.0.19 → 1.0.20
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/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useWildduckAutoReply.d.ts +23 -0
- package/dist/hooks/useWildduckAutoReply.d.ts.map +1 -0
- package/dist/hooks/useWildduckAutoReply.js +130 -0
- package/dist/hooks/useWildduckAutoReply.js.map +1 -0
- package/package.json +1 -1
- package/dist/hooks/autoreply/index.d.ts +0 -4
- package/dist/hooks/autoreply/index.d.ts.map +0 -1
- package/dist/hooks/autoreply/index.js +0 -4
- package/dist/hooks/autoreply/index.js.map +0 -1
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.d.ts +0 -13
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.d.ts.map +0 -1
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.js +0 -46
- package/dist/hooks/autoreply/useWildduckDeleteAutoreply.js.map +0 -1
- package/dist/hooks/autoreply/useWildduckGetAutoreply.d.ts +0 -172
- package/dist/hooks/autoreply/useWildduckGetAutoreply.d.ts.map +0 -1
- package/dist/hooks/autoreply/useWildduckGetAutoreply.js +0 -39
- package/dist/hooks/autoreply/useWildduckGetAutoreply.js.map +0 -1
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.d.ts +0 -13
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.d.ts.map +0 -1
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.js +0 -46
- package/dist/hooks/autoreply/useWildduckUpdateAutoreply.js.map +0 -1
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from "./messages";
|
|
2
2
|
export * from "./users";
|
|
3
3
|
export * from "./addresses";
|
|
4
|
-
export * from "./autoreply";
|
|
5
4
|
export * from "./useWildduckHealth";
|
|
6
5
|
export * from "./useWildduckSettings";
|
|
7
6
|
export * from "./useWildduckMessages";
|
|
@@ -10,6 +9,7 @@ export * from "./useWildduckUsers";
|
|
|
10
9
|
export * from "./useWildduckFilters";
|
|
11
10
|
export * from "./useWildduckAddresses";
|
|
12
11
|
export * from "./useWildduckAuth";
|
|
12
|
+
export * from "./useWildduckAutoReply";
|
|
13
13
|
export { useWildduckUsersList, useWildduckUser, useWildduckUserAddresses, useWildduckUserMessages, useWildduckMessage, useWildduckUserFilters, useWildduckUserSettings, useWildduckUserMailboxes, useWildduckAuthStatus, } from "./useWildduckQueries";
|
|
14
14
|
export type { WildduckUserSettings, WildduckAuthStatusResponse, } from "./useWildduckQueries";
|
|
15
15
|
export { WildduckMockData } from "./mocks";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AASA,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AASA,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC;AAK5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AAKvC,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAO9B,YAAY,EACV,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAS9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from "./messages";
|
|
2
2
|
export * from "./users";
|
|
3
3
|
export * from "./addresses";
|
|
4
|
-
export * from "./autoreply";
|
|
5
4
|
export * from "./useWildduckHealth";
|
|
6
5
|
export * from "./useWildduckSettings";
|
|
7
6
|
export * from "./useWildduckMessages";
|
|
@@ -10,6 +9,7 @@ export * from "./useWildduckUsers";
|
|
|
10
9
|
export * from "./useWildduckFilters";
|
|
11
10
|
export * from "./useWildduckAddresses";
|
|
12
11
|
export * from "./useWildduckAuth";
|
|
12
|
+
export * from "./useWildduckAutoReply";
|
|
13
13
|
export { useWildduckUsersList, useWildduckUser, useWildduckUserAddresses, useWildduckUserMessages, useWildduckMessage, useWildduckUserFilters, useWildduckUserSettings, useWildduckUserMailboxes, useWildduckAuthStatus, } from "./useWildduckQueries";
|
|
14
14
|
export { WildduckMockData } from "./mocks";
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AASA,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AASA,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,aAAa,CAAC;AAK5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AAKvC,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAmB9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Optional } from "@sudobility/types";
|
|
2
|
+
import type { WildduckAuthResponse, WildduckAutoreplyRequest, WildduckAutoreplyResponse, WildduckConfig } from "@sudobility/types";
|
|
3
|
+
interface UseWildduckAutoReplyReturn {
|
|
4
|
+
autoreply: Optional<WildduckAutoreplyResponse>;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
error: Optional<string>;
|
|
7
|
+
getAutoreply: (userId: string) => Promise<WildduckAutoreplyResponse>;
|
|
8
|
+
refresh: () => Promise<void>;
|
|
9
|
+
updateAutoreply: (userId: string, params: WildduckAutoreplyRequest) => Promise<{
|
|
10
|
+
success: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
isUpdating: boolean;
|
|
13
|
+
updateError: Optional<Error>;
|
|
14
|
+
deleteAutoreply: (userId: string) => Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
isDeleting: boolean;
|
|
18
|
+
deleteError: Optional<Error>;
|
|
19
|
+
clearError: () => void;
|
|
20
|
+
}
|
|
21
|
+
declare const useWildduckAutoReply: (config: WildduckConfig, authData: Optional<WildduckAuthResponse>, _devMode?: boolean) => UseWildduckAutoReplyReturn;
|
|
22
|
+
export { useWildduckAutoReply, type UseWildduckAutoReplyReturn };
|
|
23
|
+
//# sourceMappingURL=useWildduckAutoReply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWildduckAutoReply.d.ts","sourceRoot":"","sources":["../../src/hooks/useWildduckAutoReply.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,UAAU,0BAA0B;IAElC,SAAS,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAGxB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACrE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAG7B,eAAe,EAAE,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,wBAAwB,KAC7B,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE7B,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACnE,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAG7B,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAWD,QAAA,MAAM,oBAAoB,GACxB,QAAQ,cAAc,EACtB,UAAU,QAAQ,CAAC,oBAAoB,CAAC,EACxC,WAAU,OAAe,KACxB,0BAyMF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
const useWildduckAutoReply = (config, authData, _devMode = false) => {
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
const userId = authData?.id || null;
|
|
7
|
+
const buildHeaders = () => {
|
|
8
|
+
const headers = {
|
|
9
|
+
"Content-Type": "application/json",
|
|
10
|
+
Accept: "application/json",
|
|
11
|
+
};
|
|
12
|
+
if (config.cloudflareWorkerUrl) {
|
|
13
|
+
headers["Authorization"] = `Bearer ${config.apiToken}`;
|
|
14
|
+
headers["X-App-Source"] = "0xmail-box";
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
headers["X-Access-Token"] = config.apiToken;
|
|
18
|
+
}
|
|
19
|
+
return headers;
|
|
20
|
+
};
|
|
21
|
+
const getAutoreply = useCallback(async (userId) => {
|
|
22
|
+
try {
|
|
23
|
+
const apiUrl = config.cloudflareWorkerUrl || config.backendUrl;
|
|
24
|
+
const headers = buildHeaders();
|
|
25
|
+
const endpoint = `/users/${userId}/autoreply`;
|
|
26
|
+
const response = await axios.get(`${apiUrl}${endpoint}`, { headers });
|
|
27
|
+
const autoreplyData = response.data;
|
|
28
|
+
queryClient.setQueryData(["wildduck-autoreply", userId], autoreplyData);
|
|
29
|
+
return autoreplyData;
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to get autoreply";
|
|
33
|
+
console.error("[useWildduckAutoReply] Failed to get autoreply:", errorMessage);
|
|
34
|
+
throw new Error(errorMessage);
|
|
35
|
+
}
|
|
36
|
+
}, [config.cloudflareWorkerUrl, config.backendUrl, buildHeaders, queryClient]);
|
|
37
|
+
const cachedAutoreply = userId
|
|
38
|
+
? queryClient.getQueryData([
|
|
39
|
+
"wildduck-autoreply",
|
|
40
|
+
userId,
|
|
41
|
+
]) || null
|
|
42
|
+
: null;
|
|
43
|
+
const updateMutation = useMutation({
|
|
44
|
+
mutationKey: [
|
|
45
|
+
"wildduck-update-autoreply",
|
|
46
|
+
config.cloudflareWorkerUrl || config.backendUrl,
|
|
47
|
+
],
|
|
48
|
+
mutationFn: async ({ userId, params, }) => {
|
|
49
|
+
try {
|
|
50
|
+
const apiUrl = config.cloudflareWorkerUrl || config.backendUrl;
|
|
51
|
+
const headers = buildHeaders();
|
|
52
|
+
const response = await axios.put(`${apiUrl}/users/${userId}/autoreply`, params, { headers });
|
|
53
|
+
return response.data;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to update autoreply";
|
|
57
|
+
console.error("[useWildduckAutoReply] Failed to update autoreply:", errorMessage);
|
|
58
|
+
throw new Error(errorMessage);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
onSuccess: async (_, variables) => {
|
|
62
|
+
await getAutoreply(variables.userId);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const deleteMutation = useMutation({
|
|
66
|
+
mutationKey: [
|
|
67
|
+
"wildduck-delete-autoreply",
|
|
68
|
+
config.cloudflareWorkerUrl || config.backendUrl,
|
|
69
|
+
],
|
|
70
|
+
mutationFn: async (userId) => {
|
|
71
|
+
try {
|
|
72
|
+
const apiUrl = config.cloudflareWorkerUrl || config.backendUrl;
|
|
73
|
+
const headers = buildHeaders();
|
|
74
|
+
const response = await axios.delete(`${apiUrl}/users/${userId}/autoreply`, { headers });
|
|
75
|
+
return response.data;
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to delete autoreply";
|
|
79
|
+
console.error("[useWildduckAutoReply] Failed to delete autoreply:", errorMessage);
|
|
80
|
+
throw new Error(errorMessage);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
onSuccess: async (_, userId) => {
|
|
84
|
+
await getAutoreply(userId);
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
const refresh = useCallback(async () => {
|
|
88
|
+
if (!userId) {
|
|
89
|
+
throw new Error("Cannot refresh: user not authenticated");
|
|
90
|
+
}
|
|
91
|
+
await getAutoreply(userId);
|
|
92
|
+
}, [userId, getAutoreply]);
|
|
93
|
+
const isLoading = updateMutation.isPending || deleteMutation.isPending;
|
|
94
|
+
const error = updateMutation.error?.message || deleteMutation.error?.message || null;
|
|
95
|
+
const updateAutoreply = useCallback(async (userId, params) => updateMutation.mutateAsync({ userId, params }), [updateMutation]);
|
|
96
|
+
const deleteAutoreply = useCallback(async (userId) => deleteMutation.mutateAsync(userId), [deleteMutation]);
|
|
97
|
+
const clearError = useCallback(() => {
|
|
98
|
+
updateMutation.reset();
|
|
99
|
+
deleteMutation.reset();
|
|
100
|
+
}, [updateMutation, deleteMutation]);
|
|
101
|
+
return useMemo(() => ({
|
|
102
|
+
autoreply: cachedAutoreply,
|
|
103
|
+
isLoading,
|
|
104
|
+
error,
|
|
105
|
+
getAutoreply,
|
|
106
|
+
refresh,
|
|
107
|
+
updateAutoreply,
|
|
108
|
+
isUpdating: updateMutation.isPending,
|
|
109
|
+
updateError: updateMutation.error,
|
|
110
|
+
deleteAutoreply,
|
|
111
|
+
isDeleting: deleteMutation.isPending,
|
|
112
|
+
deleteError: deleteMutation.error,
|
|
113
|
+
clearError,
|
|
114
|
+
}), [
|
|
115
|
+
cachedAutoreply,
|
|
116
|
+
isLoading,
|
|
117
|
+
error,
|
|
118
|
+
getAutoreply,
|
|
119
|
+
refresh,
|
|
120
|
+
updateAutoreply,
|
|
121
|
+
updateMutation.isPending,
|
|
122
|
+
updateMutation.error,
|
|
123
|
+
deleteAutoreply,
|
|
124
|
+
deleteMutation.isPending,
|
|
125
|
+
deleteMutation.error,
|
|
126
|
+
clearError,
|
|
127
|
+
]);
|
|
128
|
+
};
|
|
129
|
+
export { useWildduckAutoReply };
|
|
130
|
+
//# sourceMappingURL=useWildduckAutoReply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWildduckAutoReply.js","sourceRoot":"","sources":["../../src/hooks/useWildduck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AAW,EAAE,cAAc,CAAC,KAAK;QAGjC,UAAU;KACX,CAAC,EACF;QACE,eAAe;QACf,SAAS;QACT,KAAK;QACL,YAAY;QACZ,OAAO;QACP,eAAe;QACf,cAAc,CAAC,SAAS;QACxB,cAAc,CAAC,KAAK;QACpB,eAAe;QACf,cAAc,CAAC,SAAS;QACxB,cAAc,CAAC,KAAK;QACpB,UAAU;KACX,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAmC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/autoreply/index.ts"],"names":[],"mappings":"AAMA,cAAc,2BAA2B,CAAC;AAG1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/autoreply/index.ts"],"names":[],"mappings":"AAMA,cAAc,2BAA2B,CAAC;AAG1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Optional } from "@sudobility/types";
|
|
2
|
-
import { type NetworkClient } from "@sudobility/types";
|
|
3
|
-
import { type WildduckConfig } from "@sudobility/types";
|
|
4
|
-
import type { WildduckSuccessResponse, WildduckUserAuth } from "@sudobility/types";
|
|
5
|
-
interface UseWildduckDeleteAutoreplyReturn {
|
|
6
|
-
deleteAutoreply: (userAuth: WildduckUserAuth) => Promise<WildduckSuccessResponse>;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
error: Optional<Error>;
|
|
9
|
-
clearError: () => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const useWildduckDeleteAutoreply: (networkClient: NetworkClient, config: WildduckConfig, devMode?: boolean) => UseWildduckDeleteAutoreplyReturn;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=useWildduckDeleteAutoreply.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWildduckDeleteAutoreply.d.ts","sourceRoot":"","sources":["../../../src/hooks/autoreply/useWildduckDeleteAutoreply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,UAAU,gCAAgC;IACxC,eAAe,EAAE,CACf,QAAQ,EAAE,gBAAgB,KACvB,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAYD,eAAO,MAAM,0BAA0B,GACrC,eAAe,aAAa,EAC5B,QAAQ,cAAc,EACtB,UAAS,OAAe,KACvB,gCA+DF,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { WildduckAPI } from "../../network/wildduck-client";
|
|
3
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
export const useWildduckDeleteAutoreply = (networkClient, config, devMode = false) => {
|
|
5
|
-
const queryClient = useQueryClient();
|
|
6
|
-
const wildduckClient = useMemo(() => new WildduckAPI(networkClient, config), [networkClient, config]);
|
|
7
|
-
const deleteMutation = useMutation({
|
|
8
|
-
mutationKey: [
|
|
9
|
-
"wildduck-delete-autoreply",
|
|
10
|
-
config.cloudflareWorkerUrl || config.backendUrl,
|
|
11
|
-
],
|
|
12
|
-
mutationFn: async (userAuth) => {
|
|
13
|
-
try {
|
|
14
|
-
return await wildduckClient.deleteAutoreply(userAuth);
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
if (devMode) {
|
|
18
|
-
console.warn("[DevMode] deleteAutoreply failed, returning mock data:", err);
|
|
19
|
-
return { success: true };
|
|
20
|
-
}
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
onSuccess: (_, userAuth) => {
|
|
25
|
-
queryClient.invalidateQueries({
|
|
26
|
-
queryKey: ["wildduck-autoreply", userAuth.userId],
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
const deleteAutoreply = useCallback(async (userAuth) => {
|
|
31
|
-
return deleteMutation.mutateAsync(userAuth);
|
|
32
|
-
}, [deleteMutation]);
|
|
33
|
-
const clearError = useCallback(() => deleteMutation.reset(), [deleteMutation]);
|
|
34
|
-
return useMemo(() => ({
|
|
35
|
-
deleteAutoreply,
|
|
36
|
-
isLoading: deleteMutation.isPending,
|
|
37
|
-
error: deleteMutation.error,
|
|
38
|
-
clearError,
|
|
39
|
-
}), [
|
|
40
|
-
deleteAutoreply,
|
|
41
|
-
deleteMutation.isPending,
|
|
42
|
-
deleteMutation.error,
|
|
43
|
-
clearError,
|
|
44
|
-
]);
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=useWildduckDeleteAutoreply.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWildduckDeleteAutoreply.js","sourceRoot":"","sources":["../../../src/hooks/autoreply/useWildduckDeleteAutoreply.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAyBpE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,aAA4B,EAC5B,MAAsB,EACtB,UAAmB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,CAAC;QACL,eAAe;QACf,SAAS,EAAE,cAAc,CAAC,SAAS;QACnC,KAAK,EAAE,cAAc,CAAC,KAAK;QAC3B,UAAU;KACX,CAAC,EACF;QACE,eAAe;QACf,cAAc,CAAC,SAAS;QACxB,cAAc,CAAC,KAAK;QACpB,UAAU;KACX,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { type NetworkClient } from "@sudobility/types";
|
|
2
|
-
import { type WildduckConfig } from "@sudobility/types";
|
|
3
|
-
import type { WildduckAutoreplyResponse, WildduckUserAuth } from "@sudobility/types";
|
|
4
|
-
export interface UseWildduckGetAutoreplyParams {
|
|
5
|
-
userAuth?: WildduckUserAuth;
|
|
6
|
-
devMode?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const useWildduckGetAutoreply: (networkClient: NetworkClient, config: WildduckConfig, params?: UseWildduckGetAutoreplyParams) => {
|
|
9
|
-
data: WildduckAutoreplyResponse;
|
|
10
|
-
error: Error;
|
|
11
|
-
isError: true;
|
|
12
|
-
isPending: false;
|
|
13
|
-
isLoading: false;
|
|
14
|
-
isLoadingError: false;
|
|
15
|
-
isRefetchError: true;
|
|
16
|
-
isSuccess: false;
|
|
17
|
-
isPlaceholderData: false;
|
|
18
|
-
status: "error";
|
|
19
|
-
dataUpdatedAt: number;
|
|
20
|
-
errorUpdatedAt: number;
|
|
21
|
-
failureCount: number;
|
|
22
|
-
failureReason: Error | null;
|
|
23
|
-
errorUpdateCount: number;
|
|
24
|
-
isFetched: boolean;
|
|
25
|
-
isFetchedAfterMount: boolean;
|
|
26
|
-
isFetching: boolean;
|
|
27
|
-
isInitialLoading: boolean;
|
|
28
|
-
isPaused: boolean;
|
|
29
|
-
isRefetching: boolean;
|
|
30
|
-
isStale: boolean;
|
|
31
|
-
isEnabled: boolean;
|
|
32
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WildduckAutoreplyResponse, Error>>;
|
|
33
|
-
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
34
|
-
promise: Promise<WildduckAutoreplyResponse>;
|
|
35
|
-
} | {
|
|
36
|
-
data: WildduckAutoreplyResponse;
|
|
37
|
-
error: null;
|
|
38
|
-
isError: false;
|
|
39
|
-
isPending: false;
|
|
40
|
-
isLoading: false;
|
|
41
|
-
isLoadingError: false;
|
|
42
|
-
isRefetchError: false;
|
|
43
|
-
isSuccess: true;
|
|
44
|
-
isPlaceholderData: false;
|
|
45
|
-
status: "success";
|
|
46
|
-
dataUpdatedAt: number;
|
|
47
|
-
errorUpdatedAt: number;
|
|
48
|
-
failureCount: number;
|
|
49
|
-
failureReason: Error | null;
|
|
50
|
-
errorUpdateCount: number;
|
|
51
|
-
isFetched: boolean;
|
|
52
|
-
isFetchedAfterMount: boolean;
|
|
53
|
-
isFetching: boolean;
|
|
54
|
-
isInitialLoading: boolean;
|
|
55
|
-
isPaused: boolean;
|
|
56
|
-
isRefetching: boolean;
|
|
57
|
-
isStale: boolean;
|
|
58
|
-
isEnabled: boolean;
|
|
59
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WildduckAutoreplyResponse, Error>>;
|
|
60
|
-
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
61
|
-
promise: Promise<WildduckAutoreplyResponse>;
|
|
62
|
-
} | {
|
|
63
|
-
data: undefined;
|
|
64
|
-
error: Error;
|
|
65
|
-
isError: true;
|
|
66
|
-
isPending: false;
|
|
67
|
-
isLoading: false;
|
|
68
|
-
isLoadingError: true;
|
|
69
|
-
isRefetchError: false;
|
|
70
|
-
isSuccess: false;
|
|
71
|
-
isPlaceholderData: false;
|
|
72
|
-
status: "error";
|
|
73
|
-
dataUpdatedAt: number;
|
|
74
|
-
errorUpdatedAt: number;
|
|
75
|
-
failureCount: number;
|
|
76
|
-
failureReason: Error | null;
|
|
77
|
-
errorUpdateCount: number;
|
|
78
|
-
isFetched: boolean;
|
|
79
|
-
isFetchedAfterMount: boolean;
|
|
80
|
-
isFetching: boolean;
|
|
81
|
-
isInitialLoading: boolean;
|
|
82
|
-
isPaused: boolean;
|
|
83
|
-
isRefetching: boolean;
|
|
84
|
-
isStale: boolean;
|
|
85
|
-
isEnabled: boolean;
|
|
86
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WildduckAutoreplyResponse, Error>>;
|
|
87
|
-
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
88
|
-
promise: Promise<WildduckAutoreplyResponse>;
|
|
89
|
-
} | {
|
|
90
|
-
data: undefined;
|
|
91
|
-
error: null;
|
|
92
|
-
isError: false;
|
|
93
|
-
isPending: true;
|
|
94
|
-
isLoading: true;
|
|
95
|
-
isLoadingError: false;
|
|
96
|
-
isRefetchError: false;
|
|
97
|
-
isSuccess: false;
|
|
98
|
-
isPlaceholderData: false;
|
|
99
|
-
status: "pending";
|
|
100
|
-
dataUpdatedAt: number;
|
|
101
|
-
errorUpdatedAt: number;
|
|
102
|
-
failureCount: number;
|
|
103
|
-
failureReason: Error | null;
|
|
104
|
-
errorUpdateCount: number;
|
|
105
|
-
isFetched: boolean;
|
|
106
|
-
isFetchedAfterMount: boolean;
|
|
107
|
-
isFetching: boolean;
|
|
108
|
-
isInitialLoading: boolean;
|
|
109
|
-
isPaused: boolean;
|
|
110
|
-
isRefetching: boolean;
|
|
111
|
-
isStale: boolean;
|
|
112
|
-
isEnabled: boolean;
|
|
113
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WildduckAutoreplyResponse, Error>>;
|
|
114
|
-
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
115
|
-
promise: Promise<WildduckAutoreplyResponse>;
|
|
116
|
-
} | {
|
|
117
|
-
data: undefined;
|
|
118
|
-
error: null;
|
|
119
|
-
isError: false;
|
|
120
|
-
isPending: true;
|
|
121
|
-
isLoadingError: false;
|
|
122
|
-
isRefetchError: false;
|
|
123
|
-
isSuccess: false;
|
|
124
|
-
isPlaceholderData: false;
|
|
125
|
-
status: "pending";
|
|
126
|
-
dataUpdatedAt: number;
|
|
127
|
-
errorUpdatedAt: number;
|
|
128
|
-
failureCount: number;
|
|
129
|
-
failureReason: Error | null;
|
|
130
|
-
errorUpdateCount: number;
|
|
131
|
-
isFetched: boolean;
|
|
132
|
-
isFetchedAfterMount: boolean;
|
|
133
|
-
isFetching: boolean;
|
|
134
|
-
isLoading: boolean;
|
|
135
|
-
isInitialLoading: boolean;
|
|
136
|
-
isPaused: boolean;
|
|
137
|
-
isRefetching: boolean;
|
|
138
|
-
isStale: boolean;
|
|
139
|
-
isEnabled: boolean;
|
|
140
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WildduckAutoreplyResponse, Error>>;
|
|
141
|
-
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
142
|
-
promise: Promise<WildduckAutoreplyResponse>;
|
|
143
|
-
} | {
|
|
144
|
-
data: WildduckAutoreplyResponse;
|
|
145
|
-
isError: false;
|
|
146
|
-
error: null;
|
|
147
|
-
isPending: false;
|
|
148
|
-
isLoading: false;
|
|
149
|
-
isLoadingError: false;
|
|
150
|
-
isRefetchError: false;
|
|
151
|
-
isSuccess: true;
|
|
152
|
-
isPlaceholderData: true;
|
|
153
|
-
status: "success";
|
|
154
|
-
dataUpdatedAt: number;
|
|
155
|
-
errorUpdatedAt: number;
|
|
156
|
-
failureCount: number;
|
|
157
|
-
failureReason: Error | null;
|
|
158
|
-
errorUpdateCount: number;
|
|
159
|
-
isFetched: boolean;
|
|
160
|
-
isFetchedAfterMount: boolean;
|
|
161
|
-
isFetching: boolean;
|
|
162
|
-
isInitialLoading: boolean;
|
|
163
|
-
isPaused: boolean;
|
|
164
|
-
isRefetching: boolean;
|
|
165
|
-
isStale: boolean;
|
|
166
|
-
isEnabled: boolean;
|
|
167
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<WildduckAutoreplyResponse, Error>>;
|
|
168
|
-
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
169
|
-
promise: Promise<WildduckAutoreplyResponse>;
|
|
170
|
-
};
|
|
171
|
-
export type UseWildduckGetAutoreplyReturn = ReturnType<typeof useWildduckGetAutoreply>;
|
|
172
|
-
//# sourceMappingURL=useWildduckGetAutoreply.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWildduckGetAutoreply.d.ts","sourceRoot":"","sources":["../../../src/hooks/autoreply/useWildduckGetAutoreply.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EACV,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAWD,eAAO,MAAM,uBAAuB,GAClC,eAAe,aAAa,EAC5B,QAAQ,cAAc,EACtB,SAAQ,6BAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+C3C,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,uBAAuB,CAC/B,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { WildduckAPI } from "../../network/wildduck-client";
|
|
4
|
-
export const useWildduckGetAutoreply = (networkClient, config, params = {}) => {
|
|
5
|
-
const { userAuth, devMode = false } = params;
|
|
6
|
-
const api = useMemo(() => new WildduckAPI(networkClient, config), [networkClient, config]);
|
|
7
|
-
const queryFn = useCallback(async () => {
|
|
8
|
-
if (!userAuth)
|
|
9
|
-
throw new Error("userAuth is required");
|
|
10
|
-
try {
|
|
11
|
-
return await api.getAutoreply(userAuth);
|
|
12
|
-
}
|
|
13
|
-
catch (err) {
|
|
14
|
-
if (devMode) {
|
|
15
|
-
console.warn("[DevMode] getAutoreply failed, returning mock data:", err);
|
|
16
|
-
return {
|
|
17
|
-
success: true,
|
|
18
|
-
status: false,
|
|
19
|
-
name: "",
|
|
20
|
-
subject: "",
|
|
21
|
-
text: "",
|
|
22
|
-
html: "",
|
|
23
|
-
start: false,
|
|
24
|
-
end: false,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
29
|
-
}, [userAuth, api, devMode]);
|
|
30
|
-
const query = useQuery({
|
|
31
|
-
queryKey: ["wildduck-autoreply", userAuth?.userId],
|
|
32
|
-
queryFn,
|
|
33
|
-
enabled: !!userAuth,
|
|
34
|
-
});
|
|
35
|
-
return useMemo(() => ({
|
|
36
|
-
...query,
|
|
37
|
-
}), [query]);
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=useWildduckGetAutoreply.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWildduckGetAutoreply.js","sourceRoot":"","sources":["../../../src/hooks/autoreply/useWildduckGetAutoreply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAsB5D,MAAM,CAAC,MAAM,uBAAuB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AAC,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Optional } from "@sudobility/types";
|
|
2
|
-
import { type NetworkClient } from "@sudobility/types";
|
|
3
|
-
import { type WildduckConfig } from "@sudobility/types";
|
|
4
|
-
import type { WildduckAutoreplyRequest, WildduckSuccessResponse, WildduckUserAuth } from "@sudobility/types";
|
|
5
|
-
interface UseWildduckUpdateAutoreplyReturn {
|
|
6
|
-
updateAutoreply: (userAuth: WildduckUserAuth, params: WildduckAutoreplyRequest) => Promise<WildduckSuccessResponse>;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
error: Optional<Error>;
|
|
9
|
-
clearError: () => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const useWildduckUpdateAutoreply: (networkClient: NetworkClient, config: WildduckConfig, devMode?: boolean) => UseWildduckUpdateAutoreplyReturn;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=useWildduckUpdateAutoreply.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWildduckUpdateAutoreply.d.ts","sourceRoot":"","sources":["../../../src/hooks/autoreply/useWildduckUpdateAutoreply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,UAAU,gCAAgC;IACxC,eAAe,EAAE,CACf,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,wBAAwB,KAC7B,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAYD,eAAO,MAAM,0BAA0B,GACrC,eAAe,aAAa,EAC5B,QAAQ,cAAc,EACtB,UAAS,OAAe,KACvB,gCAmEF,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { WildduckAPI } from "../../network/wildduck-client";
|
|
3
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
export const useWildduckUpdateAutoreply = (networkClient, config, devMode = false) => {
|
|
5
|
-
const queryClient = useQueryClient();
|
|
6
|
-
const wildduckClient = useMemo(() => new WildduckAPI(networkClient, config), [networkClient, config]);
|
|
7
|
-
const updateMutation = useMutation({
|
|
8
|
-
mutationKey: [
|
|
9
|
-
"wildduck-update-autoreply",
|
|
10
|
-
config.cloudflareWorkerUrl || config.backendUrl,
|
|
11
|
-
],
|
|
12
|
-
mutationFn: async ({ userAuth, params, }) => {
|
|
13
|
-
try {
|
|
14
|
-
return await wildduckClient.updateAutoreply(userAuth, params);
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
if (devMode) {
|
|
18
|
-
console.warn("[DevMode] updateAutoreply failed, returning mock data:", err);
|
|
19
|
-
return { success: true };
|
|
20
|
-
}
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
onSuccess: (_, variables) => {
|
|
25
|
-
queryClient.invalidateQueries({
|
|
26
|
-
queryKey: ["wildduck-autoreply", variables.userAuth.userId],
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
const updateAutoreply = useCallback(async (userAuth, params) => {
|
|
31
|
-
return updateMutation.mutateAsync({ userAuth, params });
|
|
32
|
-
}, [updateMutation]);
|
|
33
|
-
const clearError = useCallback(() => updateMutation.reset(), [updateMutation]);
|
|
34
|
-
return useMemo(() => ({
|
|
35
|
-
updateAutoreply,
|
|
36
|
-
isLoading: updateMutation.isPending,
|
|
37
|
-
error: updateMutation.error,
|
|
38
|
-
clearError,
|
|
39
|
-
}), [
|
|
40
|
-
updateAutoreply,
|
|
41
|
-
updateMutation.isPending,
|
|
42
|
-
updateMutation.error,
|
|
43
|
-
clearError,
|
|
44
|
-
]);
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=useWildduckUpdateAutoreply.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWildduckUpdateAutoreply.js","sourceRoot":"","sources":["../../../src/hooks/autoreply/useWildduckUpdateAutoreply.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA2BpE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,aAA4B,EAC5B,MAAsB,EACtB,UAAmB,KAAK,EACU,EAAE;IACpC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,MAAM,cAAc,GAAG,OAAO,CAC5B,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,EAC5C,CAAC,aAAa,EAAE,MAAM,CAAC,CACxB,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAAC;QACjC,WAAW,EAAE;YACX,2BAA2B;YAC3B,MAAM,CAAC,mBAAmB,IAAI,MAAM,CAAC,UAAU;SAChD;QACD,UAAU,EAAE,KAAK,EAAE,EACjB,QAAQ,EACR,MAAM,GAIP,EAAoC,EAAE;YACrC,IAAI,CAAC;gBACH,OAAO,MAAM,cAAc,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAChE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,CAAC,IAAI,CACV,wDAA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