Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_identities_getIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const registerV1IdentitiesGetIdentity = (app: App) =>
const { identityId, externalId } = c.req.valid("query");
const { db } = c.get("services");

if (!identityId && !externalId) {
if (!(identityId || externalId)) {
throw new UnkeyApiError({
code: "BAD_REQUEST",
message: "Provide either identityId or externalId",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_identities_updateIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const registerV1IdentitiesUpdateIdentity = (app: App) =>

const { db, cache } = c.get("services");

if (!req.identityId && !req.externalId) {
if (!(req.identityId || req.externalId)) {
throw new UnkeyApiError({
code: "BAD_REQUEST",
message: "Provide either identityId or externalId",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_keys_getVerifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export const registerV1KeysGetVerifications = (app: App) =>
function transformData(
data: VerificationTimeseriesDataPoint[] | undefined,
): CacheNamespaces["verificationsByKeyId"] {
if (!data || !data.length) {
if (!data?.length) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_migrations_createKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export const registerV1MigrationsCreateKeys = (app: App) =>
});
}

if (!key.hash && !key.plaintext) {
if (!(key.hash || key.plaintext)) {
throw new UnkeyApiError({
code: "BAD_REQUEST",
message: "provide either `hash` or `plaintext`",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_ratelimits_deleteOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const registerV1RatelimitDeleteOverride = (app: App) =>
c,
buildUnkeyQuery(({ or }) => or("*", "ratelimit.*.delete_override")),
);
if (!namespaceId && !namespaceName) {
if (!(namespaceId || namespaceName)) {
throw new UnkeyApiError({
code: "BAD_REQUEST",
message: "You must provide a namespaceId or a namespaceName",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_ratelimits_getOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const registerV1RatelimitGetOverride = (app: App) =>
message: "Missing required permission: ratelimit.*.read_override",
});
}
if (!namespaceId && !namespaceName) {
if (!(namespaceId || namespaceName)) {
throw new UnkeyApiError({
code: "BAD_REQUEST",
message: "You must provide a namespaceId or a namespaceName",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_ratelimits_listOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const registerV1RatelimitListOverrides = (app: App) =>
app.openapi(route, async (c) => {
const { namespaceId, namespaceName, limit, cursor } = c.req.valid("query");
const { db } = c.get("services");
if (!namespaceId && !namespaceName) {
if (!(namespaceId || namespaceName)) {
throw new UnkeyApiError({
code: "BAD_REQUEST",
message: "You must provide a namespaceId or a namespaceName",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_ratelimits_setOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export type V1RatelimitSetOverrideResponse = z.infer<
export const registerV1RatelimitSetOverride = (app: App) =>
app.openapi(route, async (c) => {
const req = c.req.valid("json");
if (!req.namespaceId && !req.namespaceName) {
if (!(req.namespaceId || req.namespaceName)) {
throw new UnkeyApiError({
code: "BAD_REQUEST",
message: "You must provide a namespaceId or a namespaceName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ export const ExpirationSetup = () => {

// Calculate date for showing warning about close expiry (less than 1 hour)
const isExpiringVerySoon =
currentExpiryDate &&
new Date(currentExpiryDate).getTime() - new Date().getTime() < 60 * 60 * 1000;
currentExpiryDate && new Date(currentExpiryDate).getTime() - Date.now() < 60 * 60 * 1000;

const getExpiryDescription = () => {
if (isExpiringVerySoon) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const MetadataSetup = () => {
rows={15}
{...register("metadata.data", {
validate: (value) => {
if (metadataEnabled && (!value || !validateJSON(value))) {
if (metadataEnabled && !(value && validateJSON(value))) {
return "Must be valid JSON";
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const expirationValidationSchema = z.object({
})
.refine(
(date) => {
const minDate = new Date(new Date().getTime() + 2 * 60000);
const minDate = new Date(Date.now() + 2 * 60000);
return date >= minDate;
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export const formValuesToApiInput = (formValues: FormValues, keyAuthId: string):
export const isFeatureEnabled = (sectionId: SectionName, values: FormValues): boolean => {
switch (sectionId) {
case "metadata":
return values.metadata?.enabled || false;
return values.metadata?.enabled;
case "ratelimit":
return values.ratelimit?.enabled || false;
return values.ratelimit?.enabled;
case "credits":
return values.limit?.enabled || false;
return values.limit?.enabled;
case "expiration":
return values.expiration?.enabled || false;
return values.expiration?.enabled;
case "general":
return true;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export const LogsDateTime = () => {
}}
initialTitle={title ?? ""}
onSuggestionChange={setTitle}
customOptions={DEFAULT_OPTIONS.filter(
(option) => !option.value || !option.value.endsWith("m"),
)}
customOptions={DEFAULT_OPTIONS.filter((option) => !option.value?.endsWith("m"))}
>
<div className="group">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const useFilters = () => {
const activeFilters: KeysOverviewFilterValue[] = [];

for (const [field, value] of Object.entries(searchParams)) {
if (!Array.isArray(value) || !["keyIds", "names", "identities", "outcomes"].includes(field)) {
if (
!(Array.isArray(value) && ["keyIds", "names", "identities", "outcomes"].includes(field))
) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/(app)/apis/[apiId]/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type ApiLayoutData = {

export const fetchApiAndWorkspaceDataFromDb = async (apiId: string): Promise<ApiLayoutData> => {
const { orgId } = await getAuth();
if (!apiId || !orgId) {
if (!(apiId && orgId)) {
console.error("fetchApiLayoutDataFromDb: apiId or orgId is missing");
notFound();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export const LogsDateTime = () => {
}}
initialTitle={title ?? ""}
onSuggestionChange={setTitle}
customOptions={DEFAULT_OPTIONS.filter(
(option) => !option.value || !option.value.endsWith("m"),
)}
customOptions={DEFAULT_OPTIONS.filter((option) => !option.value?.endsWith("m"))}
>
<div className="group">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const EditExternalId = ({
return;
}

if (!isConfirmPopoverOpen && !open) {
if (!(isConfirmPopoverOpen || open)) {
onClose();
}
};
Expand Down Expand Up @@ -99,7 +99,7 @@ export const EditExternalId = ({
className="rounded-lg flex-1"
loading={updateKeyOwner.isLoading}
onClick={handleSubmit}
disabled={!originalIdentityId && !selectedIdentityId}
disabled={!(originalIdentityId || selectedIdentityId)}
>
Update External ID
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const BatchEditExternalId = ({
return;
}

if (!isConfirmPopoverOpen && !open) {
if (!(isConfirmPopoverOpen || open)) {
onClose();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function useKeysListQuery({ keyAuthId }: UseKeysListQueryParams) {
};

filters.forEach((filter) => {
if (!keysListFilterFieldNames.includes(filter.field) || !params[filter.field]) {
if (!(keysListFilterFieldNames.includes(filter.field) && params[filter.field])) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const KeysList = ({
) : (
<>
{/* Show icon when not selected and not hovered */}
{!isSelected && !isHovered && (
{!(isSelected || isHovered) && (
// biome-ignore lint/complexity/noUselessFragments: <explanation>
<>
{identity ? (
Expand Down Expand Up @@ -279,7 +279,7 @@ export const KeysList = ({
}

// Early exit if we already found a mix
if (!allEnabled && !allDisabled) {
if (!(allEnabled || allDisabled)) {
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default async function RolePage(props: Props) {
},
},
});
if (!role || !role.workspace) {
if (!role?.workspace) {
return notFound();
}
if (role.workspace.orgId !== orgId) {
Expand Down
5 changes: 3 additions & 2 deletions apps/dashboard/app/(app)/settings/billing/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ export const Client: React.FC<Props> = (props) => {
props.subscription &&
["active", "trialing"].includes(props.subscription.status) &&
!props.subscription.cancelAt;
const isFreeTier =
!props.subscription || !["active", "trialing"].includes(props.subscription.status);
const isFreeTier = !(
props.subscription && ["active", "trialing"].includes(props.subscription.status)
);
const selectedProductIndex = allowUpdate
? props.products.findIndex((p) => p.id === props.currentProductId)
: -1;
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/(app)/settings/team/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function TeamPageClient({ team }: { team: boolean }) {
const [tab, setTab] = useState<Tab>("members");

// make typescript happy
if (!user || !organization || !userMemberships || !currentOrgMembership) {
if (!(user && organization && userMemberships && currentOrgMembership)) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/(app)/settings/team/invite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const InviteButton = ({ user, organization, ...rest }: InviteButtonProps)
});

// If user or organization isn't available yet, return null or a loading state
if (!user!.orgId || !organization) {
if (!(user!.orgId && organization)) {
return null;
}

Expand Down
6 changes: 4 additions & 2 deletions apps/dashboard/app/integrations/vercel/callback/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ export const Client: React.FC<Props> = ({
});
const router = useRouter();

const disabled =
!projectId || !(selectedApis.development || selectedApis.preview || selectedApis.production);
const disabled = !(
projectId &&
(selectedApis.development || selectedApis.preview || selectedApis.production)
);

const create = trpc.vercel.setupProject.useMutation({
onSuccess: () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/new/create-ratelimit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const CreateRatelimit: React.FC<Props> = async (props) => {
const user = await getCurrentUser();

// make typescript happy
if (!user || !user.orgId || !user.role) {
if (!(user?.orgId && user.role)) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/components/logs/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function LogsTimeseriesBarChart({
return;
}
if (selection.start && selection.end && onSelectionChange) {
if (!selection.startTimestamp || !selection.endTimestamp) {
if (!(selection.startTimestamp && selection.endTimestamp)) {
return;
}

Expand Down Expand Up @@ -154,7 +154,7 @@ export function LogsTimeseriesBarChart({
strokeOpacity: 0.7,
}}
content={({ active, payload, label }) => {
if (!active || !payload?.length || payload?.[0]?.payload.total === 0) {
if (!(active && payload?.length) || payload?.[0]?.payload.total === 0) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ResizablePanel = ({

const handleMouseMove = useCallback(
(e: MouseEvent) => {
if (!isDragging || !panelRef.current) {
if (!(isDragging && panelRef.current)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function useBookmarkedFilters<T extends FilterValue>({
}, [localStorageName]);

useEffect(() => {
if (!filters.length || !isBrowser) {
if (!(filters.length && isBrowser)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const OverviewAreaChart = ({
};

const handleMouseMove = (e: any) => {
if (!enableSelection || !selection.start) {
if (!(enableSelection && selection.start)) {
return;
}
const timestamp = e?.activePayload?.[0]?.payload?.originalTimestamp;
Expand All @@ -95,7 +95,7 @@ export const OverviewAreaChart = ({
return;
}
if (selection.start && selection.end && onSelectionChange) {
if (!selection.startTimestamp || !selection.endTimestamp) {
if (!(selection.startTimestamp && selection.endTimestamp)) {
return;
}
const [start, end] = [selection.startTimestamp, selection.endTimestamp].sort((a, b) => a - b);
Expand Down Expand Up @@ -230,7 +230,7 @@ export const OverviewAreaChart = ({
strokeOpacity: 0.7,
}}
content={({ active, payload, label }) => {
if (!active || !payload?.length) {
if (!(active && payload?.length)) {
return null;
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function OverviewBarChart({
return;
}
if (selection.start && selection.end && onSelectionChange) {
if (!selection.startTimestamp || !selection.endTimestamp) {
if (!(selection.startTimestamp && selection.endTimestamp)) {
return;
}
const [start, end] = [selection.startTimestamp, selection.endTimestamp].sort((a, b) => a - b);
Expand Down Expand Up @@ -188,7 +188,7 @@ export function OverviewBarChart({
strokeOpacity: 0.7,
}}
content={({ active, payload, label }) => {
if (!active || !payload?.length || payload?.[0]?.payload.total === 0) {
if (!(active && payload?.length) || payload?.[0]?.payload.total === 0) {
return null;
}
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/components/logs/overview-charts/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function createTimeIntervalFormatter(data?: TimeseriesData[], timeFormat
const formattedCurrentTimestamp = format(new Date(currentTimestamp), timeFormat);

// If we don't have necessary data, fallback to displaying just the current point
if (!currentTimestamp || !data?.length) {
if (!(currentTimestamp && data?.length)) {
return (
<div>
<span className="font-mono text-accent-9 text-xs px-4">{formattedCurrentTimestamp}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function QueriesPopover<T extends FilterValue, U extends QueryParamsTypes
const [isDisabled, setIsDisabled] = useState(false);

useKeyboardShortcut("q", () => {
if (!open && !isDisabled) {
if (!(open || isDisabled)) {
setOpen(true);
setSelectedQueryIndex(0);
setFocusedTabIndex(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const parseAsSortArray = <TColumn extends string>(): Parser<
try {
return str.split(",").map((item) => {
const [column, direction] = item.split(":");
if (!column || !direction) {
if (!(column && direction)) {
throw new Error("Invalid sort format");
}
if (!VALID_DIRECTIONS.includes(direction as SortDirection)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const NestedNavItem = ({
const hasChildren = item.items && item.items.length > 0;

useLayoutEffect(() => {
if (!hasChildren || !pathname) {
if (!(hasChildren && pathname)) {
return;
}

Expand Down
Loading
Loading