forked from owncloud/web
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcapabilities.ts
213 lines (204 loc) · 5.28 KB
/
capabilities.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import { AxiosInstance } from 'axios'
import get from 'lodash-es/get'
export interface AppProviderCapability {
apps_url?: string
enabled?: boolean
new_url?: string
open_url?: string
version?: string
}
export interface PasswordPolicyCapability {
min_characters?: number
max_characters?: number
min_lowercase_characters?: number
min_uppercase_characters?: number
min_digits?: number
min_special_characters?: number
}
export interface PasswordEnforcedForCapability {
read_only?: boolean
read_write?: boolean
upload_only?: boolean
read_write_delete?: boolean
}
export interface SearchPropertyCapability {
enabled?: boolean
}
export interface LastModifiedFilterCapability extends SearchPropertyCapability {
keywords?: string[]
}
export interface MediaTypeCapability extends SearchPropertyCapability {
keywords?: string[]
}
/**
* Archiver struct within the capabilities as defined in reva
* @see https://github.com/cs3org/reva/blob/41d5a6858c2200a61736d2c165e551b9785000d1/internal/http/services/owncloud/ocs/data/capabilities.go#L105
*/
export interface ArchiverCapability {
enabled?: boolean
version?: string // version is just a major version, e.g. `v2`
formats?: string[]
archiver_url?: string
max_num_files?: string
max_size?: string
}
export interface Capabilities {
capabilities: {
checksums?: {
preferredUploadType?: string
supportedTypes?: string[]
}
password_policy?: PasswordPolicyCapability
search?: {
property?: {
content?: SearchPropertyCapability
mediatype?: MediaTypeCapability
mtime?: LastModifiedFilterCapability
name?: MediaTypeCapability
scope?: MediaTypeCapability
size?: MediaTypeCapability
tag?: MediaTypeCapability
tags?: MediaTypeCapability
type?: MediaTypeCapability
}
}
notifications?: {
'ocs-endpoints'?: string[]
configurable?: boolean
}
core: {
pollinterval?: number
status?: {
edition?: string
installed?: boolean
maintenance?: boolean
needsDbUpgrade?: boolean
product?: string
productname?: string
productversion?: string
version?: string
versionstring?: string
}
'support-sse'?: boolean
'support-url-signing'?: boolean
'webdav-root'?: string
}
dav: {
chunking?: string
chunkingParallelUploadDisabled?: boolean
reports?: string[]
trashbin?: string
}
files: {
app_providers?: AppProviderCapability[]
archivers?: ArchiverCapability[]
favorites?: boolean
full_text_search?: boolean
permanent_deletion?: boolean
privateLinks?: boolean
tags?: boolean
tus_support?: {
extension?: string
http_method_override?: boolean
max_chunk_size?: number
resumable?: string
version?: string
}
undelete?: boolean
versioning?: boolean
thumbnail?: {
enabled?: boolean
version?: string
supportedMimeTypes?: string[]
}
}
files_sharing: {
allow_custom?: boolean
api_enabled?: boolean
can_rename?: boolean
default_permissions?: number
deny_access?: boolean
federation?: {
incoming?: boolean
outgoing?: boolean
}
group_sharing?: boolean
public?: {
alias?: boolean
can_contribute?: boolean
can_edit?: boolean
default_permissions?: number
enabled?: boolean
multiple?: boolean
password?: {
enforced?: boolean
enforced_for?: PasswordEnforcedForCapability
}
send_mail?: boolean
supports_upload_only?: boolean
upload?: boolean
expire_date?: {
enabled?: boolean
default_rw_folders?: {
years?: number
months?: number
days?: number
}
max_rw_folders?: {
years?: number
months?: number
days?: number
}
}
}
search_min_length?: number
user?: {
profile_picture?: boolean
send_mail?: boolean
settings?: {
enabled?: boolean
version?: string
}[]
}
quick_link?: {
default_role?: string
}
}
spaces?: {
enabled?: boolean
max_quota?: number
projects?: boolean
version?: string
}
graph?: {
'personal-data-export'?: boolean
users: {
change_password_self_disabled?: boolean
create_disabled?: boolean
delete_disabled?: boolean
read_only_attributes?: string[]
}
}
}
version: {
edition?: string
major?: string
minor?: string
micro?: string
product?: string
productversion?: string
string?: string
}
}
export const GetCapabilitiesFactory = (baseURI: string, axios: AxiosInstance) => {
const url = new URL(baseURI)
url.pathname = [...url.pathname.split('/'), 'cloud', 'capabilities'].filter(Boolean).join('/')
url.searchParams.append('format', 'json')
const endpoint = url.href
return {
async getCapabilities(): Promise<Capabilities> {
const response = await axios.get(endpoint)
return get(response, 'data.ocs.data', { capabilities: null, version: null })
}
}
}