Skip to content

Commit f7dddf9

Browse files
committed
refactor(nextcloud): Define generated WebDAV props inside the generation script
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 70f6112 commit f7dddf9

File tree

2 files changed

+54
-41
lines changed

2 files changed

+54
-41
lines changed

packages/nextcloud/generate_props.dart

+54-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,63 @@
11
import 'dart:io';
22

33
void main() {
4-
final props = File('lib/src/webdav/props.csv').readAsLinesSync().map((line) => line.split(','));
4+
final props = <String, Map<String, String>>{
5+
'dav': {
6+
'getlastmodified': 'String',
7+
'getetag': 'String',
8+
'getcontenttype': 'String',
9+
'getcontentlength': 'int',
10+
'resourcetype': 'WebDavResourcetype',
11+
},
12+
'oc': {
13+
'id': 'String',
14+
'fileid': 'String',
15+
'favorite': 'int',
16+
'comments-href': 'String',
17+
'comments-count': 'int',
18+
'comments-unread': 'int',
19+
'downloadURL': 'String',
20+
'owner-id': 'String',
21+
'owner-display-name': 'String',
22+
'size': 'int',
23+
'permissions': 'String',
24+
},
25+
'nc': {
26+
'note': 'String',
27+
'data-fingerprint': 'String',
28+
'has-preview': 'bool',
29+
'mount-type': 'String',
30+
'is-encrypted': 'int',
31+
'metadata_etag': 'String',
32+
'upload_time': 'int',
33+
'creation_time': 'int',
34+
'rich-workspace': 'String',
35+
},
36+
'ocs': {
37+
'share-permissions': 'int',
38+
},
39+
'ocm': {
40+
'share-permissions': 'String',
41+
},
42+
};
43+
544
final valueProps = <String>[];
645
final findProps = <String>[];
746
final variables = <String>[];
8-
for (final prop in props) {
9-
final namespacePrefix = prop[0];
10-
final namespaceVariable = convertNamespace(namespacePrefix);
11-
final type = prop[2];
12-
final name = prop[1];
13-
final variable = namespacePrefix + name.toLowerCase().replaceAll(RegExp('[^a-z]'), '');
14-
valueProps.add(
15-
"@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false,)\n final $type? $variable;",
16-
);
17-
findProps.add(
18-
"@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: true, isSelfClosing: true,)\n final List<String?>? $variable;",
19-
);
20-
variables.add(variable);
47+
for (final namespacePrefix in props.keys) {
48+
for (final name in props[namespacePrefix]!.keys) {
49+
final type = props[namespacePrefix]![name]!;
50+
51+
final namespaceVariable = convertNamespace(namespacePrefix);
52+
final variable = namespacePrefix + name.toLowerCase().replaceAll(RegExp('[^a-z]'), '');
53+
valueProps.add(
54+
"@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false,)\n final $type? $variable;",
55+
);
56+
findProps.add(
57+
"@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: true, isSelfClosing: true,)\n final List<String?>? $variable;",
58+
);
59+
variables.add(variable);
60+
}
2161
}
2262
File('lib/src/webdav/props.dart').writeAsStringSync(
2363
[

packages/nextcloud/lib/src/webdav/props.csv

-27
This file was deleted.

0 commit comments

Comments
 (0)