@checkstack/integration-backend 0.0.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/src/schema.ts ADDED
@@ -0,0 +1,78 @@
1
+ import {
2
+ pgTable,
3
+ text,
4
+ boolean,
5
+ timestamp,
6
+ jsonb,
7
+ integer,
8
+ } from "drizzle-orm/pg-core";
9
+
10
+ /**
11
+ * Webhook subscriptions - admin-configured routing rules
12
+ */
13
+ export const webhookSubscriptions = pgTable("webhook_subscriptions", {
14
+ id: text("id")
15
+ .primaryKey()
16
+ .$defaultFn(() => crypto.randomUUID()),
17
+ name: text("name").notNull(),
18
+ description: text("description"),
19
+
20
+ /** Fully qualified provider ID: {pluginId}.{providerId} */
21
+ providerId: text("provider_id").notNull(),
22
+
23
+ /** Provider-specific configuration (encrypted if contains secrets) */
24
+ providerConfig: jsonb("provider_config")
25
+ .notNull()
26
+ .$type<Record<string, unknown>>(),
27
+
28
+ /** Single event to subscribe to (fully qualified event ID) */
29
+ eventId: text("event_id").notNull(),
30
+
31
+ /** Optional: Filter by system IDs */
32
+ systemFilter: text("system_filter").array(),
33
+
34
+ /** Subscription enabled state */
35
+ enabled: boolean("enabled").notNull().default(true),
36
+
37
+ createdAt: timestamp("created_at").defaultNow().notNull(),
38
+ updatedAt: timestamp("updated_at").defaultNow().notNull(),
39
+ });
40
+
41
+ /**
42
+ * Delivery logs - track webhook delivery attempts and results
43
+ */
44
+ export const deliveryLogs = pgTable("delivery_logs", {
45
+ id: text("id")
46
+ .primaryKey()
47
+ .$defaultFn(() => crypto.randomUUID()),
48
+ subscriptionId: text("subscription_id")
49
+ .notNull()
50
+ .references(() => webhookSubscriptions.id, { onDelete: "cascade" }),
51
+
52
+ eventType: text("event_type").notNull(),
53
+ eventPayload: jsonb("event_payload")
54
+ .notNull()
55
+ .$type<Record<string, unknown>>(),
56
+
57
+ /** Delivery status: pending, success, failed, retrying */
58
+ status: text("status")
59
+ .notNull()
60
+ .$type<"pending" | "success" | "failed" | "retrying">(),
61
+
62
+ /** Number of delivery attempts */
63
+ attempts: integer("attempts").notNull().default(0),
64
+
65
+ /** Timestamp of last delivery attempt */
66
+ lastAttemptAt: timestamp("last_attempt_at"),
67
+
68
+ /** Next retry timestamp (if status is retrying) */
69
+ nextRetryAt: timestamp("next_retry_at"),
70
+
71
+ /** External ID returned by the target system (e.g., Jira issue key) */
72
+ externalId: text("external_id"),
73
+
74
+ /** Error message from last failed attempt */
75
+ errorMessage: text("error_message"),
76
+
77
+ createdAt: timestamp("created_at").defaultNow().notNull(),
78
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "@checkstack/tsconfig/backend.json",
3
+ "include": [
4
+ "src"
5
+ ]
6
+ }