diff --git a/packages/api/src/services/library_item.ts b/packages/api/src/services/library_item.ts index ee284a3b1..4264fbc1a 100644 --- a/packages/api/src/services/library_item.ts +++ b/packages/api/src/services/library_item.ts @@ -39,7 +39,6 @@ enum HasFilter { export interface SearchArgs { from?: number size?: number - sort?: Sort includePending?: boolean | null includeDeleted?: boolean includeContent?: boolean @@ -389,14 +388,14 @@ export const buildQuery = ( // validate date if (start && start !== '*') { startDate = new Date(start) - if (!startDate.getTime()) { + if (isNaN(startDate.getTime())) { throw new Error('Invalid start date.') } } if (end && end !== '*') { endDate = new Date(end) - if (!endDate.getTime()) { + if (isNaN(endDate.getTime())) { throw new Error('Invalid end date.') } } @@ -695,7 +694,7 @@ export const searchLibraryItems = async ( const count = await queryBuilder.getCount() // default order by saved at descending - if (orders.length === 0) { + if (!orders.find((order) => order.by === 'library_item.saved_at')) { orders.push({ by: 'library_item.saved_at', order: SortOrder.DESCENDING, diff --git a/packages/integration-handler/src/index.ts b/packages/integration-handler/src/index.ts index fb53aa4f3..64048c041 100644 --- a/packages/integration-handler/src/index.ts +++ b/packages/integration-handler/src/index.ts @@ -97,7 +97,7 @@ export const exporter = Sentry.GCPFunction.wrapHttpFunction( const client = getIntegrationClient(integrationName) // get paginated items from the backend - const first = '50' + const first = 50 let hasMore = true let after = '0' while (hasMore) { diff --git a/packages/integration-handler/src/item.ts b/packages/integration-handler/src/item.ts index cb535904c..dd3bde5ae 100644 --- a/packages/integration-handler/src/item.ts +++ b/packages/integration-handler/src/item.ts @@ -44,7 +44,7 @@ export const search = async ( token: string, highlightOnly: boolean, updatedSince: Date, - first = '50', + first = 50, after = '0' ): Promise => { const query = `updated:${updatedSince.toISOString()} ${