Skip to content

Commit ad4caec

Browse files
committed
Use const functions + validate max timeout
1 parent abbe08b commit ad4caec

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/api/lib/api-client/api-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const requestOptionsSchema = z.object({
2020
versionOverride: z.string().nonempty().optional().refine((version) => !version || isValidApiVersion(version), {
2121
message: "Invalid API version format. Expected format is 'yyyy-mm' with month as one of '01', '04', '07', or '10'.",
2222
}),
23-
timeoutMs: z.number().positive().optional(),
23+
timeoutMs: z.number().positive().max(60_000).optional(),
2424
})
2525

2626
export type RequestOptions = z.infer<typeof requestOptionsSchema>;

packages/api/lib/api-client/middleware/file-upload.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const isFile = (value: unknown): value is File | Blob => {
6767
/**
6868
* Checks if variables contain any File or Blob objects
6969
*/
70-
function hasFiles(variables: Variables | undefined): boolean {
70+
const hasFiles = (variables: Variables | undefined): boolean => {
7171
if (!variables) {
7272
return false;
7373
}
@@ -96,10 +96,10 @@ function hasFiles(variables: Variables | undefined): boolean {
9696
* @param path - Current path in the object (for building variable paths)
9797
* @returns Object with cleaned variables (files replaced with null) and file mappings
9898
*/
99-
function extractFiles(
99+
const extractFiles = (
100100
variables: Variables,
101101
path = 'variables'
102-
): { cleanedVariables: Variables; files: FileEntry[] } {
102+
): { cleanedVariables: Variables; files: FileEntry[] } => {
103103
const files: FileEntry[] = [];
104104

105105
const processValue = (value: unknown, currentPath: string): unknown => {
@@ -131,7 +131,7 @@ function extractFiles(
131131
* Creates a FormData object for GraphQL multipart file upload requests
132132
* following the GraphQL multipart request specification.
133133
*/
134-
function createMultipartFormData(query: string, variables: Variables, files: FileEntry[]): FormData {
134+
const createMultipartFormData = (query: string, variables: Variables, files: FileEntry[]): FormData => {
135135
const formData = new FormData();
136136

137137
formData.append('query', query);

0 commit comments

Comments
 (0)