@hogsend/engine 0.40.0 → 0.42.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 +11 -8
- package/src/buckets/check-membership.ts +6 -1
- package/src/campaigns/cohort-sql.ts +198 -0
- package/src/campaigns/define-campaign.ts +207 -28
- package/src/campaigns/reconcile.ts +105 -11
- package/src/campaigns/steps.ts +48 -0
- package/src/connectors/define-action.ts +70 -0
- package/src/container.ts +124 -42
- package/src/destinations/presets/posthog.ts +7 -1
- package/src/index.ts +96 -2
- package/src/journeys/constants.ts +10 -0
- package/src/journeys/define-journey.ts +14 -405
- package/src/journeys/execute-journey-run.ts +641 -0
- package/src/journeys/graph/build-graph.ts +212 -56
- package/src/journeys/journey-boundary.ts +54 -0
- package/src/journeys/journey-context.ts +406 -59
- package/src/journeys/record-once.ts +110 -0
- package/src/lib/blueprint-lock.ts +21 -0
- package/src/lib/blueprints.ts +803 -0
- package/src/lib/campaign-send-key.ts +58 -0
- package/src/lib/connector-actions.ts +203 -19
- package/src/lib/contacts.ts +54 -0
- package/src/lib/email-service-types.ts +4 -1
- package/src/lib/email.ts +13 -2
- package/src/lib/event-names.ts +143 -0
- package/src/lib/feed.ts +77 -57
- package/src/lib/frequency-cap.ts +45 -15
- package/src/lib/hatchet-duration.ts +22 -0
- package/src/lib/html.ts +1 -0
- package/src/lib/ingestion.ts +145 -4
- package/src/lib/journey-suppress.ts +87 -0
- package/src/lib/links.ts +204 -18
- package/src/lib/outbound.ts +20 -0
- package/src/lib/preferences.ts +80 -1
- package/src/lib/tracked.ts +44 -29
- package/src/lib/tracking-event-names.ts +8 -0
- package/src/lib/tracking.ts +1 -5
- package/src/lib/webhook-signing.ts +6 -1
- package/src/lists/channels.ts +75 -0
- package/src/lists/define-list.ts +34 -0
- package/src/lists/registry.ts +29 -2
- package/src/mcp/authoring-guide.ts +160 -0
- package/src/mcp/blueprint-tools.ts +390 -0
- package/src/middleware/require-admin.ts +13 -0
- package/src/routes/admin/api-keys.ts +72 -0
- package/src/routes/admin/blueprints.ts +795 -0
- package/src/routes/admin/campaigns.ts +179 -3
- package/src/routes/admin/emails.ts +13 -0
- package/src/routes/admin/events.ts +55 -0
- package/src/routes/admin/index.ts +4 -0
- package/src/routes/admin/journeys.ts +4 -2
- package/src/routes/admin/links.ts +303 -36
- package/src/routes/admin/lists.ts +51 -0
- package/src/routes/campaigns/index.ts +44 -6
- package/src/routes/email/preferences.ts +50 -13
- package/src/routes/feed/recipient.ts +2 -43
- package/src/routes/index.ts +6 -0
- package/src/routes/lists/index.ts +138 -18
- package/src/routes/tracking/arrive.ts +260 -0
- package/src/routes/tracking/click-pipeline.ts +329 -0
- package/src/routes/tracking/click.ts +5 -270
- package/src/routes/tracking/index.ts +2 -0
- package/src/routes/tracking/vanity.ts +64 -0
- package/src/worker.ts +5 -0
- package/src/workflows/bucket-backfill.ts +4 -2
- package/src/workflows/bucket-reconcile.ts +11 -4
- package/src/workflows/check-alerts.ts +130 -1
- package/src/workflows/journey-blueprint-interpreter.ts +656 -0
- package/src/workflows/send-campaign.ts +574 -180
|
@@ -20,6 +20,50 @@ const apiKeySchema = z.object({
|
|
|
20
20
|
createdAt: z.string(),
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
// The authenticated credential's identity, discriminated on how the request
|
|
24
|
+
// authenticated. The Bearer path echoes the key requireAdmin already resolved
|
|
25
|
+
// (id/name/scopes only — NEVER the key material); the cookie path echoes the
|
|
26
|
+
// session user.
|
|
27
|
+
const selfApiKeyActorSchema = z.object({
|
|
28
|
+
actor: z.literal("api-key"),
|
|
29
|
+
id: z.string(),
|
|
30
|
+
name: z.string(),
|
|
31
|
+
scopes: z.array(z.string()),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const selfSessionActorSchema = z.object({
|
|
35
|
+
actor: z.literal("session"),
|
|
36
|
+
email: z.string(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const selfRoute = createRoute({
|
|
40
|
+
method: "get",
|
|
41
|
+
path: "/self",
|
|
42
|
+
tags: ["Admin — API Keys"],
|
|
43
|
+
summary: "Identify the authenticated credential",
|
|
44
|
+
description:
|
|
45
|
+
"Returns the identity this request authenticated as — the resolved API " +
|
|
46
|
+
"key (id, name, scopes; never the key material) for Bearer auth, or the " +
|
|
47
|
+
"session user's email for cookie auth.",
|
|
48
|
+
responses: {
|
|
49
|
+
200: {
|
|
50
|
+
content: {
|
|
51
|
+
"application/json": {
|
|
52
|
+
schema: z.discriminatedUnion("actor", [
|
|
53
|
+
selfApiKeyActorSchema,
|
|
54
|
+
selfSessionActorSchema,
|
|
55
|
+
]),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
description: "The authenticated credential's identity",
|
|
59
|
+
},
|
|
60
|
+
401: {
|
|
61
|
+
content: { "application/json": { schema: errorSchema } },
|
|
62
|
+
description: "No resolved credential on the request",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
23
67
|
const listRoute = createRoute({
|
|
24
68
|
method: "get",
|
|
25
69
|
path: "/",
|
|
@@ -152,6 +196,34 @@ function serializeKey(row: typeof apiKeys.$inferSelect) {
|
|
|
152
196
|
}
|
|
153
197
|
|
|
154
198
|
export const apiKeysRouter = new OpenAPIHono<AppEnv>()
|
|
199
|
+
// Registered before any param route so a literal "self" can never be
|
|
200
|
+
// captured as an {id}.
|
|
201
|
+
.openapi(selfRoute, (c) => {
|
|
202
|
+
const apiKey = c.get("apiKey");
|
|
203
|
+
if (apiKey) {
|
|
204
|
+
return c.json(
|
|
205
|
+
{
|
|
206
|
+
actor: "api-key" as const,
|
|
207
|
+
id: apiKey.id,
|
|
208
|
+
name: apiKey.name,
|
|
209
|
+
scopes: apiKey.scopes,
|
|
210
|
+
},
|
|
211
|
+
200,
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const sessionUser = c.get("user");
|
|
216
|
+
if (sessionUser) {
|
|
217
|
+
return c.json(
|
|
218
|
+
{ actor: "session" as const, email: sessionUser.email },
|
|
219
|
+
200,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// requireAdmin always resolves one of the two before this handler runs —
|
|
224
|
+
// defensive fallback only.
|
|
225
|
+
return c.json({ error: "Unauthorized" }, 401);
|
|
226
|
+
})
|
|
155
227
|
.openapi(listRoute, async (c) => {
|
|
156
228
|
const { db } = c.get("container");
|
|
157
229
|
const { limit, offset, includeRevoked } = c.req.valid("query");
|