@better-webhook/cli 3.3.0 → 3.4.1

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.
@@ -0,0 +1,299 @@
1
+ import { z } from "zod";
2
+ export declare const HttpMethodSchema: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]>;
3
+ export type HttpMethod = z.infer<typeof HttpMethodSchema>;
4
+ export declare const HeaderEntrySchema: z.ZodObject<{
5
+ key: z.ZodString;
6
+ value: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ value: string;
9
+ key: string;
10
+ }, {
11
+ value: string;
12
+ key: string;
13
+ }>;
14
+ export type HeaderEntry = z.infer<typeof HeaderEntrySchema>;
15
+ export declare const WebhookProviderSchema: z.ZodEnum<["stripe", "github", "shopify", "twilio", "ragie", "sendgrid", "slack", "discord", "linear", "clerk", "custom"]>;
16
+ export type WebhookProvider = z.infer<typeof WebhookProviderSchema>;
17
+ export declare const TemplateMetadataSchema: z.ZodObject<{
18
+ id: z.ZodString;
19
+ name: z.ZodString;
20
+ description: z.ZodOptional<z.ZodString>;
21
+ provider: z.ZodEnum<["stripe", "github", "shopify", "twilio", "ragie", "sendgrid", "slack", "discord", "linear", "clerk", "custom"]>;
22
+ event: z.ZodString;
23
+ file: z.ZodString;
24
+ version: z.ZodOptional<z.ZodString>;
25
+ docsUrl: z.ZodOptional<z.ZodString>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ id: string;
28
+ name: string;
29
+ provider: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom";
30
+ event: string;
31
+ file: string;
32
+ description?: string | undefined;
33
+ version?: string | undefined;
34
+ docsUrl?: string | undefined;
35
+ }, {
36
+ id: string;
37
+ name: string;
38
+ provider: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom";
39
+ event: string;
40
+ file: string;
41
+ description?: string | undefined;
42
+ version?: string | undefined;
43
+ docsUrl?: string | undefined;
44
+ }>;
45
+ export type TemplateMetadata = z.infer<typeof TemplateMetadataSchema>;
46
+ export declare const TemplatesIndexSchema: z.ZodObject<{
47
+ version: z.ZodString;
48
+ templates: z.ZodArray<z.ZodObject<{
49
+ id: z.ZodString;
50
+ name: z.ZodString;
51
+ description: z.ZodOptional<z.ZodString>;
52
+ provider: z.ZodEnum<["stripe", "github", "shopify", "twilio", "ragie", "sendgrid", "slack", "discord", "linear", "clerk", "custom"]>;
53
+ event: z.ZodString;
54
+ file: z.ZodString;
55
+ version: z.ZodOptional<z.ZodString>;
56
+ docsUrl: z.ZodOptional<z.ZodString>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ id: string;
59
+ name: string;
60
+ provider: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom";
61
+ event: string;
62
+ file: string;
63
+ description?: string | undefined;
64
+ version?: string | undefined;
65
+ docsUrl?: string | undefined;
66
+ }, {
67
+ id: string;
68
+ name: string;
69
+ provider: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom";
70
+ event: string;
71
+ file: string;
72
+ description?: string | undefined;
73
+ version?: string | undefined;
74
+ docsUrl?: string | undefined;
75
+ }>, "many">;
76
+ }, "strip", z.ZodTypeAny, {
77
+ version: string;
78
+ templates: {
79
+ id: string;
80
+ name: string;
81
+ provider: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom";
82
+ event: string;
83
+ file: string;
84
+ description?: string | undefined;
85
+ version?: string | undefined;
86
+ docsUrl?: string | undefined;
87
+ }[];
88
+ }, {
89
+ version: string;
90
+ templates: {
91
+ id: string;
92
+ name: string;
93
+ provider: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom";
94
+ event: string;
95
+ file: string;
96
+ description?: string | undefined;
97
+ version?: string | undefined;
98
+ docsUrl?: string | undefined;
99
+ }[];
100
+ }>;
101
+ export type TemplatesIndex = z.infer<typeof TemplatesIndexSchema>;
102
+ export declare const WebhookTemplateSchema: z.ZodObject<{
103
+ url: z.ZodOptional<z.ZodString>;
104
+ method: z.ZodDefault<z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]>>;
105
+ headers: z.ZodDefault<z.ZodArray<z.ZodObject<{
106
+ key: z.ZodString;
107
+ value: z.ZodString;
108
+ }, "strip", z.ZodTypeAny, {
109
+ value: string;
110
+ key: string;
111
+ }, {
112
+ value: string;
113
+ key: string;
114
+ }>, "many">>;
115
+ body: z.ZodOptional<z.ZodAny>;
116
+ provider: z.ZodOptional<z.ZodEnum<["stripe", "github", "shopify", "twilio", "ragie", "sendgrid", "slack", "discord", "linear", "clerk", "custom"]>>;
117
+ event: z.ZodOptional<z.ZodString>;
118
+ description: z.ZodOptional<z.ZodString>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
121
+ headers: {
122
+ value: string;
123
+ key: string;
124
+ }[];
125
+ description?: string | undefined;
126
+ provider?: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom" | undefined;
127
+ event?: string | undefined;
128
+ url?: string | undefined;
129
+ body?: any;
130
+ }, {
131
+ description?: string | undefined;
132
+ provider?: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom" | undefined;
133
+ event?: string | undefined;
134
+ url?: string | undefined;
135
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | undefined;
136
+ headers?: {
137
+ value: string;
138
+ key: string;
139
+ }[] | undefined;
140
+ body?: any;
141
+ }>;
142
+ export type WebhookTemplate = z.infer<typeof WebhookTemplateSchema>;
143
+ export interface LocalTemplate {
144
+ id: string;
145
+ metadata: TemplateMetadata;
146
+ template: WebhookTemplate;
147
+ downloadedAt: string;
148
+ filePath: string;
149
+ }
150
+ export interface RemoteTemplate {
151
+ metadata: TemplateMetadata;
152
+ isDownloaded: boolean;
153
+ }
154
+ export declare const CapturedWebhookSchema: z.ZodObject<{
155
+ id: z.ZodString;
156
+ timestamp: z.ZodString;
157
+ method: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]>;
158
+ url: z.ZodString;
159
+ path: z.ZodString;
160
+ headers: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
161
+ body: z.ZodOptional<z.ZodAny>;
162
+ rawBody: z.ZodString;
163
+ query: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
164
+ provider: z.ZodOptional<z.ZodEnum<["stripe", "github", "shopify", "twilio", "ragie", "sendgrid", "slack", "discord", "linear", "clerk", "custom"]>>;
165
+ contentType: z.ZodOptional<z.ZodString>;
166
+ contentLength: z.ZodOptional<z.ZodNumber>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ path: string;
169
+ id: string;
170
+ url: string;
171
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
172
+ headers: Record<string, string | string[]>;
173
+ timestamp: string;
174
+ rawBody: string;
175
+ query: Record<string, string | string[]>;
176
+ provider?: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom" | undefined;
177
+ body?: any;
178
+ contentType?: string | undefined;
179
+ contentLength?: number | undefined;
180
+ }, {
181
+ path: string;
182
+ id: string;
183
+ url: string;
184
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
185
+ headers: Record<string, string | string[]>;
186
+ timestamp: string;
187
+ rawBody: string;
188
+ query: Record<string, string | string[]>;
189
+ provider?: "stripe" | "github" | "shopify" | "twilio" | "ragie" | "sendgrid" | "slack" | "discord" | "linear" | "clerk" | "custom" | undefined;
190
+ body?: any;
191
+ contentType?: string | undefined;
192
+ contentLength?: number | undefined;
193
+ }>;
194
+ export type CapturedWebhook = z.infer<typeof CapturedWebhookSchema>;
195
+ export interface CaptureFile {
196
+ file: string;
197
+ capture: CapturedWebhook;
198
+ }
199
+ export interface WebhookExecutionOptions {
200
+ url: string;
201
+ method?: HttpMethod;
202
+ headers?: HeaderEntry[];
203
+ body?: unknown;
204
+ secret?: string;
205
+ provider?: WebhookProvider;
206
+ timeout?: number;
207
+ }
208
+ export interface WebhookExecutionResult {
209
+ status: number;
210
+ statusText: string;
211
+ headers: Record<string, string | string[]>;
212
+ body: unknown;
213
+ bodyText: string;
214
+ json?: unknown;
215
+ duration: number;
216
+ }
217
+ export interface ReplayOptions {
218
+ targetUrl: string;
219
+ method?: HttpMethod;
220
+ headers?: HeaderEntry[];
221
+ }
222
+ export declare const ConfigSchema: z.ZodObject<{
223
+ version: z.ZodDefault<z.ZodString>;
224
+ templatesDir: z.ZodOptional<z.ZodString>;
225
+ capturesDir: z.ZodOptional<z.ZodString>;
226
+ defaultTargetUrl: z.ZodOptional<z.ZodString>;
227
+ secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
228
+ dashboard: z.ZodOptional<z.ZodObject<{
229
+ port: z.ZodDefault<z.ZodNumber>;
230
+ host: z.ZodDefault<z.ZodString>;
231
+ }, "strip", z.ZodTypeAny, {
232
+ port: number;
233
+ host: string;
234
+ }, {
235
+ port?: number | undefined;
236
+ host?: string | undefined;
237
+ }>>;
238
+ capture: z.ZodOptional<z.ZodObject<{
239
+ port: z.ZodDefault<z.ZodNumber>;
240
+ host: z.ZodDefault<z.ZodString>;
241
+ }, "strip", z.ZodTypeAny, {
242
+ port: number;
243
+ host: string;
244
+ }, {
245
+ port?: number | undefined;
246
+ host?: string | undefined;
247
+ }>>;
248
+ }, "strip", z.ZodTypeAny, {
249
+ version: string;
250
+ templatesDir?: string | undefined;
251
+ capturesDir?: string | undefined;
252
+ defaultTargetUrl?: string | undefined;
253
+ secrets?: Record<string, string> | undefined;
254
+ dashboard?: {
255
+ port: number;
256
+ host: string;
257
+ } | undefined;
258
+ capture?: {
259
+ port: number;
260
+ host: string;
261
+ } | undefined;
262
+ }, {
263
+ version?: string | undefined;
264
+ templatesDir?: string | undefined;
265
+ capturesDir?: string | undefined;
266
+ defaultTargetUrl?: string | undefined;
267
+ secrets?: Record<string, string> | undefined;
268
+ dashboard?: {
269
+ port?: number | undefined;
270
+ host?: string | undefined;
271
+ } | undefined;
272
+ capture?: {
273
+ port?: number | undefined;
274
+ host?: string | undefined;
275
+ } | undefined;
276
+ }>;
277
+ export type Config = z.infer<typeof ConfigSchema>;
278
+ export interface DashboardState {
279
+ templates: {
280
+ remote: RemoteTemplate[];
281
+ local: LocalTemplate[];
282
+ };
283
+ captures: CaptureFile[];
284
+ config: Config;
285
+ }
286
+ export interface WebSocketMessage {
287
+ type: "capture" | "templates_updated" | "captures_updated" | "replay_result" | "error";
288
+ payload: unknown;
289
+ }
290
+ export interface SignatureOptions {
291
+ provider: WebhookProvider;
292
+ payload: string;
293
+ secret: string;
294
+ timestamp?: number;
295
+ }
296
+ export interface GeneratedSignature {
297
+ header: string;
298
+ value: string;
299
+ }
@@ -0,0 +1,86 @@
1
+ import { z } from "zod";
2
+ export const HttpMethodSchema = z.enum([
3
+ "GET",
4
+ "POST",
5
+ "PUT",
6
+ "PATCH",
7
+ "DELETE",
8
+ "HEAD",
9
+ "OPTIONS",
10
+ ]);
11
+ export const HeaderEntrySchema = z.object({
12
+ key: z.string().min(1),
13
+ value: z.string(),
14
+ });
15
+ export const WebhookProviderSchema = z.enum([
16
+ "stripe",
17
+ "github",
18
+ "shopify",
19
+ "twilio",
20
+ "ragie",
21
+ "sendgrid",
22
+ "slack",
23
+ "discord",
24
+ "linear",
25
+ "clerk",
26
+ "custom",
27
+ ]);
28
+ export const TemplateMetadataSchema = z.object({
29
+ id: z.string(),
30
+ name: z.string(),
31
+ description: z.string().optional(),
32
+ provider: WebhookProviderSchema,
33
+ event: z.string(),
34
+ file: z.string(),
35
+ version: z.string().optional(),
36
+ docsUrl: z.string().url().optional(),
37
+ });
38
+ export const TemplatesIndexSchema = z.object({
39
+ version: z.string(),
40
+ templates: z.array(TemplateMetadataSchema),
41
+ });
42
+ export const WebhookTemplateSchema = z.object({
43
+ url: z.string().url().optional(),
44
+ method: HttpMethodSchema.default("POST"),
45
+ headers: z.array(HeaderEntrySchema).default([]),
46
+ body: z.any().optional(),
47
+ provider: WebhookProviderSchema.optional(),
48
+ event: z.string().optional(),
49
+ description: z.string().optional(),
50
+ });
51
+ export const CapturedWebhookSchema = z.object({
52
+ id: z.string(),
53
+ timestamp: z.string(),
54
+ method: HttpMethodSchema,
55
+ url: z.string(),
56
+ path: z.string(),
57
+ headers: z.record(z.union([z.string(), z.array(z.string())])),
58
+ body: z.any().optional(),
59
+ rawBody: z.string(),
60
+ query: z.record(z.union([z.string(), z.array(z.string())])),
61
+ provider: WebhookProviderSchema.optional(),
62
+ contentType: z.string().optional(),
63
+ contentLength: z.number().optional(),
64
+ });
65
+ export const ConfigSchema = z.object({
66
+ version: z.string().default("2.0.0"),
67
+ templatesDir: z.string().optional(),
68
+ capturesDir: z.string().optional(),
69
+ defaultTargetUrl: z.string().url().optional(),
70
+ secrets: z
71
+ .record(z.string())
72
+ .optional()
73
+ .describe("Provider secrets for signature generation"),
74
+ dashboard: z
75
+ .object({
76
+ port: z.number().default(4000),
77
+ host: z.string().default("localhost"),
78
+ })
79
+ .optional(),
80
+ capture: z
81
+ .object({
82
+ port: z.number().default(3001),
83
+ host: z.string().default("0.0.0.0"),
84
+ })
85
+ .optional(),
86
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-webhook/cli",
3
- "version": "3.3.0",
3
+ "version": "3.4.1",
4
4
  "description": "Modern CLI for developing, capturing, and replaying webhooks locally with dashboard UI.",
5
5
  "type": "module",
6
6
  "bin": {