Skip to content

Add package uploading feature #1435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

Oksamies
Copy link
Contributor

No description provided.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Oksamies Oksamies force-pushed the 03-25-add_package_uploading_feature branch 2 times, most recently from a271640 to 6e1e6bd Compare March 26, 2025 19:44
controller: AbortController
) => Promise<Res>;

function chainActions<T1, T2, T3>(

Check failure

Code scanning / ESLint

Disallow unused variables

'chainActions' is defined but never used.

Copilot Autofix

AI 18 days ago

To fix the problem, we need to remove the unused chainActions function from the code. This will eliminate the ESLint error and clean up the code by removing unnecessary definitions.

  • Locate the chainActions function definition in the file packages/ts-uploader/src/tasks/chain.ts.
  • Remove the entire function definition, including its type definition and implementation.
Suggested changeset 1
packages/ts-uploader/src/tasks/chain.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/ts-uploader/src/tasks/chain.ts b/packages/ts-uploader/src/tasks/chain.ts
--- a/packages/ts-uploader/src/tasks/chain.ts
+++ b/packages/ts-uploader/src/tasks/chain.ts
@@ -5,9 +5 @@
 
-function chainActions<T1, T2, T3>(
-  act1: TaskAction<T1, T2>,
-  act2: TaskAction<T2, T3>
-): TaskAction<T1, T3> {
-  return async (args, controller) => {
-    return await act2(await act1(args, controller), controller);
-  };
-}
EOF
@@ -5,9 +5 @@

function chainActions<T1, T2, T3>(
act1: TaskAction<T1, T2>,
act2: TaskAction<T2, T3>
): TaskAction<T1, T3> {
return async (args, controller) => {
return await act2(await act1(args, controller), controller);
};
}
Copilot is powered by AI and may make mistakes. Always verify output.
export type AbortedTask<Args, Res> = TaskBase<Args, Res> & {
status: TaskStatus.FINISHED;
finishReason: TaskFinishReason.ABORTED;
abortReason?: any;

Check failure

Code scanning / ESLint

Disallow the `any` type

Unexpected any. Specify a different type.

Copilot Autofix

AI 18 days ago

To fix the problem, we need to replace the any type with a more specific type that accurately represents the possible values for abortReason. Since abortReason is used in the context of an AbortController, it should be of type DOMException or undefined, as these are the types typically associated with abort reasons in the DOM API.

Suggested changeset 1
packages/ts-uploader/src/tasks/task.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/ts-uploader/src/tasks/task.ts b/packages/ts-uploader/src/tasks/task.ts
--- a/packages/ts-uploader/src/tasks/task.ts
+++ b/packages/ts-uploader/src/tasks/task.ts
@@ -31,3 +31,3 @@
   finishReason: TaskFinishReason.ABORTED;
-  abortReason?: any;
+  abortReason?: DOMException | undefined;
 };
EOF
@@ -31,3 +31,3 @@
finishReason: TaskFinishReason.ABORTED;
abortReason?: any;
abortReason?: DOMException | undefined;
};
Copilot is powered by AI and may make mistakes. Always verify output.

