@devwithbobby/loops 0.1.11 → 0.1.13
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/README.md +1 -24
- package/dist/client/index.d.ts +122 -52
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +15 -26
- package/dist/component/convex.config.d.ts +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +0 -1
- package/dist/component/lib.d.ts +237 -29
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +47 -133
- package/dist/component/schema.d.ts +66 -1
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/tables/contacts.d.ts +123 -1
- package/dist/component/tables/contacts.d.ts.map +1 -1
- package/dist/component/tables/emailOperations.d.ts +151 -1
- package/dist/component/tables/emailOperations.d.ts.map +1 -1
- package/dist/component/tables/emailOperations.js +1 -6
- package/dist/component/validators.d.ts +20 -3
- package/dist/component/validators.d.ts.map +1 -1
- package/dist/utils.d.ts +186 -3
- package/dist/utils.d.ts.map +1 -1
- package/package.json +101 -101
- package/src/client/index.ts +56 -57
- package/src/component/convex.config.ts +0 -1
- package/src/component/lib.ts +146 -219
- package/src/component/tables/contacts.ts +0 -1
- package/src/component/tables/emailOperations.ts +1 -7
- package/src/component/validators.ts +0 -1
package/dist/component/lib.d.ts
CHANGED
|
@@ -1,55 +1,144 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal mutation to store/update a contact in the database
|
|
3
3
|
*/
|
|
4
|
-
export declare const storeContact:
|
|
4
|
+
export declare const storeContact: import("convex/server").RegisteredMutation<"public", {
|
|
5
|
+
email: string;
|
|
6
|
+
firstName?: string | undefined;
|
|
7
|
+
lastName?: string | undefined;
|
|
8
|
+
userId?: string | undefined;
|
|
9
|
+
source?: string | undefined;
|
|
10
|
+
subscribed?: boolean | undefined;
|
|
11
|
+
userGroup?: string | undefined;
|
|
12
|
+
loopsContactId?: string | undefined;
|
|
13
|
+
}, Promise<void>>;
|
|
5
14
|
/**
|
|
6
15
|
* Internal mutation to delete a contact from the database
|
|
7
16
|
*/
|
|
8
|
-
export declare const removeContact:
|
|
17
|
+
export declare const removeContact: import("convex/server").RegisteredMutation<"public", {
|
|
18
|
+
email: string;
|
|
19
|
+
}, Promise<void>>;
|
|
9
20
|
/**
|
|
10
21
|
* Internal mutation to log an email operation for monitoring
|
|
11
22
|
*/
|
|
12
|
-
export declare const logEmailOperation:
|
|
23
|
+
export declare const logEmailOperation: import("convex/server").RegisteredMutation<"public", {
|
|
24
|
+
operationType: "transactional" | "event" | "campaign" | "loop";
|
|
25
|
+
email: string;
|
|
26
|
+
success: boolean;
|
|
27
|
+
actorId?: string | undefined;
|
|
28
|
+
transactionalId?: string | undefined;
|
|
29
|
+
campaignId?: string | undefined;
|
|
30
|
+
loopId?: string | undefined;
|
|
31
|
+
eventName?: string | undefined;
|
|
32
|
+
messageId?: string | undefined;
|
|
33
|
+
metadata?: Record<string, any> | undefined;
|
|
34
|
+
}, Promise<void>>;
|
|
13
35
|
/**
|
|
14
36
|
* Count contacts in the database
|
|
15
37
|
* Can filter by audience criteria (userGroup, source, subscribed status)
|
|
16
38
|
*/
|
|
17
|
-
export declare const countContacts:
|
|
39
|
+
export declare const countContacts: import("convex/server").RegisteredQuery<"public", {
|
|
40
|
+
userGroup?: string | undefined;
|
|
41
|
+
source?: string | undefined;
|
|
42
|
+
subscribed?: boolean | undefined;
|
|
43
|
+
}, Promise<number>>;
|
|
18
44
|
/**
|
|
19
45
|
* List contacts from the database with pagination
|
|
20
46
|
* Can filter by audience criteria (userGroup, source, subscribed status)
|
|
21
47
|
* Returns actual contact data, not just a count
|
|
22
48
|
*/
|
|
23
|
-
export declare const listContacts:
|
|
49
|
+
export declare const listContacts: import("convex/server").RegisteredQuery<"public", {
|
|
50
|
+
limit: number;
|
|
51
|
+
offset: number;
|
|
52
|
+
userGroup?: string | undefined;
|
|
53
|
+
source?: string | undefined;
|
|
54
|
+
subscribed?: boolean | undefined;
|
|
55
|
+
}, Promise<{
|
|
56
|
+
contacts: {
|
|
57
|
+
_id: string;
|
|
58
|
+
email: string;
|
|
59
|
+
subscribed: boolean;
|
|
60
|
+
createdAt: number;
|
|
61
|
+
updatedAt: number;
|
|
62
|
+
firstName?: string | undefined;
|
|
63
|
+
lastName?: string | undefined;
|
|
64
|
+
userId?: string | undefined;
|
|
65
|
+
source?: string | undefined;
|
|
66
|
+
userGroup?: string | undefined;
|
|
67
|
+
loopsContactId?: string | undefined;
|
|
68
|
+
}[];
|
|
69
|
+
total: number;
|
|
70
|
+
limit: number;
|
|
71
|
+
offset: number;
|
|
72
|
+
hasMore: boolean;
|
|
73
|
+
}>>;
|
|
24
74
|
/**
|
|
25
75
|
* Add or update a contact in Loops
|
|
26
76
|
* This function tries to create a contact, and if the email already exists (409),
|
|
27
77
|
* it falls back to updating the contact instead.
|
|
28
78
|
*/
|
|
29
|
-
export declare const addContact:
|
|
79
|
+
export declare const addContact: import("convex/server").RegisteredAction<"public", {
|
|
80
|
+
apiKey: string;
|
|
81
|
+
contact: {
|
|
82
|
+
email: string;
|
|
83
|
+
firstName?: string | undefined;
|
|
84
|
+
lastName?: string | undefined;
|
|
85
|
+
userId?: string | undefined;
|
|
86
|
+
source?: string | undefined;
|
|
87
|
+
subscribed?: boolean | undefined;
|
|
88
|
+
userGroup?: string | undefined;
|
|
89
|
+
};
|
|
90
|
+
}, Promise<{
|
|
91
|
+
success: boolean;
|
|
92
|
+
id?: string | undefined;
|
|
93
|
+
}>>;
|
|
30
94
|
/**
|
|
31
95
|
* Update an existing contact in Loops
|
|
32
96
|
*/
|
|
33
|
-
export declare const updateContact:
|
|
97
|
+
export declare const updateContact: import("convex/server").RegisteredAction<"public", {
|
|
98
|
+
apiKey: string;
|
|
99
|
+
email: string;
|
|
100
|
+
dataVariables?: Record<string, any> | undefined;
|
|
101
|
+
firstName?: string | undefined;
|
|
102
|
+
lastName?: string | undefined;
|
|
103
|
+
userId?: string | undefined;
|
|
104
|
+
source?: string | undefined;
|
|
105
|
+
subscribed?: boolean | undefined;
|
|
106
|
+
userGroup?: string | undefined;
|
|
107
|
+
}, Promise<{
|
|
108
|
+
success: boolean;
|
|
109
|
+
}>>;
|
|
34
110
|
/**
|
|
35
111
|
* Send a transactional email using a transactional ID
|
|
36
112
|
*/
|
|
37
|
-
export declare const sendTransactional:
|
|
113
|
+
export declare const sendTransactional: import("convex/server").RegisteredAction<"public", {
|
|
114
|
+
apiKey: string;
|
|
115
|
+
transactionalId: string;
|
|
116
|
+
email: string;
|
|
117
|
+
dataVariables?: Record<string, any> | undefined;
|
|
118
|
+
}, Promise<{
|
|
119
|
+
success: boolean;
|
|
120
|
+
messageId?: string | undefined;
|
|
121
|
+
}>>;
|
|
38
122
|
/**
|
|
39
123
|
* Send an event to Loops to trigger email workflows
|
|
40
124
|
*/
|
|
41
|
-
export declare const sendEvent:
|
|
125
|
+
export declare const sendEvent: import("convex/server").RegisteredAction<"public", {
|
|
126
|
+
apiKey: string;
|
|
127
|
+
email: string;
|
|
128
|
+
eventName: string;
|
|
129
|
+
eventProperties?: Record<string, any> | undefined;
|
|
130
|
+
}, Promise<{
|
|
131
|
+
success: boolean;
|
|
132
|
+
}>>;
|
|
42
133
|
/**
|
|
43
134
|
* Delete a contact from Loops
|
|
44
135
|
*/
|
|
45
|
-
export declare const deleteContact:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
export declare const sendCampaign: any;
|
|
136
|
+
export declare const deleteContact: import("convex/server").RegisteredAction<"public", {
|
|
137
|
+
apiKey: string;
|
|
138
|
+
email: string;
|
|
139
|
+
}, Promise<{
|
|
140
|
+
success: boolean;
|
|
141
|
+
}>>;
|
|
53
142
|
/**
|
|
54
143
|
* Trigger a loop for a contact
|
|
55
144
|
* Note: Loops in Loops.so are triggered through events, not a direct API endpoint.
|
|
@@ -66,61 +155,180 @@ export declare const sendCampaign: any;
|
|
|
66
155
|
*
|
|
67
156
|
* This function is kept for backwards compatibility but works by sending an event.
|
|
68
157
|
*/
|
|
69
|
-
export declare const triggerLoop:
|
|
158
|
+
export declare const triggerLoop: import("convex/server").RegisteredAction<"public", {
|
|
159
|
+
apiKey: string;
|
|
160
|
+
loopId: string;
|
|
161
|
+
email: string;
|
|
162
|
+
dataVariables?: Record<string, any> | undefined;
|
|
163
|
+
eventName?: string | undefined;
|
|
164
|
+
}, Promise<{
|
|
165
|
+
success: boolean;
|
|
166
|
+
warning?: string | undefined;
|
|
167
|
+
}>>;
|
|
70
168
|
/**
|
|
71
169
|
* Find a contact by email
|
|
72
170
|
* Retrieves contact information from Loops
|
|
73
171
|
* Note: Loops API may return either an object or an array
|
|
74
172
|
*/
|
|
75
|
-
export declare const findContact:
|
|
173
|
+
export declare const findContact: import("convex/server").RegisteredAction<"public", {
|
|
174
|
+
apiKey: string;
|
|
175
|
+
email: string;
|
|
176
|
+
}, Promise<{
|
|
177
|
+
success: boolean;
|
|
178
|
+
contact?: {
|
|
179
|
+
id?: string | null | undefined;
|
|
180
|
+
email?: string | null | undefined;
|
|
181
|
+
firstName?: string | null | undefined;
|
|
182
|
+
lastName?: string | null | undefined;
|
|
183
|
+
source?: string | null | undefined;
|
|
184
|
+
subscribed?: boolean | null | undefined;
|
|
185
|
+
userGroup?: string | null | undefined;
|
|
186
|
+
userId?: string | null | undefined;
|
|
187
|
+
createdAt?: string | null | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
}>>;
|
|
76
190
|
/**
|
|
77
191
|
* Batch create contacts
|
|
78
192
|
* Creates multiple contacts sequentially using the single contact create endpoint.
|
|
79
193
|
* Note: Loops.so doesn't have a batch endpoint, so we create contacts one by one.
|
|
80
194
|
*/
|
|
81
|
-
export declare const batchCreateContacts:
|
|
195
|
+
export declare const batchCreateContacts: import("convex/server").RegisteredAction<"public", {
|
|
196
|
+
apiKey: string;
|
|
197
|
+
contacts: {
|
|
198
|
+
email: string;
|
|
199
|
+
firstName?: string | undefined;
|
|
200
|
+
lastName?: string | undefined;
|
|
201
|
+
userId?: string | undefined;
|
|
202
|
+
source?: string | undefined;
|
|
203
|
+
subscribed?: boolean | undefined;
|
|
204
|
+
userGroup?: string | undefined;
|
|
205
|
+
}[];
|
|
206
|
+
}, Promise<{
|
|
207
|
+
success: boolean;
|
|
208
|
+
created?: number | undefined;
|
|
209
|
+
failed?: number | undefined;
|
|
210
|
+
results?: {
|
|
211
|
+
email: string;
|
|
212
|
+
success: boolean;
|
|
213
|
+
error?: string | undefined;
|
|
214
|
+
}[] | undefined;
|
|
215
|
+
}>>;
|
|
82
216
|
/**
|
|
83
217
|
* Unsubscribe a contact
|
|
84
218
|
* Unsubscribes a contact from receiving emails (they remain in the system)
|
|
85
219
|
*/
|
|
86
|
-
export declare const unsubscribeContact:
|
|
220
|
+
export declare const unsubscribeContact: import("convex/server").RegisteredAction<"public", {
|
|
221
|
+
apiKey: string;
|
|
222
|
+
email: string;
|
|
223
|
+
}, Promise<{
|
|
224
|
+
success: boolean;
|
|
225
|
+
}>>;
|
|
87
226
|
/**
|
|
88
227
|
* Resubscribe a contact
|
|
89
228
|
* Resubscribes a previously unsubscribed contact
|
|
90
229
|
*/
|
|
91
|
-
export declare const resubscribeContact:
|
|
230
|
+
export declare const resubscribeContact: import("convex/server").RegisteredAction<"public", {
|
|
231
|
+
apiKey: string;
|
|
232
|
+
email: string;
|
|
233
|
+
}, Promise<{
|
|
234
|
+
success: boolean;
|
|
235
|
+
}>>;
|
|
92
236
|
/**
|
|
93
237
|
* Check for spam patterns: too many emails to the same recipient in a time window
|
|
94
238
|
* Returns email addresses that received too many emails
|
|
95
239
|
*/
|
|
96
|
-
export declare const detectRecipientSpam:
|
|
240
|
+
export declare const detectRecipientSpam: import("convex/server").RegisteredQuery<"public", {
|
|
241
|
+
timeWindowMs: number;
|
|
242
|
+
maxEmailsPerRecipient: number;
|
|
243
|
+
}, Promise<{
|
|
244
|
+
[x: string]: any;
|
|
245
|
+
email: string;
|
|
246
|
+
count: number;
|
|
247
|
+
timeWindowMs: number;
|
|
248
|
+
}[]>>;
|
|
97
249
|
/**
|
|
98
250
|
* Check for spam patterns: too many emails from the same actor/user
|
|
99
251
|
* Returns actor IDs that sent too many emails
|
|
100
252
|
*/
|
|
101
|
-
export declare const detectActorSpam:
|
|
253
|
+
export declare const detectActorSpam: import("convex/server").RegisteredQuery<"public", {
|
|
254
|
+
timeWindowMs: number;
|
|
255
|
+
maxEmailsPerActor: number;
|
|
256
|
+
}, Promise<{
|
|
257
|
+
actorId: string;
|
|
258
|
+
count: number;
|
|
259
|
+
timeWindowMs: number;
|
|
260
|
+
}[]>>;
|
|
102
261
|
/**
|
|
103
262
|
* Get recent email operation statistics for monitoring
|
|
104
263
|
*/
|
|
105
|
-
export declare const getEmailStats:
|
|
264
|
+
export declare const getEmailStats: import("convex/server").RegisteredQuery<"public", {
|
|
265
|
+
timeWindowMs: number;
|
|
266
|
+
}, Promise<{
|
|
267
|
+
[x: string]: any;
|
|
268
|
+
totalOperations: number;
|
|
269
|
+
successfulOperations: number;
|
|
270
|
+
failedOperations: number;
|
|
271
|
+
operationsByType: Record<string, number>;
|
|
272
|
+
uniqueRecipients: number;
|
|
273
|
+
uniqueActors: number;
|
|
274
|
+
}>>;
|
|
106
275
|
/**
|
|
107
276
|
* Detect rapid-fire email sending patterns (multiple emails sent in quick succession)
|
|
108
277
|
* Returns suspicious patterns indicating potential spam
|
|
109
278
|
*/
|
|
110
|
-
export declare const detectRapidFirePatterns:
|
|
279
|
+
export declare const detectRapidFirePatterns: import("convex/server").RegisteredQuery<"public", {
|
|
280
|
+
timeWindowMs: number;
|
|
281
|
+
minEmailsInWindow: number;
|
|
282
|
+
}, Promise<{
|
|
283
|
+
count: number;
|
|
284
|
+
timeWindowMs: number;
|
|
285
|
+
firstTimestamp: number;
|
|
286
|
+
lastTimestamp: number;
|
|
287
|
+
email?: string | undefined;
|
|
288
|
+
actorId?: string | undefined;
|
|
289
|
+
}[]>>;
|
|
111
290
|
/**
|
|
112
291
|
* Rate limiting: Check if an email can be sent to a recipient
|
|
113
292
|
* Based on recent email operations in the database
|
|
114
293
|
*/
|
|
115
|
-
export declare const checkRecipientRateLimit:
|
|
294
|
+
export declare const checkRecipientRateLimit: import("convex/server").RegisteredQuery<"public", {
|
|
295
|
+
email: string;
|
|
296
|
+
timeWindowMs: number;
|
|
297
|
+
maxEmails: number;
|
|
298
|
+
}, Promise<{
|
|
299
|
+
[x: string]: any;
|
|
300
|
+
allowed: boolean;
|
|
301
|
+
count: number;
|
|
302
|
+
limit: number;
|
|
303
|
+
timeWindowMs: number;
|
|
304
|
+
retryAfter?: number | undefined;
|
|
305
|
+
}>>;
|
|
116
306
|
/**
|
|
117
307
|
* Rate limiting: Check if an actor/user can send more emails
|
|
118
308
|
* Based on recent email operations in the database
|
|
119
309
|
*/
|
|
120
|
-
export declare const checkActorRateLimit:
|
|
310
|
+
export declare const checkActorRateLimit: import("convex/server").RegisteredQuery<"public", {
|
|
311
|
+
actorId: string;
|
|
312
|
+
timeWindowMs: number;
|
|
313
|
+
maxEmails: number;
|
|
314
|
+
}, Promise<{
|
|
315
|
+
allowed: boolean;
|
|
316
|
+
count: number;
|
|
317
|
+
limit: number;
|
|
318
|
+
timeWindowMs: number;
|
|
319
|
+
retryAfter?: number | undefined;
|
|
320
|
+
}>>;
|
|
121
321
|
/**
|
|
122
322
|
* Rate limiting: Check global email sending rate
|
|
123
323
|
* Checks total email operations across all senders
|
|
124
324
|
*/
|
|
125
|
-
export declare const checkGlobalRateLimit:
|
|
325
|
+
export declare const checkGlobalRateLimit: import("convex/server").RegisteredQuery<"public", {
|
|
326
|
+
timeWindowMs: number;
|
|
327
|
+
maxEmails: number;
|
|
328
|
+
}, Promise<{
|
|
329
|
+
allowed: boolean;
|
|
330
|
+
count: number;
|
|
331
|
+
limit: number;
|
|
332
|
+
timeWindowMs: number;
|
|
333
|
+
}>>;
|
|
126
334
|
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/component/lib.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;iBA6CvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;iBAexB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;iBAiC5B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;mBAwCxB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;GAmFvB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;GA4HrB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;GAoDxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;GAqD5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;GAgCpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;GA8BxB,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW;;;;;;;;;GA4DtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;GAgEtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;GAiE9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;GA+B7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;GA+B7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;KA8C9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;KA4C1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;GAkDxB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;KAsGlC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;GA+ClC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;GA6C9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;GA8B/B,CAAC"}
|