Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove unused intermediate concept

Manav Rathi9424b7a65ecc
diff --git a/web/packages/new/photos/services/ml/cluster.ts b/web/packages/new/photos/services/ml/cluster.ts
index 51c31d2e66..94fcc1c2c1 100644
--- a/web/packages/new/photos/services/ml/cluster.ts
+++ b/web/packages/new/photos/services/ml/cluster.ts
@@ -20,7 +20,7 @@ import { dotProduct } from "./math";
* A face cluster is an set of faces, and a nanoid to uniquely identify it.
*
* These are local only clusters. The clusters that are synced with remote are
- * part of {@link CGroup}s.
+ * part of "cgroup" user entities.
*/
export interface FaceCluster {
/**
diff --git a/web/packages/new/photos/services/ml/people.ts b/web/packages/new/photos/services/ml/people.ts
index cc8a5a145b..7ab61302c9 100644
--- a/web/packages/new/photos/services/ml/people.ts
+++ b/web/packages/new/photos/services/ml/people.ts
@@ -13,39 +13,38 @@ import { fileIDFromFaceID } from "./face";
* Interactions include hiding, merging and giving a name and/or a cover photo.
*
* The most frequent interaction is naming a {@link FaceCluster}, which promotes
- * it to a become a {@link CGroup}. The promotion comes with the ability to be
- * synced with remote (as a "cgroup" user entity).
+ * it to a become a {@link CGroupUserEntity}. The promotion comes with the
+ * ability to be synced with remote (as a "cgroup" user entity).
*
- * There after, the user may attach more clusters to the same {@link CGroup}.
+ * There after, the user may attach more clusters to the same cgroup.
*
* > A named cluster group can be thought of as a "person", though this is not
* > necessarily an accurate characterization. e.g. there can be a named cluster
* > group that contains face clusters of pets.
*
* The other form of interaction is hiding. The user may hide a single (unnamed)
- * cluster, or they may hide an named {@link CGroup}. In both cases, we promote
- * the cluster to a CGroup if needed so that their request to hide gets synced.
+ * cluster, or they may hide an named cgroup. In both cases, we promote the
+ * cluster to a cgroup if needed so that their request to hide gets synced.
*
* The user can see both the cgroups and clusters in the UI, but only the
* cgroups are synced with remote.
*/
-export interface CGroup {
- /**
- * A nanoid for this cluster group.
- *
- * This is the ID of the "cgroup" user entity (the envelope), and it is not
- * contained as part of the group entity payload itself.
- */
- id: string;
+export interface CGroupUserEntityData {
/**
* A name assigned by the user to this cluster group.
*
* The client should handle both empty strings and undefined as indicating a
- * cgroup without a name. When the client needs to set this to an "empty"
+ * cgroup without a name. When the client needs to set this to an <empty>
* value, which happens when hiding an unnamed cluster, it should it to an
* empty string. That is, expect `"" | undefined`, but set `""`.
+ *
+ * [Note: Mark optional for Zod/exactOptionalPropertyTypes]
+ *
+ * The type is marked as an optional (?) because currently Zod does not
+ * differentiate between optionals and undefined-valued properties as
+ * required by exactOptionalPropertyTypes.
*/
- name: string | undefined;
+ name?: string | undefined;
/**
* An unordered set ofe clusters that have been assigned to this group.
*
@@ -73,13 +72,15 @@ export interface CGroup {
*
* - {@link displayFaceID} is the automatic placeholder, and only comes
* into effect if the user has not explicitly selected a face.
+ *
+ * Also, see: [Note: Mark optional for Zod/exactOptionalPropertyTypes]
*/
- avatarFaceID: string | undefined;
+ avatarFaceID?: string | undefined;
}
/**
- * A massaged version of {@link CGroup} or a {@link FaceCluster} suitable for
- * being shown in the UI.
+ * A massaged version of {@link CGroupUserEntityData} or a {@link FaceCluster}
+ * suitable for being shown in the UI.
*
* We transform both both remote cluster groups and local-only face clusters
* into the same "person" object that can be shown in the UI.
@@ -93,12 +94,12 @@ export interface CGroup {
*
* Beyond this semantic difference, there is also data massaging: a
* {@link Person} has data converted into a format that the UI can directly and
- * efficiently use, as compared to a {@link CGroup}, which is tailored for
- * transmission and storage.
+ * efficiently use, as compared to a {@link CGroupUserEntityData}, which is
+ * tailored for transmission and storage.
*/
export interface Person {
/**
- * Nanoid of the underlying {@link CGroup} or {@link FaceCluster}.
+ * Nanoid of the underlying cgroup or {@link FaceCluster}.
*/
id: string;
/**
diff --git a/web/packages/new/photos/services/user-entity/index.ts b/web/packages/new/photos/services/user-entity/index.ts
index a0a0743e65..13cd9164fe 100644
--- a/web/packages/new/photos/services/user-entity/index.ts
+++ b/web/packages/new/photos/services/user-entity/index.ts
@@ -7,6 +7,7 @@ import {
import { nullToUndefined } from "@/utils/transform";
import { z } from "zod";
import { gunzip, gzip } from "../../utils/gzip";
+import type { CGroupUserEntityData } from "../ml/people";
import {
savedEntities,
savedLatestUpdatedAt,
@@ -78,6 +79,8 @@ const RemoteFaceCluster = z.object({
/**
* Zod schema for the fields of interest in the cgroup that we get from remote.
+ *
+ * See also: {@link CGroupUserEntityData}.
*/
const RemoteCGroup = z.object({
name: z.string().nullish().transform(nullToUndefined),
@@ -88,10 +91,10 @@ const RemoteCGroup = z.object({
avatarFaceID: z.string().nullish().transform(nullToUndefined),
});
-export type RemoteCGroup = z.infer<typeof RemoteCGroup>;
-
export type CGroupUserEntity = Omit<LocalUserEntity, "data"> & {
- data: RemoteCGroup;
+ // CGroupUserEntityData is meant to be a (documented) equivalent of
+ // `z.infer<typeof RemoteCGroup>`.
+ data: CGroupUserEntityData;
};
/**