From 964fdf171b57af8a1a338ff6d5be54b05373f1ef Mon Sep 17 00:00:00 2001
From: Jens Langhammer
Date: Sun, 1 Jan 2023 23:32:05 +0100
Subject: [PATCH] web: add check compile test to prevent compile
errors/warnings
Signed-off-by: Jens Langhammer
---
.github/workflows/ci-web.yml | 16 ++++++++++++++++
Makefile | 5 ++++-
web/package.json | 1 +
web/src/admin/flows/utils.ts | 4 ++++
web/src/admin/outposts/OutpostForm.ts | 4 ++++
web/src/admin/outposts/OutpostListPage.ts | 2 ++
.../admin/providers/proxy/ProxyProviderForm.ts | 2 ++
.../providers/proxy/ProxyProviderViewPage.ts | 4 ++++
.../admin/sources/oauth/OAuthSourceViewPage.ts | 7 ++++++-
web/src/admin/sources/oauth/utils.ts | 2 ++
web/src/admin/tokens/TokenListPage.ts | 2 ++
web/src/elements/Diagram.ts | 5 ++++-
web/src/elements/table/Table.ts | 2 +-
13 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/ci-web.yml b/.github/workflows/ci-web.yml
index fa49489ec..8cfe89335 100644
--- a/.github/workflows/ci-web.yml
+++ b/.github/workflows/ci-web.yml
@@ -27,6 +27,22 @@ jobs:
- name: Eslint
working-directory: web/
run: npm run lint
+ lint-build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3.5.1
+ with:
+ node-version: '16'
+ cache: 'npm'
+ cache-dependency-path: web/package-lock.json
+ - working-directory: web/
+ run: npm ci
+ - name: Generate API
+ run: make gen-client-ts
+ - name: TSC
+ working-directory: web/
+ run: npm run tsc
lint-prettier:
runs-on: ubuntu-latest
steps:
diff --git a/Makefile b/Makefile
index 7e92f75b1..3a914ad03 100644
--- a/Makefile
+++ b/Makefile
@@ -126,7 +126,7 @@ gen: gen-build gen-clean gen-client-ts
web-build: web-install
cd web && npm run build
-web: web-lint-fix web-lint
+web: web-lint-fix web-lint web-check-compile
web-install:
cd web && npm ci
@@ -144,6 +144,9 @@ web-lint:
cd web && npm run lint
cd web && npm run lit-analyse
+web-check-compile:
+ cd web && npm run tsc
+
web-extract:
cd web && npm run extract
diff --git a/web/package.json b/web/package.json
index 0effe8f88..6613807f9 100644
--- a/web/package.json
+++ b/web/package.json
@@ -12,6 +12,7 @@
"lit-analyse": "lit-analyzer src",
"prettier-check": "prettier --check .",
"prettier": "prettier --write .",
+ "tsc": "tsc --strict --noEmit",
"background-image": "npx @squoosh/cli -d src/assets/images --resize '{\"enabled\":true,\"width\":2560,\"method\":\"lanczos3\",\"fitMethod\":\"contain\",\"premultiply\":true,\"linearRGB\":true}' --mozjpeg '{\"quality\":75,\"baseline\":false,\"arithmetic\":false,\"progressive\":true,\"optimize_coding\":true,\"smoothing\":0,\"color_space\":3,\"quant_table\":3,\"trellis_multipass\":false,\"trellis_opt_zero\":false,\"trellis_opt_table\":false,\"trellis_loops\":1,\"auto_subsample\":true,\"chroma_subsample\":2,\"separate_chroma_quality\":false,\"chroma_quality\":75}' src/assets/images/flow_background.jpg"
},
"lingui": {
diff --git a/web/src/admin/flows/utils.ts b/web/src/admin/flows/utils.ts
index c769731df..8a4c79609 100644
--- a/web/src/admin/flows/utils.ts
+++ b/web/src/admin/flows/utils.ts
@@ -18,6 +18,8 @@ export function DesignationToLabel(designation: FlowDesignationEnum): string {
return t`Stage Configuration`;
case FlowDesignationEnum.Unenrollment:
return t`Unenrollment`;
+ case FlowDesignationEnum.UnknownDefaultOpenApi:
+ return t`Unknown designation`;
}
}
@@ -33,5 +35,7 @@ export function LayoutToLabel(layout: LayoutEnum): string {
return t`Sidebar left`;
case LayoutEnum.SidebarRight:
return t`Sidebar right`;
+ case LayoutEnum.UnknownDefaultOpenApi:
+ return t`Unknown layout`;
}
}
diff --git a/web/src/admin/outposts/OutpostForm.ts b/web/src/admin/outposts/OutpostForm.ts
index fba5ba9f9..5974a4dd3 100644
--- a/web/src/admin/outposts/OutpostForm.ts
+++ b/web/src/admin/outposts/OutpostForm.ts
@@ -107,6 +107,10 @@ export class OutpostForm extends ModelForm {
`;
});
});
+ case OutpostTypeEnum.UnknownDefaultOpenApi:
+ return Promise.resolve([
+ html` `,
+ ]);
}
}
diff --git a/web/src/admin/outposts/OutpostListPage.ts b/web/src/admin/outposts/OutpostListPage.ts
index eb3f01e70..cad8c1957 100644
--- a/web/src/admin/outposts/OutpostListPage.ts
+++ b/web/src/admin/outposts/OutpostListPage.ts
@@ -33,6 +33,8 @@ export function TypeToLabel(type?: OutpostTypeEnum): string {
return t`Proxy`;
case OutpostTypeEnum.Ldap:
return t`LDAP`;
+ case OutpostTypeEnum.UnknownDefaultOpenApi:
+ return t`Unknown type`;
}
}
diff --git a/web/src/admin/providers/proxy/ProxyProviderForm.ts b/web/src/admin/providers/proxy/ProxyProviderForm.ts
index b2b847b5a..8ccf2724f 100644
--- a/web/src/admin/providers/proxy/ProxyProviderForm.ts
+++ b/web/src/admin/providers/proxy/ProxyProviderForm.ts
@@ -279,6 +279,8 @@ export class ProxyProviderFormPage extends ModelForm {
${t`Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'.`}
`;
+ case ProxyMode.UnknownDefaultOpenApi:
+ return html`${t`Unknown proxy mode`}
`;
}
}
diff --git a/web/src/admin/providers/proxy/ProxyProviderViewPage.ts b/web/src/admin/providers/proxy/ProxyProviderViewPage.ts
index 185fcc3b3..fbbbf165a 100644
--- a/web/src/admin/providers/proxy/ProxyProviderViewPage.ts
+++ b/web/src/admin/providers/proxy/ProxyProviderViewPage.ts
@@ -47,6 +47,8 @@ export function ModeToLabel(action?: ProxyMode): string {
return t`Forward auth (single application)`;
case ProxyMode.ForwardDomain:
return t`Forward auth (domain-level)`;
+ case ProxyMode.UnknownDefaultOpenApi:
+ return t`Unknown proxy mode`;
}
}
@@ -57,6 +59,8 @@ export function isForward(mode: ProxyMode): boolean {
case ProxyMode.ForwardSingle:
case ProxyMode.ForwardDomain:
return true;
+ case ProxyMode.UnknownDefaultOpenApi:
+ return false;
}
}
diff --git a/web/src/admin/sources/oauth/OAuthSourceViewPage.ts b/web/src/admin/sources/oauth/OAuthSourceViewPage.ts
index c05dadf21..6f1993284 100644
--- a/web/src/admin/sources/oauth/OAuthSourceViewPage.ts
+++ b/web/src/admin/sources/oauth/OAuthSourceViewPage.ts
@@ -27,8 +27,9 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
import { OAuthSource, ProviderTypeEnum, SourcesApi } from "@goauthentik/api";
export function ProviderToLabel(provider?: ProviderTypeEnum): string {
- if (!provider) return "";
switch (provider) {
+ case undefined:
+ return "";
case ProviderTypeEnum.Apple:
return "Apple";
case ProviderTypeEnum.Azuread:
@@ -51,6 +52,10 @@ export function ProviderToLabel(provider?: ProviderTypeEnum): string {
return "Reddit";
case ProviderTypeEnum.Twitter:
return "Twitter";
+ case ProviderTypeEnum.Twitch:
+ return "Twitch";
+ case ProviderTypeEnum.UnknownDefaultOpenApi:
+ return t`Unknown provider type`;
}
}
diff --git a/web/src/admin/sources/oauth/utils.ts b/web/src/admin/sources/oauth/utils.ts
index 559bc7a69..f3fc3a3ef 100644
--- a/web/src/admin/sources/oauth/utils.ts
+++ b/web/src/admin/sources/oauth/utils.ts
@@ -15,5 +15,7 @@ export function UserMatchingModeToLabel(mode?: UserMatchingModeEnum): string {
return t`Link to a user with identical username. Can have security implications when a username is used with another source`;
case UserMatchingModeEnum.UsernameDeny:
return t`Use the user's username, but deny enrollment when the username already exists`;
+ case UserMatchingModeEnum.UnknownDefaultOpenApi:
+ return t`Unknown user matching mode`;
}
}
diff --git a/web/src/admin/tokens/TokenListPage.ts b/web/src/admin/tokens/TokenListPage.ts
index 2476dc2f1..91101abcf 100644
--- a/web/src/admin/tokens/TokenListPage.ts
+++ b/web/src/admin/tokens/TokenListPage.ts
@@ -27,6 +27,8 @@ export function IntentToLabel(intent: IntentEnum): string {
return t`Recovery`;
case IntentEnum.Verification:
return t`Verification`;
+ case IntentEnum.UnknownDefaultOpenApi:
+ return t`Unknown intent`;
}
}
diff --git a/web/src/elements/Diagram.ts b/web/src/elements/Diagram.ts
index 5a9c1fffc..051e7c22f 100644
--- a/web/src/elements/Diagram.ts
+++ b/web/src/elements/Diagram.ts
@@ -35,7 +35,10 @@ export class Diagram extends AKElement {
const matcher = window.matchMedia("(prefers-color-scheme: light)");
const handler = (ev?: MediaQueryListEvent) => {
mermaid.initialize({
- logLevel: "fatal",
+ // The type definition for this says number
+ // but the example use strings
+ // and numbers don't work
+ logLevel: "fatal" as unknown as number,
startOnLoad: false,
theme: ev?.matches || matcher.matches ? "default" : "dark",
flowchart: {
diff --git a/web/src/elements/table/Table.ts b/web/src/elements/table/Table.ts
index 12065bed3..cda10f7c6 100644
--- a/web/src/elements/table/Table.ts
+++ b/web/src/elements/table/Table.ts
@@ -202,7 +202,7 @@ export abstract class Table extends AKElement {
let comp = (item: T) => {
return JSON.stringify(item) === jsonRes;
};
- if ("pk" in res) {
+ if (Object.hasOwn(res as object, "pk")) {
comp = (item: T) => {
return (
(item as unknown as { pk: string | number }).pk ===