Commit a9fc2258 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Define API-only Annotation type

parent f5244b36
......@@ -77,10 +77,8 @@ export class AnnotationsService {
// We need a unique local/app identifier for this new annotation such
// that we might look it up later in the store. It won't have an ID yet,
// as it has not been persisted to the service.
const $tag = 's:' + generateHexString(8);
/** @type {Annotation} */
const annotation = Object.assign(
const $tag = `s:${generateHexString(8)}`;
const annotation: Annotation = Object.assign(
{
created: now.toISOString(),
group: groupid,
......
import type { TinyEmitter } from 'tiny-emitter';
import type { Annotation, Selector, Target } from './api';
import type { APIAnnotationData, Selector, Target } from './api';
import type { ClientAnnotationData } from './shared';
/**
......@@ -66,7 +66,7 @@ export type SegmentInfo = {
* the document.
*/
export type AnnotationData = ClientAnnotationData &
Pick<Annotation, 'target' | 'uri'> & {
Pick<APIAnnotationData, 'target' | 'uri'> & {
document?: DocumentMetadata;
};
......
......@@ -144,21 +144,13 @@ export type UserInfo = {
display_name: string | null;
};
export type Annotation = ClientAnnotationData & {
export type APIAnnotationData = {
/**
* The server-assigned ID for the annotation. This is only set once the
* annotation has been saved to the backend.
*/
id?: string;
/**
* A locally-generated unique identifier for annotations.
*
* This is set for all annotations, whether they have been saved to the
* backend or not.
*/
$tag: string;
references?: string[];
created: string;
flagged?: boolean;
......@@ -205,6 +197,8 @@ export type Annotation = ClientAnnotationData & {
user_info?: UserInfo;
};
export type Annotation = ClientAnnotationData & APIAnnotationData;
/**
* An annotation which has been saved to the backend and assigned an ID.
*/
......
......@@ -13,6 +13,7 @@ export type HighlightCluster =
*/
export type ClientAnnotationData = {
$cluster?: HighlightCluster;
/**
* Client-side identifier: set even if annotation does not have a
* server-provided `id` (i.e. is unsaved)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment