Skip to content

armgit / ente

Public Imported from GitHub
0

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

Not really

Manav Rathi42a6697531a8
diff --git a/web/packages/media/collection.ts b/web/packages/media/collection.ts
index bf0f84fdab..46772c3caa 100644
--- a/web/packages/media/collection.ts
+++ b/web/packages/media/collection.ts
@@ -6,11 +6,7 @@ import {
import { ItemVisibility } from "ente-media/file-metadata";
import { nullishToEmpty, nullToUndefined } from "ente-utils/transform";
import { z } from "zod/v4";
-import {
- decryptMagicMetadata,
- RemoteMagicMetadataSchema,
- type RemoteMagicMetadata,
-} from "./magic-metadata";
+import { decryptMagicMetadata, RemoteMagicMetadata } from "./magic-metadata";
/**
* The type of a collection.
@@ -151,10 +147,8 @@ type RemoteCollectionUser = z.infer<typeof RemoteCollectionUser>;
/**
* Zod schema for {@link Collection}.
- *
- * See: [Note: Schema suffix for exported Zod schemas].
*/
-export const RemoteCollectionSchema = z.object({
+export const RemoteCollection = z.object({
id: z.number(),
owner: RemoteCollectionUser,
encryptedKey: z.string(),
@@ -192,15 +186,13 @@ export const RemoteCollectionSchema = z.object({
* have been deleted and should thus be pruned by the client locally.
*/
isDeleted: z.boolean().nullish().transform(nullToUndefined),
- magicMetadata:
- RemoteMagicMetadataSchema.nullish().transform(nullToUndefined),
- pubMagicMetadata:
- RemoteMagicMetadataSchema.nullish().transform(nullToUndefined),
+ magicMetadata: RemoteMagicMetadata.nullish().transform(nullToUndefined),
+ pubMagicMetadata: RemoteMagicMetadata.nullish().transform(nullToUndefined),
sharedMagicMetadata:
- RemoteMagicMetadataSchema.nullish().transform(nullToUndefined),
+ RemoteMagicMetadata.nullish().transform(nullToUndefined),
});
-export type RemoteCollection = z.infer<typeof RemoteCollectionSchema>;
+export type RemoteCollection = z.infer<typeof RemoteCollection>;
export interface EncryptedCollection {
id: number;
diff --git a/web/packages/media/magic-metadata.ts b/web/packages/media/magic-metadata.ts
index b88009ed87..17ed4d7ca7 100644
--- a/web/packages/media/magic-metadata.ts
+++ b/web/packages/media/magic-metadata.ts
@@ -7,19 +7,8 @@ import { z } from "zod/v4";
* information attached.
*
* See {@link RemoteMagicMetadata} for the corresponding type.
- *
- * [Note: Schema suffix for exported Zod schemas]
- *
- * Since this module exports both the Zod schema and the TypeScript type, to
- * avoid confusion the schema is suffixed by "Schema".
- *
- * This is a general pattern we follow in all cases where we need to export the
- * Zod schema so other modules can compose schema definitions. Such exports are
- * meant to be exceptions though; usually the schema should be internal to the
- * module (and so can have the same name as the TypeScript type without the need
- * for a disambiguating suffix).
*/
-export const RemoteMagicMetadataSchema = z.object({
+export const RemoteMagicMetadata = z.object({
version: z.number(),
count: z.number(),
data: z.string(),
@@ -37,11 +26,6 @@ export const RemoteMagicMetadataSchema = z.object({
*
* When decrypt these into specific local {@link MagicMetadata} instantiations
* before using and storing them on the client.
- *
- * See {@link RemoteMagicMetadataSchema} for the corresponding Zod schema. The
- * same structure is used to store the metadata for various kinds of objects
- * (files, collections), so this module exports both the TypeScript type and
- * also the Zod schema so that other modules can compose schema definitions.
*/
export interface RemoteMagicMetadata {
/**
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index 11633e2010..e576456eec 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -12,13 +12,12 @@ import { ensureMasterKeyFromSession } from "ente-base/session";
import {
CollectionSubType,
decryptRemoteCollection,
- RemoteCollectionSchema,
+ RemoteCollection,
type Collection,
type Collection2,
type CollectionNewParticipantRole,
type CollectionPrivateMagicMetadataData,
type CollectionType,
- type RemoteCollection,
} from "ente-media/collection";
import { type EnteFile } from "ente-media/file";
import { ItemVisibility } from "ente-media/file-metadata";
@@ -179,9 +178,8 @@ const postCollections = async (
body: JSON.stringify(collectionData),
});
ensureOk(res);
- return z
- .object({ collection: RemoteCollectionSchema })
- .parse(await res.json()).collection;
+ return z.object({ collection: RemoteCollection }).parse(await res.json())
+ .collection;
};
/**