-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generated models and tests: Should be done now
- Loading branch information
Showing
61 changed files
with
5,830 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,63 @@ | ||
<!-- | ||
This README describes the package. If you publish this package to pub.dev, | ||
this README's contents appear on the landing page for your package. | ||
# hurl_parser_rust | ||
|
||
For information about how to write a good package README, see the guide for | ||
[writing package pages](https://dart.dev/tools/pub/writing-package-pages). | ||
For general information about developing packages, see the Dart guide for | ||
[creating packages](https://dart.dev/guides/libraries/create-packages) | ||
and the Flutter guide for | ||
[developing packages and plugins](https://flutter.dev/to/develop-packages). | ||
--> | ||
|
||
TODO: Put a short description of the package here that helps potential users | ||
know whether this package might be useful for them. | ||
A Dart package that provides Hurl file parsing using a Rust backend for high performance. | ||
|
||
## Features | ||
|
||
TODO: List what your package can do. Maybe include images, gifs, or videos. | ||
|
||
## Getting started | ||
|
||
TODO: List prerequisites and provide or point to information on how to | ||
start using the package. | ||
- Parse Hurl files into structured Dart objects | ||
- High-performance Rust-based parsing | ||
- Support for all Hurl features: | ||
- HTTP methods (GET, POST, PUT, DELETE, etc.) | ||
- Headers | ||
- Query parameters | ||
- Form parameters | ||
- Basic authentication | ||
- Cookies | ||
- Options | ||
- Captures | ||
- Assertions | ||
- JSON/XML bodies | ||
|
||
## Installation | ||
|
||
```yaml | ||
dependencies: | ||
hurl_parser_rust: ^0.1.0 | ||
``` | ||
## Usage | ||
TODO: Include short and useful examples for package users. Add longer examples | ||
to `/example` folder. | ||
|
||
```dart | ||
const like = 'sample'; | ||
import 'package:hurl_parser_rust/hurl_parser_rust.dart'; | ||
|
||
void main() async { | ||
// Initialize the parser | ||
final parser = await HurlParser.getInstance(); | ||
|
||
// Parse Hurl content | ||
final hurlFile = parser.parse(''' | ||
GET http://api.example.com/users | ||
Authorization: Bearer token123 | ||
Accept: application/json | ||
|
||
HTTP/1.1 200 | ||
[Captures] | ||
user_id: jsonpath "$.users[0].id" | ||
[Asserts] | ||
header "Content-Type" == "application/json" | ||
'''); | ||
// Access the parsed data | ||
final request = hurlFile.entries.first.request; | ||
print('Method: ${request.method}'); | ||
print('URL: ${request.url}'); | ||
} | ||
``` | ||
|
||
## Additional information | ||
|
||
TODO: Tell users more about the package: where to find more information, how to | ||
contribute to the package, how to file issues, what response they can expect | ||
from the package authors, and more. | ||
- [Hurl Documentation](https://hurl.dev) | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the LICENSE file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
export 'package:hurl_parser_rust/src/hurl_parser.dart'; | ||
export 'src/models/basic_auth.dart'; | ||
export 'src/models/capture.dart'; | ||
export 'src/models/cookie.dart'; | ||
export 'src/models/form_param.dart'; | ||
export 'src/models/header.dart'; | ||
export 'src/models/hurl_assert.dart'; | ||
export 'src/models/hurl_entry.dart'; | ||
export 'src/models/hurl_file.dart'; | ||
export 'src/models/hurl_request.dart'; | ||
export 'src/models/hurl_response.dart'; | ||
export 'src/models/multipart_form_data.dart'; | ||
export 'src/models/predicate.dart'; | ||
export 'src/models/query.dart'; | ||
export 'src/models/query_param.dart'; | ||
export 'src/models/request_body.dart'; | ||
export 'src/models/request_option.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// basic_auth.dart | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'basic_auth.freezed.dart'; | ||
part 'basic_auth.g.dart'; | ||
|
||
@freezed | ||
class BasicAuth with _$BasicAuth { | ||
const factory BasicAuth({ | ||
required String username, | ||
required String password, | ||
}) = _BasicAuth; | ||
|
||
factory BasicAuth.fromJson(Map<String, dynamic> json) => | ||
_$BasicAuthFromJson(json); | ||
} |
183 changes: 183 additions & 0 deletions
183
packages/hurl_parser_rust/lib/src/models/basic_auth.freezed.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark | ||
|
||
part of 'basic_auth.dart'; | ||
|
||
// ************************************************************************** | ||
// FreezedGenerator | ||
// ************************************************************************** | ||
|
||
T _$identity<T>(T value) => value; | ||
|
||
final _privateConstructorUsedError = UnsupportedError( | ||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); | ||
|
||
BasicAuth _$BasicAuthFromJson(Map<String, dynamic> json) { | ||
return _BasicAuth.fromJson(json); | ||
} | ||
|
||
/// @nodoc | ||
mixin _$BasicAuth { | ||
String get username => throw _privateConstructorUsedError; | ||
String get password => throw _privateConstructorUsedError; | ||
|
||
/// Serializes this BasicAuth to a JSON map. | ||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; | ||
|
||
/// Create a copy of BasicAuth | ||
/// with the given fields replaced by the non-null parameter values. | ||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
$BasicAuthCopyWith<BasicAuth> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} | ||
|
||
/// @nodoc | ||
abstract class $BasicAuthCopyWith<$Res> { | ||
factory $BasicAuthCopyWith(BasicAuth value, $Res Function(BasicAuth) then) = | ||
_$BasicAuthCopyWithImpl<$Res, BasicAuth>; | ||
@useResult | ||
$Res call({String username, String password}); | ||
} | ||
|
||
/// @nodoc | ||
class _$BasicAuthCopyWithImpl<$Res, $Val extends BasicAuth> | ||
implements $BasicAuthCopyWith<$Res> { | ||
_$BasicAuthCopyWithImpl(this._value, this._then); | ||
|
||
// ignore: unused_field | ||
final $Val _value; | ||
// ignore: unused_field | ||
final $Res Function($Val) _then; | ||
|
||
/// Create a copy of BasicAuth | ||
/// with the given fields replaced by the non-null parameter values. | ||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? username = null, | ||
Object? password = null, | ||
}) { | ||
return _then(_value.copyWith( | ||
username: null == username | ||
? _value.username | ||
: username // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
password: null == password | ||
? _value.password | ||
: password // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
) as $Val); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
abstract class _$$BasicAuthImplCopyWith<$Res> | ||
implements $BasicAuthCopyWith<$Res> { | ||
factory _$$BasicAuthImplCopyWith( | ||
_$BasicAuthImpl value, $Res Function(_$BasicAuthImpl) then) = | ||
__$$BasicAuthImplCopyWithImpl<$Res>; | ||
@override | ||
@useResult | ||
$Res call({String username, String password}); | ||
} | ||
|
||
/// @nodoc | ||
class __$$BasicAuthImplCopyWithImpl<$Res> | ||
extends _$BasicAuthCopyWithImpl<$Res, _$BasicAuthImpl> | ||
implements _$$BasicAuthImplCopyWith<$Res> { | ||
__$$BasicAuthImplCopyWithImpl( | ||
_$BasicAuthImpl _value, $Res Function(_$BasicAuthImpl) _then) | ||
: super(_value, _then); | ||
|
||
/// Create a copy of BasicAuth | ||
/// with the given fields replaced by the non-null parameter values. | ||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? username = null, | ||
Object? password = null, | ||
}) { | ||
return _then(_$BasicAuthImpl( | ||
username: null == username | ||
? _value.username | ||
: username // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
password: null == password | ||
? _value.password | ||
: password // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
)); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
@JsonSerializable() | ||
class _$BasicAuthImpl implements _BasicAuth { | ||
const _$BasicAuthImpl({required this.username, required this.password}); | ||
|
||
factory _$BasicAuthImpl.fromJson(Map<String, dynamic> json) => | ||
_$$BasicAuthImplFromJson(json); | ||
|
||
@override | ||
final String username; | ||
@override | ||
final String password; | ||
|
||
@override | ||
String toString() { | ||
return 'BasicAuth(username: $username, password: $password)'; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
return identical(this, other) || | ||
(other.runtimeType == runtimeType && | ||
other is _$BasicAuthImpl && | ||
(identical(other.username, username) || | ||
other.username == username) && | ||
(identical(other.password, password) || | ||
other.password == password)); | ||
} | ||
|
||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
@override | ||
int get hashCode => Object.hash(runtimeType, username, password); | ||
|
||
/// Create a copy of BasicAuth | ||
/// with the given fields replaced by the non-null parameter values. | ||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
@override | ||
@pragma('vm:prefer-inline') | ||
_$$BasicAuthImplCopyWith<_$BasicAuthImpl> get copyWith => | ||
__$$BasicAuthImplCopyWithImpl<_$BasicAuthImpl>(this, _$identity); | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return _$$BasicAuthImplToJson( | ||
this, | ||
); | ||
} | ||
} | ||
|
||
abstract class _BasicAuth implements BasicAuth { | ||
const factory _BasicAuth( | ||
{required final String username, | ||
required final String password}) = _$BasicAuthImpl; | ||
|
||
factory _BasicAuth.fromJson(Map<String, dynamic> json) = | ||
_$BasicAuthImpl.fromJson; | ||
|
||
@override | ||
String get username; | ||
@override | ||
String get password; | ||
|
||
/// Create a copy of BasicAuth | ||
/// with the given fields replaced by the non-null parameter values. | ||
@override | ||
@JsonKey(includeFromJson: false, includeToJson: false) | ||
_$$BasicAuthImplCopyWith<_$BasicAuthImpl> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} |
Oops, something went wrong.