function abortTask<Args, Res>(
task: StartedTask<Args, Res>,
reason?: any

Check failure

Code scanning / ESLint

Disallow the `any` type

Unexpected any. Specify a different type.

Copilot Autofix

AI 18 days ago

To fix the problem, we need to replace the any type with a more specific type that accurately represents the possible values for the reason parameter. In this case, the reason parameter for the abort method of AbortController can be of any type, but it is often a string, an error, or undefined. We can use a union type to represent this.

We will replace the any type with a union type that includes string, Error, and undefined. This will provide better type safety while still allowing for the flexibility needed for the reason parameter.

Suggested changeset 1
packages/ts-uploader/src/tasks/task.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/ts-uploader/src/tasks/task.ts b/packages/ts-uploader/src/tasks/task.ts
--- a/packages/ts-uploader/src/tasks/task.ts
+++ b/packages/ts-uploader/src/tasks/task.ts
@@ -108,3 +108,3 @@
   task: StartedTask<Args, Res>,
-  reason?: any
+  reason?: string | Error | undefined
 ): Promise<FinishedTask<Args, Res>> {
EOF
@@ -108,3 +108,3 @@
task: StartedTask<Args, Res>,
reason?: any
reason?: string | Error | undefined
): Promise<FinishedTask<Args, Res>> {
Copilot is powered by AI and may make mistakes. Always verify output.
Oksamies added 5 commits April 3, 2025 18:32
- Replaced NewSelect with NewSelectSearch for team, communities, and categories selection.
- Updated the Upload pages name
- Enhanced the drag-and-drop file input area for better user experience.
- Improved placeholder text and button labels for clarity.
- Added multiple selection support for communities and categories.
- Introduced new SelectSearch component with customizable styles and functionality.
- Implemented community and category selection using NewSelectSearch component.
- Added meta tags for improved SEO and page description.
- Integrated data loading for communities via loader functions.
- Updated state management for selected communities and categories.
- Improved user experience with dynamic category loading based on selected communities.
- Enhanced UI elements for clarity and usability.
- Added progress bar and status display for file uploads.
- Enhanced error handling with user feedback for upload failures.
- Updated Upload component to utilize new upload hooks for better state management.
- Refactored upload logic to support both single and multipart uploads.
- Improved UI elements for clarity and user experience during file uploads.
- Added functionality to track and display the status of package submissions.
- Implemented polling mechanism to check submission status and handle errors.
- Updated state management for selected categories and teams.
- Refactored submission logic to improve error handling and user feedback.
- Integrated new API methods for fetching package submission status.
@Oksamies Oksamies force-pushed the 03-25-add_package_uploading_feature branch from 09696da to 15bef47 Compare April 3, 2025 17:57
Oksamies added 4 commits April 4, 2025 20:55
- Introduced useRef for tracking submission status updates.
- Enhanced polling mechanism to check submission status with better error handling.
- Updated state management for submission results, including detailed package information.
- Cleaned up unused code and comments for better readability.
- Improved UI elements to display package details and community information after submission.
- Introduced NewSwitch component for improved toggle functionality in the Upload component.
- Updated Upload component to utilize NewSwitch for NSFW toggle, enhancing state management.
- Added CSS styles for the NewSwitch component to ensure consistent theming.
- Refactored related styles and components for better organization and maintainability.
…munity listings

- Updated the Upload component to present package submission results in a more structured format.
- Integrated NewTable for displaying available communities and their details, improving clarity and organization.
- Added new icons and links for enhanced user interaction with package information.
- Refactored the layout to improve the overall user experience after package submission.
… management

- Updated the Upload component to set the upload handle to undefined in case of an error during the upload process.
- Ensured that the upload process starts only after setting the handle, improving the flow of state management.
- Enhanced error handling to provide better feedback to users in case of upload failures.
}
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(_error) => {

Check failure

Code scanning / ESLint

Disallow unused variables

'_error' is defined but never used.

Copilot Autofix

AI 11 days ago

To fix the problem, we need to remove the unused variable _error from the code. This will eliminate the ESLint warning and make the code cleaner and easier to maintain. The best way to fix this is to update the retryPolling function to remove the _error parameter from the then method's second callback function.

Suggested changeset 1
apps/cyberstorm-remix/app/upload/upload.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/cyberstorm-remix/app/upload/upload.tsx b/apps/cyberstorm-remix/app/upload/upload.tsx
--- a/apps/cyberstorm-remix/app/upload/upload.tsx
+++ b/apps/cyberstorm-remix/app/upload/upload.tsx
@@ -359,4 +359,3 @@
         },
