8000
Skip to content

Stock - #5

Merged
mohamadlounnas merged 5 commits into
mainfrom
stock
Jun 7, 2026
Merged

Stock#5
mohamadlounnas merged 5 commits into
mainfrom
stock

Conversation

@mohamadlounnas
Copy link
Copy Markdown
Collaborator
  • 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.

- 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.
Copilot AI review requested due to automatic review settings June 7, 2026 03:52
@mohamadlounnas
mohamadlounnas merged commit 0ca465a into main Jun 7, 2026
1 check passed
Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 under store.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.

Comment thread lib/core/app_config.dart
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 thread lib/feeef.dart
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);
}
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.

2 participants

0