账户系统完善,使用uuid+多identity记录

This commit is contained in:
2026-04-20 03:28:03 +00:00
parent d06b3ad38c
commit d2a059d57a
26 changed files with 832 additions and 431 deletions

View File

@@ -509,7 +509,7 @@ export function PlatformHomeView({
<div className="flex gap-3 overflow-x-auto pb-1 scrollbar-hide">
{featuredShelf.map((entry: CustomWorldGalleryCard) => (
<WorldCard
key={`${entry.ownerUserId}:${entry.profileId}:featured`}
key={`${entry.ownerAccountId}:${entry.profileId}:featured`}
entry={entry}
badge="推荐"
metaLabel={describePlatformThemeLabel(entry.themeMode)}
@@ -530,7 +530,7 @@ export function PlatformHomeView({
<div className="flex gap-3 overflow-x-auto pb-1 scrollbar-hide">
{latestEntries.map((entry: CustomWorldGalleryCard) => (
<WorldCard
key={`${entry.ownerUserId}:${entry.profileId}:latest`}
key={`${entry.ownerAccountId}:${entry.profileId}:latest`}
entry={entry}
badge={formatPlatformWorldTime(entry.publishedAt)}
metaLabel={entry.authorDisplayName}
@@ -580,7 +580,7 @@ export function PlatformHomeView({
{myEntries.map(
(entry: CustomWorldLibraryEntry<CustomWorldProfile>) => (
<WorldCard
key={`${entry.ownerUserId}:${entry.profileId}:mine`}
key={`${entry.ownerAccountId}:${entry.profileId}:mine`}
entry={entry}
badge={entry.visibility === 'published' ? '已发布' : '草稿'}
metaLabel={
@@ -820,11 +820,11 @@ export function PlatformHomeView({
<div className="flex gap-3 overflow-x-auto pb-1 scrollbar-hide">
{historyEntries.map((entry) => (
<button
key={`${entry.ownerUserId}:${entry.profileId}:history`}
key={`${entry.ownerAccountId}:${entry.profileId}:history`}
type="button"
onClick={() =>
onOpenGalleryDetail({
ownerUserId: entry.ownerUserId,
ownerAccountId: entry.ownerAccountId,
profileId: entry.profileId,
visibility: 'published',
publishedAt: entry.visitedAt,

View File

@@ -233,7 +233,7 @@ beforeEach(() => {
vi.mocked(deleteCustomWorldProfile).mockResolvedValue([]);
vi.mocked(upsertCustomWorldProfile).mockResolvedValue({
entry: {
ownerUserId: 'user-1',
ownerAccountId: 'user-1',
profileId: 'agent-draft-custom-world-agent-session-1',
profile: {
id: 'agent-draft-custom-world-agent-session-1',
@@ -477,7 +477,7 @@ test('profile tab loads server browse history and can clear it after confirmatio
vi.mocked(listProfileBrowseHistory).mockResolvedValue([
{
ownerUserId: 'author-1',
ownerAccountId: 'author-1',
profileId: 'world-1',
worldName: '潮雾列岛',
subtitle: '旧灯塔与失控航路',
@@ -514,7 +514,7 @@ test('owned world detail can delete a work and return to the create tab list', a
vi.mocked(listCustomWorldLibrary).mockResolvedValue([
{
ownerUserId: 'user-1',
ownerAccountId: 'user-1',
profileId: 'world-delete-1',
profile: {
id: 'world-delete-1',

View File

@@ -326,7 +326,7 @@ export function PreGameSelectionFlow({
const nextOwnedEntry = savedCustomWorldEntries.find(
(entry) =>
entry.ownerUserId === selectedDetailEntry.ownerUserId &&
entry.ownerAccountId === selectedDetailEntry.ownerAccountId &&
entry.profileId === selectedDetailEntry.profileId,
);
if (nextOwnedEntry && nextOwnedEntry !== selectedDetailEntry) {
@@ -934,7 +934,7 @@ export function PreGameSelectionFlow({
) => {
if (entry.visibility === 'published') {
void appendBrowseHistoryEntry({
ownerUserId: entry.ownerUserId,
ownerAccountId: entry.ownerAccountId,
profileId: entry.profileId,
worldName: entry.worldName,
subtitle: entry.subtitle,
@@ -955,12 +955,12 @@ export function PreGameSelectionFlow({
setDetailError(null);
try {
const detailEntry = await getCustomWorldGalleryDetail(
entry.ownerUserId,
entry.ownerAccountId,
entry.profileId,
);
setSelectedDetailEntry(detailEntry);
void appendBrowseHistoryEntry({
ownerUserId: detailEntry.ownerUserId,
ownerAccountId: detailEntry.ownerAccountId,
profileId: detailEntry.profileId,
worldName: detailEntry.worldName,
subtitle: detailEntry.subtitle,
@@ -1186,7 +1186,7 @@ export function PreGameSelectionFlow({
selectedDetailEntry &&
savedCustomWorldEntries.some(
(entry) =>
entry.ownerUserId === selectedDetailEntry.ownerUserId &&
entry.ownerAccountId === selectedDetailEntry.ownerAccountId &&
entry.profileId === selectedDetailEntry.profileId,
),
);

View File

@@ -47,7 +47,7 @@ function createMemoryStorage() {
function createAuthStateRow(overrides: Record<string, unknown> = {}) {
return {
userId: 'user_1',
accountId: 'acct_1',
identity: {
isEqual: vi.fn(() => true),
toHexString: vi.fn(() => 'abc'),
@@ -125,7 +125,7 @@ function createConnection(options: {
my_auth_audit_logs: {
iter: vi.fn(() => []),
},
my_user_sessions: {
my_account_sessions: {
iter: vi.fn(() =>
options.sessionRows ?? [
{

View File

@@ -354,7 +354,7 @@ export async function getCurrentAuthUser(): Promise<AuthSessionSnapshot> {
export async function getAuthSessions() {
const connection = await ensureSpacetimeConnection();
const currentSessionId = getCurrentSpacetimeSessionId(connection);
return Array.from(connection.db.my_user_sessions.iter()).map((row) =>
return Array.from(connection.db.my_account_sessions.iter()).map((row) =>
mapAuthSession(row, { currentSessionId }),
);
}

View File

@@ -41,17 +41,17 @@ function normalizeHistoryEntry(
return null;
}
const ownerUserId = readString(value.ownerUserId);
const ownerAccountId = readString(value.ownerAccountId);
const profileId = readString(value.profileId);
const worldName = readString(value.worldName);
const visitedAt = readString(value.visitedAt);
if (!ownerUserId || !profileId || !worldName || !visitedAt) {
if (!ownerAccountId || !profileId || !worldName || !visitedAt) {
return null;
}
return {
ownerUserId,
ownerAccountId,
profileId,
worldName,
subtitle: readString(value.subtitle),
@@ -109,7 +109,7 @@ export function writePlatformBrowseHistory(
}
const nextEntry: PlatformBrowseHistoryEntry = {
ownerUserId: entry.ownerUserId.trim(),
ownerAccountId: entry.ownerAccountId.trim(),
profileId: entry.profileId.trim(),
worldName: entry.worldName.trim(),
subtitle: entry.subtitle?.trim() || '',
@@ -122,7 +122,7 @@ export function writePlatformBrowseHistory(
const deduped = readPlatformBrowseHistory(user).filter(
(current) =>
!(
current.ownerUserId === nextEntry.ownerUserId &&
current.ownerAccountId === nextEntry.ownerAccountId &&
current.profileId === nextEntry.profileId
),
);

View File

@@ -36,7 +36,7 @@ function createConnection() {
my_browse_history: {
iter: vi.fn(() => [
{
ownerUserId: 'author-1',
ownerAccountId: 'author-1',
profileId: 'profile-1',
worldName: '测试世界',
subtitle: '测试副标题',
@@ -82,7 +82,7 @@ describe('storageService with SpacetimeDB', () => {
spacetimeMocks.ensureSpacetimeConnection.mockResolvedValue(connection);
await upsertProfileBrowseHistory({
ownerUserId: 'user-1',
ownerAccountId: 'user-1',
profileId: 'profile-1',
worldName: '测试世界',
subtitle: '测试副标题',
@@ -96,7 +96,7 @@ describe('storageService with SpacetimeDB', () => {
expect.objectContaining({
entries: [
expect.objectContaining({
ownerUserId: 'user-1',
ownerAccountId: 'user-1',
profileId: 'profile-1',
worldName: '测试世界',
}),
@@ -111,7 +111,7 @@ describe('storageService with SpacetimeDB', () => {
await syncProfileBrowseHistory([
{
ownerUserId: 'user-1',
ownerAccountId: 'user-1',
profileId: 'profile-1',
worldName: '测试世界',
subtitle: '测试副标题',

View File

@@ -240,7 +240,7 @@ export async function upsertCustomWorldProfile(
const entry =
entries.find((item) => item.profileId === profile.id) ??
mapCustomWorldLibraryEntry({
ownerUserId: '',
ownerAccountId: '',
profileId: profile.id,
payloadJson: JSON.stringify(profile),
visibility: { tag: 'Draft' },
@@ -343,7 +343,7 @@ export async function listCustomWorldGallery(
}
export async function getCustomWorldGalleryDetail(
ownerUserId: string,
ownerAccountId: string,
profileId: string,
_options: RuntimeRequestOptions = {},
) {
@@ -352,7 +352,7 @@ export async function getCustomWorldGalleryDetail(
.map(mapPublishedProfile)
.find(
(row) =>
row.ownerUserId === ownerUserId && row.profileId === profileId,
row.ownerAccountId === ownerAccountId && row.profileId === profileId,
);
if (!entry) {
@@ -380,7 +380,7 @@ export async function upsertProfileBrowseHistory(
meta: buildRequestMeta(),
entries: [
{
ownerUserId: entry.ownerUserId,
ownerAccountId: entry.ownerAccountId,
profileId: entry.profileId,
worldName: entry.worldName,
subtitle: entry.subtitle,
@@ -408,7 +408,7 @@ export async function syncProfileBrowseHistory(
const result = await connection.procedures.upsertPlatformBrowseHistory({
meta: buildRequestMeta(),
entries: entries.map((entry) => ({
ownerUserId: entry.ownerUserId,
ownerAccountId: entry.ownerAccountId,
profileId: entry.profileId,
worldName: entry.worldName,
subtitle: entry.subtitle,

View File

@@ -55,6 +55,7 @@ import * as VerifySmsCodeProcedure from "./verify_sms_code_procedure";
// Import all table schema definitions
import ClientAppConfigRow from "./client_app_config_table";
import KickEventRow from "./kick_event_table";
import MyAccountSessionsRow from "./my_account_sessions_table";
import MyAuthAuditLogsRow from "./my_auth_audit_logs_table";
import MyAuthRiskBlocksRow from "./my_auth_risk_blocks_table";
import MyAuthStateRow from "./my_auth_state_table";
@@ -66,7 +67,6 @@ import MyProfilePlayedWorldsRow from "./my_profile_played_worlds_table";
import MyProfileWalletLedgerRow from "./my_profile_wallet_ledger_table";
import MyRuntimeSettingsRow from "./my_runtime_settings_table";
import MySnapshotRow from "./my_snapshot_table";
import MyUserSessionsRow from "./my_user_sessions_table";
import PublishedCustomWorldGalleryRow from "./published_custom_world_gallery_table";
import PublishedCustomWorldProfilesRow from "./published_custom_world_profiles_table";
import SessionRevocationEventRow from "./session_revocation_event_table";
@@ -107,6 +107,13 @@ const tablesSchema = __schema({
constraints: [
],
}, ClientAppConfigRow),
my_account_sessions: __table({
name: 'my_account_sessions',
indexes: [
],
constraints: [
],
}, MyAccountSessionsRow),
my_auth_audit_logs: __table({
name: 'my_auth_audit_logs',
indexes: [
@@ -184,13 +191,6 @@ const tablesSchema = __schema({
constraints: [
],
}, MySnapshotRow),
my_user_sessions: __table({
name: 'my_user_sessions',
indexes: [
],
constraints: [
],
}, MyUserSessionsRow),
published_custom_world_gallery: __table({
name: 'published_custom_world_gallery',
indexes: [

View File

@@ -16,7 +16,7 @@ import {
export default __t.row({
userId: __t.string().name("user_id"),
accountId: __t.string().name("account_id"),
identity: __t.identity(),
displayName: __t.string().name("display_name"),
phoneNumberMasked: __t.option(__t.string()).name("phone_number_masked"),

View File

@@ -15,7 +15,7 @@ import {
export default __t.row({
ownerUserId: __t.string().name("owner_user_id"),
ownerAccountId: __t.string().name("owner_account_id"),
profileId: __t.string().name("profile_id"),
worldName: __t.string().name("world_name"),
subtitle: __t.string(),

View File

@@ -10,13 +10,13 @@ import {
type Infer as __Infer,
} from "spacetimedb";
import {
CustomWorldPublicationStatus,
CustomWorldThemeMode,
CustomWorldPublicationStatus,
} from "./types";
export default __t.row({
ownerUserId: __t.string().name("owner_user_id"),
ownerAccountId: __t.string().name("owner_account_id"),
profileId: __t.string().name("profile_id"),
payloadJson: __t.string().name("payload_json"),
get visibility() {

View File

@@ -12,7 +12,7 @@ import {
export default __t.row({
worldKey: __t.string().name("world_key"),
ownerUserId: __t.option(__t.string()).name("owner_user_id"),
ownerAccountId: __t.option(__t.string()).name("owner_account_id"),
profileId: __t.option(__t.string()).name("profile_id"),
worldType: __t.option(__t.string()).name("world_type"),
worldTitle: __t.string().name("world_title"),

View File

@@ -10,13 +10,13 @@ import {
type Infer as __Infer,
} from "spacetimedb";
import {
CustomWorldPublicationStatus,
CustomWorldThemeMode,
CustomWorldPublicationStatus,
} from "./types";
export default __t.row({
ownerUserId: __t.string().name("owner_user_id"),
ownerAccountId: __t.string().name("owner_account_id"),
profileId: __t.string().name("profile_id"),
get visibility() {
return CustomWorldPublicationStatus;

View File

@@ -10,13 +10,13 @@ import {
type Infer as __Infer,
} from "spacetimedb";
import {
CustomWorldPublicationStatus,
CustomWorldThemeMode,
CustomWorldPublicationStatus,
} from "./types";
export default __t.row({
ownerUserId: __t.string().name("owner_user_id"),
ownerAccountId: __t.string().name("owner_account_id"),
profileId: __t.string().name("profile_id"),
payloadJson: __t.string().name("payload_json"),
get visibility() {

View File

@@ -10,6 +10,75 @@ import {
type Infer as __Infer,
} from "spacetimedb";
export const Account = __t.object("Account", {
id: __t.string(),
identity: __t.identity(),
username: __t.option(__t.string()),
passwordHash: __t.option(__t.string()),
tokenVersion: __t.u32(),
displayName: __t.string(),
get loginProvider() {
return LoginProvider;
},
get accountStatus() {
return AccountStatus;
},
phoneNumber: __t.option(__t.string()),
phoneVerifiedAtMs: __t.option(__t.u64()),
createdAtMs: __t.u64(),
updatedAtMs: __t.u64(),
});
export type Account = __Infer<typeof Account>;
export const AccountBrowseHistory = __t.object("AccountBrowseHistory", {
id: __t.string(),
accountId: __t.string(),
ownerAccountId: __t.string(),
profileId: __t.string(),
worldName: __t.string(),
subtitle: __t.string(),
summaryText: __t.string(),
coverImageSrc: __t.option(__t.string()),
get themeMode() {
return CustomWorldThemeMode;
},
authorDisplayName: __t.string(),
visitedAtMs: __t.u64(),
});
export type AccountBrowseHistory = __Infer<typeof AccountBrowseHistory>;
export const AccountIdentity = __t.object("AccountIdentity", {
id: __t.string(),
accountId: __t.string(),
get provider() {
return AuthIdentityProvider;
},
providerUid: __t.string(),
providerUnionId: __t.option(__t.string()),
displayName: __t.option(__t.string()),
avatarUrl: __t.option(__t.string()),
isVerified: __t.bool(),
metaJson: __t.option(__t.string()),
createdAtMs: __t.u64(),
updatedAtMs: __t.u64(),
});
export type AccountIdentity = __Infer<typeof AccountIdentity>;
export const AccountSession = __t.object("AccountSession", {
id: __t.string(),
accountId: __t.string(),
refreshTokenHash: __t.string(),
clientType: __t.string(),
userAgent: __t.option(__t.string()),
ip: __t.option(__t.string()),
expiresAtMs: __t.option(__t.u64()),
revokedAtMs: __t.option(__t.u64()),
createdAtMs: __t.u64(),
updatedAtMs: __t.u64(),
lastSeenAtMs: __t.u64(),
});
export type AccountSession = __Infer<typeof AccountSession>;
// The tagged union or sum type for the algebraic type `AccountStatus`.
export const AccountStatus = __t.enum("AccountStatus", {
Active: __t.unit(),
@@ -73,7 +142,7 @@ export type AppConfig = __Infer<typeof AppConfig>;
export const AuthAuditLog = __t.object("AuthAuditLog", {
id: __t.u64(),
userId: __t.string(),
accountId: __t.string(),
eventType: __t.string(),
detail: __t.string(),
ip: __t.option(__t.string()),
@@ -93,23 +162,6 @@ export const AuthAuditLogView = __t.object("AuthAuditLogView", {
});
export type AuthAuditLogView = __Infer<typeof AuthAuditLogView>;
export const AuthIdentity = __t.object("AuthIdentity", {
id: __t.string(),
userId: __t.string(),
get provider() {
return AuthIdentityProvider;
},
providerUid: __t.string(),
providerUnionId: __t.option(__t.string()),
displayName: __t.option(__t.string()),
avatarUrl: __t.option(__t.string()),
isVerified: __t.bool(),
metaJson: __t.option(__t.string()),
createdAtMs: __t.u64(),
updatedAtMs: __t.u64(),
});
export type AuthIdentity = __Infer<typeof AuthIdentity>;
// The tagged union or sum type for the algebraic type `AuthIdentityProvider`.
export const AuthIdentityProvider = __t.enum("AuthIdentityProvider", {
Guest: __t.unit(),
@@ -156,7 +208,7 @@ export const AuthSessionView = __t.object("AuthSessionView", {
export type AuthSessionView = __Infer<typeof AuthSessionView>;
export const AuthStateView = __t.object("AuthStateView", {
userId: __t.string(),
accountId: __t.string(),
identity: __t.identity(),
displayName: __t.string(),
phoneNumberMasked: __t.option(__t.string()),
@@ -187,7 +239,7 @@ export const ClientAppConfigView = __t.object("ClientAppConfigView", {
export type ClientAppConfigView = __Infer<typeof ClientAppConfigView>;
export const CustomWorldGalleryCardView = __t.object("CustomWorldGalleryCardView", {
ownerUserId: __t.string(),
ownerAccountId: __t.string(),
profileId: __t.string(),
get visibility() {
return CustomWorldPublicationStatus;
@@ -209,7 +261,7 @@ export type CustomWorldGalleryCardView = __Infer<typeof CustomWorldGalleryCardVi
export const CustomWorldProfile = __t.object("CustomWorldProfile", {
id: __t.string(),
userId: __t.string(),
accountId: __t.string(),
profileId: __t.string(),
get visibility() {
return CustomWorldPublicationStatus;
@@ -232,7 +284,7 @@ export const CustomWorldProfile = __t.object("CustomWorldProfile", {
export type CustomWorldProfile = __Infer<typeof CustomWorldProfile>;
export const CustomWorldProfileView = __t.object("CustomWorldProfileView", {
ownerUserId: __t.string(),
ownerAccountId: __t.string(),
profileId: __t.string(),
payloadJson: __t.string(),
get visibility() {
@@ -262,7 +314,7 @@ export type CustomWorldPublicationStatus = __Infer<typeof CustomWorldPublication
export const CustomWorldSession = __t.object("CustomWorldSession", {
id: __t.string(),
userId: __t.string(),
accountId: __t.string(),
sessionId: __t.string(),
payloadJson: __t.string(),
createdAtMs: __t.u64(),
@@ -315,7 +367,7 @@ export const MutationResult = __t.object("MutationResult", {
export type MutationResult = __Infer<typeof MutationResult>;
export const PlatformBrowseHistoryView = __t.object("PlatformBrowseHistoryView", {
ownerUserId: __t.string(),
ownerAccountId: __t.string(),
profileId: __t.string(),
worldName: __t.string(),
subtitle: __t.string(),
@@ -330,7 +382,7 @@ export const PlatformBrowseHistoryView = __t.object("PlatformBrowseHistoryView",
export type PlatformBrowseHistoryView = __Infer<typeof PlatformBrowseHistoryView>;
export const PlatformBrowseHistoryWriteInput = __t.object("PlatformBrowseHistoryWriteInput", {
ownerUserId: __t.string(),
ownerAccountId: __t.string(),
profileId: __t.string(),
worldName: __t.string(),
subtitle: __t.string(),
@@ -345,7 +397,7 @@ export const PlatformBrowseHistoryWriteInput = __t.object("PlatformBrowseHistory
export type PlatformBrowseHistoryWriteInput = __Infer<typeof PlatformBrowseHistoryWriteInput>;
export const ProfileDashboardState = __t.object("ProfileDashboardState", {
userId: __t.string(),
accountId: __t.string(),
walletBalance: __t.i64(),
totalPlayTimeMs: __t.u64(),
updatedAtMs: __t.u64(),
@@ -362,9 +414,9 @@ export type ProfileDashboardView = __Infer<typeof ProfileDashboardView>;
export const ProfilePlayedWorld = __t.object("ProfilePlayedWorld", {
id: __t.string(),
userId: __t.string(),
accountId: __t.string(),
worldKey: __t.string(),
ownerUserId: __t.option(__t.string()),
ownerAccountId: __t.option(__t.string()),
profileId: __t.option(__t.string()),
worldType: __t.option(__t.string()),
worldTitle: __t.string(),
@@ -377,7 +429,7 @@ export type ProfilePlayedWorld = __Infer<typeof ProfilePlayedWorld>;
export const ProfilePlayedWorldView = __t.object("ProfilePlayedWorldView", {
worldKey: __t.string(),
ownerUserId: __t.option(__t.string()),
ownerAccountId: __t.option(__t.string()),
profileId: __t.option(__t.string()),
worldType: __t.option(__t.string()),
worldTitle: __t.string(),
@@ -390,7 +442,7 @@ export type ProfilePlayedWorldView = __Infer<typeof ProfilePlayedWorldView>;
export const ProfileWalletLedger = __t.object("ProfileWalletLedger", {
id: __t.string(),
userId: __t.string(),
accountId: __t.string(),
amountDelta: __t.i64(),
balanceAfter: __t.i64(),
sourceType: __t.string(),
@@ -409,7 +461,7 @@ export const ProfileWalletLedgerView = __t.object("ProfileWalletLedgerView", {
export type ProfileWalletLedgerView = __Infer<typeof ProfileWalletLedgerView>;
export const PublishedCustomWorldProfileView = __t.object("PublishedCustomWorldProfileView", {
ownerUserId: __t.string(),
ownerAccountId: __t.string(),
profileId: __t.string(),
payloadJson: __t.string(),
get visibility() {
@@ -445,7 +497,7 @@ export const RiskBlockScopeType = __t.enum("RiskBlockScopeType", {
export type RiskBlockScopeType = __Infer<typeof RiskBlockScopeType>;
export const RuntimeSetting = __t.object("RuntimeSetting", {
userId: __t.string(),
accountId: __t.string(),
musicVolume: __t.f32(),
updatedAtMs: __t.u64(),
});
@@ -457,7 +509,7 @@ export const RuntimeSettingsView = __t.object("RuntimeSettingsView", {
export type RuntimeSettingsView = __Infer<typeof RuntimeSettingsView>;
export const SaveSnapshot = __t.object("SaveSnapshot", {
userId: __t.string(),
accountId: __t.string(),
version: __t.u32(),
savedAtMs: __t.u64(),
bottomTab: __t.string(),
@@ -537,58 +589,6 @@ export const SnapshotView = __t.object("SnapshotView", {
});
export type SnapshotView = __Infer<typeof SnapshotView>;
export const User = __t.object("User", {
id: __t.string(),
identity: __t.identity(),
username: __t.option(__t.string()),
passwordHash: __t.option(__t.string()),
tokenVersion: __t.u32(),
displayName: __t.string(),
get loginProvider() {
return LoginProvider;
},
get accountStatus() {
return AccountStatus;
},
phoneNumber: __t.option(__t.string()),
phoneVerifiedAtMs: __t.option(__t.u64()),
createdAtMs: __t.u64(),
updatedAtMs: __t.u64(),
});
export type User = __Infer<typeof User>;
export const UserBrowseHistory = __t.object("UserBrowseHistory", {
id: __t.string(),
userId: __t.string(),
ownerUserId: __t.string(),
profileId: __t.string(),
worldName: __t.string(),
subtitle: __t.string(),
summaryText: __t.string(),
coverImageSrc: __t.option(__t.string()),
get themeMode() {
return CustomWorldThemeMode;
},
authorDisplayName: __t.string(),
visitedAtMs: __t.u64(),
});
export type UserBrowseHistory = __Infer<typeof UserBrowseHistory>;
export const UserSession = __t.object("UserSession", {
id: __t.string(),
userId: __t.string(),
refreshTokenHash: __t.string(),
clientType: __t.string(),
userAgent: __t.option(__t.string()),
ip: __t.option(__t.string()),
expiresAtMs: __t.option(__t.u64()),
revokedAtMs: __t.option(__t.u64()),
createdAtMs: __t.u64(),
updatedAtMs: __t.u64(),
lastSeenAtMs: __t.u64(),
});
export type UserSession = __Infer<typeof UserSession>;
export const VerificationPromptEvent = __t.object("VerificationPromptEvent", {
targetIdentity: __t.identity(),
phoneNumberMasked: __t.option(__t.string()),

View File

@@ -77,7 +77,7 @@ function mapBindingStatus(row: AuthStateView): AuthBindingStatus {
export function mapAuthUser(row: AuthStateView): AuthUser {
return {
id: row.userId,
id: row.accountId,
username: row.displayName,
displayName: row.displayName,
phoneNumberMasked: row.phoneNumberMasked ?? null,
@@ -171,7 +171,7 @@ export function mapPlayedWorldEntry(
): ProfilePlayedWorkSummary {
return {
worldKey: row.worldKey,
ownerUserId: row.ownerUserId ?? null,
ownerAccountId: row.ownerAccountId ?? null,
profileId: row.profileId ?? null,
worldType: row.worldType ?? null,
worldTitle: row.worldTitle,
@@ -186,7 +186,7 @@ export function mapBrowseHistoryEntry(
row: PlatformBrowseHistoryView,
): PlatformBrowseHistoryEntry {
return {
ownerUserId: row.ownerUserId,
ownerAccountId: row.ownerAccountId,
profileId: row.profileId,
worldName: row.worldName,
subtitle: row.subtitle,
@@ -202,7 +202,7 @@ export function mapCustomWorldLibraryEntry(
row: CustomWorldProfileView,
): CustomWorldLibraryEntry<CustomWorldProfile> {
return {
ownerUserId: row.ownerUserId,
ownerAccountId: row.ownerAccountId,
profileId: row.profileId,
profile: parseJson<CustomWorldProfile>(row.payloadJson, {
id: row.profileId,
@@ -243,7 +243,7 @@ export function mapGalleryCard(
row: CustomWorldGalleryCardView,
): CustomWorldGalleryCard {
return {
ownerUserId: row.ownerUserId,
ownerAccountId: row.ownerAccountId,
profileId: row.profileId,
visibility: enumTag(row.visibility) === 'Published' ? 'published' : 'draft',
publishedAt: bigintToIso(row.publishedAtMs),
@@ -263,7 +263,7 @@ export function mapPublishedProfile(
row: PublishedCustomWorldProfileView,
): CustomWorldLibraryEntry<CustomWorldProfile> {
return mapCustomWorldLibraryEntry({
ownerUserId: row.ownerUserId,
ownerAccountId: row.ownerAccountId,
profileId: row.profileId,
payloadJson: row.payloadJson,
visibility: row.visibility,