Skip to content

Commit 0c86a8a

Browse files
Merge pull request #633 from appwrite/feat-revert-offline
Feat revert offline
2 parents af96e57 + c92cdf2 commit 0c86a8a

23 files changed

+80
-1196
lines changed

src/SDK/Language/Flutter.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -205,26 +205,6 @@ public function getFiles(): array
205205
'destination' => '/lib/src/interceptor.dart',
206206
'template' => 'flutter/lib/src/interceptor.dart.twig',
207207
],
208-
[
209-
'scope' => 'default',
210-
'destination' => '/lib/src/offline_db_io.dart',
211-
'template' => 'flutter/lib/src/offline_db_io.dart.twig',
212-
],
213-
[
214-
'scope' => 'default',
215-
'destination' => '/lib/src/offline_db_stub.dart',
216-
'template' => 'flutter/lib/src/offline_db_stub.dart.twig',
217-
],
218-
[
219-
'scope' => 'default',
220-
'destination' => '/lib/src/offline_db_web.dart',
221-
'template' => 'flutter/lib/src/offline_db_web.dart.twig',
222-
],
223-
[
224-
'scope' => 'default',
225-
'destination' => '/lib/src/client_offline_mixin.dart',
226-
'template' => 'flutter/lib/src/client_offline_mixin.dart.twig',
227-
],
228208
[
229209
'scope' => 'default',
230210
'destination' => '/lib/{{ language.params.packageName }}.dart',

src/Spec/Swagger2.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ public function getMethods($service)
184184
'query' => [],
185185
'body' => [],
186186
],
187-
'offline' => [
188-
'model' => $method['x-appwrite']['offline-model'] ?? '',
189-
'key' => $method['x-appwrite']['offline-key'] ?? '',
190-
'response-key' => $method['x-appwrite']['offline-response-key'] ?? '$id',
191-
],
192187
'emptyResponse' => $emptyResponse,
193188
'responseModel' => $responseModel,
194189
];

templates/dart/lib/id.dart.twig

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
11
part of {{ language.params.packageName }};
22

33
class ID {
4-
ID._();
5-
6-
// Generate a unique ID based on timestamp
7-
// Recreated from https://www.php.net/manual/en/function.uniqid.php
8-
static String _uniqid() {
9-
final now = DateTime.now();
10-
final secondsSinceEpoch = (now.millisecondsSinceEpoch / 1000).floor();
11-
final msecs = now.microsecondsSinceEpoch - secondsSinceEpoch * 1000000;
12-
return secondsSinceEpoch.toRadixString(16) +
13-
msecs.toRadixString(16).padLeft(5, '0');
14-
}
15-
16-
// Generate a unique ID with padding to have a longer ID
17-
// Recreated from https://github.com/utopia-php/database/blob/main/src/Database/ID.php#L13
18-
static String _unique({int padding = 7}) {
19-
String id = _uniqid();
20-
21-
if (padding > 0) {
22-
StringBuffer sb = StringBuffer();
23-
for (var i = 0; i < padding; i++) {
24-
sb.write(Random().nextInt(16).toRadixString(16));
25-
}
26-
27-
id += sb.toString();
4+
ID._();
5+
6+
static String unique() {
7+
return 'unique()';
288
}
299

30-
return id;
31-
}
32-
33-
static String unique() {
34-
return _unique();
35-
}
36-
37-
static String custom(String id) {
38-
return id;
39-
}
40-
}
10+
static String custom(String id) {
11+
return id;
12+
}
13+
}

templates/dart/lib/package.dart.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
library {{ language.params.packageName }};
22

33
import 'dart:async';
4-
import 'dart:math';
54
import 'dart:typed_data';
65

76
import 'src/enums.dart';

templates/flutter/base/requests/api.twig

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@
88
{{~ utils.map_headers(method.headers) }}
99
};
1010

11-
final cacheModel = '{{method['offline']['model']}}'{% if method['offline']['model'] is not empty %}{% for parameter in method.parameters.path %}.replaceAll('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | overrideIdentifier }}){% endfor %}{% endif %};
12-
final cacheKey = {% if method['offline']['key'] starts with '{' and method['offline']['key'] ends with '}' %}{{method['offline']['key'] | replace({'{': '', '}': ''}) | overrideIdentifier }}{% else %}'{{method['offline']['key']}}'{% endif %};
13-
final cacheResponseIdKey = '{{method['offline']['response-key'] | escapeDollarSign}}';
14-
final cacheResponseContainerKey = '{% for property in spec.definitions[method.responseModel].properties %}{% if property.sub_schema and property.type == 'array' %}{{property.name}}{% endif %}{% endfor %}';
15-
16-
final res = await client.call(
17-
HttpMethod.{{ method.method | caseLower }},
18-
path: path,
19-
params: params,
20-
headers: headers,
21-
cacheModel: cacheModel,
22-
cacheKey: cacheKey,
23-
cacheResponseIdKey: cacheResponseIdKey,
24-
cacheResponseContainerKey: cacheResponseContainerKey,
25-
);
11+
final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: path, params: params, headers: headers);
2612

