Skip to content

Commit

Permalink
feat(core): add optional upload.timeout to config
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Jan 24, 2024
1 parent 173bd2f commit fdc3f58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/lib/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { jsonReportToGql } from './implementation/json-to-gql';
import { normalizePersistConfig } from './normalize';
import { GlobalOptions } from './types';

export type UploadOptions = { upload: Required<UploadConfig> } & {
export type UploadOptions = { upload: UploadConfig } & {
persist: Required<PersistConfig>;
} & GlobalOptions;

Expand All @@ -21,7 +21,7 @@ export async function upload(
if (!options.upload) {
throw new Error('upload config must be set');
}
const { apiKey, server, organization, project } = options.upload;
const { apiKey, server, organization, project, timeout } = options.upload;
const report: Report = await loadReport({
...persist,
format: 'json',
Expand All @@ -38,5 +38,5 @@ export async function upload(
...jsonReportToGql(report),
};

return uploadFn({ apiKey, server, data });
return uploadFn({ apiKey, server, data, timeout });
}
5 changes: 5 additions & 0 deletions packages/models/src/lib/upload-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export const uploadConfigSchema = z.object({
}),
organization: slugSchema('Organization slug from Code PushUp portal'),
project: slugSchema('Project slug from Code PushUp portal'),
timeout: z
.number({ description: 'Request timeout in minutes (default is 5)' })
.positive()
.int()
.optional(),
});

export type UploadConfig = z.infer<typeof uploadConfigSchema>;

0 comments on commit fdc3f58

Please sign in to comment.