update libs

This commit is contained in:
Kirill Chikalin
2025-02-13 17:48:12 +03:00
parent e17e7c2786
commit 275dc598c7
816 changed files with 22479 additions and 10792 deletions

View File

@@ -0,0 +1,45 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
namespace AssetStoreTools.Api.Responses
{
/// <summary>
/// A structure used to return the success outcome and the result of Asset Store API calls
/// </summary>
internal class AssetStoreResponse
{
public bool Success { get; set; } = false;
public bool Cancelled { get; set; } = false;
public Exception Exception { get; set; }
public AssetStoreResponse() { }
public AssetStoreResponse(Exception e) : this()
{
Exception = e;
}
protected void ValidateAssetStoreResponse(string json)
{
var dict = JsonConvert.DeserializeObject<JObject>(json);
if (dict == null)
throw new Exception("Response is empty");
// Some json responses return an error field on error
if (dict.ContainsKey("error"))
{
// Server side error message
// Do not write to console since this is an error that
// is "expected" ie. can be handled by the gui.
throw new Exception(dict.GetValue("error").ToString());
}
// Some json responses return status+message fields instead of an error field. Go figure.
else if (dict.ContainsKey("status") && dict.GetValue("status").ToString() != "ok"
&& dict.ContainsKey("message"))
{
throw new Exception(dict.GetValue("message").ToString());
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ee338db031a0cfb459f7cac7f41a5d75
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/AssetStoreResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,38 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
namespace AssetStoreTools.Api.Responses
{
internal class AssetStoreToolsVersionResponse : AssetStoreResponse
{
public string Version { get; set; }
public AssetStoreToolsVersionResponse() : base() { }
public AssetStoreToolsVersionResponse(Exception e) : base(e) { }
public AssetStoreToolsVersionResponse(string json)
{
try
{
ValidateAssetStoreResponse(json);
ParseVersion(json);
Success = true;
}
catch (Exception e)
{
Success = false;
Exception = e;
}
}
private void ParseVersion(string json)
{
var dict = JsonConvert.DeserializeObject<JObject>(json);
if (!dict.ContainsKey("version"))
throw new Exception("Version was not found");
Version = dict.GetValue("version").ToString();
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 40558675926f913478a654350149209e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/AssetStoreToolsVersionResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,74 @@
using AssetStoreTools.Api.Models;
using Newtonsoft.Json;
using System;
using System.Net;
using System.Net.Http;
namespace AssetStoreTools.Api.Responses
{
internal class AuthenticationResponse : AssetStoreResponse
{
public User User { get; set; }
public AuthenticationResponse() : base() { }
public AuthenticationResponse(Exception e) : base(e) { }
public AuthenticationResponse(HttpStatusCode statusCode, HttpRequestException fallbackException)
{
string message;
switch (statusCode)
{
case HttpStatusCode.Unauthorized:
message = "Incorrect email and/or password. Please try again.";
break;
case HttpStatusCode.InternalServerError:
message = "Authentication request failed\nIf you were logging in with your Unity Cloud account, please make sure you are still logged in.\n" +
"This might also be caused by too many invalid login attempts - if that is the case, please try again later.";
break;
default:
Exception = fallbackException;
return;
}
Exception = new Exception(message);
}
public AuthenticationResponse(string json)
{
try
{
ValidateAssetStoreResponse(json);
var serializerSettings = new JsonSerializerSettings()
{
ContractResolver = User.AssetStoreUserResolver.Instance
};
User = JsonConvert.DeserializeObject<User>(json, serializerSettings);
ValidateLoginData();
ValidatePublisher();
Success = true;
}
catch (Exception e)
{
Success = false;
Exception = e;
}
}
private void ValidateLoginData()
{
if (string.IsNullOrEmpty(User.Id)
|| string.IsNullOrEmpty(User.SessionId)
|| string.IsNullOrEmpty(User.Name)
|| string.IsNullOrEmpty(User.Username))
throw new Exception("Could not parse the necessary publisher information from the response.");
}
private void ValidatePublisher()
{
if (!User.IsPublisher)
throw new Exception($"Your Unity ID {User.Name} is not currently connected to a publisher account. " +
$"Please create a publisher profile.");
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ec3a5cb59a7e78646b07f800d317874d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/AuthenticationResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,43 @@
using AssetStoreTools.Api.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace AssetStoreTools.Api.Responses
{
internal class CategoryDataResponse : AssetStoreResponse
{
public List<Category> Categories { get; set; }
public CategoryDataResponse() : base() { }
public CategoryDataResponse(Exception e) : base(e) { }
public CategoryDataResponse(string json)
{
try
{
var categoryArray = JsonConvert.DeserializeObject<JArray>(json);
Categories = new List<Category>();
var serializer = new JsonSerializer()
{
ContractResolver = new Category.AssetStoreCategoryResolver()
};
foreach (var categoryData in categoryArray)
{
var category = categoryData.ToObject<Category>(serializer);
Categories.Add(category);
}
Success = true;
}
catch (Exception e)
{
Success = false;
Exception = e;
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: e3789323453f1604286b436f77bdca97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/CategoryDataResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace AssetStoreTools.Api.Responses
{
internal class PackageThumbnailResponse : AssetStoreResponse
{
public Texture2D Thumbnail { get; set; }
public PackageThumbnailResponse() : base() { }
public PackageThumbnailResponse(Exception e) : base(e) { }
public PackageThumbnailResponse(byte[] textureBytes)
{
try
{
var tex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
var success = tex.LoadImage(textureBytes);
if (!success)
throw new Exception("Could not retrieve image from the provided texture bytes");
Thumbnail = tex;
Success = true;
}
catch (Exception e)
{
Success = false;
Exception = e;
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dacfba636b3757e408514b850d715e18
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/PackageThumbnailResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,44 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace AssetStoreTools.Api.Responses
{
internal class PackageUploadedUnityVersionDataResponse : AssetStoreResponse
{
public List<string> UnityVersions { get; set; }
public PackageUploadedUnityVersionDataResponse() : base() { }
public PackageUploadedUnityVersionDataResponse(Exception e) : base(e) { }
public PackageUploadedUnityVersionDataResponse(string json)
{
try
{
ValidateAssetStoreResponse(json);
ParseVersionData(json);
Success = true;
}
catch (Exception e)
{
Success = false;
Exception = e;
}
}
private void ParseVersionData(string json)
{
var data = JsonConvert.DeserializeObject<JObject>(json);
try
{
var content = data.GetValue("content").ToObject<JObject>();
UnityVersions = content.GetValue("unity_versions").ToObject<List<string>>();
}
catch
{
throw new Exception("Could not parse the unity versions array");
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2552f659a600e124aa952f3ba760ddf3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/PackageUploadedUnityVersionDataResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,59 @@
using AssetStoreTools.Api.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace AssetStoreTools.Api.Responses
{
internal class PackagesAdditionalDataResponse : AssetStoreResponse
{
public List<PackageAdditionalData> Packages { get; set; }
public PackagesAdditionalDataResponse() : base() { }
public PackagesAdditionalDataResponse(Exception e) : base(e) { }
public PackagesAdditionalDataResponse(string json)
{
try
{
ValidateAssetStoreResponse(json);
ParseExtraData(json);
Success = true;
}
catch (Exception e)
{
Success = false;
Exception = e;
}
}
private void ParseExtraData(string json)
{
var packageDict = JsonConvert.DeserializeObject<JObject>(json);
if (!packageDict.ContainsKey("packages"))
throw new Exception("Response did not not contain the list of packages");
Packages = new List<PackageAdditionalData>();
var serializer = new JsonSerializer()
{
ContractResolver = PackageAdditionalData.AssetStorePackageResolver.Instance
};
var packageArray = packageDict.GetValue("packages").ToObject<JArray>();
foreach (var packageData in packageArray)
{
var package = packageData.ToObject<PackageAdditionalData>(serializer);
// Some fields are based on the latest version in the json
var latestVersion = packageData["versions"].ToObject<JArray>().Last;
package.VersionId = latestVersion["id"].ToString();
package.Modified = latestVersion["modified"].ToString();
package.Size = latestVersion["size"].ToString();
Packages.Add(package);
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 88d58ad5e0eea6345b5c83f30ee8ebd5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/PackagesAdditionalDataResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,59 @@
using AssetStoreTools.Api.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace AssetStoreTools.Api.Responses
{
internal class PackagesDataResponse : AssetStoreResponse
{
public List<Package> Packages { get; set; }
public PackagesDataResponse() : base() { }
public PackagesDataResponse(Exception e) : base(e) { }
public PackagesDataResponse(string json)
{
try
{
ValidateAssetStoreResponse(json);
ParseMainData(json);
Success = true;
}
catch (Exception e)
{
Success = false;
Exception = e;
}
}
private void ParseMainData(string json)
{
var packageDict = JsonConvert.DeserializeObject<JObject>(json);
if (!packageDict.ContainsKey("packages"))
throw new Exception("Response did not not contain the list of packages");
Packages = new List<Package>();
var serializer = new JsonSerializer()
{
ContractResolver = Package.AssetStorePackageResolver.Instance
};
foreach (var packageToken in packageDict["packages"])
{
var property = (JProperty)packageToken;
var packageData = property.Value.ToObject<Package>(serializer);
// Package Id is the key of the package object
packageData.PackageId = property.Name;
// Package Icon Url is returned without the https: prefix
if (!string.IsNullOrEmpty(packageData.IconUrl))
packageData.IconUrl = $"https:{packageData.IconUrl}";
Packages.Add(packageData);
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 705ec748e689148479f54666993cd79d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/PackagesDataResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,12 @@
using AssetStoreTools.Api.Models;
using System;
namespace AssetStoreTools.Api.Responses
{
internal class RefreshedPackageDataResponse : AssetStoreResponse
{
public Package Package { get; set; }
public RefreshedPackageDataResponse() { }
public RefreshedPackageDataResponse(Exception e) : base(e) { }
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 20f710024d5ed514db02672f12ac361c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/RefreshedPackageDataResponse.cs
uploadId: 724584

View File

@@ -0,0 +1,28 @@
using System;
namespace AssetStoreTools.Api.Responses
{
internal class PackageUploadResponse : AssetStoreResponse
{
public UploadStatus Status { get; set; }
public PackageUploadResponse() : base() { }
public PackageUploadResponse(Exception e) : base(e) { }
public PackageUploadResponse(string json)
{
try
{
ValidateAssetStoreResponse(json);
Status = UploadStatus.Success;
Success = true;
}
catch (Exception e)
{
Success = false;
Status = UploadStatus.Fail;
Exception = e;
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8f1758cfa8119cf49a61b010a04352e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 115
packageName: Asset Store Publishing Tools
packageVersion: 12.0.1
assetPath: Packages/com.unity.asset-store-tools/Editor/Api/Responses/UploadResponse.cs
uploadId: 724584