0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/util/github/graphql/util.ts
2024-08-19 13:15:27 +00:00

27 lines
740 B
TypeScript

import type { DurationLikeObject } from 'luxon';
import { DateTime } from 'luxon';
export function prepareQuery(payloadQuery: string): string {
return `
query($owner: String!, $name: String!, $cursor: String, $count: Int!) {
repository(owner: $owner, name: $name) {
isRepoPrivate: isPrivate
payload: ${payloadQuery}
}
}
`;
}
/**
* Tells whether the time `duration` is expired starting
* from the `date` (ISO date format) at the moment of `now`.
*/
export function isDateExpired(
currentTime: DateTime,
initialTimestamp: string,
duration: DurationLikeObject,
): boolean {
const expiryTime = DateTime.fromISO(initialTimestamp).plus(duration).toUTC();
return currentTime >= expiryTime;
}