Skip to content

armgit / ente

Public Imported from GitHub
0

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

passthrough => looseObject

Manav Rathi5e26a895d31a
diff --git a/web/packages/media/file-metadata.ts b/web/packages/media/file-metadata.ts
index bfea23fb17..dfd18ba5c7 100644
--- a/web/packages/media/file-metadata.ts
+++ b/web/packages/media/file-metadata.ts
@@ -326,21 +326,19 @@ export interface PublicMagicMetadata {
* might be other, newer, clients out there adding fields that the current
* client might not we aware of, and we don't want to overwrite them.
*/
-const PublicMagicMetadata = z
- .object({
- // [Note: Zod doesn't work with `exactOptionalPropertyTypes` yet]
- //
- // Using `optional` is not accurate here. The key is optional, but the
- // value itself is not optional.
- //
- // Zod doesn't work with `exactOptionalPropertyTypes` yet, but it seems
- // to be on the roadmap so we suppress these mismatches.
- //
- // See:
- // https://github.com/colinhacks/zod/issues/635#issuecomment-2196579063
- editedTime: z.number().optional(),
- })
- .passthrough();
+const PublicMagicMetadata = z.looseObject({
+ // [Note: Zod doesn't work with `exactOptionalPropertyTypes` yet]
+ //
+ // Using `optional` is not accurate here. The key is optional, but the
+ // value itself is not optional.
+ //
+ // Zod doesn't work with `exactOptionalPropertyTypes` yet, but it seems
+ // to be on the roadmap so we suppress these mismatches.
+ //
+ // See:
+ // https://github.com/colinhacks/zod/issues/635#issuecomment-2196579063
+ editedTime: z.number().optional(),
+});
/**
* Return the private magic metadata for an {@link EnteFile}.
diff --git a/web/packages/new/photos/services/ml/ml-data.ts b/web/packages/new/photos/services/ml/ml-data.ts
index 21098294e1..5f035d9cc0 100644
--- a/web/packages/new/photos/services/ml/ml-data.ts
+++ b/web/packages/new/photos/services/ml/ml-data.ts
@@ -129,7 +129,7 @@ const RemoteCLIPIndex = z.object({
/**
* Zod schema for the {@link RawRemoteMLData} type.
*/
-const RawRemoteMLData = z.object({}).passthrough();
+const RawRemoteMLData = z.looseObject({});
/**
* Zod schema for the {@link ParsedRemoteMLData} type.
diff --git a/web/packages/new/photos/services/user-entity/db.ts b/web/packages/new/photos/services/user-entity/db.ts
index c7c0b3d7aa..bc3e870c04 100644
--- a/web/packages/new/photos/services/user-entity/db.ts
+++ b/web/packages/new/photos/services/user-entity/db.ts
@@ -37,7 +37,7 @@ export interface LocalUserEntity {
const LocalUserEntity = z.object({
id: z.string(),
// Retain the data verbatim.
- data: z.object({}).passthrough(),
+ data: z.looseObject({}),
updatedAt: z.number(),
});
diff --git a/web/packages/new/photos/services/user-entity/index.ts b/web/packages/new/photos/services/user-entity/index.ts
index 37909422dd..16d3a904e6 100644
--- a/web/packages/new/photos/services/user-entity/index.ts
+++ b/web/packages/new/photos/services/user-entity/index.ts
@@ -50,13 +50,11 @@ export type EntityType =
* Zod schema for the fields of interest in the location tag that we get from
* remote.
*/
-const RemoteLocationTagData = z
- .object({
- name: z.string(),
- radius: z.number(),
- centerPoint: z.object({ latitude: z.number(), longitude: z.number() }),
- })
- .passthrough();
+const RemoteLocationTagData = z.looseObject({
+ name: z.string(),
+ radius: z.number(),
+ centerPoint: z.object({ latitude: z.number(), longitude: z.number() }),
+});
/**
* A view of the location tag data suitable for use by the rest of the app.
@@ -71,9 +69,10 @@ export const savedLocationTags = (): Promise<LocationTag[]> =>
es.map((e) => RemoteLocationTagData.parse(e.data)),
);
-const RemoteFaceCluster = z
- .object({ id: z.string(), faces: z.string().array() })
- .passthrough();
+const RemoteFaceCluster = z.looseObject({
+ id: z.string(),
+ faces: z.string().array(),
+});
/**
* Zod schema for the fields of interest in the cgroup that we get from remote.
@@ -82,21 +81,13 @@ const RemoteFaceCluster = z
*
* See: [Note: Use passthrough for metadata Zod schemas].
*/
-const RemoteCGroupData = z
- .object({
- name: z.string().nullish().transform(nullToUndefined),
- assigned: z
- .array(RemoteFaceCluster)
- .nullish()
- .transform(nullishToEmpty),
- rejectedFaceIDs: z
- .array(z.string())
- .nullish()
- .transform(nullishToEmpty),
- isHidden: z.boolean(),
- avatarFaceID: z.string().nullish().transform(nullToUndefined),
- })
- .passthrough();
+const RemoteCGroupData = z.looseObject({
+ name: z.string().nullish().transform(nullToUndefined),
+ assigned: z.array(RemoteFaceCluster).nullish().transform(nullishToEmpty),
+ rejectedFaceIDs: z.array(z.string()).nullish().transform(nullishToEmpty),
+ isHidden: z.boolean(),
+ avatarFaceID: z.string().nullish().transform(nullToUndefined),
+});
/**
* A "cgroup" user entity.