Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextcloud)!: tables row endpoints #2509

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions packages/nextcloud/lib/src/api/tables/patches/1-broken-spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
{
"op": "replace",
"path": "/paths/~1index.php~1apps~1tables~1api~11~1tables~1{tableId}~1rows~1simple/get/responses/200/content/application~1json/schema/items/type",
"value": "array"
},
{
"op": "add",
"path": "/paths/~1index.php~1apps~1tables~1api~11~1tables~1{tableId}~1rows~1simple/get/responses/200/content/application~1json/schema/items/items",
"value": {
"type": "object"
}
},
{
"op": "remove",
"path": "/components/schemas/Row/properties/data/properties"
},
{
"op": "remove",
"path": "/components/schemas/Row/properties/data/required"
},
{
"op": "remove",
"path": "/components/schemas/Row/properties/data/nullable"
},
{
"op": "replace",
"path": "/components/schemas/Row/properties/data/type",
"value": "array"
},
{
"op": "add",
"path": "/components/schemas/Row/properties/data/items",
"value": {
"type": "object",
"nullable": true,
"required": [
"columnId",
"value"
],
"properties": {
"columnId": {
"type": "integer",
"format": "int64"
},
"value": {
"type": "object"
}
}
}
}
]
25 changes: 18 additions & 7 deletions packages/nextcloud/lib/src/api/tables/tables.openapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2324,8 +2324,11 @@ class $Api1Client {

/// Builds a serializer to parse the response of [$indexTableRowsSimple_Request].
@_i2.experimental
_i1.DynamiteSerializer<BuiltList<String>, void> $indexTableRowsSimple_Serializer() => _i1.DynamiteSerializer(
bodyType: const FullType(BuiltList, [FullType(String)]),
_i1.DynamiteSerializer<BuiltList<BuiltList<JsonObject>>, void> $indexTableRowsSimple_Serializer() =>
_i1.DynamiteSerializer(
bodyType: const FullType(BuiltList, [
FullType(BuiltList, [FullType(JsonObject)]),
]),
headersType: null,
serializers: _$jsonSerializers,
validStatuses: const {200},
Expand Down Expand Up @@ -2410,7 +2413,7 @@ class $Api1Client {
/// See:
/// * [$indexTableRowsSimple_Request] for the request send by this method.
/// * [$indexTableRowsSimple_Serializer] for a converter to parse the `Response` from an executed request.
Future<_i1.DynamiteResponse<BuiltList<String>, void>> indexTableRowsSimple({
Future<_i1.DynamiteResponse<BuiltList<BuiltList<JsonObject>>, void>> indexTableRowsSimple({
required int tableId,
int? limit,
int? offset,
Expand All @@ -2424,7 +2427,7 @@ class $Api1Client {
final _response = await _i3.Response.fromStream(_streamedResponse);

final _serializer = $indexTableRowsSimple_Serializer();
return _i1.ResponseConverter<BuiltList<String>, void>(_serializer).convert(_response);
return _i1.ResponseConverter<BuiltList<BuiltList<JsonObject>>, void>(_serializer).convert(_response);
}

/// Builds a serializer to parse the response of [$indexTableRows_Request].
Expand Down Expand Up @@ -9322,7 +9325,7 @@ sealed class $RowInterface {
String get createdAt;
String get lastEditBy;
String get lastEditAt;
Row_Data? get data;
BuiltList<Row_Data?> get data;

/// Rebuilds the instance.
///
Expand Down Expand Up @@ -16171,11 +16174,18 @@ final Serializers _$serializers = (Serializers().toBuilder()
Api1UpdateColumnRequestApplicationJsonBuilder.new,
)
..add(Api1UpdateColumnRequestApplicationJson.serializer)
..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder<String>.new)
..addBuilderFactory(const FullType(BuiltList, [FullType(JsonObject)]), ListBuilder<JsonObject>.new)
..addBuilderFactory(
const FullType(BuiltList, [
FullType(BuiltList, [FullType(JsonObject)]),
]),
ListBuilder<BuiltList<JsonObject>>.new,
)
..addBuilderFactory(const FullType(Row), RowBuilder.new)
..add(Row.serializer)
..addBuilderFactory(const FullType(Row_Data), Row_DataBuilder.new)
..add(Row_Data.serializer)
..addBuilderFactory(const FullType(BuiltList, [FullType.nullable(Row_Data)]), ListBuilder<Row_Data?>.new)
..addBuilderFactory(const FullType(BuiltList, [FullType(Row)]), ListBuilder<Row>.new)
..addBuilderFactory(
const FullType(Api1CreateRowInTableRequestApplicationJson),
Expand Down Expand Up @@ -16580,7 +16590,8 @@ final Serializers _$serializers = (Serializers().toBuilder()
..addBuilderFactory(const FullType(Capabilities), CapabilitiesBuilder.new)
..add(Capabilities.serializer)
..addBuilderFactory(const FullType(Capabilities_Tables), Capabilities_TablesBuilder.new)
..add(Capabilities_Tables.serializer))
..add(Capabilities_Tables.serializer)
..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder<String>.new))
.build();

/// Serializer for all values in this library.
Expand Down
34 changes: 16 additions & 18 deletions packages/nextcloud/lib/src/api/tables/tables.openapi.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 20 additions & 14 deletions packages/nextcloud/lib/src/api/tables/tables.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,19 +370,22 @@
"type": "string"
},
"data": {
"type": "object",
"nullable": true,
"required": [
"columnId",
"value"
],
"properties": {
"columnId": {
"type": "integer",
"format": "int64"
},
"value": {
"type": "object"
"type": "array",
"items": {
"type": "object",
"nullable": true,
"required": [
"columnId",
"value"
],
"properties": {
"columnId": {
"type": "integer",
"format": "int64"
},
"value": {
"type": "object"
}
}
}
}
Expand Down Expand Up @@ -3843,7 +3846,10 @@
"schema": {
"type": "array",
"items": {
"type": "string"
"type": "array",
"items": {
"type": "object"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/matchers/matchers.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:nextcloud/utils.dart';
import 'package:test/expect.dart';
import 'package:timezone/timezone.dart' as tz;

/// Returns a matcher which matches if the match argument is within [delta]
/// of some [value].
///
/// In other words, this matches if the difference of the match argument and [value]
/// is greater than or equal to -[delta] and less than or equal to [delta].
///
/// The match argument can either be a `DateTime, `String` or `int`.
/// A `String` value is parsed into a utc date, while an `int` value is interpreted
/// as a unix timestamp (seconds since epoch).
Matcher closeToDate(DateTime value, Duration delta) => _IsCloseToDate(value, delta);

class _IsCloseToDate extends TypeMatcher<DateTime> {
const _IsCloseToDate(this._value, this._delta);

final DateTime _value;
final Duration _delta;

static DateTime? _parse(dynamic item) {
switch (item) {
case DateTime():
return item;

case String():
final date = DateTime.parse(item);
return date.toUtc().add(date.timeZoneOffset);

case int():
return DateTimeUtils.fromSecondsSinceEpoch(tz.UTC, item);

default:
return null;
}
}

@override
bool matches(
dynamic item,
Map<dynamic, dynamic> matchState,
) {
final date = _parse(item);
if (date == null) {
return false;
}

var diff = date.difference(_value);
if (diff.isNegative) {
diff = -diff;
}
return diff <= _delta;
}

@override
Description describeMismatch(
Object? item,
Description mismatchDescription,
Map<dynamic, dynamic> matchState,
bool verbose,
) {
final date = _parse(item);
if (date == null) {
return super.describe(mismatchDescription.add('not an '));
}

final diff = date.difference(_value);
return mismatchDescription.add(' differs by ').addDescriptionOf(diff);
}

@override
Description describe(Description description) =>
description.add('a time value within ').addDescriptionOf(_delta).add(' of ').addDescriptionOf(_value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'date_matcher.dart';
1 change: 1 addition & 0 deletions packages/nextcloud/packages/nextcloud_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
process_run: ^1.0.0+1
test: ^1.24.0
test_api: ^0.7.0
timezone: ^0.9.4
universal_io: ^2.0.0
version: ^3.0.0

Expand Down
Loading
Loading