Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,9 @@ MessagePack、MasterMemory、MagicOnion 等第三方依赖分别受其自身许
SiriusData 是非官方的社区互操作与基础设施项目。

*World Dai Star*、*World Dai Star: Yume no Stellarium*、ユメステ,以及相关名称、数据、资源和商标均归各自权利人所有。本仓库不是官方 SDK,与游戏开发商、发行商和运营方不存在官方隶属或授权关系。

## 内部导入 API 兼容性

共享官服导入契约包含 Dashboard 与 Server 使用的 `conflictPolicy`、`targetAccountId`、`source`、`hasReusableRawData`。缺少或未知策略按 `incremental` 处理,`new_account` 显式新建独立账号;目标未传为 0。这些新增 JSON 字段不改变 MasterMemory 表或游戏协议模型。

使用 .NET 10 SDK 执行 `dotnet test tests/Sirius.Protocol.Tests` 检查策略与 JSON 兼容性。
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,9 @@ Third-party dependencies such as MessagePack, MasterMemory, and MagicOnion remai
SiriusData is an unofficial community interoperability and infrastructure project.

*World Dai Star*, *World Dai Star: Yume no Stellarium*, ユメステ, and related names, data, assets, and trademarks belong to their respective rights holders. This repository is not an official SDK and is not affiliated with or endorsed by the game's developers, publishers, or operators.

## Internal import API compatibility

The shared official-import contracts include `conflictPolicy`, `targetAccountId`, `source`, and `hasReusableRawData` consumed by Dashboard and Server. Missing/unknown policy normalizes to `incremental`; `new_account` explicitly creates a separate account. Missing target remains zero. These additive JSON fields do not change MasterMemory tables or game wire models.

Run `dotnet test tests/Sirius.Protocol.Tests` for policy and JSON compatibility checks (.NET 10 SDK).
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
public string ErrorCode { get; set; } = string.Empty;
}

public static class OfficialUserImportConflictPolicies

Check failure on line 58 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The namespace 'Sirius.Protocol.InternalApi' already contains a definition for 'OfficialUserImportConflictPolicies'

Check failure on line 58 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The namespace 'Sirius.Protocol.InternalApi' already contains a definition for 'OfficialUserImportConflictPolicies'
{
public const string Incremental = "incremental";
public const string NewAccount = "new_account";

public static string Normalize(string? value) =>

Check failure on line 63 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

Type 'OfficialUserImportConflictPolicies' already defines a member called 'Normalize' with the same parameter types

Check failure on line 63 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

Type 'OfficialUserImportConflictPolicies' already defines a member called 'Normalize' with the same parameter types
string.Equals(value?.Trim(), NewAccount, StringComparison.OrdinalIgnoreCase) ? NewAccount : Incremental;
}

public sealed class PlatformCreateOfficialUserImportRequest
{
public string LinkageId { get; set; } = string.Empty;
Expand Down Expand Up @@ -113,6 +122,9 @@
public long CreatedAt { get; set; }
public long? StartedAt { get; set; }
public long? CompletedAt { get; set; }
public string ConflictPolicy { get; set; } = string.Empty;

Check failure on line 125 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The type 'PlatformOfficialUserImportStatusReply' already contains a definition for 'ConflictPolicy'

Check failure on line 125 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The type 'PlatformOfficialUserImportStatusReply' already contains a definition for 'ConflictPolicy'
public string Source { get; set; } = string.Empty;

Check failure on line 126 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The type 'PlatformOfficialUserImportStatusReply' already contains a definition for 'Source'

Check failure on line 126 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The type 'PlatformOfficialUserImportStatusReply' already contains a definition for 'Source'
public bool HasReusableRawData { get; set; }

Check failure on line 127 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The type 'PlatformOfficialUserImportStatusReply' already contains a definition for 'HasReusableRawData'

Check failure on line 127 in src/Sirius.Protocol/Models/InternalApi/PlatformAccountApiContracts.cs

View workflow job for this annotation

GitHub Actions / build

The type 'PlatformOfficialUserImportStatusReply' already contains a definition for 'HasReusableRawData'
}

public sealed class PlatformOfficialUserImportJobPage
Expand Down
44 changes: 44 additions & 0 deletions tests/Sirius.Protocol.Tests/OfficialImportContractTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Text.Json;
using Sirius.Protocol.InternalApi;
using Xunit;

namespace Sirius.Protocol.Tests;

public sealed class OfficialImportContractTests
{
private static readonly JsonSerializerOptions Json = new(JsonSerializerDefaults.Web);

[Theory]
[InlineData(null, "incremental")]
[InlineData("", "incremental")]
[InlineData("unknown", "incremental")]
[InlineData("incremental", "incremental")]
[InlineData("new_account", "new_account")]
[InlineData(" NEW_ACCOUNT ", "new_account")]
public void Policy_matches_the_server_documented_fallback(string? input, string expected) =>
Assert.Equal(expected, OfficialUserImportConflictPolicies.Normalize(input));

[Fact]
public void Legacy_request_keeps_unspecified_policy_and_no_target()
{
var request = JsonSerializer.Deserialize<PlatformCreateOfficialUserImportRequest>("""{"linkageId":"123","password":"fake"}""", Json)!;
Assert.Equal("", request.ConflictPolicy);
Assert.Equal(0, request.TargetAccountId);
Assert.Equal("incremental", OfficialUserImportConflictPolicies.Normalize(request.ConflictPolicy));
}

[Fact]
public void Incremental_request_and_reusable_job_status_round_trip()
{
var request = JsonSerializer.Deserialize<PlatformCreateOfficialUserImportRequest>("""{"linkageId":"123","password":"fake","conflictPolicy":"incremental","targetAccountId":81}""", Json)!;
Assert.Equal(81, request.TargetAccountId);
Assert.Equal("incremental", request.ConflictPolicy);
var status = new PlatformOfficialUserImportStatusReply { ConflictPolicy = "new_account", Source = "uploaded_file", HasReusableRawData = true };
var encoded = JsonSerializer.Serialize(status, Json);
Assert.Contains("\"hasReusableRawData\":true", encoded);
var decoded = JsonSerializer.Deserialize<PlatformOfficialUserImportStatusReply>(encoded, Json)!;
Assert.Equal(status.ConflictPolicy, decoded.ConflictPolicy);
Assert.Equal(status.Source, decoded.Source);
Assert.True(decoded.HasReusableRawData);
}
}
15 changes: 15 additions & 0 deletions tests/Sirius.Protocol.Tests/Sirius.Protocol.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" PrivateAssets="all" />
<ProjectReference Include="../../src/Sirius.Protocol/Sirius.Protocol.csproj" />
</ItemGroup>
</Project>
Loading