/** * @module notification.api * * API parameter types, Arktype validation schemas, and Firebase function definitions for the notification CRUD operations. * * Each param interface has a corresponding Arktype validator (e.g., {@link updateNotificationUserParamsType}). * The {@link NotificationFunctions} abstract class defines the client-callable function map. */ import { type Type } from 'arktype'; import { type TargetModelParams, type FirestoreModelKey, type FirebaseAuthUserId } from '../../common'; import { type ModelFirebaseCrudFunction, type FirebaseFunctionTypeConfigMap, type ModelFirebaseCrudFunctionConfigMap, type ModelFirebaseFunctionMap } from '../../client'; import { type E164PhoneNumber, type EmailAddress, type IndexNumber, type Maybe } from '@dereekb/util'; import { type NotificationTypes } from './notification'; import { type NotificationUserDefaultNotificationBoxRecipientConfig, type NotificationBoxRecipientTemplateConfigArrayEntry, NotificationBoxRecipientFlag } from './notification.config'; import { type NotificationBoxId, type NotificationSummaryId, type NotificationTemplateType } from './notification.id'; import { type NotificationSendEmailMessagesResult, type NotificationSendTextMessagesResult, type NotificationSendNotificationSummaryMessagesResult } from './notification.send'; import { type NotificationTaskServiceTaskHandlerCompletionType } from './notification.task'; export declare const NOTIFICATION_RECIPIENT_NAME_MIN_LENGTH = 0; export declare const NOTIFICATION_RECIPIENT_NAME_MAX_LENGTH = 42; export declare const NOTIFICATION_SUBJECT_MIN_LENGTH = 2; export declare const NOTIFICATION_SUBJECT_MAX_LENGTH = 100; export declare const NOTIFICATION_MESSAGE_MIN_LENGTH = 2; export declare const NOTIFICATION_MESSAGE_MAX_LENGTH = 1000; /** * Config entries are inserted, unless marked as remove. */ export interface NotificationBoxRecipientTemplateConfigArrayEntryParam extends NotificationBoxRecipientTemplateConfigArrayEntry { readonly type: NotificationTemplateType; readonly sd?: Maybe; readonly se?: Maybe; readonly st?: Maybe; readonly sp?: Maybe; readonly sn?: Maybe; readonly remove?: Maybe; } export declare const notificationBoxRecipientTemplateConfigArrayEntryParamType: import("arktype/internal/variants/object.ts").ObjectType<{ type: string; sd?: boolean | null | undefined; se?: boolean | null | undefined; st?: boolean | null | undefined; sp?: boolean | null | undefined; sn?: boolean | null | undefined; remove?: boolean | null | undefined; }, {}>; /** * Used for creating a new NotificationUser for a user. */ export interface CreateNotificationUserParams { readonly uid: FirebaseAuthUserId; } export declare const createNotificationUserParamsType: Type; /** * Used for updating the global or default config on a NotificationUser. */ export interface UpdateNotificationUserDefaultNotificationBoxRecipientConfigParams extends Omit { readonly i?: Maybe; readonly e?: Maybe; readonly t?: Maybe; readonly configs?: Maybe; readonly lk?: Maybe; readonly bk?: Maybe; readonly f?: Maybe; } export declare const updateNotificationUserDefaultNotificationBoxRecipientConfigParamsType: Type; export interface UpdateNotificationBoxRecipientLikeParams { readonly e?: Maybe; readonly t?: Maybe; readonly s?: Maybe; readonly configs?: Maybe; } export declare const updateNotificationBoxRecipientLikeParamsType: Type; /** * Used for updating the target NotificationUserNotificationBoxRecipientConfig. */ export interface UpdateNotificationUserNotificationBoxRecipientParams extends UpdateNotificationBoxRecipientLikeParams { readonly nb: NotificationBoxId; readonly rm?: Maybe; readonly lk?: Maybe; readonly bk?: Maybe; readonly f?: Maybe; readonly deleteRemovedConfig?: Maybe; } export declare const updateNotificationUserNotificationBoxRecipientParamsType: Type; /** * Used for updating the NotificationUser. */ export interface UpdateNotificationUserParams extends TargetModelParams { readonly gc?: Maybe; readonly dc?: Maybe; readonly bc?: Maybe; } export declare const updateNotificationUserParamsType: Type; export type ResyncNotificationUserParams = TargetModelParams; export declare const resyncNotificationUserParamsType: import("arktype/internal/variants/object.ts").ObjectType; export interface ResyncNotificationUserResult { readonly notificationBoxesUpdated: number; } export interface ResyncAllNotificationUserParams { } export declare const resyncAllNotificationUserParamsType: Type; export interface ResyncAllNotificationUsersResult extends ResyncNotificationUserResult { readonly notificationUsersResynced: number; } /** * Used for creating a new NotificationSummary for a model. */ export interface CreateNotificationSummaryParams { readonly model: FirestoreModelKey; } export declare const createNotificationSummaryParamsType: Type; /** * Used for updating the NotificationSummary. */ export interface UpdateNotificationSummaryParams extends TargetModelParams { readonly flagAllRead?: Maybe; readonly setReadAtTime?: Maybe; } export declare const updateNotificationSummaryParamsType: Type; /** * Used for creating or initializing a new NotificationBox for a model. * * Mainly used for testing. Not exposed to the API. * * The preferred way is to create a NotificationBox through a Notification. */ export interface CreateNotificationBoxParams { readonly model: FirestoreModelKey; } export declare const createNotificationBoxParamsType: Type; /** * Used for initializing an uninitialized model like NotificationBox or NotificationSummary. */ export interface InitializeNotificationModelParams extends TargetModelParams { readonly throwErrorIfAlreadyInitialized?: boolean; } export declare const initializeNotificationModelParamsType: Type; export interface InitializeAllApplicableNotificationBoxesParams { } export declare const initializeAllApplicableNotificationBoxesParamsType: Type; export interface InitializeAllApplicableNotificationBoxesResult { readonly notificationBoxesVisited: number; readonly notificationBoxesSucceeded: number; readonly notificationBoxesFailed: number; readonly notificationBoxesAlreadyInitialized: number; } export interface InitializeAllApplicableNotificationSummariesParams { } export declare const initializeAllApplicableNotificationSummariesParamsType: Type; export interface InitializeAllApplicableNotificationSummariesResult { readonly notificationSummariesVisited: number; readonly notificationSummariesSucceeded: number; readonly notificationSummariesFailed: number; readonly notificationSummariesAlreadyInitialized: number; } /** * Used for updating the NotificationBox. */ export type UpdateNotificationBoxParams = TargetModelParams; export declare const updateNotificationBoxParamsType: import("arktype/internal/variants/object.ts").ObjectType; /** * Used to create/update a notification box recipient. */ export interface UpdateNotificationBoxRecipientParams extends UpdateNotificationBoxRecipientLikeParams, TargetModelParams { readonly key: FirestoreModelKey; readonly i?: Maybe; readonly uid?: Maybe; readonly insert?: Maybe; readonly enabled?: Maybe; readonly remove?: Maybe; readonly setExclusion?: Maybe; } export declare const updateNotificationBoxRecipientParamsType: Type; export interface NotificationRecipientParams { readonly uid?: Maybe; readonly un?: Maybe; readonly e?: Maybe; readonly p?: Maybe; } export declare const notificationRecipientParamsType: Type; /** * Used for sending the notification immediately, if it has not already been sent. */ export interface SendNotificationParams extends TargetModelParams { readonly ignoreSendAtThrottle?: Maybe; readonly throwErrorIfSent?: Maybe; } export declare const sendNotificationParamsType: Type; /** * Params class used for subscribing a system user to a NotificationBox for a model. */ export interface AbstractSubscribeToNotificationBoxParams extends TargetModelParams { readonly uid: FirebaseAuthUserId; } export declare const abstractSubscribeToNotificationBoxParamsType: Type; export interface AbstractSubscribeOrUnsubscribeToNotificationBoxParams extends AbstractSubscribeToNotificationBoxParams { readonly unsubscribe?: Maybe; } export declare const abstractSubscribeOrUnsubscribeToNotificationBoxParamsType: Type; export interface SendNotificationResultOnSendCompleteResult { readonly value?: T; readonly error?: Maybe; } /** * Detailed result returned by the `sendNotification` function, describing the outcome of sending a single notification. */ export interface SendNotificationResult { readonly notificationTemplateType: Maybe; readonly isKnownTemplateType: Maybe; readonly isNotificationTask: boolean; readonly isUniqueNotificationTask: boolean; readonly uniqueNotificationTaskConflict: boolean; readonly isConfiguredTemplateType: Maybe; readonly throttled: boolean; readonly success: boolean; readonly notificationTaskCompletionType?: Maybe; readonly notificationTaskPartsRunCount?: Maybe; readonly notificationTaskLoopingProtectionTriggered?: Maybe; readonly notificationMarkedDone: boolean; readonly createdBox: boolean; readonly notificationBoxNeedsInitialization: boolean; readonly deletedNotification: boolean; readonly exists: boolean; readonly boxExists: boolean; readonly tryRun: boolean; readonly sendEmailsResult: Maybe; readonly sendTextsResult: Maybe; readonly sendNotificationSummaryResult: Maybe; readonly loadMessageFunctionFailure: boolean; readonly buildMessageFailure: boolean; readonly onSendAttemptedResult?: Maybe; readonly onSendSuccessResult?: Maybe; } /** * Used for sending queued notifications in the system. */ export interface SendQueuedNotificationsParams { readonly maxSendNotificationLoops?: Maybe; readonly maxParellelSendTasks?: Maybe; readonly sendNotificationLoopsTaskExcessThreshold?: Maybe; } export declare const sendQueuedNotificationsParamsType: Type; /** * Aggregate result of processing the notification send queue, with counts of visited, succeeded, failed, and deleted notifications. */ export interface SendQueuedNotificationsResult extends Omit { readonly excessLoopsDetected: boolean; readonly notificationLoopCount: number; readonly notificationBoxesCreated: number; readonly notificationsVisited: number; readonly notificationTasksVisited: number; readonly notificationsSucceeded: number; readonly notificationsDelayed: number; readonly notificationsFailed: number; readonly notificationsDeleted: number; } /** * Used for sending queued notifications in the system. */ export interface CleanupSentNotificationsParams { } export declare const cleanupSentNotificationsParamsType: Type; export interface CleanupSentNotificationsResult { readonly notificationBoxesUpdatesCount: number; readonly notificationTasksDeletedCount: number; readonly notificationsDeleted: number; readonly notificationWeeksCreated: number; readonly notificationWeeksUpdated: number; } /** * Custom (non-CRUD) function type map for notifications. Currently empty — all operations use the CRUD pattern. */ export type NotificationFunctionTypeMap = {}; export declare const notificationFunctionTypeConfigMap: FirebaseFunctionTypeConfigMap; export type NotificationBoxModelCrudFunctionsConfig = { readonly notificationUser: { update: { _: UpdateNotificationUserParams; resync: [ResyncNotificationUserParams, ResyncNotificationUserResult]; }; }; readonly notificationSummary: { update: { _: UpdateNotificationSummaryParams; }; }; readonly notificationBox: { update: { _: UpdateNotificationBoxParams; recipient: UpdateNotificationBoxRecipientParams; }; }; readonly notification: { update: { send: [SendNotificationParams, SendNotificationResult]; }; }; readonly notificationWeek: null; }; export declare const notificationBoxModelCrudFunctionsConfig: ModelFirebaseCrudFunctionConfigMap; /** * Abstract client-callable function map for notification CRUD operations. * * Implementations are generated by {@link notificationFunctionMap} for client-side use, * and by the server-side function registration in the demo-api or application module. */ export declare abstract class NotificationFunctions implements ModelFirebaseFunctionMap { abstract notificationUser: { updateNotificationUser: { update: ModelFirebaseCrudFunction; resync: ModelFirebaseCrudFunction; }; }; abstract notificationSummary: { updateNotificationSummary: { update: ModelFirebaseCrudFunction; }; }; abstract notificationBox: { updateNotificationBox: { update: ModelFirebaseCrudFunction; recipient: ModelFirebaseCrudFunction; }; }; abstract notification: { updateNotification: { send: ModelFirebaseCrudFunction; }; }; } /** * Factory for creating client-side callable function instances from the notification CRUD configuration. */ export declare const notificationFunctionMap: import("../..").ModelFirebaseFunctionMapFactory;