Files
NianToB/shared/yinian.ts
inman 0abc48189c
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled
feat: prepare Zhinian desktop pilot
2026-05-07 21:49:20 +08:00

167 lines
3.8 KiB
TypeScript

export type YinianControlPlaneMode = 'mock' | 'http';
export interface YinianServerStatus {
mode: YinianControlPlaneMode;
apiBaseUrl?: string;
reachable: boolean;
checkedAt: number;
serverTime?: number;
version?: string;
message?: string;
}
export interface YinianUser {
id: string;
name: string;
phone?: string;
email?: string;
avatar?: string;
}
// Compatibility note: early M1 contracts used "hotel" as the tenant object
// name. The product surface now treats this as a generic B-end workspace or
// business object, while the field names remain stable for storage/API safety.
export interface YinianHotel {
id: string;
name: string;
brand?: string;
}
export interface YinianAuthSession {
authenticated: true;
user: YinianUser;
hotels: YinianHotel[];
currentHotelId: string;
accessTokenExpiresAt: number;
}
export interface YinianUnauthenticatedSession {
authenticated: false;
}
export type YinianSessionState = YinianAuthSession | YinianUnauthenticatedSession;
export interface YinianPersistedSession {
mode: YinianControlPlaneMode;
user: YinianUser;
hotels: YinianHotel[];
currentHotelId: string;
accessTokenExpiresAt: number;
refreshToken?: string;
updatedAt: number;
}
export interface YinianLoginWithSmsInput {
phone: string;
code: string;
captchaCode?: string;
randomStr?: string;
}
export interface YinianLoginWithPasswordInput {
account: string;
password: string;
captchaCode?: string;
randomStr?: string;
}
export interface YinianImageCaptcha {
randomStr: string;
image?: string;
imageBase64?: string;
mimeType?: string;
raw?: Record<string, unknown>;
}
export interface YinianSavedCredentials {
account: string;
password?: string;
rememberPassword: boolean;
updatedAt: number;
}
export interface YinianSkillEntitlement {
skillId: string;
name: string;
version: string;
enabled: boolean;
category: 'ota-monitoring' | 'reporting' | 'guest-comm' | 'ops-automation';
triggers: Array<'manual' | 'scheduled' | 'webhook' | 'reply'>;
lastRunAt?: number;
}
export type YinianSkillSyncStatus = 'installed' | 'updated' | 'skipped' | 'disabled' | 'failed';
export interface YinianLocalSkill {
skillId: string;
name: string;
version: string;
enabled: boolean;
installedAt: number;
lastSyncedAt: number;
status: YinianSkillSyncStatus;
source: 'mock' | 'nianxx';
bundleSha256?: string;
error?: string;
}
export interface YinianSkillSyncResult {
hotelId: string;
syncedAt: number;
skills: YinianLocalSkill[];
}
export interface YinianSkillRegistry {
hotelId: string;
updatedAt: number;
skills: YinianLocalSkill[];
}
export type YinianSkillRegistryByHotel = Record<string, YinianSkillRegistry>;
export type YinianWorkspace = YinianHotel;
export type YinianSkillRegistryByWorkspace = YinianSkillRegistryByHotel;
export type YinianAppCenterItemType = 'native' | 'webview' | 'external';
export type YinianAppCenterItemSource = 'built-in' | 'server' | 'local';
export interface YinianAppCenterItem {
id: string;
name: string;
description?: string;
category?: string;
tags?: string[];
icon?: string;
type: YinianAppCenterItemType;
route?: string;
url?: string;
pinned?: boolean;
source: YinianAppCenterItemSource;
createdAt?: string;
updatedAt?: string;
}
export interface YinianNotificationChannel {
id: string;
kind: string;
label: string;
recipient: string;
enabled: boolean;
source: 'kernel' | 'nianxx';
}
export interface YinianConfigSnapshot {
serverTime: number;
user: YinianUser;
hotel: YinianHotel;
hotels: YinianHotel[];
entitlements: YinianSkillEntitlement[];
notificationChannels: YinianNotificationChannel[];
featureFlags: Record<string, boolean>;
uiPolicy: {
defaultPage: 'today' | 'chat';
showAdvancedSettings: boolean;
};
}