chore: update prettier configuration for print width (#519)
* feat: update prettier configuration for print width * chore: apply code formatting to entire repository * fix: remove build files * fix: format issue --------- Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
export const createDefinition = <
|
||||
const TKeys extends string[],
|
||||
TOptions extends { defaultValue: TKeys[number] } | void,
|
||||
>(
|
||||
export const createDefinition = <const TKeys extends string[], TOptions extends { defaultValue: TKeys[number] } | void>(
|
||||
values: TKeys,
|
||||
options: TOptions,
|
||||
) => ({
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
import type { inferDefinitionType } from "./_definition";
|
||||
import { createDefinition } from "./_definition";
|
||||
|
||||
export const backgroundImageAttachments = createDefinition(
|
||||
["fixed", "scroll"],
|
||||
{ defaultValue: "fixed" },
|
||||
);
|
||||
export const backgroundImageRepeats = createDefinition(
|
||||
["repeat", "repeat-x", "repeat-y", "no-repeat"],
|
||||
{ defaultValue: "no-repeat" },
|
||||
);
|
||||
export const backgroundImageAttachments = createDefinition(["fixed", "scroll"], { defaultValue: "fixed" });
|
||||
export const backgroundImageRepeats = createDefinition(["repeat", "repeat-x", "repeat-y", "no-repeat"], {
|
||||
defaultValue: "no-repeat",
|
||||
});
|
||||
export const backgroundImageSizes = createDefinition(["cover", "contain"], {
|
||||
defaultValue: "cover",
|
||||
});
|
||||
|
||||
export type BackgroundImageAttachment = inferDefinitionType<
|
||||
typeof backgroundImageAttachments
|
||||
>;
|
||||
export type BackgroundImageRepeat = inferDefinitionType<
|
||||
typeof backgroundImageRepeats
|
||||
>;
|
||||
export type BackgroundImageSize = inferDefinitionType<
|
||||
typeof backgroundImageSizes
|
||||
>;
|
||||
export type BackgroundImageAttachment = inferDefinitionType<typeof backgroundImageAttachments>;
|
||||
export type BackgroundImageRepeat = inferDefinitionType<typeof backgroundImageRepeats>;
|
||||
export type BackgroundImageSize = inferDefinitionType<typeof backgroundImageSizes>;
|
||||
|
||||
@@ -12,113 +12,97 @@ export const integrationDefs = {
|
||||
sabNzbd: {
|
||||
name: "SABnzbd",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/sabnzbd.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/sabnzbd.png",
|
||||
category: ["useNetClient"],
|
||||
},
|
||||
nzbGet: {
|
||||
name: "NZBGet",
|
||||
secretKinds: [["username", "password"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/nzbget.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/nzbget.png",
|
||||
category: ["useNetClient"],
|
||||
},
|
||||
deluge: {
|
||||
name: "Deluge",
|
||||
secretKinds: [["password"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/deluge.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/deluge.png",
|
||||
category: ["downloadClient"],
|
||||
},
|
||||
transmission: {
|
||||
name: "Transmission",
|
||||
secretKinds: [["username", "password"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/transmission.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/transmission.png",
|
||||
category: ["downloadClient"],
|
||||
},
|
||||
qBittorrent: {
|
||||
name: "qBittorrent",
|
||||
secretKinds: [["username", "password"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/qbittorrent.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/qbittorrent.png",
|
||||
category: ["downloadClient"],
|
||||
},
|
||||
sonarr: {
|
||||
name: "Sonarr",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/sonarr.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/sonarr.png",
|
||||
category: ["calendar"],
|
||||
},
|
||||
radarr: {
|
||||
name: "Radarr",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/radarr.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/radarr.png",
|
||||
category: ["calendar"],
|
||||
},
|
||||
lidarr: {
|
||||
name: "Lidarr",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/lidarr.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/lidarr.png",
|
||||
category: ["calendar"],
|
||||
},
|
||||
readarr: {
|
||||
name: "Readarr",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/readarr.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/readarr.png",
|
||||
category: ["calendar"],
|
||||
},
|
||||
jellyfin: {
|
||||
name: "Jellyfin",
|
||||
secretKinds: [["username", "password"], ["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/jellyfin.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/jellyfin.png",
|
||||
category: ["mediaService"],
|
||||
},
|
||||
plex: {
|
||||
name: "Plex",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/plex.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/plex.png",
|
||||
category: ["mediaService"],
|
||||
},
|
||||
jellyseerr: {
|
||||
name: "Jellyseerr",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/jellyseerr.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/jellyseerr.png",
|
||||
category: ["mediaSearch", "mediaRequest"],
|
||||
},
|
||||
overseerr: {
|
||||
name: "Overseerr",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/overseerr.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/overseerr.png",
|
||||
category: ["mediaSearch", "mediaRequest"],
|
||||
},
|
||||
piHole: {
|
||||
name: "Pi-hole",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/pi-hole.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/pi-hole.png",
|
||||
category: ["dnsHole"],
|
||||
},
|
||||
adGuardHome: {
|
||||
name: "AdGuard Home",
|
||||
secretKinds: [["username", "password"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/adguard-home.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/adguard-home.png",
|
||||
category: ["dnsHole"],
|
||||
},
|
||||
homeAssistant: {
|
||||
name: "Home Assistant",
|
||||
secretKinds: [["apiKey"]],
|
||||
iconUrl:
|
||||
"https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/home-assistant.png",
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/png/home-assistant.png",
|
||||
category: [],
|
||||
},
|
||||
} satisfies Record<
|
||||
@@ -131,20 +115,16 @@ export const integrationDefs = {
|
||||
}
|
||||
>;
|
||||
|
||||
export const getIconUrl = (integration: IntegrationKind) =>
|
||||
integrationDefs[integration]?.iconUrl ?? null;
|
||||
export const getIconUrl = (integration: IntegrationKind) => integrationDefs[integration]?.iconUrl ?? null;
|
||||
|
||||
export const getIntegrationName = (integration: IntegrationKind) =>
|
||||
integrationDefs[integration].name;
|
||||
export const getIntegrationName = (integration: IntegrationKind) => integrationDefs[integration].name;
|
||||
|
||||
export const getDefaultSecretKinds = (
|
||||
integration: IntegrationKind,
|
||||
): IntegrationSecretKind[] => integrationDefs[integration]?.secretKinds[0];
|
||||
export const getDefaultSecretKinds = (integration: IntegrationKind): IntegrationSecretKind[] =>
|
||||
integrationDefs[integration]?.secretKinds[0];
|
||||
|
||||
export const getAllSecretKindOptions = (
|
||||
integration: IntegrationKind,
|
||||
): [IntegrationSecretKind[], ...IntegrationSecretKind[][]] =>
|
||||
integrationDefs[integration]?.secretKinds;
|
||||
): [IntegrationSecretKind[], ...IntegrationSecretKind[][]] => integrationDefs[integration]?.secretKinds;
|
||||
|
||||
export const integrationKinds = objectKeys(integrationDefs);
|
||||
|
||||
|
||||
@@ -20,14 +20,10 @@ const groupPermissionParents = {
|
||||
admin: ["board-full-access", "integration-full-access"],
|
||||
} satisfies Partial<Record<GroupPermissionKey, GroupPermissionKey[]>>;
|
||||
|
||||
export const getPermissionsWithParents = (
|
||||
permissions: GroupPermissionKey[],
|
||||
): GroupPermissionKey[] => {
|
||||
export const getPermissionsWithParents = (permissions: GroupPermissionKey[]): GroupPermissionKey[] => {
|
||||
const res = permissions.map((permission) => {
|
||||
return objectEntries(groupPermissionParents)
|
||||
.filter(([_key, value]: [string, GroupPermissionKey[]]) =>
|
||||
value.includes(permission),
|
||||
)
|
||||
.filter(([_key, value]: [string, GroupPermissionKey[]]) => value.includes(permission))
|
||||
.map(([key]) => getPermissionsWithParents([key]))
|
||||
.flat();
|
||||
});
|
||||
@@ -35,13 +31,9 @@ export const getPermissionsWithParents = (
|
||||
return permissions.concat(res.flat());
|
||||
};
|
||||
|
||||
const getPermissionsInner = (
|
||||
permissionSet: Set<GroupPermissionKey>,
|
||||
permissions: GroupPermissionKey[],
|
||||
) => {
|
||||
const getPermissionsInner = (permissionSet: Set<GroupPermissionKey>, permissions: GroupPermissionKey[]) => {
|
||||
permissions.forEach((permission) => {
|
||||
const children =
|
||||
groupPermissionParents[permission as keyof typeof groupPermissionParents];
|
||||
const children = groupPermissionParents[permission as keyof typeof groupPermissionParents];
|
||||
if (children) {
|
||||
getPermissionsInner(permissionSet, children);
|
||||
}
|
||||
@@ -50,9 +42,7 @@ const getPermissionsInner = (
|
||||
});
|
||||
};
|
||||
|
||||
export const getPermissionsWithChildren = (
|
||||
permissions: GroupPermissionKey[],
|
||||
) => {
|
||||
export const getPermissionsWithChildren = (permissions: GroupPermissionKey[]) => {
|
||||
const permissionSet = new Set<GroupPermissionKey>();
|
||||
getPermissionsInner(permissionSet, permissions);
|
||||
return Array.from(permissionSet);
|
||||
@@ -66,19 +56,14 @@ export type GroupPermissionKey = {
|
||||
: key;
|
||||
}[keyof GroupPermissions];
|
||||
|
||||
export const groupPermissionKeys = objectKeys(groupPermissions).reduce(
|
||||
(acc, key) => {
|
||||
const item = groupPermissions[key];
|
||||
if (typeof item !== "boolean") {
|
||||
acc.push(
|
||||
...item.map((subKey) => `${key}-${subKey}` as GroupPermissionKey),
|
||||
);
|
||||
} else {
|
||||
acc.push(key as GroupPermissionKey);
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
[] as GroupPermissionKey[],
|
||||
);
|
||||
export const groupPermissionKeys = objectKeys(groupPermissions).reduce((acc, key) => {
|
||||
const item = groupPermissions[key];
|
||||
if (typeof item !== "boolean") {
|
||||
acc.push(...item.map((subKey) => `${key}-${subKey}` as GroupPermissionKey));
|
||||
} else {
|
||||
acc.push(key as GroupPermissionKey);
|
||||
}
|
||||
return acc;
|
||||
}, [] as GroupPermissionKey[]);
|
||||
|
||||
export type BoardPermission = (typeof boardPermissions)[number];
|
||||
|
||||
@@ -1,47 +1,22 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import type { GroupPermissionKey } from "../permissions";
|
||||
import {
|
||||
getPermissionsWithChildren,
|
||||
getPermissionsWithParents,
|
||||
} from "../permissions";
|
||||
import { getPermissionsWithChildren, getPermissionsWithParents } from "../permissions";
|
||||
|
||||
describe("getPermissionsWithParents should return the correct permissions", () => {
|
||||
test.each([
|
||||
[
|
||||
["board-view-all"],
|
||||
["board-view-all", "board-modify-all", "board-full-access", "admin"],
|
||||
],
|
||||
[["board-view-all"], ["board-view-all", "board-modify-all", "board-full-access", "admin"]],
|
||||
[["board-modify-all"], ["board-modify-all", "board-full-access", "admin"]],
|
||||
[["board-create"], ["board-create", "board-full-access", "admin"]],
|
||||
[["board-full-access"], ["board-full-access", "admin"]],
|
||||
[
|
||||
["integration-use-all"],
|
||||
[
|
||||
"integration-use-all",
|
||||
"integration-interact-all",
|
||||
"integration-full-access",
|
||||
"admin",
|
||||
],
|
||||
],
|
||||
[
|
||||
["integration-create"],
|
||||
["integration-create", "integration-full-access", "admin"],
|
||||
],
|
||||
[
|
||||
["integration-interact-all"],
|
||||
["integration-interact-all", "integration-full-access", "admin"],
|
||||
],
|
||||
[["integration-use-all"], ["integration-use-all", "integration-interact-all", "integration-full-access", "admin"]],
|
||||
[["integration-create"], ["integration-create", "integration-full-access", "admin"]],
|
||||
[["integration-interact-all"], ["integration-interact-all", "integration-full-access", "admin"]],
|
||||
[["integration-full-access"], ["integration-full-access", "admin"]],
|
||||
[["admin"], ["admin"]],
|
||||
] satisfies [GroupPermissionKey[], GroupPermissionKey[]][])(
|
||||
"expect %s to return %s",
|
||||
(input, expectedOutput) => {
|
||||
expect(getPermissionsWithParents(input)).toEqual(
|
||||
expect.arrayContaining(expectedOutput),
|
||||
);
|
||||
},
|
||||
);
|
||||
] satisfies [GroupPermissionKey[], GroupPermissionKey[]][])("expect %s to return %s", (input, expectedOutput) => {
|
||||
expect(getPermissionsWithParents(input)).toEqual(expect.arrayContaining(expectedOutput));
|
||||
});
|
||||
});
|
||||
|
||||
describe("getPermissionsWithChildren should return the correct permissions", () => {
|
||||
@@ -49,24 +24,11 @@ describe("getPermissionsWithChildren should return the correct permissions", ()
|
||||
[["board-view-all"], ["board-view-all"]],
|
||||
[["board-modify-all"], ["board-view-all", "board-modify-all"]],
|
||||
[["board-create"], ["board-create"]],
|
||||
[
|
||||
["board-full-access"],
|
||||
["board-full-access", "board-modify-all", "board-view-all"],
|
||||
],
|
||||
[["board-full-access"], ["board-full-access", "board-modify-all", "board-view-all"]],
|
||||
[["integration-use-all"], ["integration-use-all"]],
|
||||
[["integration-create"], ["integration-create"]],
|
||||
[
|
||||
["integration-interact-all"],
|
||||
["integration-interact-all", "integration-use-all"],
|
||||
],
|
||||
[
|
||||
["integration-full-access"],
|
||||
[
|
||||
"integration-full-access",
|
||||
"integration-interact-all",
|
||||
"integration-use-all",
|
||||
],
|
||||
],
|
||||
[["integration-interact-all"], ["integration-interact-all", "integration-use-all"]],
|
||||
[["integration-full-access"], ["integration-full-access", "integration-interact-all", "integration-use-all"]],
|
||||
[
|
||||
["admin"],
|
||||
[
|
||||
@@ -79,12 +41,7 @@ describe("getPermissionsWithChildren should return the correct permissions", ()
|
||||
"integration-use-all",
|
||||
],
|
||||
],
|
||||
] satisfies [GroupPermissionKey[], GroupPermissionKey[]][])(
|
||||
"expect %s to return %s",
|
||||
(input, expectedOutput) => {
|
||||
expect(getPermissionsWithChildren(input)).toEqual(
|
||||
expect.arrayContaining(expectedOutput),
|
||||
);
|
||||
},
|
||||
);
|
||||
] satisfies [GroupPermissionKey[], GroupPermissionKey[]][])("expect %s to return %s", (input, expectedOutput) => {
|
||||
expect(getPermissionsWithChildren(input)).toEqual(expect.arrayContaining(expectedOutput));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,2 @@
|
||||
export const widgetKinds = [
|
||||
"clock",
|
||||
"weather",
|
||||
"app",
|
||||
"iframe",
|
||||
"video",
|
||||
"notebook",
|
||||
] as const;
|
||||
export const widgetKinds = ["clock", "weather", "app", "iframe", "video", "notebook"] as const;
|
||||
export type WidgetKind = (typeof widgetKinds)[number];
|
||||
|
||||
Reference in New Issue
Block a user