File
Blob: src/worker/objects/common/collection-types.ts
| 1 | import type { DavChangeType } from "@/worker/db/types"; |
| 2 | import type { ParsedIfHeader } from "@/worker/dav/if-header"; |
| 3 | |
| 4 | export interface CollectionDomainError { |
| 5 | ok: false; |
| 6 | status: number; |
| 7 | message: string; |
| 8 | } |
| 9 | |
| 10 | export interface DomainCollection { |
| 11 | id: string; |
| 12 | name: string; |
| 13 | } |
| 14 | |
| 15 | export interface DomainObject { |
| 16 | id: string; |
| 17 | name: string; |
| 18 | uid: string; |
| 19 | etag: string; |
| 20 | version: number; |
| 21 | } |
| 22 | |
| 23 | export interface ParsedDomainObject { |
| 24 | uid: string; |
| 25 | body: string; |
| 26 | size: number; |
| 27 | } |
| 28 | |
| 29 | export interface DomainChange { |
| 30 | seq: number; |
| 31 | href: string; |
| 32 | changeType: DavChangeType; |
| 33 | } |
| 34 | |
| 35 | export interface SubjectTimeInput { |
| 36 | subjectId: string; |
| 37 | nowMs: number; |
| 38 | } |
| 39 | |
| 40 | export interface DomainConditionalInput extends SubjectTimeInput { |
| 41 | ifMatch: string | null; |
| 42 | ifNoneMatch: string | null; |
| 43 | ifHeader: ParsedIfHeader; |
| 44 | } |
| 45 | |
| 46 | export type DomainDeadPropInstruction = |
| 47 | | { kind: "set"; nsUri: string; localName: string; xmlValue: string } |
| 48 | | { kind: "remove"; nsUri: string; localName: string }; |
| 49 | |
| 50 | export interface DomainDescribeInput extends SubjectTimeInput { |
| 51 | kind: string; |
| 52 | collectionName?: string; |
| 53 | objectName?: string; |
| 54 | depth: "0" | "1"; |
| 55 | maxResults: number; |
| 56 | } |
| 57 | |
| 58 | export interface DomainProppatchInput extends DomainConditionalInput { |
| 59 | kind: string; |
| 60 | resourceId: string | null; |
| 61 | collectionName?: string; |
| 62 | objectName?: string; |
| 63 | instructions: DomainDeadPropInstruction[]; |
| 64 | } |
| 65 | |
| 66 | export interface DomainGetObjectInput extends SubjectTimeInput { |
| 67 | collectionName: string; |
| 68 | objectName: string; |
| 69 | } |
| 70 | |
| 71 | export interface DomainPutObjectInput extends DomainConditionalInput { |
| 72 | collectionName: string; |
| 73 | objectName: string; |
| 74 | body: ArrayBuffer; |
| 75 | maxBytes: number; |
| 76 | } |
| 77 | |
| 78 | export interface DomainDeleteObjectInput extends DomainConditionalInput { |
| 79 | collectionName: string; |
| 80 | objectName: string; |
| 81 | } |
| 82 | |
| 83 | export interface DomainMultigetInput extends SubjectTimeInput { |
| 84 | collectionName: string; |
| 85 | hrefs: string[]; |
| 86 | maxResults: number; |
| 87 | acceptedOrigins?: string[]; |
| 88 | } |
| 89 | |
| 90 | export interface DomainSyncInput extends SubjectTimeInput { |
| 91 | collectionName: string; |
| 92 | token: string | null; |
| 93 | maxResults: number; |
| 94 | } |
| 95 | |
| 96 | export interface DomainObjectResources<TResource> { |
| 97 | resources: TResource[]; |
| 98 | truncated: boolean; |
| 99 | } |
| 100 | |
| 101 | export interface DomainChangesSince<TChange extends DomainChange> { |
| 102 | changes: TChange[]; |
| 103 | truncated: boolean; |
| 104 | } |