Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
import z from "zod";
/**
* Zod schema for the HMAC signature algorithm pin. Matches the values
* accepted by `@suaveplan/webhook-client`'s `WebhookSignatureAlgorithm`.
*/
export const WebhookSignatureAlgorithmSchema = z.enum(["sha256", "sha512"]);
/**
* Zod schema for the persistent `WebhookEndpoint` shape. Used by the
* `EndpointStore` conformance harness and by the read-side `GET` routes.
*/
export const WebhookEndpointSchema = z.object({
id: z.string().min(1),
tenantId: z.string().min(1).nullable(),
url: z.string().url(),
secret: z.string().min(8),
events: z.array(z.string().min(1)).min(1).readonly(),
description: z.string().optional(),
headers: z.record(z.string(), z.string()).optional(),
algorithm: WebhookSignatureAlgorithmSchema,
active: z.boolean(),
createdAt: z.string(),
updatedAt: z.string(),
});
/**
* Zod schema for `POST /webhooks` request bodies. Derives `id`,
* `createdAt`, `updatedAt`, `algorithm` (default `"sha256"`), and
* `active` (default `true`).
*/
export const CreateEndpointInputSchema = z.object({
tenantId: z.string().min(1).nullable(),
url: z.string().url(),
secret: z.string().min(8),
events: z.array(z.string().min(1)).min(1),
description: z.string().optional(),
headers: z.record(z.string(), z.string()).optional(),
algorithm: WebhookSignatureAlgorithmSchema.optional(),
active: z.boolean().optional(),
});
/**
* Zod schema for `PATCH /webhooks/:id` request bodies. Every field is
* optional and `tenantId` is intentionally absent (cross-tenant moves
* require delete + recreate).
*/
export const UpdateEndpointInputSchema = z.object({
url: z.string().url().optional(),
secret: z.string().min(8).optional(),
events: z.array(z.string().min(1)).min(1).optional(),
description: z.string().optional(),
headers: z.record(z.string(), z.string()).optional(),
algorithm: WebhookSignatureAlgorithmSchema.optional(),
active: z.boolean().optional(),
});
export type WebhookEndpointShape = z.infer<typeof WebhookEndpointSchema>;
export type CreateEndpointInputShape = z.infer<
typeof CreateEndpointInputSchema
>;
export type UpdateEndpointInputShape = z.infer<
typeof UpdateEndpointInputSchema
>;