mirror of
https://github.com/logto-io/logto.git
synced 2025-02-10 21:58:23 -05:00
feat(core): init hooks schemas
This commit is contained in:
parent
aeb4fbc14a
commit
54c03f1a90
2 changed files with 30 additions and 0 deletions
|
@ -200,3 +200,24 @@ export type Translation = {
|
||||||
export const translationGuard: z.ZodType<Translation> = z.lazy(() =>
|
export const translationGuard: z.ZodType<Translation> = z.lazy(() =>
|
||||||
z.record(z.string().or(translationGuard))
|
z.record(z.string().or(translationGuard))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hooks
|
||||||
|
*/
|
||||||
|
|
||||||
|
export type HookConfig = {
|
||||||
|
/** We don't need `type` since v1 only has web hook */
|
||||||
|
// type: 'web';
|
||||||
|
/** Method fixed to `POST` */
|
||||||
|
url: string;
|
||||||
|
/** Additional headers that attach to the request */
|
||||||
|
headers: Record<string, string>;
|
||||||
|
/** Only retry when status code >= 500 */
|
||||||
|
retries: number; //
|
||||||
|
};
|
||||||
|
|
||||||
|
export const hookConfigGuard: z.ZodType<HookConfig> = z.object({
|
||||||
|
url: z.string(),
|
||||||
|
headers: z.record(z.string()),
|
||||||
|
retries: z.number(),
|
||||||
|
});
|
||||||
|
|
9
packages/schemas/tables/hooks.sql
Normal file
9
packages/schemas/tables/hooks.sql
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
create table hooks (
|
||||||
|
id varchar(128) not null,
|
||||||
|
event varchar(128) not null,
|
||||||
|
config jsonb /* @use HookConfig */ not null,
|
||||||
|
created_at timestamptz not null default(now()),
|
||||||
|
primary key (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
create index hooks__event on hooks (event);
|
Loading…
Add table
Reference in a new issue