mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 02:39:19 +08:00
Introduces `preRequestScript` and `postRequestScript` fields to the request model to store user-defined scripts. Implements a service using `flutter_js` to execute JavaScript pre-request scripts before a request is sent. The script can access and modify request data (like headers, body, URL) and environment variables. Adds bridging to forward JavaScript `console.log`, `console.warn`, and `console.error` calls to the Dart console for easier debugging
32 lines
926 B
Dart
32 lines
926 B
Dart
import 'package:apidash_core/apidash_core.dart';
|
|
|
|
part 'request_model.freezed.dart';
|
|
|
|
part 'request_model.g.dart';
|
|
|
|
@freezed
|
|
class RequestModel with _$RequestModel {
|
|
@JsonSerializable(
|
|
explicitToJson: true,
|
|
anyMap: true,
|
|
)
|
|
const factory RequestModel({
|
|
required String id,
|
|
@Default(APIType.rest) APIType apiType,
|
|
@Default("") String name,
|
|
@Default("") String description,
|
|
@JsonKey(includeToJson: false) @Default(0) requestTabIndex,
|
|
HttpRequestModel? httpRequestModel,
|
|
int? responseStatus,
|
|
String? message,
|
|
HttpResponseModel? httpResponseModel,
|
|
@JsonKey(includeToJson: false) @Default(false) bool isWorking,
|
|
@JsonKey(includeToJson: false) DateTime? sendingTime,
|
|
@Default("") String preRequestScript,
|
|
@Default("") String postRequestScript,
|
|
}) = _RequestModel;
|
|
|
|
factory RequestModel.fromJson(Map<String, Object?> json) =>
|
|
_$RequestModelFromJson(json);
|
|
}
|