feat: import #831
@ -86,6 +86,17 @@ export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<
 | 
				
			|||||||
| 
						
							
	
	
	
	
	
	
	
	 | 
				|||||||
    if (client.Upgrades) {
 | 
					    if (client.Upgrades) {
 | 
				
			||||||
        replaceArray<IUpgradeDatabase>(db.Upgrades, client.Upgrades.map(convertUpgrade));
 | 
					        replaceArray<IUpgradeDatabase>(db.Upgrades, client.Upgrades.map(convertUpgrade));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    for (const key of ["RawUpgrades", "MiscItems"] as const) {
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					        if (client[key]) {
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					            db[key].splice(0, db[key].length);
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					            client[key].forEach(x => {
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					                db[key].push({
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					                    ItemType: x.ItemType,
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					                    ItemCount: x.ItemCount
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					                });
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					            });
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					        }
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
 | 
					    }
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
    for (const key of ["OperatorLoadOuts", "AdultOperatorLoadOuts"] as const) {
 | 
					    for (const key of ["OperatorLoadOuts", "AdultOperatorLoadOuts"] as const) {
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 ⚠️ Potential issue Validate  In the  Apply this diff to add validation: 
 _:warning: Potential issue_
**Validate `ItemId.$oid` and `CrewMembers` in `convertCrewShip`**
In the `convertCrewShip` function, add validation for `ItemId.$oid` and ensure that `CrewMembers` are properly converted if present.
Apply this diff to add validation:
```diff
 const convertCrewShip = (client: ICrewShipClient): ICrewShipDatabase => {
     const { ItemId, ...rest } = client;
+    if (!ItemId || !ItemId.$oid || !Types.ObjectId.isValid(ItemId.$oid)) {
+        throw new Error('Invalid ItemId');
+    }
     return {
         ...rest,
         _id: new Types.ObjectId(ItemId.$oid),
         CrewMembers: client.CrewMembers ? convertCrewShipMembers(client.CrewMembers) : undefined
     };
 };
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
        if (client[key]) {
 | 
					        if (client[key]) {
 | 
				
			||||||
            replaceArray<IOperatorConfigDatabase>(db[key], client[key].map(convertOperatorConfig));
 | 
					            replaceArray<IOperatorConfigDatabase>(db[key], client[key].map(convertOperatorConfig));
 | 
				
			||||||
 | 
				
			|||||||
| 
						
							
	
	
	
	
	
	
	
	 🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		🛠️ Refactor suggestion Consider using transactions for atomic operations. The  Additionally, the function should validate the client object structure before processing. 
 _:hammer_and_wrench: Refactor suggestion_
**Consider using transactions for atomic operations.**
The `importInventory` function performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.
Additionally, the function should validate the client object structure before processing.
```diff
 export const importInventory = (db: TInventoryDatabaseDocument, client: Partial<IInventoryClient>): void => {
+    if (!db || !client) {
+        throw new Error('Invalid arguments: db and client are required');
+    }
+
+    // Validate required client properties
+    const requiredKeys = ['WeaponSkins', 'Upgrades'];
+    for (const key of requiredKeys) {
+        if (client[key] && !Array.isArray(client[key])) {
+            throw new Error(`Invalid ${key} format: expected array`);
+        }
+    }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit --> 
			
			
		 | 
				|||||||
🛠️ Refactor suggestion
Consider using transactions for atomic operations.
The
importInventoryfunction performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.Additionally, the function should validate the client object structure before processing.
🛠️ Refactor suggestion
Consider using transactions for atomic operations.
The
importInventoryfunction performs multiple updates that should be atomic. Consider wrapping the operations in a transaction.Additionally, the function should validate the client object structure before processing.