This commit introduces a new utility function, `isEmptyOperand`, to treat empty strings as null or missing values in filter parsing. It updates the `parseFilter` function and related utility functions to handle cases where empty values are provided, ensuring consistent behavior across different field types. Additionally, corresponding tests are added to verify the correct handling of empty values in various scenarios, enhancing the robustness of the filtering capabilities.
This commit updates the allowed filters and sorters in the filament, part, and product SKU management routes to include 'overrideCost' and 'overridePrice'. Additionally, it refactors the route handlers for improved readability and consistency. These changes aim to enhance data retrieval capabilities and maintain a consistent structure across the management routes.
This commit enhances the audit log service route tests by replacing direct calls to the `auditLogModel` with mocked database functions `listObjects` and `getObject`. This change improves the accuracy of the tests by ensuring they reflect the updated database interaction methods. The tests now verify that the correct parameters are passed to these functions, enhancing the overall reliability of the audit log service tests.
This commit introduces new functions for handling various date operations, including start and end of day, week, month, hour, and minute. It also adds relative date parsing capabilities, allowing for expressions like 'TODAY', '-7D..', and '-1M..-CM'. Additionally, the `parseFilter` function is updated to support these new date functionalities, with corresponding tests added to ensure accurate date filtering and validation. The changes improve the overall date management and querying capabilities within the application.
This commit modifies the `distributeUpdate` function in `utils.js` to include the `_id` in the published object, improving data integrity during distribution. Additionally, it updates the allowed filters in the `products` and `clients` routes to include 'tags', enhancing the filtering capabilities for better data categorization and retrieval.
This commit introduces a new `objectView` schema and corresponding routes for managing object views, enhancing the application's data handling capabilities. It includes CRUD operations for object views, allowing users to create, retrieve, update, and delete views based on specific object types. The implementation also updates existing services and routes to integrate the new functionality, ensuring proper authentication and data validation. Additionally, the commit modifies relevant utility functions and filters to accommodate the new object view model, improving overall application structure and maintainability.
This commit updates the allowed filters and sorters in multiple routes, including invoices, payment policies, inventory, management, and sales. It removes unnecessary filters, adds new ones for improved categorization, and ensures consistency in the data structure. These changes aim to streamline data retrieval and enhance the overall functionality of the application.
This commit introduces new functions to handle model prefix stripping and leading operator detection in the `utils.js` file. The `stripModelPrefixFromExpression` and `splitLeadingOperator` functions are added to enhance expression parsing. Additionally, existing functions are updated to utilize these new utilities, improving the handling of expressions in filters. Corresponding tests are added to ensure the correctness of the new functionality, particularly for equality and not-equal expressions.
This commit introduces a new `tax.js` module containing functions for tax rate resolution and amount calculation with tax. The `amountWithTax` and `resolveTaxRate` functions are integrated into various schemas, including `invoice`, `orderitem`, `shipment`, `courierservice`, `filament`, `part`, and `product`, enhancing their ability to compute amounts with applicable taxes. Additionally, corresponding tests are added to ensure the correctness of the new tax-related functionalities.
This commit updates the filament stock schema to set a default state of 'draft' and introduces a new route handler for posting filament stocks. The posting process includes validation to ensure stocks are in the draft state before transitioning to 'unconsumed', along with the creation of an initial stock event. Additionally, the service layer is updated to handle these changes, and tests are added to verify the new functionality.
This commit modifies the `stockTransfer` schema by removing the `toStockLocation` field and introducing `fromLocation` and `toLocation` fields, ensuring better clarity in stock transfer operations. The routes and services are updated to reflect these changes, including adjustments in the `executePostedLine` function to validate stock locations. Additionally, the allowed filters and sorters in the stock transfer routes are refined, enhancing the overall functionality and maintainability of the inventory management system.
This commit modifies the `stockAuditLevel` schema by making the `tags` field required, ensuring that all stock audit levels have associated tags for better categorization. Additionally, it enhances the readability of the `normalizeAuditLevelLine` function by adjusting the formatting of the item and itemSku assignments, improving overall code clarity.
This commit introduces a new `stockAuditLevel` schema and corresponding routes for managing stock audit levels, enhancing the inventory management capabilities. It includes CRUD operations for stock audit levels, allowing for the creation, retrieval, updating, and deletion of audit levels. The integration with existing stock audit functionalities is established, enabling the association of audit levels with stock audits. Additionally, utility functions for handling stock audit levels are implemented, improving the overall structure and maintainability of the inventory system.
This commit modifies the `deviceInfo` schema by removing unused fields such as `uptime`, `memory`, and `network`, streamlining the schema for better clarity and performance. The `deviceInfo` property in the `hostSchema` is updated to directly reference the `deviceInfoSchema`, enhancing code readability and maintainability.
This commit enhances the `invoice`, `taxrecord`, `orderitem`, `purchaseorder`, `shipment`, and `salesorder` schemas by introducing new rollup configurations for various states and values. It adds methods for aggregating statistics and historical data using `aggregateRollups` and `aggregateRollupsHistory`, improving data analysis capabilities across financial and inventory records. The new rollups include counts and sums for different transaction types and states, facilitating better reporting and insights into the application's financial and inventory management.
This commit introduces new utility functions to support number field validation and regex condition building in the `utils.js` file. It updates the `buildEquality`, `buildComparison`, and `parseLeafCondition` functions to accommodate number fields, ensuring proper handling of numeric values in filters. Additionally, a new test suite is added to validate the behavior of the `parseFilter` function with number fields, covering various scenarios including exact matches, wildcard handling, and non-numeric input. This enhancement improves the robustness of the filtering mechanism in the application.
This commit updates multiple routes across the management and inventory modules to enhance the handling of property value requests. The `/values` endpoints are modified to incorporate a filtering mechanism that allows for both a standard filter and an optional master filter, improving the flexibility and accuracy of data retrieval. Additionally, debug logging statements are added to assist in tracking the filter parameters during requests. This refactor aims to streamline the data fetching process and improve the overall user experience when interacting with the API.
This commit refactors the eBay order integration by introducing a new module for trading requests, encapsulating common functionalities such as XML parsing and request handling. The `orders.js` file is significantly expanded to include new parsing functions for shipping addresses, tracking details, and trading transactions, enhancing the overall order processing capabilities. Additionally, the `shippingServices.js` file is streamlined by removing deprecated constants and functions, replacing them with calls to the new trading request utilities. Comprehensive tests are added to ensure the correctness of the new functionalities and their integration with existing systems, improving the reliability of eBay marketplace operations.
This commit introduces the `syncWebhooks` function to streamline the process of synchronizing webhook configurations for marketplaces. It enhances the existing `ensureWebhookSubscriptions` function to utilize `syncWebhooks`, ensuring that webhook URLs and verification tokens are correctly set and updated. Additionally, a new module for managing webhook configurations is added, which includes utility functions for building webhook URLs and generating verification tokens. Tests are also included to validate the new functionality and its integration with existing systems, improving the overall reliability of webhook management.
This commit introduces new fields `syncHash` and `syncImageHash` to the `listing` and `listingVariant` schemas, enhancing the tracking of synchronization states. Additionally, a new module for sync fingerprinting is added, which includes functions to generate hashes for listings and their variants. The marketplace integration logic is updated to utilize these hashes for determining if updates are necessary, improving efficiency in syncing operations. Tests are also added to ensure the correctness of the new functionality and its integration with existing systems.
This commit introduces mock functions for the `permissions` module in the user API test file, enhancing test isolation and allowing for comprehensive testing of permission-related functionalities. The new mocks include methods for checking permissions, managing user permissions cache, and resolving permission settings, improving the overall test coverage and reliability of the user API tests.
This commit modifies the log level in the configuration file from "trace" to "debug" for improved logging clarity. It also introduces new routes for fulfillment, return, and payment policies in the index file, enhancing the marketplace integration capabilities. Additionally, the initialization process is updated to start the marketplace worker, ensuring that the application can handle marketplace operations effectively. Various schemas are updated to include new fields and relationships for policies, improving the overall functionality and flexibility of the marketplace management system.
This commit enhances the `aggregateRollupsHistory` function by restructuring the logic for filtering and processing audit logs, improving the accuracy of rollup snapshots over time. New utility functions are introduced to streamline the matching of objects against filters and to handle the existence of objects at specific timestamps. The overall flow is optimized to ensure that rollup calculations reflect the correct state of objects based on historical data, enhancing the reliability of data analysis and reporting.
This commit enhances the `client`, `listing`, and `marketplace` schemas by introducing rollup statistics and history tracking capabilities. New rollup configurations are added to count various states, such as 'active', 'inactive', and others specific to each schema. The `stats` and `history` static methods are implemented to aggregate data using the newly introduced `aggregateRollups` and `aggregateRollupsHistory` functions, improving data analysis and reporting for sales entities.
This commit adds new rollup configurations to the `filamentstock`, `partstock`, and `productstock` schemas to track the counts of different stock states: 'unconsumed', 'used', and 'consumed'. Additionally, the `stockevent` schema is updated to include rollup statistics for various stock types, improving the overall inventory management capabilities. Tests are also updated to mock new aggregate functions, ensuring comprehensive coverage of the new functionalities.
This commit introduces several utility functions in `utils.js` to improve ObjectId handling, including `isByte`, `isTwelveByteBuffer`, and `objectIdToString`. The `expandObjectIds` function is updated to better handle various ObjectId formats, including BSON ObjectIds and serialized 12-byte buffers. Additionally, comprehensive tests are added in `utils.expandObjectIds.test.js` to verify the correct behavior of these enhancements, ensuring robust handling of ObjectId conversions and expansions.
This commit updates the `syncModelsWithWS` function to include detailed statistics on schema synchronization, tracking the number of added, updated, and unchanged files. The `syncDirectory` function is modified to read file contents and determine if changes exist before copying, utilizing a new utility function, `fileHasChanges`, for comparison. Additionally, a helper function, `readFileIfExists`, is introduced to handle file reading more gracefully. These enhancements improve the efficiency and clarity of the schema synchronization process.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.