Skip to content
File

Blob: src/worker/objects/common/collection-types.ts

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