2713
return {% if method.responseModel and method.responseModel != 'any' %}models.{{method.responseModel | caseUcfirst | overrideIdentifier}}.fromMap(res.data){% else %} res.data{% endif %};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
name: {{ language.params.packageName }}_example
22
environment:
3-
sdk: ">=2.17.0 <3.0.0"
3+
sdk: '>=2.17.0 <3.0.0'
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
library {{ language.params.packageName }};
22

33
import 'dart:async';
4-
import 'dart:math';
54
import 'dart:typed_data';
65
import 'src/enums.dart';
76
import 'src/service.dart';
87
import 'src/input_file.dart';
98
import 'models.dart' as models;
109
import 'src/upload_progress.dart';
1110

11+
export 'src/response.dart';
1212
export 'src/client.dart';
1313
export 'src/exception.dart';
14-
export 'src/input_file.dart';
1514
export 'src/realtime.dart';
16-
export 'src/realtime_message.dart';
17-
export 'src/realtime_subscription.dart';
18-
export 'src/response.dart';
1915
export 'src/upload_progress.dart';
16+
export 'src/realtime_subscription.dart';
17+
export 'src/realtime_message.dart';
18+
export 'src/input_file.dart';
2019

21-
part 'id.dart';
22-
part 'permission.dart';
2320
part 'query.dart';
21+
part 'permission.dart';
2422
part 'role.dart';
23+
part 'id.dart';
2524
{% for service in spec.services %}
2625
part 'services/{{service.name | caseDash}}.dart';
2726
{% endfor %}
Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1+
import 'enums.dart';
12
import 'client_stub.dart'
23
if (dart.library.html) 'client_browser.dart'
34
if (dart.library.io) 'client_io.dart';
4-
import 'enums.dart';
55
import 'response.dart';
66
import 'upload_progress.dart';
77

88
abstract class Client {
9-
static const int CHUNK_SIZE = 5 * 1024 * 1024;
9+
static const int CHUNK_SIZE = 5*1024*1024;
1010
late Map<String, String> config;
1111
late String _endPoint;
1212
late String? _endPointRealtime;
1313

1414
String get endPoint => _endPoint;
1515
String? get endPointRealtime => _endPointRealtime;
1616

17-
factory Client({
18-
String endPoint = '{{ spec.endpoint }}',
19-
bool selfSigned = false,
20-
}) =>
17+
factory Client(
18+
{String endPoint = '{{ spec.endpoint }}',
19+
bool selfSigned = false}) =>
2120
createClient(endPoint: endPoint, selfSigned: selfSigned);
2221

2322
Future webAuth(Uri url, {String? callbackUrlScheme});
@@ -39,34 +38,17 @@ abstract class Client {
3938

4039
{% for header in spec.global.headers %}
4140
{% if header.description %}
42-
/// {{header.description}}
41+
/// {{header.description}}
4342
{% endif %}
4443
Client set{{header.key | caseUcfirst}}(value);
4544
{% endfor %}
4645

4746
Client addHeader(String key, String value);
4847

49-
Future<Response> call(
50-
HttpMethod method, {
48+
Future<Response> call(HttpMethod method, {
5149
String path = '',
5250
Map<String, String> headers = const {},
5351
Map<String, dynamic> params = const {},
5452
ResponseType? responseType,
55-
String cacheModel = '',
56-
String cacheKey = '',
57-
String cacheResponseIdKey = '',
58-
String cacheResponseContainerKey = '',
59-
Map<String, Object?>? previous,
60-
});
61-
62-
Future<Client> setOfflinePersistency({
63-
bool status = true,
64-
void Function(Object)? onWriteQueueError,
6553
});
66-
67-
bool getOfflinePersistency();
68-
69-
Client setOfflineCacheSize(int kbytes);
70-
71-
int getOfflineCacheSize();
7254
}
Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
import 'response.dart';
12
import 'client.dart';
23
import 'enums.dart';
3-
import 'response.dart';
44

5-
abstract class ClientBase implements Client {
5+
abstract class ClientBase implements Client {
66
{% for header in spec.global.headers %}
77
{% if header.description %}
88
/// {{header.description}}
99
{% endif %}
1010
@override
1111
ClientBase set{{header.key | caseUcfirst}}(value);
12-
1312
{% endfor %}
13+
1414
@override
1515
ClientBase setSelfSigned({bool status = true});
1616

@@ -30,25 +30,5 @@ abstract class ClientBase implements Client {
3030
Map<String, String> headers = const {},
3131
Map<String, dynamic> params = const {},
3232
ResponseType? responseType,
33-
String cacheModel = '',
34-
String cacheKey = '',
35-
String cacheResponseIdKey = '',
36-
String cacheResponseContainerKey = '',
37-
Map<String, Object?>? previous,
38-
});
39-
40-
@override
41-
Future<ClientBase> setOfflinePersistency({
42-
bool status = true,
43-
void Function(Object)? onWriteQueueError,
4433
});
45-
46-
@override
47-
bool getOfflinePersistency();
48-
49-
@override
50-
ClientBase setOfflineCacheSize(int kbytes);
51-
52-
@override
53-
int getOfflineCacheSize();
5434
}

0 commit comments

Comments
 (0)