UNPKG

@topgroup/diginext

Version:

A BUILD SERVER & CLI to deploy apps to any Kubernetes clusters.

423 lines 12.6 kB
import { z } from "zod"; import type { INotification } from "../entities/Notification"; import type { IWebhook } from "../entities/Webhook"; import type { IQueryFilter, IQueryOptions } from "../interfaces"; import { type Ownership } from "../interfaces/SystemTypes"; import BaseService from "./BaseService"; export declare const sendNotificationDataSchema: z.ZodObject<{ /** * User ID of the sender */ from: z.ZodString; /** * User ID of the recipient */ to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>; /** * Notification's title */ title: z.ZodString; /** * Notification's content */ message: z.ZodOptional<z.ZodString>; /** * The system event that triggered the notification */ events: z.ZodOptional<z.ZodArray<z.ZodEnum<["build_status", "deploy_status", "dbbackup_status", "app_status", "project_status", "environment_status"]>, "many">>; /** * Target channels */ channels: z.ZodOptional<z.ZodArray<z.ZodEnum<["http_callback", "email", "sms", "web_push", "push_notification", "instant_message"]>, "many">>; /** * Referenced data of a notification */ references: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; /** * Callback URL of a notification */ url: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { url?: string; message?: string; from?: string; events?: ("build_status" | "deploy_status" | "dbbackup_status" | "app_status" | "project_status" | "environment_status")[]; channels?: ("email" | "http_callback" | "sms" | "web_push" | "push_notification" | "instant_message")[]; to?: string | string[]; title?: string; references?: Record<string, any>; }, { url?: string; message?: string; from?: string; events?: ("build_status" | "deploy_status" | "dbbackup_status" | "app_status" | "project_status" | "environment_status")[]; channels?: ("email" | "http_callback" | "sms" | "web_push" | "push_notification" | "instant_message")[]; to?: string | string[]; title?: string; references?: Record<string, any>; }>; export type SendNotificationData = z.infer<typeof sendNotificationDataSchema>; export declare const sendNotificationWebhookDataSchema: z.ZodObject<Pick<{ /** * User ID of the sender */ from: z.ZodString; /** * User ID of the recipient */ to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>; /** * Notification's title */ title: z.ZodString; /** * Notification's content */ message: z.ZodOptional<z.ZodString>; /** * The system event that triggered the notification */ events: z.ZodOptional<z.ZodArray<z.ZodEnum<["build_status", "deploy_status", "dbbackup_status", "app_status", "project_status", "environment_status"]>, "many">>; /** * Target channels */ channels: z.ZodOptional<z.ZodArray<z.ZodEnum<["http_callback", "email", "sms", "web_push", "push_notification", "instant_message"]>, "many">>; /** * Referenced data of a notification */ references: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; /** * Callback URL of a notification */ url: z.ZodOptional<z.ZodString>; }, "url" | "message" | "from" | "to" | "title" | "references">, "strip", z.ZodTypeAny, { url?: string; message?: string; from?: string; to?: string | string[]; title?: string; references?: Record<string, any>; }, { url?: string; message?: string; from?: string; to?: string | string[]; title?: string; references?: Record<string, any>; }>; export type SendNotificationWebhookData = z.infer<typeof sendNotificationWebhookDataSchema>; export declare const jojoWebhookSchema: z.ZodObject<{ channelId: z.ZodOptional<z.ZodString>; content: z.ZodOptional<z.ZodString>; embeds: z.ZodOptional<z.ZodArray<z.ZodObject<{ title: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; color: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; image: z.ZodOptional<z.ZodObject<{ url: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { url?: string; }, { url?: string; }>>; author: z.ZodOptional<z.ZodObject<{ name: z.ZodOptional<z.ZodString>; icon_url: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name?: string; icon_url?: string; }, { name?: string; icon_url?: string; }>>; footer: z.ZodOptional<z.ZodObject<{ text: z.ZodOptional<z.ZodString>; icon_url: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { text?: string; icon_url?: string; }, { text?: string; icon_url?: string; }>>; fields: z.ZodOptional<z.ZodArray<z.ZodObject<{ name: z.ZodOptional<z.ZodString>; value: z.ZodOptional<z.ZodString>; inline: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name?: string; value?: string; inline?: boolean; }, { name?: string; value?: string; inline?: boolean; }>, "many">>; }, "strip", z.ZodTypeAny, { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }, { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }>, "many">>; components: z.ZodOptional<z.ZodArray<z.ZodOptional<z.ZodAny>, "many">>; }, "strip", z.ZodTypeAny, { content?: string; channelId?: string; embeds?: { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }[]; components?: any[]; }, { content?: string; channelId?: string; embeds?: { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }[]; components?: any[]; }>; export type JojoWebhookData = z.infer<typeof jojoWebhookSchema>; export declare const sendJojoNotificationDataSchema: z.ZodObject<Pick<{ channelId: z.ZodOptional<z.ZodString>; content: z.ZodOptional<z.ZodString>; embeds: z.ZodOptional<z.ZodArray<z.ZodObject<{ title: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; color: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; image: z.ZodOptional<z.ZodObject<{ url: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { url?: string; }, { url?: string; }>>; author: z.ZodOptional<z.ZodObject<{ name: z.ZodOptional<z.ZodString>; icon_url: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name?: string; icon_url?: string; }, { name?: string; icon_url?: string; }>>; footer: z.ZodOptional<z.ZodObject<{ text: z.ZodOptional<z.ZodString>; icon_url: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { text?: string; icon_url?: string; }, { text?: string; icon_url?: string; }>>; fields: z.ZodOptional<z.ZodArray<z.ZodObject<{ name: z.ZodOptional<z.ZodString>; value: z.ZodOptional<z.ZodString>; inline: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; }, "strip", z.ZodTypeAny, { name?: string; value?: string; inline?: boolean; }, { name?: string; value?: string; inline?: boolean; }>, "many">>; }, "strip", z.ZodTypeAny, { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }, { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }>, "many">>; components: z.ZodOptional<z.ZodArray<z.ZodOptional<z.ZodAny>, "many">>; }, "content" | "channelId" | "embeds" | "components">, "strip", z.ZodTypeAny, { content?: string; channelId?: string; embeds?: { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }[]; components?: any[]; }, { content?: string; channelId?: string; embeds?: { author?: { name?: string; icon_url?: string; }; url?: string; description?: string; fields?: { name?: string; value?: string; inline?: boolean; }[]; image?: { url?: string; }; title?: string; footer?: { text?: string; icon_url?: string; }; color?: number; }[]; components?: any[]; }>; export type SendJojoNotificationData = z.infer<typeof sendJojoNotificationDataSchema>; export declare class NotificationService extends BaseService<INotification> { private readonly JOJO_API_KEY; private readonly JOJO_API_URL; constructor(ownership?: Ownership); /** * Send the notification via webhook */ webhookSend(webhook: IWebhook, data: SendNotificationWebhookData, options?: IQueryOptions): Promise<void | INotification | INotification[]>; /** * Send the notification directly */ send(data: SendNotificationData, options?: IQueryOptions): Promise<void | INotification | INotification[]>; /** * Mark the notification as read. * @param id - Notification ID */ markAsRead(filter?: IQueryFilter<INotification>, options?: IQueryOptions): Promise<INotification>; /** * Send the notification to Jojo */ sendToJojo(data: SendJojoNotificationData, options?: IQueryOptions): Promise<any>; } //# sourceMappingURL=NotificationService.d.ts.map