Update har package name

This commit is contained in:
Ashita Prasad
2025-06-23 04:37:56 +05:30
parent 963bc400d9
commit a1eac15f06
20 changed files with 60 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
import 'package:har_parser/har_parser.dart' as hp; import 'package:har/har.dart' as har;
import 'package:seed/seed.dart'; import 'package:seed/seed.dart';
import '../consts.dart'; import '../consts.dart';
import '../models/models.dart'; import '../models/models.dart';
@@ -8,8 +8,8 @@ class HarParserIO {
List<(String?, HttpRequestModel)>? getHttpRequestModelList(String content) { List<(String?, HttpRequestModel)>? getHttpRequestModelList(String content) {
content = content.trim(); content = content.trim();
try { try {
final hl = hp.harLogFromJsonStr(content); final hl = har.harLogFromJsonStr(content);
final requests = hp.getRequestsFromHarLog(hl); final requests = har.getRequestsFromHarLog(hl);
return requests return requests
.map((req) => (req.$2.url, harRequestToHttpRequestModel(req.$2))) .map((req) => (req.$2.url, harRequestToHttpRequestModel(req.$2)))
.toList(); .toList();
@@ -18,7 +18,7 @@ class HarParserIO {
} }
} }
HttpRequestModel harRequestToHttpRequestModel(hp.Request request) { HttpRequestModel harRequestToHttpRequestModel(har.Request request) {
HTTPVerb method; HTTPVerb method;
try { try {
@@ -33,7 +33,7 @@ class HarParserIO {
List<NameValueModel> params = []; List<NameValueModel> params = [];
List<bool> isParamEnabledList = []; List<bool> isParamEnabledList = [];
for (var header in request.headers ?? <hp.Header>[]) { for (var header in request.headers ?? <har.Header>[]) {
var name = header.name ?? ""; var name = header.name ?? "";
var value = header.value; var value = header.value;
var activeHeader = header.disabled ?? false; var activeHeader = header.disabled ?? false;
@@ -41,7 +41,7 @@ class HarParserIO {
isHeaderEnabledList.add(!activeHeader); isHeaderEnabledList.add(!activeHeader);
} }
for (var query in request.queryString ?? <hp.Query>[]) { for (var query in request.queryString ?? <har.Query>[]) {
var name = query.name ?? ""; var name = query.name ?? "";
var value = query.value; var value = query.value;
var activeQuery = query.disabled ?? false; var activeQuery = query.disabled ?? false;
@@ -77,7 +77,7 @@ class HarParserIO {
if (request.postData?.mimeType == "multipart/form-data") { if (request.postData?.mimeType == "multipart/form-data") {
bodyContentType = ContentType.formdata; bodyContentType = ContentType.formdata;
var name, val; var name, val;
for (var fd in request.postData?.params ?? <hp.Param>[]) { for (var fd in request.postData?.params ?? <har.Param>[]) {
name = fd.name; name = fd.name;
if (fd.contentType == "text/plain") { if (fd.contentType == "text/plain") {
formDataType = FormDataType.text; formDataType = FormDataType.text;

View File

@@ -21,8 +21,8 @@ dependencies:
path: ../insomnia_collection path: ../insomnia_collection
postman: postman:
path: ../postman path: ../postman
har_parser: har:
path: ../har_parser path: ../har
seed: ^0.0.3 seed: ^0.0.3
xml: ^6.3.0 xml: ^6.3.0

View File

@@ -1,10 +1,9 @@
# melos_managed_dependency_overrides: har_parser # melos_managed_dependency_overrides: curl_parser,insomnia_collection,postman,seed,har
# melos_managed_dependency_overrides: curl_parser,insomnia_collection,postman,seed
dependency_overrides: dependency_overrides:
curl_parser: curl_parser:
path: ../curl_parser path: ../curl_parser
har_parser: har:
path: ..\\har_parser path: ../har
insomnia_collection: insomnia_collection:
path: ../insomnia_collection path: ../insomnia_collection
postman: postman:

View File

@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.
Copyright 2023 Ashita Prasad, Ankit Mahato Copyright 2025 Ashita Prasad, Ankit Mahato
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@@ -1,4 +1,4 @@
# insomnia # har
Seamlessly convert Har Collection Format v1.2 to Dart. Seamlessly convert Har Collection Format v1.2 to Dart.
@@ -11,7 +11,7 @@ Currently, this package is being used by [API Dash](https://github.com/foss42/ap
### Example 1: Har collection JSON string to Har model ### Example 1: Har collection JSON string to Har model
```dart ```dart
import 'package:har_parser/har_parser.dart'; import 'package:har/har.dart';
void main() { void main() {
// Example 1: Har collection JSON string to Har model // Example 1: Har collection JSON string to Har model
@@ -173,7 +173,7 @@ void main() {
### Example 2: Har collection from JSON ### Example 2: Har collection from JSON
```dart ```dart
import 'package:har_parser/har_parser.dart'; import 'package:har/har.dart';
void main() { void main() {
// Example 2: Har collection from JSON // Example 2: Har collection from JSON
@@ -337,4 +337,4 @@ var collectionJson = {
## License ## License
This project is licensed under the [Apache License 2.0](https://github.com/foss42/apidash/blob/main/packages/har_parser/LICENSE). This project is licensed under the [Apache License 2.0](https://github.com/foss42/apidash/blob/main/packages/har/LICENSE).

View File

@@ -1,4 +1,4 @@
import 'package:har_parser/har_parser.dart'; import 'package:har/har.dart';
void main() { void main() {
//Example 1 //Example 1

View File

@@ -0,0 +1,4 @@
library har;
export 'models/models.dart';
export 'utils/har_utils.dart';

View File

@@ -1,4 +1,4 @@
name: har_parser name: har
description: "Seamlessly convert har Format to Dart and vice versa." description: "Seamlessly convert har Format to Dart and vice versa."
version: 0.0.1 version: 0.0.1
homepage: https://github.com/foss42/apidash homepage: https://github.com/foss42/apidash

View File

@@ -1,4 +1,4 @@
import 'package:har_parser/har_parser.dart'; import 'package:har/har.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'collection_examples/collection_apidash.dart'; import 'collection_examples/collection_apidash.dart';

View File

@@ -1,4 +1,4 @@
import 'package:har_parser/models/models.dart'; import 'package:har/models/models.dart';
var collectionApiDashModel = HarLog( var collectionApiDashModel = HarLog(
log: Log( log: Log(
@@ -62,7 +62,8 @@ var collectionApiDashModel = HarLog(
time: 200, time: 200,
request: Request( request: Request(
method: "GET", method: "GET",
url: "https://api.apidash.dev/humanize/social?num=8700000&digits=3&system=SS&add_space=true&trailing_zeros=true", url:
"https://api.apidash.dev/humanize/social?num=8700000&digits=3&system=SS&add_space=true&trailing_zeros=true",
httpVersion: null, httpVersion: null,
cookies: null, cookies: null,
headers: [], headers: [],
@@ -122,15 +123,32 @@ var collectionApiDashModel = HarLog(
request: Request( request: Request(
method: "POST", method: "POST",
url: "https://api.apidash.dev/io/form", url: "https://api.apidash.dev/io/form",
headers: [Header(name: "User-Agent", value: "Test Agent", disabled: null)], headers: [
Header(name: "User-Agent", value: "Test Agent", disabled: null)
],
queryString: [], queryString: [],
bodySize: 100, bodySize: 100,
postData: PostData( postData: PostData(
mimeType: "multipart/form-data", mimeType: "multipart/form-data",
params: [ params: [
Param(name: "text", value: "API", fileName: null, contentType: "text/plain", disabled: null), Param(
Param(name: "sep", value: "|", fileName: null, contentType: "text/plain", disabled: null), name: "text",
Param(name: "times", value: "3", fileName: null, contentType: "text/plain", disabled: null) value: "API",
fileName: null,
contentType: "text/plain",
disabled: null),
Param(
name: "sep",
value: "|",
fileName: null,
contentType: "text/plain",
disabled: null),
Param(
name: "times",
value: "3",
fileName: null,
contentType: "text/plain",
disabled: null)
], ],
), ),
), ),
@@ -160,8 +178,18 @@ var collectionApiDashModel = HarLog(
mimeType: "multipart/form-data", mimeType: "multipart/form-data",
text: null, text: null,
params: [ params: [
Param(name: "token", value: "xyz", fileName: null, contentType: "text/plain", disabled: null), Param(
Param(name: "imfile", value: null, fileName: "hire AI.jpeg", contentType: "image/jpeg", disabled: null) name: "token",
value: "xyz",
fileName: null,
contentType: "text/plain",
disabled: null),
Param(
name: "imfile",
value: null,
fileName: "hire AI.jpeg",
contentType: "image/jpeg",
disabled: null)
], ],
), ),
headersSize: null, headersSize: null,

View File

@@ -1,4 +0,0 @@
library har_parser;
export 'models/models.dart';
export 'utils/har_parser_utils.dart';