Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

View file

@ -0,0 +1,43 @@
//#region src/util/attempt.d.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param func - The function to execute.
* @returns A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
declare function attempt<T, E>(func: () => T): [null, T] | [E, null];
//#endregion
export { attempt };

View file

@ -0,0 +1,43 @@
//#region src/util/attempt.d.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param func - The function to execute.
* @returns A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
declare function attempt<T, E>(func: () => T): [null, T] | [E, null];
//#endregion
export { attempt };

49
frontend/node_modules/es-toolkit/dist/util/attempt.js generated vendored Normal file
View file

@ -0,0 +1,49 @@
//#region src/util/attempt.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param func - The function to execute.
* @returns A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
function attempt(func) {
try {
return [null, func()];
} catch (error) {
return [error, null];
}
}
//#endregion
exports.attempt = attempt;

49
frontend/node_modules/es-toolkit/dist/util/attempt.mjs generated vendored Normal file
View file

@ -0,0 +1,49 @@
//#region src/util/attempt.ts
/**
* Attempt to execute a function and return the result or error.
* Returns a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the function.
* @template {unknown} E - The type of the error that can be thrown by the function.
* @param func - The function to execute.
* @returns A tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, result] = attempt(() => 42);
* // [null, 42]
*
* // Failed execution
* const [error, result] = attempt(() => {
* throw new Error('Something went wrong');
* });
* // [Error, null]
*
* // With type parameter
* const [error, names] = attempt<string[]>(() => ['Alice', 'Bob']);
* // [null, ['Alice', 'Bob']]
*
* @note
* Important: This function is not suitable for async functions (functions that return a `Promise`).
* When passing an async function, it will return `[null, Promise<Result>]`, but won't catch any
* errors if the Promise is rejected later.
*
* For handling async functions, use the `attemptAsync` function instead:
* ```
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* ```
*/
function attempt(func) {
try {
return [null, func()];
} catch (error) {
return [error, null];
}
}
//#endregion
export { attempt };

View file

@ -0,0 +1,36 @@
//#region src/util/attemptAsync.d.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param func - The async function to execute.
* @returns A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
declare function attemptAsync<T, E>(func: () => Promise<T>): Promise<[null, T] | [E, null]>;
//#endregion
export { attemptAsync };

View file

@ -0,0 +1,36 @@
//#region src/util/attemptAsync.d.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param func - The async function to execute.
* @returns A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
declare function attemptAsync<T, E>(func: () => Promise<T>): Promise<[null, T] | [E, null]>;
//#endregion
export { attemptAsync };

View file

@ -0,0 +1,42 @@
//#region src/util/attemptAsync.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param func - The async function to execute.
* @returns A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
async function attemptAsync(func) {
try {
return [null, await func()];
} catch (error) {
return [error, null];
}
}
//#endregion
exports.attemptAsync = attemptAsync;

View file

@ -0,0 +1,42 @@
//#region src/util/attemptAsync.ts
/**
* Attempt to execute an async function and return the result or error.
* Returns a Promise that resolves to a tuple where:
* - On success: [null, Result] - First element is null, second is the result
* - On error: [Error, null] - First element is the caught error, second is null
*
* @template {unknown} T - The type of the result of the async function.
* @template {unknown} E - The type of the error that can be thrown by the async function.
* @param func - The async function to execute.
* @returns A Promise that resolves to a tuple containing either [null, result] or [error, null].
*
* @example
* // Successful execution
* const [error, data] = await attemptAsync(async () => {
* const response = await fetch('https://api.example.com/data');
* return response.json();
* });
* // If successful: [null, { ... data ... }]
*
* // Failed execution
* const [error, data] = await attemptAsync(async () => {
* throw new Error('Network error');
* });
* // [Error, null]
*
* // With type parameter
* const [error, users] = await attemptAsync<User[]>(async () => {
* const response = await fetch('https://api.example.com/users');
* return response.json();
* });
* // users is typed as User[]
*/
async function attemptAsync(func) {
try {
return [null, await func()];
} catch (error) {
return [error, null];
}
}
//#endregion
export { attemptAsync };

View file

