Skip to content

Commit d33acb0

Browse files
committed
refactor(types): remove unused fields and improve type definitions
Remove unused fields such as `password`, `allowDownloadProtectedFile`, `temporaryTokenDuration`, `privateIndex`, and `SITE_PASSWORD` from various schema definitions to simplify the codebase and reduce complexity. This cleanup helps in maintaining a leaner codebase by eliminating unnecessary fields that are no longer required. Additionally, improve type definitions for better readability and maintainability, such as formatting the `position` enum for better clarity.
1 parent 1777139 commit d33acb0

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/types/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ type ActionResponseError = {
66
success: false;
77
error: string;
88
};
9-
export type ActionResponseSchema<T = undefined> = (ActionResponseSuccess<T> | ActionResponseError) & {
9+
export type ActionResponseSchema<T = undefined> = (
10+
| ActionResponseSuccess<T>
11+
| ActionResponseError
12+
) & {
1013
message: string;
1114
};

src/types/schema.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,10 @@ export const Schema_v1_Config = z.object({
5757
searchResult: z.number().positive(),
5858

5959
specialFile: z.object({
60-
password: z.string(),
6160
readme: z.string(),
6261
banner: z.string(),
6362
}),
6463
hiddenFiles: z.array(z.string()),
65-
66-
allowDownloadProtectedFile: z.boolean(),
67-
temporaryTokenDuration: z.number().positive(),
6864
maxFileSize: z.number().positive(),
6965
}),
7066

@@ -77,8 +73,6 @@ export const Schema_v1_Config = z.object({
7773

7874
defaultAccentColor: z.string(),
7975

80-
privateIndex: z.boolean().optional().default(false),
81-
8276
navbarItems: z.array(
8377
z.object({
8478
icon: z.string(),
@@ -104,14 +98,10 @@ const Schema_Config_API = z
10498
streamMaxSize: z.coerce.number(),
10599

106100
specialFile: z.object({
107-
password: z.string(),
108101
readme: z.string(),
109102
banner: z.string(),
110103
}),
111104
hiddenFiles: z.array(z.string()),
112-
113-
allowDownloadProtectedFile: z.coerce.boolean(),
114-
temporaryTokenDuration: z.coerce.number().positive(),
115105
maxFileSize: z.coerce.number(),
116106
})
117107
.refine(
@@ -136,12 +126,16 @@ const Schema_v2_3_Config_Site = z.object({
136126

137127
footer: z.string().array().optional(),
138128

139-
privateIndex: z.boolean().optional().default(false),
140129
breadcrumbMax: z.number(),
141130

142131
toaster: z
143132
.object({
144-
position: z.enum(["top-left", "top-right", "bottom-left", "bottom-right"]),
133+
position: z.enum([
134+
"top-left",
135+
"top-right",
136+
"bottom-left",
137+
"bottom-right",
138+
]),
145139
duration: z.number().positive(),
146140
})
147141
.optional()
@@ -190,12 +184,16 @@ export const Schema_Config_Site = z.object({
190184
.or(z.enum(["s", "ms"]))
191185
.default("ms"),
192186

193-
privateIndex: z.coerce.boolean().optional().default(false),
194187
breadcrumbMax: z.coerce.number(),
195188

196189
toaster: z
197190
.object({
198-
position: z.enum(["top-left", "top-right", "bottom-left", "bottom-right"]),
191+
position: z.enum([
192+
"top-left",
193+
"top-right",
194+
"bottom-left",
195+
"bottom-right",
196+
]),
199197
duration: z.coerce.number().positive(),
200198
})
201199
.optional()
@@ -252,7 +250,6 @@ export const Schema_Config = z.object({
252250
export const Schema_App_Configuration_Env = z.object({
253251
GD_SERVICE_B64: z.string(),
254252
ENCRYPTION_KEY: z.string(),
255-
SITE_PASSWORD: z.string().optional(),
256253
NEXT_PUBLIC_DOMAIN: z.string().optional(),
257254
});
258255

@@ -290,10 +287,12 @@ export const Schema_App_Configuration = z.object({
290287
),
291288
});
292289

293-
export type ConfigurationCategory = keyof z.infer<typeof Schema_App_Configuration>;
294-
export type ConfigurationKeys<T extends keyof z.infer<typeof Schema_App_Configuration>> = keyof z.infer<
290+
export type ConfigurationCategory = keyof z.infer<
295291
typeof Schema_App_Configuration
296-
>[T];
292+
>;
293+
export type ConfigurationKeys<
294+
T extends keyof z.infer<typeof Schema_App_Configuration>,
295+
> = keyof z.infer<typeof Schema_App_Configuration>[T];
297296
export type ConfigurationValue<
298297
T extends keyof z.infer<typeof Schema_App_Configuration>,
299298
K extends keyof z.infer<typeof Schema_App_Configuration>[T],

0 commit comments

Comments
 (0)