intial commit

This commit is contained in:
Ned Halksworth
2026-05-15 21:36:13 +01:00
committed by Ned
parent 012b900716
commit bd3e970286
12 changed files with 566 additions and 2457 deletions
+378 -1086
View File
File diff suppressed because it is too large Load Diff
+12 -17
View File
@@ -1,25 +1,20 @@
import type { Flavour } from "../types";
export const BUILT_IN_FLAVOURS: Flavour[] = [
{ name: "Original", accent: "#282874" },
{ name: "Zero", accent: "#B1D0EE", sugarFree: true },
{ name: "Sugar Free", accent: "#009EDF", sugarFree: true },
{ name: "Ruby", accent: "#B50045" },
{ name: "Iced Vanilla", accent: "#53B2C2" },
{ name: "Tropical", accent: "#FFCB04" },
{ name: "Cherry Edition", accent: "#D81B60" },
{ name: "Apricot Edition", accent: "#F3911B" },
{ name: "Lilac Sugarfree", accent: "#7D62CE", sugarFree: true },
{ name: "Pink Sugarfree", accent: "#E77BAB", sugarFree: true },
{ name: "Watermelon", accent: "#E6301F" },
{ name: "Original", accent: "#00A7FF" },
{ name: "Sugar Free", accent: "#E7EEF8", sugarFree: true },
{ name: "Ruby", accent: "#C3093B" },
{ name: "Iced Vanilla", accent: "#49adbe" },
{ name: "Tropical", accent: "#FFC247" },
{ name: "Watermelon", accent: "#FF355E" },
{ name: "Blueberry", accent: "#496DFF" },
{ name: "Coconut Berry", accent: "#0070B8" },
{ name: "Peach", accent: "#E24585" },
{ name: "Juneberry", accent: "#0085C8" },
{ name: "Coconut Berry", accent: "#D8F9FF" },
{ name: "Peach", accent: "#FF9B63" },
{ name: "Juneberry", accent: "#9C73FF" },
{ name: "Dragon Fruit", accent: "#FF3DBD" },
{ name: "Curuba Elderflower", accent: "#78B941" },
{ name: "Winter Edition", accent: "#BF1431" },
{ name: "Summer Edition", accent: "#F2E853" },
{ name: "Curuba Elderflower", accent: "#B7FF4A" },
{ name: "Winter Edition", accent: "#7CE7FF" },
{ name: "Summer Edition", accent: "#f0e53b" },
{ name: "Other", accent: "#AEB9C7" },
];
+128 -1002
View File
File diff suppressed because it is too large Load Diff
+17 -6
View File
@@ -1,16 +1,15 @@
import { Account, Channel, Client, ID, Permission, Query, Role, TablesDB } from "appwrite";
import { Account, Channel, Client, ID, OAuthProvider, Permission, Query, Role, TablesDB } from "appwrite";
const env = import.meta.env;
const currentOrigin = window.location.origin;
export const appwriteConfig = {
endpoint: env.VITE_APPWRITE_ENDPOINT || "https://fra.cloud.appwrite.io/v1",
projectId: env.VITE_APPWRITE_PROJECT_ID!,
projectId: env.VITE_APPWRITE_PROJECT_ID || "6a0752ee001fb2ef7138",
databaseId: env.VITE_APPWRITE_DATABASE_ID || "redbull_tracker",
collectionId: env.VITE_APPWRITE_COLLECTION_ID || "intake_entries",
chatCollectionId: env.VITE_APPWRITE_CHAT_COLLECTION_ID || "coach_chats",
barcodeCollectionId: env.VITE_APPWRITE_BARCODE_COLLECTION_ID || "barcode_products",
oauthSuccessUrl: resolveOAuthUrl(env.VITE_APPWRITE_OAUTH_SUCCESS_URL),
oauthFailureUrl: resolveOAuthUrl(env.VITE_APPWRITE_OAUTH_FAILURE_URL),
};
const client = new Client()
@@ -24,6 +23,18 @@ export async function pingAppwrite() {
return client.ping();
}
export { account, Channel, client, ID, Permission, Query, Role, tablesDB };
export { account, Channel, client, ID, OAuthProvider, Permission, Query, Role, tablesDB };
function resolveOAuthUrl(value?: string) {
if (!value) return currentOrigin;
const configured = new URL(value, currentOrigin);
const current = new URL(currentOrigin);
const localHosts = new Set(["localhost", "127.0.0.1", "::1"]);
if (env.DEV && localHosts.has(configured.hostname) && localHosts.has(current.hostname)) {
return currentOrigin;
}
return configured.toString().replace(/\/$/, "");
}
-88
View File
@@ -34,57 +34,6 @@ export type EntryDraft = Omit<
source?: RedBullEntry["source"];
};
export type BarcodeFormatName = "ean-13" | "ean-8" | "upc-a" | "upc-e" | "unknown";
export type BarcodeProductDraft = {
flavourName: string;
sizeMl: number;
pricePerCan: number;
sugarFree?: boolean;
caffeineMgPerCan?: number;
};
export type ResolvedBarcodeProduct = BarcodeProductDraft & {
flavourAccent: string;
source: "built-in" | "user";
};
export type BarcodeSeedProduct = BarcodeProductDraft & {
verifiedBy: string;
sourceName?: string;
sourceUrl?: string;
notes?: string;
variant?: string;
};
export type UserBarcodeMapping = BarcodeProductDraft & {
barcode: string;
createdAt: string;
updatedAt: string;
};
export type BarcodeLookupCatalog = {
verifiedProducts?: Record<string, BarcodeSeedProduct>;
userMappings?: UserBarcodeMapping[];
};
export type BarcodeLookupResult =
| {
status: "known" | "user";
barcode: string;
product: ResolvedBarcodeProduct;
}
| {
status: "partial";
barcode: string;
product: BarcodeProductDraft;
reason: string;
}
| {
status: "unknown";
barcode: string;
};
export type Filters = {
flavour: string;
dateRange: DateFilter;
@@ -105,40 +54,3 @@ export type ImportPreview = {
fileName: string;
rows: ImportPreviewRow[];
};
export type ChatRole = "user" | "assistant";
export type CoachMessage = {
id: string;
role: ChatRole;
content: string;
thinking?: string;
pending?: boolean;
stopped?: boolean;
};
export type CoachChat = {
id: string;
userId: string;
title: string;
messages: CoachMessage[];
createdAt: string;
updatedAt: string;
};
export type UserLimits = {
dailyCanLimit?: number;
dailySpendLimit?: number;
stopTime?: string;
};
export type LimitViolation = "cans" | "spend" | "stopTime";
export type LimitCheckResult = {
violations: LimitViolation[];
projectedCans: number;
projectedSpend: number;
todayCans: number;
todaySpend: number;
pastStopTime: boolean;
};
-3
View File
@@ -5,11 +5,8 @@ interface ImportMetaEnv {
readonly VITE_APPWRITE_PROJECT_ID?: string;
readonly VITE_APPWRITE_DATABASE_ID?: string;
readonly VITE_APPWRITE_COLLECTION_ID?: string;
readonly VITE_APPWRITE_CHAT_COLLECTION_ID?: string;
readonly VITE_APPWRITE_BARCODE_COLLECTION_ID?: string;
readonly VITE_APPWRITE_OAUTH_SUCCESS_URL?: string;
readonly VITE_APPWRITE_OAUTH_FAILURE_URL?: string;
readonly VITE_OLLAMA_PROXY_URL?: string;
}
interface ImportMeta {