Skip to content

Commit d641757

Browse files
authored
Merge branch 'main' into dashbot-core
2 parents 7e6032d + 9389585 commit d641757

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3318
-435
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pub" # See documentation for possible values
9+
directories:
10+
- "/" # Location of package manifests
11+
- "/packages/*/"
12+
schedule:
13+
interval: "monthly"

.github/workflows/aur-publish.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Update AUR Package
2+
permissions:
3+
contents: read
24

35
on:
46
push:
@@ -12,7 +14,7 @@ jobs:
1214
runs-on: ubuntu-latest
1315
steps:
1416
- name: Checkout code
15-
uses: actions/checkout@v4
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1618

1719
- name: Get version from pubspec
1820
id: get_version
@@ -42,7 +44,7 @@ jobs:
4244
echo "license_checksum=$LICENSE_CHECKSUM" >> $GITHUB_OUTPUT
4345
4446
- name: Publish AUR package
45-
uses: KSXGitHub/github-actions-deploy-aur@v2.7.0
47+
uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1
4648
with:
4749
pkgname: apidash-bin
4850
pkgbuild: |
@@ -85,4 +87,4 @@ jobs:
8587
commit_username: ${{ secrets.AUR_USERNAME }}
8688
commit_email: ${{ secrets.AUR_EMAIL }}
8789
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
88-
commit_message: "Update to version ${{ steps.get_version.outputs.version }}"
90+
commit_message: "Update to version ${{ steps.get_version.outputs.version }}"

.github/workflows/scorecard.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '30 5 1 * *'
14+
push:
15+
branches: [ "main" ]
16+
17+
# Declare default permissions as read only.
18+
permissions: read-all
19+
20+
jobs:
21+
analysis:
22+
name: Scorecard analysis
23+
runs-on: ubuntu-latest
24+
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
25+
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
26+
permissions:
27+
# Needed to upload the results to code-scanning dashboard.
28+
security-events: write
29+
# Needed to publish results and get a badge (see publish_results below).
30+
id-token: write
31+
# Uncomment the permissions below if installing in a private repository.
32+
# contents: read
33+
# actions: read
34+
35+
steps:
36+
- name: "Checkout code"
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
with:
39+
persist-credentials: false
40+
41+
- name: "Run analysis"
42+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
43+
with:
44+
results_file: results.sarif
45+
results_format: sarif
46+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
47+
# - you want to enable the Branch-Protection check on a *public* repository, or
48+
# - you are installing Scorecard on a *private* repository
49+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
50+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
51+
52+
# Public repositories:
53+
# - Publish results to OpenSSF REST API for easy access by consumers
54+
# - Allows the repository to include the Scorecard badge.
55+
# - See https://github.com/ossf/scorecard-action#publishing-results.
56+
# For private repositories:
57+
# - `publish_results` will always be set to `false`, regardless
58+
# of the value entered here.
59+
publish_results: true
60+
61+
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
62+
# file_mode: git
63+
64+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
65+
# format to the repository Actions tab.
66+
- name: "Upload artifact"
67+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
68+
with:
69+
name: SARIF file
70+
path: results.sarif
71+
retention-days: 5
72+
73+
# Upload the results to GitHub's code scanning dashboard (optional).
74+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
75+
- name: "Upload to code-scanning"
76+
uses: github/codeql-action/upload-sarif@v3
77+
with:
78+
sarif_file: results.sarif

