@k-msg/webhook 0.29.7 → 0.29.8

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.
@@ -37,75 +37,6 @@ export declare enum WebhookEventType {
37
37
  ANOMALY_DETECTED = "analytics.anomaly_detected",
38
38
  THRESHOLD_EXCEEDED = "analytics.threshold_exceeded"
39
39
  }
40
- export interface WebhookEvent<T = any> {
41
- id: string;
42
- type: WebhookEventType;
43
- timestamp: Date;
44
- data: T;
45
- metadata: {
46
- providerId?: string;
47
- channelId?: string;
48
- templateId?: string;
49
- messageId?: string;
50
- userId?: string;
51
- organizationId?: string;
52
- correlationId?: string;
53
- retryCount?: number;
54
- };
55
- version: string;
56
- }
57
- export interface WebhookEndpoint {
58
- id: string;
59
- url: string;
60
- name?: string;
61
- description?: string;
62
- active: boolean;
63
- events: WebhookEventType[];
64
- headers?: Record<string, string>;
65
- secret?: string;
66
- retryConfig?: {
67
- maxRetries: number;
68
- retryDelayMs: number;
69
- backoffMultiplier: number;
70
- };
71
- filters?: {
72
- providerId?: string[];
73
- channelId?: string[];
74
- templateId?: string[];
75
- };
76
- createdAt: Date;
77
- updatedAt: Date;
78
- lastTriggeredAt?: Date;
79
- status: "active" | "inactive" | "error" | "suspended";
80
- }
81
- export interface WebhookDelivery {
82
- id: string;
83
- endpointId: string;
84
- eventId: string;
85
- /**
86
- * Optional event type for filtering/stats.
87
- * (Helpful because `payload` is a JSON string and timestamps need revival when parsed.)
88
- */
89
- eventType?: WebhookEventType;
90
- url: string;
91
- httpMethod: "POST" | "PUT" | "PATCH";
92
- headers: Record<string, string>;
93
- payload: string;
94
- attempts: WebhookAttempt[];
95
- status: "pending" | "success" | "failed" | "exhausted";
96
- createdAt: Date;
97
- completedAt?: Date;
98
- nextRetryAt?: Date;
99
- }
100
- export interface WebhookAttempt {
101
- attemptNumber: number;
102
- timestamp: Date;
103
- httpStatus?: number;
104
- responseBody?: string;
105
- responseHeaders?: Record<string, string>;
106
- error?: string;
107
- latencyMs: number;
108
- }
109
40
  export interface WebhookSecurity {
110
41
  algorithm: "sha256" | "sha1";
111
42
  header: string;
@@ -142,9 +73,18 @@ export interface WebhookTestResult {
142
73
  error?: string;
143
74
  testedAt: Date;
144
75
  }
76
+ export declare const WebhookAttemptSchema: z.ZodMiniObject<{
77
+ attemptNumber: z.ZodMiniNumber<number>;
78
+ timestamp: z.ZodMiniDate<Date>;
79
+ httpStatus: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
80
+ responseBody: z.ZodMiniOptional<z.ZodMiniString<string>>;
81
+ responseHeaders: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
82
+ error: z.ZodMiniOptional<z.ZodMiniString<string>>;
83
+ latencyMs: z.ZodMiniNumber<number>;
84
+ }, z.core.$strip>;
145
85
  export declare const WebhookEventSchema: z.ZodMiniObject<{
146
86
  id: z.ZodMiniString<string>;
147
- type: z.ZodMiniString<string>;
87
+ type: z.ZodMiniEnum<typeof WebhookEventType>;
148
88
  timestamp: z.ZodMiniPipe<z.ZodMiniTransform<unknown, unknown>, z.ZodMiniDate<Date>>;
149
89
  data: z.ZodMiniAny;
150
90
  metadata: z.ZodMiniObject<{
@@ -165,7 +105,7 @@ export declare const WebhookEndpointSchema: z.ZodMiniObject<{
165
105
  name: z.ZodMiniOptional<z.ZodMiniString<string>>;
166
106
  description: z.ZodMiniOptional<z.ZodMiniString<string>>;
167
107
  active: z.ZodMiniBoolean<boolean>;
168
- events: z.ZodMiniArray<z.ZodMiniString<string>>;
108
+ events: z.ZodMiniArray<z.ZodMiniEnum<typeof WebhookEventType>>;
169
109
  headers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
170
110
  secret: z.ZodMiniOptional<z.ZodMiniString<string>>;
171
111
  retryConfig: z.ZodMiniOptional<z.ZodMiniObject<{
@@ -183,8 +123,8 @@ export declare const WebhookEndpointSchema: z.ZodMiniObject<{
183
123
  lastTriggeredAt: z.ZodMiniOptional<z.ZodMiniDate<Date>>;
184
124
  status: z.ZodMiniEnum<{
185
125
  active: "active";
186
- inactive: "inactive";
187
126
  error: "error";
127
+ inactive: "inactive";
188
128
  suspended: "suspended";
189
129
  }>;
190
130
  }, z.core.$strip>;
@@ -192,12 +132,12 @@ export declare const WebhookDeliverySchema: z.ZodMiniObject<{
192
132
  id: z.ZodMiniString<string>;
193
133
  endpointId: z.ZodMiniString<string>;
194
134
  eventId: z.ZodMiniString<string>;
195
- eventType: z.ZodMiniOptional<z.ZodMiniString<string>>;
135
+ eventType: z.ZodMiniOptional<z.ZodMiniEnum<typeof WebhookEventType>>;
196
136
  url: z.ZodMiniURL;
197
137
  httpMethod: z.ZodMiniEnum<{
138
+ PATCH: "PATCH";
198
139
  POST: "POST";
199
140
  PUT: "PUT";
200
- PATCH: "PATCH";
201
141
  }>;
202
142
  headers: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
203
143
  payload: z.ZodMiniString<string>;
@@ -211,15 +151,21 @@ export declare const WebhookDeliverySchema: z.ZodMiniObject<{
211
151
  latencyMs: z.ZodMiniNumber<number>;
212
152
  }, z.core.$strip>>;
213
153
  status: z.ZodMiniEnum<{
154
+ exhausted: "exhausted";
155
+ failed: "failed";
214
156
  pending: "pending";
215
157
  success: "success";
216
- failed: "failed";
217
- exhausted: "exhausted";
218
158
  }>;
219
159
  createdAt: z.ZodMiniDate<Date>;
220
160
  completedAt: z.ZodMiniOptional<z.ZodMiniDate<Date>>;
221
161
  nextRetryAt: z.ZodMiniOptional<z.ZodMiniDate<Date>>;
222
162
  }, z.core.$strip>;
163
+ export type WebhookEvent<T = any> = Omit<WebhookEventData, "data"> & {
164
+ data: T;
165
+ };
166
+ export type WebhookEndpoint = z.infer<typeof WebhookEndpointSchema>;
167
+ export type WebhookAttempt = z.infer<typeof WebhookAttemptSchema>;
168
+ export type WebhookDelivery = z.infer<typeof WebhookDeliverySchema>;
223
169
  export type WebhookEventData = z.infer<typeof WebhookEventSchema>;
224
- export type WebhookEndpointData = z.infer<typeof WebhookEndpointSchema>;
225
- export type WebhookDeliveryData = z.infer<typeof WebhookDeliverySchema>;
170
+ export type WebhookEndpointData = WebhookEndpoint;
171
+ export type WebhookDeliveryData = WebhookDelivery;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@k-msg/webhook",
3
- "version": "0.29.7",
4
- "packageManager": "bun@1.3.11",
3
+ "version": "0.29.8",
4
+ "packageManager": "bun@1.3.13",
5
5
  "description": "Webhook system for real-time message event notifications",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -35,18 +35,19 @@
35
35
  "dev": "tsc --watch",
36
36
  "test": "bun test",
37
37
  "test:unit": "bun test --testPathPattern='.*\\.test\\.(ts|js)$' --testTimeout=5000",
38
- "typecheck": "tsc --noEmit",
38
+ "typecheck": "ttsc --noEmit",
39
39
  "clean": "rm -rf dist tsconfig.tsbuildinfo",
40
40
  "pack": "bun pm pack",
41
41
  "publish": "bun publish --access public"
42
42
  },
43
43
  "dependencies": {
44
- "@k-msg/core": "0.29.7",
44
+ "@k-msg/core": "0.29.8",
45
45
  "@noble/hashes": "^1.8.0",
46
- "zod": "^4.0.14"
46
+ "zod": "^4.4.3"
47
47
  },
48
48
  "devDependencies": {
49
- "typescript": "^6.0.3",
49
+ "ttsc": "^0.18.1",
50
+ "typescript": "^7.0.2",
50
51
  "@types/bun": "^1.3.14"
51
52
  },
52
53
  "keywords": [