@hogsend/engine 0.5.0 → 0.7.0
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/package.json +6 -6
- package/src/buckets/bucket-access.ts +213 -0
- package/src/buckets/bucket-reactions.ts +225 -0
- package/src/buckets/check-membership.ts +35 -15
- package/src/buckets/define-bucket.ts +79 -8
- package/src/buckets/registry.ts +81 -0
- package/src/container.ts +69 -4
- package/src/env.ts +4 -0
- package/src/index.ts +27 -0
- package/src/journeys/journey-context.ts +5 -1
- package/src/lib/boot.ts +12 -2
- package/src/lib/bucket-emit.ts +49 -7
- package/src/lib/contacts.ts +1083 -18
- package/src/lib/email-service-types.ts +8 -0
- package/src/lib/ingestion.ts +63 -33
- package/src/lib/mailer.ts +1 -0
- package/src/lib/preferences.ts +106 -0
- package/src/lib/tracked.ts +159 -34
- package/src/lib/tracking-events.ts +1 -1
- package/src/lists/define-list.ts +81 -0
- package/src/lists/registry-singleton.ts +39 -0
- package/src/lists/registry.ts +95 -0
- package/src/middleware/api-key.ts +33 -7
- package/src/middleware/rate-limit.ts +73 -49
- package/src/routes/_shared.ts +30 -0
- package/src/routes/admin/api-keys.ts +1 -1
- package/src/routes/admin/buckets.ts +39 -9
- package/src/routes/admin/bulk.ts +7 -3
- package/src/routes/admin/contacts.ts +66 -57
- package/src/routes/admin/events.ts +65 -0
- package/src/routes/admin/journeys.ts +3 -1
- package/src/routes/admin/preferences.ts +2 -2
- package/src/routes/admin/reporting.ts +3 -3
- package/src/routes/admin/timeline.ts +5 -2
- package/src/routes/campaigns/index.ts +252 -0
- package/src/routes/contacts/index.ts +188 -0
- package/src/routes/email/preferences.ts +27 -3
- package/src/routes/email/unsubscribe.ts +7 -49
- package/src/routes/emails/index.ts +133 -0
- package/src/routes/events/index.ts +119 -0
- package/src/routes/index.ts +52 -2
- package/src/routes/lists/index.ts +222 -0
- package/src/worker.ts +25 -2
- package/src/workflows/bucket-backfill.ts +122 -22
- package/src/workflows/bucket-reconcile.ts +225 -12
- package/src/workflows/import-contacts.ts +28 -20
- package/src/workflows/send-campaign.ts +589 -0
- package/src/routes/ingest.ts +0 -71
package/src/routes/ingest.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
2
|
-
import type { AppEnv } from "../app.js";
|
|
3
|
-
import { ingestEvent } from "../lib/ingestion.js";
|
|
4
|
-
|
|
5
|
-
const ingestRequestSchema = z.object({
|
|
6
|
-
event: z.string().min(1),
|
|
7
|
-
userId: z.string().min(1),
|
|
8
|
-
userEmail: z.string().email().optional(),
|
|
9
|
-
properties: z.record(z.string(), z.unknown()).optional(),
|
|
10
|
-
idempotencyKey: z.string().optional(),
|
|
11
|
-
timestamp: z.string().datetime().optional(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const ingestResponseSchema = z.object({
|
|
15
|
-
stored: z.boolean(),
|
|
16
|
-
exits: z.array(
|
|
17
|
-
z.object({
|
|
18
|
-
journeyId: z.string(),
|
|
19
|
-
stateId: z.string(),
|
|
20
|
-
exited: z.boolean(),
|
|
21
|
-
}),
|
|
22
|
-
),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const ingestRoute = createRoute({
|
|
26
|
-
method: "post",
|
|
27
|
-
path: "/",
|
|
28
|
-
tags: ["Ingestion"],
|
|
29
|
-
summary: "Ingest an event",
|
|
30
|
-
description:
|
|
31
|
-
"Receives events from direct API calls. Stores the event, pushes it to Hatchet for journey routing, and processes exit conditions.",
|
|
32
|
-
request: {
|
|
33
|
-
body: {
|
|
34
|
-
content: {
|
|
35
|
-
"application/json": { schema: ingestRequestSchema },
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
responses: {
|
|
40
|
-
202: {
|
|
41
|
-
content: {
|
|
42
|
-
"application/json": { schema: ingestResponseSchema },
|
|
43
|
-
},
|
|
44
|
-
description: "Event accepted and dispatched",
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const ingestRouter = new OpenAPIHono<AppEnv>().openapi(
|
|
50
|
-
ingestRoute,
|
|
51
|
-
async (c) => {
|
|
52
|
-
const body = c.req.valid("json");
|
|
53
|
-
const { db, registry, hatchet, logger } = c.get("container");
|
|
54
|
-
|
|
55
|
-
const result = await ingestEvent({
|
|
56
|
-
db,
|
|
57
|
-
registry,
|
|
58
|
-
hatchet,
|
|
59
|
-
logger,
|
|
60
|
-
event: {
|
|
61
|
-
event: body.event,
|
|
62
|
-
userId: body.userId,
|
|
63
|
-
userEmail: body.userEmail ?? "",
|
|
64
|
-
properties: body.properties ?? {},
|
|
65
|
-
idempotencyKey: body.idempotencyKey,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return c.json(result, 202);
|
|
70
|
-
},
|
|
71
|
-
);
|