@go-avro/avro-js 0.0.47 → 0.0.48
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.
|
@@ -12,6 +12,13 @@ import type { BulkDeleteBillsResponse, BulkEmailBillsResponse } from '../client/
|
|
|
12
12
|
/** Callbacks for a tracked email request. */
|
|
13
13
|
export interface TrackEmailOptions {
|
|
14
14
|
emailType?: EmailType;
|
|
15
|
+
/**
|
|
16
|
+
* Pre-existing request_id to register. When omitted, a fresh uuid is
|
|
17
|
+
* generated. Pass this when the request_id was produced elsewhere
|
|
18
|
+
* (e.g. a bulk endpoint returns one in its synchronous response, or
|
|
19
|
+
* the caller wants to pre-generate it and ship it in the POST body).
|
|
20
|
+
*/
|
|
21
|
+
requestId?: string;
|
|
15
22
|
/** How long to wait before firing onTimeout (ms). Default 30 000. */
|
|
16
23
|
timeout?: number;
|
|
17
24
|
onSuccess?: (data: EmailSucceededPayload) => void;
|
|
@@ -1142,8 +1142,15 @@ export class AvroQueryClient {
|
|
|
1142
1142
|
*/
|
|
1143
1143
|
trackEmail(options = {}) {
|
|
1144
1144
|
this._initEmailListeners();
|
|
1145
|
-
const requestId = uuidv4();
|
|
1145
|
+
const requestId = options.requestId ?? uuidv4();
|
|
1146
1146
|
const { timeout = 30000 } = options;
|
|
1147
|
+
// If this request_id is already being tracked, replace the existing
|
|
1148
|
+
// entry so the latest caller's handlers win. (Callers that reuse a
|
|
1149
|
+
// request_id are explicitly opting in to this behaviour.)
|
|
1150
|
+
const existing = this._emailTracking.get(requestId);
|
|
1151
|
+
if (existing) {
|
|
1152
|
+
clearTimeout(existing.timerId);
|
|
1153
|
+
}
|
|
1147
1154
|
const timerId = setTimeout(() => {
|
|
1148
1155
|
this._emailTracking.delete(requestId);
|
|
1149
1156
|
options.onTimeout?.(requestId);
|
|
@@ -43,7 +43,10 @@ export interface UseEmailStatusOptions {
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export declare function useEmailStatus(options?: UseEmailStatusOptions): {
|
|
46
|
-
readonly trackEmail: (emailType?: EmailType
|
|
46
|
+
readonly trackEmail: (emailType?: EmailType, opts?: {
|
|
47
|
+
requestId?: string;
|
|
48
|
+
timeout?: number;
|
|
49
|
+
}) => string;
|
|
47
50
|
readonly pending: Map<string, {
|
|
48
51
|
emailType?: EmailType;
|
|
49
52
|
trackedAt: number;
|
|
@@ -36,10 +36,11 @@ export function useEmailStatus(options = {}) {
|
|
|
36
36
|
const [pending, setPending] = useState(new Map());
|
|
37
37
|
const [results, setResults] = useState(new Map());
|
|
38
38
|
/* ── trackEmail — delegates to client.trackEmail() ──────────────── */
|
|
39
|
-
const trackEmail = useCallback((emailType) => {
|
|
39
|
+
const trackEmail = useCallback((emailType, opts = {}) => {
|
|
40
40
|
const requestId = client.trackEmail({
|
|
41
41
|
emailType,
|
|
42
|
-
|
|
42
|
+
requestId: opts.requestId,
|
|
43
|
+
timeout: opts.timeout ?? timeout,
|
|
43
44
|
onSuccess: (data) => {
|
|
44
45
|
const result = {
|
|
45
46
|
requestId: data.request_id,
|