2024-05-12 19:16:59 +02:00
|
|
|
import { assert, type Equals } from "tsafe/assert";
|
2024-05-12 21:41:49 +02:00
|
|
|
import type { KeycloakAccountV1Version, KeycloakThemeAdditionalInfoExtensionVersion } from "./extensionVersions";
|
2024-05-16 09:20:37 +02:00
|
|
|
import { id } from "tsafe/id";
|
|
|
|
|
|
|
|
export type KeycloakVersionRange = KeycloakVersionRange.WithAccountTheme | KeycloakVersionRange.WithoutAccountTheme;
|
|
|
|
|
|
|
|
export namespace KeycloakVersionRange {
|
|
|
|
export type WithoutAccountTheme = "21-and-below" | "22-and-above";
|
|
|
|
|
|
|
|
export type WithAccountTheme = "21-and-below" | "23" | "24-and-above";
|
|
|
|
}
|
2024-05-12 19:16:59 +02:00
|
|
|
|
|
|
|
export function getKeycloakVersionRangeForJar(params: {
|
2024-05-12 21:23:20 +02:00
|
|
|
doesImplementAccountTheme: boolean;
|
2024-05-12 21:41:49 +02:00
|
|
|
keycloakAccountV1Version: KeycloakAccountV1Version;
|
|
|
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
2024-05-16 09:20:37 +02:00
|
|
|
}): KeycloakVersionRange | undefined {
|
2024-05-12 21:23:20 +02:00
|
|
|
const { keycloakAccountV1Version, keycloakThemeAdditionalInfoExtensionVersion, doesImplementAccountTheme } = params;
|
2024-05-12 19:16:59 +02:00
|
|
|
|
2024-05-16 09:20:37 +02:00
|
|
|
if (doesImplementAccountTheme) {
|
|
|
|
return id<KeycloakVersionRange.WithAccountTheme | undefined>(
|
|
|
|
(() => {
|
|
|
|
switch (keycloakAccountV1Version) {
|
|
|
|
case null:
|
|
|
|
switch (keycloakThemeAdditionalInfoExtensionVersion) {
|
|
|
|
case null:
|
|
|
|
return "21-and-below" as const;
|
|
|
|
case "1.1.5":
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
assert<Equals<typeof keycloakThemeAdditionalInfoExtensionVersion, never>>(false);
|
|
|
|
case "0.3":
|
|
|
|
switch (keycloakThemeAdditionalInfoExtensionVersion) {
|
|
|
|
case null:
|
|
|
|
return undefined;
|
|
|
|
case "1.1.5":
|
|
|
|
return "23" as const;
|
|
|
|
}
|
|
|
|
assert<Equals<typeof keycloakThemeAdditionalInfoExtensionVersion, never>>(false);
|
|
|
|
case "0.4":
|
|
|
|
switch (keycloakThemeAdditionalInfoExtensionVersion) {
|
|
|
|
case null:
|
|
|
|
return undefined;
|
|
|
|
case "1.1.5":
|
|
|
|
return "24-and-above" as const;
|
|
|
|
}
|
|
|
|
assert<Equals<typeof keycloakThemeAdditionalInfoExtensionVersion, never>>(false);
|
|
|
|
}
|
|
|
|
})()
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return id<KeycloakVersionRange.WithoutAccountTheme | undefined>(
|
|
|
|
(() => {
|
|
|
|
switch (keycloakAccountV1Version) {
|
|
|
|
case null:
|
|
|
|
switch (keycloakThemeAdditionalInfoExtensionVersion) {
|
|
|
|
case null:
|
|
|
|
return "21-and-below";
|
|
|
|
case "1.1.5":
|
|
|
|
return "22-and-above";
|
|
|
|
}
|
|
|
|
assert<Equals<typeof keycloakThemeAdditionalInfoExtensionVersion, never>>(false);
|
|
|
|
case "0.3":
|
|
|
|
switch (keycloakThemeAdditionalInfoExtensionVersion) {
|
|
|
|
case null:
|
|
|
|
return undefined;
|
|
|
|
case "1.1.5":
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
assert<Equals<typeof keycloakThemeAdditionalInfoExtensionVersion, never>>(false);
|
|
|
|
case "0.4":
|
|
|
|
switch (keycloakThemeAdditionalInfoExtensionVersion) {
|
|
|
|
case null:
|
|
|
|
return undefined;
|
|
|
|
case "1.1.5":
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
assert<Equals<typeof keycloakThemeAdditionalInfoExtensionVersion, never>>(false);
|
|
|
|
}
|
|
|
|
})()
|
|
|
|
);
|
2024-05-12 19:16:59 +02:00
|
|
|
}
|
|
|
|
}
|