Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Unify creditCosts.ts files (#5952)

James Brunton7f9bbebe5bac
diff --git a/app/core/src/main/java/stirling/software/SPDF/model/api/PDFExtractImagesRequest.java b/app/core/src/main/java/stirling/software/SPDF/model/api/PDFExtractImagesRequest.java
index 272c5c8b1e..107582cf42 100644
--- a/app/core/src/main/java/stirling/software/SPDF/model/api/PDFExtractImagesRequest.java
+++ b/app/core/src/main/java/stirling/software/SPDF/model/api/PDFExtractImagesRequest.java
@@ -9,10 +9,10 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class PDFExtractImagesRequest extends PDFWithImageFormatRequest {
- @Schema(
- description =
- "Boolean to enable/disable the saving of duplicate images, true to enable"
- + " duplicates",
- defaultValue = "false")
- private Boolean allowDuplicates;
+ // @Schema(
+ // description =
+ // "Boolean to enable/disable the saving of duplicate images, true to enable"
+ // + " duplicates",
+ // defaultValue = "false")
+ // private Boolean allowDuplicates;
}
diff --git a/frontend/src/core/components/tools/extractImages/ExtractImagesSettings.tsx b/frontend/src/core/components/tools/extractImages/ExtractImagesSettings.tsx
index 424da2cc23..9a6b347222 100644
--- a/frontend/src/core/components/tools/extractImages/ExtractImagesSettings.tsx
+++ b/frontend/src/core/components/tools/extractImages/ExtractImagesSettings.tsx
@@ -1,5 +1,5 @@
import { useTranslation } from 'react-i18next';
-import { Stack, Select, Checkbox } from '@mantine/core';
+import { Stack, Select } from '@mantine/core';
import { ExtractImagesParameters } from '@app/hooks/tools/extractImages/useExtractImagesParameters';
import { Z_INDEX_AUTOMATE_DROPDOWN } from "@app/styles/zIndex";
@@ -35,12 +35,12 @@ const ExtractImagesSettings = ({
comboboxProps={{ withinPortal: true, zIndex: Z_INDEX_AUTOMATE_DROPDOWN }}
/>
- <Checkbox
+ {/* <Checkbox
label={t('extractImages.allowDuplicates', 'Allow Duplicate Images')}
checked={parameters.allowDuplicates}
onChange={(event) => onParameterChange('allowDuplicates', event.currentTarget.checked)}
disabled={disabled}
- />
+ /> */}
</Stack>
);
};
diff --git a/frontend/src/core/hooks/tools/extractImages/useExtractImagesOperation.ts b/frontend/src/core/hooks/tools/extractImages/useExtractImagesOperation.ts
index 317630317c..ac691baf08 100644
--- a/frontend/src/core/hooks/tools/extractImages/useExtractImagesOperation.ts
+++ b/frontend/src/core/hooks/tools/extractImages/useExtractImagesOperation.ts
@@ -10,7 +10,7 @@ export const buildExtractImagesFormData = (parameters: ExtractImagesParameters,
const formData = new FormData();
formData.append("fileInput", file);
formData.append("format", parameters.format);
- formData.append("allowDuplicates", parameters.allowDuplicates.toString());
+ // formData.append("allowDuplicates", parameters.allowDuplicates.toString());
return formData;
};
diff --git a/frontend/src/core/hooks/tools/extractImages/useExtractImagesParameters.ts b/frontend/src/core/hooks/tools/extractImages/useExtractImagesParameters.ts
index 183fdd2a76..4321bfe9f2 100644
--- a/frontend/src/core/hooks/tools/extractImages/useExtractImagesParameters.ts
+++ b/frontend/src/core/hooks/tools/extractImages/useExtractImagesParameters.ts
@@ -2,12 +2,12 @@ import { useBaseParameters } from '@app/hooks/tools/shared/useBaseParameters';
export interface ExtractImagesParameters {
format: 'png' | 'jpg' | 'gif';
- allowDuplicates: boolean;
+ // allowDuplicates: boolean;
}
export const defaultParameters: ExtractImagesParameters = {
format: 'png',
- allowDuplicates: false,
+ // allowDuplicates: false,
};
export const useExtractImagesParameters = () => {
diff --git a/frontend/src/desktop/utils/creditCosts.ts b/frontend/src/proprietary/utils/creditCosts.ts
similarity index 100%
rename from frontend/src/desktop/utils/creditCosts.ts
rename to frontend/src/proprietary/utils/creditCosts.ts
diff --git a/frontend/src/saas/utils/creditCosts.ts b/frontend/src/saas/utils/creditCosts.ts
deleted file mode 100644
index d0b2acae0b..0000000000
--- a/frontend/src/saas/utils/creditCosts.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-import { ToolId } from '@app/types/toolId'
-
-// Credit costs based on ResourceWeight enum from backend
-export const CREDIT_COSTS = {
- NONE: 0,
- SMALL: 1,
- MEDIUM: 3,
- LARGE: 5,
- XLARGE: 10
-} as const
-
-/**
- * Mapping of tool IDs to their credit costs
- * Based on backend ResourceWeight annotations
- */
-export const TOOL_CREDIT_COSTS: Record<ToolId, number> = {
- // No cost operations (0 credits)
- showJS: CREDIT_COSTS.NONE,
- devApi: CREDIT_COSTS.NONE,
- devFolderScanning: CREDIT_COSTS.NONE,
- devSsoGuide: CREDIT_COSTS.NONE,
- devAirgapped: CREDIT_COSTS.NONE,
-
- // Small operations (1 credit)
- rotate: CREDIT_COSTS.SMALL,
- removePages: CREDIT_COSTS.SMALL,
- addText: CREDIT_COSTS.SMALL,
- addPassword: CREDIT_COSTS.SMALL,
- removePassword: CREDIT_COSTS.SMALL,
- changePermissions: CREDIT_COSTS.SMALL,
- flatten: CREDIT_COSTS.SMALL,
- repair: CREDIT_COSTS.SMALL,
- unlockPDFForms: CREDIT_COSTS.SMALL,
- crop: CREDIT_COSTS.SMALL,
- addPageNumbers: CREDIT_COSTS.SMALL,
- extractPages: CREDIT_COSTS.SMALL,
- reorganizePages: CREDIT_COSTS.SMALL,
- scalePages: CREDIT_COSTS.SMALL,
- editTableOfContents: CREDIT_COSTS.SMALL,
- sign: CREDIT_COSTS.SMALL,
- annotate: CREDIT_COSTS.SMALL,
- formFill: CREDIT_COSTS.SMALL,
- removeAnnotations: CREDIT_COSTS.SMALL,
- removeImage: CREDIT_COSTS.SMALL,
- scannerImageSplit: CREDIT_COSTS.SMALL,
- adjustContrast: CREDIT_COSTS.SMALL,
- multiTool: CREDIT_COSTS.SMALL,
- compare: CREDIT_COSTS.SMALL,
- addAttachments: CREDIT_COSTS.SMALL,
- getPdfInfo: CREDIT_COSTS.MEDIUM,
- validateSignature: CREDIT_COSTS.SMALL,
- read: CREDIT_COSTS.SMALL,
-
- // Medium operations (3 credits)
- split: CREDIT_COSTS.MEDIUM,
- merge: CREDIT_COSTS.MEDIUM,
- pdfTextEditor: CREDIT_COSTS.MEDIUM,
- changeMetadata: CREDIT_COSTS.MEDIUM,
- watermark: CREDIT_COSTS.MEDIUM,
- bookletImposition: CREDIT_COSTS.MEDIUM,
- pdfToSinglePage: CREDIT_COSTS.MEDIUM,
- removeBlanks: CREDIT_COSTS.MEDIUM,
- autoRename: CREDIT_COSTS.MEDIUM,
- sanitize: CREDIT_COSTS.MEDIUM,
- addImage: CREDIT_COSTS.MEDIUM,
- addStamp: CREDIT_COSTS.MEDIUM,
- extractImages: CREDIT_COSTS.MEDIUM,
- overlayPdfs: CREDIT_COSTS.MEDIUM,
- pageLayout: CREDIT_COSTS.MEDIUM,
- redact: CREDIT_COSTS.MEDIUM,
- removeCertSign: CREDIT_COSTS.MEDIUM,
- scannerEffect: CREDIT_COSTS.MEDIUM,
- replaceColor: CREDIT_COSTS.MEDIUM,
-
- // Large operations (5 credits)
- compress: CREDIT_COSTS.LARGE,
- convert: CREDIT_COSTS.LARGE,
- ocr: CREDIT_COSTS.LARGE,
- certSign: CREDIT_COSTS.LARGE,
-
- // Extra large operations (10 credits)
- automate: CREDIT_COSTS.XLARGE,
-}
-
-/**
- * Get the credit cost for a specific tool
- * @param toolId - The tool identifier
- * @returns The credit cost for the tool, defaults to MEDIUM if not found
- */
-export const getToolCreditCost = (toolId: ToolId): number => {
- return TOOL_CREDIT_COSTS[toolId] ?? CREDIT_COSTS.MEDIUM
-}
diff --git a/testing/cucumber/features/general.feature b/testing/cucumber/features/general.feature
index 9736e2f301..6ede9bb4fc 100644
--- a/testing/cucumber/features/general.feature
+++ b/testing/cucumber/features/general.feature
@@ -70,21 +70,21 @@ Feature: API Validation
| 1 | 10 | 2 | 10 |
- @extract-images
- Scenario Outline: Extract Image Scans duplicates
- Given I use an example file at "exampleFiles/images.pdf" as parameter "fileInput"
- And the request data includes
- | parameter | value |
- | format | <format> |
- When I send the API request to the endpoint "/api/v1/misc/extract-images"
- Then the response content type should be "application/octet-stream"
- And the response file should have extension ".zip"
- And the response ZIP should contain 2 files
- And the response file should have size greater than 0
- And the response status code should be 200
-
- Examples:
- | format |
- | png |
- | gif |
- | jpeg |
+ # @extract-images
+ # Scenario Outline: Extract Image Scans duplicates
+ # Given I use an example file at "exampleFiles/images.pdf" as parameter "fileInput"
+ # And the request data includes
+ # | parameter | value |
+ # | format | <format> |
+ # When I send the API request to the endpoint "/api/v1/misc/extract-images"
+ # Then the response content type should be "application/octet-stream"
+ # And the response file should have extension ".zip"
+ # And the response ZIP should contain 2 files
+ # And the response file should have size greater than 0
+ # And the response status code should be 200
+ #
+ # Examples:
+ # | format |
+ # | png |
+ # | gif |
+ # | jpeg |
diff --git a/testing/cucumber/features/general_new.feature b/testing/cucumber/features/general_new.feature
index ea999c043e..9d07bb1749 100644
--- a/testing/cucumber/features/general_new.feature
+++ b/testing/cucumber/features/general_new.feature
@@ -231,21 +231,21 @@ Feature: General PDF Operations API Validation
And the response file should have size greater than 200
- @remove-image-pdf @positive
- Scenario: remove-image-pdf strips images from a PDF containing images
- Given I generate a PDF file as "fileInput"
- And the pdf contains 3 images of size 100x100 on 2 pages
- When I send the API request to the endpoint "/api/v1/general/remove-image-pdf"
- Then the response content type should be "application/pdf"
- And the response status code should be 200
- And the response file should have size greater than 0
-
-
- @remove-image-pdf @positive
- Scenario: remove-image-pdf on a plain text PDF returns a PDF
- Given I generate a PDF file as "fileInput"
- And the pdf contains 3 pages with random text
- When I send the API request to the endpoint "/api/v1/general/remove-image-pdf"
- Then the response content type should be "application/pdf"
- And the response status code should be 200
- And the response file should have size greater than 0
+ # @remove-image-pdf @positive
+ # Scenario: remove-image-pdf strips images from a PDF containing images
+ # Given I generate a PDF file as "fileInput"
+ # And the pdf contains 3 images of size 100x100 on 2 pages
+ # When I send the API request to the endpoint "/api/v1/general/remove-image-pdf"
+ # Then the response content type should be "application/pdf"
+ # And the response status code should be 200
+ # And the response file should have size greater than 0
+ #
+ #
+ # @remove-image-pdf @positive
+ # Scenario: remove-image-pdf on a plain text PDF returns a PDF
+ # Given I generate a PDF file as "fileInput"
+ # And the pdf contains 3 pages with random text
+ # When I send the API request to the endpoint "/api/v1/general/remove-image-pdf"
+ # Then the response content type should be "application/pdf"
+ # And the response status code should be 200
+ # And the response file should have size greater than 0