lib/apitoolgen/request_consolidator.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class APIDashRequestDescription {
5050
if (bodyJSON != null) {
5151
getTyp(input, [i = 0]) {
5252
String indent = "\t";
53-
for (int j = 0; j < i; j++) indent += "\t";
53+
for (int j = 0; j < i; j++) {
54+
indent += "\t";
55+
}
5456
if (input.runtimeType.toString().toLowerCase().contains('map')) {
5557
String typd = '{';
5658
for (final z in input.keys) {

lib/consts.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,6 @@ const kMsgClearHistorySuccess = 'History cleared successfully';
512512
const kMsgClearHistoryError = 'Error clearing history';
513513
const kMsgShareError = "Unable to share";
514514
const kLabelGenerateUI = "Generate UI";
515+
// Terminal Page
516+
const kMsgNoLogs = 'No logs yet';
517+
const kMsgSendToView = 'Send a request to view its details in the console.';

lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ void main() async {
1919

2020
var settingsModel = await getSettingsFromSharedPrefs();
2121
var onboardingStatus = await getOnboardingStatusFromSharedPrefs();
22-
initializeJsRuntime();
2322
final initStatus = await initApp(
2423
kIsDesktop,
2524
settingsModel: settingsModel,

lib/providers/collection_providers.dart

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:apidash_core/apidash_core.dart';
33
import 'package:flutter/material.dart';
44
import 'package:flutter_riverpod/flutter_riverpod.dart';
55
import 'package:apidash/consts.dart';
6+
import 'package:apidash/terminal/terminal.dart';
67
import 'providers.dart';
78
import '../models/models.dart';
89
import '../services/services.dart';
@@ -320,7 +321,9 @@ class CollectionStateNotifier
320321
RequestModel executionRequestModel = requestModel!.copyWith();
321322

322323
if (!requestModel.preRequestScript.isNullOrEmpty()) {
323-
executionRequestModel = await handlePreRequestScript(
324+
executionRequestModel = await ref
325+
.read(jsRuntimeNotifierProvider.notifier)
326+
.handlePreRequestScript(
324327
executionRequestModel,
325328
originalEnvironmentModel,
326329
(envModel, updatedValues) {
@@ -347,6 +350,18 @@ class CollectionStateNotifier
347350
executionRequestModel.httpRequestModel!);
348351
}
349352

353+
// Terminal: start network log
354+
final terminal = ref.read(terminalStateProvider.notifier);
355+
final logId = terminal.startNetwork(
356+
apiType: executionRequestModel.apiType,
357+
method: substitutedHttpRequestModel.method,
358+
url: substitutedHttpRequestModel.url,
359+
requestId: requestId,
360+
requestHeaders: substitutedHttpRequestModel.enabledHeadersMap,
361+
requestBodyPreview: substitutedHttpRequestModel.body,
362+
isStreaming: true,
363+
);
364+
350365
// Set model to working and streaming
351366
state = {
352367
...state!,
@@ -398,6 +413,17 @@ class CollectionStateNotifier
398413
...state!,
399414
requestId: newRequestModel,
400415
};
416+
// Terminal: append chunk preview
417+
if (response != null && response.body.isNotEmpty) {
418+
terminal.addNetworkChunk(
419+
logId,
420+
BodyChunk(
421+
ts: DateTime.now(),
422+
text: response.body,
423+
sizeBytes: response.body.codeUnits.length,
424+
),
425+
);
426+
}
401427
unsave();
402428

403429
if (historyModel != null && httpResponseModel != null) {
@@ -425,6 +451,7 @@ class CollectionStateNotifier
425451
if (!completer.isCompleted) {
426452
completer.complete((null, null, 'StreamError: $e'));
427453
}
454+
terminal.failNetwork(logId, 'StreamError: $e');
428455
});
429456

430457
final (response, duration, errorMessage) = await completer.future;
@@ -436,6 +463,7 @@ class CollectionStateNotifier
436463
isWorking: false,
437464
isStreaming: false,
438465
);
466+
terminal.failNetwork(logId, errorMessage ?? 'Unknown error');
439467
} else {
440468
final statusCode = response.statusCode;
441469
httpResponseModel = baseHttpResponseModel.fromResponse(
@@ -461,6 +489,14 @@ class CollectionStateNotifier
461489
isWorking: false,
462490
);
463491

492+
terminal.completeNetwork(
493+
logId,
494+
statusCode: statusCode,
495+
responseHeaders: response.headers,
496+
responseBodyPreview: httpResponseModel?.body,
497+
duration: duration,
498+
);
499+
464500
String newHistoryId = getNewUuid();
465501
historyModel = HistoryRequestModel(
466502
historyId: newHistoryId,
@@ -487,7 +523,9 @@ class CollectionStateNotifier
487523
.addHistoryRequest(historyModel!);
488524

489525
if (!requestModel.postRequestScript.isNullOrEmpty()) {
490-
newRequestModel = await handlePostResponseScript(
526+
newRequestModel = await ref
527+
.read(jsRuntimeNotifierProvider.notifier)
528+
.handlePostResponseScript(
491529
newRequestModel,
492530
originalEnvironmentModel,
493531
(envModel, updatedValues) {

0 commit comments

Comments
 (0)