-        // eslint-disable-next-line @typescript-eslint/no-unused-vars
-        (_error) => {
+        () => {
           setSubmissionError({
EOF
@@ -359,4 +359,3 @@
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(_error) => {
() => {
setSubmissionError({
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Oksamies added 4 commits April 6, 2025 01:46
- Removed the legacy MD5 calculation function and replaced it with a worker-based implementation for improved performance.
- Updated MultipartUpload and SinglePartUpload components to utilize the new MD5 worker for checksum calculations.
- Introduced WorkerManager and MD5WorkerManager to handle upload and MD5 operations in separate threads, enhancing responsiveness.
- Added new worker scripts for handling part uploads and MD5 calculations, ensuring better error handling and progress tracking during uploads.
- Removed SinglePartUpload component and its associated MD5 calculation utility to streamline the upload process.
- Updated MultipartUpload to utilize worker-based MD5 calculations and improved part upload handling.
- Enhanced WorkerManager and MD5WorkerManager for better concurrency and error handling during uploads.
- Cleaned up code by removing legacy upload worker scripts and unnecessary comments, improving overall maintainability.
- Added a TODO comment in MultipartUpload to address potential issues with error visibility when a 400/500 response is received during upload initialization.
- This change aims to improve error handling and ensure users receive appropriate feedback in case of upload failures.
…r handling

- Introduced a new progress bar layout to display individual part upload statuses, improving user feedback during uploads.
- Updated the Upload component to format and display upload speed and total bytes transferred, enhancing clarity.
- Refactored the MultipartUpload class to manage part progress and state more effectively, including error handling for individual parts.
- Removed legacy upload handling code and unnecessary comments to streamline the upload process and improve maintainability.
}
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(_error) => {

Check failure

Code scanning / ESLint

Disallow unused variables

'_error' is defined but never used.

Copilot Autofix

AI 11 days ago

To fix the problem, we need to remove the unused variable _error from the code. This will resolve the ESLint warning and clean up the code. The best way to fix this without changing existing functionality is to remove the _error parameter from the function definition on line 306.

Suggested changeset 1
apps/cyberstorm-remix/app/upload/upload.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/cyberstorm-remix/app/upload/upload.tsx b/apps/cyberstorm-remix/app/upload/upload.tsx
--- a/apps/cyberstorm-remix/app/upload/upload.tsx
+++ b/apps/cyberstorm-remix/app/upload/upload.tsx
@@ -305,3 +305,3 @@
         // eslint-disable-next-line @typescript-eslint/no-unused-vars
-        (_error) => {
+        () => {
           setSubmissionError({
EOF
@@ -305,3 +305,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(_error) => {
() => {
setSubmissionError({
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated

async pause(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {

Check failure

Code scanning / ESLint

Disallow unused variables

'_key' is defined but never used.

Copilot Autofix

AI 11 days ago

To fix the problem, we need to remove the unused variable _key from the forEach callback function. This can be done by using a different parameter signature that only includes the used variable value. This change should be applied to all instances where _key is defined but not used.

Suggested changeset 1
packages/ts-uploader/src/state/MultipartUpload.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/ts-uploader/src/state/MultipartUpload.ts b/packages/ts-uploader/src/state/MultipartUpload.ts
--- a/packages/ts-uploader/src/state/MultipartUpload.ts
+++ b/packages/ts-uploader/src/state/MultipartUpload.ts
@@ -236,4 +236,3 @@
   async pause(): Promise<void> {
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "uploading") {
@@ -246,4 +245,3 @@
   async resume(): Promise<void> {
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "paused") {
@@ -267,4 +265,3 @@
   async retry(): Promise<void> {
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "error") {
EOF
@@ -236,4 +236,3 @@
async pause(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "uploading") {
@@ -246,4 +245,3 @@
async resume(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "paused") {
@@ -267,4 +265,3 @@
async retry(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "error") {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated

async resume(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {

Check failure

Code scanning / ESLint

Disallow unused variables

'_key' is defined but never used.

Copilot Autofix

AI 11 days ago

To fix the problem, we need to remove the unused _key variable from the forEach loop in the pause, resume, and retry methods. This will eliminate the ESLint warning and improve the code quality. Specifically, we will update the forEach loop to only include the value parameter, which is actually used in the loop body.

Suggested changeset 1
packages/ts-uploader/src/state/MultipartUpload.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/ts-uploader/src/state/MultipartUpload.ts b/packages/ts-uploader/src/state/MultipartUpload.ts
--- a/packages/ts-uploader/src/state/MultipartUpload.ts
+++ b/packages/ts-uploader/src/state/MultipartUpload.ts
@@ -236,4 +236,3 @@
   async pause(): Promise<void> {
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "uploading") {
@@ -246,4 +245,3 @@
   async resume(): Promise<void> {
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "paused") {
@@ -267,4 +265,3 @@
   async retry(): Promise<void> {
-    // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "error") {
EOF
@@ -236,4 +236,3 @@
async pause(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "uploading") {
@@ -246,4 +245,3 @@
async resume(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "paused") {
@@ -267,4 +265,3 @@
async retry(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "error") {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated

async retry(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {

Check failure

Code scanning / ESLint

Disallow unused variables

'_key' is defined but never used.

Copilot Autofix

AI 11 days ago

The best way to fix the problem is to remove the unused variable _key from the forEach loop. This will resolve the ESLint error without changing the existing functionality of the code. The variable _key is not used within the loop, so its removal will not affect the logic of the code.

To implement this fix, we need to edit the forEach loops in the pause, resume, and retry methods to remove the _key variable. This involves changing the parameter list of the forEach callback function to only include the value parameter.

Suggested changeset 1
packages/ts-uploader/src/state/MultipartUpload.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/ts-uploader/src/state/MultipartUpload.ts b/packages/ts-uploader/src/state/MultipartUpload.ts
--- a/packages/ts-uploader/src/state/MultipartUpload.ts
+++ b/packages/ts-uploader/src/state/MultipartUpload.ts
@@ -237,3 +237,3 @@
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "uploading") {
@@ -247,3 +247,3 @@
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "paused") {
@@ -268,3 +268,3 @@
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
-    Object.entries(this.partStates).forEach(([_key, value]) => {
+    Object.entries(this.partStates).forEach(([, value]) => {
       if (value.state === "error") {
EOF
@@ -237,3 +237,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "uploading") {
@@ -247,3 +247,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "paused") {
@@ -268,3 +268,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Object.entries(this.partStates).forEach(([_key, value]) => {
Object.entries(this.partStates).forEach(([, value]) => {
if (value.state === "error") {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Oksamies added 9 commits April 9, 2025 16:44
- Updated the Upload component to change the layout of progress bars from column to row for better visibility.
- Introduced new user media upload API methods for initiating, finishing, and aborting uploads, improving the upload workflow.
- Enhanced error handling in the apiFetch function to provide clearer feedback on validation errors using Zod.
- Added utility functions for formatting error messages, ensuring better user experience during upload processes.
- Cleaned up and organized the codebase by removing legacy components and comments, improving maintainability.
…d clarity

- Removed legacy community schema and integrated Zod validation for community-related API responses.
- Updated fetch functions to utilize structured request and response schemas, enhancing type safety.
- Introduced query parameter schemas for better handling of community list requests and filters.
- Cleaned up code by removing unused imports and legacy components, improving maintainability.
- Enhanced error handling in API fetch functions to provide clearer feedback on validation errors.
…eturn type to CurrentUserResponseData and reorganizing imports for clarity.
- Updated fetch functions to utilize structured request and response schemas, improving type safety across various API endpoints.
- Replaced legacy parameter handling with Zod validation for better input validation and error handling.
- Cleaned up code by removing unused imports and legacy components, enhancing maintainability.
- Introduced new request parameter types for community, namespace, and package-related fetch functions, ensuring consistent data handling.
- Updated the organization of API fetch functions to separate GET and POST requests, enhancing clarity and maintainability.
- Introduced new request and response schemas for package submission, improving type safety and validation using Zod.
- Refactored the fetchPackageSubmissionStatus function to utilize structured parameters and schemas, ensuring consistent data handling.
- Cleaned up imports and removed legacy components to streamline the codebase.
- Updated API exports to consolidate team and package-related endpoints, improving organization and clarity.
- Introduced new endpoints for package handling, including package rating and listing updates, enhancing functionality.
- Removed deprecated and unused endpoints to streamline the codebase and improve maintainability.
- Added new request and response schemas for markdown rendering and user media handling, improving type safety and validation.
- Cleaned up imports and organized code for better readability and maintainability.
- Updated PackageDeprecateAction and PackageLikeAction to utilize structured parameters and improve type safety with new ApiEndpointProps.
- Refactored onSubmit methods to align with the new parameter structure, enhancing clarity and maintainability.
- Removed deprecated schemas and cleaned up imports for better organization.
- Enhanced error handling in forms and actions to provide clearer feedback on validation errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant