Skip to content

Commit

Permalink
Merge branch 'supabase-integration' into stable-release
Browse files Browse the repository at this point in the history
  • Loading branch information
tshedor committed Sep 7, 2024
2 parents e52ad27 + 99f7b25 commit 14a1c41
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/reusable-dart-analyze-format-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ jobs:

- run: dart pub get && dart run melos bootstrap --scope="${{ inputs.package }}"

- run: dart analyze --fatal-infos lib
# TODO: Restore --fatal-infos when analyzer 6.5 is significantly available
# in major versions of Flutter. Likely in Q1 2025 https://github.com/GetDutchie/brick/pull/435
# - run: dart analyze --fatal-infos lib
- run: dart analyze lib
working-directory: packages/${{ inputs.package }}

- run: dart format --output=none --line-length 100 --set-exit-if-changed lib test
Expand Down
4 changes: 4 additions & 0 deletions packages/brick_build/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased

## 3.2.1

- Revert `.getDisplayString()` change due to Flutter 3.22 being restricted to analyzer <6.4.1. `meta` is pinned to `1.12` in this version of Flutter, and `analyzer >=6.5.0`, where the change was made, requires `meta >= 1.15`. This change will eventually be re-reverted.

## 3.2.0

- Add convenience mixin `AnnotationFinderWithFieldRename` for field renames in generators
Expand Down
5 changes: 3 additions & 2 deletions packages/brick_build/lib/src/utils/shared_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class SharedChecker<_SiblingModel extends Model> {
if (classElement.supertype?.typeArguments == null ||
classElement.supertype!.typeArguments.isEmpty) {
throw InvalidGenerationSourceError(
'Type argument for ${targetType.getDisplayString()} is undefined.',
'Type argument for ${targetType.getDisplayString(withNullability: true)} is undefined.',
todo:
'Define the type on class ${targetType.element}, e.g. `extends ${withoutNullability(classElement.supertype!)}<int>`',
element: targetType.element,
Expand Down Expand Up @@ -243,7 +243,8 @@ class SharedChecker<_SiblingModel extends Model> {
}

/// Print the `DartType` without nullability
static String withoutNullability(DartType type) => type.getDisplayString().replaceAll('?', '');
static String withoutNullability(DartType type) =>
type.getDisplayString(withNullability: true).replaceAll('?', '');

/// Destructs a type to determine the bottom type after going through Futures and Iterables.
///
Expand Down
2 changes: 1 addition & 1 deletion packages/brick_build/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_build
issue_tracker: https://github.com/GetDutchie/brick/issues
repository: https://github.com/GetDutchie/brick

version: 3.2.0
version: 3.2.1

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/brick_json_generators/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Unreleased

- (test) remove analysis options override for non-standard library prefixes
- Revert `.getDisplayString()` change due to Flutter 3.22 being restricted to analyzer <6.4.1. `meta` is pinned to `1.12` in this version of Flutter, and `analyzer >=6.5.0`, where the change was made, requires `meta >= 1.15`. This change will eventually be re-reverted.

## 3.1.0
## 3.1.1

- Apply standardized lints
- Update `analyzer` constraints to `>=6.0.0 <7.0.0`
Expand Down
4 changes: 2 additions & 2 deletions packages/brick_json_generators/lib/json_deserialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mixin JsonDeserialize<TModel extends Model, Annotation extends FieldSerializable
final nullableSuffix = checker.isNullable ? '?' : '';

return '''$fieldValue$nullableSuffix.map(
(d) => ${klass.displayName}.fromJson(d as ${parameterType.getDisplayString()})
(d) => ${klass.displayName}.fromJson(d as ${parameterType.getDisplayString(withNullability: true)})
)$castIterable$defaultValue''';
}

Expand Down Expand Up @@ -138,7 +138,7 @@ mixin JsonDeserialize<TModel extends Model, Annotation extends FieldSerializable
final parameterType = checker.fromJsonConstructor!.parameters.first.type;

final output =
'${klass.displayName}.fromJson($fieldValue as ${parameterType.getDisplayString()})';
'${klass.displayName}.fromJson($fieldValue as ${parameterType.getDisplayString(withNullability: true)})';
if (checker.isNullable) return '$fieldValue != null ? $output : null';
return output;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/brick_json_generators/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_json_gene
issue_tracker: https://github.com/GetDutchie/brick/issues
repository: https://github.com/GetDutchie/brick

version: 3.1.0
version: 3.1.1

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down
3 changes: 3 additions & 0 deletions packages/brick_offline_first_build/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Unreleased

## 3.2.1

- (test) remove analysis options override for non-standard library prefixes
- Revert `.getDisplayString()` change due to Flutter 3.22 being restricted to analyzer <6.4.1. `meta` is pinned to `1.12` in this version of Flutter, and `analyzer >=6.5.0`, where the change was made, requires `meta >= 1.15`. This change will eventually be re-reverted.

## 3.2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ mixin OfflineFirstJsonDeserialize<TModel extends Model, Annotation extends Field
if (argTypeChecker.hasSerdes) {
final doesHaveConstructor = hasConstructor(checker.argType);
if (doesHaveConstructor) {
final serializableType = argTypeChecker.superClassTypeArgs.first.getDisplayString();
final serializableType =
argTypeChecker.superClassTypeArgs.first.getDisplayString(withNullability: true);
final nullabilityOperator = checker.isNullable ? '?' : '';
return '$fieldValue$nullabilityOperator.map((c) => ${SharedChecker.withoutNullability(checker.argType)}.$constructorName(c as $serializableType))$castIterable$defaultValue';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class OfflineFirstSqliteDeserialize extends SqliteDeserialize {
if (argTypeChecker.hasSerdes) {
final doesHaveConstructor = hasConstructor(checker.argType);
if (doesHaveConstructor) {
final serializableType = argTypeChecker.superClassTypeArgs.last.getDisplayString();
final serializableType =
argTypeChecker.superClassTypeArgs.last.getDisplayString(withNullability: true);
return '''
jsonDecode($fieldValue).map(
(c) => $argType.$constructorName(c as $serializableType)
Expand All @@ -105,7 +106,8 @@ class OfflineFirstSqliteDeserialize extends SqliteDeserialize {
if ((checker as OfflineFirstChecker).hasSerdes) {
final doesHaveConstructor = hasConstructor(field.type);
if (doesHaveConstructor) {
final serializableType = checker.superClassTypeArgs.last.getDisplayString();
final serializableType =
checker.superClassTypeArgs.last.getDisplayString(withNullability: true);
return '${SharedChecker.withoutNullability(field.type)}.$constructorName($fieldValue as $serializableType)';
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/brick_offline_first_build/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_offline_f
issue_tracker: https://github.com/GetDutchie/brick/issues
repository: https://github.com/GetDutchie/brick

version: 3.2.0
version: 3.2.1

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,21 @@ abstract class OfflineFirstWithSupabaseRepository
required DatabaseFactory databaseFactory,
http.Client? innerClient,
Duration? processingInterval,
List<int>? reattemptForStatusCodes,
List<int> reattemptForStatusCodes = const [
400,
401,
403,
404,
405,
408,
409,
429,
500,
501,
502,
503,
504,
],
bool? serialProcessing,
}) {
final client = RestOfflineQueueClient(
Expand Down
5 changes: 3 additions & 2 deletions packages/brick_offline_first_with_supabase/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ environment:
dependencies:
brick_core: ^1.1.1
brick_offline_first: ">=3.0.0 <4.0.0"
brick_supabase: ">=0.0.1 <2.0.0"
brick_sqlite: ">=3.0.0 <4.0.0"
brick_supabase: ">=0.0.1 <2.0.0"
brick_offline_first_with_rest: ">=3.0.2 <4.0.0"
http: ">=1.0.0 <2.0.0"
logging: ">=1.0.0 <2.0.0"
Expand All @@ -24,5 +24,6 @@ dependencies:
dev_dependencies:
lints: ^2.0.1
mockito: ^5.0.0
test: ^1.16.5
sqflite_common_ffi: ^2.0.0
supabase: ">=2.3.0 <3.0.0"
test: ^1.16.5
4 changes: 4 additions & 0 deletions packages/brick_sqlite_generators/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased

## 3.2.2

- Revert `.getDisplayString()` change due to Flutter 3.22 being restricted to analyzer <6.4.1. `meta` is pinned to `1.12` in this version of Flutter, and `analyzer >=6.5.0`, where the change was made, requires `meta >= 1.15`. This change will eventually be re-reverted.

## 3.2.1

- Use `SharedChecker.withoutNullability` instead of stripping null suffixes manually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class SqliteDeserialize<_Model extends SqliteModel> extends SqliteSerdesGenerato
final discoveredByIndex =
'jsonDecode($fieldValue).map((d) => d as int > -1 ? ${SharedChecker.withoutNullability(argType)}.values[d] : null)';
final nullableSuffix = checker.isNullable ? '?' : '';
return '$discoveredByIndex$nullableSuffix.whereType<${argType.getDisplayString()}>()$castIterable';
return '$discoveredByIndex$nullableSuffix.whereType<${argType.getDisplayString(withNullability: true)}>()$castIterable';
}

// Iterable<bool>
Expand All @@ -152,7 +152,7 @@ class SqliteDeserialize<_Model extends SqliteModel> extends SqliteSerdesGenerato
final nullableSuffix = checker.isNullable ? " ?? '[]'" : '';

return '''jsonDecode($fieldValue$nullableSuffix).map(
(d) => ${klass.displayName}.fromJson(d as ${parameterType.getDisplayString()})
(d) => ${klass.displayName}.fromJson(d as ${parameterType.getDisplayString(withNullability: true)})
)$castIterable$defaultValue''';
}

Expand Down Expand Up @@ -210,7 +210,7 @@ class SqliteDeserialize<_Model extends SqliteModel> extends SqliteSerdesGenerato
} else if (checker.fromJsonConstructor != null) {
final klass = checker.targetType.element as ClassElement;
final parameterType = checker.fromJsonConstructor!.parameters.first.type;
return '${klass.displayName}.fromJson(jsonDecode($fieldValue as String) as ${parameterType.getDisplayString()})';
return '${klass.displayName}.fromJson(jsonDecode($fieldValue as String) as ${parameterType.getDisplayString(withNullability: true)})';
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/brick_sqlite_generators/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_sqlite_ge
issue_tracker: https://github.com/GetDutchie/brick/issues
repository: https://github.com/GetDutchie/brick

version: 3.2.1
version: 3.2.2

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down

0 comments on commit 14a1c41

Please sign in to comment.