@mailoo/forms 0.0.0-stage → 1.32.2
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/LICENSE +16 -0
- package/README.md +205 -2
- package/dist/chunk-4B377BWO.js +147 -0
- package/dist/chunk-4B377BWO.js.map +1 -0
- package/dist/chunk-LD246ORB.js +86 -0
- package/dist/chunk-LD246ORB.js.map +1 -0
- package/dist/chunk-QBZAYHBD.js +36 -0
- package/dist/chunk-QBZAYHBD.js.map +1 -0
- package/dist/events/index.cjs +176 -0
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.d.cts +107 -0
- package/dist/events/index.d.ts +107 -0
- package/dist/events/index.js +17 -0
- package/dist/events/index.js.map +1 -0
- package/dist/hooks/index.cjs +301 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +130 -0
- package/dist/hooks/index.d.ts +130 -0
- package/dist/hooks/index.js +221 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/routes/index.cjs +544 -0
- package/dist/routes/index.cjs.map +1 -0
- package/dist/routes/index.d.cts +59 -0
- package/dist/routes/index.d.ts +59 -0
- package/dist/routes/index.js +351 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/server/index.cjs +270 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +44 -0
- package/dist/server/index.d.ts +44 -0
- package/dist/server/index.js +112 -0
- package/dist/server/index.js.map +1 -0
- package/dist/webhooks/index.cjs +111 -0
- package/dist/webhooks/index.cjs.map +1 -0
- package/dist/webhooks/index.d.cts +37 -0
- package/dist/webhooks/index.d.ts +37 -0
- package/dist/webhooks/index.js +9 -0
- package/dist/webhooks/index.js.map +1 -0
- package/package.json +77 -3
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/hooks/index.ts
|
|
22
|
+
var hooks_exports = {};
|
|
23
|
+
__export(hooks_exports, {
|
|
24
|
+
emitMailooLifecycleEvent: () => emitMailooLifecycleEvent,
|
|
25
|
+
fetchMailooLifecycleStatus: () => fetchMailooLifecycleStatus,
|
|
26
|
+
retryMailooLifecycleEvent: () => retryMailooLifecycleEvent,
|
|
27
|
+
useMailooFeedbackSubmit: () => useMailooFeedbackSubmit,
|
|
28
|
+
useMailooFormSubmit: () => useMailooFormSubmit,
|
|
29
|
+
useMailooLifecycleEvent: () => useMailooLifecycleEvent,
|
|
30
|
+
useMailooLifecycleRetry: () => useMailooLifecycleRetry,
|
|
31
|
+
useMailooLifecycleStatus: () => useMailooLifecycleStatus
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
|
|
36
|
+
// src/events/index.ts
|
|
37
|
+
var MAILOO_LIFECYCLE_EVENTS = {
|
|
38
|
+
USER_REGISTERED: "user.registered",
|
|
39
|
+
USER_ACTIVATED: "user.activated"
|
|
40
|
+
};
|
|
41
|
+
var MAILOO_LIFECYCLE_EVENT_NAMES = [
|
|
42
|
+
MAILOO_LIFECYCLE_EVENTS.USER_REGISTERED,
|
|
43
|
+
MAILOO_LIFECYCLE_EVENTS.USER_ACTIVATED
|
|
44
|
+
];
|
|
45
|
+
var EVENT_NAME_SET = new Set(MAILOO_LIFECYCLE_EVENT_NAMES);
|
|
46
|
+
var MAILOO_LIFECYCLE_ATTRIBUTE_KEYS = [
|
|
47
|
+
"plan",
|
|
48
|
+
"tier",
|
|
49
|
+
"country",
|
|
50
|
+
"signupChannel",
|
|
51
|
+
"referrer"
|
|
52
|
+
];
|
|
53
|
+
var ATTRIBUTE_KEY_SET = new Set(MAILOO_LIFECYCLE_ATTRIBUTE_KEYS);
|
|
54
|
+
function isPlainObject(v) {
|
|
55
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
56
|
+
}
|
|
57
|
+
function parseMailooLifecycleIngestData(data) {
|
|
58
|
+
if (!isPlainObject(data)) return null;
|
|
59
|
+
if (typeof data.eventId !== "string" || typeof data.contactId !== "string") {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
let send = null;
|
|
63
|
+
if (data.send === null) {
|
|
64
|
+
send = null;
|
|
65
|
+
} else if (isPlainObject(data.send) && typeof data.send.sendId === "string") {
|
|
66
|
+
send = {
|
|
67
|
+
sendId: data.send.sendId,
|
|
68
|
+
status: String(data.send.status ?? ""),
|
|
69
|
+
messageId: data.send.messageId === null || typeof data.send.messageId === "string" ? data.send.messageId : null,
|
|
70
|
+
trackingToken: String(data.send.trackingToken ?? ""),
|
|
71
|
+
campaignId: data.send.campaignId === null || typeof data.send.campaignId === "string" ? data.send.campaignId : null
|
|
72
|
+
};
|
|
73
|
+
} else {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
eventId: data.eventId,
|
|
78
|
+
contactId: data.contactId,
|
|
79
|
+
idempotentReplay: data.idempotentReplay === true,
|
|
80
|
+
processingStatus: String(data.processingStatus ?? ""),
|
|
81
|
+
skipReason: data.skipReason === null || typeof data.skipReason === "string" ? data.skipReason : null,
|
|
82
|
+
send
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/hooks/index.ts
|
|
87
|
+
async function resolveHeaders(getHeaders) {
|
|
88
|
+
if (!getHeaders) return {};
|
|
89
|
+
if (typeof getHeaders === "function") {
|
|
90
|
+
return await getHeaders() ?? {};
|
|
91
|
+
}
|
|
92
|
+
return getHeaders;
|
|
93
|
+
}
|
|
94
|
+
async function postJson(endpoint, body, getHeaders) {
|
|
95
|
+
try {
|
|
96
|
+
const extra = await resolveHeaders(getHeaders);
|
|
97
|
+
const res = await fetch(endpoint, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: { "Content-Type": "application/json", ...extra },
|
|
100
|
+
body: JSON.stringify(body)
|
|
101
|
+
});
|
|
102
|
+
const data = await res.json().catch(() => ({}));
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
return {
|
|
105
|
+
ok: false,
|
|
106
|
+
status: res.status,
|
|
107
|
+
message: typeof data.message === "string" ? data.message : typeof data.error === "string" ? data.error : "Submit failed"
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return { ok: true, status: res.status, data };
|
|
111
|
+
} catch {
|
|
112
|
+
return { ok: false, status: 0, message: "Network error" };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function getJson(endpoint, getHeaders) {
|
|
116
|
+
try {
|
|
117
|
+
const extra = await resolveHeaders(getHeaders);
|
|
118
|
+
const res = await fetch(endpoint, {
|
|
119
|
+
method: "GET",
|
|
120
|
+
headers: { ...extra }
|
|
121
|
+
});
|
|
122
|
+
const data = await res.json().catch(() => ({}));
|
|
123
|
+
if (!res.ok) {
|
|
124
|
+
return {
|
|
125
|
+
ok: false,
|
|
126
|
+
status: res.status,
|
|
127
|
+
message: typeof data.message === "string" ? data.message : typeof data.error === "string" ? data.error : "Request failed"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return { ok: true, status: res.status, data };
|
|
131
|
+
} catch {
|
|
132
|
+
return { ok: false, status: 0, message: "Network error" };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function toLifecycleEmitResult(result) {
|
|
136
|
+
if (!result.ok) {
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
status: result.status,
|
|
140
|
+
message: result.message
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const envelope = result.data;
|
|
144
|
+
const dataObj = envelope && typeof envelope === "object" && !Array.isArray(envelope) && "data" in envelope ? envelope.data : envelope;
|
|
145
|
+
const parsed = parseMailooLifecycleIngestData(dataObj);
|
|
146
|
+
if (!parsed) {
|
|
147
|
+
return {
|
|
148
|
+
ok: false,
|
|
149
|
+
status: result.status,
|
|
150
|
+
message: "Unexpected lifecycle ingest response shape",
|
|
151
|
+
data: result.data
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return { ok: true, status: result.status, data: parsed };
|
|
155
|
+
}
|
|
156
|
+
function useMailooFormSubmit(options) {
|
|
157
|
+
const endpoint = options?.endpoint ?? "/api/v1/webhooks/forms/submit";
|
|
158
|
+
const getHeaders = options?.getHeaders;
|
|
159
|
+
const [pending, setPending] = (0, import_react.useState)(false);
|
|
160
|
+
const submit = (0, import_react.useCallback)(
|
|
161
|
+
async (body) => {
|
|
162
|
+
setPending(true);
|
|
163
|
+
try {
|
|
164
|
+
return await postJson(endpoint, body, getHeaders);
|
|
165
|
+
} finally {
|
|
166
|
+
setPending(false);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
[endpoint, getHeaders]
|
|
170
|
+
);
|
|
171
|
+
return { submit, pending };
|
|
172
|
+
}
|
|
173
|
+
function useMailooFeedbackSubmit(options) {
|
|
174
|
+
const endpoint = options?.endpoint ?? "/api/v1/webhooks/feedback/submit";
|
|
175
|
+
const getHeaders = options?.getHeaders;
|
|
176
|
+
const [pending, setPending] = (0, import_react.useState)(false);
|
|
177
|
+
const submit = (0, import_react.useCallback)(
|
|
178
|
+
async (body) => {
|
|
179
|
+
setPending(true);
|
|
180
|
+
try {
|
|
181
|
+
return await postJson(endpoint, body, getHeaders);
|
|
182
|
+
} finally {
|
|
183
|
+
setPending(false);
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
[endpoint, getHeaders]
|
|
187
|
+
);
|
|
188
|
+
return { submit, pending };
|
|
189
|
+
}
|
|
190
|
+
async function emitMailooLifecycleEvent(body, options) {
|
|
191
|
+
const endpoint = options?.endpoint ?? "/api/v1/webhooks/lifecycle/events";
|
|
192
|
+
const result = await postJson(endpoint, body, options?.getHeaders);
|
|
193
|
+
return toLifecycleEmitResult(result);
|
|
194
|
+
}
|
|
195
|
+
function useMailooLifecycleEvent(options) {
|
|
196
|
+
const endpoint = options?.endpoint ?? "/api/v1/webhooks/lifecycle/events";
|
|
197
|
+
const getHeaders = options?.getHeaders;
|
|
198
|
+
const [pending, setPending] = (0, import_react.useState)(false);
|
|
199
|
+
const emit = (0, import_react.useCallback)(
|
|
200
|
+
async (body) => {
|
|
201
|
+
setPending(true);
|
|
202
|
+
try {
|
|
203
|
+
return await emitMailooLifecycleEvent(body, { endpoint, getHeaders });
|
|
204
|
+
} finally {
|
|
205
|
+
setPending(false);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
[endpoint, getHeaders]
|
|
209
|
+
);
|
|
210
|
+
return { emit, pending };
|
|
211
|
+
}
|
|
212
|
+
async function retryMailooLifecycleEvent(eventId, options) {
|
|
213
|
+
const base = options?.endpoint ?? "/api/v1/webhooks/lifecycle/events";
|
|
214
|
+
const endpoint = `${base.replace(/\/$/, "")}/${encodeURIComponent(eventId)}/retry`;
|
|
215
|
+
const result = await postJson(endpoint, {}, options?.getHeaders);
|
|
216
|
+
return toLifecycleEmitResult(result);
|
|
217
|
+
}
|
|
218
|
+
function useMailooLifecycleRetry(options) {
|
|
219
|
+
const endpoint = options?.endpoint ?? "/api/v1/webhooks/lifecycle/events";
|
|
220
|
+
const getHeaders = options?.getHeaders;
|
|
221
|
+
const [pending, setPending] = (0, import_react.useState)(false);
|
|
222
|
+
const retry = (0, import_react.useCallback)(
|
|
223
|
+
async (eventId) => {
|
|
224
|
+
setPending(true);
|
|
225
|
+
try {
|
|
226
|
+
return await retryMailooLifecycleEvent(eventId, {
|
|
227
|
+
endpoint,
|
|
228
|
+
getHeaders
|
|
229
|
+
});
|
|
230
|
+
} finally {
|
|
231
|
+
setPending(false);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
[endpoint, getHeaders]
|
|
235
|
+
);
|
|
236
|
+
return { retry, pending };
|
|
237
|
+
}
|
|
238
|
+
async function fetchMailooLifecycleStatus(query, options) {
|
|
239
|
+
const base = options?.endpoint ?? "/api/v1/webhooks/lifecycle/status";
|
|
240
|
+
const params = new URLSearchParams();
|
|
241
|
+
if (query.externalUserId?.trim()) {
|
|
242
|
+
params.set("externalUserId", query.externalUserId.trim());
|
|
243
|
+
}
|
|
244
|
+
if (query.externalUserIds?.length) {
|
|
245
|
+
params.set("externalUserIds", query.externalUserIds.join(","));
|
|
246
|
+
}
|
|
247
|
+
if (query.emails?.length) {
|
|
248
|
+
params.set("emails", query.emails.join(","));
|
|
249
|
+
}
|
|
250
|
+
const qs = params.toString();
|
|
251
|
+
const url = qs ? `${base}?${qs}` : base;
|
|
252
|
+
const result = await getJson(url, options?.getHeaders);
|
|
253
|
+
if (!result.ok) {
|
|
254
|
+
return {
|
|
255
|
+
ok: false,
|
|
256
|
+
status: result.status,
|
|
257
|
+
message: result.message
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const data = result.data;
|
|
261
|
+
if (!data || data.success !== true) {
|
|
262
|
+
return {
|
|
263
|
+
ok: false,
|
|
264
|
+
status: result.status,
|
|
265
|
+
message: "Unexpected lifecycle status response shape"
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
return { ok: true, status: result.status, data };
|
|
269
|
+
}
|
|
270
|
+
function useMailooLifecycleStatus(options) {
|
|
271
|
+
const endpoint = options?.endpoint ?? "/api/v1/webhooks/lifecycle/status";
|
|
272
|
+
const getHeaders = options?.getHeaders;
|
|
273
|
+
const [pending, setPending] = (0, import_react.useState)(false);
|
|
274
|
+
const load = (0, import_react.useCallback)(
|
|
275
|
+
async (query) => {
|
|
276
|
+
setPending(true);
|
|
277
|
+
try {
|
|
278
|
+
return await fetchMailooLifecycleStatus(query, {
|
|
279
|
+
endpoint,
|
|
280
|
+
getHeaders
|
|
281
|
+
});
|
|
282
|
+
} finally {
|
|
283
|
+
setPending(false);
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
[endpoint, getHeaders]
|
|
287
|
+
);
|
|
288
|
+
return { load, pending };
|
|
289
|
+
}
|
|
290
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
291
|
+
0 && (module.exports = {
|
|
292
|
+
emitMailooLifecycleEvent,
|
|
293
|
+
fetchMailooLifecycleStatus,
|
|
294
|
+
retryMailooLifecycleEvent,
|
|
295
|
+
useMailooFeedbackSubmit,
|
|
296
|
+
useMailooFormSubmit,
|
|
297
|
+
useMailooLifecycleEvent,
|
|
298
|
+
useMailooLifecycleRetry,
|
|
299
|
+
useMailooLifecycleStatus
|
|
300
|
+
});
|
|
301
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/index.ts","../../src/events/index.ts"],"sourcesContent":["'use client'\n\nimport { useCallback, useState } from 'react'\nimport type {\n MailooLifecycleEventInput,\n MailooLifecycleEventName,\n MailooMarketingConsent,\n MailooLifecycleAttributeKey,\n MailooLifecycleIngestData,\n MailooLifecycleStatusData,\n MailooLifecycleContactSummary,\n} from '../events/index.js'\nimport { parseMailooLifecycleIngestData } from '../events/index.js'\n\nexport type MailooFormSubmitBody = {\n email: string\n name?: string\n subject?: string\n content?: string\n source?: string\n /** Recipient UI locale for welcome email template overlays. */\n locale?: string\n metadata?: Record<string, unknown>\n}\n\nexport type MailooFormSubmitSuccess = {\n success: true\n message: string\n messageId?: string\n}\n\nexport type MailooFeedbackSubmitBody = {\n email: string\n message: string\n name?: string\n subject?: string\n formKey?: string\n locale?: string\n metadata?: Record<string, unknown>\n}\n\nexport type MailooFeedbackSubmitSuccess = {\n success: true\n message: string\n messageId: string\n feedbackId: string\n}\n\nexport type MailooFormSubmitResult =\n | { ok: true; status: number; data: unknown }\n | { ok: false; status: number; message: string }\n\nexport type MailooLifecycleEmitResult =\n | { ok: true; status: number; data: MailooLifecycleIngestData }\n | { ok: false; status: number; message: string; data?: unknown }\n\nexport type MailooLifecycleStatusResult =\n | { ok: true; status: number; data: MailooLifecycleStatusData }\n | { ok: false; status: number; message: string }\n\nexport type MailooFetchHeaders =\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>)\n\nasync function resolveHeaders(\n getHeaders?: MailooFetchHeaders\n): Promise<Record<string, string>> {\n if (!getHeaders) return {}\n if (typeof getHeaders === 'function') {\n return (await getHeaders()) ?? {}\n }\n return getHeaders\n}\n\nasync function postJson(\n endpoint: string,\n body: unknown,\n getHeaders?: MailooFetchHeaders\n): Promise<MailooFormSubmitResult> {\n try {\n const extra = await resolveHeaders(getHeaders)\n const res = await fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...extra },\n body: JSON.stringify(body),\n })\n const data = await res.json().catch(() => ({}))\n if (!res.ok) {\n return {\n ok: false,\n status: res.status,\n message:\n typeof (data as { message?: string }).message === 'string'\n ? (data as { message: string }).message\n : typeof (data as { error?: string }).error === 'string'\n ? (data as { error: string }).error\n : 'Submit failed',\n }\n }\n return { ok: true, status: res.status, data }\n } catch {\n return { ok: false, status: 0, message: 'Network error' }\n }\n}\n\nasync function getJson(\n endpoint: string,\n getHeaders?: MailooFetchHeaders\n): Promise<MailooFormSubmitResult> {\n try {\n const extra = await resolveHeaders(getHeaders)\n const res = await fetch(endpoint, {\n method: 'GET',\n headers: { ...extra },\n })\n const data = await res.json().catch(() => ({}))\n if (!res.ok) {\n return {\n ok: false,\n status: res.status,\n message:\n typeof (data as { message?: string }).message === 'string'\n ? (data as { message: string }).message\n : typeof (data as { error?: string }).error === 'string'\n ? (data as { error: string }).error\n : 'Request failed',\n }\n }\n return { ok: true, status: res.status, data }\n } catch {\n return { ok: false, status: 0, message: 'Network error' }\n }\n}\n\nfunction toLifecycleEmitResult(\n result: MailooFormSubmitResult\n): MailooLifecycleEmitResult {\n if (!result.ok) {\n return {\n ok: false,\n status: result.status,\n message: result.message,\n }\n }\n const envelope = result.data\n const dataObj =\n envelope &&\n typeof envelope === 'object' &&\n !Array.isArray(envelope) &&\n 'data' in envelope\n ? (envelope as { data: unknown }).data\n : envelope\n const parsed = parseMailooLifecycleIngestData(dataObj)\n if (!parsed) {\n return {\n ok: false,\n status: result.status,\n message: 'Unexpected lifecycle ingest response shape',\n data: result.data,\n }\n }\n return { ok: true, status: result.status, data: parsed }\n}\n\nexport function useMailooFormSubmit(options?: {\n endpoint?: string\n getHeaders?: MailooFetchHeaders\n}) {\n const endpoint = options?.endpoint ?? '/api/v1/webhooks/forms/submit'\n const getHeaders = options?.getHeaders\n const [pending, setPending] = useState(false)\n\n const submit = useCallback(\n async (body: MailooFormSubmitBody): Promise<MailooFormSubmitResult> => {\n setPending(true)\n try {\n return await postJson(endpoint, body, getHeaders)\n } finally {\n setPending(false)\n }\n },\n [endpoint, getHeaders]\n )\n\n return { submit, pending }\n}\n\nexport function useMailooFeedbackSubmit(options?: {\n endpoint?: string\n getHeaders?: MailooFetchHeaders\n}) {\n const endpoint = options?.endpoint ?? '/api/v1/webhooks/feedback/submit'\n const getHeaders = options?.getHeaders\n const [pending, setPending] = useState(false)\n\n const submit = useCallback(\n async (\n body: MailooFeedbackSubmitBody\n ): Promise<MailooFormSubmitResult> => {\n setPending(true)\n try {\n return await postJson(endpoint, body, getHeaders)\n } finally {\n setPending(false)\n }\n },\n [endpoint, getHeaders]\n )\n\n return { submit, pending }\n}\n\nexport type EmitMailooLifecycleEventBody = {\n eventName: MailooLifecycleEventName\n idempotencyKey: string\n externalUserId: string\n email: string\n marketingConsent: MailooMarketingConsent\n locale?: string\n name?: string\n attributes?: Partial<Record<MailooLifecycleAttributeKey, unknown>>\n}\n\n/**\n * Browser → same-origin BFF lifecycle ingest. Never send X-API-Key from the client.\n * Use `getHeaders` to attach host auth (e.g. Firebase ID token Bearer).\n */\nexport async function emitMailooLifecycleEvent(\n body: EmitMailooLifecycleEventBody,\n options?: { endpoint?: string; getHeaders?: MailooFetchHeaders }\n): Promise<MailooLifecycleEmitResult> {\n const endpoint =\n options?.endpoint ?? '/api/v1/webhooks/lifecycle/events'\n const result = await postJson(endpoint, body, options?.getHeaders)\n return toLifecycleEmitResult(result)\n}\n\nexport function useMailooLifecycleEvent(options?: {\n endpoint?: string\n getHeaders?: MailooFetchHeaders\n}) {\n const endpoint =\n options?.endpoint ?? '/api/v1/webhooks/lifecycle/events'\n const getHeaders = options?.getHeaders\n const [pending, setPending] = useState(false)\n\n const emit = useCallback(\n async (\n body: EmitMailooLifecycleEventBody | MailooLifecycleEventInput\n ): Promise<MailooLifecycleEmitResult> => {\n setPending(true)\n try {\n return await emitMailooLifecycleEvent(body, { endpoint, getHeaders })\n } finally {\n setPending(false)\n }\n },\n [endpoint, getHeaders]\n )\n\n return { emit, pending }\n}\n\nexport async function retryMailooLifecycleEvent(\n eventId: string,\n options?: { endpoint?: string; getHeaders?: MailooFetchHeaders }\n): Promise<MailooLifecycleEmitResult> {\n const base =\n options?.endpoint ?? '/api/v1/webhooks/lifecycle/events'\n const endpoint = `${base.replace(/\\/$/, '')}/${encodeURIComponent(eventId)}/retry`\n const result = await postJson(endpoint, {}, options?.getHeaders)\n return toLifecycleEmitResult(result)\n}\n\nexport function useMailooLifecycleRetry(options?: {\n endpoint?: string\n getHeaders?: MailooFetchHeaders\n}) {\n const endpoint =\n options?.endpoint ?? '/api/v1/webhooks/lifecycle/events'\n const getHeaders = options?.getHeaders\n const [pending, setPending] = useState(false)\n\n const retry = useCallback(\n async (eventId: string): Promise<MailooLifecycleEmitResult> => {\n setPending(true)\n try {\n return await retryMailooLifecycleEvent(eventId, {\n endpoint,\n getHeaders,\n })\n } finally {\n setPending(false)\n }\n },\n [endpoint, getHeaders]\n )\n\n return { retry, pending }\n}\n\nexport type MailooLifecycleStatusQuery = {\n externalUserIds?: string[]\n emails?: string[]\n externalUserId?: string\n}\n\nexport async function fetchMailooLifecycleStatus(\n query: MailooLifecycleStatusQuery,\n options?: { endpoint?: string; getHeaders?: MailooFetchHeaders }\n): Promise<MailooLifecycleStatusResult> {\n const base =\n options?.endpoint ?? '/api/v1/webhooks/lifecycle/status'\n const params = new URLSearchParams()\n if (query.externalUserId?.trim()) {\n params.set('externalUserId', query.externalUserId.trim())\n }\n if (query.externalUserIds?.length) {\n params.set('externalUserIds', query.externalUserIds.join(','))\n }\n if (query.emails?.length) {\n params.set('emails', query.emails.join(','))\n }\n const qs = params.toString()\n const url = qs ? `${base}?${qs}` : base\n const result = await getJson(url, options?.getHeaders)\n if (!result.ok) {\n return {\n ok: false,\n status: result.status,\n message: result.message,\n }\n }\n const data = result.data as MailooLifecycleStatusData\n if (!data || data.success !== true) {\n return {\n ok: false,\n status: result.status,\n message: 'Unexpected lifecycle status response shape',\n }\n }\n return { ok: true, status: result.status, data }\n}\n\nexport function useMailooLifecycleStatus(options?: {\n endpoint?: string\n getHeaders?: MailooFetchHeaders\n}) {\n const endpoint =\n options?.endpoint ?? '/api/v1/webhooks/lifecycle/status'\n const getHeaders = options?.getHeaders\n const [pending, setPending] = useState(false)\n\n const load = useCallback(\n async (\n query: MailooLifecycleStatusQuery\n ): Promise<MailooLifecycleStatusResult> => {\n setPending(true)\n try {\n return await fetchMailooLifecycleStatus(query, {\n endpoint,\n getHeaders,\n })\n } finally {\n setPending(false)\n }\n },\n [endpoint, getHeaders]\n )\n\n return { load, pending }\n}\n\nexport type { MailooLifecycleContactSummary, MailooLifecycleIngestData }\n","/**\n * Closed lifecycle event catalog for FORM / CONTACT_FORM integrations.\n * Integrators choose *when* to emit; they must not invent event names or\n * attribute keys.\n */\n\nexport const MAILOO_LIFECYCLE_EVENTS = {\n USER_REGISTERED: 'user.registered',\n USER_ACTIVATED: 'user.activated',\n} as const\n\nexport type MailooLifecycleEventName =\n (typeof MAILOO_LIFECYCLE_EVENTS)[keyof typeof MAILOO_LIFECYCLE_EVENTS]\n\nexport const MAILOO_LIFECYCLE_EVENT_NAMES = [\n MAILOO_LIFECYCLE_EVENTS.USER_REGISTERED,\n MAILOO_LIFECYCLE_EVENTS.USER_ACTIVATED,\n] as const\n\nconst EVENT_NAME_SET = new Set<string>(MAILOO_LIFECYCLE_EVENT_NAMES)\n\nexport const MAILOO_LIFECYCLE_ATTRIBUTE_KEYS = [\n 'plan',\n 'tier',\n 'country',\n 'signupChannel',\n 'referrer',\n] as const\n\nexport type MailooLifecycleAttributeKey =\n (typeof MAILOO_LIFECYCLE_ATTRIBUTE_KEYS)[number]\n\nconst ATTRIBUTE_KEY_SET = new Set<string>(MAILOO_LIFECYCLE_ATTRIBUTE_KEYS)\n\nconst EMAIL_RE = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\nexport type MailooMarketingConsent =\n | boolean\n | {\n granted: boolean\n at?: string\n source?: string\n }\n\nexport type MailooLifecycleEventInput = {\n eventName: MailooLifecycleEventName\n idempotencyKey: string\n externalUserId: string\n email: string\n marketingConsent: MailooMarketingConsent\n locale?: string\n name?: string\n attributes?: Partial<Record<MailooLifecycleAttributeKey, unknown>>\n}\n\nexport type MailooLifecycleEventValidation =\n | { ok: true; value: MailooLifecycleEventInput }\n | { ok: false; message: string }\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v)\n}\n\n/**\n * Parse and validate a lifecycle ingest body. Fail-fast — no default\n * `eventName`. Used by BFF handlers and server ingest.\n */\nexport function validateMailooLifecycleEvent(\n body: unknown\n): MailooLifecycleEventValidation {\n if (!isPlainObject(body)) {\n return { ok: false, message: 'JSON body object is required' }\n }\n\n const idempotencyKey =\n typeof body.idempotencyKey === 'string' ? body.idempotencyKey.trim() : ''\n if (!idempotencyKey || idempotencyKey.length > 256) {\n return {\n ok: false,\n message: 'idempotencyKey is required (max 256 characters)',\n }\n }\n\n const eventName =\n typeof body.eventName === 'string' ? body.eventName.trim() : ''\n if (!eventName) {\n return { ok: false, message: 'eventName is required' }\n }\n if (!EVENT_NAME_SET.has(eventName)) {\n return {\n ok: false,\n message: `Unknown eventName: ${eventName}. Allowed: ${MAILOO_LIFECYCLE_EVENT_NAMES.join(', ')}`,\n }\n }\n\n const externalUserId =\n typeof body.externalUserId === 'string' ? body.externalUserId.trim() : ''\n if (!externalUserId) {\n return { ok: false, message: 'externalUserId is required' }\n }\n\n const emailRaw = typeof body.email === 'string' ? body.email.trim() : ''\n if (!emailRaw || !EMAIL_RE.test(emailRaw)) {\n return { ok: false, message: 'Valid email is required' }\n }\n\n const locale =\n typeof body.locale === 'string' && body.locale.trim()\n ? body.locale.trim()\n : undefined\n const name =\n typeof body.name === 'string' && body.name.trim()\n ? body.name.trim()\n : undefined\n\n let marketingConsent: MailooMarketingConsent\n const rawConsent = body.marketingConsent\n if (rawConsent === true || rawConsent === false) {\n marketingConsent = rawConsent\n } else if (isPlainObject(rawConsent) && typeof rawConsent.granted === 'boolean') {\n const at =\n typeof rawConsent.at === 'string' && rawConsent.at.trim()\n ? rawConsent.at.trim()\n : undefined\n if (at !== undefined) {\n const parsed = new Date(at)\n if (Number.isNaN(parsed.getTime())) {\n return {\n ok: false,\n message: 'marketingConsent.at must be a valid ISO timestamp',\n }\n }\n }\n marketingConsent = {\n granted: rawConsent.granted,\n ...(at ? { at } : {}),\n ...(typeof rawConsent.source === 'string'\n ? { source: rawConsent.source }\n : {}),\n }\n } else {\n return {\n ok: false,\n message: 'marketingConsent is required (boolean or { granted })',\n }\n }\n\n let attributes:\n | Partial<Record<MailooLifecycleAttributeKey, unknown>>\n | undefined\n if (body.attributes !== undefined) {\n if (!isPlainObject(body.attributes)) {\n return { ok: false, message: 'attributes must be an object' }\n }\n attributes = {}\n for (const [key, value] of Object.entries(body.attributes)) {\n if (!ATTRIBUTE_KEY_SET.has(key)) {\n return { ok: false, message: `Unknown attribute key: ${key}` }\n }\n attributes[key as MailooLifecycleAttributeKey] = value\n }\n }\n\n return {\n ok: true,\n value: {\n eventName: eventName as MailooLifecycleEventName,\n idempotencyKey,\n externalUserId,\n email: emailRaw,\n marketingConsent,\n ...(locale ? { locale } : {}),\n ...(name ? { name } : {}),\n ...(attributes ? { attributes } : {}),\n },\n }\n}\n\nexport function isMailooLifecycleEventName(\n value: string\n): value is MailooLifecycleEventName {\n return EVENT_NAME_SET.has(value)\n}\n\n/** Send row returned by lifecycle ingest / retry. */\nexport type MailooLifecycleSendResult = {\n sendId: string\n status: string\n messageId: string | null\n trackingToken: string\n campaignId: string | null\n}\n\n/**\n * Typed `data` from lifecycle ingest / retry success JSON.\n * `contactId` is Mailoo's Subscriber cuid — not the host user id.\n * Host identity key is `externalUserId` (e.g. Firebase UID).\n */\nexport type MailooLifecycleIngestData = {\n eventId: string\n contactId: string\n idempotentReplay: boolean\n processingStatus: string\n skipReason: string | null\n send: MailooLifecycleSendResult | null\n}\n\nexport type MailooLifecycleIngestSuccess = {\n success: true\n data: MailooLifecycleIngestData\n}\n\nexport type MailooLifecycleContactSummary = {\n requestedExternalUserId: string | null\n requestedEmail: string | null\n matchedBy: 'externalUserId' | 'email' | null\n contactId: string | null\n externalUserId: string | null\n email: string | null\n marketingConsentGranted: boolean | null\n unsubscribedAt: string | null\n lastEvent: {\n eventId: string\n eventName: string\n processingStatus: string\n skipReason: string | null\n createdAt: string\n } | null\n lastSend: {\n sendId: string\n status: string\n messageId: string | null\n openedAt: string | null\n clickedAt: string | null\n } | null\n}\n\nexport type MailooLifecycleStatusData = {\n success: true\n configured: true\n contacts: number\n contact: Record<string, unknown> | null\n events: Array<Record<string, unknown>>\n sends: Array<Record<string, unknown>>\n segments: Array<{\n id: string\n name: string\n systemKey: string | null\n }>\n summaries?: MailooLifecycleContactSummary[]\n}\n\nexport function parseMailooLifecycleIngestData(\n data: unknown\n): MailooLifecycleIngestData | null {\n if (!isPlainObject(data)) return null\n if (typeof data.eventId !== 'string' || typeof data.contactId !== 'string') {\n return null\n }\n let send: MailooLifecycleSendResult | null = null\n if (data.send === null) {\n send = null\n } else if (isPlainObject(data.send) && typeof data.send.sendId === 'string') {\n send = {\n sendId: data.send.sendId,\n status: String(data.send.status ?? ''),\n messageId:\n data.send.messageId === null || typeof data.send.messageId === 'string'\n ? (data.send.messageId as string | null)\n : null,\n trackingToken: String(data.send.trackingToken ?? ''),\n campaignId:\n data.send.campaignId === null ||\n typeof data.send.campaignId === 'string'\n ? (data.send.campaignId as string | null)\n : null,\n }\n } else {\n return null\n }\n return {\n eventId: data.eventId,\n contactId: data.contactId,\n idempotentReplay: data.idempotentReplay === true,\n processingStatus: String(data.processingStatus ?? ''),\n skipReason:\n data.skipReason === null || typeof data.skipReason === 'string'\n ? (data.skipReason as string | null)\n : null,\n send,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAsC;;;ACI/B,IAAM,0BAA0B;AAAA,EACrC,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;AAKO,IAAM,+BAA+B;AAAA,EAC1C,wBAAwB;AAAA,EACxB,wBAAwB;AAC1B;AAEA,IAAM,iBAAiB,IAAI,IAAY,4BAA4B;AAE5D,IAAM,kCAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA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AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,SAAO,EAAE,MAAM,QAAQ;AACzB;","names":[]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { MailooLifecycleIngestData, MailooLifecycleStatusData, MailooLifecycleEventName, MailooMarketingConsent, MailooLifecycleAttributeKey, MailooLifecycleEventInput } from '../events/index.cjs';
|
|
2
|
+
export { MailooLifecycleContactSummary } from '../events/index.cjs';
|
|
3
|
+
|
|
4
|
+
type MailooFormSubmitBody = {
|
|
5
|
+
email: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
subject?: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
source?: string;
|
|
10
|
+
/** Recipient UI locale for welcome email template overlays. */
|
|
11
|
+
locale?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
type MailooFormSubmitSuccess = {
|
|
15
|
+
success: true;
|
|
16
|
+
message: string;
|
|
17
|
+
messageId?: string;
|
|
18
|
+
};
|
|
19
|
+
type MailooFeedbackSubmitBody = {
|
|
20
|
+
email: string;
|
|
21
|
+
message: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
subject?: string;
|
|
24
|
+
formKey?: string;
|
|
25
|
+
locale?: string;
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
type MailooFeedbackSubmitSuccess = {
|
|
29
|
+
success: true;
|
|
30
|
+
message: string;
|
|
31
|
+
messageId: string;
|
|
32
|
+
feedbackId: string;
|
|
33
|
+
};
|
|
34
|
+
type MailooFormSubmitResult = {
|
|
35
|
+
ok: true;
|
|
36
|
+
status: number;
|
|
37
|
+
data: unknown;
|
|
38
|
+
} | {
|
|
39
|
+
ok: false;
|
|
40
|
+
status: number;
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
type MailooLifecycleEmitResult = {
|
|
44
|
+
ok: true;
|
|
45
|
+
status: number;
|
|
46
|
+
data: MailooLifecycleIngestData;
|
|
47
|
+
} | {
|
|
48
|
+
ok: false;
|
|
49
|
+
status: number;
|
|
50
|
+
message: string;
|
|
51
|
+
data?: unknown;
|
|
52
|
+
};
|
|
53
|
+
type MailooLifecycleStatusResult = {
|
|
54
|
+
ok: true;
|
|
55
|
+
status: number;
|
|
56
|
+
data: MailooLifecycleStatusData;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
status: number;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
type MailooFetchHeaders = Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
63
|
+
declare function useMailooFormSubmit(options?: {
|
|
64
|
+
endpoint?: string;
|
|
65
|
+
getHeaders?: MailooFetchHeaders;
|
|
66
|
+
}): {
|
|
67
|
+
submit: (body: MailooFormSubmitBody) => Promise<MailooFormSubmitResult>;
|
|
68
|
+
pending: boolean;
|
|
69
|
+
};
|
|
70
|
+
declare function useMailooFeedbackSubmit(options?: {
|
|
71
|
+
endpoint?: string;
|
|
72
|
+
getHeaders?: MailooFetchHeaders;
|
|
73
|
+
}): {
|
|
74
|
+
submit: (body: MailooFeedbackSubmitBody) => Promise<MailooFormSubmitResult>;
|
|
75
|
+
pending: boolean;
|
|
76
|
+
};
|
|
77
|
+
type EmitMailooLifecycleEventBody = {
|
|
78
|
+
eventName: MailooLifecycleEventName;
|
|
79
|
+
idempotencyKey: string;
|
|
80
|
+
externalUserId: string;
|
|
81
|
+
email: string;
|
|
82
|
+
marketingConsent: MailooMarketingConsent;
|
|
83
|
+
locale?: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
attributes?: Partial<Record<MailooLifecycleAttributeKey, unknown>>;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Browser → same-origin BFF lifecycle ingest. Never send X-API-Key from the client.
|
|
89
|
+
* Use `getHeaders` to attach host auth (e.g. Firebase ID token Bearer).
|
|
90
|
+
*/
|
|
91
|
+
declare function emitMailooLifecycleEvent(body: EmitMailooLifecycleEventBody, options?: {
|
|
92
|
+
endpoint?: string;
|
|
93
|
+
getHeaders?: MailooFetchHeaders;
|
|
94
|
+
}): Promise<MailooLifecycleEmitResult>;
|
|
95
|
+
declare function useMailooLifecycleEvent(options?: {
|
|
96
|
+
endpoint?: string;
|
|
97
|
+
getHeaders?: MailooFetchHeaders;
|
|
98
|
+
}): {
|
|
99
|
+
emit: (body: EmitMailooLifecycleEventBody | MailooLifecycleEventInput) => Promise<MailooLifecycleEmitResult>;
|
|
100
|
+
pending: boolean;
|
|
101
|
+
};
|
|
102
|
+
declare function retryMailooLifecycleEvent(eventId: string, options?: {
|
|
103
|
+
endpoint?: string;
|
|
104
|
+
getHeaders?: MailooFetchHeaders;
|
|
105
|
+
}): Promise<MailooLifecycleEmitResult>;
|
|
106
|
+
declare function useMailooLifecycleRetry(options?: {
|
|
107
|
+
endpoint?: string;
|
|
108
|
+
getHeaders?: MailooFetchHeaders;
|
|
109
|
+
}): {
|
|
110
|
+
retry: (eventId: string) => Promise<MailooLifecycleEmitResult>;
|
|
111
|
+
pending: boolean;
|
|
112
|
+
};
|
|
113
|
+
type MailooLifecycleStatusQuery = {
|
|
114
|
+
externalUserIds?: string[];
|
|
115
|
+
emails?: string[];
|
|
116
|
+
externalUserId?: string;
|
|
117
|
+
};
|
|
118
|
+
declare function fetchMailooLifecycleStatus(query: MailooLifecycleStatusQuery, options?: {
|
|
119
|
+
endpoint?: string;
|
|
120
|
+
getHeaders?: MailooFetchHeaders;
|
|
121
|
+
}): Promise<MailooLifecycleStatusResult>;
|
|
122
|
+
declare function useMailooLifecycleStatus(options?: {
|
|
123
|
+
endpoint?: string;
|
|
124
|
+
getHeaders?: MailooFetchHeaders;
|
|
125
|
+
}): {
|
|
126
|
+
load: (query: MailooLifecycleStatusQuery) => Promise<MailooLifecycleStatusResult>;
|
|
127
|
+
pending: boolean;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export { type EmitMailooLifecycleEventBody, type MailooFeedbackSubmitBody, type MailooFeedbackSubmitSuccess, type MailooFetchHeaders, type MailooFormSubmitBody, type MailooFormSubmitResult, type MailooFormSubmitSuccess, type MailooLifecycleEmitResult, MailooLifecycleIngestData, type MailooLifecycleStatusQuery, type MailooLifecycleStatusResult, emitMailooLifecycleEvent, fetchMailooLifecycleStatus, retryMailooLifecycleEvent, useMailooFeedbackSubmit, useMailooFormSubmit, useMailooLifecycleEvent, useMailooLifecycleRetry, useMailooLifecycleStatus };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { MailooLifecycleIngestData, MailooLifecycleStatusData, MailooLifecycleEventName, MailooMarketingConsent, MailooLifecycleAttributeKey, MailooLifecycleEventInput } from '../events/index.js';
|
|
2
|
+
export { MailooLifecycleContactSummary } from '../events/index.js';
|
|
3
|
+
|
|
4
|
+
type MailooFormSubmitBody = {
|
|
5
|
+
email: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
subject?: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
source?: string;
|
|
10
|
+
/** Recipient UI locale for welcome email template overlays. */
|
|
11
|
+
locale?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
type MailooFormSubmitSuccess = {
|
|
15
|
+
success: true;
|
|
16
|
+
message: string;
|
|
17
|
+
messageId?: string;
|
|
18
|
+
};
|
|
19
|
+
type MailooFeedbackSubmitBody = {
|
|
20
|
+
email: string;
|
|
21
|
+
message: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
subject?: string;
|
|
24
|
+
formKey?: string;
|
|
25
|
+
locale?: string;
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
type MailooFeedbackSubmitSuccess = {
|
|
29
|
+
success: true;
|
|
30
|
+
message: string;
|
|
31
|
+
messageId: string;
|
|
32
|
+
feedbackId: string;
|
|
33
|
+
};
|
|
34
|
+
type MailooFormSubmitResult = {
|
|
35
|
+
ok: true;
|
|
36
|
+
status: number;
|
|
37
|
+
data: unknown;
|
|
38
|
+
} | {
|
|
39
|
+
ok: false;
|
|
40
|
+
status: number;
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
type MailooLifecycleEmitResult = {
|
|
44
|
+
ok: true;
|
|
45
|
+
status: number;
|
|
46
|
+
data: MailooLifecycleIngestData;
|
|
47
|
+
} | {
|
|
48
|
+
ok: false;
|
|
49
|
+
status: number;
|
|
50
|
+
message: string;
|
|
51
|
+
data?: unknown;
|
|
52
|
+
};
|
|
53
|
+
type MailooLifecycleStatusResult = {
|
|
54
|
+
ok: true;
|
|
55
|
+
status: number;
|
|
56
|
+
data: MailooLifecycleStatusData;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
status: number;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
type MailooFetchHeaders = Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
63
|
+
declare function useMailooFormSubmit(options?: {
|
|
64
|
+
endpoint?: string;
|
|
65
|
+
getHeaders?: MailooFetchHeaders;
|
|
66
|
+
}): {
|
|
67
|
+
submit: (body: MailooFormSubmitBody) => Promise<MailooFormSubmitResult>;
|
|
68
|
+
pending: boolean;
|
|
69
|
+
};
|
|
70
|
+
declare function useMailooFeedbackSubmit(options?: {
|
|
71
|
+
endpoint?: string;
|
|
72
|
+
getHeaders?: MailooFetchHeaders;
|
|
73
|
+
}): {
|
|
74
|
+
submit: (body: MailooFeedbackSubmitBody) => Promise<MailooFormSubmitResult>;
|
|
75
|
+
pending: boolean;
|
|
76
|
+
};
|
|
77
|
+
type EmitMailooLifecycleEventBody = {
|
|
78
|
+
eventName: MailooLifecycleEventName;
|
|
79
|
+
idempotencyKey: string;
|
|
80
|
+
externalUserId: string;
|
|
81
|
+
email: string;
|
|
82
|
+
marketingConsent: MailooMarketingConsent;
|
|
83
|
+
locale?: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
attributes?: Partial<Record<MailooLifecycleAttributeKey, unknown>>;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Browser → same-origin BFF lifecycle ingest. Never send X-API-Key from the client.
|
|
89
|
+
* Use `getHeaders` to attach host auth (e.g. Firebase ID token Bearer).
|
|
90
|
+
*/
|
|
91
|
+
declare function emitMailooLifecycleEvent(body: EmitMailooLifecycleEventBody, options?: {
|
|
92
|
+
endpoint?: string;
|
|
93
|
+
getHeaders?: MailooFetchHeaders;
|
|
94
|
+
}): Promise<MailooLifecycleEmitResult>;
|
|
95
|
+
declare function useMailooLifecycleEvent(options?: {
|
|
96
|
+
endpoint?: string;
|
|
97
|
+
getHeaders?: MailooFetchHeaders;
|
|
98
|
+
}): {
|
|
99
|
+
emit: (body: EmitMailooLifecycleEventBody | MailooLifecycleEventInput) => Promise<MailooLifecycleEmitResult>;
|
|
100
|
+
pending: boolean;
|
|
101
|
+
};
|
|
102
|
+
declare function retryMailooLifecycleEvent(eventId: string, options?: {
|
|
103
|
+
endpoint?: string;
|
|
104
|
+
getHeaders?: MailooFetchHeaders;
|
|
105
|
+
}): Promise<MailooLifecycleEmitResult>;
|
|
106
|
+
declare function useMailooLifecycleRetry(options?: {
|
|
107
|
+
endpoint?: string;
|
|
108
|
+
getHeaders?: MailooFetchHeaders;
|
|
109
|
+
}): {
|
|
110
|
+
retry: (eventId: string) => Promise<MailooLifecycleEmitResult>;
|
|
111
|
+
pending: boolean;
|
|
112
|
+
};
|
|
113
|
+
type MailooLifecycleStatusQuery = {
|
|
114
|
+
externalUserIds?: string[];
|
|
115
|
+
emails?: string[];
|
|
116
|
+
externalUserId?: string;
|
|
117
|
+
};
|
|
118
|
+
declare function fetchMailooLifecycleStatus(query: MailooLifecycleStatusQuery, options?: {
|
|
119
|
+
endpoint?: string;
|
|
120
|
+
getHeaders?: MailooFetchHeaders;
|
|
121
|
+
}): Promise<MailooLifecycleStatusResult>;
|
|
122
|
+
declare function useMailooLifecycleStatus(options?: {
|
|
123
|
+
endpoint?: string;
|
|
124
|
+
getHeaders?: MailooFetchHeaders;
|
|
125
|
+
}): {
|
|
126
|
+
load: (query: MailooLifecycleStatusQuery) => Promise<MailooLifecycleStatusResult>;
|
|
127
|
+
pending: boolean;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export { type EmitMailooLifecycleEventBody, type MailooFeedbackSubmitBody, type MailooFeedbackSubmitSuccess, type MailooFetchHeaders, type MailooFormSubmitBody, type MailooFormSubmitResult, type MailooFormSubmitSuccess, type MailooLifecycleEmitResult, MailooLifecycleIngestData, type MailooLifecycleStatusQuery, type MailooLifecycleStatusResult, emitMailooLifecycleEvent, fetchMailooLifecycleStatus, retryMailooLifecycleEvent, useMailooFeedbackSubmit, useMailooFormSubmit, useMailooLifecycleEvent, useMailooLifecycleRetry, useMailooLifecycleStatus };
|