diff --git a/core/crates/cloud-services/src/p2p/mod.rs b/core/crates/cloud-services/src/p2p/mod.rs index 701bb4969620..bdefe97ec759 100644 --- a/core/crates/cloud-services/src/p2p/mod.rs +++ b/core/crates/cloud-services/src/p2p/mod.rs @@ -41,6 +41,7 @@ pub struct Ticket(u64); #[derive(Debug, Serialize, specta::Type)] #[serde(tag = "kind", content = "data")] +#[specta(rename = "CloudP2PNotifyUser")] pub enum NotifyUser { ReceivedJoinSyncGroupRequest { ticket: Ticket, @@ -84,6 +85,7 @@ pub struct BasicLibraryCreationArgs { #[derive(Debug, Deserialize, specta::Type)] #[serde(tag = "kind", content = "data")] +#[specta(rename = "CloudP2PUserResponse")] pub enum UserResponse { AcceptDeviceInSyncGroup { ticket: Ticket, diff --git a/packages/client/src/core.ts b/packages/client/src/core.ts index 11776426f77c..9a5a3277f42a 100644 --- a/packages/client/src/core.ts +++ b/packages/client/src/core.ts @@ -5,16 +5,16 @@ export type Procedures = { queries: { key: "backups.getAll", input: never, result: GetAll } | { key: "buildInfo", input: never, result: BuildInfo } | - { key: "cloud.devices.get", input: DeviceGetRequest, result: Device } | - { key: "cloud.devices.get_current_device", input: AccessToken, result: Device } | - { key: "cloud.devices.list", input: DeviceListRequest, result: Device[] } | - { key: "cloud.libraries.get", input: LibraryGetRequest, result: Library } | - { key: "cloud.libraries.list", input: LibraryListRequest, result: Library[] } | - { key: "cloud.locations.list", input: LocationListRequest, result: CloudLocation[] } | - { key: "cloud.syncGroups.get", input: SyncGroupGetRequest, result: SyncGroup } | - { key: "cloud.syncGroups.leave", input: SyncGroupsLeaveArgs, result: null } | - { key: "cloud.syncGroups.list", input: SyncGroupListRequest, result: SyncGroup[] } | - { key: "cloud.syncGroups.remove_device", input: SyncGroupsRemoveDeviceArgs, result: null } | + { key: "cloud.devices.get", input: DevicePubId, result: Device } | + { key: "cloud.devices.get_current_device", input: never, result: Device } | + { key: "cloud.devices.list", input: never, result: Device[] } | + { key: "cloud.libraries.get", input: CloudGetLibraryArgs, result: Library } | + { key: "cloud.libraries.list", input: boolean, result: Library[] } | + { key: "cloud.locations.list", input: CloudListLocationsArgs, result: CloudLocation[] } | + { key: "cloud.syncGroups.get", input: CloudGetSyncGroupArgs, result: SyncGroup } | + { key: "cloud.syncGroups.leave", input: SyncGroupPubId, result: null } | + { key: "cloud.syncGroups.list", input: boolean, result: SyncGroup[] } | + { key: "cloud.syncGroups.remove_device", input: CloudSyncGroupsRemoveDeviceArgs, result: null } | { key: "ephemeralFiles.getMediaData", input: string, result: MediaData | null } | { key: "files.get", input: LibraryArgs, result: ObjectWithFilePaths2 | null } | { key: "files.getConvertibleImageExtensions", input: never, result: string[] } | @@ -66,17 +66,17 @@ export type Procedures = { { key: "backups.delete", input: string, result: null } | { key: "backups.restore", input: string, result: null } | { key: "cloud.bootstrap", input: [AccessToken, RefreshToken], result: null } | - { key: "cloud.devices.delete", input: DeviceDeleteRequest, result: null } | - { key: "cloud.devices.update", input: DeviceUpdateRequest, result: null } | - { key: "cloud.libraries.create", input: LibraryArgs, result: null } | - { key: "cloud.libraries.delete", input: LibraryArgs, result: null } | - { key: "cloud.libraries.update", input: LibraryArgs, result: null } | - { key: "cloud.locations.create", input: LocationCreateRequest, result: null } | - { key: "cloud.locations.delete", input: LocationDeleteRequest, result: null } | - { key: "cloud.syncGroups.create", input: LibraryArgs, result: null } | - { key: "cloud.syncGroups.delete", input: SyncGroupDeleteRequest, result: null } | + { key: "cloud.devices.delete", input: DevicePubId, result: null } | + { key: "cloud.devices.update", input: CloudUpdateDeviceArgs, result: null } | + { key: "cloud.libraries.create", input: LibraryArgs, result: null } | + { key: "cloud.libraries.delete", input: LibraryArgs, result: null } | + { key: "cloud.libraries.update", input: LibraryArgs, result: null } | + { key: "cloud.locations.create", input: CloudCreateLocationArgs, result: null } | + { key: "cloud.locations.delete", input: LocationPubId, result: null } | + { key: "cloud.syncGroups.create", input: LibraryArgs, result: null } | + { key: "cloud.syncGroups.delete", input: SyncGroupPubId, result: null } | { key: "cloud.syncGroups.request_join", input: SyncGroupsRequestJoinArgs, result: null } | - { key: "cloud.userResponse", input: UserResponse, result: null } | + { key: "cloud.userResponse", input: CloudP2PUserResponse, result: null } | { key: "ephemeralFiles.copyFiles", input: LibraryArgs, result: null } | { key: "ephemeralFiles.createFile", input: LibraryArgs, result: string } | { key: "ephemeralFiles.createFolder", input: LibraryArgs, result: string } | @@ -137,7 +137,7 @@ export type Procedures = { { key: "tags.update", input: LibraryArgs, result: null } | { key: "toggleFeatureFlag", input: BackendFeature, result: null }, subscriptions: - { key: "cloud.listenCloudServicesNotifications", input: never, result: NotifyUser } | + { key: "cloud.listenCloudServicesNotifications", input: never, result: CloudP2PNotifyUser } | { key: "invalidation.listen", input: never, result: InvalidateOperationEvent[] } | { key: "jobs.newFilePathIdentified", input: LibraryArgs, result: number[] } | { key: "jobs.newThumbnail", input: LibraryArgs, result: ThumbKey } | @@ -182,12 +182,28 @@ export type ChangeNodeNameArgs = { name: string | null; p2p_port: Port | null; p export type Chapter = { id: number; start: [number, number]; end: [number, number]; time_base_den: number; time_base_num: number; metadata: Metadata } +export type CloudCreateLocationArgs = { pub_id: LocationPubId; name: string; library_pub_id: LibraryPubId; device_pub_id: DevicePubId } + +export type CloudGetLibraryArgs = { pub_id: LibraryPubId; with_device: boolean } + +export type CloudGetSyncGroupArgs = { pub_id: SyncGroupPubId; with_library: boolean; with_devices: boolean; with_used_storage: boolean } + +export type CloudListLocationsArgs = { library_pub_id: LibraryPubId; with_library: boolean; with_device: boolean } + export type CloudLocation = { pub_id: LocationPubId; name: string; device: Device | null; library: Library | null; created_at: string; updated_at: string } export type CloudP2PError = "Rejected" | "UnableToConnect" | "TimedOut" +export type CloudP2PNotifyUser = { kind: "ReceivedJoinSyncGroupRequest"; data: { ticket: CloudP2PTicket; asking_device: Device; sync_group: SyncGroupWithLibraryAndDevices } } | { kind: "ReceivedJoinSyncGroupResponse"; data: { response: JoinSyncGroupResponse; sync_group: SyncGroupWithLibraryAndDevices } } | { kind: "SendingJoinSyncGroupResponseError"; data: { error: JoinSyncGroupError; sync_group: SyncGroupWithLibraryAndDevices } } | { kind: "TimedOutJoinRequest"; data: { device: Device; succeeded: boolean } } + export type CloudP2PTicket = bigint +export type CloudP2PUserResponse = { kind: "AcceptDeviceInSyncGroup"; data: { ticket: CloudP2PTicket; accepted: BasicLibraryCreationArgs | null } } + +export type CloudSyncGroupsRemoveDeviceArgs = { group_pub_id: SyncGroupPubId; to_remove_device_pub_id: DevicePubId } + +export type CloudUpdateDeviceArgs = { pub_id: DevicePubId; name: string; storage_size: bigint; used_storage: bigint } + export type Codec = { kind: string | null; sub_kind: string | null; tag: string | null; name: string | null; profile: string | null; bit_rate: number; props: Props | null } export type ColorProfile = "Normal" | "Custom" | "HDRNoOriginal" | "HDRWithOriginal" | "OriginalForHDR" | "Panorama" | "PortraitHDR" | "Portrait" @@ -242,18 +258,10 @@ export type DefaultLocations = { desktop: boolean; documents: boolean; downloads export type Device = { pub_id: DevicePubId; name: string; os: DeviceOS; storage_size: bigint; used_storage: bigint; connection_id: string; created_at: string; updated_at: string; hardware_model: HardwareModel } -export type DeviceDeleteRequest = { access_token: AccessToken; pub_id: DevicePubId } - -export type DeviceGetRequest = { access_token: AccessToken; pub_id: DevicePubId } - -export type DeviceListRequest = { access_token: AccessToken } - export type DeviceOS = "Linux" | "Windows" | "MacOS" | "iOS" | "Android" export type DevicePubId = string -export type DeviceUpdateRequest = { access_token: AccessToken; pub_id: DevicePubId; name: string; storage_size: bigint; used_storage: bigint } - /** * The method used for the discovery of this peer. * *Technically* you can have multiple under the hood but this simplifies things for the UX. @@ -424,8 +432,6 @@ export type Label = { id: number; name: string; date_created: string | null; dat export type LabelWithObjects = { id: number; name: string; date_created: string | null; date_modified: string | null; label_objects: { object: { id: number; file_paths: FilePath[] } }[] } -export type LibrariesUpdateArgs = { access_token: AccessToken; name: string } - export type Library = { pub_id: LibraryPubId; name: string; original_device: Device | null; created_at: string; updated_at: string } /** @@ -459,10 +465,6 @@ export type LibraryConfigVersion = "V0" | "V1" | "V2" | "V3" | "V4" | "V5" | "V6 export type LibraryConfigWrapped = { uuid: string; instance_id: string; instance_public_key: RemoteIdentity; config: LibraryConfig } -export type LibraryGetRequest = { access_token: AccessToken; pub_id: LibraryPubId; with_device: boolean } - -export type LibraryListRequest = { access_token: AccessToken; with_device: boolean } - export type LibraryName = string export type LibraryPreferences = { location?: { [key in string]: LocationSettings }; tag?: { [key in string]: TagSettings } } @@ -484,12 +486,6 @@ export type Location = { id: number; pub_id: number[]; name: string | null; path */ export type LocationCreateArgs = { path: string; dry_run: boolean; indexer_rules_ids: number[] } -export type LocationCreateRequest = { access_token: AccessToken; pub_id: LocationPubId; name: string; library_pub_id: LibraryPubId; device_pub_id: DevicePubId } - -export type LocationDeleteRequest = { access_token: AccessToken; pub_id: LocationPubId } - -export type LocationListRequest = { access_token: AccessToken; library_pub_id: LibraryPubId; with_library: boolean; with_device: boolean } - export type LocationPubId = string export type LocationSettings = { explorer: ExplorerSettings } @@ -575,8 +571,6 @@ export type NotificationId = { type: "library"; id: [string, number] } | { type: export type NotificationKind = "info" | "success" | "error" | "warning" -export type NotifyUser = { kind: "ReceivedJoinSyncGroupRequest"; data: { ticket: CloudP2PTicket; asking_device: Device; sync_group: SyncGroupWithLibraryAndDevices } } | { kind: "ReceivedJoinSyncGroupResponse"; data: { response: JoinSyncGroupResponse; sync_group: SyncGroupWithLibraryAndDevices } } | { kind: "SendingJoinSyncGroupResponseError"; data: { error: JoinSyncGroupError; sync_group: SyncGroupWithLibraryAndDevices } } | { kind: "TimedOutJoinRequest"; data: { device: Device; succeeded: boolean } } - export type Object = { id: number; pub_id: number[]; kind: number | null; key_id: number | null; hidden: boolean | null; favorite: boolean | null; important: boolean | null; note: string | null; date_created: string | null; date_accessed: string | null; device_pub_id: number[] | null } export type ObjectCursor = "none" | { dateAccessed: CursorOrderItem } | { kind: CursorOrderItem } @@ -692,21 +686,11 @@ export type SubtitleProps = { width: number; height: number } export type SyncGroup = { pub_id: SyncGroupPubId; latest_key_hash: KeyHash; library: Library | null; devices: Device[] | null; total_sync_messages_bytes: bigint | null; total_space_files_bytes: bigint | null; created_at: string; updated_at: string } -export type SyncGroupDeleteRequest = { access_token: AccessToken; pub_id: SyncGroupPubId } - -export type SyncGroupGetRequest = { access_token: AccessToken; pub_id: SyncGroupPubId; with_library: boolean; with_devices: boolean; with_used_storage: boolean } - -export type SyncGroupListRequest = { access_token: AccessToken; with_library: boolean } - export type SyncGroupPubId = string export type SyncGroupWithLibraryAndDevices = { pub_id: SyncGroupPubId; latest_key_hash: KeyHash; library: Library; devices: Device[]; created_at: string; updated_at: string } -export type SyncGroupsLeaveArgs = { access_token: AccessToken; group_pub_id: SyncGroupPubId } - -export type SyncGroupsRemoveDeviceArgs = { access_token: AccessToken; group_pub_id: SyncGroupPubId; to_remove_device_pub_id: DevicePubId } - -export type SyncGroupsRequestJoinArgs = { access_token: AccessToken; sync_group: SyncGroupWithLibraryAndDevices; asking_device: Device } +export type SyncGroupsRequestJoinArgs = { sync_group: SyncGroupWithLibraryAndDevices; asking_device: Device } export type SyncStatus = { ingest: boolean; cloud_send: boolean; cloud_receive: boolean; cloud_ingest: boolean } @@ -732,8 +716,6 @@ export type ThumbKey = { shard_hex: string; cas_id: CasId; base_directory_str: s export type UpdateThumbnailerPreferences = Record -export type UserResponse = { kind: "AcceptDeviceInSyncGroup"; data: { ticket: CloudP2PTicket; accepted: BasicLibraryCreationArgs | null } } - export type VideoProps = { pixel_format: string | null; color_range: string | null; bits_per_channel: number | null; color_space: string | null; color_primaries: string | null; color_transfer: string | null; field_order: string | null; chroma_location: string | null; width: number; height: number; aspect_ratio_num: number | null; aspect_ratio_den: number | null; properties: string[] } export type Volume = { name: string; mount_points: string[]; total_capacity: string; available_capacity: string; disk_type: DiskType; file_system: string | null; is_root_filesystem: boolean }