API Reference

Below contains an overview of the specifications for the Firestore Record Acknowledgments extension, including TypeScript definitions & detailed descriptions.

NoticeDocument Interface

The specification for a single document within the configured collection:

export interface NoticeDocument {
  // The document ID.
  id: string;
  // The type of notice, e.g. `banner` | `terms-and-condition` | `privacy-policy`.
  type: string;
  // An optional notice version. This can be used to filter a specific notice versions via the `getNotice` callable function.
  version?: number;
  // The optional title of the notice.
  title?: string;
  // The optional description of the notice.
  description?: string;
  // The optional link of the notice.
  link?: string;
  // The timestamp when the notice was created.
  createdAt: Timestamp;
  // A list of user IDs that are allowed to see the notice.
  allowList: string[];
}

AcknowledgmentDocument Interface

The specification for a single document within a notice sub-collection:

type BaseAcknowledgment = {
  // The document ID.
  id: string;
  // The UID of the user who acknowledged the notice.
  userId: string;
  // The ID of the notice that was acknowledged.
  noticeId: string;
  // The timestamp when the notice was acknowledged.
  createdAt: Timestamp;
  // The optional metadata of the acknowledgment.
  metadata: any;
};

export type AcknowledgmentDocument =
  | (BaseAcknowledgment & {
      // The type of the acknowledgment.
      ackEvent: 'acknowledged';
      // The type of the acknowledgment. Defaults to `seen`.
      type: string;
    })
  | (BaseAcknowledgment & {
      // The type of the acknowledgment.
      ackEvent: 'unacknowledged';
    });

GetNoticeRequest Interface

The response interface provided to a getNotice callable function:

export interface GetNoticeRequest {
  // The `type` of the notice to get.
  type: string;
  // If provided, the specific version of this notice (if exists) will be returned.
  version?: number;
}

GetNoticeResponse Interface

The result interface returned from a getNotice callable function:

export type GetNoticeResponse = Omit<NoticeDocument,allowList’> & {
 // The timestamp when the notice was unacknowledged by the user (undefined if the user has not unacknowledged this notice).
 unacknowledgedAt?: Timestamp;

 // An ordered array of acknowledgments.
 acknowledgments: AcknowledgmentDocument[];
}

AcknowledgeNoticeRequest Interface

The response interface provided to a acknowledgeNotice callable function:

export interface AcknowledgeNoticeRequest {
  // The notice ID to acknowledge.
  noticeId: string;
  // A custom type to provide as the acknowledgment. Defaults to `seen`.
  type?: string;
  // Optional preference metadata to store with this acknowledgment.
  metadata?: any;
}

UnacknowledgeNoticeRequest Interface

The response interface provided to a unacknowledgeNotice callable function:

export interface UnacknowledgeNoticeRequest {
  // The notice ID to unacknowledge.
  noticeId: string;
  // Optional preference metadata to store with this unacknowledgment.
  metadata?: any;
}

GetAcknowledgmentsRequest Interface

The response interface provided to a getAcknowledgments callable function:

export interface GetAcknowledgmentsRequest {
  // If true, include unacknowledgment documents.
  includeUnacknowledgments?: boolean;
}

GetAcknowledgmentsResponse Interface

The response interface provided to a getAcknowledgments callable function:

export type GetAcknowledgmentsResponse  = (AcknowledgmentDocument & {
  // The notice of this acknowledgment, excluding the allowList.
  notice: Omit<NoticeDocument,allowList’>;
})[];