Compare commits

..
Author SHA1 Message Date
hugo f2a6c446eb chore: remove deprecated http client package in favor of http/dio packages
continuous-integration/drone/pr Build is failing
2024-03-30 17:48:11 +01:00
hugo fda5a0ae62 chore(deferred): remove unimplemented deferred packages 2024-03-30 17:47:30 +01:00
136 changed files with 265 additions and 3431 deletions
-445
View File
@@ -3,451 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 2025-06-11
### Changes
---
Packages with breaking changes:
- There are no breaking changes in this release.
Packages with other changes:
- [`wyatt_crud_bloc_firestore` - `v0.2.0+3`](#wyatt_crud_bloc_firestore---v0203)
---
#### `wyatt_crud_bloc_firestore` - `v0.2.0+3`
## 2025-05-21
### Changes
---
Packages with breaking changes:
- There are no breaking changes in this release.
Packages with other changes:
- [`wyatt_ui_layout` - `v0.1.3+2`](#wyatt_ui_layout---v0132)
---
#### `wyatt_ui_layout` - `v0.1.3+2`
## 2025-05-21
### Changes
---
Packages with breaking changes:
- There are no breaking changes in this release.
Packages with other changes:
- [`wyatt_ui_layout` - `v0.1.3+1`](#wyatt_ui_layout---v0131)
---
#### `wyatt_ui_layout` - `v0.1.3+1`
## 2025-05-21
### Changes
---
Packages with breaking changes:
- There are no breaking changes in this release.
Packages with other changes:
- [`wyatt_bloc_helper` - `v2.0.3`](#wyatt_bloc_helper---v203)
---
#### `wyatt_bloc_helper` - `v2.0.3`
## 2025-05-21
### Changes
---
Packages with breaking changes:
- [`architecture_example` - `v2.0.0`](#architecture_example---v200)
- [`bloc_layout_example` - `v2.0.0`](#bloc_layout_example---v200)
- [`crud_bloc_example` - `v2.0.0`](#crud_bloc_example---v200)
- [`example_router` - `v2.0.0`](#example_router---v200)
- [`form_bloc_example` - `v2.0.0`](#form_bloc_example---v200)
- [`wyatt_i18n_example` - `v2.0.0`](#wyatt_i18n_example---v200)
- [`wyatt_ui_components_example` - `v2.0.0`](#wyatt_ui_components_example---v200)
- [`wyatt_ui_kit_example` - `v2.0.0`](#wyatt_ui_kit_example---v200)
- [`wyatt_ui_layout_example` - `v2.0.0`](#wyatt_ui_layout_example---v200)
Packages with other changes:
- [`bloc_helper_example` - `v1.1.0`](#bloc_helper_example---v110)
- [`component_copy_with_extension_example` - `v1.1.0`](#component_copy_with_extension_example---v110)
- [`component_copy_with_gen_example` - `v1.1.0`](#component_copy_with_gen_example---v110)
- [`notification_bloc_example` - `v1.0.1`](#notification_bloc_example---v101)
- [`type_utils_example` - `v1.1.0`](#type_utils_example---v110)
- [`wyatt_continuous_deployment` - `v1.1.1`](#wyatt_continuous_deployment---v111)
- [`wyatt_continuous_deployment_example` - `v1.0.1`](#wyatt_continuous_deployment_example---v101)
- [`wyatt_type_utils` - `v0.1.0+1`](#wyatt_type_utils---v0101)
- [`wyatt_cloud_messaging_bloc_base` - `v0.1.1+5`](#wyatt_cloud_messaging_bloc_base---v0115)
- [`wyatt_authentication_bloc` - `v0.6.0+1`](#wyatt_authentication_bloc---v0601)
- [`wyatt_crud_bloc_firestore` - `v0.2.0+2`](#wyatt_crud_bloc_firestore---v0202)
- [`wyatt_crud_bloc` - `v0.2.0+2`](#wyatt_crud_bloc---v0202)
- [`wyatt_i18n` - `v2.0.4`](#wyatt_i18n---v204)
- [`wyatt_architecture` - `v0.2.0+3`](#wyatt_architecture---v0203)
- [`wyatt_form_bloc` - `v0.2.0+6`](#wyatt_form_bloc---v0206)
- [`wyatt_cloud_messaging_bloc_firebase` - `v0.1.0+5`](#wyatt_cloud_messaging_bloc_firebase---v0105)
- [`wyatt_bloc_layout` - `v0.1.2+7`](#wyatt_bloc_layout---v0127)
- [`cloud_messaging_bloc_firebase_example` - `v1.0.1`](#cloud_messaging_bloc_firebase_example---v101)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `wyatt_cloud_messaging_bloc_base` - `v0.1.1+5`
- `wyatt_authentication_bloc` - `v0.6.0+1`
- `wyatt_crud_bloc_firestore` - `v0.2.0+2`
- `wyatt_crud_bloc` - `v0.2.0+2`
- `wyatt_i18n` - `v2.0.4`
- `wyatt_architecture` - `v0.2.0+3`
- `wyatt_form_bloc` - `v0.2.0+6`
- `wyatt_cloud_messaging_bloc_firebase` - `v0.1.0+5`
- `wyatt_bloc_layout` - `v0.1.2+7`
- `cloud_messaging_bloc_firebase_example` - `v1.0.1`
---
#### `architecture_example` - `v2.0.0`
- **REFACTOR**(wyatt_architecture): upgrade usecases to add NoParams.
- **REFACTOR**(architecture): update naming methodes (close #47).
- **REFACTOR**(architecture): update example. (close #38).
- **FIX**: apply dart fix --apply.
- **FIX**: remove wyatt arch ios example.
- **FEAT**(arch): add new project for wyatt clean architecture.
- **DOCS**(arch): add documentation.
- **BREAKING** **REFACTOR**(http): fix cascade dart good practices + docs.
#### `bloc_layout_example` - `v2.0.0`
- **REFACTOR**(bloc_layouts): refactored block using the ui layout package, due to breaking changes.
- **REFACTOR**(bloc_layout): remove cross package export.
- **REFACTOR**(bloc_layout): migrate bloc layouts using copywith component method (close #121).
- **REFACTOR**(bloc_layout): update example (#92).
- **REFACTOR**(bloc_layout): update example with new app bar entity (#90).
- **FIX**: apply dart fix --apply.
- **FIX**: remove wyatt arch ios example.
- **FIX**(ui): change example to be compatible with new AppTopBar and TextWrapper.
- **FIX**(bloc_layout): fix textwrapper.
- **FEAT**(bloc_layout): rework on structure using new components and layouts.
- **FEAT**(bloc_layout): add new package to combine bloc_helper, crud_bloc, ui_components, and ui_layout.
- **BREAKING** **FEAT**(layout): update layout plugins with new components system.
#### `crud_bloc_example` - `v2.0.0`
- **FIX**: rename wyatt_bruc_bloc_firestore main package file.
- **FIX**(crud): update example.
- **FEAT**(crud): add streaming usecase (closes #180).
- **FEAT**(crud): change responsibility of blocs (closes #45, closes #44).
- **DOCS**(crud): add example app.
- **BREAKING** **FEAT**(crud): make crudbuilder integration more easy by integrating blocbuilder (closes #181).
- **BREAKING** **FEAT**(crud): move crud firestore implementation into his own package.
#### `example_router` - `v2.0.0`
- **REFACTOR**(authentication): remove cross package export.
- **REFACTOR**(authentication): use fromFirebaseUser factory to parse user.
- **REFACTOR**(auth): update example with new input builders.
- **FIX**(authentication_bloc): upgrade google sign to his major v.
- **FIX**(authentication_bloc): go router version refactoring.
- **FIX**(authentication): make sur access token is available on every steps.
- **FIX**(authentication): allow email/password validators customization (closes #57).
- **FIX**(auth): fix some bugs to validate publishing.
- **FIX**(auth): update form plugin and fix auth.
- **FIX**(auth): example needs multidex support.
- **FEAT**(authentication): remove session wrapper for AuthenticationSession.
- **FEAT**(authentication): add custom routine, and documentation.
- **FEAT**(authentication): add full event support.
- **FEAT**(authentication): add google sign in in signIn cubit.
- **FEAT**(auth): add reactive repo + extra data + router examples + tests.
- **FEAT**(auth): add google, facebook, apple, twitter login.
- **DOCS**(authentication): update example with multiple data sources.
- **DOCS**(authentication): add full dartdoc.
- **DOCS**(authentication): update example.
- **DOCS**(authentication): update example.
- **DOCS**(auth): add correct header.
- **BREAKING** **FIX**(authentication): use correct usecase and result.
- **BREAKING** **FIX**(authentication): use FutureOrResult extension (close #41).
- **BREAKING** **FIX**(auth): add signInWithEmailAndPassword and signInAnonymously methods in SignInCubit #26.
- **BREAKING** **FEAT**(authentication): add repo in callback usecases (close #55).
- **BREAKING** **FEAT**(auth): use form_bloc package.
- **BREAKING** **FEAT**(authentication): rename package.
#### `form_bloc_example` - `v2.0.0`
- **REFACTOR**(form): refactor simple example.
- **FEAT**(from): add form validator class with strategy design pattern.
- **BREAKING** **REFACTOR**(form): input builders provides FormInput.
#### `wyatt_i18n_example` - `v2.0.0`
- **FIX**: apply dart fix --apply.
- **FEAT**(i18n): add i18n delegate + example.
- **FEAT**(i18n): add ICU parser.
- **FEAT**(i18n): add arb, json and yaml parsers.
- **BREAKING** **FEAT**(i18n): rename few files + add clearer documentation.
#### `wyatt_ui_components_example` - `v2.0.0`
- **REFACTOR**(ui_components): migrate top nav bar using generify top bar.
- **REFACTOR**(ui_components): update example (close #115).
- **REFACTOR**(ui_component): update example (#92).
- **REFACTOR**(ui_components): update example (#92).
- **FIX**: remove wyatt arch ios example.
- **FEAT**: add items manipulation in bottom bar component.
- **FEAT**(ui): add colors and rework ComponentThemeData.
- **FEAT**(ui): make gradient as component.
- **FEAT**(ui_components): update attributs and proxy most of appbar attributs.
- **FEAT**(ui_components): add centerTitle property to app bar component.
- **FEAT**(ui): add some useful text customization in TextWrapper (closes #149).
- **FEAT**(ui_component): add string extension to easely wrap text.
- **FEAT**(ui_components): add text wrapper instead of String/Widget for Texts.
- **FEAT**(ui_components): add information_card & quote_card (#126).
- **FEAT**(ui_components): make component data field nullable (#92).
- **FEAT**(ui_components): make app bar leading & actions customizable.
- **FEAT**(ui_layout): update example & move configure function (#69).
- **FEAT**: create new package to split components and layouts.
- **BREAKING** **FEAT**(ui_components): available same type component usage (#200).
- **BREAKING** **FEAT**(ui): move last extensions + add extension provider.
#### `wyatt_ui_kit_example` - `v2.0.0`
- **REFACTOR**(ui): rework text gradient and text wrapper.
- **REFACTOR**(ui_kit): use tapped state and merged styles.
- **REFACTOR**(ui_kit): Refactored code using the UI components package, due to breaking changes.
- **REFACTOR**(ui_kit): update textinput component using borderColors as Color.
- **FIX**(ui_kit): add cacheExtend as a trade-off in listview example.
- **FIX**: apply dart fix --apply.
- **FIX**(ui_kit): add local font assets + compress images.
- **FIX**(ui_kit): fix text align, add selection and update example for rich text builder.
- **FIX**: upgrade to flutter 3.10.
- **FIX**(ui_kit): remove null check operator in Loader component.
- **FEAT**(ui_kit): make skillcard header icon customizable.
- **FEAT**(ui_kit): implement flat button.
- **FEAT**: implement notification abstraction package.
- **FEAT**(ui_kit): implement top nav bar.
- **FEAT**(ui_kit): implement top app bar and update example.
- **FEAT**(ui_kit): add card theme extension, fix bugs & update example (close #126).
- **FEAT**(ui_kit): add quote / skill / portfolio cards (#126).
- **FEAT**(ui_kit): update example (#138).
- **FEAT**(ui_kit): update example by removing adaptative theme.
- **FEAT**(ui_kit): implement rich text builder (closes #141).
- **FEAT**(ui): add pricing card.
- **FEAT**(ui_kit): update example with full studio button theme.
- **FEAT**(ui_kit): add theme control in example.
- **FEAT**(ui_kit): finalize material ready buttons.
- **FEAT**(ui_kit): implement information card (#126).
- **FEAT**(ui): update default extension implementation.
- **FEAT**(ui_kit): update example with drawer and custom launch parameters.
- **FEAT**(ui_kit): implement file selection button with invalid cubit and dotted package.
- **FEAT**(ui_kit): implement simple icon button and use dimension style.
- **FEAT**(ui_kit): add symbol button + enhance bloc control over state.
- **FEAT**(ui_kit): allow to cascade styles in ThemeHelper.
- **FEAT**(ui_kit): use MultiColor in button style.
- **FEAT**(ui_kit): implement flat/outlined button.
- **FEAT**(ui): add animated decorated box + animate all buttons + customize duration in style.
- **BREAKING** **REFACTOR**(ui): remove bloc export in buttons to be state management solution agnostic (closes #147).
- **BREAKING** **FEAT**(ui): rework theme resolver mechanism + move theme extension implementations.
- **BREAKING** **FEAT**(ui): move last extensions + add extension provider.
#### `wyatt_ui_layout_example` - `v2.0.0`
- **REFACTOR**(ui_layouts): Refactored block using the UI components package, introducing breaking changes.
- **REFACTOR**(ui_layout): update exemple (close #116).
- **REFACTOR**(ui_layout): update example (#92).
- **REFACTOR**(ui_layout): update example with components updates (close #90).
- **REFACTOR**(ui_layout): update field name.
- **FIX**: remove wyatt arch ios example.
- **FIX**(ui): change example to be compatible with new AppTopBar and TextWrapper.
- **FIX**(ui_layout): fix textwrapper.
- **FIX**(ui_layout): fix emample after splititng packages.
- **FEAT**: implement notification abstraction package.
- **FEAT**: update layouts to allow more control on components.
- **FEAT**(ui_layout): add new package for app compenant and start implementing layouts.
- **DOCS**: add doc.
- **BREAKING** **FEAT**(layout): update layout plugins with new components system.
#### `bloc_helper_example` - `v1.1.0`
- **FIX**: compilation issue with flutter 3.16.0 and generics name.
- **FEAT**(bloc): add a lot of docs, fix `onWrap`, and add repo provider.
- **FEAT**(bloc): add provider, consumer and helpers.
- **DOCS**(bloc): add ios example.
#### `component_copy_with_extension_example` - `v1.1.0`
- **FIX**: remove wyatt arch ios example.
- **FEAT**: add class annotation for component code generators.
#### `component_copy_with_gen_example` - `v1.1.0`
- **FIX**: remove wyatt arch ios example.
- **FIX**(ui): change example to be compatible with new AppTopBar and TextWrapper.
- **FIX**(cw_gen): fix textwrapper.
- **FIX**(component_copy_with_gen): update example (#118).
- **FEAT**: add generators for components proxy and mixins to enable copywith methods.
#### `notification_bloc_example` - `v1.0.1`
- **FIX**: apply dart format.
#### `type_utils_example` - `v1.1.0`
- **FEAT**(types): add strongly typed Option and Result.
- **FEAT**(types): add mason generated package.
- **DOCS**: remove useless web example.
#### `wyatt_continuous_deployment` - `v1.1.1`
- **REFACTOR**(cd): fiw injectable warning.
#### `wyatt_continuous_deployment_example` - `v1.0.1`
- **FIX**(cd): make cd use new usecases.
#### `wyatt_type_utils` - `v0.1.0+1`
- **REFACTOR**(utils): fix warnings.
## 2025-05-21
### Changes
---
Packages with breaking changes:
- [`wyatt_authentication_bloc` - `v0.6.0`](#wyatt_authentication_bloc---v060)
- [`wyatt_type_utils` - `v0.1.0`](#wyatt_type_utils---v010)
- [`wyatt_ui_components` - `v0.4.0`](#wyatt_ui_components---v040)
Packages with other changes:
- [`wyatt_analysis` - `v2.7.0`](#wyatt_analysis---v270)
- [`wyatt_architecture` - `v0.2.0+2`](#wyatt_architecture---v0202)
- [`wyatt_cloud_messaging_bloc_base` - `v0.1.1+4`](#wyatt_cloud_messaging_bloc_base---v0114)
- [`wyatt_continuous_deployment` - `v1.1.0`](#wyatt_continuous_deployment---v110)
- [`wyatt_form_bloc` - `v0.2.0+5`](#wyatt_form_bloc---v0205)
- [`wyatt_go_router` - `v1.0.1`](#wyatt_go_router---v101)
- [`wyatt_http_client` - `v2.0.2`](#wyatt_http_client---v202)
- [`wyatt_ui_layout` - `v0.1.3`](#wyatt_ui_layout---v013)
- [`wyatt_crud_bloc_firestore` - `v0.2.0+1`](#wyatt_crud_bloc_firestore---v0201)
- [`wyatt_crud_bloc` - `v0.2.0+1`](#wyatt_crud_bloc---v0201)
- [`wyatt_i18n` - `v2.0.3`](#wyatt_i18n---v203)
- [`wyatt_cloud_messaging_bloc_firebase` - `v0.1.0+4`](#wyatt_cloud_messaging_bloc_firebase---v0104)
- [`wyatt_bloc_layout` - `v0.1.2+6`](#wyatt_bloc_layout---v0126)
- [`wyatt_ui_kit` - `v3.2.5`](#wyatt_ui_kit---v325)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `wyatt_crud_bloc_firestore` - `v0.2.0+1`
- `wyatt_crud_bloc` - `v0.2.0+1`
- `wyatt_i18n` - `v2.0.3`
- `wyatt_cloud_messaging_bloc_firebase` - `v0.1.0+4`
- `wyatt_bloc_layout` - `v0.1.2+6`
- `wyatt_ui_kit` - `v3.2.5`
---
#### `wyatt_authentication_bloc` - `v0.6.0`
- **FIX**(authentication_bloc): upgrade google sign to his major v.
- **FIX**: apply dart format.
- **FIX**: apply dart fix --apply.
- **FIX**(authentication_bloc): go router version refactoring.
- **FIX**: use correct behavior subject for stream session.
- **BREAKING** **FIX**(authentication): use correct usecase and result.
#### `wyatt_type_utils` - `v0.1.0`
- **BREAKING** **REFACTOR**(wyatt_type_utils): upgrade Result to prepare migration to sealed classes.
#### `wyatt_ui_components` - `v0.4.0`
- **FIX**: make components nullable.
- **FIX**(ui_components): rollback private fileds in component theme data.
- **FIX**: apply dart format.
- **FEAT**: add generic card.
- **FEAT**(ui_components): marking fields as private since it was accessible from getters.
- **BREAKING** **FEAT**(ui_components): available same type component usage (#200).
#### `wyatt_analysis` - `v2.7.0`
- **REFACTOR**: rename tools/ to tool/ to follow dart conventions.
- **FIX**: remove not yet implemented rule.
- **FEAT**(analysis): remove describe properties rule.
- **FEAT**: upgrade to handle dart 3.0.0.
- **FEAT**(analysis): add full toolchain to easely update ruleset.
#### `wyatt_architecture` - `v0.2.0+2`
- **REFACTOR**(wyatt_architecture): upgrade usecases to add NoParams.
- **FIX**: apply dart fix --apply.
- **DOCS**(wyatt_architecture): update readme.
#### `wyatt_cloud_messaging_bloc_base` - `v0.1.1+4`
- **FIX**(notification): port the new usecase syntax.
#### `wyatt_continuous_deployment` - `v1.1.0`
- **REFACTOR**: rename default cd config file from wyatt.yaml to cd_config.yaml.
- **FIX**(cd): make cd use new usecases.
- **FIX**(wyatt_cd): make getIt initializable.
- **FEAT**: fetch certs in read-only.
#### `wyatt_form_bloc` - `v0.2.0+5`
- **FIX**: apply dart format.
#### `wyatt_go_router` - `v1.0.1`
- **DOCS**(router): add missing template name.
#### `wyatt_http_client` - `v2.0.2`
- **FIX**: apply dart fix --apply.
#### `wyatt_ui_layout` - `v0.1.3`
- **REFACTOR**(ui_layouts): Refactored block using the UI components package, introducing breaking changes.
- **FIX**(ui_layout): fix bottom navbar layouts.
- **FIX**(ui_layout): fix topappbar layouts.
- **FIX**: make components nullable.
- **FEAT**: implement notification abstraction package.
## 2023-11-18
### Changes
+1
View File
@@ -4,6 +4,7 @@ packages:
- "packages/**"
ignore:
- "packages/**/example"
- "packages/**/.dart_tool/**"
sdkPath: auto
-8
View File
@@ -1,11 +1,3 @@
## 2.7.0
- **REFACTOR**: rename tools/ to tool/ to follow dart conventions.
- **FIX**: remove not yet implemented rule.
- **FEAT**(analysis): remove describe properties rule.
- **FEAT**: upgrade to handle dart 3.0.0.
- **FEAT**(analysis): add full toolchain to easely update ruleset.
## 2.6.1
- **REMOVED** diagnostic_describe_all_properties (https://dart.dev/tools/linter-rules/diagnostic_describe_all_properties)
+1 -1
View File
@@ -39,7 +39,7 @@ To use the lints, add a dependency in your `pubspec.yaml` :
```yaml
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: 2.7.0
version: 2.6.1
```
Then, add an include in `analysis_options.yaml` :
+1 -1
View File
@@ -17,7 +17,7 @@
name: wyatt_analysis
description: Lint rules for Dart and Flutter used internally at Wyatt Studio.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis
version: 2.7.0
version: 2.6.1
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
-10
View File
@@ -1,13 +1,3 @@
## 0.2.0+3
- Update a dependency to the latest release.
## 0.2.0+2
- **REFACTOR**(wyatt_architecture): upgrade usecases to add NoParams.
- **FIX**: apply dart fix --apply.
- **DOCS**(wyatt_architecture): update readme.
## 0.2.0+1
- **FIX**: apply dart fix --apply.
+4 -6
View File
@@ -177,13 +177,13 @@ Then implements your data sources:
```dart
class PhotoApiDataSourceImpl extends PhotoRemoteDataSource {
final MiddlewareClient _client;
final Client _client;
PhotoApiDataSourceImpl(this._client);
@override
Future<Photo> getPhoto(int id) async {
final response = await _client.get(Uri.parse('/photos/$id'));
final response = await _client.get(Uri.parse('$kDefaultApiUrl/photos/$id'));
final photo =
PhotoModel.fromJson(jsonDecode(response.body) as Map<String, Object?>);
return photo;
@@ -197,7 +197,7 @@ class PhotoApiDataSourceImpl extends PhotoRemoteDataSource {
(startQuery.isNotEmpty || limitQuery.isNotEmpty) ? '?' : '';
final delimiter2 =
(startQuery.isNotEmpty && limitQuery.isNotEmpty) ? '&' : '';
final url = '/photos$delimiter1$startQuery$delimiter2$limitQuery';
final url = '$kDefaultApiUrl/photos$delimiter1$startQuery$delimiter2$limitQuery';
final response = await _client.get(Uri.parse(url));
final photos =
ListPhotoModel.fromJson({'photos': jsonDecode(response.body)});
@@ -206,9 +206,7 @@ class PhotoApiDataSourceImpl extends PhotoRemoteDataSource {
}
```
> 1: Note that here we use `MiddlewareClient` from our http package.
> 2: You can create multiple implementations (one real and one mock for example).
> 1: You can create multiple implementations (one real and one mock for example).
And implement the repositories:
@@ -1,13 +0,0 @@
## 2.0.0
> Note: This release has breaking changes.
- **REFACTOR**(wyatt_architecture): upgrade usecases to add NoParams.
- **REFACTOR**(architecture): update naming methodes (close #47).
- **REFACTOR**(architecture): update example. (close #38).
- **FIX**: apply dart fix --apply.
- **FIX**: remove wyatt arch ios example.
- **FEAT**(arch): add new project for wyatt clean architecture.
- **DOCS**(arch): add documentation.
- **BREAKING** **REFACTOR**(http): fix cascade dart good practices + docs.
@@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2024 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,4 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
export 'middleware_context.dart';
export 'middleware_request.dart';
export 'middleware_response.dart';
export 'unfreezed_request.dart';
const String kDefaultApiUrl = 'https://jsonplaceholder.typicode.com/';
@@ -26,7 +26,6 @@ import 'package:architecture_example/domain/data_sources/local/favorite_local_da
import 'package:architecture_example/domain/data_sources/remote/album_remote_data_source.dart';
import 'package:architecture_example/domain/data_sources/remote/photo_remote_data_source.dart';
import 'package:get_it/get_it.dart';
import 'package:wyatt_http_client/wyatt_http_client.dart';
final getIt = GetIt.I;
@@ -50,22 +49,11 @@ abstract class GetItInitializer {
..registerLazySingleton<FavoriteLocalDataSource>(
FavoriteHiveDataSource.new,
)
..registerLazySingleton<MiddlewareClient>(() {
final Pipeline pipeline = Pipeline()
..addMiddleware(
const UriPrefixMiddleware(
protocol: Protocols.https,
authority: 'jsonplaceholder.typicode.com',
),
)
..addMiddleware(const BodyToJsonMiddleware());
return MiddlewareClient(pipeline: pipeline);
})
..registerLazySingleton<PhotoRemoteDataSource>(
() => PhotoApiDataSourceImpl(getIt()),
PhotoApiDataSourceImpl.new,
)
..registerLazySingleton<AlbumRemoteDataSource>(
() => AlbumApiDataSourceImpl(getIt()),
AlbumApiDataSourceImpl.new,
);
}
@@ -16,20 +16,25 @@
import 'dart:convert';
import 'package:architecture_example/core/constants/constants.dart';
import 'package:architecture_example/data/models/album_model.dart';
import 'package:architecture_example/data/models/list_album_model.dart';
import 'package:architecture_example/domain/data_sources/remote/album_remote_data_source.dart';
import 'package:architecture_example/domain/entities/album.dart';
import 'package:wyatt_http_client/wyatt_http_client.dart';
import 'package:http/http.dart';
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
class AlbumApiDataSourceImpl extends AlbumRemoteDataSource {
AlbumApiDataSourceImpl(this._client);
final MiddlewareClient _client;
AlbumApiDataSourceImpl({
Client? client,
}) : _client = client ?? Client();
final Client _client;
@override
Future<Album> getAlbum(int id) async {
final response = await _client.get(Uri.parse('/albums/$id'));
final response = await _client
.get(Uri.parse('$kDefaultApiUrl/albums/$id'));
final album =
AlbumModel.fromJson(jsonDecode(response.body) as Map<String, Object?>);
return album;
@@ -43,7 +48,7 @@ class AlbumApiDataSourceImpl extends AlbumRemoteDataSource {
(startQuery.isNotEmpty || limitQuery.isNotEmpty) ? '?' : '';
final delimiter2 =
(startQuery.isNotEmpty && limitQuery.isNotEmpty) ? '&' : '';
final url = '/albums$delimiter1$startQuery$delimiter2$limitQuery';
final url = '$kDefaultApiUrl/albums$delimiter1$startQuery$delimiter2$limitQuery';
final response = await _client.get(Uri.parse(url));
final albums =
ListAlbumModel.fromJson({'albums': jsonDecode(response.body)});
@@ -16,20 +16,24 @@
import 'dart:convert';
import 'package:architecture_example/core/constants/constants.dart';
import 'package:architecture_example/data/models/list_photo_model.dart';
import 'package:architecture_example/data/models/photo_model.dart';
import 'package:architecture_example/domain/data_sources/remote/photo_remote_data_source.dart';
import 'package:architecture_example/domain/entities/photo.dart';
import 'package:wyatt_http_client/wyatt_http_client.dart';
import 'package:http/http.dart';
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
class PhotoApiDataSourceImpl extends PhotoRemoteDataSource {
PhotoApiDataSourceImpl(this._client);
final MiddlewareClient _client;
PhotoApiDataSourceImpl({
Client? client,
}) : _client = client ?? Client();
final Client _client;
@override
Future<Photo> getPhoto(int id) async {
final response = await _client.get(Uri.parse('/photos/$id'));
final response = await _client.get(Uri.parse('$kDefaultApiUrl/photos/$id'));
final photo =
PhotoModel.fromJson(jsonDecode(response.body) as Map<String, Object?>);
return photo;
@@ -43,7 +47,8 @@ class PhotoApiDataSourceImpl extends PhotoRemoteDataSource {
(startQuery.isNotEmpty || limitQuery.isNotEmpty) ? '?' : '';
final delimiter2 =
(startQuery.isNotEmpty && limitQuery.isNotEmpty) ? '&' : '';
final url = '/photos$delimiter1$startQuery$delimiter2$limitQuery';
final url =
'$kDefaultApiUrl/photos$delimiter1$startQuery$delimiter2$limitQuery';
final response = await _client.get(Uri.parse(url));
final photos =
ListPhotoModel.fromJson({'photos': jsonDecode(response.body)});
@@ -60,7 +65,8 @@ class PhotoApiDataSourceImpl extends PhotoRemoteDataSource {
final limitQuery = limit.isNotNull ? '_limit=$limit' : '';
final delimiter =
(startQuery.isNotEmpty && limitQuery.isNotEmpty) ? '&' : '';
final url = '/photos?albumId=$albumId&$startQuery$delimiter$limitQuery';
final url =
'$kDefaultApiUrl/photos?albumId=$albumId&$startQuery$delimiter$limitQuery';
final response = await _client.get(Uri.parse(url));
final photos =
ListPhotoModel.fromJson({'photos': jsonDecode(response.body)});
@@ -23,8 +23,8 @@ class AddPhotoToFavorites extends AsyncUseCase<Photo, List<Photo>> {
final PhotoRepository _photoRepository;
@override
FutureOrResult<List<Photo>> execute(Photo? params) async {
await _photoRepository.addPhotoToFavorites(params!);
FutureOrResult<List<Photo>> execute(Photo params) async {
await _photoRepository.addPhotoToFavorites(params);
return _photoRepository.getAllPhotosFromFavorites();
}
}
@@ -22,6 +22,6 @@ class CheckIfPhotoIsInFavorites extends AsyncUseCase<int, bool> {
final PhotoRepository _photoRepository;
@override
FutureOrResult<bool> execute(int? params) async =>
_photoRepository.checkIfPhotoIsInFavorites(params!);
FutureOrResult<bool> execute(int params) async =>
_photoRepository.checkIfPhotoIsInFavorites(params);
}
@@ -23,8 +23,8 @@ class DisplayPhoto extends AsyncUseCase<int, Photo> {
final PhotoRepository _photoRepository;
@override
FutureOrResult<Photo> execute(int? params) {
final photo = _photoRepository.getPhoto(params!);
FutureOrResult<Photo> execute(int params) {
final photo = _photoRepository.getPhoto(params);
return photo;
}
}
@@ -24,9 +24,9 @@ class OpenAlbum extends AsyncUseCase<QueryParameters, List<Photo>> {
final PhotoRepository _photoRepository;
@override
FutureOrResult<List<Photo>> execute(QueryParameters? params) {
FutureOrResult<List<Photo>> execute(QueryParameters params) {
final photos = _photoRepository.getPhotosFromAlbum(
params!.albumId,
params.albumId,
start: params.start,
limit: params.limit,
);
@@ -23,8 +23,8 @@ class RemovePhotoFromFavorites extends AsyncUseCase<int, List<Photo>> {
final PhotoRepository _photoRepository;
@override
FutureOrResult<List<Photo>> execute(int? params) async {
await _photoRepository.deletePhotoFromFavorites(params!);
FutureOrResult<List<Photo>> execute(int params) async {
await _photoRepository.deletePhotoFromFavorites(params);
return _photoRepository.getAllPhotosFromFavorites();
}
}
@@ -24,9 +24,9 @@ class RetrieveAllAlbums extends AsyncUseCase<QueryParameters, List<Album>> {
final PhotoRepository _photoRepository;
@override
FutureOrResult<List<Album>> execute(QueryParameters? params) {
FutureOrResult<List<Album>> execute(QueryParameters params) {
final albums = _photoRepository.getAllAlbums(
start: params!.start,
start: params.start,
limit: params.limit,
);
return albums;
@@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.0
version: 1.0.0+1
environment:
sdk: ">=2.17.0 <3.0.0"
@@ -32,36 +32,34 @@ dependencies:
wyatt_architecture:
path: "../"
flutter_bloc: ^9.1.1
get_it: ^8.0.3
flutter_bloc: ^8.1.1
get_it: ^7.2.0
hive: ^2.2.3
hive_flutter: ^1.1.0
equatable: ^2.0.5
stream_transform: ^2.1.0
bloc_concurrency: ^0.3.0
freezed_annotation: ^3.0.0
bloc_concurrency: ^0.2.0
freezed_annotation: ^2.2.0
json_annotation: ^4.7.0
wyatt_bloc_helper:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^2.0.3
wyatt_http_client:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^2.0.1
version: ^2.0.2
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.1.0+1
version: ^0.0.5
http: ^1.2.1
dev_dependencies:
build_runner: ^2.3.2
flutter_test: { sdk: flutter }
freezed: ^3.0.0-0.0.dev
freezed: ^2.2.1
hive_generator: ^2.0.0
json_serializable: ^6.5.4
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^2.7.0
version: ^2.5.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
+3 -3
View File
@@ -17,7 +17,7 @@
name: wyatt_architecture
description: Wyatt Architecture contains useful classes to help you to create a clean architecture following the Wyatt Architecture principles.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_architecture
version: 0.2.0+3
version: 0.2.0+1
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -28,9 +28,9 @@ dependencies:
generic_usecase: ^3.0.0
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.1.0+1
version: ^0.0.5
dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.6.1
@@ -1,18 +1,3 @@
## 0.6.0+1
- Update a dependency to the latest release.
## 0.6.0
> Note: This release has breaking changes.
- **FIX**(authentication_bloc): upgrade google sign to his major v.
- **FIX**: apply dart format.
- **FIX**: apply dart fix --apply.
- **FIX**(authentication_bloc): go router version refactoring.
- **FIX**: use correct behavior subject for stream session.
- **BREAKING** **FIX**(authentication): use correct usecase and result.
## 0.5.1+3
- upgrade deps
@@ -1,32 +0,0 @@
## 2.0.0
> Note: This release has breaking changes.
- **REFACTOR**(authentication): remove cross package export.
- **REFACTOR**(authentication): use fromFirebaseUser factory to parse user.
- **REFACTOR**(auth): update example with new input builders.
- **FIX**(authentication_bloc): upgrade google sign to his major v.
- **FIX**(authentication_bloc): go router version refactoring.
- **FIX**(authentication): make sur access token is available on every steps.
- **FIX**(authentication): allow email/password validators customization (closes #57).
- **FIX**(auth): fix some bugs to validate publishing.
- **FIX**(auth): update form plugin and fix auth.
- **FIX**(auth): example needs multidex support.
- **FEAT**(authentication): remove session wrapper for AuthenticationSession.
- **FEAT**(authentication): add custom routine, and documentation.
- **FEAT**(authentication): add full event support.
- **FEAT**(authentication): add google sign in in signIn cubit.
- **FEAT**(auth): add reactive repo + extra data + router examples + tests.
- **FEAT**(auth): add google, facebook, apple, twitter login.
- **DOCS**(authentication): update example with multiple data sources.
- **DOCS**(authentication): add full dartdoc.
- **DOCS**(authentication): update example.
- **DOCS**(authentication): update example.
- **DOCS**(auth): add correct header.
- **BREAKING** **FIX**(authentication): use correct usecase and result.
- **BREAKING** **FIX**(authentication): use FutureOrResult extension (close #41).
- **BREAKING** **FIX**(auth): add signInWithEmailAndPassword and signInAnonymously methods in SignInCubit #26.
- **BREAKING** **FEAT**(authentication): add repo in callback usecases (close #55).
- **BREAKING** **FEAT**(auth): use form_bloc package.
- **BREAKING** **FEAT**(authentication): rename package.
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.0
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
@@ -30,12 +30,12 @@ dependencies:
flutter:
sdk: flutter
go_router: ^15.1.2
firebase_core: ^3.13.1
flutter_bloc: ^9.1.1
firebase_auth: ^5.5.4
go_router: ^10.1.0
firebase_core: ^2.1.1
flutter_bloc: ^8.1.1
firebase_auth: ^4.2.0
google_sign_in: ^6.1.4
get_it: ^8.0.3
get_it: ^7.2.0
wyatt_authentication_bloc:
path: "../"
@@ -50,7 +50,7 @@ dependencies:
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.1.0+1
version: 0.0.5
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
@@ -65,7 +65,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
@@ -1,7 +1,7 @@
name: wyatt_authentication_bloc
description: Authentication BLoC for Flutter
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_authentication_bloc
version: 0.6.0+1
version: 0.5.1+3
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -12,31 +12,31 @@ environment:
dependencies:
flutter: { sdk: flutter }
crypto: ^3.0.3
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.3
equatable: ^2.0.5
firebase_auth: ^5.5.4
firebase_auth: ^4.10.1
google_sign_in: ^6.1.5
rxdart: ^0.28.0
rxdart: ^0.27.7
flutter_secure_storage: ^9.0.0
http: ^1.1.0
wyatt_form_bloc:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+6
version: ^0.2.0+4
wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+3
version: ^0.2.0+1
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.1.0+1
version: ^0.0.5
dev_dependencies:
flutter_test: { sdk: flutter }
bloc_test: ^10.0.0
bloc_test: ^9.1.0
mocktail: ^1.0.0
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^2.7.0
version: ^2.5.0
-2
View File
@@ -1,5 +1,3 @@
## 2.0.3
## 2.0.2
- **FIX**: compilation issue with flutter 3.16.0 and generics name.
@@ -1,7 +0,0 @@
## 1.1.0
- **FIX**: compilation issue with flutter 3.16.0 and generics name.
- **FEAT**(bloc): add a lot of docs, fix `onWrap`, and add repo provider.
- **FEAT**(bloc): add provider, consumer and helpers.
- **DOCS**(bloc): add ios example.
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.0
version: 1.0.0+1
environment:
sdk: ">=3.0.0 <4.0.0"
@@ -35,7 +35,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.5
equatable: ^2.0.5
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.1
wyatt_bloc_helper:
path: ../
@@ -49,7 +49,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
flutter_lints: ^2.0.1
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
+4 -4
View File
@@ -1,7 +1,7 @@
name: wyatt_bloc_helper
description: Your best friend for blocs in Flutter
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_helper
version: 2.0.3
version: 2.0.2
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -11,13 +11,13 @@ environment:
dependencies:
flutter: { sdk: flutter }
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.1
equatable: ^2.0.5
dev_dependencies:
flutter_test: { sdk: flutter }
bloc_test: ^10.0.0
bloc_test: ^9.1.0
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.5.0
-8
View File
@@ -1,11 +1,3 @@
## 0.1.2+7
- Update a dependency to the latest release.
## 0.1.2+6
- Update a dependency to the latest release.
## 0.1.2+5
- Update a dependency to the latest release.
@@ -1,17 +0,0 @@
## 2.0.0
> Note: This release has breaking changes.
- **REFACTOR**(bloc_layouts): refactored block using the ui layout package, due to breaking changes.
- **REFACTOR**(bloc_layout): remove cross package export.
- **REFACTOR**(bloc_layout): migrate bloc layouts using copywith component method (close #121).
- **REFACTOR**(bloc_layout): update example (#92).
- **REFACTOR**(bloc_layout): update example with new app bar entity (#90).
- **FIX**: apply dart fix --apply.
- **FIX**: remove wyatt arch ios example.
- **FIX**(ui): change example to be compatible with new AppTopBar and TextWrapper.
- **FIX**(bloc_layout): fix textwrapper.
- **FEAT**(bloc_layout): rework on structure using new components and layouts.
- **FEAT**(bloc_layout): add new package to combine bloc_helper, crud_bloc, ui_components, and ui_layout.
- **BREAKING** **FEAT**(layout): update layout plugins with new components system.
@@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.0
version: 1.0.0+1
environment:
sdk: ">=2.17.0 <3.0.0"
@@ -32,20 +32,20 @@ dependencies:
wyatt_bloc_layout:
path: "../"
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.2
wyatt_bloc_helper:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.0.3
version: ^2.0.2
wyatt_ui_layout:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.1.3+1
version: ^0.1.2+3
wyatt_crud_bloc:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.2.0+2
version: ^0.2.0
wyatt_ui_components:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.4.0
version: ^0.3.0+2
wyatt_component_copy_with_extension:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.0.1
@@ -59,7 +59,7 @@ dev_dependencies:
version: ^2.0.1
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.5.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
+6 -6
View File
@@ -1,7 +1,7 @@
name: wyatt_bloc_layout
description: Layouts based on bloc helper library
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_layout
version: 0.1.2+7
version: 0.1.2+5
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -11,23 +11,23 @@ environment:
dependencies:
flutter: { sdk: flutter }
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.2
wyatt_bloc_helper:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.0.3
version: ^2.0.2
wyatt_ui_layout:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.1.3
version: ^0.1.2+3
wyatt_crud_bloc:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.2.0+2
version: ^0.2.0
wyatt_ui_components:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.4.0
version: ^0.3.0+2
dev_dependencies:
flutter_test: { sdk: flutter }
@@ -1,11 +1,3 @@
## 0.1.1+5
- Update a dependency to the latest release.
## 0.1.1+4
- **FIX**(notification): port the new usecase syntax.
## 0.1.1+3
- Update a dependency to the latest release.
@@ -1,4 +0,0 @@
## 1.0.1
- **FIX**: apply dart format.
@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.1
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
@@ -32,7 +32,7 @@ dependencies:
flutter:
sdk: flutter
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.1
wyatt_cloud_messaging_bloc_base:
path: ../
@@ -40,7 +40,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
firebase_core: ^3.13.1
firebase_core: ^2.3.0
dev_dependencies:
flutter_test:
@@ -48,7 +48,7 @@ dev_dependencies:
wyatt_analysis:
git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
ref: wyatt_analysis-v2.7.0
ref: wyatt_analysis-v2.2.2
path: packages/wyatt_analysis
# The "flutter_lints" package below contains a set of recommended lints to
@@ -56,7 +56,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
@@ -1,7 +1,7 @@
name: wyatt_cloud_messaging_bloc_base
description: A starting point for Dart libraries or applications.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_notification_bloc
version: 0.1.1+5
version: 0.1.1+3
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -12,27 +12,27 @@ dependencies:
flutter:
sdk: flutter
equatable: ^2.0.5
firebase_messaging: ^15.2.6
flutter_bloc: ^9.1.1
rxdart: ^0.28.0
firebase_messaging: ^14.1.1
flutter_bloc: ^8.1.1
rxdart: ^0.27.7
wyatt_architecture:
hosted:
url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
name: wyatt_architecture
version: ^0.2.0+3
version: ^0.2.0+1
wyatt_type_utils:
hosted:
url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
name: wyatt_type_utils
version: ^0.1.0+1
version: ^0.0.5
wyatt_bloc_helper:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^2.0.3
version: ^2.0.2
dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^2.7.0
version: 2.2.2
@@ -1,11 +1,3 @@
## 0.1.0+5
- Update a dependency to the latest release.
## 0.1.0+4
- Update a dependency to the latest release.
## 0.1.0+3
- Update a dependency to the latest release.
@@ -1,4 +0,0 @@
## 1.0.1
- Update a dependency to the latest release.
@@ -1,6 +1,6 @@
name: cloud_messaging_bloc_firebase_example
description: A new Flutter project.
version: 1.0.1
version: 1.0.0
publish_to: 'none'
@@ -28,7 +28,7 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.4.0
# The following section is specific to Flutter.
@@ -1,7 +1,7 @@
name: wyatt_cloud_messaging_bloc_firebase
description: A.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_cloud_messaging_bloc_firebase
version: 0.1.0+5
version: 0.1.0+3
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -14,12 +14,12 @@ dependencies:
wyatt_cloud_messaging_bloc_base:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.1.1+5
version: ^0.1.1+3
path: ^1.8.0
firebase_messaging: ^15.2.6
flutter_local_notifications: ^18.0.1
firebase_messaging: ^14.6.6
flutter_local_notifications: ^15.1.0+1
dev_dependencies:
@@ -32,7 +32,7 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.4.0
# The following section is specific to Flutter.
@@ -1,5 +0,0 @@
## 1.1.0
- **FIX**: remove wyatt arch ios example.
- **FEAT**: add class annotation for component code generators.
@@ -1,6 +1,6 @@
name: component_copy_with_extension_example
description: A new Flutter project.
version: 1.1.0
version: 1.0.0
publish_to: "none"
@@ -20,7 +20,7 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.5.0
# The following section is specific to Flutter.
flutter:
@@ -14,4 +14,4 @@ dependencies:
dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.5.0
@@ -1,8 +0,0 @@
## 1.1.0
- **FIX**: remove wyatt arch ios example.
- **FIX**(ui): change example to be compatible with new AppTopBar and TextWrapper.
- **FIX**(cw_gen): fix textwrapper.
- **FIX**(component_copy_with_gen): update example (#118).
- **FEAT**: add generators for components proxy and mixins to enable copywith methods.
@@ -1,6 +1,6 @@
name: component_copy_with_gen_example
description: A new Flutter project.
version: 1.1.0
version: 1.0.0
publish_to: "none"
@@ -26,4 +26,4 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.5.0
@@ -10,8 +10,8 @@ environment:
dependencies:
build: ^2.3.1
source_gen: ^2.0.0
analyzer: ^7.4.5
source_gen: ^1.2.7
analyzer: ^6.2.0
wyatt_component_copy_with_extension:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -22,4 +22,4 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.5.0
@@ -1,14 +1,3 @@
## 1.1.1
- **REFACTOR**(cd): fiw injectable warning.
## 1.1.0
- **REFACTOR**: rename default cd config file from wyatt.yaml to cd_config.yaml.
- **FIX**(cd): make cd use new usecases.
- **FIX**(wyatt_cd): make getIt initializable.
- **FEAT**: fetch certs in read-only.
## 1.0.0
- Initial version.
@@ -1,4 +0,0 @@
## 1.0.1
- **FIX**(cd): make cd use new usecases.
@@ -1,6 +1,6 @@
name: wyatt_continuous_deployment_example
description: A new Flutter project.
version: 1.0.1
version: 1.0.0
publish_to: 'none'
@@ -25,7 +25,7 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.6.1
@@ -21,6 +21,6 @@ import 'package:wyatt_continuous_deployment/src/core/utils/task_observer.dart';
Future<void> bootstrap([Logger? logger]) async {
getIt.registerSingleton<Logger>(logger ?? Logger());
await configureDependencies();
await Injectable.configureDependencies();
Bloc.observer = TaskObserver();
}
@@ -8,95 +8,89 @@
// coverage:ignore-file
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:get_it/get_it.dart' as _i174;
import 'package:injectable/injectable.dart' as _i526;
import 'package:get_it/get_it.dart' as _i1;
import 'package:injectable/injectable.dart' as _i2;
import 'package:wyatt_continuous_deployment/src/core/injection/injectable.dart'
as _i899;
as _i21;
import 'package:wyatt_continuous_deployment/src/domain/entities/fastlane.dart'
as _i150;
as _i6;
import 'package:wyatt_continuous_deployment/src/domain/entities/flutter.dart'
as _i614;
as _i12;
import 'package:wyatt_continuous_deployment/src/domain/usecases/config/get_android_config_usecase.dart'
as _i152;
as _i18;
import 'package:wyatt_continuous_deployment/src/domain/usecases/config/get_ios_config_usecase.dart'
as _i592;
as _i19;
import 'package:wyatt_continuous_deployment/src/domain/usecases/config/init_config_usecase.dart'
as _i135;
as _i20;
import 'package:wyatt_continuous_deployment/src/domain/usecases/decrypt_keys/decrypt_keys_usecase.dart'
as _i589;
as _i5;
import 'package:wyatt_continuous_deployment/src/domain/usecases/fastlane/fastlane_create_keychain_usecase.dart'
as _i835;
as _i7;
import 'package:wyatt_continuous_deployment/src/domain/usecases/fastlane/fastlane_deploy_pilot_usecase.dart'
as _i942;
as _i8;
import 'package:wyatt_continuous_deployment/src/domain/usecases/fastlane/fastlane_deploy_supply_usecase.dart'
as _i643;
as _i9;
import 'package:wyatt_continuous_deployment/src/domain/usecases/fastlane/fastlane_get_certificates_usecase.dart'
as _i886;
as _i10;
import 'package:wyatt_continuous_deployment/src/domain/usecases/find_last_ipa_file_usecase.dart'
as _i38;
as _i11;
import 'package:wyatt_continuous_deployment/src/domain/usecases/flutter/flutter_build_app_bundle_usecase.dart'
as _i224;
as _i13;
import 'package:wyatt_continuous_deployment/src/domain/usecases/flutter/flutter_build_ipa_usecase.dart'
as _i895;
as _i14;
import 'package:wyatt_continuous_deployment/src/domain/usecases/flutter/flutter_build_xcarchive_usecase.dart'
as _i591;
as _i15;
import 'package:wyatt_continuous_deployment/src/domain/usecases/flutter/flutter_clean_usecase.dart'
as _i355;
as _i16;
import 'package:wyatt_continuous_deployment/src/domain/usecases/flutter/flutter_pub_get_usecase.dart'
as _i574;
as _i17;
import 'package:wyatt_continuous_deployment/src/domain/usecases/requirements/check_config_file_usecase.dart'
as _i652;
as _i3;
import 'package:wyatt_continuous_deployment/src/domain/usecases/requirements/check_tools_usecase.dart'
as _i677;
as _i4;
extension GetItInjectableX on _i174.GetIt {
extension GetItInjectableX on _i1.GetIt {
// initializes the registration of main-scope dependencies inside of GetIt
_i174.GetIt init({
_i1.GetIt init({
String? environment,
_i526.EnvironmentFilter? environmentFilter,
_i2.EnvironmentFilter? environmentFilter,
}) {
final gh = _i526.GetItHelper(
final gh = _i2.GetItHelper(
this,
environment,
environmentFilter,
);
final registerModule = _$RegisterModule();
gh.singleton<_i135.InitConfigUsecase>(
() => const _i135.InitConfigUsecase());
gh.singleton<_i152.GetAndroidConfigUsecase>(
() => const _i152.GetAndroidConfigUsecase());
gh.singleton<_i592.GetIosConfigUsecase>(
() => const _i592.GetIosConfigUsecase());
gh.singleton<_i677.CheckToolsUsecase>(
() => const _i677.CheckToolsUsecase());
gh.singleton<_i652.CheckConfigFileUsecase>(
() => const _i652.CheckConfigFileUsecase());
gh.singleton<_i38.FindLastIpaFileUsecase>(
() => const _i38.FindLastIpaFileUsecase());
gh.singleton<_i591.FlutterBuildXcarchiveUsecase>(
() => const _i591.FlutterBuildXcarchiveUsecase());
gh.singleton<_i355.FlutterCleanUsecase>(
() => const _i355.FlutterCleanUsecase());
gh.singleton<_i895.FlutterBuildIpaUsecase>(
() => const _i895.FlutterBuildIpaUsecase());
gh.singleton<_i224.FlutterBuildAppBundleUsecase>(
() => const _i224.FlutterBuildAppBundleUsecase());
gh.singleton<_i574.FlutterPubGetUsecase>(
() => const _i574.FlutterPubGetUsecase());
gh.singleton<_i886.FastlaneGetCertificateUsecase>(
() => _i886.FastlaneGetCertificateUsecase());
gh.singleton<_i835.FastlaneCreateKeychainUsecase>(
() => _i835.FastlaneCreateKeychainUsecase());
gh.singleton<_i942.FastlaneDeployPilotUsecase>(
() => _i942.FastlaneDeployPilotUsecase());
gh.singleton<_i643.FastlaneDeploySupplyUsecase>(
() => _i643.FastlaneDeploySupplyUsecase());
gh.singleton<_i589.DecryptKeysUsecase>(
() => const _i589.DecryptKeysUsecase());
gh.lazySingleton<_i614.Flutter>(() => registerModule.flutter);
gh.lazySingleton<_i150.Fastlane>(() => registerModule.fastlane);
gh.singleton<_i3.CheckConfigFileUsecase>(
const _i3.CheckConfigFileUsecase());
gh.singleton<_i4.CheckToolsUsecase>(const _i4.CheckToolsUsecase());
gh.singleton<_i5.DecryptKeysUsecase>(const _i5.DecryptKeysUsecase());
gh.lazySingleton<_i6.Fastlane>(() => registerModule.fastlane);
gh.singleton<_i7.FastlaneCreateKeychainUsecase>(
_i7.FastlaneCreateKeychainUsecase());
gh.singleton<_i8.FastlaneDeployPilotUsecase>(
_i8.FastlaneDeployPilotUsecase());
gh.singleton<_i9.FastlaneDeploySupplyUsecase>(
_i9.FastlaneDeploySupplyUsecase());
gh.singleton<_i10.FastlaneGetCertificateUsecase>(
_i10.FastlaneGetCertificateUsecase());
gh.singleton<_i11.FindLastIpaFileUsecase>(
const _i11.FindLastIpaFileUsecase());
gh.lazySingleton<_i12.Flutter>(() => registerModule.flutter);
gh.singleton<_i13.FlutterBuildAppBundleUsecase>(
const _i13.FlutterBuildAppBundleUsecase());
gh.singleton<_i14.FlutterBuildIpaUsecase>(
const _i14.FlutterBuildIpaUsecase());
gh.singleton<_i15.FlutterBuildXcarchiveUsecase>(
const _i15.FlutterBuildXcarchiveUsecase());
gh.singleton<_i16.FlutterCleanUsecase>(const _i16.FlutterCleanUsecase());
gh.singleton<_i17.FlutterPubGetUsecase>(const _i17.FlutterPubGetUsecase());
gh.singleton<_i18.GetAndroidConfigUsecase>(
const _i18.GetAndroidConfigUsecase());
gh.singleton<_i19.GetIosConfigUsecase>(const _i19.GetIosConfigUsecase());
gh.singleton<_i20.InitConfigUsecase>(const _i20.InitConfigUsecase());
return this;
}
}
class _$RegisterModule extends _i899.RegisterModule {}
class _$RegisterModule extends _i21.RegisterModule {}
@@ -27,7 +27,9 @@ final getIt = GetIt.instance;
preferRelativeImports: false,
asExtension: true,
)
Future<void> configureDependencies() => getIt.init().allReady();
abstract final class Injectable {
static Future<void> configureDependencies() => getIt.init().allReady();
}
@module
abstract class RegisterModule {
@@ -1,7 +1,7 @@
name: wyatt_continuous_deployment
description: Wyatt CD.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_continuous_deployment
version: 1.1.1
version: 1.0.0
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -10,26 +10,26 @@ environment:
dependencies:
args: ^2.4.2
bloc: ^9.0.0
bloc: ^8.1.3
checked_yaml: ^2.0.3
cli_completion: ^0.5.0
get_it: ^8.0.3
get_it: ^7.6.7
injectable: ^2.3.2
json_annotation: ^4.8.1
mason_logger: ^0.3.3
mason_logger: ^0.2.12
meta: ^1.12.0
wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+3
version: ^0.2.0+1
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.1.0+1
version: ^0.0.5
yaml: ^3.1.2
yaml_edit: ^2.1.1
dev_dependencies:
build_runner: ^2.4.8
dart_code_linter: ^2.0.0
dart_code_linter: ^1.1.1
injectable_generator: ^2.4.1
json_serializable: ^6.7.1
@@ -37,4 +37,4 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.6.1
-8
View File
@@ -1,11 +1,3 @@
## 0.2.0+2
- Update a dependency to the latest release.
## 0.2.0+1
- Update a dependency to the latest release.
## 0.2.0
> Note: This release has breaking changes.
@@ -1,12 +0,0 @@
## 2.0.0
> Note: This release has breaking changes.
- **FIX**: rename wyatt_bruc_bloc_firestore main package file.
- **FIX**(crud): update example.
- **FEAT**(crud): add streaming usecase (closes #180).
- **FEAT**(crud): change responsibility of blocs (closes #45, closes #44).
- **DOCS**(crud): add example app.
- **BREAKING** **FEAT**(crud): make crudbuilder integration more easy by integrating blocbuilder (closes #181).
- **BREAKING** **FEAT**(crud): move crud firestore implementation into his own package.
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.0
version: 1.0.0+1
environment:
sdk: ">=3.0.0 <4.0.0"
@@ -31,9 +31,9 @@ dependencies:
sdk: flutter
equatable: ^2.0.5
firebase_core: ^3.13.1
cloud_firestore: ^5.6.8
flutter_bloc: ^9.1.1
firebase_core: ^2.22.0
cloud_firestore: ^4.13.0
flutter_bloc: ^8.1.3
wyatt_crud_bloc:
path: "../"
wyatt_crud_bloc_firestore:
@@ -41,7 +41,7 @@ dependencies:
wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+3
version: ^0.2.0+1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
@@ -57,7 +57,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
flutter_lints: ^2.0.0
json_serializable: ^6.7.1
build_runner: ^2.4.6
+7 -7
View File
@@ -1,7 +1,7 @@
name: wyatt_crud_bloc
description: Create/Read/Update/Delete BLoC for Flutter
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_crud_bloc
version: 0.2.0+2
version: 0.2.0
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -11,21 +11,21 @@ environment:
dependencies:
flutter: { sdk: flutter }
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.1
equatable: ^2.0.5
wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+3
version: ^0.2.0+1
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.1.0+1
rxdart: ^0.28.0
version: ^0.0.5
rxdart: ^0.27.7
dev_dependencies:
flutter_test: { sdk: flutter }
bloc_test: ^10.0.0
bloc_test: ^9.1.0
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.6.1
@@ -1,13 +1,3 @@
## 0.2.0+3
## 0.2.0+2
- Update a dependency to the latest release.
## 0.2.0+1
- Update a dependency to the latest release.
## 0.2.0
> Note: This release has breaking changes.
@@ -1,7 +1,7 @@
name: wyatt_crud_bloc_firestore
description: Create/Read/Update/Delete implementation for Cloud Firestore
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_crud_bloc
version: 0.2.0+3
version: 0.2.0
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -11,25 +11,25 @@ environment:
dependencies:
flutter: { sdk: flutter }
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.1
equatable: ^2.0.5
cloud_firestore: ^5.6.8
cloud_firestore: ^4.0.5
wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+3
version: ^0.2.0+1
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.1.0+1
version: ^0.0.5
wyatt_crud_bloc:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+2
version: ^0.2.0
dev_dependencies:
flutter_test: { sdk: flutter }
bloc_test: ^10.0.0
bloc_test: ^9.1.0
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.6.1
@@ -1 +0,0 @@
../../.gitignore
@@ -1 +0,0 @@
../../.pubignore
@@ -1 +0,0 @@
../../AUTHORS
@@ -1 +0,0 @@
../../LICENSE
@@ -1 +0,0 @@
../../.gitignore
@@ -1 +0,0 @@
../../.pubignore
@@ -1 +0,0 @@
../../AUTHORS
@@ -1 +0,0 @@
../../LICENSE
-8
View File
@@ -1,11 +1,3 @@
## 0.2.0+6
- Update a dependency to the latest release.
## 0.2.0+5
- **FIX**: apply dart format.
## 0.2.0+4
- **FIX**: apply dart format.
@@ -1,11 +1,3 @@
## 2.0.0
> Note: This release has breaking changes.
- **REFACTOR**(form): refactor simple example.
- **FEAT**(from): add form validator class with strategy design pattern.
- **BREAKING** **REFACTOR**(form): input builders provides FormInput.
## 1.1.0
- **FEAT**: add list option validator.
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.0
version: 1.1.0
environment:
sdk: ">=2.17.2 <3.0.0"
@@ -30,7 +30,7 @@ dependencies:
flutter:
sdk: flutter
flutter_bloc: ^9.1.1
flutter_bloc: ^8.0.1
wyatt_form_bloc:
path: "../"
@@ -47,7 +47,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
+5 -5
View File
@@ -1,7 +1,7 @@
name: wyatt_form_bloc
description: Manage forms in Dart & Flutter with Bloc
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_form_bloc
version: 0.2.0+6
version: 0.2.0+4
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -12,16 +12,16 @@ dependencies:
flutter:
sdk: flutter
flutter_bloc: ^9.1.1
flutter_bloc: ^8.1.0
equatable: ^2.0.5
wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0+3
version: ^0.2.0+1
wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.1.0+1
version: ^0.0.5
dev_dependencies:
@@ -30,4 +30,4 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^2.7.0
version: ^2.5.0
-4
View File
@@ -1,7 +1,3 @@
## 1.0.1
- **DOCS**(router): add missing template name.
## 1.0.0
- Initial version.
@@ -18,7 +18,7 @@ dev_dependencies:
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.6.1
# The following section is specific to Flutter.
flutter:
+4 -4
View File
@@ -1,7 +1,7 @@
name: wyatt_go_router
description: GoRouter Enhancements.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_go_router
version: 1.0.1
version: 1.0.0
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -10,11 +10,11 @@ environment:
dependencies:
flutter: { sdk: flutter }
go_router: ^15.1.2
go_router: ^12.1.1
dev_dependencies:
flutter_test: { sdk: flutter }
dart_code_linter: ^2.0.0
dart_code_linter: ^1.1.1
wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.7.0
version: ^2.6.1
-1
View File
@@ -1 +0,0 @@
../../.gitignore
-1
View File
@@ -1 +0,0 @@
../../.pubignore
-24
View File
@@ -1,24 +0,0 @@
/*
* Copyright (C) 2022 WYATT GROUP
* Please see the AUTHORS file for details.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
{
"recommendations": [
"psioniq.psi-header",
"blaugold.melos-code"
]
}
-71
View File
@@ -1,71 +0,0 @@
{
"psi-header.changes-tracking": {
"isActive": true
},
"psi-header.config": {
"blankLinesAfter": 1,
"forceToTop": true
},
"psi-header.lang-config": [
{
"beforeHeader": [
"# -*- coding:utf-8 -*-",
"#!/usr/bin/env python3"
],
"begin": "###",
"end": "###",
"language": "python",
"prefix": "# "
},
{
"beforeHeader": [
"#!/usr/bin/env sh",
""
],
"language": "shellscript",
"begin": "",
"end": "",
"prefix": "# "
},
{
"begin": "",
"end": "",
"language": "dart",
"prefix": "// "
},
{
"begin": "",
"end": "",
"language": "yaml",
"prefix": "# "
},
{
"begin": "<!--",
"end": "-->",
"language": "markdown",
},
],
"psi-header.templates": [
{
"language": "*",
"template": [
"Copyright (C) <<year>> WYATT GROUP",
"Please see the AUTHORS file for details.",
"",
"This program is free software: you can redistribute it and/or modify",
"it under the terms of the GNU General Public License as published by",
"the Free Software Foundation, either version 3 of the License, or",
"any later version.",
"",
"This program is distributed in the hope that it will be useful,",
"but WITHOUT ANY WARRANTY; without even the implied warranty of",
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
"GNU General Public License for more details.",
"",
"You should have received a copy of the GNU General Public License",
"along with this program. If not, see <https://www.gnu.org/licenses/>."
],
}
],
"dart.runPubGetOnPubspecChanges": false,
}
-1
View File
@@ -1 +0,0 @@
../../AUTHORS
-29
View File
@@ -1,29 +0,0 @@
## 2.0.2
- **FIX**: apply dart fix --apply.
## 2.0.1
- **FIX**: apply dart fix --apply.
## 2.0.0
> Note: This release has breaking changes.
- **DOCS**: add simple example.
- **BREAKING** **REFACTOR**: fix cascade dart good practices + docs.
## 1.2.0
- **FEAT**: add new middleware feature.
- **FEAT**: implements doublelinked list for middlewares.
- **FEAT**: [WIP] implements middleware system.
- **FEAT**: [WIP] work on middleware feature.
## 1.1.0
- **FEAT**: add oauth2 refresh token client.
## 1.0.0
- Initial version.
-1
View File
@@ -1 +0,0 @@
../../LICENSE
-182
View File
@@ -1,182 +0,0 @@
<!--
* Copyright (C) 2022 WYATT GROUP
* Please see the AUTHORS file for details.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
# HTTP Client
<p align="left">
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
<img src="https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square" alt="SDK: Dart & Flutter" />
</p>
HTTP Client for Dart with Middlewares !
## Getting started
Simply add wyatt_http_client in pubspec.yaml, then
```dart
import 'package:wyatt_http_client/wyatt_http_client.dart';
```
## Usage
Firstly you have to understand **Middleware** and **Pipeline** concepts.
In `wyatt_http_client` a middleware is an object where requests and responses
pass through. And a pipeline is basicaly a list of middlewares.
In a pipeline with middlewares A and B, if request pass through A, then B,
the response will pass through B then A.
> You can `print(pipeline)` to get full process order of a pipeline.
For example, if you want to log every request, and simplify an url you can use provided `SimpleLogger` and `UriPrefix` .
```dart
// Create the Pipeline
final Pipeline pipeline = Pipeline()
..addMiddleware(
const UriPrefixMiddleware(
protocol: Protocols.http,
authority: 'localhost:80',
),
)
..addMiddleware(const SimpleLoggerMiddleware());
```
Then if you print the pipeline,
```
[Req] -> UriPrefix -> SimpleLogger
[Res] -> SimpleLogger
```
> The `response` doesn't pass through `UriPrefix` because it's an `OnRequestMiddleware` only.
And you can create a client.
```dart
final client = MiddlewareClient(pipeline: pipeline);
```
At this point you can use `client` like every Client from `package:http/http.dart` .
## Recipes
### Rest API with URL Authentication
Let's build a client for a REST API where the (bad) authentication is through the URL.
We need some middlewares:
* SimpleLogger, to log every request and response (useful for debug).
* BodyToJson, to automaticaly transform Map object to JSON.
* UriPrefix, to simplify the build of an API Object (save protocol and API prefix).
* UnsafeAuth, to use url based authentication.
Let's start by creating the Pipeline:
```dart
final Pipeline pipeline = Pipeline()
..addMiddleware(
const UriPrefixMiddleware(
protocol: Protocols.http,
authority: 'localhost:80',
),
)
..addMiddleware(const BodyToJsonMiddleware())
..addMiddleware(
const UnsafeAuthMiddleware(
username: 'wyatt',
password: 'motdepasse',
),
)
..addMiddleware(SimpleLoggerMiddleware());
```
Then simply create a client and make a call.
```dart
final client = MiddlewareClient(pipeline: pipeline);
await client.get(Uri.parse('/protected'));
```
> Here it make a `GET` call on `http://localhost:80/protected?username=wyatt&password=motdepasse`
And voilà.
### Rest API with Oauth2
So now we want a real authentication.
```dart
final Pipeline pipeline = Pipeline()
..addMiddleware(
const UriPrefixMiddleware(
protocol: Protocols.http,
authority: 'localhost:80',
),
)
..addMiddleware(const BodyToJsonMiddleware())
..addMiddleware(
RefreshTokenAuthMiddleware(
authorizationEndpoint: '/auth/sign-in',
tokenEndpoint: '/auth/refresh',
accessTokenParser: (body) => body['access_token']! as String,
refreshTokenParser: (body) => body['refresh_token']! as String,
unauthorized: HttpStatus.forbidden,
),
)
..addMiddleware(const SimpleLoggerMiddleware());
```
> Here we just change `UnsafeAuthMiddleware` by `RefreshTokenAuthMiddleware` and the whole app while adapt to a new authentication system.
### Create a new Middleware
You can create your own middleware by implementing `Middleware` class, and use mixins to add `OnRequest` and/or `OnResponse` methods.
```dart
class SimpleLoggerMiddleware
with OnRequestMiddleware, OnResponseMiddleware
implements Middleware {
const SimpleLoggerMiddleware();
@override
String getName() => 'SimpleLogger';
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
print('${getName()}::OnRequest');
return request;
}
@override
Future<MiddlewareResponse> onResponse(
MiddlewareContext context,
MiddlewareResponse response,
) async {
print('${getName()}::OnResponse');
return response;
}
}
```
@@ -1 +0,0 @@
include: package:wyatt_analysis/analysis_options.yaml
@@ -1,78 +0,0 @@
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/wyatt_http_client.dart';
Future<void> testSimpleGet() async {
print('testSimpleGet');
final pipeline = Pipeline()
..addMiddleware(const BodyToJsonMiddleware())
..addMiddleware(const SimpleLoggerMiddleware());
final client = MiddlewareClient(pipeline: pipeline);
final response = await client
.get(Uri.parse('https://jsonplaceholder.typicode.com/todos/1'));
print(response.body);
}
Future<void> testUriPrefix() async {
print('testUriPrefix');
final pipeline = Pipeline()
..addMiddleware(
const UriPrefixMiddleware(
protocol: Protocols.https,
authority: 'jsonplaceholder.typicode.com',
),
)
..addMiddleware(const BodyToJsonMiddleware())
..addMiddleware(const SimpleLoggerMiddleware());
final client = MiddlewareClient(pipeline: pipeline);
final response = await client.get(Uri.parse('/todos/1'));
print(response.body);
}
Future<void> testBasicAuth() async {
print('testBasicAuth');
final pipeline = Pipeline()
..addMiddleware(
const BasicAuthMiddleware(
username: 'guest',
password: 'guest',
),
)
..addMiddleware(const BodyToJsonMiddleware())
..addMiddleware(const SimpleLoggerMiddleware());
final client = MiddlewareClient(pipeline: pipeline);
final response =
await client.get(Uri.parse('https://jigsaw.w3.org/HTTP/Basic/'));
if (HttpStatus.from(response.statusCode).isSuccess()) {
print("🎉 You're in!");
} else {
print("⭕️ Nope, you're not in.");
}
}
void main(List<String> args) {
testSimpleGet();
testUriPrefix();
testBasicAuth();
}
@@ -1,48 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
/// {@template middleware}
/// A middleware is a class that can intercept requests and responses
/// and modify them before they are sent to the server or before they
/// are returned to the client.
/// {@endtemplate}
abstract class Middleware {
/// {@macro middleware}
const Middleware();
/// The name of the middleware.
String getName();
}
mixin OnRequestMiddleware {
/// Performs an action before the request is sent to the server.
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
);
}
mixin OnResponseMiddleware {
/// Performs an action before the response is returned to the client.
Future<MiddlewareResponse> onResponse(
MiddlewareContext context,
MiddlewareResponse response,
);
}
@@ -1,134 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
import 'package:wyatt_http_client/src/models/unfreezed_request.dart';
import 'package:wyatt_http_client/src/pipeline.dart';
import 'package:wyatt_http_client/src/utils/http_methods.dart';
/// {@template middleware_client}
/// A custom [Client] implementation that allows you to intercept requests
/// and responses and modify them before they are sent to the server or
/// before they are returned to the client.
/// {@endtemplate}
class MiddlewareClient extends BaseClient {
/// {@macro middleware_client}
MiddlewareClient({
Pipeline? pipeline,
Client? inner,
}) : pipeline = pipeline ?? Pipeline(),
inner = inner ?? Client();
/// The [Client] that will be used to send requests.
final Client inner;
/// The [Pipeline] that will be used to intercept requests and responses.
final Pipeline pipeline;
@override
Future<Response> head(Uri url, {Map<String, String>? headers}) =>
_sendUnstreamed(HttpMethods.head.method, url, headers);
@override
Future<Response> get(Uri url, {Map<String, String>? headers}) =>
_sendUnstreamed(HttpMethods.get.method, url, headers);
@override
Future<Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_sendUnstreamed(HttpMethods.post.method, url, headers, body, encoding);
@override
Future<Response> put(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_sendUnstreamed(HttpMethods.put.method, url, headers, body, encoding);
@override
Future<Response> patch(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_sendUnstreamed(HttpMethods.patch.method, url, headers, body, encoding);
@override
Future<Response> delete(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
_sendUnstreamed(HttpMethods.delete.method, url, headers, body, encoding);
@override
Future<StreamedResponse> send(BaseRequest request) => inner.send(request);
Future<Response> _sendUnstreamed(
String method,
Uri url,
Map<String, String>? headers, [
Object? body,
Encoding? encoding,
]) async {
final originalRequest = MiddlewareRequest(
unfreezedRequest: UnfreezedRequest(
method: method,
url: url,
headers: headers,
body: body,
encoding: encoding,
),
);
final requestContext = MiddlewareContext(
pipeline: pipeline,
client: this,
originalRequest: originalRequest,
);
final modifiedRequest = await pipeline.onRequest(
requestContext,
originalRequest.copyWith(),
);
final originalResponse = MiddlewareResponse(
httpResponse: await Response.fromStream(
await send(modifiedRequest.request),
),
);
final responseContext =
requestContext.copyWith(originalResponse: originalResponse);
final modifiedResponse =
await pipeline.onResponse(responseContext, originalResponse.copyWith());
return modifiedResponse.httpResponse as Response;
}
}
@@ -1,65 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/utils/authentication_methods.dart';
import 'package:wyatt_http_client/src/utils/header_keys.dart';
/// {@template basic_auth_middleware}
/// A middleware that adds basic authentication to the request.
/// {@endtemplate}
class BasicAuthMiddleware with OnRequestMiddleware implements Middleware {
/// {@macro basic_auth_middleware}
const BasicAuthMiddleware({
this.username,
this.password,
this.authenticationHeader = HeaderKeys.authorization,
});
/// The username to use for authentication.
final String? username;
/// The password to use for authentication.
final String? password;
/// The header to use for authentication.
final String authenticationHeader;
@override
String getName() => 'BasicAuth';
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
if (username == null || password == null) {
return request;
}
final mutation = {
authenticationHeader: '${AuthenticationMethods.basic} '
'${base64Encode(utf8.encode('$username:$password'))}',
};
final Map<String, String> headers = request.headers..addAll(mutation);
request.modifyRequest(request.unfreezedRequest.copyWith(headers: headers));
return request;
}
}
@@ -1,50 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
/// {@template body_to_json_middleware}
/// A middleware that transforms the body in json if it's a [Map].
/// {@endtemplate}
class BodyToJsonMiddleware with OnRequestMiddleware implements Middleware {
/// {@macro body_to_json_middleware}
const BodyToJsonMiddleware();
@override
String getName() => 'BodyToJson';
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
final mutation = {
'content-type': 'application/json; charset=utf-8',
};
if (request.body is Map) {
final Map<String, String> headers = request.headers..addAll(mutation);
request.modifyRequest(
request.unfreezedRequest
.copyWith(headers: headers, body: jsonEncode(request.body)),
);
}
return request;
}
}
@@ -1,28 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/middleware.dart';
/// {@template default_middleware}
/// A default middleware that does nothing.
/// {@endtemplate}
class DefaultMiddleware implements Middleware {
/// {@macro default_middleware}
const DefaultMiddleware();
@override
String getName() => 'DefaultMiddleware';
}
@@ -1,87 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
import 'package:wyatt_http_client/src/utils/digest_auth.dart';
import 'package:wyatt_http_client/src/utils/header_keys.dart';
import 'package:wyatt_http_client/src/utils/http_status.dart';
/// {@template digest_auth_middleware}
/// A middleware that handles digest authentication.
/// {@endtemplate}
class DigestAuthMiddleware
with OnRequestMiddleware, OnResponseMiddleware
implements Middleware {
/// {@macro digest_auth_middleware}
DigestAuthMiddleware({
required this.username,
required this.password,
this.authenticationHeader = HeaderKeys.authorization,
this.wwwAuthenticateHeader = HeaderKeys.wwwAuthenticate,
this.unauthorized = HttpStatus.unauthorized,
}) : _digestAuth = DigestAuth(username, password);
final String username;
final String password;
final DigestAuth _digestAuth;
final String authenticationHeader;
final String wwwAuthenticateHeader;
final HttpStatus unauthorized;
@override
String getName() => 'DigestAuth';
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
if (_digestAuth.isReady()) {
final mutation = {
authenticationHeader: _digestAuth.getAuthString(
request.method,
request.url,
),
};
final Map<String, String> headers = request.headers..addAll(mutation);
request
.modifyRequest(request.unfreezedRequest.copyWith(headers: headers));
}
return request;
}
@override
Future<MiddlewareResponse> onResponse(
MiddlewareContext context,
MiddlewareResponse response,
) async {
if (response.status == unauthorized) {
final authInfo =
response.headers[HeaderKeys.wwwAuthenticate.toLowerCase()];
_digestAuth.initFromAuthenticateHeader(authInfo);
final MiddlewareRequest? newRequest = context.lastRequest?.copyWith();
if (newRequest != null) {
final newResponse = await context.client.send(newRequest.request);
return MiddlewareResponse(httpResponse: newResponse);
}
}
return response;
}
}
@@ -1,26 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// All built-in middlewares
export 'basic_auth_middleware.dart';
export 'body_to_json_middleware.dart';
export 'default_middleware.dart';
export 'digest_auth_middleware.dart';
export 'refresh_token_auth_middleware.dart';
export 'simple_logger_middleware.dart';
export 'unsafe_auth_middleware.dart';
export 'uri_prefix_middleware.dart';
@@ -1,184 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/middleware_client.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
import 'package:wyatt_http_client/src/utils/authentication_methods.dart';
import 'package:wyatt_http_client/src/utils/delay.dart';
import 'package:wyatt_http_client/src/utils/header_keys.dart';
import 'package:wyatt_http_client/src/utils/http_status.dart';
typedef TokenParser = String Function(Map<String, dynamic>);
/// {@template refresh_token_auth_middleware}
/// A middleware that refreshes the access token when it expires.
/// This middleware is useful for OAuth2.
/// {@endtemplate}
class RefreshTokenAuthMiddleware
with OnRequestMiddleware, OnResponseMiddleware
implements Middleware {
/// {@macro refresh_token_auth_middleware}
RefreshTokenAuthMiddleware({
required this.authorizationEndpoint,
required this.tokenEndpoint,
required this.accessTokenParser,
required this.refreshTokenParser,
this.authenticationHeader = HeaderKeys.authorization,
this.authenticationMethod = AuthenticationMethods.bearer,
this.unauthorized = HttpStatus.unauthorized,
this.maxAttempts = 8,
});
final String authorizationEndpoint;
final String tokenEndpoint;
String? accessToken;
final TokenParser accessTokenParser;
String? refreshToken;
final TokenParser refreshTokenParser;
final String authenticationHeader;
final String authenticationMethod;
final HttpStatus unauthorized;
final int maxAttempts;
@override
String getName() => 'RefreshToken';
Future<MiddlewareRequest?> refresh(MiddlewareContext context) async {
final subPipeline = context.pipeline.sub(this);
final httpClient = MiddlewareClient(
pipeline: subPipeline,
inner: context.client.inner,
);
final headers = {
authenticationHeader: '$authenticationMethod $refreshToken',
};
final response = MiddlewareResponse(
httpResponse: await httpClient.get(
Uri.parse(tokenEndpoint),
headers: headers,
),
);
if (response.status.isSuccess()) {
final body = jsonDecode(response.body) as Map<String, dynamic>;
accessToken = accessTokenParser(body);
// Then modify current request with accessToken
final mutation = {
authenticationHeader: '$authenticationMethod $accessToken',
};
final Map<String, String>? headers = context.lastRequest?.headers
?..addAll(mutation);
final newRequest = context.lastRequest?.copyWith(
unfreezedRequest:
context.lastRequest?.unfreezedRequest.copyWith(headers: headers),
);
return newRequest;
}
return null;
}
Future<MiddlewareRequest?> retry(MiddlewareContext context) async {
// Retry
int attempt = 1;
while (attempt <= maxAttempts) {
// Delayed before retry
await Future<void>.delayed(Delay.getRetryDelay(attempt));
final newRequest = await refresh(context);
if (newRequest != null) {
return newRequest;
}
attempt++;
}
return null;
}
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
// Check if it is authorization
if (context.originalRequest?.url == Uri.parse(authorizationEndpoint)) {
return request;
}
// Check if it is refresh
if (context.originalRequest?.url == Uri.parse(tokenEndpoint)) {
return request;
}
// If AccessToken not null then return request with authorization header
if (accessToken != null) {
final mutation = {
authenticationHeader: '$authenticationMethod $accessToken',
};
final Map<String, String> headers = request.headers..addAll(mutation);
request
.modifyRequest(request.unfreezedRequest.copyWith(headers: headers));
return request;
}
// If AccessToken is null BUT there is a refreshToken, then try refreshing
if (refreshToken != null) {
MiddlewareRequest? newRequest = await refresh(context);
newRequest ??= await retry(context);
return newRequest ?? request;
}
// Pass
return request;
}
@override
Future<MiddlewareResponse> onResponse(
MiddlewareContext context,
MiddlewareResponse response,
) async {
// Check if it is authorization
if (context.originalRequest?.url == Uri.parse(authorizationEndpoint)) {
// If success, then update tokens
if (response.status.isSuccess()) {
final body = jsonDecode(response.body) as Map<String, dynamic>;
final accessToken = accessTokenParser(body);
final refreshToken = refreshTokenParser(body);
if (accessToken.isNotEmpty) {
this.accessToken = accessToken;
}
if (refreshToken.isNotEmpty) {
this.refreshToken = refreshToken;
}
}
}
if (response.status == unauthorized) {
// Refresh
MiddlewareRequest? newRequest = await refresh(context);
newRequest ??= await retry(context);
if (newRequest != null) {
return response.copyWith(
httpResponse: await context.client.send(newRequest.request),
);
}
}
return response;
}
}
@@ -1,72 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
/// {@template simple_logger_middleware}
/// A simple logger middleware that logs the request and response.
/// {@endtemplate}
class SimpleLoggerMiddleware
with OnRequestMiddleware, OnResponseMiddleware
implements Middleware {
/// {@macro simple_logger_middleware}
const SimpleLoggerMiddleware();
@override
String getName() => 'SimpleLogger';
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
final log = StringBuffer()
..writeln('${getName()}::OnRequest')
..writeln('>> ${request.method} ${request.url}');
if (request.headers.isNotEmpty) {
log.writeln('>> Headers:');
request.headers.forEach((key, value) {
log.writeln('>> $key: $value');
});
}
if (request.encodedBody.isNotEmpty) {
log
..writeln('>> Body:')
..writeln(request.encodedBody);
}
print(log);
return request;
}
@override
Future<MiddlewareResponse> onResponse(
MiddlewareContext context,
MiddlewareResponse response,
) async {
final log = StringBuffer()
..writeln('${getName()}::OnResponse')
..writeln('>> Status: ${response.status.name.toUpperCase()}')
..writeln('>> Length: ${response.contentLength ?? '0'} bytes');
print(log);
return response;
}
}
@@ -1,56 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/utils/convert.dart';
/// {@template unsafe_auth_middleware}
/// A middleware that appends the username and password to the URL.
///
/// This is not recommended to use in production.
/// {@endtemplate}
class UnsafeAuthMiddleware with OnRequestMiddleware implements Middleware {
const UnsafeAuthMiddleware({
this.username,
this.password,
this.usernameField = 'username',
this.passwordField = 'password',
});
final String? username;
final String? password;
final String usernameField;
final String passwordField;
@override
String getName() => 'UnsafeAuth';
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
if (username == null || password == null) {
return request;
}
final Uri uri =
request.url + '?$usernameField=$username&$passwordField=$password';
request.modifyRequest(request.unfreezedRequest.copyWith(url: uri));
return request;
}
}
@@ -1,50 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/utils/protocols.dart';
/// {@template uri_prefix_middleware}
/// A middleware that adds a prefix to the request's URI.
/// {@endtemplate}
class UriPrefixMiddleware with OnRequestMiddleware implements Middleware {
/// {@macro uri_prefix_middleware}
const UriPrefixMiddleware({
required this.protocol,
required this.authority,
});
/// The protocol of the prefix.
final Protocols protocol;
/// The authority of the prefix.
final String? authority;
@override
String getName() => 'UriPrefix';
@override
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
final Uri uri = Uri.parse('${protocol.scheme}$authority${request.url}');
request.modifyRequest(request.unfreezedRequest.copyWith(url: uri));
return request;
}
}
@@ -1,78 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/middleware_client.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
import 'package:wyatt_http_client/src/pipeline.dart';
/// {@template middleware_context}
/// A class that contains the context of the middleware.
/// {@endtemplate}
class MiddlewareContext {
/// {@macro middleware_context}
const MiddlewareContext({
required this.pipeline,
required this.client,
this.originalRequest,
this.lastRequest,
this.originalResponse,
this.lastResponse,
});
/// The pipeline that the middleware is in.
final Pipeline pipeline;
/// The client that the middleware is in.
final MiddlewareClient client;
/// The original request that the middleware is in.
final MiddlewareRequest? originalRequest;
/// The last request that the middleware is in.
final MiddlewareRequest? lastRequest;
/// The original response that the middleware is in.
final MiddlewareResponse? originalResponse;
/// The last response that the middleware is in.
final MiddlewareResponse? lastResponse;
/// Create a copy of this [MiddlewareContext] with the given fields replaced
/// with the new values.
MiddlewareContext copyWith({
Pipeline? pipeline,
MiddlewareClient? client,
MiddlewareRequest? originalRequest,
MiddlewareRequest? lastRequest,
MiddlewareResponse? originalResponse,
MiddlewareResponse? lastResponse,
}) =>
MiddlewareContext(
pipeline: pipeline ?? this.pipeline,
client: client ?? this.client,
originalRequest: originalRequest ?? this.originalRequest,
lastRequest: lastRequest ?? this.lastRequest,
originalResponse: originalResponse ?? this.originalResponse,
lastResponse: lastResponse ?? this.lastResponse,
);
@override
String toString() =>
'MiddlewareContext(pipeline: $pipeline, client: $client, '
'originalRequest: $originalRequest, lastRequest: $lastRequest, '
'originalResponse: $originalResponse, lastResponse: $lastResponse)';
}
@@ -1,102 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/models/unfreezed_request.dart';
import 'package:wyatt_http_client/src/utils/convert.dart';
import 'package:wyatt_http_client/src/utils/request_utils.dart';
/// {@template middleware_request}
/// A class that represents a middleware request.
/// {@endtemplate}
class MiddlewareRequest {
/// {@macro middleware_request}
MiddlewareRequest({
required this.unfreezedRequest,
}) : _httpRequest = Request(unfreezedRequest.method, unfreezedRequest.url);
/// The unfreezed request.
UnfreezedRequest unfreezedRequest;
Request _httpRequest;
/// The http request. (Read-only)
Request get request => _httpRequest;
/// The request method (proxy, read-only).
String get method => _httpRequest.method;
/// The request url (proxy, read-only).
Uri get url => _httpRequest.url;
/// The request headers (proxy, read-only).
Map<String, String> get headers => _httpRequest.headers;
/// The request body (proxy, read-only).
Encoding get encoding => _httpRequest.encoding;
/// The request body (proxy, read-only).
String get encodedBody => _httpRequest.body;
/// The request body (proxy, read-only).
Object? get body => unfreezedRequest.body;
/// Copies this request and returns a new request with the given
/// [unfreezedRequest].
MiddlewareRequest copyWith({
UnfreezedRequest? unfreezedRequest,
}) =>
MiddlewareRequest(
unfreezedRequest: unfreezedRequest ?? this.unfreezedRequest,
);
/// Modifies the request with the given [unfreezedRequest].
void modifyRequest(UnfreezedRequest unfreezedRequest) {
String? body;
if (unfreezedRequest.body != null) {
var body = unfreezedRequest.body;
if (body is String) {
body = body;
} else if (body is List) {
body = String.fromCharCodes(body.cast<int>());
} else if (body is Map) {
body = Convert.mapToQuery(body.cast<String, String>());
}
}
_httpRequest = RequestUtils.copyRequestWith(
_httpRequest,
method: unfreezedRequest.method,
url: unfreezedRequest.url,
headers: unfreezedRequest.headers,
body: body,
) as Request;
if (unfreezedRequest.encoding != null) {
_httpRequest.encoding = unfreezedRequest.encoding!;
}
this.unfreezedRequest = unfreezedRequest;
}
/// Applies the changes made to the request by modifying it with the
/// [unfreezedRequest].
void apply() {
modifyRequest(unfreezedRequest);
}
@override
String toString() => 'MiddlewareRequest(unfreezedRequest: $unfreezedRequest)';
}
@@ -1,63 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:http/http.dart';
import 'package:wyatt_http_client/src/utils/http_status.dart';
/// {@template middleware_response}
/// A class that represents a middleware response.
/// {@endtemplate}
class MiddlewareResponse {
/// {@macro middleware_response}
const MiddlewareResponse({
required this.httpResponse,
});
/// {@macro middleware_response}
final BaseResponse httpResponse;
/// The status code of the response. (proxy)
int get statusCode => httpResponse.statusCode;
/// The status of the response. (proxy)
HttpStatus get status => HttpStatus.from(statusCode);
/// The body of the response. (proxy or empty string)
String get body {
if (httpResponse is Response) {
return (httpResponse as Response).body;
} else {
return '';
}
}
/// The content length of the response. (proxy)
int? get contentLength => httpResponse.contentLength;
/// The headers of the response. (proxy)
Map<String, String> get headers => httpResponse.headers;
/// Returns a copy of this response with the given [httpResponse].
MiddlewareResponse copyWith({
BaseResponse? httpResponse,
}) =>
MiddlewareResponse(
httpResponse: httpResponse ?? this.httpResponse,
);
@override
String toString() => 'MiddlewareResponse(httpResponse: $httpResponse)';
}
@@ -1,69 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:convert';
/// {@template unfreezed_request}
/// A class that represents an unfreezed request.
/// It is used to unfreeze a Request object, and allows you to
/// modify the request before sending it.
/// {@endtemplate}
class UnfreezedRequest {
/// {@macro unfreezed_request}
const UnfreezedRequest({
required this.method,
required this.url,
this.headers,
this.body,
this.encoding,
});
/// The request method.
final String method;
/// The request url.
final Uri url;
/// The request headers.
final Map<String, String>? headers;
/// The request body.
final Object? body;
/// The request encoding.
final Encoding? encoding;
/// Copies this request and returns a new request with the given [method],
/// [url], [headers], [body] and [encoding].
UnfreezedRequest copyWith({
String? method,
Uri? url,
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) =>
UnfreezedRequest(
method: method ?? this.method,
url: url ?? this.url,
headers: headers ?? this.headers,
body: body ?? this.body,
encoding: encoding ?? this.encoding,
);
@override
String toString() => 'UnfreezedRequest(method: $method, url: $url, headers: '
'$headers, body: $body, encoding: $encoding)';
}
@@ -1,122 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_http_client/src/middleware.dart';
import 'package:wyatt_http_client/src/models/middleware_context.dart';
import 'package:wyatt_http_client/src/models/middleware_request.dart';
import 'package:wyatt_http_client/src/models/middleware_response.dart';
/// {@template pipeline}
/// A [Pipeline] is a list of [Middleware]s that are executed in order.
/// {@endtemplate}
class Pipeline {
/// {@macro pipeline}
Pipeline() : _middlewares = <Middleware>[];
/// {@macro pipeline}
Pipeline.fromIterable(Iterable<Middleware> middlewares)
: _middlewares = middlewares.toList();
final List<Middleware> _middlewares;
/// The length of the [Pipeline].
///
/// This is the number of [Middleware]s in the [Pipeline].
int get length => _middlewares.length;
/// Add a [Middleware] to this [Pipeline]
void addMiddleware(Middleware middleware) {
_middlewares.add(middleware);
}
/// Create new [Pipeline] from the start or end to a specified [Middleware].
Pipeline sub(
Middleware middleware, {
bool include = false,
bool fromEnd = false,
}) {
final nodes = <Middleware>[];
final list = fromEnd ? _middlewares.reversed : _middlewares;
for (final m in list) {
if (m != middleware) {
nodes.add(m);
}
if (m == middleware) {
if (include) {
nodes.add(m);
}
break;
}
}
return Pipeline.fromIterable(fromEnd ? nodes.reversed : nodes);
}
/// Call the [onRequest] method of all [OnRequestMiddleware]s in the
/// [Pipeline].
///
/// The [MiddlewareRequest] returned by the last [OnRequestMiddleware] is
/// returned.
Future<MiddlewareRequest> onRequest(
MiddlewareContext context,
MiddlewareRequest request,
) async {
MiddlewareRequest req = request..apply();
MiddlewareContext ctx = context.copyWith(lastRequest: req);
for (final middleware in _middlewares) {
if (middleware is OnRequestMiddleware) {
req = await (middleware as OnRequestMiddleware).onRequest(ctx, request);
ctx = context.copyWith(lastRequest: req);
}
}
return req;
}
/// Call the [onResponse] method of all [OnResponseMiddleware]s in the
/// [Pipeline].
///
/// The [MiddlewareResponse] returned by the last [OnResponseMiddleware] is
/// returned.
Future<MiddlewareResponse> onResponse(
MiddlewareContext context,
MiddlewareResponse response,
) async {
MiddlewareResponse res = response;
MiddlewareContext ctx = context.copyWith(lastResponse: res);
for (final middleware in _middlewares.reversed) {
if (middleware is OnResponseMiddleware) {
res = await (middleware as OnResponseMiddleware)
.onResponse(ctx, response);
ctx = context.copyWith(lastResponse: res);
}
}
return res;
}
@override
String toString() {
final req = <String>[];
final res = <String>[];
for (final middleware in _middlewares) {
if (middleware is OnRequestMiddleware) {
req.add(middleware.getName());
}
if (middleware is OnResponseMiddleware) {
res.insert(0, middleware.getName());
}
}
return '[Req] -> ${req.join(' -> ')}\n[Res] -> ${res.join(' -> ')}';
}
}

Some files were not shown because too many files have changed in this diff Show More