({
role,
databaseResources,
expirationTimestampInMS,
}: {
role: string;
databaseResources?: DatabaseResource[];
expirationTimestampInMS?: number;
})
| 82 | }; |
| 83 | |
| 84 | const buildConditionTitle = ({ |
| 85 | role, |
| 86 | databaseResources, |
| 87 | expirationTimestampInMS, |
| 88 | }: { |
| 89 | role: string; |
| 90 | databaseResources?: DatabaseResource[]; |
| 91 | expirationTimestampInMS?: number; |
| 92 | }): string => { |
| 93 | const title = [displayRoleTitle(role)]; |
| 94 | |
| 95 | let conditionSuffix = ""; |
| 96 | if (databaseResources !== undefined) { |
| 97 | if (databaseResources.length === 0) { |
| 98 | conditionSuffix = `All databases`; |
| 99 | } else if (databaseResources.length <= 3) { |
| 100 | const databaseResourceNames = databaseResources.map((ds) => |
| 101 | getDatabaseResourceName(ds) |
| 102 | ); |
| 103 | conditionSuffix = `${databaseResourceNames.join(", ")}`; |
| 104 | } else { |
| 105 | const firstDatabaseResourceName = getDatabaseResourceName( |
| 106 | head(databaseResources)! |
| 107 | ); |
| 108 | conditionSuffix = `${firstDatabaseResourceName} and ${ |
| 109 | databaseResources.length - 1 |
| 110 | } more`; |
| 111 | } |
| 112 | } |
| 113 | if (conditionSuffix) { |
| 114 | title.push(conditionSuffix); |
| 115 | } |
| 116 | |
| 117 | if (expirationTimestampInMS) { |
| 118 | title.push( |
| 119 | `${dayjs().format("L")}-${dayjs(expirationTimestampInMS).format("L")}` |
| 120 | ); |
| 121 | } |
| 122 | |
| 123 | return title.join(" "); |
| 124 | }; |
| 125 | |
| 126 | export const buildConditionExpr = ({ |
| 127 | title, |
no test coverage detected