UNPKG

@veltdev/types

Version:

Velt is an SDK to add collaborative features to your product within minutes. Example: Comments like Figma, Frame.io, Google docs or sheets, Recording like Loom, Huddles like Slack and much more.

58 lines (57 loc) 2.36 kB
import { SuggestionEventTypes } from '../../utils/enums'; import { ApprovedSuggestion, PendingSuggestion, RejectedSuggestion, StaleSuggestion, TargetEditCommitBuilder, TargetEditDetails } from './suggestion.data.model'; /** * Public payload types for the v1 Suggestions feature. Mirrors the layout of * `comment-events.data.model.ts` and `recorder-events.data.model.ts`: * * - One named interface per event payload. * - One `SuggestionEventTypesMap` keyed by `SuggestionEventTypes` enum values. * * Customers pass an event-name string (or the enum constant — they're * equivalent) to `velt.getSuggestionElement().on(...)` and receive an * `Observable<SuggestionEventTypesMap[T]>`. * * No separate `actor`/`user` field on the payloads: the user info is on * `suggestion.createdBy` (for created) and `suggestion.resolvedBy` (for * approved/rejected/stale). Matches the comment-event shape. */ export interface SuggestionCreatedEvent { suggestion: PendingSuggestion; timestamp: number; } export interface SuggestionApprovedEvent { suggestion: ApprovedSuggestion; timestamp: number; } export interface SuggestionRejectedEvent { suggestion: RejectedSuggestion; timestamp: number; } export interface SuggestionStaleEvent { suggestion: StaleSuggestion; timestamp: number; } export interface TargetEditStartEvent { details: TargetEditDetails; timestamp: number; } export interface TargetEditCommitEvent { details: TargetEditDetails; /** * Pre-bound builder. Calling it commits the suggestion using the SDK's * default summary/metadata, optionally overridden by `result`. If the * customer's `onTargetEditCommit` handler already returned a non-null * result for this edit, this builder is a no-op so subscribers can't * double-commit. */ commitSuggestion: TargetEditCommitBuilder; timestamp: number; } export type SuggestionEventTypesMap = { [SuggestionEventTypes.SUGGESTION_CREATED]: SuggestionCreatedEvent; [SuggestionEventTypes.SUGGESTION_APPROVED]: SuggestionApprovedEvent; [SuggestionEventTypes.SUGGESTION_REJECTED]: SuggestionRejectedEvent; [SuggestionEventTypes.SUGGESTION_STALE]: SuggestionStaleEvent; [SuggestionEventTypes.TARGET_EDIT_START]: TargetEditStartEvent; [SuggestionEventTypes.TARGET_EDIT_COMMIT]: TargetEditCommitEvent; };