Stock - #5
Merged
Merged
Conversation
- Introduced InventoryRepository for managing inventory objects, movemen 8000 ts, reservations, aliases, and warehouses. - Added models for InventoryObject, InventoryMovement, InventoryWarehouse, InventoryReservation, and InventoryAlias to match backend API structures. - Implemented methods for listing, creating, and deleting inventory items and related entities. - Enhanced Store model with projectId and inventory integration capabilities.
…ialization - Updated InventoryWarehouseUpdate to include fields for name, code, and namespacePrefix, improving data handling. - Modified updateFromJson method to parse these fields from JSON input. - Enhanced toJson method to serialize the new fields, ensuring compatibility with backend API structures.
…tories - Added batch operation methods to ModelRepository for delete, update, and create actions, allowing for efficient handling of multiple records. - Introduced InventoryBatchUpdateObjectsRequest for batch updates specific to inventory objects, enhancing inventory management capabilities. - Updated InventoryReservation model to include lines for detailed reservation tracking, improving data structure alignment with backend API. - Integrated batch models into various repositories to streamline batch processing across the application.
…guration - Introduced `IntegrationCatalogItemConfig` and `IntegrationsBillingRulesConfig` for managing integration pricing and billing rules. - Enhanced `AppConfig` to include optional integrations configuration, allowing for dynamic integration management. - Added methods in `StoreRepository` for subscribing to and canceling integration subscriptions, facilitating user management of paid integrations. - Updated `StoreSubscription` model to track integration subscriptions, including billing status and lifecycle management. - Enhanced JSON serialization for new integration-related models, ensuring compatibility with backend API structures.
…se stock - Introduced `StoreInventoryIntegration` model for managing inventory status and metadata. - Updated `StoreIntegrations` interface to include the new inventory integration. - Enhanced JSON serialization for the `StoreInventoryIntegration` model to ensure compatibility with backend API structures. - Added inventory field to the `StoreIntegrations` mixin for better integration management.
There was a problem hiding this comment.
Pull request overview
This PR expands the SDK’s “stock/inventory” surface area by introducing inventory domain repositories/models, wiring store-level inventory integration flags/config into existing store models, and adding per-integration subscription billing support (including a new transfer type and store subscription per-integration billing metadata).
Changes:
- Add inventory module support: repositories (
InventoryRepository+ sub-repos), batch RPC request/response types, and inventory domain models. - Extend store models to include
projectId, inventory integration toggles/config hooks, and per-integration billing entries understore.subscription.integrations. - Add per-integration subscription endpoints (repository/API client) and update enums/serialization to support new billing and transfer types.
Reviewed changes
Copilot reviewed 18 out of 24 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/transfers/models/transfer.dart | Adds new TransferType.integrationSubscription enum value. |
| lib/transfers/models/transfer.g.dart | Updates generated enum map for the new transfer type. |
| lib/stores/store_repository.dart | Adds integration subscription subscribe/cancel endpoints. |
| lib/stores/models/store.dart | Adds projectId, per-integration billing models, inventory config hooks, and subscription type ultra. |
| lib/stores/models/store.freezed.dart | Generated updates for new Store fields/types (projectId, billing/inventory integration types). |
| lib/stores/models/store.g.dart | Generated JSON updates for projectId, billing/inventory integration serialization. |
| lib/orders/order_repository.dart | Adds returnOrder API call to return items to inventory. |
| lib/mixins/repository_batch_mixins.dart | Introduces mixins for batch delete/update/create on repositories. |
| lib/inventory/models/inventory_models.dart | Adds inventory domain models and batch request helpers. |
| lib/inventory/inventory_repository.dart | Adds inventory API entrypoint + typed sub-repositories. |
| lib/interfaces/store.dart | Extends StoreEntity with projectId. |
| lib/interfaces/embadded/store_integrations.dart | Adds StoreInventoryIntegration model and inventory field on StoreIntegrations. |
| lib/interfaces/embadded/store_integrations.freezed.dart | Generated updates for StoreIntegrations.inventory and StoreInventoryIntegration. |
| lib/interfaces/embadded/store_integrations.g.dart | Generated JSON for StoreIntegrations.inventory / StoreInventoryIntegration. |
| lib/interfaces/embadded/member_scope.dart | Adds new scopes inventory / inventory.read. |
| lib/integrations/integration_subscription_api.dart | Adds standalone API client for per-integration subscription billing. |
| lib/feeef.dart | Exposes new inventory/batch/subscription API surfaces via barrel exports. |
| lib/feeef_client.dart | Wires Feeef.inventory onto the main SDK client. |
| lib/core/resource_repository.dart | Updates docs to describe opting into batch operations via mixins. |
| lib/core/model_repository.dart | Adds batch operation APIs (postBatch, postBatchAction, and default unimplemented batch CRUD). |
| lib/core/list_response.dart | Makes list parsing more tolerant to non-list data shapes. |
| lib/core/app_config.dart | Adds integrations billing/catalog config parsing. |
Files not reviewed (4)
- lib/interfaces/embadded/store_integrations.freezed.dart: Language not supported
- lib/interfaces/embadded/store_integrations.g.dart: Language not supported
- lib/stores/models/store.g.dart: Language not supported
- lib/transfers/models/transfer.g.dart: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (models != null) 'models': models!.toJson(), | ||
| 'languages': languages.map((e) => e.toJson()).toList(), | ||
| if (extra != null) 'extra': extra!.toJson(), | ||
| if (integrations != null) 'integrations': {'billing': {}, 'items': {}}, |
Comment on lines
+24
to
+35
| } else if (rawData is Map) { | ||
| // In case the API wraps data strangely or returns a single object under data | ||
| // Sometimes an array is serialized as {"0": {...}, "1": {...}} | ||
| if (rawData.isNotEmpty && | ||
| rawData.keys.every((k) => int.tryParse(k.toString()) != null)) { | ||
| listData = rawData.values.toList(); | ||
| } else { | ||
| // If it's a map but not with integer keys, it's likely an error object | ||
| // or a different response type. Returning an empty list is safer than | ||
| // wrapping the map and crashing the item parsers. | ||
| listData = []; | ||
| } |
Comment on lines
394
to
399
| @Default([]) List<StoreCountryConfig> countries, | ||
| String? selectedCountry, | ||
| @Default([]) List<CustomStatusMapping> customStatusMappings, | ||
| @Default(false) bool customStatusEnabled, | ||
| InventoryIntegration? inventory_integration, | ||
| }) = _StoreConfigs; |
Comment on lines
+405
to
+411
| @freezed | ||
| abstract class InventoryIntegration with _$InventoryIntegration { | ||
| const factory InventoryIntegration({ | ||
| @Default([]) List<OrderStatus> reserve_on, | ||
| @Default([]) List<OrderStatus> unreserve_on, | ||
| @Default([]) List<OrderStatus> consume_on, | ||
| }) = _InventoryIntegration; |
Comment on lines
+278
to
+288
| /// Subscribe to a paid integration (wallet charge). | ||
| Future<Map<String, dynamic>> subscribeIntegration({ | ||
| required String storeId, | ||
| required String integrationId, | ||
| }) async { | ||
| final res = await client.post( | ||
| '/$table/$storeId/integrations/subscription/subscribe', | ||
| data: {'integrationId': integrationId}, | ||
| ); | ||
| return Map<String, dynamic>.from(res.data as Map); | ||
| } |
Comment on lines
+290
to
+300
| /// Cancel auto-renew for a paid integration. | ||
| Future<Map<String, dynamic>> cancelIntegrationSubscription({ | ||
| required String storeId, | ||
| required String integrationId, | ||
| }) async { | ||
| final res = await client.post( | ||
| '/$table/$storeId/integrations/subscription/cancel', | ||
| data: {'integrationId': integrationId}, | ||
| ); | ||
| return Map<String, dynamic>.from(res.data as Map); | ||
| } |
Comment on lines
+24
to
+27
| export 'core/batch_models.dart'; | ||
| export 'mixins/repository_batch_mixins.dart'; | ||
| export 'inventory/inventory_repository.dart'; | ||
| export 'inventory/models/inventory_models.dart'; |
Comment on lines
+81
to
+83
| receivedAt: json['receivedAt'] != null | ||
| ? DateTime.parse(json['receivedAt'] as String) | ||
| : DateTime.now(), |
Comment on lines
+540
to
+545
| final data = response.data; | ||
| if (data is List && data.isNotEmpty) { | ||
| return modelFromJson(data.first); | ||
| } | ||
| return modelFromJson(data); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
StoreInventoryIntegrationmodel for managing inventory status and metadata.StoreIntegrationsinterface to include the new inventory integration.StoreInventoryIntegrationmodel to ensure compatibility with backend API structures.StoreIntegrationsmixin for better integration management.