244 Commits

Author SHA1 Message Date
8cd8ee6f94 Add stock quantity calculation to listing variant schema and enhance tests
This commit introduces a new utility function, `toId`, to handle ID conversions in the `listingvarient.schema.js` file. The `recalculate` method is updated to compute and update the stock quantity for listing variants based on product SKU and stock location. Additionally, a new test case is added in `stockQuantity.recalculate.test.js` to verify the correct behavior of stock quantity calculations before rolling up, ensuring comprehensive test coverage for this functionality.
2026-08-24 18:33:10 +01:00
e0f2870af3 Enhance test coverage by adding additional mock implementations for database and schema modules
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit expands the test setup in `stockQuantity.recalculate.test.js` and `shipments.test.js` by introducing new mock functions for various database operations, including `searchObjects`, `getPropertyValues`, and `listObjects`. These enhancements improve the isolation of tests and ensure that the tests can run independently of the actual database implementation. The updates also include mocks for sales order and marketplace schemas, further enriching the test environment and facilitating comprehensive testing of inventory-related functionalities.
2026-08-24 02:58:10 +01:00
5ff93be27c Add audit owner resolution and actor display name functions
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
This commit introduces a new module, `auditOwner.js`, which includes functions for resolving audit owner details and generating display names for actors. The `resolveAuditOwner` function determines the owner type based on the actor's object type, defaulting to 'user' if not specified. The `actorDisplayName` function formats the display name based on the actor's properties, enhancing the clarity of audit logs. Additionally, the `AUDIT_OWNER_TYPES` constant is exported for use in other modules. Updates to existing files incorporate these new functions for improved audit logging and notification handling.
2026-08-24 02:49:38 +01:00
8974d1e9da Add quantity field to document job schema and update related routes and services
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit introduces a new `quantity` field to the document job schema, ensuring it is required with a default value of 1. The routes and services for managing document jobs are updated to include this new field, allowing for its inclusion in both creation and editing processes. Additionally, the allowed filters and sorters are modified to accommodate the new `quantity` field, enhancing the overall functionality and flexibility of document job management.
2026-08-22 20:02:28 +01:00
0470f62e05 Refactor schema type handling and enhance utility functions in utils and database modules
This commit introduces several utility functions to improve schema type handling, including `getEmbeddedSchemaType` and `getObjectIdSchemaTypeFromPath`. The `getFilterFieldKind` function is updated to utilize these new utilities for better clarity and functionality. Additionally, the `getArrayParentPaths` function is renamed to `getArrayUnwindPaths` for improved readability, and the logic for fetching unique IDs is enhanced with a new `flattenRefIds` function. These changes streamline the code and enhance the overall management of schema references and array paths.
2026-08-22 20:02:21 +01:00
b0943f3fa0 Enhance document template schema and service with referenced templates functionality
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit introduces a new field, `referencedTemplates`, to the document template schema, allowing for the association of other document templates. It also adds utility functions for extracting references from template content and converting filter values to ObjectIds. The document template service is updated to recalculate and populate referenced templates when editing a document template. Additionally, route handlers are modified to support the new referenced templates in their population logic, improving the management of document templates.
2026-08-22 16:39:10 +01:00
827f3b7c8c Update progress messages in PDF generation tests for consistency and clarity
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit modifies the progress messages in the PDF generation tests to include ellipses and exclamation marks, enhancing the clarity and consistency of the output. The changes ensure that the messages reflect a more engaging user experience during the PDF generation process. Corresponding tests have been updated to verify these modifications.
2026-08-22 13:23:48 +01:00
97c44565a8 Implement EventManager for handling object events and enhance document template management
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
This commit introduces the `EventManager` class, which facilitates tracking and broadcasting object events using NATS and websockets. The `documenttemplate.schema.js` file is updated to change the `testObject` field type to `ObjectId` with a reference path, improving data integrity. Additionally, the document template service is enhanced with new functionalities for asynchronous rendering and progress reporting, utilizing Redis for storing render requests. Corresponding tests are added to ensure the correct functionality of the new event handling and document management features.
2026-08-22 12:56:05 +01:00
30d1469204 Refactor query handling in various routes to standardize sort property and order parameters
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit updates multiple route handlers across the management and inventory modules to replace the `sort` and `order` parameters with `sortProperty` and `sortOrder`. This change enhances consistency in query handling and improves the clarity of the code. Additionally, the `getFilter` function is modified to accommodate these new parameters, ensuring that filtering logic remains intact. Corresponding tests have been updated to verify the correct functionality of the modified routes.
2026-08-22 02:36:05 +01:00
4ee5eb7d0a Add pdf-lib dependency and implement PDF merging functionality
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit introduces the `pdf-lib` library to facilitate PDF document manipulation. A new function, `mergePdfBuffers`, is added to handle the merging of multiple PDF buffers into a single document. Additionally, the PDF generation process is updated to support pagination, allowing for the export of each paginated page before merging. The changes enhance the PDF generation capabilities, ensuring that documents can be created with multiple pages while maintaining proper formatting and structure. Corresponding tests have been added to verify the new functionality.
2026-08-22 00:17:43 +01:00
bec4c8bf4c Enhance EJS formatting functionality with new placeholder handling and text tag collapsing
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit introduces several improvements to the EJS formatting logic in the `templateformatter.js` file. It adds new regex patterns for inline placeholders and text-only tags, enhancing the ability to manage EJS content. The `maskEjsBlocks` function is updated to differentiate between control and inline EJS tags, while the `restoreEjsBlocks` function now handles both comment and inline placeholders. Additionally, a new function, `collapseTextOnlyTags`, is introduced to ensure that text content within tags is properly formatted without unnecessary whitespace. Corresponding tests have been added to verify these enhancements, improving the overall template content formatting capabilities.
2026-08-21 22:46:44 +01:00
ff60d6cf09 Enhance document size and template management with padding options
This commit introduces new padding options for document sizes, allowing for customizable print padding and specific padding values (left, right, top, bottom). The document size schema has been updated to include these new fields, and corresponding route handlers have been modified to handle padding data during document size creation and editing. Additionally, the template manager has been updated to apply padding when rendering templates, ensuring that the layout respects the specified padding values. Tests have been added to verify the correct application of padding in both document sizes and templates, improving the overall document formatting capabilities.
2026-08-21 22:39:13 +01:00
e8c9a307ab Enhance route permission checks across management and inventory modules
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit updates various route handlers in the management and inventory modules to include permission checks using the `checkPermissions` middleware. The changes ensure that access to properties, values, and search functionalities for different entities (e.g., users, products, tax rates) is properly restricted based on user permissions. This enhancement improves the security and integrity of the application by enforcing role-based access control across multiple routes.
2026-08-20 20:15:07 +01:00
bce5afad7e Implement caching and permission checks for user permissions
This commit introduces a caching mechanism for user permissions using Redis, enhancing performance by reducing database queries. The `permissions.js` file has been updated to include functions for saving and retrieving user permissions from Redis, as well as middleware for checking permissions in various routes. Additionally, tests have been added to ensure the correctness of the permission logic and caching behavior, improving the overall security and efficiency of the application.
2026-08-20 19:35:15 +01:00
1c51766da6 Add user group management functionality and refactor permission settings
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit introduces a new feature for managing user groups within the application, including the creation of a `usergroup.schema.js` file for the Mongoose schema and corresponding route handlers for CRUD operations. Additionally, the permission settings functionality has been refactored to use a singular `permissionSetting` model instead of the previous plural form. Tests have been added to ensure the functionality of both user groups and permission settings services, enhancing the application's capability to manage user roles and permissions effectively.
2026-08-20 15:04:52 +01:00
806a32d306 Add permission settings management functionality
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit introduces a new feature for managing permission settings within the application. It includes the creation of a new `permissions.js` file for handling permission logic, a corresponding Mongoose schema for permission settings, and route handlers for CRUD operations on permission settings. Additionally, tests have been added to ensure the functionality of the new permission settings service. This enhancement improves the application's capability to manage user permissions effectively.
2026-08-20 12:28:04 +01:00
322a086040 Update PDF generation height calculation and corresponding test value
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit modifies the height calculation in the PDF generation function to increase the height by 2 pixels when the height option is set to 'auto'. Additionally, the related test has been updated to reflect this change, ensuring that the expected height value is now 122px instead of 121px. These adjustments improve the accuracy of the PDF rendering process.
2026-08-20 00:12:27 +01:00
0b94774443 Refactor Puppeteer launch options for improved configurability
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces a new module, `puppeteerLaunchOptions.js`, which centralizes the Puppeteer launch configuration. The `getPuppeteerLaunchOptions` function is added to provide customizable launch arguments, enhancing the flexibility of browser instantiation in both `mailworker.js` and `pdffactory.js`. This refactor improves code maintainability and allows for easier adjustments to Puppeteer settings in the future.
2026-08-19 22:19:05 +01:00
5cbcdacd3b Add function to tighten parentheses around EJS output and corresponding test
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces a new function, `tightenParenthesesAroundEjs`, which removes unnecessary spaces inside parentheses surrounding EJS output in formatted templates. Additionally, a test case is added to ensure that the formatting behaves as expected, enhancing the overall template content formatting functionality.
2026-08-19 20:15:09 +01:00
f467b1be33 Add formatting functionality for document templates
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces a new route for formatting document templates, utilizing the `formatTemplateContent` function to beautify HTML and JavaScript within templates. The `formatDocumentTemplateRouteHandler` is added to handle formatting requests, and the content is processed to maintain EJS blocks. Additionally, a new `templateformatter.js` file is created, containing the logic for formatting templates, along with corresponding tests to ensure functionality. This enhancement improves the usability and presentation of document templates in the application.
2026-08-19 20:02:39 +01:00
8af8c3364f Add minWidth and minHeight attributes to getNodeStyles function
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update enhances the getNodeStyles function in templatemanager.js by adding support for minWidth and minHeight attributes. This allows for more flexible styling options when defining node styles, improving the overall template management capabilities.
2026-08-19 19:36:41 +01:00
f9e0f2b75e Update PDF factory test to correct height value from 120px to 121px
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-19 19:03:29 +01:00
f3391fb8f3 Add createDocumentJobUserNotifier utility and integrate into document job handling
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
This update introduces the `createDocumentJobUserNotifier` function in `utils.js`, which creates a user notifier for document jobs if it doesn't already exist. The function is then integrated into the `newDocumentJobRouteHandler` in `documentjobs.js`, ensuring that user notifications are properly managed upon the creation of new document jobs. Additionally, tests have been updated to verify the correct invocation of the new utility function, enhancing the overall notification system for document jobs.
2026-08-19 18:58:28 +01:00
0fe1714e1a Add PDF generation and document template management features
This update introduces a comprehensive PDF generation system using Puppeteer, allowing for the rendering and downloading of document templates in various formats. Key features include the addition of preview and download routes for document templates, integration of EJS for template rendering, and utilities for converting PDFs to images. The new `TemplateManager` class manages template loading and rendering, while the `pdffactory.js` handles PDF generation. Additionally, several assets and styles for document templates have been added to enhance the visual presentation. This enhancement significantly improves the document management capabilities of the application.
2026-08-19 18:18:44 +01:00
5a4770820a Refactor audit logs route and service for improved readability and maintainability
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update enhances the `auditlogs.js` files by formatting the allowed filters for better clarity and refactoring the `listAuditLogsRouteHandler` function to improve code readability. Unused filter translations for Mongoose have been removed, streamlining the filtering logic. These changes contribute to cleaner code and easier future modifications.
2026-08-19 17:08:13 +01:00
aa4b173a7e Add sorting functionality to various inventory and management routes
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces a new utility function, `getSort`, to validate and apply sorting based on allowed sorters across multiple routes in the inventory and management modules. The function is integrated into route handlers for invoices, payments, tax records, filament stocks, order items, part stocks, product stocks, purchase orders, shipments, and various management entities. This enhancement improves the flexibility and consistency of sorting operations throughout the application.
2026-08-11 02:12:27 +01:00
3d4150c6cc Add mock for getModelByName in database tests to enhance test coverage
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-10 02:03:38 +01:00
234652f7b0 Enhance database utility functions for improved property value retrieval and reference handling
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
This update introduces several new functions in `database.js` to enhance the handling of Mongoose model references and property values. Key additions include `getObjectRefPathInfo`, `resolveMongooseModel`, and `fetchBasicObjectsByIds`, which improve the efficiency of fetching related objects based on property references. Additionally, the `getPropertyValues` function has been updated to support dynamic references and filtering, ensuring more robust data retrieval. Minor adjustments were also made to the `getJobPropertyValuesRouteHandler` to accommodate the new filtering capabilities.
2026-08-10 00:56:59 +01:00
4bd29e2010 Enhance utility functions in utils.js for improved reference model handling and filtering logic
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces new functions such as `getRefModelEntryFromPrefix`, `stripPrefixFromOperand`, and `getRefModelEntryForToken` to streamline the processing of reference models and tokens. Additionally, the `resolveRefLeaf` and `resolveRefCondition` functions have been refactored to utilize these enhancements, improving the overall efficiency and clarity of the filtering and reference resolution processes. Minor formatting adjustments were also made in orderitems.js for consistency.
2026-08-09 22:52:05 +01:00
069406e4d8 Remove unnecessary logging statements in utils.js to streamline the filtering and parsing functions. This change enhances code clarity and performance by eliminating debug logs that are no longer needed.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-09 22:28:05 +01:00
2a30b7f3f6 Enhance filtering and parsing logic in utils.js and update route handlers for async support
This update introduces several utility functions in `utils.js` to improve the handling of ObjectId paths, schema types, and filtering logic. Key additions include `isObjectIdPath`, `getBaseProperty`, and `getFilterFieldKind`, which enhance the flexibility of property handling. Additionally, all route handlers in the finance and inventory modules have been refactored to support asynchronous operations, ensuring better performance and responsiveness when processing requests.
2026-08-09 22:27:45 +01:00
d3adf00477 Add sortSidebarVisibility field to user settings schema
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces a new field, `sortSidebarVisibility`, to the user settings schema, allowing for more flexible management of sidebar visibility preferences. The field is defined as a mixed type with a default value of an empty object, enhancing the schema's capabilities for user customization.
2026-08-09 20:54:59 +01:00
fcdd76f891 Add additional boolean operand parsing in utils.js
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update expands the `parseBooleanOperand` function to handle more string representations of boolean values, including '1', '0', 'on', 'off', 'y', and 'n'. This enhancement improves the flexibility and robustness of boolean parsing in the application.
2026-08-09 20:29:27 +01:00
05d0cd539c Improve CORS error handling in index.js by logging allowed origins and the rejected origin. This change enhances debugging capabilities by providing clearer context when a request is denied due to CORS policy.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-02 01:27:20 +01:00
627de41cca Refactor CORS origin handling in index.js to support multiple origins using a Set for uniqueness. Log allowed origins during server initialization for better visibility and debugging. 2026-08-02 01:18:05 +01:00
87256257d7 Update CORS configuration in config.json and README.md to allow multiple origins. Refactor CORS handling in index.js to utilize new server.corsOrigins setting, enhancing API security and flexibility. 2026-08-02 01:01:50 +01:00
0dafdf1eda Update slicer.js and slicer.test.js to include createFileThumbnails function. This change integrates thumbnail creation into the slicer service and updates the test suite to mock the new function, enhancing testing coverage for file upload scenarios.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-01 18:30:26 +01:00
f69c88926c Refactor allowedFilters in inventory and management routes to improve consistency and readability. Cleaned up whitespace and ensured all filters are properly formatted for better query handling across purchase orders, shipments, and filament SKUs.
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
2026-08-01 18:25:59 +01:00
c0112d61fb Add thumbnail creation call in slicerUploadRouteHandler to generate file thumbnails upon upload. This enhancement improves the user experience by ensuring thumbnails are created for uploaded files.
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
2026-08-01 15:22:04 +01:00
6b80aee80a Refactor thumbnail creation logic in createFileThumbnails function to handle GCode file types and improve thumbnail source validation. Cleaned up whitespace and enhanced caching logic for better performance in database.js. 2026-08-01 15:10:59 +01:00
6c694d7d48 Add boolean field handling to filtering logic in utils.js
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces functions to manage boolean fields in the filtering process, including parsing boolean operands and building equality/comparison conditions. The `buildCondition`, `parseLeafCondition`, and `parseFilter` functions have been modified to accommodate boolean field checks, enhancing the overall filtering capabilities across the application.
2026-08-01 14:33:03 +01:00
c043ad7a86 Enhance allowedFilters across multiple routes to include 'createdAt', 'updatedAt', and '_reference' for improved filtering capabilities. This update applies to finance, inventory, management, and sales modules, ensuring consistency and better query handling.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-01 14:26:40 +01:00
c233be5d80 Enhance allowedFilters in printers.js and subjobs.js to include 'state' and '_reference' for improved filtering capabilities. Cleaned up whitespace for better code readability.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-01 13:31:27 +01:00
664a3a4884 Update allowedFilters in jobs.js to include '_id' and '_reference' for enhanced filtering capabilities in job queries. Cleaned up whitespace for improved code readability. 2026-08-01 13:28:50 +01:00
7606afcf11 Add getObjectNeighbors mock implementation in various test files for improved neighbor retrieval functionality across multiple modules.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
2026-08-01 13:26:23 +01:00
300478b62b Update package.json to specify pnpm as the package manager and add minimumReleaseAge to pnpm-workspace.yaml for improved workspace configuration.
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
2026-08-01 13:24:36 +01:00
74c0d8eb52 Refactor propertiesAllowedFilters across various routes to streamline filtering logic. Removed redundant allowedFilters definitions and replaced them with propertiesAllowedFilters for improved query handling in finance, inventory, and management modules.
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
2026-08-01 13:22:51 +01:00
1e807beacf Implement neighbors caching and retrieval for various entities in the inventory and finance modules. Introduced new route handlers for fetching neighbors in invoices, payments, tax records, filament stocks, order items, part stocks, product stocks, purchase orders, shipments, stock audits, stock events, stock locations, and stock transfers. Updated allowed filters for improved query capabilities across these routes. Enhanced database.js with caching logic for neighbors, including cache invalidation on object updates.
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
2026-08-01 13:20:01 +01:00
6a9cd2a2ea Refactor Redis integration to use ioredis instead of redis, enhancing performance and compatibility. Updated connection handling and command syntax for improved functionality. Added new dependencies for ioredis and updated mongoose version in package.json.
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
2026-08-01 12:42:08 +01:00
7a1b85bb19 Updated allowedFilters in printers.js to include '_id' and '_reference' for enhanced filtering capabilities in printer queries. Cleaned up unnecessary whitespace in the file. 2026-08-01 12:41:29 +01:00