diff --git a/src/index.ts b/src/index.ts index 5f31910..06ea5c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -111,17 +111,15 @@ export interface EntryCommon { visibleName: string; /** the last modified timestamp */ lastModified: string; + /** true if the entry is starred in most ui elements */ + pinned: boolean; /** * the parent of this entry * * There are two special parents, "" (empty string) for the root directory, * and "trash" for the trash */ - parent: string; - /** true if the entry is starred in most ui elements */ - pinned: boolean; - /** the timestamp of the last time this entry was opened */ - lastOpened: string; + parent?: string; /** any tags the entry might have */ tags?: Tag[]; } @@ -138,35 +136,23 @@ export interface DocumentType extends EntryCommon { type: "DocumentType"; /** the type of the file */ fileType: "epub" | "pdf" | "notebook"; + /** the timestamp of the last time this entry was opened */ + lastOpened: string; } /** a remarkable entry for cloud items */ export type Entry = CollectionEntry | DocumentType; -/** an simple entry produced by the upload api */ -export interface UploadEntry { - /** the document id */ - docID: string; - /** the document hash */ - hash: string; -} - -const uploadEntry = properties({ - docID: string(), - hash: string(), -}) satisfies CompiledSchema; - const commonProperties = { id: string(), hash: string(), visibleName: string(), lastModified: string(), - parent: string(), pinned: boolean(), - lastOpened: string(), } as const; const commonOptionalProperties = { + parent: string(), tags: elements( properties({ name: string(), @@ -178,7 +164,11 @@ const commonOptionalProperties = { const entry = discriminator("type", { CollectionType: properties(commonProperties, commonOptionalProperties, true), DocumentType: properties( - { ...commonProperties, fileType: enumeration("epub", "pdf", "notebook") }, + { + ...commonProperties, + lastOpened: string(), + fileType: enumeration("epub", "pdf", "notebook"), + }, commonOptionalProperties, true, ), @@ -186,6 +176,19 @@ const entry = discriminator("type", { const entries = elements(entry) satisfies CompiledSchema; +/** an simple entry produced by the upload api */ +export interface UploadEntry { + /** the document id */ + docID: string; + /** the document hash */ + hash: string; +} + +const uploadEntry = properties({ + docID: string(), + hash: string(), +}) satisfies CompiledSchema; + /** the new hash of a modified entry */ export interface HashEntry { /** the actual hash */