From b7e39b59fd0fc7b5610ebff29035bf622079e0d8 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 5 Oct 2022 20:45:21 +0800 Subject: refactor: Change file structure --- apps/kit/src/actions/pwKey.ts | 10 - apps/kit/src/app.d.ts | 9 - apps/kit/src/app.html | 14 - apps/kit/src/app.pcss | 34 -- apps/kit/src/global.d.ts | 11 - apps/kit/src/hooks.server.ts | 47 -- apps/kit/src/lib/api/internal-fetch.ts | 170 ------- apps/kit/src/lib/api/root.ts | 6 - apps/kit/src/lib/api/time-entry.ts | 83 ---- apps/kit/src/lib/api/user.ts | 47 -- apps/kit/src/lib/colors.ts | 47 -- apps/kit/src/lib/components/alert.svelte | 268 ----------- apps/kit/src/lib/components/button.svelte | 103 ----- apps/kit/src/lib/components/checkbox.svelte | 24 - .../src/lib/components/icons/adjustments.svelte | 14 - .../lib/components/icons/bars-3-center-left.svelte | 15 - apps/kit/src/lib/components/icons/calendar.svelte | 14 - .../src/lib/components/icons/check-circle.svelte | 13 - .../lib/components/icons/chevron-up-down.svelte | 13 - apps/kit/src/lib/components/icons/database.svelte | 14 - .../lib/components/icons/exclamation-circle.svelte | 13 - .../components/icons/exclamation-triangle.svelte | 13 - .../src/lib/components/icons/folder-open.svelte | 14 - apps/kit/src/lib/components/icons/home.svelte | 14 - apps/kit/src/lib/components/icons/index.ts | 41 -- .../lib/components/icons/information-circle.svelte | 13 - .../lib/components/icons/magnifying-glass.svelte | 13 - apps/kit/src/lib/components/icons/megaphone.svelte | 14 - apps/kit/src/lib/components/icons/menu.svelte | 14 - .../kit/src/lib/components/icons/queue-list.svelte | 14 - apps/kit/src/lib/components/icons/spinner.svelte | 20 - apps/kit/src/lib/components/icons/x-circle.svelte | 13 - apps/kit/src/lib/components/icons/x-mark.svelte | 11 - apps/kit/src/lib/components/icons/x.svelte | 14 - apps/kit/src/lib/components/index.ts | 15 - apps/kit/src/lib/components/input.svelte | 103 ----- apps/kit/src/lib/components/locale-switcher.svelte | 55 --- apps/kit/src/lib/components/switch.svelte | 143 ------ apps/kit/src/lib/configuration.ts | 60 --- apps/kit/src/lib/helpers.ts | 493 --------------------- apps/kit/src/lib/i18n/en/app/index.ts | 5 - apps/kit/src/lib/i18n/en/index.ts | 50 --- apps/kit/src/lib/i18n/formatters.ts | 13 - apps/kit/src/lib/i18n/i18n-svelte.ts | 12 - apps/kit/src/lib/i18n/i18n-types.ts | 359 --------------- apps/kit/src/lib/i18n/i18n-util.async.ts | 42 -- apps/kit/src/lib/i18n/i18n-util.sync.ts | 35 -- apps/kit/src/lib/i18n/i18n-util.ts | 39 -- apps/kit/src/lib/i18n/nb/app/index.ts | 8 - apps/kit/src/lib/i18n/nb/index.ts | 50 --- apps/kit/src/lib/logger.ts | 86 ---- apps/kit/src/lib/models/CreateAccountPayload.ts | 4 - apps/kit/src/lib/models/ErrorResult.ts | 4 - apps/kit/src/lib/models/IInternalFetchRequest.ts | 6 - apps/kit/src/lib/models/IInternalFetchResponse.ts | 6 - apps/kit/src/lib/models/ISession.ts | 8 - apps/kit/src/lib/models/IValidationResult.ts | 31 -- apps/kit/src/lib/models/LoginPayload.ts | 5 - apps/kit/src/lib/models/TimeCategoryDto.ts | 9 - apps/kit/src/lib/models/TimeEntryDto.ts | 13 - apps/kit/src/lib/models/TimeEntryQuery.ts | 27 -- apps/kit/src/lib/models/TimeLabelDto.ts | 8 - apps/kit/src/lib/models/TimeQueryDto.ts | 29 -- apps/kit/src/lib/models/UnwrappedEntryDateTime.ts | 9 - apps/kit/src/lib/models/UpdateProfilePayload.ts | 4 - apps/kit/src/lib/persistent-store.ts | 102 ----- apps/kit/src/lib/session.ts | 69 --- apps/kit/src/params/guid.ts | 5 - apps/kit/src/params/integer.ts | 3 - apps/kit/src/routes/(main)/(app)/+layout.svelte | 297 ------------- apps/kit/src/routes/(main)/(app)/home/+page.svelte | 1 - apps/kit/src/routes/(main)/(app)/org/+page.svelte | 4 - .../src/routes/(main)/(app)/profile/+page.svelte | 4 - .../src/routes/(main)/(app)/projects/+page.svelte | 4 - .../src/routes/(main)/(app)/settings/+page.svelte | 4 - .../src/routes/(main)/(app)/tickets/+page.svelte | 4 - apps/kit/src/routes/(main)/(app)/todo/+page.svelte | 4 - apps/kit/src/routes/(main)/(app)/wiki/+page.svelte | 4 - apps/kit/src/routes/(main)/(public)/+layout.svelte | 18 - .../(main)/(public)/reset-password/+page.svelte | 82 ---- .../(public)/reset-password/[id]/+page.server.ts | 11 - .../(public)/reset-password/[id]/+page.svelte | 132 ------ .../routes/(main)/(public)/sign-in/+page.svelte | 153 ------- .../kit/src/routes/(main)/(public)/sign-in/test.ts | 12 - .../routes/(main)/(public)/sign-up/+page.svelte | 82 ---- apps/kit/src/routes/(main)/+layout.server.ts | 34 -- apps/kit/src/routes/(main)/+layout.svelte | 29 -- apps/kit/src/routes/(main)/+layout.ts | 15 - apps/kit/src/routes/(main)/+page.svelte | 1 - apps/kit/src/routes/book/+layout.svelte | 64 --- apps/kit/src/routes/book/+page.svelte | 1 - apps/kit/src/routes/book/alerts/+page.svelte | 70 --- apps/kit/src/routes/book/buttons/+page.svelte | 23 - apps/kit/src/routes/book/inputs/+page.svelte | 48 -- apps/kit/src/routes/book/toggles/+page.svelte | 27 -- 95 files changed, 4215 deletions(-) delete mode 100644 apps/kit/src/actions/pwKey.ts delete mode 100644 apps/kit/src/app.d.ts delete mode 100644 apps/kit/src/app.html delete mode 100644 apps/kit/src/app.pcss delete mode 100644 apps/kit/src/global.d.ts delete mode 100644 apps/kit/src/hooks.server.ts delete mode 100644 apps/kit/src/lib/api/internal-fetch.ts delete mode 100644 apps/kit/src/lib/api/root.ts delete mode 100644 apps/kit/src/lib/api/time-entry.ts delete mode 100644 apps/kit/src/lib/api/user.ts delete mode 100644 apps/kit/src/lib/colors.ts delete mode 100644 apps/kit/src/lib/components/alert.svelte delete mode 100644 apps/kit/src/lib/components/button.svelte delete mode 100644 apps/kit/src/lib/components/checkbox.svelte delete mode 100644 apps/kit/src/lib/components/icons/adjustments.svelte delete mode 100644 apps/kit/src/lib/components/icons/bars-3-center-left.svelte delete mode 100644 apps/kit/src/lib/components/icons/calendar.svelte delete mode 100644 apps/kit/src/lib/components/icons/check-circle.svelte delete mode 100644 apps/kit/src/lib/components/icons/chevron-up-down.svelte delete mode 100644 apps/kit/src/lib/components/icons/database.svelte delete mode 100644 apps/kit/src/lib/components/icons/exclamation-circle.svelte delete mode 100644 apps/kit/src/lib/components/icons/exclamation-triangle.svelte delete mode 100644 apps/kit/src/lib/components/icons/folder-open.svelte delete mode 100644 apps/kit/src/lib/components/icons/home.svelte delete mode 100644 apps/kit/src/lib/components/icons/index.ts delete mode 100644 apps/kit/src/lib/components/icons/information-circle.svelte delete mode 100644 apps/kit/src/lib/components/icons/magnifying-glass.svelte delete mode 100644 apps/kit/src/lib/components/icons/megaphone.svelte delete mode 100644 apps/kit/src/lib/components/icons/menu.svelte delete mode 100644 apps/kit/src/lib/components/icons/queue-list.svelte delete mode 100644 apps/kit/src/lib/components/icons/spinner.svelte delete mode 100644 apps/kit/src/lib/components/icons/x-circle.svelte delete mode 100644 apps/kit/src/lib/components/icons/x-mark.svelte delete mode 100644 apps/kit/src/lib/components/icons/x.svelte delete mode 100644 apps/kit/src/lib/components/index.ts delete mode 100644 apps/kit/src/lib/components/input.svelte delete mode 100644 apps/kit/src/lib/components/locale-switcher.svelte delete mode 100644 apps/kit/src/lib/components/switch.svelte delete mode 100644 apps/kit/src/lib/configuration.ts delete mode 100644 apps/kit/src/lib/helpers.ts delete mode 100644 apps/kit/src/lib/i18n/en/app/index.ts delete mode 100644 apps/kit/src/lib/i18n/en/index.ts delete mode 100644 apps/kit/src/lib/i18n/formatters.ts delete mode 100644 apps/kit/src/lib/i18n/i18n-svelte.ts delete mode 100644 apps/kit/src/lib/i18n/i18n-types.ts delete mode 100644 apps/kit/src/lib/i18n/i18n-util.async.ts delete mode 100644 apps/kit/src/lib/i18n/i18n-util.sync.ts delete mode 100644 apps/kit/src/lib/i18n/i18n-util.ts delete mode 100644 apps/kit/src/lib/i18n/nb/app/index.ts delete mode 100644 apps/kit/src/lib/i18n/nb/index.ts delete mode 100644 apps/kit/src/lib/logger.ts delete mode 100644 apps/kit/src/lib/models/CreateAccountPayload.ts delete mode 100644 apps/kit/src/lib/models/ErrorResult.ts delete mode 100644 apps/kit/src/lib/models/IInternalFetchRequest.ts delete mode 100644 apps/kit/src/lib/models/IInternalFetchResponse.ts delete mode 100644 apps/kit/src/lib/models/ISession.ts delete mode 100644 apps/kit/src/lib/models/IValidationResult.ts delete mode 100644 apps/kit/src/lib/models/LoginPayload.ts delete mode 100644 apps/kit/src/lib/models/TimeCategoryDto.ts delete mode 100644 apps/kit/src/lib/models/TimeEntryDto.ts delete mode 100644 apps/kit/src/lib/models/TimeEntryQuery.ts delete mode 100644 apps/kit/src/lib/models/TimeLabelDto.ts delete mode 100644 apps/kit/src/lib/models/TimeQueryDto.ts delete mode 100644 apps/kit/src/lib/models/UnwrappedEntryDateTime.ts delete mode 100644 apps/kit/src/lib/models/UpdateProfilePayload.ts delete mode 100644 apps/kit/src/lib/persistent-store.ts delete mode 100644 apps/kit/src/lib/session.ts delete mode 100644 apps/kit/src/params/guid.ts delete mode 100644 apps/kit/src/params/integer.ts delete mode 100644 apps/kit/src/routes/(main)/(app)/+layout.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/home/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/org/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/profile/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/projects/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/settings/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/tickets/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/todo/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(app)/wiki/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(public)/+layout.svelte delete mode 100644 apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts delete mode 100644 apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/(public)/sign-in/test.ts delete mode 100644 apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte delete mode 100644 apps/kit/src/routes/(main)/+layout.server.ts delete mode 100644 apps/kit/src/routes/(main)/+layout.svelte delete mode 100644 apps/kit/src/routes/(main)/+layout.ts delete mode 100644 apps/kit/src/routes/(main)/+page.svelte delete mode 100644 apps/kit/src/routes/book/+layout.svelte delete mode 100644 apps/kit/src/routes/book/+page.svelte delete mode 100644 apps/kit/src/routes/book/alerts/+page.svelte delete mode 100644 apps/kit/src/routes/book/buttons/+page.svelte delete mode 100644 apps/kit/src/routes/book/inputs/+page.svelte delete mode 100644 apps/kit/src/routes/book/toggles/+page.svelte (limited to 'apps/kit/src') diff --git a/apps/kit/src/actions/pwKey.ts b/apps/kit/src/actions/pwKey.ts deleted file mode 100644 index a2f22e7..0000000 --- a/apps/kit/src/actions/pwKey.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { is_development, is_testing } from "$lib/configuration"; - -export default function pwKey(node: HTMLElement, value: string | undefined) { - if (!value) return; - if (!is_testing()) { - if (is_development()) console.warn("VITE_TESTING is false, so not setting pw-key attributes"); - return; - } - node.setAttribute("pw-key", value); -} \ No newline at end of file diff --git a/apps/kit/src/app.d.ts b/apps/kit/src/app.d.ts deleted file mode 100644 index 220ddc1..0000000 --- a/apps/kit/src/app.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// See https://kit.svelte.dev/docs/types#app -// for information about these interfaces -// and what to do when importing types -declare namespace App { - interface Locals {} - interface Platform {} - interface PrivateEnv {} - interface PublicEnv {} -} \ No newline at end of file diff --git a/apps/kit/src/app.html b/apps/kit/src/app.html deleted file mode 100644 index 308b223..0000000 --- a/apps/kit/src/app.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - %sveltekit.head% - - - -
%sveltekit.body%
- - - \ No newline at end of file diff --git a/apps/kit/src/app.pcss b/apps/kit/src/app.pcss deleted file mode 100644 index d256fea..0000000 --- a/apps/kit/src/app.pcss +++ /dev/null @@ -1,34 +0,0 @@ -/* Write your global styles here, in PostCSS syntax */ -@tailwind base; -@tailwind components; -@tailwind utilities; - -pre { - font-family: monospace !important; -} - -*:focus-visible { - outline: 1px auto; -} - -.c-disabled { - cursor: not-allowed !important; - filter: opacity(.45); - pointer-events: none !important; -} - -.c-disabled.loading { - cursor: wait !important; -} - -.link { - @apply text-blue-600 hover:text-blue-700 transition duration-300 ease-in-out mb-4; - - &.danger { - @apply text-red-600 hover:text-red-700; - } - - &.active { - @apply underline - } -} \ No newline at end of file diff --git a/apps/kit/src/global.d.ts b/apps/kit/src/global.d.ts deleted file mode 100644 index 13f5e16..0000000 --- a/apps/kit/src/global.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -type Locales = import('$lib/i18n/i18n-types').Locales -type TranslationFunctions = import('$lib/i18n/i18n-types').TranslationFunctions - -declare namespace App { - interface Locals { - locale: Locales - LL: TranslationFunctions - } -} \ No newline at end of file diff --git a/apps/kit/src/hooks.server.ts b/apps/kit/src/hooks.server.ts deleted file mode 100644 index 0f6e0c0..0000000 --- a/apps/kit/src/hooks.server.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { CookieNames } from "$lib/configuration"; -import { detectLocale, i18n, isLocale, locales } from '$lib/i18n/i18n-util' -import type { Handle, RequestEvent } from '@sveltejs/kit' -import { initAcceptLanguageHeaderDetector } from 'typesafe-i18n/detectors' -import { parse, serialize } from "cookie"; -import type { Locales } from "$lib/i18n/i18n-types"; -import { loadAllLocales } from "$lib/i18n/i18n-util.sync"; - - -loadAllLocales() -const L = i18n() - -export const handle: Handle = async ({ event, resolve }) => { - const cookies = parse(event.request.headers.get("Cookie") ?? ''); - const localeCookie = cookies[CookieNames.locale]; - const preferredLocale = getPreferredLocale(event); - let finalLocale = localeCookie ?? preferredLocale; - - console.log("Handling locale", { - locales, - localeCookie, - preferredLocale, - finalLocale - }); - - if (!isLocale(finalLocale)) finalLocale = "en"; - if (!localeCookie) { - // Set a locale cookie - event.setHeaders({ - "Set-Cookie": serialize(CookieNames.locale, finalLocale, { - path: "/", - expires: new Date(2099, 1, 1, 0, 0, 0, 0), - sameSite: "strict" - }) - }); - } - - event.locals.locale = finalLocale as Locales; - event.locals.LL = L[finalLocale as Locales]; - - return resolve(event, { transformPageChunk: ({ html }) => html.replace('%lang%', finalLocale) }); -} - -function getPreferredLocale(event: RequestEvent) { - const acceptLanguageDetector = initAcceptLanguageHeaderDetector(event.request); - return detectLocale(acceptLanguageDetector); -} diff --git a/apps/kit/src/lib/api/internal-fetch.ts b/apps/kit/src/lib/api/internal-fetch.ts deleted file mode 100644 index b21d669..0000000 --- a/apps/kit/src/lib/api/internal-fetch.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { Temporal } from "temporal-polyfill"; -import { clear_session_data } from "$lib/session"; -import { resolve_references } from "$lib/helpers"; -import type { IInternalFetchResponse } from "$lib/models/IInternalFetchResponse"; -import type { IInternalFetchRequest } from "$lib/models/IInternalFetchRequest"; -import { redirect } from "@sveltejs/kit"; - -export async function http_post(url: string, body?: object | string, timeout = -1, skip_401_check = false, abort_signal?: AbortSignal): Promise { - const init = { - method: "post", - } as RequestInit; - - if (abort_signal) { - init.signal = abort_signal; - } - - if (body) { - init.headers = { - "Content-Type": "application/json;charset=UTF-8", - }; - init.body = JSON.stringify(body); - } - - const response = await internal_fetch({ url, init, timeout }); - const result = {} as IInternalFetchResponse; - - if (!skip_401_check && await is_401(response)) return result; - - result.ok = response.ok; - result.status = response.status; - result.http_response = response; - - if (response.status !== 204) { - try { - const ct = response.headers.get("Content-Type")?.toString() ?? ""; - if (ct.startsWith("application/json")) { - const data = await response.json(); - result.data = resolve_references(data); - } else if (ct.startsWith("text/plain")) { - const text = await response.text(); - result.data = text as string; - } - } catch { - // Ignored - } - } - - return result; -} - -export async function http_get(url: string, timeout = -1, skip_401_check = false, abort_signal?: AbortSignal): Promise { - const init = { - method: "get", - } as RequestInit; - - if (abort_signal) { - init.signal = abort_signal; - } - - const response = await internal_fetch({ url, init, timeout }); - const result = {} as IInternalFetchResponse; - - if (!skip_401_check && await is_401(response)) return result; - - result.ok = response.ok; - result.status = response.status; - result.http_response = response; - - if (response.status !== 204) { - try { - const ct = response.headers.get("Content-Type")?.toString() ?? ""; - if (ct.startsWith("application/json")) { - const data = await response.json(); - result.data = resolve_references(data); - } else if (ct.startsWith("text/plain")) { - const text = await response.text(); - result.data = text as string; - } - } catch { - // Ignored - } - } - - return result; -} - -export async function http_delete(url: string, body?: object | string, timeout = -1, skip_401_check = false, abort_signal?: AbortSignal): Promise { - const init = { - method: "delete", - } as RequestInit; - - if (abort_signal) { - init.signal = abort_signal; - } - - if (body) { - init.headers = { - "Content-Type": "application/json;charset=UTF-8", - }; - init.body = JSON.stringify(body); - } - - const response = await internal_fetch({ url, init, timeout }); - const result = {} as IInternalFetchResponse; - - if (!skip_401_check && await is_401(response)) return result; - - result.ok = response.ok; - result.status = response.status; - result.http_response = response; - - if (response.status !== 204) { - try { - const ct = response.headers.get("Content-Type")?.toString() ?? ""; - if (ct.startsWith("application/json")) { - const data = await response.json(); - result.data = resolve_references(data); - } else if (ct.startsWith("text/plain")) { - const text = await response.text(); - result.data = text as string; - } - } catch (error) { - // ignored - } - } - - return result; -} - -async function internal_fetch(request: IInternalFetchRequest): Promise { - if (!request.init) request.init = {}; - request.init.credentials = "include"; - request.init.headers = { - "X-TimeZone": Temporal.Now.timeZone().id, - ...request.init.headers - }; - - const fetch_request = new Request(request.url, request.init); - let response: any; - - try { - if (request.timeout && request.timeout > 500) { - response = await Promise.race([ - fetch(fetch_request), - new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout")), request.timeout)) - ]); - } else { - response = await fetch(fetch_request); - } - } catch (error: any) { - console.log(error); - if (error.message === "Timeout") { - console.error("Request timed out"); - } else if (error.message === "Network request failed") { - console.error("No internet connection"); - } else { - throw error; // rethrow other unexpected errors - } - } - - return response; -} - -async function is_401(response: Response): Promise { - if (response.status === 401) { - clear_session_data(); - throw redirect(307, "/login"); - } - return false; -} diff --git a/apps/kit/src/lib/api/root.ts b/apps/kit/src/lib/api/root.ts deleted file mode 100644 index 3e5bda2..0000000 --- a/apps/kit/src/lib/api/root.ts +++ /dev/null @@ -1,6 +0,0 @@ -import {http_post} from "$lib/api/internal-fetch"; -import {api_base} from "$lib/configuration"; - -export function server_log(message: string): void { - http_post(api_base("_/api/log"), message); -} diff --git a/apps/kit/src/lib/api/time-entry.ts b/apps/kit/src/lib/api/time-entry.ts deleted file mode 100644 index a40b0c2..0000000 --- a/apps/kit/src/lib/api/time-entry.ts +++ /dev/null @@ -1,83 +0,0 @@ -import {api_base} from "$lib/configuration"; -import {is_guid} from "$lib/helpers"; -import {http_delete, http_get, http_post} from "./internal-fetch"; -import type {TimeCategoryDto} from "$lib/models/TimeCategoryDto"; -import type {TimeLabelDto} from "$lib/models/TimeLabelDto"; -import type {TimeEntryDto} from "$lib/models/TimeEntryDto"; -import type {TimeEntryQuery} from "$lib/models/TimeEntryQuery"; -import type {IInternalFetchResponse} from "$lib/models/IInternalFetchResponse"; - - -// ENTRIES - -export async function create_time_entry(payload: TimeEntryDto): Promise { - return http_post(api_base("v1/entries/create"), payload); -} - -export async function get_time_entry(entryId: string): Promise { - if (is_guid(entryId)) { - return http_get(api_base("v1/entries/" + entryId)); - } - throw new Error("entryId is not a valid guid."); -} - -export async function get_time_entries(entryQuery: TimeEntryQuery): Promise { - return http_post(api_base("v1/entries/query"), entryQuery); -} - -export async function delete_time_entry(id: string): Promise { - if (!is_guid(id)) throw new Error("id is not a valid guid"); - return http_delete(api_base("v1/entries/" + id + "/delete")); -} - -export async function update_time_entry(entryDto: TimeEntryDto): Promise { - if (!is_guid(entryDto.id ?? "")) throw new Error("id is not a valid guid"); - if (!entryDto.category) throw new Error("category is empty"); - if (!entryDto.stop) throw new Error("stop is empty"); - if (!entryDto.start) throw new Error("start is empty"); - return http_post(api_base("v1/entries/update"), entryDto); -} - -// LABELS -export async function create_time_label(labelDto: TimeLabelDto): Promise { - return http_post(api_base("v1/labels/create"), labelDto); -} - -export async function get_time_labels(): Promise { - return http_get(api_base("v1/labels")); -} - -export async function delete_time_label(id: string): Promise { - if (!is_guid(id)) throw new Error("id is not a valid guid"); - return http_delete(api_base("v1/labels/" + id + "/delete")); -} - -export async function update_time_label(labelDto: TimeLabelDto): Promise { - if (!is_guid(labelDto.id ?? "")) throw new Error("id is not a valid guid"); - if (!labelDto.name) throw new Error("name is empty"); - if (!labelDto.color) throw new Error("color is empty"); - return http_post(api_base("v1/labels/update"), labelDto); -} - -// CATEGORIES -export async function create_time_category(category: TimeCategoryDto): Promise { - if (!category.name) throw new Error("name is empty"); - if (!category.color) throw new Error("color is empty"); - return http_post(api_base("v1/categories/create"), category); -} - -export async function get_time_categories(): Promise { - return http_get(api_base("v1/categories")); -} - -export async function delete_time_category(id: string): Promise { - if (!is_guid(id)) throw new Error("id is not a valid guid"); - return http_delete(api_base("v1/categories/" + id + "/delete")); -} - -export async function update_time_category(category: TimeCategoryDto): Promise { - if (!is_guid(category.id ?? "")) throw new Error("id is not a valid guid"); - if (!category.name) throw new Error("name is empty"); - if (!category.color) throw new Error("color is empty"); - return http_post(api_base("v1/categories/update"), category); -} diff --git a/apps/kit/src/lib/api/user.ts b/apps/kit/src/lib/api/user.ts deleted file mode 100644 index f0dc932..0000000 --- a/apps/kit/src/lib/api/user.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {api_base} from "$lib/configuration"; -import {http_delete, http_get, http_post} from "./internal-fetch"; -import type {LoginPayload} from "$lib/models/LoginPayload"; -import type {UpdateProfilePayload} from "$lib/models/UpdateProfilePayload"; -import type {CreateAccountPayload} from "$lib/models/CreateAccountPayload"; -import type {IInternalFetchResponse} from "$lib/models/IInternalFetchResponse"; - -export async function login(payload: LoginPayload): Promise { - return http_post(api_base("_/account/login"), payload); -} - -export async function logout(): Promise { - return http_get(api_base("_/account/logout")); -} - -export async function create_forgot_password_request(username: string): Promise { - if (!username) throw new Error("Username is empty"); - return http_get(api_base("_/forgot-password-requests/create?username=" + username)); -} - -export async function check_forgot_password_request(public_id: string): Promise { - if (!public_id) throw new Error("Id is empty"); - return http_get(api_base("_/forgot-password-requests/is-valid?id=" + public_id)); -} - -export async function fulfill_forgot_password_request(public_id: string, newPassword: string): Promise { - if (!public_id) throw new Error("Id is empty"); - return http_post(api_base("_/forgot-password-requests/fulfill"), {id: public_id, newPassword}); -} - -export async function delete_account(): Promise { - return http_delete(api_base("_/account/delete")); -} - -export async function update_profile(payload: UpdateProfilePayload): Promise { - if (!payload.password && !payload.username) throw new Error("Password and Username is empty"); - return http_post(api_base("_/account/update"), payload); -} - -export async function create_account(payload: CreateAccountPayload): Promise { - if (!payload.password && !payload.username) throw new Error("Password and Username is empty"); - return http_post(api_base("_/account/create"), payload); -} - -export async function get_profile_for_active_check(): Promise { - return http_get(api_base("_/account"), 0, true); -} diff --git a/apps/kit/src/lib/colors.ts b/apps/kit/src/lib/colors.ts deleted file mode 100644 index 34c7992..0000000 --- a/apps/kit/src/lib/colors.ts +++ /dev/null @@ -1,47 +0,0 @@ -export function generate_random_hex_color(skip_contrast_check = false) { - let hex = __generate_random_hex_color(); - if (skip_contrast_check) return hex; - while ((__calculate_contrast_ratio("#ffffff", hex) < 4.5) || (__calculate_contrast_ratio("#000000", hex) < 4.5)) { - hex = __generate_random_hex_color(); - } - - return hex; -} - -// Largely copied from chroma js api -function __generate_random_hex_color(): string { - let code = "#"; - for (let i = 0; i < 6; i++) { - code += "0123456789abcdef".charAt(Math.floor(Math.random() * 16)); - } - return code; -} - -function __calculate_contrast_ratio(hex1: string, hex2: string): number { - const rgb1 = __hex_to_rgb(hex1); - const rgb2 = __hex_to_rgb(hex2); - const l1 = __get_luminance(rgb1[0], rgb1[1], rgb1[2]); - const l2 = __get_luminance(rgb2[0], rgb2[1], rgb2[2]); - const result = l1 > l2 ? (l1 + 0.05) / (l2 + 0.05) : (l2 + 0.05) / (l1 + 0.05); - return result; -} - -function __hex_to_rgb(hex: string): number[] { - if (!hex.match(/^#([A-Fa-f0-9]{6})$/)) return []; - if (hex[0] === "#") hex = hex.substring(1, hex.length); - return [parseInt(hex.substring(0, 2), 16), parseInt(hex.substring(2, 4), 16), parseInt(hex.substring(4, 6), 16)]; -} - -function __get_luminance(r: any, g: any, b: any) { - // relative luminance - // see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef - r = __luminance_x(r); - g = __luminance_x(g); - b = __luminance_x(b); - return 0.2126 * r + 0.7152 * g + 0.0722 * b; -} - -function __luminance_x(x: any) { - x /= 255; - return x <= 0.03928 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); -} diff --git a/apps/kit/src/lib/components/alert.svelte b/apps/kit/src/lib/components/alert.svelte deleted file mode 100644 index fd57105..0000000 --- a/apps/kit/src/lib/components/alert.svelte +++ /dev/null @@ -1,268 +0,0 @@ - - -{#if visible} -
-
-
- -
-
- {#if !rightLinkText} - {#if title} -

- {title} -

- {/if} - {#if message} -
-

- {@html message} -

-
- {/if} - {#if listItems?.length ?? 0} -
    - {#each listItems as listItem} -
  • {listItem}
  • - {/each} -
- {/if} - {:else} -
-
- {#if title} -

- {title} -

- {/if} - {#if message} -
-

- {@html message} -

-
- {/if} - {#if listItems?.length ?? 0} -
    - {#each listItems as listItem} -
  • {listItem}
  • - {/each} -
- {/if} -
-

- rightLinkClicked()} - class="whitespace-nowrap font-medium text-{colorClassPart}-700 hover:text-{colorClassPart}-600" - > - {rightLinkText} - - -

-
- {/if} - {#if actions?.length ?? 0} -
-
- {#each actions as action} - {@const color = action?.color ?? colorClassPart} - - {/each} -
-
- {/if} -
- {#if closeable} -
-
- -
-
- {/if} -
-
-{/if} diff --git a/apps/kit/src/lib/components/button.svelte b/apps/kit/src/lib/components/button.svelte deleted file mode 100644 index cbc09e2..0000000 --- a/apps/kit/src/lib/components/button.svelte +++ /dev/null @@ -1,103 +0,0 @@ - - - - -{#if href} - - {#if loading} - - {/if} - {text} - -{:else} - -{/if} diff --git a/apps/kit/src/lib/components/checkbox.svelte b/apps/kit/src/lib/components/checkbox.svelte deleted file mode 100644 index b2fcddb..0000000 --- a/apps/kit/src/lib/components/checkbox.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - -
- - -
diff --git a/apps/kit/src/lib/components/icons/adjustments.svelte b/apps/kit/src/lib/components/icons/adjustments.svelte deleted file mode 100644 index 83bda27..0000000 --- a/apps/kit/src/lib/components/icons/adjustments.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/bars-3-center-left.svelte b/apps/kit/src/lib/components/icons/bars-3-center-left.svelte deleted file mode 100644 index 785ece3..0000000 --- a/apps/kit/src/lib/components/icons/bars-3-center-left.svelte +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/calendar.svelte b/apps/kit/src/lib/components/icons/calendar.svelte deleted file mode 100644 index e0053ee..0000000 --- a/apps/kit/src/lib/components/icons/calendar.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/check-circle.svelte b/apps/kit/src/lib/components/icons/check-circle.svelte deleted file mode 100644 index e30778e..0000000 --- a/apps/kit/src/lib/components/icons/check-circle.svelte +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/chevron-up-down.svelte b/apps/kit/src/lib/components/icons/chevron-up-down.svelte deleted file mode 100644 index c07aed5..0000000 --- a/apps/kit/src/lib/components/icons/chevron-up-down.svelte +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/database.svelte b/apps/kit/src/lib/components/icons/database.svelte deleted file mode 100644 index 6ffdadb..0000000 --- a/apps/kit/src/lib/components/icons/database.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/exclamation-circle.svelte b/apps/kit/src/lib/components/icons/exclamation-circle.svelte deleted file mode 100644 index 2ce79b1..0000000 --- a/apps/kit/src/lib/components/icons/exclamation-circle.svelte +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/exclamation-triangle.svelte b/apps/kit/src/lib/components/icons/exclamation-triangle.svelte deleted file mode 100644 index 8d807db..0000000 --- a/apps/kit/src/lib/components/icons/exclamation-triangle.svelte +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/folder-open.svelte b/apps/kit/src/lib/components/icons/folder-open.svelte deleted file mode 100644 index 409c8e2..0000000 --- a/apps/kit/src/lib/components/icons/folder-open.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/home.svelte b/apps/kit/src/lib/components/icons/home.svelte deleted file mode 100644 index ee8305d..0000000 --- a/apps/kit/src/lib/components/icons/home.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/index.ts b/apps/kit/src/lib/components/icons/index.ts deleted file mode 100644 index 8c24873..0000000 --- a/apps/kit/src/lib/components/icons/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import XIcon from "./x.svelte"; -import MenuIcon from "./menu.svelte"; -import AdjustmentsIcon from "./adjustments.svelte"; -import DatabaseIcon from "./database.svelte"; -import HomeIcon from "./home.svelte"; -import InformationCircleIcon from "./information-circle.svelte"; -import ExclamationTriangleIcon from "./exclamation-triangle.svelte"; -import XCircleIcon from "./x-circle.svelte"; -import CheckCircleIcon from "./check-circle.svelte"; -import XMarkIcon from "./x-mark.svelte"; -import SpinnerIcon from "./spinner.svelte"; -import ExclamationCircleIcon from "./exclamation-circle.svelte"; -import ChevronUpDownIcon from "./chevron-up-down.svelte"; -import MagnifyingGlassIcon from "./magnifying-glass.svelte"; -import Bars3CenterLeftIcon from "./bars-3-center-left.svelte"; -import CalendarIcon from "./calendar.svelte"; -import FolderOpenIcon from "./folder-open.svelte"; -import MegaphoneIcon from "./megaphone.svelte"; -import QueueListIcon from "./queue-list.svelte"; - -export { - QueueListIcon, - FolderOpenIcon, - MegaphoneIcon, - CalendarIcon, - Bars3CenterLeftIcon, - MagnifyingGlassIcon, - ChevronUpDownIcon, - XIcon, - MenuIcon, - HomeIcon, - DatabaseIcon, - AdjustmentsIcon, - InformationCircleIcon, - ExclamationTriangleIcon, - ExclamationCircleIcon, - XCircleIcon, - CheckCircleIcon, - XMarkIcon, - SpinnerIcon -} \ No newline at end of file diff --git a/apps/kit/src/lib/components/icons/information-circle.svelte b/apps/kit/src/lib/components/icons/information-circle.svelte deleted file mode 100644 index 68dbc60..0000000 --- a/apps/kit/src/lib/components/icons/information-circle.svelte +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/magnifying-glass.svelte b/apps/kit/src/lib/components/icons/magnifying-glass.svelte deleted file mode 100644 index f8fdb6e..0000000 --- a/apps/kit/src/lib/components/icons/magnifying-glass.svelte +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/megaphone.svelte b/apps/kit/src/lib/components/icons/megaphone.svelte deleted file mode 100644 index 7ada5f3..0000000 --- a/apps/kit/src/lib/components/icons/megaphone.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/menu.svelte b/apps/kit/src/lib/components/icons/menu.svelte deleted file mode 100644 index 471d85f..0000000 --- a/apps/kit/src/lib/components/icons/menu.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/queue-list.svelte b/apps/kit/src/lib/components/icons/queue-list.svelte deleted file mode 100644 index 6148394..0000000 --- a/apps/kit/src/lib/components/icons/queue-list.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/icons/spinner.svelte b/apps/kit/src/lib/components/icons/spinner.svelte deleted file mode 100644 index 80cc57c..0000000 --- a/apps/kit/src/lib/components/icons/spinner.svelte +++ /dev/null @@ -1,20 +0,0 @@ - - - - diff --git a/apps/kit/src/lib/components/icons/x-circle.svelte b/apps/kit/src/lib/components/icons/x-circle.svelte deleted file mode 100644 index 3793b5a..0000000 --- a/apps/kit/src/lib/components/icons/x-circle.svelte +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/x-mark.svelte b/apps/kit/src/lib/components/icons/x-mark.svelte deleted file mode 100644 index fd1c6a1..0000000 --- a/apps/kit/src/lib/components/icons/x-mark.svelte +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/apps/kit/src/lib/components/icons/x.svelte b/apps/kit/src/lib/components/icons/x.svelte deleted file mode 100644 index 6125ab8..0000000 --- a/apps/kit/src/lib/components/icons/x.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/index.ts b/apps/kit/src/lib/components/index.ts deleted file mode 100644 index a81e0c3..0000000 --- a/apps/kit/src/lib/components/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import Alert from "./alert.svelte"; -import Button from "./button.svelte"; -import Checkbox from "./checkbox.svelte"; -import Input from "./input.svelte"; -import LocaleSwitcher from "./locale-switcher.svelte"; -import Switch from "./switch.svelte"; - -export { - Alert, - Button, - Checkbox, - Input, - LocaleSwitcher, - Switch -} \ No newline at end of file diff --git a/apps/kit/src/lib/components/input.svelte b/apps/kit/src/lib/components/input.svelte deleted file mode 100644 index c0ed654..0000000 --- a/apps/kit/src/lib/components/input.svelte +++ /dev/null @@ -1,103 +0,0 @@ - - -
- {#if label && !cornerHint && !hideLabel} - - {:else if cornerHint && !hideLabel} -
- {#if label} - - {/if} - - {cornerHint} - -
- {/if} -
- {#if icon} -
- -
- {:else if addon} -
- {addon} -
- {/if} - - {#if errorText} -
- -
- {/if} -
- {#if helpText && !errorText} -

- {helpText} -

- {/if} - {#if errorText} -

- {errorText} -

- {/if} -
diff --git a/apps/kit/src/lib/components/locale-switcher.svelte b/apps/kit/src/lib/components/locale-switcher.svelte deleted file mode 100644 index f880bfb..0000000 --- a/apps/kit/src/lib/components/locale-switcher.svelte +++ /dev/null @@ -1,55 +0,0 @@ - - - diff --git a/apps/kit/src/lib/components/switch.svelte b/apps/kit/src/lib/components/switch.svelte deleted file mode 100644 index 16da23a..0000000 --- a/apps/kit/src/lib/components/switch.svelte +++ /dev/null @@ -1,143 +0,0 @@ - - - - -
- {#if hasLabelOrDescription && !rightAlignedLabelDescription} - - {#if label} - {label} - {/if} - {#if description} - {description} - {/if} - - {/if} - {#if type === "short"} - - {:else if type === "icon"} - - {:else if type === "default"} - - {/if} - {#if hasLabelOrDescription && rightAlignedLabelDescription} - - {#if label} - {label} - {/if} - {#if description} - {description} - {/if} - - {/if} -
diff --git a/apps/kit/src/lib/configuration.ts b/apps/kit/src/lib/configuration.ts deleted file mode 100644 index 5a6a1bf..0000000 --- a/apps/kit/src/lib/configuration.ts +++ /dev/null @@ -1,60 +0,0 @@ -export const BASE_DOMAIN = "dev.greatoffice.app"; -export const DEV_BASE_DOMAIN = "http://localhost"; -export const API_ADDRESS = "https://api." + BASE_DOMAIN; -export const DEV_API_ADDRESS = "http://localhost:5000"; -export const SECONDS_BETWEEN_SESSION_CHECK = 600; - -export function api_base(path: string = ""): string { - return (is_development() ? DEV_API_ADDRESS : API_ADDRESS) + (path !== "" ? "/" + path : ""); -} - -export function is_development(): boolean { - return import.meta.env.DEV; -} - -export function is_testing(): boolean { - return import.meta.env.VITE_TESTING; -} - -export function is_debug(): boolean { - return localStorage.getItem(StorageKeys.debug) !== "true"; -} - -export const CookieNames = { - theme: "go_theme", - locale: "go_locale", - session: "go_session" -}; - -export function get_test_context(): TestContext { - return { - user: { - username: import.meta.env.VITE_TEST_USERNAME, - password: import.meta.env.VITE_TEST_PASSWORD - } - } -} - -export interface TestContext { - user: { - username: string, - password: string - } -} - -export const QueryKeys = { - labels: "labels", - categories: "categories", - entries: "entries", -}; - -export const StorageKeys = { - session: "sessionData", - theme: "theme", - debug: "debug", - categories: "categories", - labels: "labels", - entries: "entries", - stopwatch: "stopwatchState", - logLevel: "logLevel" -}; \ No newline at end of file diff --git a/apps/kit/src/lib/helpers.ts b/apps/kit/src/lib/helpers.ts deleted file mode 100644 index 38376e5..0000000 --- a/apps/kit/src/lib/helpers.ts +++ /dev/null @@ -1,493 +0,0 @@ -import { browser } from "$app/environment"; -import type { TimeEntryDto } from "$lib/models/TimeEntryDto"; -import type { UnwrappedEntryDateTime } from "$lib/models/UnwrappedEntryDateTime"; -import { logInfo } from "$lib/logger"; -import { Temporal } from "temporal-polyfill"; - -export const EMAIL_REGEX = new RegExp(/^([a-z0-9]+(?:([._\-])[a-z0-9]+)*@(?:[a-z0-9]+(?:(-)[a-z0-9]+)?\.)+[a-z0-9](?:[a-z0-9]*[a-z0-9])?)$/i); -export const URL_REGEX = new RegExp(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-.][a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/gm); -export const GUID_REGEX = new RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i); -export const NORWEGIAN_PHONE_NUMBER_REGEX = new RegExp(/(0047|\+47|47)?\d{8,12}/); - -export function get_default_sorted(unsorted: Array): Array { - if (unsorted.length < 1) return unsorted; - const byStart = unsorted.sort((a, b) => { - return Temporal.Instant.compare(Temporal.Instant.from(b.start), Temporal.Instant.from(a.start)); - }); - - return byStart.sort((a, b) => { - return Temporal.Instant.compare(Temporal.Instant.from(b.stop), Temporal.Instant.from(a.stop)); - }); -} - -export function get_element_by_pw_key(key: string): HTMLElement | null { - return document.querySelector("[pw-key='" + key + "']"); -} - -export function is_email(value: string): boolean { - return EMAIL_REGEX.test(String(value).toLowerCase()); -} - -export function is_url(value: string): boolean { - return URL_REGEX.test(String(value).toLowerCase()); -} - -export function is_norwegian_phone_number(value: string): boolean { - if (value.length < 8 || value.length > 12) { - return false; - } - return NORWEGIAN_PHONE_NUMBER_REGEX.test(String(value)); -} - -export function get_cookie(name: string) { - const value = `; ${document.cookie}`; - const parts = value.split(`; ${name}=`); - if (parts.length === 2) return parts.pop()?.split(";").shift(); -} - -export function set_cookie(name: string, value: string, baseDomain = window.location.hostname) { - document.cookie = name + "=" + encodeURIComponent(value) + (baseDomain ? ";domain=" + baseDomain : ""); -} - -export function unwrap_date_time_from_entry(entry: TimeEntryDto): UnwrappedEntryDateTime { - if (!entry) throw new Error("entry was undefined"); - const currentTimeZone = Temporal.Now.timeZone().id; - const startInstant = Temporal.Instant.from(entry.start).toZonedDateTimeISO(currentTimeZone); - const stopInstant = Temporal.Instant.from(entry.stop).toZonedDateTimeISO(currentTimeZone); - - return { - start_date: startInstant.toPlainDate(), - stop_date: stopInstant.toPlainDate(), - start_time: startInstant.toPlainTime(), - stop_time: stopInstant.toPlainTime(), - duration: Temporal.Duration.from({ - hours: stopInstant.hour, - minutes: stopInstant.minute, - }).subtract(Temporal.Duration.from({ - hours: startInstant.hour, - minutes: startInstant.minute, - })), - }; -} - - -export function is_guid(value: string): boolean { - if (!value) { - return false; - } - if (value[0] === "{") { - value = value.substring(1, value.length - 1); - } - return GUID_REGEX.test(value); -} - -export function is_empty_object(obj: object): boolean { - return obj !== void 0 && Object.keys(obj).length > 0; -} - -export function merge_obj_arr(a: Array, b: Array, props: Array): Array { - let start = 0; - let merge = []; - - while (start < a.length) { - - if (a[start] === b[start]) { - //pushing the merged objects into array - merge.push({ ...a[start], ...b[start] }); - } - //incrementing start value - start = start + 1; - } - return merge; -} - -export function set_favicon(url: string) { - // Find the current favicon element - const favicon = document.querySelector("link[rel=\"icon\"]") as HTMLLinkElement; - if (favicon) { - // Update the new link - favicon.href = url; - } else { - // Create new `link` - const link = document.createElement("link"); - link.rel = "icon"; - link.href = url; - - // Append to the `head` element - document.head.appendChild(link); - } -} -export function no_type_check(x: any) { - return x; -} -export function capitalise(value: string): string { - return value.charAt(0).toUpperCase() + value.slice(1); -} - -export function set_emoji_favicon(emoji: string) { - // Create a canvas element - const canvas = document.createElement("canvas"); - canvas.height = 64; - canvas.width = 64; - - // Get the canvas context - const context = canvas.getContext("2d") as CanvasRenderingContext2D; - context.font = "64px serif"; - context.fillText(emoji, 0, 64); - - // Get the custom URL - const url = canvas.toDataURL(); - - // Update the favicon - set_favicon(url); -} - - -// https://stackoverflow.com/a/48400665/11961742 -export function seconds_to_hour_minute_string(seconds: number, hourChar = "h", minuteChar = "m") { - const hours = Math.floor(seconds / (60 * 60)); - seconds -= hours * (60 * 60); - const minutes = Math.floor(seconds / 60); - return hours + "h" + minutes + "m"; -} - -export function seconds_to_hour_minute(seconds: number) { - const hours = Math.floor(seconds / (60 * 60)); - seconds -= hours * (60 * 60); - const minutes = Math.floor(seconds / 60); - return { hours, minutes }; -} - -export function get_query_string(params: any = {}): string { - const map = Object.keys(params).reduce((arr: Array, key: string) => { - if (params[key] !== undefined) { - return arr.concat(`${key}=${encodeURIComponent(params[key])}`); - } - return arr; - }, [] as any); - - if (map.length) { - return `?${map.join("&")}`; - } - - return ""; -} - -export function make_url(url: string, params: object): string { - return `${url}${get_query_string(params)}`; -} - -export function noop() { -} - -export async function run_async(functionToRun: Function): Promise { - return new Promise((greatSuccess, graveFailure) => { - try { - greatSuccess(functionToRun()); - } catch (exception) { - graveFailure(exception); - } - }); -} - -// https://stackoverflow.com/a/45215694/11961742 -export function get_selected_options(domElement: HTMLSelectElement): Array { - const ret = []; - - // fast but not universally supported - if (domElement.selectedOptions !== undefined) { - for (let i = 0; i < domElement.selectedOptions.length; i++) { - ret.push(domElement.selectedOptions[i].value); - } - - // compatible, but can be painfully slow - } else { - for (let i = 0; i < domElement.options.length; i++) { - if (domElement.options[i].selected) { - ret.push(domElement.options[i].value); - } - } - } - return ret; -} - -export function random_string(length: number): string { - if (!length) { - throw new Error("length is undefined"); - } - let result = ""; - const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - const charactersLength = characters.length; - for (let i = 0; i < length; i++) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; -} - -interface CreateElementOptions { - name: string, - properties?: object, - children?: Array -} - -export function create_element_from_object(elementOptions: CreateElementOptions): HTMLElement { - return create_element(elementOptions.name, elementOptions.properties, elementOptions.children); -} - -export function create_element(name: string, properties?: object, children?: Array): HTMLElement { - if (!name || name.length < 1) { - throw new Error("name is required"); - } - const node = document.createElement(name); - if (properties) { - for (const [key, value] of Object.entries(properties)) { - // @ts-ignore - node[key] = value; - } - } - - if (children && children.length > 0) { - let actualChildren = children; - if (typeof children === "function") { - // @ts-ignore - actualChildren = children(); - } - for (const child of actualChildren) { - node.appendChild(child as Node); - } - } - return node; -} - -export function get_element_position(element: HTMLElement | any) { - if (!element) return { x: 0, y: 0 }; - let x = 0; - let y = 0; - while (true) { - x += element.offsetLeft; - y += element.offsetTop; - if (element.offsetParent === null) { - break; - } - element = element.offsetParent; - } - return { x, y }; -} - -export function restrict_input_to_numbers(element: HTMLElement, specials: Array = [], mergeSpecialsWithDefaults: boolean = false): void { - if (element) { - element.addEventListener("keydown", (e) => { - const defaultSpecials = ["Backspace", "ArrowLeft", "ArrowRight", "Tab"]; - let keys = specials.length > 0 ? specials : defaultSpecials; - if (mergeSpecialsWithDefaults && specials) { - keys = [...specials, ...defaultSpecials]; - } - if (keys.indexOf(e.key) !== -1) { - return; - } - if (isNaN(parseInt(e.key))) { - e.preventDefault(); - } - }); - } -} - -export function element_has_focus(element: HTMLElement): boolean { - return element === document.activeElement; -} - -export function move_focus(element: HTMLElement): void { - if (!element) { - element = document.getElementsByTagName("body")[0]; - } - element.focus(); - // @ts-ignore - if (!element_has_focus(element)) { - element.setAttribute("tabindex", "-1"); - element.focus(); - } -} - -export function get_url_parameter(name: string): string { - // @ts-ignore - return new RegExp("[?&]" + name + "=([^&#]*)")?.exec(window.location.href)[1]; -} - -export function update_url_parameter(param: string, newVal: string): void { - let newAdditionalURL = ""; - let tempArray = location.href.split("?"); - const baseURL = tempArray[0]; - const additionalURL = tempArray[1]; - let temp = ""; - if (additionalURL) { - tempArray = additionalURL.split("&"); - for (let i = 0; i < tempArray.length; i++) { - if (tempArray[i].split("=")[0] !== param) { - newAdditionalURL += temp + tempArray[i]; - temp = "&"; - } - } - } - const rows_txt = temp + "" + param + "=" + newVal; - const newUrl = baseURL + "?" + newAdditionalURL + rows_txt; - window.history.replaceState("", "", newUrl); -} - - -export function get_style_string(rules: CSSRuleList) { - let styleString = ""; - for (const [key, value] of Object.entries(rules)) { - styleString += key + ":" + value + ";"; - } - return styleString; -} - -export function parse_iso_local(s: string) { - const b = s.split(/\D/); - //@ts-ignore - return new Date(b[0], b[1] - 1, b[2], b[3], b[4], b[5]); -} - -export function resolve_references(json: any) { - if (!json) return; - if (typeof json === "string") { - json = JSON.parse(json ?? "{}"); - } - const byid = {}, refs = []; - json = function recurse(obj, prop, parent) { - if (typeof obj !== "object" || !obj) { - return obj; - } - if (Object.prototype.toString.call(obj) === "[object Array]") { - for (let i = 0; i < obj.length; i++) { - if (typeof obj[i] !== "object" || !obj[i]) { - continue; - } else if ("$ref" in obj[i]) { - // @ts-ignore - obj[i] = recurse(obj[i], i, obj); - } else { - obj[i] = recurse(obj[i], prop, obj); - } - } - return obj; - } - if ("$ref" in obj) { - let ref = obj.$ref; - if (ref in byid) { - // @ts-ignore - return byid[ref]; - } - refs.push([parent, prop, ref]); - return; - } else if ("$id" in obj) { - let id = obj.$id; - delete obj.$id; - if ("$values" in obj) { - obj = obj.$values.map(recurse); - } else { - for (let prop2 in obj) { - // @ts-ignore - obj[prop2] = recurse(obj[prop2], prop2, obj); - } - } - // @ts-ignore - byid[id] = obj; - } - return obj; - }(json); - for (let i = 0; i < refs.length; i++) { - let ref = refs[i]; - // @ts-ignore - ref[0][ref[1]] = byid[ref[2]]; - } - return json; -} - -export function get_random_int(min: number, max: number): number { - min = Math.ceil(min); - max = Math.floor(max); - return Math.floor(Math.random() * (max - min + 1)) + min; -} - -export function to_readable_bytes(bytes: number): string { - const s = ["bytes", "kB", "MB", "GB", "TB", "PB"]; - const e = Math.floor(Math.log(bytes) / Math.log(1024)); - return (bytes / Math.pow(1024, e)).toFixed(2) + " " + s[e]; -} - -export function can_use_dom(): boolean { - return !!(typeof window !== "undefined" && window.document && window.document.createElement); -} - -export function session_storage_remove_regex(regex: RegExp): void { - if (!browser) { - logInfo("sessionStorage is not available in non-browser contexts"); - return; - } - let n = sessionStorage.length; - while (n--) { - const key = sessionStorage.key(n); - if (key && regex.test(key)) { - sessionStorage.removeItem(key); - } - } -} - -export function local_storage_remove_regex(regex: RegExp): void { - if (!browser) { - logInfo("sessionStorage is not available in non-browser contexts"); - return; - } - let n = localStorage.length; - while (n--) { - const key = localStorage.key(n); - if (key && regex.test(key)) { - localStorage.removeItem(key); - } - } -} - -export function session_storage_set_json(key: string, value: object): void { - if (!browser) { - console.warn("sessionStorage is not available in non-browser contexts"); - return; - } - sessionStorage.setItem(key, JSON.stringify(value)); -} - -export function session_storage_get_json(key: string): object { - if (!browser) { - console.warn("sessionStorage is not available in non-browser contexts"); - return {}; - } - return JSON.parse(sessionStorage.getItem(key) ?? "{}"); -} - -export function local_storage_set_json(key: string, value: object): void { - if (!browser) { - console.warn("sessionStorage is not available in non-browser contexts"); - return; - } - localStorage.setItem(key, JSON.stringify(value)); -} - -export function local_storage_get_json(key: string): object { - if (!browser) { - console.warn("sessionStorage is not available in non-browser contexts"); - return {}; - } - return JSON.parse(localStorage.getItem(key) ?? "{}"); -} - -export function get_hash_code(value: string): number | undefined { - let hash = 0; - if (value.length === 0) { - return; - } - for (let i = 0; i < value.length; i++) { - const char = value.charCodeAt(i); - hash = (hash << 5) - hash + char; - hash |= 0; - } - return hash; -} diff --git a/apps/kit/src/lib/i18n/en/app/index.ts b/apps/kit/src/lib/i18n/en/app/index.ts deleted file mode 100644 index 7cd05ee..0000000 --- a/apps/kit/src/lib/i18n/en/app/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { BaseTranslation } from '../../i18n-types' - -const en_app: BaseTranslation = {} - -export default en_app \ No newline at end of file diff --git a/apps/kit/src/lib/i18n/en/index.ts b/apps/kit/src/lib/i18n/en/index.ts deleted file mode 100644 index e084a6c..0000000 --- a/apps/kit/src/lib/i18n/en/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { BaseTranslation } from "../i18n-types"; - -const en: BaseTranslation = { - or: "Or", - emailAddress: "Email address", - password: "Password", - pageNotFound: "Page not found", - noInternet: "It seems like your device does not have a internet connection, please check your connection.", - reset: "Reset", - of: "{0} of {1}", - isRequired: "{0} is required", - submit: "Submit", - success: "Success", - tryAgainSoon: "Try again soon", - createANewAccount: "Create a new account", - unexpectedError: "An unexpected error occured", - notFound: "Not found", - documentation: "Documentation", - tos: "Terms of service", - privacyPolicy: "Privacy policy", - signIntoYourAccount: "Sign into your account", - signInPage: { - notMyComputer: "This is not my computer", - resetPassword: "Reset password", - yourPasswordIsUpdated: "Your password is updated", - signIn: "Sign In", - yourNewPasswordIsApplied: "Your new password is applied", - signInBelow: "Sign in below", - yourAccountIsDisabled: "Your account is disabled", - contactYourAdminIfDisabled: "Contact your administrator if this feels wrong", - youHaveReachedInactivityLimit: "You've reached the hidden inactivity limit", - feelFreeToSignInAgain: "Feel free to sign in again" - }, - signUpPage: { - createYourNewAccount: "Create your new account", - }, - resetPasswordPage: { - setANewPassword: "Set a new password", - expired: "Expired", - requestHasExpired: "Your request has expired", - requestANewReset: "Request a new reset", - newPassword: "New password", - requestSentMessage: "If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account.", - requestAPasswordReset: "Request a password reset", - requestNotFound: "Your request was not found", - submitANewRequestBelow: "Submit a new reset request below" - } -}; - -export default en; diff --git a/apps/kit/src/lib/i18n/formatters.ts b/apps/kit/src/lib/i18n/formatters.ts deleted file mode 100644 index 5232b7d..0000000 --- a/apps/kit/src/lib/i18n/formatters.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { capitalise } from '$lib/helpers' -import type { FormattersInitializer } from 'typesafe-i18n' -import type { Locales, Formatters } from './i18n-types' - -export const initFormatters: FormattersInitializer = (locale: Locales) => { - - const formatters: Formatters = { - // add your formatter functions here - capitalise: (value: string) => capitalise(value) - } - - return formatters -} diff --git a/apps/kit/src/lib/i18n/i18n-svelte.ts b/apps/kit/src/lib/i18n/i18n-svelte.ts deleted file mode 100644 index 6cdffb3..0000000 --- a/apps/kit/src/lib/i18n/i18n-svelte.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { initI18nSvelte } from 'typesafe-i18n/svelte' -import type { Formatters, Locales, TranslationFunctions, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales } from './i18n-util' - -const { locale, LL, setLocale } = initI18nSvelte(loadedLocales, loadedFormatters) - -export { locale, LL, setLocale } - -export default LL diff --git a/apps/kit/src/lib/i18n/i18n-types.ts b/apps/kit/src/lib/i18n/i18n-types.ts deleted file mode 100644 index 0df6d1a..0000000 --- a/apps/kit/src/lib/i18n/i18n-types.ts +++ /dev/null @@ -1,359 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ -import type { BaseTranslation as BaseTranslationType, LocalizedString, RequiredParams } from 'typesafe-i18n' - -export type BaseTranslation = BaseTranslationType & DisallowNamespaces -export type BaseLocale = 'en' - -export type Locales = - | 'en' - | 'nb' - -export type Translation = RootTranslation & DisallowNamespaces - -export type Translations = RootTranslation & -{ - app: NamespaceAppTranslation -} - -type RootTranslation = { - /** - * O​r - */ - or: string - /** - * E​m​a​i​l​ ​a​d​d​r​e​s​s - */ - emailAddress: string - /** - * P​a​s​s​w​o​r​d - */ - password: string - /** - * P​a​g​e​ ​n​o​t​ ​f​o​u​n​d - */ - pageNotFound: string - /** - * I​t​ ​s​e​e​m​s​ ​l​i​k​e​ ​y​o​u​r​ ​d​e​v​i​c​e​ ​d​o​e​s​ ​n​o​t​ ​h​a​v​e​ ​a​ ​i​n​t​e​r​n​e​t​ ​c​o​n​n​e​c​t​i​o​n​,​ ​p​l​e​a​s​e​ ​c​h​e​c​k​ ​y​o​u​r​ ​c​o​n​n​e​c​t​i​o​n​. - */ - noInternet: string - /** - * R​e​s​e​t - */ - reset: string - /** - * {​0​}​ ​o​f​ ​{​1​} - * @param {unknown} 0 - * @param {unknown} 1 - */ - of: RequiredParams<'0' | '1'> - /** - * {​0​}​ ​i​s​ ​r​e​q​u​i​r​e​d - * @param {unknown} 0 - */ - isRequired: RequiredParams<'0'> - /** - * S​u​b​m​i​t - */ - submit: string - /** - * S​u​c​c​e​s​s - */ - success: string - /** - * T​r​y​ ​a​g​a​i​n​ ​s​o​o​n - */ - tryAgainSoon: string - /** - * C​r​e​a​t​e​ ​a​ ​n​e​w​ ​a​c​c​o​u​n​t - */ - createANewAccount: string - /** - * A​n​ ​u​n​e​x​p​e​c​t​e​d​ ​e​r​r​o​r​ ​o​c​c​u​r​e​d - */ - unexpectedError: string - /** - * N​o​t​ ​f​o​u​n​d - */ - notFound: string - /** - * D​o​c​u​m​e​n​t​a​t​i​o​n - */ - documentation: string - /** - * T​e​r​m​s​ ​o​f​ ​s​e​r​v​i​c​e - */ - tos: string - /** - * P​r​i​v​a​c​y​ ​p​o​l​i​c​y - */ - privacyPolicy: string - /** - * S​i​g​n​ ​i​n​t​o​ ​y​o​u​r​ ​a​c​c​o​u​n​t - */ - signIntoYourAccount: string - signInPage: { - /** - * T​h​i​s​ ​i​s​ ​n​o​t​ ​m​y​ ​c​o​m​p​u​t​e​r - */ - notMyComputer: string - /** - * R​e​s​e​t​ ​p​a​s​s​w​o​r​d - */ - resetPassword: string - /** - * Y​o​u​r​ ​p​a​s​s​w​o​r​d​ ​i​s​ ​u​p​d​a​t​e​d - */ - yourPasswordIsUpdated: string - /** - * S​i​g​n​ ​I​n - */ - signIn: string - /** - * Y​o​u​r​ ​n​e​w​ ​p​a​s​s​w​o​r​d​ ​i​s​ ​a​p​p​l​i​e​d - */ - yourNewPasswordIsApplied: string - /** - * S​i​g​n​ ​i​n​ ​b​e​l​o​w - */ - signInBelow: string - /** - * Y​o​u​r​ ​a​c​c​o​u​n​t​ ​i​s​ ​d​i​s​a​b​l​e​d - */ - yourAccountIsDisabled: string - /** - * C​o​n​t​a​c​t​ ​y​o​u​r​ ​a​d​m​i​n​i​s​t​r​a​t​o​r​ ​i​f​ ​t​h​i​s​ ​f​e​e​l​s​ ​w​r​o​n​g - */ - contactYourAdminIfDisabled: string - /** - * Y​o​u​'​v​e​ ​r​e​a​c​h​e​d​ ​t​h​e​ ​h​i​d​d​e​n​ ​i​n​a​c​t​i​v​i​t​y​ ​l​i​m​i​t - */ - youHaveReachedInactivityLimit: string - /** - * F​e​e​l​ ​f​r​e​e​ ​t​o​ ​s​i​g​n​ ​i​n​ ​a​g​a​i​n - */ - feelFreeToSignInAgain: string - } - signUpPage: { - /** - * C​r​e​a​t​e​ ​y​o​u​r​ ​n​e​w​ ​a​c​c​o​u​n​t - */ - createYourNewAccount: string - } - resetPasswordPage: { - /** - * S​e​t​ ​a​ ​n​e​w​ ​p​a​s​s​w​o​r​d - */ - setANewPassword: string - /** - * E​x​p​i​r​e​d - */ - expired: string - /** - * Y​o​u​r​ ​r​e​q​u​e​s​t​ ​h​a​s​ ​e​x​p​i​r​e​d - */ - requestHasExpired: string - /** - * R​e​q​u​e​s​t​ ​a​ ​n​e​w​ ​r​e​s​e​t - */ - requestANewReset: string - /** - * N​e​w​ ​p​a​s​s​w​o​r​d - */ - newPassword: string - /** - * I​f​ ​w​e​ ​f​i​n​d​ ​y​o​u​r​ ​e​m​a​i​l​ ​a​d​d​r​e​s​s​ ​i​n​ ​o​u​r​ ​s​y​s​t​e​m​s​,​ ​y​o​u​ ​w​i​l​l​ ​r​e​c​e​i​v​e​ ​a​n​ ​e​m​a​i​l​ ​w​i​t​h​ ​i​n​s​t​r​u​c​t​i​o​n​s​ ​o​n​ ​h​o​w​ ​t​o​ ​s​e​t​ ​a​ ​n​e​w​ ​p​a​s​s​w​o​r​d​ ​f​o​r​ ​y​o​u​r​ ​a​c​c​o​u​n​t​. - */ - requestSentMessage: string - /** - * R​e​q​u​e​s​t​ ​a​ ​p​a​s​s​w​o​r​d​ ​r​e​s​e​t - */ - requestAPasswordReset: string - /** - * Y​o​u​r​ ​r​e​q​u​e​s​t​ ​w​a​s​ ​n​o​t​ ​f​o​u​n​d - */ - requestNotFound: string - /** - * S​u​b​m​i​t​ ​a​ ​n​e​w​ ​r​e​s​e​t​ ​r​e​q​u​e​s​t​ ​b​e​l​o​w - */ - submitANewRequestBelow: string - } -} - -export type NamespaceAppTranslation = {} - -export type Namespaces = - | 'app' - -type DisallowNamespaces = { - /** - * reserved for 'app'-namespace\ - * you need to use the `./app/index.ts` file instead - */ - app?: "[typesafe-i18n] reserved for 'app'-namespace. You need to use the `./app/index.ts` file instead." -} - -export type TranslationFunctions = { - /** - * Or - */ - or: () => LocalizedString - /** - * Email address - */ - emailAddress: () => LocalizedString - /** - * Password - */ - password: () => LocalizedString - /** - * Page not found - */ - pageNotFound: () => LocalizedString - /** - * It seems like your device does not have a internet connection, please check your connection. - */ - noInternet: () => LocalizedString - /** - * Reset - */ - reset: () => LocalizedString - /** - * {0} of {1} - */ - of: (arg0: unknown, arg1: unknown) => LocalizedString - /** - * {0} is required - */ - isRequired: (arg0: unknown) => LocalizedString - /** - * Submit - */ - submit: () => LocalizedString - /** - * Success - */ - success: () => LocalizedString - /** - * Try again soon - */ - tryAgainSoon: () => LocalizedString - /** - * Create a new account - */ - createANewAccount: () => LocalizedString - /** - * An unexpected error occured - */ - unexpectedError: () => LocalizedString - /** - * Not found - */ - notFound: () => LocalizedString - /** - * Documentation - */ - documentation: () => LocalizedString - /** - * Terms of service - */ - tos: () => LocalizedString - /** - * Privacy policy - */ - privacyPolicy: () => LocalizedString - /** - * Sign into your account - */ - signIntoYourAccount: () => LocalizedString - signInPage: { - /** - * This is not my computer - */ - notMyComputer: () => LocalizedString - /** - * Reset password - */ - resetPassword: () => LocalizedString - /** - * Your password is updated - */ - yourPasswordIsUpdated: () => LocalizedString - /** - * Sign In - */ - signIn: () => LocalizedString - /** - * Your new password is applied - */ - yourNewPasswordIsApplied: () => LocalizedString - /** - * Sign in below - */ - signInBelow: () => LocalizedString - /** - * Your account is disabled - */ - yourAccountIsDisabled: () => LocalizedString - /** - * Contact your administrator if this feels wrong - */ - contactYourAdminIfDisabled: () => LocalizedString - /** - * You've reached the hidden inactivity limit - */ - youHaveReachedInactivityLimit: () => LocalizedString - /** - * Feel free to sign in again - */ - feelFreeToSignInAgain: () => LocalizedString - } - signUpPage: { - /** - * Create your new account - */ - createYourNewAccount: () => LocalizedString - } - resetPasswordPage: { - /** - * Set a new password - */ - setANewPassword: () => LocalizedString - /** - * Expired - */ - expired: () => LocalizedString - /** - * Your request has expired - */ - requestHasExpired: () => LocalizedString - /** - * Request a new reset - */ - requestANewReset: () => LocalizedString - /** - * New password - */ - newPassword: () => LocalizedString - /** - * If we find your email address in our systems, you will receive an email with instructions on how to set a new password for your account. - */ - requestSentMessage: () => LocalizedString - /** - * Request a password reset - */ - requestAPasswordReset: () => LocalizedString - /** - * Your request was not found - */ - requestNotFound: () => LocalizedString - /** - * Submit a new reset request below - */ - submitANewRequestBelow: () => LocalizedString - } - app: { - } -} - -export type Formatters = {} diff --git a/apps/kit/src/lib/i18n/i18n-util.async.ts b/apps/kit/src/lib/i18n/i18n-util.async.ts deleted file mode 100644 index 00b8e0a..0000000 --- a/apps/kit/src/lib/i18n/i18n-util.async.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { initFormatters } from './formatters' -import type { Locales, Namespaces, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' - -const localeTranslationLoaders = { - en: () => import('./en'), - nb: () => import('./nb'), -} - -const localeNamespaceLoaders = { - en: { - app: () => import('./en/app') - }, - nb: { - app: () => import('./nb/app') - } -} - -const updateDictionary = (locale: Locales, dictionary: Partial) => - loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary } - -export const importLocaleAsync = async (locale: Locales) => - (await localeTranslationLoaders[locale]()).default as unknown as Translations - -export const loadLocaleAsync = async (locale: Locales): Promise => { - updateDictionary(locale, await importLocaleAsync(locale)) - loadFormatters(locale) -} - -export const loadAllLocalesAsync = (): Promise => Promise.all(locales.map(loadLocaleAsync)) - -export const loadFormatters = (locale: Locales): void => - void (loadedFormatters[locale] = initFormatters(locale)) - -export const importNamespaceAsync = async(locale: Locales, namespace: Namespace) => - (await localeNamespaceLoaders[locale][namespace]()).default as unknown as Translations[Namespace] - -export const loadNamespaceAsync = async (locale: Locales, namespace: Namespace): Promise => - void updateDictionary(locale, { [namespace]: await importNamespaceAsync(locale, namespace )}) diff --git a/apps/kit/src/lib/i18n/i18n-util.sync.ts b/apps/kit/src/lib/i18n/i18n-util.sync.ts deleted file mode 100644 index 8144fdc..0000000 --- a/apps/kit/src/lib/i18n/i18n-util.sync.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { initFormatters } from './formatters' -import type { Locales, Translations } from './i18n-types' -import { loadedFormatters, loadedLocales, locales } from './i18n-util' - -import en from './en' -import nb from './nb' - -import en_app from './en/app' -import nb_app from './nb/app' - -const localeTranslations = { - en: { - ...en, - app: en_app - }, - nb: { - ...nb, - app: nb_app - }, -} - -export const loadLocale = (locale: Locales): void => { - if (loadedLocales[locale]) return - - loadedLocales[locale] = localeTranslations[locale] as unknown as Translations - loadFormatters(locale) -} - -export const loadAllLocales = (): void => locales.forEach(loadLocale) - -export const loadFormatters = (locale: Locales): void => - void (loadedFormatters[locale] = initFormatters(locale)) diff --git a/apps/kit/src/lib/i18n/i18n-util.ts b/apps/kit/src/lib/i18n/i18n-util.ts deleted file mode 100644 index 35f023c..0000000 --- a/apps/kit/src/lib/i18n/i18n-util.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten. -/* eslint-disable */ - -import { i18n as initI18n, i18nObject as initI18nObject, i18nString as initI18nString } from 'typesafe-i18n' -import type { LocaleDetector } from 'typesafe-i18n/detectors' -import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors' -import type { Formatters, Locales, Namespaces, Translations, TranslationFunctions } from './i18n-types' - -export const baseLocale: Locales = 'en' - -export const locales: Locales[] = [ - 'en', - 'nb' -] - -export const namespaces: Namespaces[] = [ - 'app' -] - -export const isLocale = (locale: string) => locales.includes(locale as Locales) - -export const isNamespace = (namespace: string) => namespaces.includes(namespace as Namespaces) - -export const loadedLocales = {} as Record - -export const loadedFormatters = {} as Record - -export const i18nString = (locale: Locales) => initI18nString(locale, loadedFormatters[locale]) - -export const i18nObject = (locale: Locales) => - initI18nObject( - locale, - loadedLocales[locale], - loadedFormatters[locale] - ) - -export const i18n = () => initI18n(loadedLocales, loadedFormatters) - -export const detectLocale = (...detectors: LocaleDetector[]) => detectLocaleFn(baseLocale, locales, ...detectors) diff --git a/apps/kit/src/lib/i18n/nb/app/index.ts b/apps/kit/src/lib/i18n/nb/app/index.ts deleted file mode 100644 index 15d0b9a..0000000 --- a/apps/kit/src/lib/i18n/nb/app/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { NamespaceAppTranslation } from '../../i18n-types' - -const nb_app: NamespaceAppTranslation = { - // TODO: insert translations - -} - -export default nb_app diff --git a/apps/kit/src/lib/i18n/nb/index.ts b/apps/kit/src/lib/i18n/nb/index.ts deleted file mode 100644 index fa81477..0000000 --- a/apps/kit/src/lib/i18n/nb/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { Translation } from "../i18n-types"; - -const nb: Translation = { - or: "Eller", - emailAddress: "E-postadresse", - password: "Passord", - pageNotFound: "Fant ikke siden", - noInternet: "Det ser ut som at du ikke tilkoblet internettet, sjekk tilkoblingen din for å fortsette", - reset: "Tilbakestill", - of: "{0} av {1}", - isRequired: "{0} er påkrevd", - submit: "Send", - success: "Suksess", - tryAgainSoon: "Prøv igjen snart", - createANewAccount: "Lag en ny konto", - unexpectedError: "En uventet feil oppstod", - notFound: "Ikke funnet", - documentation: "Dokumentasjon", - tos: "Vilkår", - privacyPolicy: "Personvernerklæring", - signIntoYourAccount: "Logg inn med din konto", - signInPage: { - notMyComputer: "Dette er ikke min datamaskin", - resetPassword: "Tilbakestill passord", - yourPasswordIsUpdated: "Ditt passord er oppdater", - signIn: "Logg inn", - yourNewPasswordIsApplied: "Ditt nye passord er satt", - signInBelow: "Logg inn nedenfor", - yourAccountIsDisabled: "Din konto er deaktivert", - contactYourAdminIfDisabled: "Ta kontakt med din administrator hvis dette føles feil", - youHaveReachedInactivityLimit: "Du har nådd den hemmelige inaktivitetsgrensen", - feelFreeToSignInAgain: "Logg gjerne inn igjen" - }, - signUpPage: { - createYourNewAccount: "Opprett din nye konto", - }, - resetPasswordPage: { - setANewPassword: "Skriv et nytt passord", - expired: "Utgått", - requestHasExpired: "Din forespørsel er utgått", - requestANewReset: "Spør om en ny tilbakestillingslenke", - newPassword: "Nytt passord", - requestSentMessage: "Hvis vi finner e-postadressen din i våre systemer, vil du få en e-post med instrukser for å sette ditt nye passord.", - requestAPasswordReset: "Forespør tilbakestilling av ditt passord", - requestNotFound: "Din forespørsel ble ikke funnet", - submitANewRequestBelow: "Spør om en ny tilbakestillingslenke nedenfor" - } -} - -export default nb; \ No newline at end of file diff --git a/apps/kit/src/lib/logger.ts b/apps/kit/src/lib/logger.ts deleted file mode 100644 index df0a821..0000000 --- a/apps/kit/src/lib/logger.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { browser, dev } from "$app/environment"; -import { StorageKeys } from "$lib/configuration"; -import pino from "pino"; - -const pinoConfig = dev ? { - transport: { - target: "pino-pretty", - } -} : {}; - -const pinoLogger = pino(pinoConfig); - -function browserLogLevel(): number { - if (browser) return LogLevel.toNumber(sessionStorage.getItem(StorageKeys.logLevel), LogLevel.INFO); - throw new Error("Called browser api in server"); -} - -function serverLogLevel(): number { - if (!browser) return LogLevel.toNumber(import.meta.env.VITE_LOG_LEVEL, LogLevel.ERROR); - throw new Error("Called server api in browser"); -} - -export const LogLevel = { - DEBUG: 0, - INFO: 1, - ERROR: 2, - SILENT: 3, - toString(levelInt: number): string { - switch (levelInt) { - case 0: - return "DEBUG"; - case 1: - return "INFO"; - case 2: - return "ERROR"; - case 3: - return "SILENT"; - default: - throw new Error("Log level int is unknown"); - } - }, - toNumber(levelString?: string | null, fallback?: number): number { - if (!levelString && fallback) return fallback; - else if (!levelString && !fallback) throw new Error("levelString was empty, and no fallback was specified"); - switch (levelString?.toUpperCase()) { - case "DEBUG": - return 0; - case "INFO": - return 1; - case "ERROR": - return 2; - case "SILENT": - return 3; - default: - if (!fallback) throw new Error("Log level string is unknown"); - else return fallback; - } - }, -}; - -export function logDebug(message: string, ...additional: any[]): void { - if (browser && browserLogLevel() <= LogLevel.DEBUG) { - pinoLogger.debug(message, additional); - } - if (!browser && serverLogLevel() <= LogLevel.DEBUG) { - pinoLogger.debug(message, additional); - } -} - -export function logInfo(message: string, ...additional: any[]): void { - if (browser && browserLogLevel() <= LogLevel.INFO) { - pinoLogger.info(message, additional); - } - if (!browser && serverLogLevel() <= LogLevel.INFO) { - pinoLogger.info(message, additional); - } -} - -export function logError(message: any, ...additional: any[]): void { - if (browser && browserLogLevel() <= LogLevel.ERROR) { - pinoLogger.error(message, additional); - } - if (!browser && serverLogLevel() <= LogLevel.ERROR) { - pinoLogger.error(message, additional); - } -} \ No newline at end of file diff --git a/apps/kit/src/lib/models/CreateAccountPayload.ts b/apps/kit/src/lib/models/CreateAccountPayload.ts deleted file mode 100644 index d116308..0000000 --- a/apps/kit/src/lib/models/CreateAccountPayload.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface CreateAccountPayload { - username: string, - password: string -} diff --git a/apps/kit/src/lib/models/ErrorResult.ts b/apps/kit/src/lib/models/ErrorResult.ts deleted file mode 100644 index 7c70017..0000000 --- a/apps/kit/src/lib/models/ErrorResult.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ErrorResult { - title: string, - text: string -} diff --git a/apps/kit/src/lib/models/IInternalFetchRequest.ts b/apps/kit/src/lib/models/IInternalFetchRequest.ts deleted file mode 100644 index 68505e2..0000000 --- a/apps/kit/src/lib/models/IInternalFetchRequest.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface IInternalFetchRequest { - url: string, - init?: RequestInit, - timeout?: number - retry_count?: number -} diff --git a/apps/kit/src/lib/models/IInternalFetchResponse.ts b/apps/kit/src/lib/models/IInternalFetchResponse.ts deleted file mode 100644 index 6c91b35..0000000 --- a/apps/kit/src/lib/models/IInternalFetchResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface IInternalFetchResponse { - ok: boolean, - status: number, - data: any, - http_response: Response -} diff --git a/apps/kit/src/lib/models/ISession.ts b/apps/kit/src/lib/models/ISession.ts deleted file mode 100644 index 7587145..0000000 --- a/apps/kit/src/lib/models/ISession.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface ISession { - profile: { - username: string, - displayName: string, - id: string, - }, - lastChecked: number, -} \ No newline at end of file diff --git a/apps/kit/src/lib/models/IValidationResult.ts b/apps/kit/src/lib/models/IValidationResult.ts deleted file mode 100644 index 9a21b13..0000000 --- a/apps/kit/src/lib/models/IValidationResult.ts +++ /dev/null @@ -1,31 +0,0 @@ -export interface IValidationResult { - errors: Array, - has_errors: Function, - add_error: Function, - remove_error: Function, -} - -export interface IValidationError { - _id?: string, - title: string, - text?: string -} - -export default class ValidationResult implements IValidationResult { - errors: IValidationError[] - has_errors(): boolean { - return this.errors?.length > 0; - } - add_error(prop: string, error: IValidationError): void { - if (!this.errors) this.errors = []; - error._id = prop; - this.errors.push(error); - } - remove_error(property: string): void { - const new_errors = []; - for (const error of this.errors) { - if (error._id != property) new_errors.push(error) - } - this.errors = new_errors; - } -} diff --git a/apps/kit/src/lib/models/LoginPayload.ts b/apps/kit/src/lib/models/LoginPayload.ts deleted file mode 100644 index beb96cf..0000000 --- a/apps/kit/src/lib/models/LoginPayload.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface LoginPayload { - username: string, - password: string, - persist: boolean -} diff --git a/apps/kit/src/lib/models/TimeCategoryDto.ts b/apps/kit/src/lib/models/TimeCategoryDto.ts deleted file mode 100644 index fcdb7ea..0000000 --- a/apps/kit/src/lib/models/TimeCategoryDto.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Temporal } from "temporal-polyfill"; - -export interface TimeCategoryDto { - selected?: boolean; - id?: string, - modified_at?: Temporal.PlainDate, - name?: string, - color?: string -} diff --git a/apps/kit/src/lib/models/TimeEntryDto.ts b/apps/kit/src/lib/models/TimeEntryDto.ts deleted file mode 100644 index 571c52e..0000000 --- a/apps/kit/src/lib/models/TimeEntryDto.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { TimeLabelDto } from "./TimeLabelDto"; -import type { TimeCategoryDto } from "./TimeCategoryDto"; -import { Temporal } from "temporal-polyfill"; - -export interface TimeEntryDto { - id: string, - modified_at?: Temporal.PlainDate, - start: string, - stop: string, - description: string, - labels?: Array, - category: TimeCategoryDto, -} diff --git a/apps/kit/src/lib/models/TimeEntryQuery.ts b/apps/kit/src/lib/models/TimeEntryQuery.ts deleted file mode 100644 index d983d1a..0000000 --- a/apps/kit/src/lib/models/TimeEntryQuery.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { TimeCategoryDto } from "./TimeCategoryDto"; -import type { TimeLabelDto } from "./TimeLabelDto"; -import type { Temporal } from "temporal-polyfill"; - -export interface TimeEntryQuery { - duration: TimeEntryQueryDuration, - categories?: Array, - labels?: Array, - dateRange?: TimeEntryQueryDateRange, - specificDate?: Temporal.PlainDateTime - page: number, - pageSize: number -} - -export interface TimeEntryQueryDateRange { - from: Temporal.PlainDateTime, - to: Temporal.PlainDateTime -} - -export enum TimeEntryQueryDuration { - TODAY = 0, - THIS_WEEK = 1, - THIS_MONTH = 2, - THIS_YEAR = 3, - SPECIFIC_DATE = 4, - DATE_RANGE = 5, -} diff --git a/apps/kit/src/lib/models/TimeLabelDto.ts b/apps/kit/src/lib/models/TimeLabelDto.ts deleted file mode 100644 index 7183bcf..0000000 --- a/apps/kit/src/lib/models/TimeLabelDto.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Temporal } from "temporal-polyfill"; - -export interface TimeLabelDto { - id?: string, - modified_at?: Temporal.PlainDate, - name?: string, - color?: string -} diff --git a/apps/kit/src/lib/models/TimeQueryDto.ts b/apps/kit/src/lib/models/TimeQueryDto.ts deleted file mode 100644 index 607c51e..0000000 --- a/apps/kit/src/lib/models/TimeQueryDto.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { TimeEntryDto } from "./TimeEntryDto"; -import ValidationResult, { IValidationResult } from "./IValidationResult"; - -export interface ITimeQueryDto { - results: Array, - page: number, - pageSize: number, - totalRecords: number, - totalPageCount: number, - is_valid: Function -} - -export class TimeQueryDto implements ITimeQueryDto { - results: TimeEntryDto[]; - page: number; - pageSize: number; - totalRecords: number; - totalPageCount: number; - - is_valid(): IValidationResult { - const result = new ValidationResult(); - if (this.page < 0) { - result.add_error("page", { - title: "Page cannot be less than zero", - }) - } - return result; - } -} diff --git a/apps/kit/src/lib/models/UnwrappedEntryDateTime.ts b/apps/kit/src/lib/models/UnwrappedEntryDateTime.ts deleted file mode 100644 index d614f91..0000000 --- a/apps/kit/src/lib/models/UnwrappedEntryDateTime.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Temporal } from "temporal-polyfill"; - -export interface UnwrappedEntryDateTime { - start_date: Temporal.PlainDate, - stop_date: Temporal.PlainDate, - start_time: Temporal.PlainTime, - stop_time: Temporal.PlainTime, - duration: Temporal.Duration, -} diff --git a/apps/kit/src/lib/models/UpdateProfilePayload.ts b/apps/kit/src/lib/models/UpdateProfilePayload.ts deleted file mode 100644 index d2983ff..0000000 --- a/apps/kit/src/lib/models/UpdateProfilePayload.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface UpdateProfilePayload { - username?: string, - password?: string, -} diff --git a/apps/kit/src/lib/persistent-store.ts b/apps/kit/src/lib/persistent-store.ts deleted file mode 100644 index 922f3ab..0000000 --- a/apps/kit/src/lib/persistent-store.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { writable as _writable, readable as _readable, } from "svelte/store"; -import type { Writable, Readable, StartStopNotifier } from "svelte/store"; - -enum StoreType { - SESSION = 0, - LOCAL = 1 -} - -interface StoreOptions { - store?: StoreType; -} - -const default_store_options = { - store: StoreType.SESSION -} as StoreOptions; - -interface WritableStore { - name: string, - initialState: T, - options?: StoreOptions -} - -interface ReadableStore { - name: string, - initialState: T, - callback: StartStopNotifier, - options?: StoreOptions -} - -function get_store(type: StoreType): Storage { - switch (type) { - case StoreType.SESSION: - return window.sessionStorage; - case StoreType.LOCAL: - return window.localStorage; - } -} - -function prepared_store_value(value: any): string { - try { - return JSON.stringify(value); - } catch (e) { - console.error(e); - return "__INVALID__"; - } -} - -function get_store_value(options: WritableStore | ReadableStore): any { - try { - const storage = get_store(options.options.store); - const value = storage.getItem(options.name); - if (!value) return false; - return JSON.parse(value); - } catch (e) { - console.error(e); - return { __INVALID__: true }; - } -} - -function hydrate(store: Writable, options: WritableStore | ReadableStore): void { - const value = get_store_value(options); - if (value && store.set) store.set(value); -} - -function subscribe(store: Writable | Readable, options: WritableStore | ReadableStore): void { - const storage = get_store(options.options.store); - if (!store.subscribe) return; - store.subscribe((state: any) => { - storage.setItem(options.name, prepared_store_value(state)); - }); -} - -function writable_persistent(options: WritableStore): Writable { - if (options.options === undefined) options.options = default_store_options; - console.log("Creating writable store with options: ", options); - const store = _writable(options.initialState); - hydrate(store, options); - subscribe(store, options); - return store; -} - -function readable_persistent(options: ReadableStore): Readable { - if (options.options === undefined) options.options = default_store_options; - console.log("Creating readable store with options: ", options); - const store = _readable(options.initialState, options.callback); - // hydrate(store, options); - subscribe(store, options); - return store; -} - -export { - writable_persistent, - readable_persistent, - StoreType -}; - -export type { - WritableStore, - ReadableStore, - StoreOptions -}; - diff --git a/apps/kit/src/lib/session.ts b/apps/kit/src/lib/session.ts deleted file mode 100644 index ee79933..0000000 --- a/apps/kit/src/lib/session.ts +++ /dev/null @@ -1,69 +0,0 @@ -import {logError, logInfo} from "$lib/logger"; -import { Temporal } from "temporal-polyfill"; -import { get_profile_for_active_check, logout } from "./api/user"; -import { is_guid, session_storage_get_json, session_storage_set_json } from "./helpers"; -import { SECONDS_BETWEEN_SESSION_CHECK, StorageKeys } from "./configuration"; -import type { ISession } from "$lib/models/ISession"; - -export async function is_active(forceRefresh: boolean = false): Promise { - const nowEpoch = Temporal.Now.instant().epochSeconds; - const data = session_storage_get_json(StorageKeys.session) as ISession; - const expiryEpoch = data?.lastChecked + SECONDS_BETWEEN_SESSION_CHECK; - const lastCheckIsStaleOrNone = !is_guid(data?.profile?.id) || (expiryEpoch < nowEpoch); - if (forceRefresh || lastCheckIsStaleOrNone) { - return await call_api(); - } else { - const sessionIsValid = data.profile && is_guid(data.profile.id); - if (!sessionIsValid) { - clear_session_data(); - logInfo("Session data is not valid"); - } - return sessionIsValid; - } -} - -export async function end_session(cb: Function): Promise { - await logout(); - clear_session_data(); - cb(); -} - -async function call_api(): Promise { - logInfo("Getting profile data while checking session state"); - try { - const response = await get_profile_for_active_check(); - if (response.ok) { - const userData = await response.data; - if (is_guid(userData.id) && userData.username) { - const session = { - profile: userData, - lastChecked: Temporal.Now.instant().epochSeconds - } as ISession; - session_storage_set_json(StorageKeys.session, session); - logInfo("Successfully got profile data while checking session state"); - return true; - } else { - logError("Api returned invalid data while getting profile data"); - clear_session_data(); - return false; - } - } else { - logError("Api returned unsuccessfully while getting profile data"); - clear_session_data(); - return false; - } - } catch (e) { - logError(e); - clear_session_data(); - return false; - } -} - -export function clear_session_data() { - session_storage_set_json(StorageKeys.session, {}); - logInfo("Cleared session data."); -} - -export function get_session_data(): ISession { - return session_storage_get_json(StorageKeys.session) as ISession; -} diff --git a/apps/kit/src/params/guid.ts b/apps/kit/src/params/guid.ts deleted file mode 100644 index d8f7231..0000000 --- a/apps/kit/src/params/guid.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {is_guid} from "$lib/helpers"; - -export function match(param: string): boolean { - return is_guid(param); -} \ No newline at end of file diff --git a/apps/kit/src/params/integer.ts b/apps/kit/src/params/integer.ts deleted file mode 100644 index 6e36cd8..0000000 --- a/apps/kit/src/params/integer.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function match(param: string): boolean { - return /^\d+$/.test(param); -} \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(app)/+layout.svelte b/apps/kit/src/routes/(main)/(app)/+layout.svelte deleted file mode 100644 index 0be6ff3..0000000 --- a/apps/kit/src/routes/(main)/(app)/+layout.svelte +++ /dev/null @@ -1,297 +0,0 @@ - - -
- - - (sidebarOpen = false)}> - -
- - -
- - - -
- -
-
- -
-
- -
-
-
- - - - - -
- -
- -
-
-
- -
- -
-
-
-
- - -
- - Open user menu - -
- - -
- - View profile - - - Settings - -
- - sign_out()} class="text-gray-700 block px-4 py-2 text-sm"> Sign out - -
-
-
-
-
-
-
-
-
- -
-
-
diff --git a/apps/kit/src/routes/(main)/(app)/home/+page.svelte b/apps/kit/src/routes/(main)/(app)/home/+page.svelte deleted file mode 100644 index 247ee47..0000000 --- a/apps/kit/src/routes/(main)/(app)/home/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -

Welcome Home

\ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(app)/org/+page.svelte b/apps/kit/src/routes/(main)/(app)/org/+page.svelte deleted file mode 100644 index 429ec25..0000000 --- a/apps/kit/src/routes/(main)/(app)/org/+page.svelte +++ /dev/null @@ -1,4 +0,0 @@ - - -

$ORGNAME

diff --git a/apps/kit/src/routes/(main)/(app)/profile/+page.svelte b/apps/kit/src/routes/(main)/(app)/profile/+page.svelte deleted file mode 100644 index 7c6eb3e..0000000 --- a/apps/kit/src/routes/(main)/(app)/profile/+page.svelte +++ /dev/null @@ -1,4 +0,0 @@ - - -

Hi, Ivar

diff --git a/apps/kit/src/routes/(main)/(app)/projects/+page.svelte b/apps/kit/src/routes/(main)/(app)/projects/+page.svelte deleted file mode 100644 index 6413e1d..0000000 --- a/apps/kit/src/routes/(main)/(app)/projects/+page.svelte +++ /dev/null @@ -1,4 +0,0 @@ - - -

Projects

diff --git a/apps/kit/src/routes/(main)/(app)/settings/+page.svelte b/apps/kit/src/routes/(main)/(app)/settings/+page.svelte deleted file mode 100644 index ae6d403..0000000 --- a/apps/kit/src/routes/(main)/(app)/settings/+page.svelte +++ /dev/null @@ -1,4 +0,0 @@ - - -

Settings

diff --git a/apps/kit/src/routes/(main)/(app)/tickets/+page.svelte b/apps/kit/src/routes/(main)/(app)/tickets/+page.svelte deleted file mode 100644 index 2a4792b..0000000 --- a/apps/kit/src/routes/(main)/(app)/tickets/+page.svelte +++ /dev/null @@ -1,4 +0,0 @@ - - -

Tickets

diff --git a/apps/kit/src/routes/(main)/(app)/todo/+page.svelte b/apps/kit/src/routes/(main)/(app)/todo/+page.svelte deleted file mode 100644 index e29f263..0000000 --- a/apps/kit/src/routes/(main)/(app)/todo/+page.svelte +++ /dev/null @@ -1,4 +0,0 @@ - - -

Todo

diff --git a/apps/kit/src/routes/(main)/(app)/wiki/+page.svelte b/apps/kit/src/routes/(main)/(app)/wiki/+page.svelte deleted file mode 100644 index 1762d43..0000000 --- a/apps/kit/src/routes/(main)/(app)/wiki/+page.svelte +++ /dev/null @@ -1,4 +0,0 @@ - - -

Wiki

diff --git a/apps/kit/src/routes/(main)/(public)/+layout.svelte b/apps/kit/src/routes/(main)/(public)/+layout.svelte deleted file mode 100644 index 69c29c5..0000000 --- a/apps/kit/src/routes/(main)/(public)/+layout.svelte +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte b/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte deleted file mode 100644 index aa26892..0000000 --- a/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte +++ /dev/null @@ -1,82 +0,0 @@ - - -
-
-

- {$LL.resetPasswordPage.requestAPasswordReset()} -

-

- {$LL.or().toLowerCase()} - - {$LL.signIntoYourAccount().toLowerCase()} - -

-
- -
-
-
- - - - - -
-
-
diff --git a/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts b/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts deleted file mode 100644 index 389d04c..0000000 --- a/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { is_guid } from '$lib/helpers'; -import { redirect } from '@sveltejs/kit'; -import type { PageServerLoad } from './$types'; - -export const load: PageServerLoad = async ({ params }) => { - const resetRequestId = params.id ?? ""; - if (!is_guid(resetRequestId)) throw redirect(302, "/reset-password"); - return { - resetRequestId - }; -}; \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte b/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte deleted file mode 100644 index 562d902..0000000 --- a/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte +++ /dev/null @@ -1,132 +0,0 @@ - - -
- {#if finishedPreliminaryLoading} -
-

- {$LL.resetPasswordPage.setANewPassword()} -

-

- {$LL.or().toLowerCase()} - - {$LL.signIntoYourAccount().toLowerCase()} - -

-
- -
-
-
- {#if errorState === "404"} - - {:else if errorState === "expired"} - - {:else if errorState === "unknown"} - - {/if} - - - -
-
- {:else} -

Checking your request...

- {/if} -
diff --git a/apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte b/apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte deleted file mode 100644 index 101b49d..0000000 --- a/apps/kit/src/routes/(main)/(public)/sign-in/+page.svelte +++ /dev/null @@ -1,153 +0,0 @@ - - - - -
- {#if messageType} -
- {#if messageType === "after-password-reset"} - - {:else if messageType === "user-disabled"} - - {:else if messageType === "user-inactivity"} - - {/if} -
- {/if} -
-

- {$LL.signInPage.signIn()} -

-

- {$LL.or().toLowerCase()} - {$LL.createANewAccount().toLowerCase()} -

-
-
-
- {#if showErrorAlert} - - {/if} -
- - - - - - -
-
-
diff --git a/apps/kit/src/routes/(main)/(public)/sign-in/test.ts b/apps/kit/src/routes/(main)/(public)/sign-in/test.ts deleted file mode 100644 index 27af2ea..0000000 --- a/apps/kit/src/routes/(main)/(public)/sign-in/test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { get_test_context } from "$lib/configuration"; -import { get_element_by_pw_key } from "$lib/helpers"; -import { test, expect } from "@playwright/test"; -import { signInPageTestKeys } from "./+page.svelte"; - -const context = get_test_context(); - -test("form loads", async ({ page }) => { - await page.goto("/sign-up"); - const formElement = get_element_by_pw_key(signInPageTestKeys.signUpForm); - expect(formElement).toBeTruthy(); -}); \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte b/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte deleted file mode 100644 index 0dfa41a..0000000 --- a/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte +++ /dev/null @@ -1,82 +0,0 @@ - - -
-
-

- {$LL.signUpPage.createYourNewAccount()} -

-

- {$LL.or().toLowerCase()} - - {$LL.signIntoYourAccount().toLowerCase()} - -

-
- -
-
- -
- - - -
-
-
diff --git a/apps/kit/src/routes/(main)/+layout.server.ts b/apps/kit/src/routes/(main)/+layout.server.ts deleted file mode 100644 index d2eb2eb..0000000 --- a/apps/kit/src/routes/(main)/+layout.server.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { api_base, CookieNames } from "$lib/configuration"; -import { logError } from "$lib/logger"; -import { error, redirect } from "@sveltejs/kit"; -import type { LayoutServerLoad } from "./$types"; - -export const load: LayoutServerLoad = async ({ routeId, cookies, locals }) => { - const isPublicRoute = (routeId?.startsWith("(main)/(public)") || routeId === "(main)") ?? true; - - let sessionIsValid = (await fetch(api_base("_/valid-session"), { - headers: { - Cookie: CookieNames.session + "=" + cookies.get(CookieNames.session) - } - }).catch((e) => { - logError(e); - throw error(503, { - message: "We are experiencing a service distruption! Have patience while we resolve the issue." - }) - })).ok; - - console.log("Base Layout loaded", { - sessionIsValid, - isPublicRoute, - routeId - }); - - if (sessionIsValid && isPublicRoute) { - throw redirect(302, "/home"); - } else if (!sessionIsValid && !isPublicRoute) { - throw redirect(302, "/sign-in"); - } - return { - locale: locals.locale - } -}; \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/+layout.svelte b/apps/kit/src/routes/(main)/+layout.svelte deleted file mode 100644 index 1a870bb..0000000 --- a/apps/kit/src/routes/(main)/+layout.svelte +++ /dev/null @@ -1,29 +0,0 @@ - - - - -{#if !online} -
-
-
- -
-
-

You seem to be offline, please check your internet connection.

-
-
-
-{/if} - - - diff --git a/apps/kit/src/routes/(main)/+layout.ts b/apps/kit/src/routes/(main)/+layout.ts deleted file mode 100644 index 5d0e005..0000000 --- a/apps/kit/src/routes/(main)/+layout.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { LayoutLoad } from './$types' -import type { Locales } from '$lib/i18n/i18n-types' -import { loadLocaleAsync } from '$lib/i18n/i18n-util.async' -import { setLocale } from '$lib/i18n/i18n-svelte' - -export const load: LayoutLoad<{ locale: Locales }> = async ({ data: { locale } }) => { - // load dictionary into memory - await loadLocaleAsync(locale) - - // if you need to output a localized string in a `load` function, - // you always need to call `setLocale` right before you access the `LL` store - setLocale(locale) - // pass locale to the "rendering context" - return { locale } -} \ No newline at end of file diff --git a/apps/kit/src/routes/(main)/+page.svelte b/apps/kit/src/routes/(main)/+page.svelte deleted file mode 100644 index e507a19..0000000 --- a/apps/kit/src/routes/(main)/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -

Hold on...

diff --git a/apps/kit/src/routes/book/+layout.svelte b/apps/kit/src/routes/book/+layout.svelte deleted file mode 100644 index aeed0d4..0000000 --- a/apps/kit/src/routes/book/+layout.svelte +++ /dev/null @@ -1,64 +0,0 @@ - - -
- -
- -
-
- - diff --git a/apps/kit/src/routes/book/+page.svelte b/apps/kit/src/routes/book/+page.svelte deleted file mode 100644 index 635b3c2..0000000 --- a/apps/kit/src/routes/book/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -

A showcase of greatoffices components

diff --git a/apps/kit/src/routes/book/alerts/+page.svelte b/apps/kit/src/routes/book/alerts/+page.svelte deleted file mode 100644 index d008d85..0000000 --- a/apps/kit/src/routes/book/alerts/+page.svelte +++ /dev/null @@ -1,70 +0,0 @@ - - -
-

Info

- -
-
-

Warning

- -
-
-

Error

- -
-
-

Success

- -
-
-

Actions

- -
-
-

Right link

- alert("Right link clicked")} - rightLinkText="Link or action" - title="Go here" - message="Hehe" - type="error" - /> -
-
-

List

- { - alert("Repeat requested"); - }} - actions={[{ id: "repeat", text: "Try again" }]} - /> -
-
-

Closeable

- -
diff --git a/apps/kit/src/routes/book/buttons/+page.svelte b/apps/kit/src/routes/book/buttons/+page.svelte deleted file mode 100644 index 19ba163..0000000 --- a/apps/kit/src/routes/book/buttons/+page.svelte +++ /dev/null @@ -1,23 +0,0 @@ - - -
-

Primary

-
-
-

Secondary

-
-
-

White

-
-
-

Loading

-
diff --git a/apps/kit/src/routes/book/inputs/+page.svelte b/apps/kit/src/routes/book/inputs/+page.svelte deleted file mode 100644 index a693f69..0000000 --- a/apps/kit/src/routes/book/inputs/+page.svelte +++ /dev/null @@ -1,48 +0,0 @@ - - -
-

Default

- -
- -
-

With icon

- -
- -
-

With corner hint

- -
- -
-

Disabled

- -
- -
-

Errored

- -
- -
-

Help

- -
-
-

Addon

- -
diff --git a/apps/kit/src/routes/book/toggles/+page.svelte b/apps/kit/src/routes/book/toggles/+page.svelte deleted file mode 100644 index 94228b4..0000000 --- a/apps/kit/src/routes/book/toggles/+page.svelte +++ /dev/null @@ -1,27 +0,0 @@ - - -
-

Default

- -
-
-

Short

- -
-
-

Icon

- -
-
-

Label / Description

-
- -
-
- -
-

Label / Description (right aligned)

- -
\ No newline at end of file -- cgit v1.3