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 { ...@@ -77,10 +77,8 @@ export class AnnotationsService {
// We need a unique local/app identifier for this new annotation such // 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, // 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. // as it has not been persisted to the service.
const $tag = 's:' + generateHexString(8); const $tag = `s:${generateHexString(8)}`;
const annotation: Annotation = Object.assign(
/** @type {Annotation} */
const annotation = Object.assign(
{ {
created: now.toISOString(), created: now.toISOString(),
group: groupid, group: groupid,
......
import type { TinyEmitter } from 'tiny-emitter'; 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'; import type { ClientAnnotationData } from './shared';
/** /**
...@@ -66,7 +66,7 @@ export type SegmentInfo = { ...@@ -66,7 +66,7 @@ export type SegmentInfo = {
* the document. * the document.
*/ */
export type AnnotationData = ClientAnnotationData & export type AnnotationData = ClientAnnotationData &
Pick<Annotation, 'target' | 'uri'> & { Pick<APIAnnotationData, 'target' | 'uri'> & {
document?: DocumentMetadata; document?: DocumentMetadata;
}; };
......
...@@ -144,21 +144,13 @@ export type UserInfo = { ...@@ -144,21 +144,13 @@ export type UserInfo = {
display_name: string | null; display_name: string | null;
}; };
export type Annotation = ClientAnnotationData & { export type APIAnnotationData = {
/** /**
* The server-assigned ID for the annotation. This is only set once the * The server-assigned ID for the annotation. This is only set once the
* annotation has been saved to the backend. * annotation has been saved to the backend.
*/ */
id?: string; 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[]; references?: string[];
created: string; created: string;
flagged?: boolean; flagged?: boolean;
...@@ -205,6 +197,8 @@ export type Annotation = ClientAnnotationData & { ...@@ -205,6 +197,8 @@ export type Annotation = ClientAnnotationData & {
user_info?: UserInfo; user_info?: UserInfo;
}; };
export type Annotation = ClientAnnotationData & APIAnnotationData;
/** /**
* An annotation which has been saved to the backend and assigned an ID. * An annotation which has been saved to the backend and assigned an ID.
*/ */
......
...@@ -13,6 +13,7 @@ export type HighlightCluster = ...@@ -13,6 +13,7 @@ export type HighlightCluster =
*/ */
export type ClientAnnotationData = { export type ClientAnnotationData = {
$cluster?: HighlightCluster; $cluster?: HighlightCluster;
/** /**
* Client-side identifier: set even if annotation does not have a * Client-side identifier: set even if annotation does not have a
* server-provided `id` (i.e. is unsaved) * 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