@ -0,0 +1,4 @@
import { attempt } from "./attempt.mjs";
import { attemptAsync } from "./attemptAsync.mjs";
import { invariant } from "./invariant.mjs";
export { invariant as assert, attempt, attemptAsync, invariant };

View file

@ -0,0 +1,4 @@
import { attempt } from "./attempt.js";
import { attemptAsync } from "./attemptAsync.js";
import { invariant } from "./invariant.js";
export { invariant as assert, attempt, attemptAsync, invariant };

8
frontend/node_modules/es-toolkit/dist/util/index.js generated vendored Normal file
View file

@ -0,0 +1,8 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_attempt = require("./attempt.js");
const require_attemptAsync = require("./attemptAsync.js");
const require_invariant = require("./invariant.js");
exports.assert = require_invariant.invariant;
exports.attempt = require_attempt.attempt;
exports.attemptAsync = require_attemptAsync.attemptAsync;
exports.invariant = require_invariant.invariant;

4
frontend/node_modules/es-toolkit/dist/util/index.mjs generated vendored Normal file
View file

@ -0,0 +1,4 @@
import { attempt } from "./attempt.mjs";
import { attemptAsync } from "./attemptAsync.mjs";
import { invariant } from "./invariant.mjs";
export { invariant as assert, attempt, attemptAsync, invariant };

View file

@ -0,0 +1,41 @@
//#region src/util/invariant.d.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param condition - The condition to evaluate.
* @param message - The error message to throw if the condition is false.
* @returns Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*/
declare function invariant(condition: unknown, message: string): asserts condition;
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided error.
*
* @param condition - The condition to evaluate.
* @param error - The error to throw if the condition is false.
* @returns Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, new Error('This should not throw'));
*
* class CustomError extends Error {
* constructor(message: string) {
* super(message);
* }
* }
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, new CustomError('This should throw'));
*/
declare function invariant(condition: unknown, error: Error): asserts condition;
//#endregion
export { invariant };

View file

@ -0,0 +1,41 @@
//#region src/util/invariant.d.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param condition - The condition to evaluate.
* @param message - The error message to throw if the condition is false.
* @returns Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*/
declare function invariant(condition: unknown, message: string): asserts condition;
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided error.
*
* @param condition - The condition to evaluate.
* @param error - The error to throw if the condition is false.
* @returns Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, new Error('This should not throw'));
*
* class CustomError extends Error {
* constructor(message: string) {
* super(message);
* }
* }
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, new CustomError('This should throw'));
*/
declare function invariant(condition: unknown, error: Error): asserts condition;
//#endregion
export { invariant };

View file

@ -0,0 +1,32 @@
//#region src/util/invariant.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param condition - The condition to evaluate.
* @param [message] - The error message to throw if the condition is false.
* @returns Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*
* // Example of using invariant with a condition
* invariant(condition, 'Expected condition is false');
*
* // Ensure that the value is neither null nor undefined
* invariant(value !== null && value !== undefined, 'Value should not be null or undefined');
*
* // Example of using invariant to check if a number is positive
* invariant(number > 0, 'Number must be positive');
*/
function invariant(condition, message) {
if (condition) return;
if (typeof message === "string") throw new Error(message);
throw message;
}
//#endregion
exports.invariant = invariant;

View file

@ -0,0 +1,32 @@
//#region src/util/invariant.ts
/**
* Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
*
* @param condition - The condition to evaluate.
* @param [message] - The error message to throw if the condition is false.
* @returns Returns void if the condition is true.
* @throws {Error} Throws an error if the condition is false.
*
* @example
* // This call will succeed without any errors
* invariant(true, 'This should not throw');
*
* // This call will fail and throw an error with the message 'This should throw'
* invariant(false, 'This should throw');
*
* // Example of using invariant with a condition
* invariant(condition, 'Expected condition is false');
*
* // Ensure that the value is neither null nor undefined
* invariant(value !== null && value !== undefined, 'Value should not be null or undefined');
*
* // Example of using invariant to check if a number is positive
* invariant(number > 0, 'Number must be positive');
*/
function invariant(condition, message) {
if (condition) return;
if (typeof message === "string") throw new Error(message);
throw message;
}
//#endregion
export { invariant };