Compare commits
2 Commits
f17daa2c78
...
upgrade-ze
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7adb76f752 | ||
|
|
018dab38c0 |
@@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hono/node-server": "^1.19.5",
|
"@hono/node-server": "^1.19.5",
|
||||||
"@money/shared": "workspace:*",
|
"@money/shared": "link:../shared",
|
||||||
"better-auth": "^1.3.27",
|
"better-auth": "^1.3.27",
|
||||||
"hono": "^4.9.12",
|
"hono": "^4.9.12",
|
||||||
"plaid": "^39.0.0",
|
"plaid": "^39.0.0",
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { betterAuth } from "better-auth";
|
import { betterAuth } from "better-auth";
|
||||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||||
import { bearer, deviceAuthorization, genericOAuth } from "better-auth/plugins";
|
import { genericOAuth } from "better-auth/plugins";
|
||||||
import { expo } from "@better-auth/expo";
|
import { expo } from "@better-auth/expo";
|
||||||
import { drizzleSchema } from "@money/shared/db";
|
import { drizzleSchema } from "@money/shared/db";
|
||||||
import { db } from "./db";
|
import { db } from "./db";
|
||||||
@@ -37,8 +37,6 @@ export const auth = betterAuth({
|
|||||||
scopes: ["profile", "email"],
|
scopes: ["profile", "email"],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}),
|
})
|
||||||
deviceAuthorization(),
|
|
||||||
bearer(),
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -99,8 +99,6 @@ const createMutators = (authData: AuthData | null) => {
|
|||||||
id: randomUUID(),
|
id: randomUUID(),
|
||||||
userId: authData.user.id,
|
userId: authData.user.id,
|
||||||
token: data.access_token,
|
token: data.access_token,
|
||||||
logoUrl: "",
|
|
||||||
name: ""
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -4,10 +4,10 @@ import 'react-native-reanimated';
|
|||||||
import { authClient } from '@/lib/auth-client';
|
import { authClient } from '@/lib/auth-client';
|
||||||
import { ZeroProvider } from '@rocicorp/zero/react';
|
import { ZeroProvider } from '@rocicorp/zero/react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { authDataSchema } from '@money/shared/auth';
|
import { authDataSchema } from '@/shared/src/auth';
|
||||||
import { Platform } from 'react-native';
|
import { Platform } from 'react-native';
|
||||||
import type { ZeroOptions } from '@rocicorp/zero';
|
import type { ZeroOptions } from '@rocicorp/zero';
|
||||||
import { schema, type Schema, createMutators, type Mutators, BASE_URL } from '@money/shared';
|
import { schema, type Schema, createMutators, type Mutators, BASE_URL } from '@/shared/src';
|
||||||
import { expoSQLiteStoreProvider } from "@rocicorp/zero/react-native";
|
import { expoSQLiteStoreProvider } from "@rocicorp/zero/react-native";
|
||||||
|
|
||||||
export const unstable_settings = {
|
export const unstable_settings = {
|
||||||
@@ -44,8 +44,8 @@ export default function RootLayout() {
|
|||||||
<ZeroProvider {...zeroProps}>
|
<ZeroProvider {...zeroProps}>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Stack.Protected guard={!isPending && !!session}>
|
<Stack.Protected guard={!isPending && !!session}>
|
||||||
<Stack.Screen name="[...route]" options={{ headerShown: false }} />
|
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||||
<Stack.Screen name="approve" />
|
<Stack.Screen name="settings" options={{ headerShown: false }} />
|
||||||
</Stack.Protected>
|
</Stack.Protected>
|
||||||
<Stack.Protected guard={!isPending && !session}>
|
<Stack.Protected guard={!isPending && !session}>
|
||||||
<Stack.Screen name="auth" />
|
<Stack.Screen name="auth" />
|
||||||
99
app/index.web.tsx
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
import { authClient } from '@/lib/auth-client';
|
||||||
|
import { Button, Image, Platform, Pressable, ScrollView, Text, View } from 'react-native';
|
||||||
|
import { useQuery, useZero } from "@rocicorp/zero/react";
|
||||||
|
import { queries, type Mutators, type Schema } from '@money/shared';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Link } from 'expo-router';
|
||||||
|
|
||||||
|
export default function HomeScreen() {
|
||||||
|
const { data: session } = authClient.useSession();
|
||||||
|
|
||||||
|
const z = useZero<Schema, Mutators>();
|
||||||
|
const [transactions] = useQuery(queries.allTransactions(session));
|
||||||
|
const [balances] = useQuery(queries.getBalances(session));
|
||||||
|
|
||||||
|
const [idx, setIdx] = useState(0);
|
||||||
|
const [accountIdx, setAccountIdx] = useState(0);
|
||||||
|
|
||||||
|
const account = balances.at(accountIdx)!;
|
||||||
|
|
||||||
|
const filteredTransactions = transactions
|
||||||
|
.filter(t => t.account_id == account.plaid_id)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (Platform.OS != 'web') return;
|
||||||
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === "j") {
|
||||||
|
setIdx((prevIdx) => {
|
||||||
|
if (prevIdx + 1 == filteredTransactions.length) return prevIdx;
|
||||||
|
return prevIdx + 1
|
||||||
|
});
|
||||||
|
} else if (event.key === "k") {
|
||||||
|
setIdx((prevIdx) => prevIdx == 0 ? 0 : prevIdx - 1);
|
||||||
|
} else if (event.key == 'g') {
|
||||||
|
setIdx(0);
|
||||||
|
} else if (event.key == "G") {
|
||||||
|
setIdx(transactions.length - 1);
|
||||||
|
} else if (event.key == 'R') {
|
||||||
|
z.mutate.link.updateTransactions();
|
||||||
|
z.mutate.link.updateBalences();
|
||||||
|
} else if (event.key == 'h') {
|
||||||
|
setAccountIdx((prevIdx) => prevIdx == 0 ? 0 : prevIdx - 1);
|
||||||
|
} else if (event.key == 'l') {
|
||||||
|
setAccountIdx((prevIdx) => {
|
||||||
|
if (prevIdx + 1 == balances.length) return prevIdx;
|
||||||
|
return prevIdx + 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("keydown", handleKeyDown);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("keydown", handleKeyDown);
|
||||||
|
};
|
||||||
|
}, [filteredTransactions, balances]);
|
||||||
|
|
||||||
|
function lpad(n: number): string {
|
||||||
|
const LEN = 9;
|
||||||
|
const nstr = n.toFixed(2).toLocaleString();
|
||||||
|
return Array.from({ length: LEN - nstr.length }).join(" ") + nstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function uuu(t: typeof filteredTransactions[number]): string | undefined {
|
||||||
|
if (!t.json) return;
|
||||||
|
const j = JSON.parse(t.json);
|
||||||
|
return j.counterparties.filter((c: any) => !!c.logo_url).at(0)?.logo_url || j.personal_finance_category_icon_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Link prefetch href="/settings">
|
||||||
|
<Button title="Settings" />
|
||||||
|
</Link>
|
||||||
|
<View style={{ flexDirection: "row" }}>
|
||||||
|
<View style={{ backgroundColor: '' }}>
|
||||||
|
{balances.map((bal, i) => <View key={bal.id} style={{ backgroundColor: i == accountIdx ? 'black' : undefined}}>
|
||||||
|
<Text style={{ fontFamily: 'mono', color: i == accountIdx ? 'white' : undefined }}>{bal.name}: {bal.current} ({bal.avaliable})</Text>
|
||||||
|
</View>)}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View>
|
||||||
|
{filteredTransactions.map((t, i) => <Pressable onHoverIn={() => {
|
||||||
|
setIdx(i);
|
||||||
|
}} style={{ backgroundColor: i == idx ? 'black' : undefined, cursor: 'default' as 'auto' }} key={t.id}>
|
||||||
|
<Text style={{ fontFamily: 'mono', color: i == idx ? 'white' : undefined }}>
|
||||||
|
{new Date(t.datetime!).toDateString()}
|
||||||
|
<Text style={{ color: t.amount > 0 ? 'red' : 'green' }}> {lpad(t.amount)}</Text>
|
||||||
|
<Image style={{ width: 15, height: 15, marginHorizontal: 10 }} source={{ uri: uuu(t) || "" }} />
|
||||||
|
{t.name.substring(0, 50)}
|
||||||
|
</Text>
|
||||||
|
</Pressable>)}
|
||||||
|
</View>
|
||||||
|
<ScrollView>
|
||||||
|
<Text style={{ fontFamily: 'mono' }}>{JSON.stringify(JSON.parse(filteredTransactions.at(idx)?.json || "null"), null, 4)}</Text>
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
41
app/settings.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
|
import { authClient } from '@/lib/auth-client';
|
||||||
|
import { Button, Linking, Text } from 'react-native';
|
||||||
|
import { useQuery, useZero } from "@rocicorp/zero/react";
|
||||||
|
import { queries, type Mutators, type Schema } from '@money/shared';
|
||||||
|
|
||||||
|
export default function HomeScreen() {
|
||||||
|
const { data: session } = authClient.useSession();
|
||||||
|
|
||||||
|
const onLogout = () => {
|
||||||
|
authClient.signOut();
|
||||||
|
}
|
||||||
|
const z = useZero<Schema, Mutators>();
|
||||||
|
const [user] = useQuery(queries.me(session));
|
||||||
|
const [plaidLink] = useQuery(queries.getPlaidLink(session));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView>
|
||||||
|
<Text>Hello {user?.name}</Text>
|
||||||
|
<Button onPress={onLogout} title="Logout" />
|
||||||
|
|
||||||
|
<Text>{JSON.stringify(plaidLink)}</Text>
|
||||||
|
{plaidLink ? <Button onPress={() => {
|
||||||
|
Linking.openURL(plaidLink.link);
|
||||||
|
}} title="Open Plaid" /> : <Text>No plaid link</Text>}
|
||||||
|
|
||||||
|
<Button onPress={() => {
|
||||||
|
z.mutate.link.create();
|
||||||
|
}} title="Generate Link" />
|
||||||
|
|
||||||
|
{plaidLink && <Button onPress={() => {
|
||||||
|
z.mutate.link.get({ link_token: plaidLink.token });
|
||||||
|
}} title="Check Link" />}
|
||||||
|
|
||||||
|
{plaidLink && <Button onPress={() => {
|
||||||
|
z.mutate.link.updateTransactions();
|
||||||
|
}} title="Update transactions" />}
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
6
apps/expo/.gitignore
vendored
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
|
|
||||||
# The following patterns were generated by expo-cli
|
|
||||||
|
|
||||||
expo-env.d.ts
|
|
||||||
# @end expo-cli
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import { useLocalSearchParams } from "expo-router";
|
|
||||||
import { Text } from "react-native";
|
|
||||||
import { App, type Route } from "@money/ui";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
const { route: initalRoute } = useLocalSearchParams<{ route: string[] }>();
|
|
||||||
const [route, setRoute] = useState(initalRoute ? "/" + initalRoute.join("/") : "/");
|
|
||||||
|
|
||||||
const { data } = authClient.useSession();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handler = () => {
|
|
||||||
const newRoute = window.location.pathname.slice(1);
|
|
||||||
setRoute(newRoute);
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener("popstate", handler);
|
|
||||||
return () => window.removeEventListener("popstate", handler);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<App
|
|
||||||
auth={data}
|
|
||||||
route={route as Route}
|
|
||||||
setRoute={(page) => {
|
|
||||||
window.history.pushState({}, "", page);
|
|
||||||
setRoute(page);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
import { useLocalSearchParams } from "expo-router";
|
|
||||||
import { useEffect } from "react";
|
|
||||||
import { Text } from "react-native";
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
const { code } = useLocalSearchParams<{code: string }>();
|
|
||||||
const { isPending, data } = authClient.useSession();
|
|
||||||
if (isPending) return <Text>Loading...</Text>;
|
|
||||||
if (!isPending && !data) return <Text>Please log in</Text>;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
authClient.device.approve({
|
|
||||||
userCode: code,
|
|
||||||
});
|
|
||||||
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return <Text>
|
|
||||||
Approving: {code}
|
|
||||||
</Text>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
import { queries } from "@money/shared";
|
|
||||||
import { useQuery } from "@rocicorp/zero/react";
|
|
||||||
import { Link, usePathname, useRouter, type LinkProps } from "expo-router";
|
|
||||||
import { useEffect } from "react";
|
|
||||||
import { View, Text, Platform } from "react-native";
|
|
||||||
|
|
||||||
type Page = { name: string, href: LinkProps['href'] };
|
|
||||||
const PAGES: Page[] = [
|
|
||||||
{
|
|
||||||
name: "Home",
|
|
||||||
href: "/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Settings",
|
|
||||||
href: "/settings",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
export default function Header() {
|
|
||||||
const router = useRouter();
|
|
||||||
const { data: session } = authClient.useSession();
|
|
||||||
const [user] = useQuery(queries.me(session));
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (Platform.OS != 'web') return;
|
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
|
||||||
if (event.key === "1" && event.ctrlKey) {
|
|
||||||
router.push(PAGES.at(0)!.href);
|
|
||||||
} else if (event.key === "2" && event.ctrlKey) {
|
|
||||||
router.push(PAGES.at(1)!.href);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener("keydown", handleKeyDown);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener("keydown", handleKeyDown);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={{ flexDirection: "row", justifyContent: "space-between", backgroundColor: "#f7e2c8" }}>
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
{PAGES.map(page => <Page
|
|
||||||
key={page.name}
|
|
||||||
name={page.name}
|
|
||||||
href={page.href}
|
|
||||||
/>)}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<Link href={"#" as any}>
|
|
||||||
<Text style={{ fontFamily: 'mono' }}>{user?.name} </Text>
|
|
||||||
</Link>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Page({ name, href }: Page) {
|
|
||||||
const path = usePathname();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Link href={href }>
|
|
||||||
<Text style={{ fontFamily: 'mono' }}>{path == href ? `[ ${name} ]` : ` ${name} `}</Text>
|
|
||||||
</Link>
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@money/expo",
|
|
||||||
"main": "expo-router/entry",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"scripts": {
|
|
||||||
"start": "expo start",
|
|
||||||
"reset-project": "node ./scripts/reset-project.js",
|
|
||||||
"android": "expo start --android",
|
|
||||||
"ios": "expo start --ios",
|
|
||||||
"web": "expo start --web",
|
|
||||||
"build": "expo export --platform web",
|
|
||||||
"lint": "expo lint",
|
|
||||||
"db:migrate": "dotenv -- pnpm run --dir=shared db:migrate",
|
|
||||||
"db:gen": "dotenv -- pnpm run --dir=shared generate:zero"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@better-auth/expo": "^1.3.27",
|
|
||||||
"@expo/vector-icons": "^15.0.2",
|
|
||||||
"@money/shared": "workspace:*",
|
|
||||||
"@money/ui": "workspace:*",
|
|
||||||
"@react-navigation/bottom-tabs": "^7.4.0",
|
|
||||||
"@react-navigation/elements": "^2.6.3",
|
|
||||||
"@react-navigation/native": "^7.1.8",
|
|
||||||
"@rocicorp/zero": "^0.23.2025090100",
|
|
||||||
"better-auth": "^1.3.27",
|
|
||||||
"drizzle-orm": "^0.44.6",
|
|
||||||
"expo": "~54.0.13",
|
|
||||||
"expo-constants": "~18.0.9",
|
|
||||||
"expo-crypto": "~15.0.7",
|
|
||||||
"expo-font": "~14.0.9",
|
|
||||||
"expo-haptics": "~15.0.7",
|
|
||||||
"expo-image": "~3.0.9",
|
|
||||||
"expo-linking": "~8.0.8",
|
|
||||||
"expo-router": "~6.0.11",
|
|
||||||
"expo-splash-screen": "~31.0.10",
|
|
||||||
"expo-sqlite": "~16.0.8",
|
|
||||||
"expo-status-bar": "~3.0.8",
|
|
||||||
"expo-symbols": "~1.0.7",
|
|
||||||
"expo-system-ui": "~6.0.7",
|
|
||||||
"expo-web-browser": "~15.0.8",
|
|
||||||
"pg": "^8.16.3",
|
|
||||||
"react": "19.1.0",
|
|
||||||
"react-dom": "19.1.0",
|
|
||||||
"react-native": "0.81.4",
|
|
||||||
"react-native-gesture-handler": "~2.28.0",
|
|
||||||
"react-native-reanimated": "~4.1.1",
|
|
||||||
"react-native-safe-area-context": "~5.6.0",
|
|
||||||
"react-native-screens": "~4.16.0",
|
|
||||||
"react-native-web": "~0.21.0",
|
|
||||||
"react-native-worklets": "0.5.1"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/pg": "^8.15.5",
|
|
||||||
"@types/react": "~19.1.0",
|
|
||||||
"dotenv-cli": "^10.0.0",
|
|
||||||
"drizzle-kit": "^0.31.5",
|
|
||||||
"eslint": "^9.25.0",
|
|
||||||
"eslint-config-expo": "~10.0.0",
|
|
||||||
"typescript": "~5.9.2"
|
|
||||||
},
|
|
||||||
"private": true
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "expo/tsconfig.base",
|
|
||||||
"compilerOptions": {
|
|
||||||
"strict": true,
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"paths": {
|
|
||||||
"@/*": ["./*"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"]
|
|
||||||
}
|
|
||||||
34
apps/tui/.gitignore
vendored
@@ -1,34 +0,0 @@
|
|||||||
# dependencies (bun install)
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
# output
|
|
||||||
out
|
|
||||||
dist
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# code coverage
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# dotenv environment variable files
|
|
||||||
.env
|
|
||||||
.env.development.local
|
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
.env.local
|
|
||||||
|
|
||||||
# caches
|
|
||||||
.eslintcache
|
|
||||||
.cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# IntelliJ based IDEs
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# Finder (MacOS) folder config
|
|
||||||
.DS_Store
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# react
|
|
||||||
|
|
||||||
To install dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun install
|
|
||||||
```
|
|
||||||
|
|
||||||
To run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun run src/index.tsx
|
|
||||||
```
|
|
||||||
|
|
||||||
This project was created using `bun create tui`. [create-tui](https://git.new/create-tui) is the easiest way to get started with OpenTUI.
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import esbuild from "esbuild";
|
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
// Custom plugin to alias "react-native" to react-native-opentui
|
|
||||||
const aliasPlugin = {
|
|
||||||
name: "alias-react-native",
|
|
||||||
setup(build) {
|
|
||||||
build.onResolve({ filter: /^react-native$/ }, args => {
|
|
||||||
return {
|
|
||||||
path: path.resolve(__dirname, "../../packages/react-native-opentui/index.tsx"),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Build configuration
|
|
||||||
await esbuild.build({
|
|
||||||
entryPoints: ["src/index.tsx"], // your app entry
|
|
||||||
bundle: true, // inline all dependencies (ui included)
|
|
||||||
platform: "node", // Node/Bun target
|
|
||||||
format: "esm", // keep ESM for top-level await
|
|
||||||
outfile: "dist/index.js",
|
|
||||||
sourcemap: true,
|
|
||||||
plugins: [aliasPlugin],
|
|
||||||
loader: {
|
|
||||||
".ts": "ts",
|
|
||||||
".tsx": "tsx",
|
|
||||||
},
|
|
||||||
external: [
|
|
||||||
// leave OpenTUI and Bun built-ins for Bun runtime
|
|
||||||
"react",
|
|
||||||
"@opentui/core",
|
|
||||||
"@opentui/react",
|
|
||||||
"@opentui/react/jsx-runtime",
|
|
||||||
"bun:ffi",
|
|
||||||
// "./assets/**/*.scm",
|
|
||||||
// "./assets/**/*.wasm",
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("✅ App bundled successfully");
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { createAuthClient } from "better-auth/client";
|
|
||||||
import { deviceAuthorizationClient } from "better-auth/client/plugins";
|
|
||||||
|
|
||||||
export const authClient = createAuthClient({
|
|
||||||
baseURL: "http://laptop:3000",
|
|
||||||
plugins: [
|
|
||||||
deviceAuthorizationClient(),
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@money/tui",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"scripts": {
|
|
||||||
"build": "bun run build.js",
|
|
||||||
"start": "bun run dist/index.js"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": "*"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@effect/platform": "^0.93.2",
|
|
||||||
"@effect/platform-bun": "^0.83.0",
|
|
||||||
"@money/shared": "workspace:*",
|
|
||||||
"@money/ui": "workspace:*",
|
|
||||||
"@opentui/core": "^0.1.39",
|
|
||||||
"@opentui/react": "^0.1.39",
|
|
||||||
"@types/qrcode": "^1.5.6",
|
|
||||||
"effect": "^3.19.4",
|
|
||||||
"qrcode": "^1.5.4",
|
|
||||||
"react-native": "^0.82.1",
|
|
||||||
"react-native-opentui": "workspace:*"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"esbuild": "^0.27.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
import { Context, Data, Effect, Layer, Schema, Console, Schedule, Match, Ref, Duration } from "effect";
|
|
||||||
import { FileSystem } from "@effect/platform";
|
|
||||||
import { config } from "./config";
|
|
||||||
import { AuthState } from "./schema";
|
|
||||||
import { authClient } from "@/lib/auth-client";
|
|
||||||
import type { BetterFetchResponse } from "@better-fetch/fetch";
|
|
||||||
|
|
||||||
const CLIENT_ID = "koon-family";
|
|
||||||
|
|
||||||
const getFromFromDisk = Effect.gen(function* () {
|
|
||||||
const fs = yield* FileSystem.FileSystem;
|
|
||||||
const content = yield* fs.readFileString(config.authPath);
|
|
||||||
return yield* Schema.decode(Schema.parseJson(AuthState))(content);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
class AuthClientErrorString extends Data.TaggedError("AuthClientErrorString")<{
|
|
||||||
errorString: string,
|
|
||||||
}> {};
|
|
||||||
|
|
||||||
|
|
||||||
type ErrorType<E> = { [key in keyof ((E extends Record<string, any> ? E : {
|
|
||||||
message?: string;
|
|
||||||
}) & {
|
|
||||||
status: number;
|
|
||||||
statusText: string;
|
|
||||||
})]: ((E extends Record<string, any> ? E : {
|
|
||||||
message?: string;
|
|
||||||
}) & {
|
|
||||||
status: number;
|
|
||||||
statusText: string;
|
|
||||||
})[key]; };
|
|
||||||
|
|
||||||
class AuthClientError<T> extends Data.TaggedError("AuthClientError")<{
|
|
||||||
error: T,
|
|
||||||
}> {};
|
|
||||||
|
|
||||||
export class AuthClient extends Context.Tag("AuthClient")<AuthClient, AuthClientImpl>() {};
|
|
||||||
|
|
||||||
export interface AuthClientImpl {
|
|
||||||
use: <T, E>(
|
|
||||||
fn: (client: typeof authClient) => Promise<BetterFetchResponse<T, E>>,
|
|
||||||
) => Effect.Effect<T, AuthClientError<ErrorType<E>> | AuthClientErrorString, never>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const make = () =>
|
|
||||||
Effect.gen(function* () {
|
|
||||||
return AuthClient.of({
|
|
||||||
use: (fn) =>
|
|
||||||
Effect.gen(function* () {
|
|
||||||
const { data, error } = yield* Effect.tryPromise({
|
|
||||||
try: () => fn(authClient),
|
|
||||||
catch: () => new AuthClientErrorString({ errorString: "Bad" }),
|
|
||||||
});
|
|
||||||
if (error != null) return yield* Effect.fail(new AuthClientError({ error }));
|
|
||||||
if (data == null) return yield* Effect.fail(new AuthClientErrorString({ errorString: "No data" }));
|
|
||||||
return data;
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
export const layer = () => Layer.scoped(AuthClient, make());
|
|
||||||
|
|
||||||
const pollToken = ({ device_code }: { device_code: string }) => Effect.gen(function* () {
|
|
||||||
const auth = yield* AuthClient;
|
|
||||||
const intervalRef = yield* Ref.make(5);
|
|
||||||
|
|
||||||
const tokenEffect = auth.use(client => {
|
|
||||||
Console.debug("Fetching");
|
|
||||||
|
|
||||||
return client.device.token({
|
|
||||||
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
||||||
device_code,
|
|
||||||
client_id: CLIENT_ID,
|
|
||||||
fetchOptions: { headers: { "user-agent": "CLI" } },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return yield* tokenEffect
|
|
||||||
.pipe(
|
|
||||||
Effect.tapError(error =>
|
|
||||||
error._tag == "AuthClientError" && error.error.error == "slow_down"
|
|
||||||
? Ref.update(intervalRef, current => {
|
|
||||||
Console.debug("updating delay to ", current + 5);
|
|
||||||
return current + 5
|
|
||||||
})
|
|
||||||
: Effect.void
|
|
||||||
),
|
|
||||||
Effect.retry({
|
|
||||||
schedule: Schedule.addDelayEffect(
|
|
||||||
Schedule.recurWhile<Effect.Effect.Error<typeof tokenEffect>>(error =>
|
|
||||||
error._tag == "AuthClientError" &&
|
|
||||||
(error.error.error == "authorization_pending" || error.error.error == "slow_down")
|
|
||||||
),
|
|
||||||
() => Ref.get(intervalRef).pipe(Effect.map(Duration.seconds))
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
const requestAuth = Effect.gen(function* () {
|
|
||||||
const auth = yield* AuthClient;
|
|
||||||
const { device_code, user_code } = yield* auth.use(client => client.device.code({
|
|
||||||
client_id: CLIENT_ID,
|
|
||||||
scope: "openid profile email",
|
|
||||||
}));
|
|
||||||
|
|
||||||
console.log(`Please use the code: ${user_code}`);
|
|
||||||
|
|
||||||
const { access_token } = yield* pollToken({ device_code });
|
|
||||||
|
|
||||||
const sessionData = yield* auth.use(client => client.getSession({
|
|
||||||
fetchOptions: {
|
|
||||||
auth: {
|
|
||||||
type: "Bearer",
|
|
||||||
token: access_token,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
if (sessionData == null) return yield* Effect.fail("Session was null");
|
|
||||||
|
|
||||||
const fs = yield* FileSystem.FileSystem;
|
|
||||||
yield* fs.writeFileString(config.authPath, JSON.stringify(sessionData));
|
|
||||||
|
|
||||||
return sessionData;
|
|
||||||
});
|
|
||||||
|
|
||||||
export const getAuth = Effect.gen(function* () {
|
|
||||||
return yield* getFromFromDisk.pipe(
|
|
||||||
Effect.catchAll(() => requestAuth)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { join } from "path";
|
|
||||||
import { homedir } from "os";
|
|
||||||
|
|
||||||
const PATH = join(homedir(), ".local", "share", "money");
|
|
||||||
const AUTH_PATH = join(PATH, "auth.json");
|
|
||||||
|
|
||||||
export const config = {
|
|
||||||
authPath: AUTH_PATH,
|
|
||||||
};
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import { createCliRenderer } from "@opentui/core";
|
|
||||||
import { createRoot } from "@opentui/react";
|
|
||||||
import { App, type Route } from "@money/ui";
|
|
||||||
import { ZeroProvider } from "@rocicorp/zero/react";
|
|
||||||
import { schema } from '@money/shared';
|
|
||||||
import { useState } from "react";
|
|
||||||
import { AuthClient, getAuth, layer } from "./auth";
|
|
||||||
import { Effect, Layer } from "effect";
|
|
||||||
import { BunContext } from "@effect/platform-bun";
|
|
||||||
import type { AuthData } from "./schema";
|
|
||||||
|
|
||||||
const userID = "anon";
|
|
||||||
const server = "http://laptop:4848";
|
|
||||||
|
|
||||||
function Main({ auth }: { auth: AuthData }) {
|
|
||||||
const [route, setRoute] = useState<Route>("/");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ZeroProvider {...{ userID, auth: auth.session.token, server, schema }}>
|
|
||||||
<App
|
|
||||||
auth={auth || null}
|
|
||||||
route={route}
|
|
||||||
setRoute={setRoute}
|
|
||||||
/>
|
|
||||||
</ZeroProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const auth = await Effect.runPromise(
|
|
||||||
getAuth.pipe(
|
|
||||||
Effect.provide(BunContext.layer),
|
|
||||||
Effect.provide(layer()),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const renderer = await createCliRenderer();
|
|
||||||
createRoot(renderer).render(<Main auth={auth} />);
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import { Schema } from "effect";
|
|
||||||
|
|
||||||
const SessionSchema = Schema.Struct({
|
|
||||||
expiresAt: Schema.DateFromString,
|
|
||||||
token: Schema.String,
|
|
||||||
createdAt: Schema.DateFromString,
|
|
||||||
updatedAt: Schema.DateFromString,
|
|
||||||
ipAddress: Schema.optional(Schema.NullishOr(Schema.String)),
|
|
||||||
userAgent: Schema.optional(Schema.NullishOr(Schema.String)),
|
|
||||||
userId: Schema.String,
|
|
||||||
id: Schema.String,
|
|
||||||
});
|
|
||||||
|
|
||||||
const UserSchema = Schema.Struct({
|
|
||||||
name: Schema.String,
|
|
||||||
email: Schema.String,
|
|
||||||
emailVerified: Schema.Boolean,
|
|
||||||
image: Schema.optional(Schema.NullishOr(Schema.String)),
|
|
||||||
createdAt: Schema.DateFromString,
|
|
||||||
updatedAt: Schema.DateFromString,
|
|
||||||
id: Schema.String,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
export const AuthState = Schema.Struct({
|
|
||||||
session: SessionSchema,
|
|
||||||
user: UserSchema,
|
|
||||||
});
|
|
||||||
|
|
||||||
export type AuthData = typeof AuthState.Type;
|
|
||||||
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"paths": {
|
|
||||||
"react-native": ["../react-native-opentui"],
|
|
||||||
"@/*": ["./*"]
|
|
||||||
},
|
|
||||||
// Environment setup & latest features
|
|
||||||
"lib": ["ESNext"],
|
|
||||||
"target": "ESNext",
|
|
||||||
"module": "Preserve",
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"jsxImportSource": "@opentui/react",
|
|
||||||
"allowJs": true,
|
|
||||||
|
|
||||||
// Bundler mode
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"noEmit": true,
|
|
||||||
|
|
||||||
// Best practices
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noUncheckedIndexedAccess": true,
|
|
||||||
"noImplicitOverride": true,
|
|
||||||
|
|
||||||
// Some stricter flags (disabled by default)
|
|
||||||
"noUnusedLocals": false,
|
|
||||||
"noUnusedParameters": false,
|
|
||||||
"noPropertyAccessFromIndexSignature": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import QRCode from "qrcode";
|
|
||||||
|
|
||||||
export function QR(value: string): string {
|
|
||||||
const qr = QRCode.create(value, {
|
|
||||||
errorCorrectionLevel: "L",
|
|
||||||
version: 3,
|
|
||||||
});
|
|
||||||
|
|
||||||
const m = qr.modules.data;
|
|
||||||
const size = qr.modules.size;
|
|
||||||
|
|
||||||
// Use half-block characters to compress vertically
|
|
||||||
// Upper half = '▀', lower half = '▄', full = '█', empty = ' '
|
|
||||||
let out = "";
|
|
||||||
for (let y = 0; y < size; y += 2) {
|
|
||||||
for (let x = 0; x < size; x++) {
|
|
||||||
const top = m[y * size + x];
|
|
||||||
const bottom = m[(y + 1) * size + x];
|
|
||||||
out += top && bottom ? "█" : top ? "▀" : bottom ? "▄" : " ";
|
|
||||||
}
|
|
||||||
out += "\n";
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 384 KiB After Width: | Height: | Size: 384 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -19,7 +19,6 @@
|
|||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
corepack
|
corepack
|
||||||
nodejs_22
|
nodejs_22
|
||||||
bun
|
|
||||||
|
|
||||||
postgresql
|
postgresql
|
||||||
process-compose
|
process-compose
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createAuthClient } from "better-auth/react";
|
import { createAuthClient } from "better-auth/react";
|
||||||
import { deviceAuthorizationClient, genericOAuthClient } from "better-auth/client/plugins";
|
import { genericOAuthClient } from "better-auth/client/plugins";
|
||||||
import { expoClient } from "@better-auth/expo/client";
|
import { expoClient } from "@better-auth/expo/client";
|
||||||
import * as SecureStore from "expo-secure-store";
|
import * as SecureStore from "expo-secure-store";
|
||||||
import { BASE_URL } from "@money/shared";
|
import { BASE_URL } from "@money/shared";
|
||||||
@@ -13,6 +13,5 @@ export const authClient = createAuthClient({
|
|||||||
storage: SecureStore,
|
storage: SecureStore,
|
||||||
}),
|
}),
|
||||||
genericOAuthClient(),
|
genericOAuthClient(),
|
||||||
deviceAuthorizationClient(),
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
63
package.json
@@ -1,18 +1,71 @@
|
|||||||
{
|
{
|
||||||
"name": "money",
|
"name": "money",
|
||||||
"private": true,
|
"main": "expo-router/entry",
|
||||||
|
"version": "1.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "process-compose up -p 0",
|
"start": "expo start",
|
||||||
"tui": "bun run --hot apps/tui/src/index.tsx"
|
"reset-project": "node ./scripts/reset-project.js",
|
||||||
|
"android": "expo start --android",
|
||||||
|
"ios": "expo start --ios",
|
||||||
|
"web": "expo start --web",
|
||||||
|
"build": "expo export --platform web",
|
||||||
|
"lint": "expo lint",
|
||||||
|
"db:migrate": "dotenv -- pnpm run --dir=shared db:migrate",
|
||||||
|
"db:gen": "dotenv -- pnpm run --dir=shared generate:zero",
|
||||||
|
"dev": "process-compose up -p 0"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@better-auth/expo": "^1.3.27",
|
||||||
|
"@expo/vector-icons": "^15.0.2",
|
||||||
|
"@money/shared": "link:shared",
|
||||||
|
"@react-navigation/bottom-tabs": "^7.4.0",
|
||||||
|
"@react-navigation/elements": "^2.6.3",
|
||||||
|
"@react-navigation/native": "^7.1.8",
|
||||||
|
"@rocicorp/zero": "^0.24.2025101500",
|
||||||
|
"better-auth": "^1.3.27",
|
||||||
|
"drizzle-orm": "^0.44.6",
|
||||||
|
"expo": "~54.0.13",
|
||||||
|
"expo-constants": "~18.0.9",
|
||||||
|
"expo-crypto": "~15.0.7",
|
||||||
|
"expo-font": "~14.0.9",
|
||||||
|
"expo-haptics": "~15.0.7",
|
||||||
|
"expo-image": "~3.0.9",
|
||||||
|
"expo-linking": "~8.0.8",
|
||||||
|
"expo-router": "~6.0.11",
|
||||||
|
"expo-splash-screen": "~31.0.10",
|
||||||
|
"expo-sqlite": "~16.0.8",
|
||||||
|
"expo-status-bar": "~3.0.8",
|
||||||
|
"expo-symbols": "~1.0.7",
|
||||||
|
"expo-system-ui": "~6.0.7",
|
||||||
|
"expo-web-browser": "~15.0.8",
|
||||||
|
"pg": "^8.16.3",
|
||||||
|
"react": "19.1.0",
|
||||||
|
"react-dom": "19.1.0",
|
||||||
|
"react-native": "0.81.4",
|
||||||
|
"react-native-gesture-handler": "~2.28.0",
|
||||||
|
"react-native-reanimated": "~4.1.1",
|
||||||
|
"react-native-safe-area-context": "~5.6.0",
|
||||||
|
"react-native-screens": "~4.16.0",
|
||||||
|
"react-native-web": "~0.21.0",
|
||||||
|
"react-native-worklets": "0.5.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/pg": "^8.15.5",
|
||||||
|
"@types/react": "~19.1.0",
|
||||||
|
"dotenv-cli": "^10.0.0",
|
||||||
|
"drizzle-kit": "^0.31.5",
|
||||||
|
"eslint": "^9.25.0",
|
||||||
|
"eslint-config-expo": "~10.0.0",
|
||||||
|
"typescript": "~5.9.2"
|
||||||
|
},
|
||||||
|
"private": true,
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"onlyBuiltDependencies": [
|
"onlyBuiltDependencies": [
|
||||||
"@rocicorp/zero-sqlite3"
|
"@rocicorp/zero-sqlite3"
|
||||||
],
|
],
|
||||||
"ignoredBuiltDependencies": [
|
"ignoredBuiltDependencies": [
|
||||||
"esbuild",
|
"esbuild",
|
||||||
"protobufjs",
|
"protobufjs"
|
||||||
"unrs-resolver"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import type { ViewProps, TextProps, PressableProps } from "react-native";
|
|
||||||
|
|
||||||
export function View({ children, style }: ViewProps) {
|
|
||||||
const bg = style &&
|
|
||||||
'backgroundColor' in style
|
|
||||||
? typeof style.backgroundColor == 'string'
|
|
||||||
? style.backgroundColor
|
|
||||||
: undefined
|
|
||||||
: undefined;
|
|
||||||
const flexDirection = style &&
|
|
||||||
'flexDirection' in style
|
|
||||||
? typeof style.flexDirection == 'string'
|
|
||||||
? style.flexDirection
|
|
||||||
: undefined
|
|
||||||
: undefined;
|
|
||||||
const flex = style &&
|
|
||||||
'flex' in style
|
|
||||||
? typeof style.flex == 'number'
|
|
||||||
? style.flex
|
|
||||||
: undefined
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return <box backgroundColor={bg} flexDirection={flexDirection} flexGrow={flex}>{children}</box>
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Pressable({ children: childrenRaw, style, onPress }: PressableProps) {
|
|
||||||
const bg = style &&
|
|
||||||
'backgroundColor' in style
|
|
||||||
? typeof style.backgroundColor == 'string'
|
|
||||||
? style.backgroundColor
|
|
||||||
: undefined
|
|
||||||
: undefined;
|
|
||||||
const flexDirection = style &&
|
|
||||||
'flexDirection' in style
|
|
||||||
? typeof style.flexDirection == 'string'
|
|
||||||
? style.flexDirection
|
|
||||||
: undefined
|
|
||||||
: undefined;
|
|
||||||
const flex = style &&
|
|
||||||
'flex' in style
|
|
||||||
? typeof style.flex == 'number'
|
|
||||||
? style.flex
|
|
||||||
: undefined
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const children = childrenRaw instanceof Function ? childrenRaw({ pressed: true }) : childrenRaw;
|
|
||||||
|
|
||||||
return <box
|
|
||||||
backgroundColor={bg}
|
|
||||||
flexDirection={flexDirection}
|
|
||||||
flexGrow={flex}
|
|
||||||
onMouseDown={onPress ? ((_event) => {
|
|
||||||
// @ts-ignore
|
|
||||||
onPress();
|
|
||||||
}) : undefined}
|
|
||||||
>{children}</box>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function Text({ style, children }: TextProps) {
|
|
||||||
const fg = style &&
|
|
||||||
'color' in style
|
|
||||||
? typeof style.color == 'string'
|
|
||||||
? style.color
|
|
||||||
: undefined
|
|
||||||
: undefined;
|
|
||||||
return <text fg={fg || "black"}>{children}</text>
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Platform = {
|
|
||||||
OS: "tui",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
View,
|
|
||||||
Text,
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "react-native-opentui",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"main": "index.tsx",
|
|
||||||
"exports": {
|
|
||||||
".": "./index.tsx"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["ESNext", "DOM"],
|
|
||||||
"target": "ESNext",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"jsxImportSource": "@opentui/react",
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@money/ui",
|
|
||||||
"private": true,
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"exports": {
|
|
||||||
".": "./src/index.tsx"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@money/shared": "workspace:*",
|
|
||||||
"react-native-opentui": "workspace:*"
|
|
||||||
},
|
|
||||||
"packageManager": "pnpm@10.18.2"
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
import { createContext, use, useState } from "react";
|
|
||||||
import { Transactions } from "./transactions";
|
|
||||||
import { View, Text } from "react-native";
|
|
||||||
import { Settings } from "./settings";
|
|
||||||
import { useKeyboard } from "./useKeyboard";
|
|
||||||
import type { AuthData } from "@money/shared/auth";
|
|
||||||
|
|
||||||
|
|
||||||
const PAGES = {
|
|
||||||
'/': {
|
|
||||||
screen: <Transactions />,
|
|
||||||
key: "1",
|
|
||||||
},
|
|
||||||
'/settings': {
|
|
||||||
screen: <Settings />,
|
|
||||||
key: "2",
|
|
||||||
children: {
|
|
||||||
"/accounts": {},
|
|
||||||
"/family": {},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
type Join<A extends string, B extends string> =
|
|
||||||
`${A}${B}` extends `${infer X}` ? X : never;
|
|
||||||
|
|
||||||
type ChildRoutes<Parent extends string, Children> =
|
|
||||||
{
|
|
||||||
[K in keyof Children & string]:
|
|
||||||
K extends `/${string}`
|
|
||||||
? Join<Parent, K>
|
|
||||||
: never;
|
|
||||||
}[keyof Children & string];
|
|
||||||
|
|
||||||
type Routes<T> = {
|
|
||||||
[K in keyof T & string]:
|
|
||||||
| K
|
|
||||||
| (T[K] extends { children: infer C }
|
|
||||||
? ChildRoutes<K, C>
|
|
||||||
: never)
|
|
||||||
}[keyof T & string];
|
|
||||||
|
|
||||||
export type Route = Routes<typeof PAGES>;
|
|
||||||
|
|
||||||
interface RouterContextType {
|
|
||||||
auth: AuthData | null;
|
|
||||||
route: Route;
|
|
||||||
setRoute: (route: Route) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const RouterContext = createContext<RouterContextType>({
|
|
||||||
auth: null,
|
|
||||||
route: '/',
|
|
||||||
setRoute: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
type AppProps = {
|
|
||||||
auth: AuthData | null;
|
|
||||||
route: Route;
|
|
||||||
setRoute: (page: Route) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function App({ auth, route, setRoute }: AppProps) {
|
|
||||||
return <RouterContext.Provider value={{ auth, route, setRoute }}>
|
|
||||||
<Main />
|
|
||||||
</RouterContext.Provider>
|
|
||||||
}
|
|
||||||
|
|
||||||
function Main() {
|
|
||||||
const { route, setRoute } = use(RouterContext);
|
|
||||||
|
|
||||||
useKeyboard((key) => {
|
|
||||||
const screen = Object.entries(PAGES)
|
|
||||||
.find(([, screen]) => screen.key == key.name);
|
|
||||||
|
|
||||||
if (!screen) return;
|
|
||||||
|
|
||||||
const [route] = screen as [Route, never];
|
|
||||||
|
|
||||||
setRoute(route);
|
|
||||||
});
|
|
||||||
|
|
||||||
const match =
|
|
||||||
route in PAGES
|
|
||||||
? (route as keyof typeof PAGES)
|
|
||||||
: (Object.keys(PAGES).sort((a, b) => b.length - a.length).find(p => route.startsWith(p)) as
|
|
||||||
keyof typeof PAGES);
|
|
||||||
|
|
||||||
return PAGES[match].screen;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import { useState, type ReactNode } from "react";
|
|
||||||
import { View, Text } from "react-native";
|
|
||||||
import { useKeyboard } from "./useKeyboard";
|
|
||||||
|
|
||||||
export type ListProps<T> = {
|
|
||||||
items: T[],
|
|
||||||
renderItem: (props: { item: T, isSelected: boolean }) => ReactNode;
|
|
||||||
};
|
|
||||||
export function List<T>({ items, renderItem }: ListProps<T>) {
|
|
||||||
const [idx, setIdx] = useState(0);
|
|
||||||
|
|
||||||
useKeyboard((key) => {
|
|
||||||
if (key.name == 'j') {
|
|
||||||
setIdx((prevIdx) => prevIdx + 1 < items.length ? prevIdx + 1 : items.length - 1);
|
|
||||||
} else if (key.name == 'k') {
|
|
||||||
setIdx((prevIdx) => prevIdx == 0 ? 0 : prevIdx - 1);
|
|
||||||
} else if (key.name == 'g' && key.shift) {
|
|
||||||
setIdx(items.length - 1);
|
|
||||||
}
|
|
||||||
}, [items]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
{items.map((item, index) => <View style={{ backgroundColor: index == idx ? 'black' : undefined }}>
|
|
||||||
{renderItem({ item, isSelected: index == idx })}
|
|
||||||
</View>)}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
import { Text, View, Pressable } from "react-native";
|
|
||||||
import { use, useState, type ReactNode } from "react";
|
|
||||||
import { RouterContext, type Route } from ".";
|
|
||||||
import { General } from "./settings/general";
|
|
||||||
import { Accounts } from "./settings/accounts";
|
|
||||||
import { Family } from "./settings/family";
|
|
||||||
import { useKeyboard } from "./useKeyboard";
|
|
||||||
|
|
||||||
type SettingsRoute = Extract<Route, `/settings${string}`>;
|
|
||||||
|
|
||||||
const TABS = {
|
|
||||||
"/settings": {
|
|
||||||
label: "General",
|
|
||||||
screen: <General />
|
|
||||||
},
|
|
||||||
"/settings/accounts": {
|
|
||||||
label: "Bank Accounts",
|
|
||||||
screen: <Accounts />
|
|
||||||
},
|
|
||||||
"/settings/family": {
|
|
||||||
label: "Family",
|
|
||||||
screen: <Family />
|
|
||||||
},
|
|
||||||
} as const satisfies Record<SettingsRoute, { label: string, screen: ReactNode }>;
|
|
||||||
|
|
||||||
type Tab = keyof typeof TABS;
|
|
||||||
|
|
||||||
export function Settings() {
|
|
||||||
const { route, setRoute } = use(RouterContext);
|
|
||||||
|
|
||||||
useKeyboard((key) => {
|
|
||||||
if (key.name == 'h') {
|
|
||||||
const currentIdx = Object.entries(TABS).findIndex(([tabRoute, _]) => tabRoute == route)
|
|
||||||
const routes = Object.keys(TABS) as SettingsRoute[];
|
|
||||||
const last = routes[currentIdx - 1]
|
|
||||||
if (!last) return;
|
|
||||||
setRoute(last);
|
|
||||||
} else if (key.name == 'l') {
|
|
||||||
const currentIdx = Object.entries(TABS).findIndex(([tabRoute, _]) => tabRoute == route)
|
|
||||||
const routes = Object.keys(TABS) as SettingsRoute[];
|
|
||||||
const next = routes[currentIdx + 1]
|
|
||||||
if (!next) return;
|
|
||||||
setRoute(next);
|
|
||||||
}
|
|
||||||
}, [route]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
|
|
||||||
<View>
|
|
||||||
{Object.entries(TABS).map(([tabRoute, tab]) => {
|
|
||||||
const isSelected = tabRoute == route;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Pressable key={tab.label} style={{ backgroundColor: isSelected ? 'black' : undefined }} onPress={() => setRoute(tabRoute as SettingsRoute)}>
|
|
||||||
<Text style={{ fontFamily: 'mono', color: isSelected ? 'white' : 'black' }}>{tab.label}</Text>
|
|
||||||
</Pressable>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View>
|
|
||||||
{TABS[route as Tab].screen}
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import { useQuery } from "@rocicorp/zero/react";
|
|
||||||
import { queries } from '@money/shared';
|
|
||||||
import * as Table from "../table";
|
|
||||||
import { use } from "react";
|
|
||||||
import { RouterContext } from "..";
|
|
||||||
|
|
||||||
const COLUMNS: Table.Column[] = [
|
|
||||||
{ name: 'name', label: 'Name' },
|
|
||||||
{ name: 'createdAt', label: 'Added At', render: (n) => new Date(n).toLocaleString() },
|
|
||||||
];
|
|
||||||
|
|
||||||
export function Accounts() {
|
|
||||||
const { auth } = use(RouterContext);
|
|
||||||
const [items] = useQuery(queries.getItems(auth));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Table.Provider columns={COLUMNS} data={items}>
|
|
||||||
<Table.Body />
|
|
||||||
</Table.Provider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { Text } from "react-native";
|
|
||||||
|
|
||||||
export function Family() {
|
|
||||||
return <Text style={{ fontFamily: 'mono' }}>Welcome to family</Text>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { Text } from "react-native";
|
|
||||||
|
|
||||||
export function General() {
|
|
||||||
return <Text style={{ fontFamily: 'mono' }}>Welcome to settings</Text>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
import { createContext, use, useState, type ReactNode } from "react";
|
|
||||||
import { View, Text } from "react-native";
|
|
||||||
import { useKeyboard } from "./useKeyboard";
|
|
||||||
|
|
||||||
const HEADER_COLOR = '#7158e2';
|
|
||||||
const TABLE_COLORS = [
|
|
||||||
'#ddd',
|
|
||||||
'#eee'
|
|
||||||
];
|
|
||||||
const SELECTED_COLOR = '#f7b730';
|
|
||||||
|
|
||||||
|
|
||||||
const EXTRA = 5;
|
|
||||||
|
|
||||||
export type ValidRecord = Record<string, string | number | null>;
|
|
||||||
|
|
||||||
interface TableState {
|
|
||||||
data: unknown[];
|
|
||||||
columns: Column[];
|
|
||||||
columnMap: Map<string, number>;
|
|
||||||
idx: number;
|
|
||||||
selectedFrom: number | undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const INITAL_STATE = {
|
|
||||||
data: [],
|
|
||||||
columns: [],
|
|
||||||
columnMap: new Map(),
|
|
||||||
idx: 0,
|
|
||||||
selectedFrom: undefined,
|
|
||||||
} satisfies TableState;
|
|
||||||
|
|
||||||
export const Context = createContext<TableState>(INITAL_STATE);
|
|
||||||
|
|
||||||
export type Column = { name: string, label: string, render?: (i: number | string) => string };
|
|
||||||
|
|
||||||
|
|
||||||
function renderCell(row: ValidRecord, column: Column): string {
|
|
||||||
const cell = row[column.name];
|
|
||||||
if (cell == undefined) return 'n/a';
|
|
||||||
if (cell == null) return 'null';
|
|
||||||
if (column.render) return column.render(cell);
|
|
||||||
return cell.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export interface ProviderProps<T> {
|
|
||||||
data: T[];
|
|
||||||
columns: Column[];
|
|
||||||
children: ReactNode;
|
|
||||||
};
|
|
||||||
export function Provider<T extends ValidRecord>({ data, columns, children }: ProviderProps<T>) {
|
|
||||||
const [idx, setIdx] = useState(0);
|
|
||||||
const [selectedFrom, setSelectedFrom] = useState<number>();
|
|
||||||
|
|
||||||
useKeyboard((key) => {
|
|
||||||
if (key.name == 'j' || key.name == 'down') {
|
|
||||||
if (key.shift && selectedFrom == undefined) {
|
|
||||||
setSelectedFrom(idx);
|
|
||||||
}
|
|
||||||
setIdx((prev) => Math.min(prev + 1, data.length - 1));
|
|
||||||
} else if (key.name == 'k' || key.name == 'up') {
|
|
||||||
if (key.shift && selectedFrom == undefined) {
|
|
||||||
setSelectedFrom(idx);
|
|
||||||
}
|
|
||||||
setIdx((prev) => Math.max(prev - 1, 0));
|
|
||||||
} else if (key.name == 'g' && key.shift) {
|
|
||||||
setIdx(data.length - 1);
|
|
||||||
} else if (key.name == 'v') {
|
|
||||||
setSelectedFrom(idx);
|
|
||||||
} else if (key.name == 'escape') {
|
|
||||||
setSelectedFrom(undefined);
|
|
||||||
}
|
|
||||||
}, [data, idx]);
|
|
||||||
|
|
||||||
|
|
||||||
const columnMap = new Map(columns.map(col => {
|
|
||||||
return [col.name, Math.max(col.label.length, ...data.map(row => renderCell(row, col).length))]
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Context.Provider value={{ data, columns, columnMap, idx, selectedFrom }}>
|
|
||||||
{children}
|
|
||||||
</Context.Provider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Body() {
|
|
||||||
const { columns, data, columnMap, idx, selectedFrom } = use(Context);
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<View style={{ backgroundColor: HEADER_COLOR, flexDirection: 'row' }}>
|
|
||||||
{columns.map(column => <Text key={column.name} style={{ fontFamily: 'mono', color: 'white' }}>{rpad(column.label, columnMap.get(column.name)! - column.label.length + EXTRA)}</Text>)}
|
|
||||||
</View>
|
|
||||||
{data.map((row, index) => {
|
|
||||||
const isSelected = index == idx || (selectedFrom != undefined && ((selectedFrom <= index && index <= idx) || (idx <= index && index <= selectedFrom)))
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View key={index} style={{ backgroundColor: isSelected ? SELECTED_COLOR : TABLE_COLORS[index % 2] }}>
|
|
||||||
<TableRow key={index} row={row as ValidRecord} index={index} isSelected={isSelected} />
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</View>
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RowProps<T> {
|
|
||||||
row: T;
|
|
||||||
index: number;
|
|
||||||
isSelected: boolean;
|
|
||||||
}
|
|
||||||
function TableRow<T extends ValidRecord>({ row, isSelected }: RowProps<T>) {
|
|
||||||
const { data, columns, columnMap } = use(Context);
|
|
||||||
|
|
||||||
|
|
||||||
return <View style={{ flexDirection: 'row' }}>
|
|
||||||
{columns.map(column => {
|
|
||||||
const rendered = renderCell(row, column);
|
|
||||||
return <Text key={column.name} style={{ fontFamily: 'mono', color: isSelected ? 'black' : 'black' }}>{rpad(rendered, columnMap.get(column.name)! - rendered.length + EXTRA)}</Text>;
|
|
||||||
})}
|
|
||||||
</View>
|
|
||||||
}
|
|
||||||
|
|
||||||
function rpad(input: string, length: number): string {
|
|
||||||
return input + Array.from({ length })
|
|
||||||
.map(_ => " ")
|
|
||||||
.join("");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
import * as Table from "./table";
|
|
||||||
import { useQuery } from "@rocicorp/zero/react";
|
|
||||||
import { queries, type Transaction } from '@money/shared';
|
|
||||||
import { use } from "react";
|
|
||||||
import { View, Text } from "react-native";
|
|
||||||
import { RouterContext } from ".";
|
|
||||||
|
|
||||||
|
|
||||||
const FORMAT = new Intl.NumberFormat("en-US", {
|
|
||||||
minimumFractionDigits: 2,
|
|
||||||
maximumFractionDigits: 2,
|
|
||||||
});
|
|
||||||
|
|
||||||
export type Account = {
|
|
||||||
name: string;
|
|
||||||
createdAt: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const COLUMNS: Table.Column[] = [
|
|
||||||
{ name: 'createdAt', label: 'Date', render: (n) => new Date(n).toDateString() },
|
|
||||||
{ name: 'amount', label: 'Amount' },
|
|
||||||
{ name: 'name', label: 'Name' },
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
export function Transactions() {
|
|
||||||
const { auth } = use(RouterContext);
|
|
||||||
const [items] = useQuery(queries.allTransactions(auth));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Table.Provider
|
|
||||||
data={items}
|
|
||||||
columns={COLUMNS} >
|
|
||||||
<Table.Body />
|
|
||||||
{/* Spacer */}
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Selected />
|
|
||||||
</Table.Provider>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Selected() {
|
|
||||||
const { data, idx, selectedFrom } = use(Table.Context);
|
|
||||||
|
|
||||||
if (selectedFrom == undefined)
|
|
||||||
return (
|
|
||||||
<View style={{ backgroundColor: '#ddd' }}>
|
|
||||||
<Text style={{ fontFamily: 'mono' }}>No items selected</Text>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
|
|
||||||
const from = Math.min(idx, selectedFrom);
|
|
||||||
const to = Math.max(idx, selectedFrom);
|
|
||||||
const selected = data.slice(from, to + 1) as Transaction[];
|
|
||||||
const count = selected.length;
|
|
||||||
const sum = selected.reduce((prev, curr) => prev + curr.amount, 0);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View style={{ backgroundColor: '#9f9' }}>
|
|
||||||
<Text style={{ fontFamily: 'mono' }}>{count} transaction{count == 1 ? "" : "s"} selected | ${FORMAT.format(sum)}</Text>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { useKeyboard as useOpentuiKeyboard } from "@opentui/react";
|
|
||||||
|
|
||||||
export function useKeyboard(handler: Parameters<typeof useOpentuiKeyboard>[0], _deps: any[] = []) {
|
|
||||||
return useOpentuiKeyboard(handler);
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
import { useEffect } from "react";
|
|
||||||
import type { KeyboardEvent } from "react";
|
|
||||||
import type { KeyEvent } from "@opentui/core";
|
|
||||||
|
|
||||||
|
|
||||||
function convertName(keyName: string): string {
|
|
||||||
const result = keyName.toLowerCase()
|
|
||||||
if (result == 'arrowdown') return 'down';
|
|
||||||
if (result == 'arrowup') return 'up';
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useKeyboard(handler: (key: KeyEvent) => void, deps: any[] = []) {
|
|
||||||
useEffect(() => {
|
|
||||||
const handlerWeb = (event: KeyboardEvent) => {
|
|
||||||
// @ts-ignore
|
|
||||||
handler({
|
|
||||||
name: convertName(event.key),
|
|
||||||
ctrl: event.ctrlKey,
|
|
||||||
meta: event.metaKey,
|
|
||||||
shift: event.shiftKey,
|
|
||||||
option: event.metaKey,
|
|
||||||
sequence: '',
|
|
||||||
number: false,
|
|
||||||
raw: '',
|
|
||||||
eventType: 'press',
|
|
||||||
source: "raw",
|
|
||||||
code: event.code,
|
|
||||||
super: false,
|
|
||||||
hyper: false,
|
|
||||||
capsLock: false,
|
|
||||||
numLock: false,
|
|
||||||
baseCode: event.keyCode,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
window.addEventListener("keydown", handlerWeb);
|
|
||||||
return () => {
|
|
||||||
// @ts-ignore
|
|
||||||
window.removeEventListener("keydown", handlerWeb);
|
|
||||||
};
|
|
||||||
}, deps);
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
// Environment setup & latest features
|
|
||||||
"lib": ["ESNext"],
|
|
||||||
"target": "ESNext",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"allowJs": true,
|
|
||||||
|
|
||||||
// Bundler mode
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"noEmit": true,
|
|
||||||
|
|
||||||
// Best practices
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noUncheckedIndexedAccess": true,
|
|
||||||
|
|
||||||
// Some stricter flags (disabled by default)
|
|
||||||
"noUnusedLocals": false,
|
|
||||||
"noUnusedParameters": false,
|
|
||||||
"noPropertyAccessFromIndexSignature": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
5318
pnpm-lock.yaml
generated
@@ -1,4 +1,4 @@
|
|||||||
nodeLinker: hoisted
|
nodeLinker: hoisted
|
||||||
packages:
|
packages:
|
||||||
- 'apps/*'
|
- 'api'
|
||||||
- 'packages/*'
|
- 'shared'
|
||||||
|
|||||||
@@ -29,13 +29,14 @@ processes:
|
|||||||
command: "pnpm tsx ./scripts/set-machine-name.ts"
|
command: "pnpm tsx ./scripts/set-machine-name.ts"
|
||||||
|
|
||||||
expo:
|
expo:
|
||||||
command: "pnpm --filter=@money/expo start"
|
command: "pnpm start"
|
||||||
depends_on:
|
depends_on:
|
||||||
tailscale_machine_name:
|
tailscale_machine_name:
|
||||||
condition: process_completed_successfully
|
condition: process_completed_successfully
|
||||||
|
|
||||||
api:
|
api:
|
||||||
command: "pnpm --filter=@money/api dev"
|
command: "pnpm run dev"
|
||||||
|
working_dir: ./api
|
||||||
|
|
||||||
migrate:
|
migrate:
|
||||||
command: |
|
command: |
|
||||||
@@ -48,14 +49,14 @@ processes:
|
|||||||
db:
|
db:
|
||||||
condition: process_healthy
|
condition: process_healthy
|
||||||
zero:
|
zero:
|
||||||
command: npx zero-cache-dev -p packages/shared/src/schema.ts
|
command: npx zero-cache-dev -p shared/src/schema.ts
|
||||||
depends_on:
|
depends_on:
|
||||||
migrate:
|
migrate:
|
||||||
condition: process_completed_successfully
|
condition: process_completed_successfully
|
||||||
|
|
||||||
studio:
|
studio:
|
||||||
command: npx drizzle-kit studio
|
command: npx drizzle-kit studio
|
||||||
working_dir: ./packages/shared
|
working_dir: ./shared
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: process_healthy
|
condition: process_healthy
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
"./db": "./src/db/index.ts"
|
"./db": "./src/db/index.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"drizzle-zero": "^0.14.3"
|
"drizzle-zero": "^0.15.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate:zero": "drizzle-zero generate -s ./src/db/schema/public.ts -o ./src/zero-schema.gen.ts -f && sed -i 's/enableLegacyQueries: true,/enableLegacyQueries: false,/g' src/zero-schema.gen.ts && sed -i 's/enableLegacyMutators: true,/enableLegacyMutators: false,/g' src/zero-schema.gen.ts",
|
"generate:zero": "drizzle-zero generate -s ./src/db/schema/public.ts -o ./src/zero-schema.gen.ts -f --disable-legacy-queries --disable-legacy-mutators",
|
||||||
"db:migrate": "drizzle-kit push"
|
"db:migrate": "drizzle-kit push"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
text,
|
text,
|
||||||
timestamp,
|
timestamp,
|
||||||
uniqueIndex,
|
uniqueIndex,
|
||||||
integer,
|
|
||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
import { users } from "./public";
|
import { users } from "./public";
|
||||||
|
|
||||||
@@ -94,19 +93,9 @@ export const auditLogs = pgTable("audit_log", {
|
|||||||
action: text("action").notNull(),
|
action: text("action").notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const deviceCodes = pgTable("deviceCode", {
|
export const plaidAccessTokens = pgTable("plaidAccessToken", {
|
||||||
id: text("id").primaryKey(),
|
id: text("id").primaryKey(),
|
||||||
deviceCode: text("device_code").notNull(),
|
userId: text("user_id").notNull(),
|
||||||
userCode: text("user_code").notNull(),
|
token: text("token").notNull(),
|
||||||
userId: text("user_id").references(() => users.id, {
|
|
||||||
onDelete: "set null",
|
|
||||||
}),
|
|
||||||
clientId: text("client_id"),
|
|
||||||
scope: text("scope"),
|
|
||||||
status: text("status").notNull(),
|
|
||||||
expiresAt: timestamp("expires_at"),
|
|
||||||
lastPolledAt: timestamp("last_polled_at"),
|
|
||||||
pollingInterval: integer("polling_interval"),
|
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
||||||
});
|
});
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { definePermissions } from "@rocicorp/zero";
|
||||||
import { pgTable, text, boolean, timestamp, uniqueIndex, decimal } from "drizzle-orm/pg-core";
|
import { pgTable, text, boolean, timestamp, uniqueIndex, decimal } from "drizzle-orm/pg-core";
|
||||||
|
|
||||||
export const users = pgTable(
|
export const users = pgTable(
|
||||||
@@ -45,13 +46,4 @@ export const balance = pgTable("balance", {
|
|||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
||||||
});
|
})
|
||||||
|
|
||||||
export const plaidAccessTokens = pgTable("plaidAccessToken", {
|
|
||||||
id: text("id").primaryKey(),
|
|
||||||
name: text("name").notNull(),
|
|
||||||
logoUrl: text("logoUrl").notNull(),
|
|
||||||
userId: text("user_id").notNull(),
|
|
||||||
token: text("token").notNull(),
|
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
||||||
});
|
|
||||||
@@ -30,11 +30,5 @@ export const queries = {
|
|||||||
return builder.balance
|
return builder.balance
|
||||||
.where('user_id', '=', authData.user.id)
|
.where('user_id', '=', authData.user.id)
|
||||||
.orderBy('name', 'asc');
|
.orderBy('name', 'asc');
|
||||||
}),
|
|
||||||
getItems: syncedQueryWithContext('getItems', z.tuple([]), (authData: AuthData | null) => {
|
|
||||||
isLoggedIn(authData);
|
|
||||||
return builder.plaidAccessTokens
|
|
||||||
.where('userId', '=', authData.user.id)
|
|
||||||
.orderBy('createdAt', 'desc');
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
@@ -10,11 +10,9 @@
|
|||||||
|
|
||||||
import type { Row } from "@rocicorp/zero";
|
import type { Row } from "@rocicorp/zero";
|
||||||
import { createBuilder } from "@rocicorp/zero";
|
import { createBuilder } from "@rocicorp/zero";
|
||||||
import type { DrizzleToZeroSchema, ZeroCustomType } from "drizzle-zero";
|
import type { CustomType } from "drizzle-zero";
|
||||||
import type * as drizzleSchema from "./db/schema/public";
|
import type * as drizzleSchema from "./db/schema/public";
|
||||||
|
|
||||||
type ZeroSchema = DrizzleToZeroSchema<typeof drizzleSchema>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Zero schema object.
|
* The Zero schema object.
|
||||||
* This type is auto-generated from your Drizzle schema definition.
|
* This type is auto-generated from your Drizzle schema definition.
|
||||||
@@ -27,8 +25,8 @@ export const schema = {
|
|||||||
id: {
|
id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"id"
|
"id"
|
||||||
>,
|
>,
|
||||||
@@ -36,8 +34,8 @@ export const schema = {
|
|||||||
user_id: {
|
user_id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"user_id"
|
"user_id"
|
||||||
>,
|
>,
|
||||||
@@ -46,8 +44,8 @@ export const schema = {
|
|||||||
plaid_id: {
|
plaid_id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"plaid_id"
|
"plaid_id"
|
||||||
>,
|
>,
|
||||||
@@ -56,8 +54,8 @@ export const schema = {
|
|||||||
avaliable: {
|
avaliable: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"avaliable"
|
"avaliable"
|
||||||
>,
|
>,
|
||||||
@@ -65,8 +63,8 @@ export const schema = {
|
|||||||
current: {
|
current: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"current"
|
"current"
|
||||||
>,
|
>,
|
||||||
@@ -74,8 +72,8 @@ export const schema = {
|
|||||||
name: {
|
name: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"name"
|
"name"
|
||||||
>,
|
>,
|
||||||
@@ -83,8 +81,8 @@ export const schema = {
|
|||||||
createdAt: {
|
createdAt: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"createdAt"
|
"createdAt"
|
||||||
>,
|
>,
|
||||||
@@ -93,8 +91,8 @@ export const schema = {
|
|||||||
updatedAt: {
|
updatedAt: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"balance",
|
"balance",
|
||||||
"updatedAt"
|
"updatedAt"
|
||||||
>,
|
>,
|
||||||
@@ -103,77 +101,14 @@ export const schema = {
|
|||||||
},
|
},
|
||||||
primaryKey: ["id"],
|
primaryKey: ["id"],
|
||||||
},
|
},
|
||||||
plaidAccessTokens: {
|
|
||||||
name: "plaidAccessTokens",
|
|
||||||
columns: {
|
|
||||||
id: {
|
|
||||||
type: "string",
|
|
||||||
optional: false,
|
|
||||||
customType: null as unknown as ZeroCustomType<
|
|
||||||
ZeroSchema,
|
|
||||||
"plaidAccessTokens",
|
|
||||||
"id"
|
|
||||||
>,
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
type: "string",
|
|
||||||
optional: false,
|
|
||||||
customType: null as unknown as ZeroCustomType<
|
|
||||||
ZeroSchema,
|
|
||||||
"plaidAccessTokens",
|
|
||||||
"name"
|
|
||||||
>,
|
|
||||||
},
|
|
||||||
logoUrl: {
|
|
||||||
type: "string",
|
|
||||||
optional: false,
|
|
||||||
customType: null as unknown as ZeroCustomType<
|
|
||||||
ZeroSchema,
|
|
||||||
"plaidAccessTokens",
|
|
||||||
"logoUrl"
|
|
||||||
>,
|
|
||||||
},
|
|
||||||
userId: {
|
|
||||||
type: "string",
|
|
||||||
optional: false,
|
|
||||||
customType: null as unknown as ZeroCustomType<
|
|
||||||
ZeroSchema,
|
|
||||||
"plaidAccessTokens",
|
|
||||||
"userId"
|
|
||||||
>,
|
|
||||||
serverName: "user_id",
|
|
||||||
},
|
|
||||||
token: {
|
|
||||||
type: "string",
|
|
||||||
optional: false,
|
|
||||||
customType: null as unknown as ZeroCustomType<
|
|
||||||
ZeroSchema,
|
|
||||||
"plaidAccessTokens",
|
|
||||||
"token"
|
|
||||||
>,
|
|
||||||
},
|
|
||||||
createdAt: {
|
|
||||||
type: "number",
|
|
||||||
optional: true,
|
|
||||||
customType: null as unknown as ZeroCustomType<
|
|
||||||
ZeroSchema,
|
|
||||||
"plaidAccessTokens",
|
|
||||||
"createdAt"
|
|
||||||
>,
|
|
||||||
serverName: "created_at",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
primaryKey: ["id"],
|
|
||||||
serverName: "plaidAccessToken",
|
|
||||||
},
|
|
||||||
plaidLink: {
|
plaidLink: {
|
||||||
name: "plaidLink",
|
name: "plaidLink",
|
||||||
columns: {
|
columns: {
|
||||||
id: {
|
id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"plaidLink",
|
"plaidLink",
|
||||||
"id"
|
"id"
|
||||||
>,
|
>,
|
||||||
@@ -181,8 +116,8 @@ export const schema = {
|
|||||||
user_id: {
|
user_id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"plaidLink",
|
"plaidLink",
|
||||||
"user_id"
|
"user_id"
|
||||||
>,
|
>,
|
||||||
@@ -190,8 +125,8 @@ export const schema = {
|
|||||||
link: {
|
link: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"plaidLink",
|
"plaidLink",
|
||||||
"link"
|
"link"
|
||||||
>,
|
>,
|
||||||
@@ -199,8 +134,8 @@ export const schema = {
|
|||||||
token: {
|
token: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"plaidLink",
|
"plaidLink",
|
||||||
"token"
|
"token"
|
||||||
>,
|
>,
|
||||||
@@ -208,8 +143,8 @@ export const schema = {
|
|||||||
createdAt: {
|
createdAt: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"plaidLink",
|
"plaidLink",
|
||||||
"createdAt"
|
"createdAt"
|
||||||
>,
|
>,
|
||||||
@@ -224,8 +159,8 @@ export const schema = {
|
|||||||
id: {
|
id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"id"
|
"id"
|
||||||
>,
|
>,
|
||||||
@@ -233,8 +168,8 @@ export const schema = {
|
|||||||
user_id: {
|
user_id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"user_id"
|
"user_id"
|
||||||
>,
|
>,
|
||||||
@@ -242,8 +177,8 @@ export const schema = {
|
|||||||
plaid_id: {
|
plaid_id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"plaid_id"
|
"plaid_id"
|
||||||
>,
|
>,
|
||||||
@@ -251,8 +186,8 @@ export const schema = {
|
|||||||
account_id: {
|
account_id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"account_id"
|
"account_id"
|
||||||
>,
|
>,
|
||||||
@@ -260,8 +195,8 @@ export const schema = {
|
|||||||
name: {
|
name: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"name"
|
"name"
|
||||||
>,
|
>,
|
||||||
@@ -269,8 +204,8 @@ export const schema = {
|
|||||||
amount: {
|
amount: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"amount"
|
"amount"
|
||||||
>,
|
>,
|
||||||
@@ -278,8 +213,8 @@ export const schema = {
|
|||||||
datetime: {
|
datetime: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"datetime"
|
"datetime"
|
||||||
>,
|
>,
|
||||||
@@ -287,8 +222,8 @@ export const schema = {
|
|||||||
authorized_datetime: {
|
authorized_datetime: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"authorized_datetime"
|
"authorized_datetime"
|
||||||
>,
|
>,
|
||||||
@@ -296,8 +231,8 @@ export const schema = {
|
|||||||
json: {
|
json: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"json"
|
"json"
|
||||||
>,
|
>,
|
||||||
@@ -305,8 +240,8 @@ export const schema = {
|
|||||||
createdAt: {
|
createdAt: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"createdAt"
|
"createdAt"
|
||||||
>,
|
>,
|
||||||
@@ -315,8 +250,8 @@ export const schema = {
|
|||||||
updatedAt: {
|
updatedAt: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"transaction",
|
"transaction",
|
||||||
"updatedAt"
|
"updatedAt"
|
||||||
>,
|
>,
|
||||||
@@ -331,8 +266,8 @@ export const schema = {
|
|||||||
id: {
|
id: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"users",
|
"users",
|
||||||
"id"
|
"id"
|
||||||
>,
|
>,
|
||||||
@@ -340,8 +275,8 @@ export const schema = {
|
|||||||
name: {
|
name: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"users",
|
"users",
|
||||||
"name"
|
"name"
|
||||||
>,
|
>,
|
||||||
@@ -349,8 +284,8 @@ export const schema = {
|
|||||||
email: {
|
email: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: false,
|
optional: false,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"users",
|
"users",
|
||||||
"email"
|
"email"
|
||||||
>,
|
>,
|
||||||
@@ -358,8 +293,8 @@ export const schema = {
|
|||||||
emailVerified: {
|
emailVerified: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"users",
|
"users",
|
||||||
"emailVerified"
|
"emailVerified"
|
||||||
>,
|
>,
|
||||||
@@ -368,8 +303,8 @@ export const schema = {
|
|||||||
image: {
|
image: {
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"users",
|
"users",
|
||||||
"image"
|
"image"
|
||||||
>,
|
>,
|
||||||
@@ -377,8 +312,8 @@ export const schema = {
|
|||||||
createdAt: {
|
createdAt: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"users",
|
"users",
|
||||||
"createdAt"
|
"createdAt"
|
||||||
>,
|
>,
|
||||||
@@ -387,8 +322,8 @@ export const schema = {
|
|||||||
updatedAt: {
|
updatedAt: {
|
||||||
type: "number",
|
type: "number",
|
||||||
optional: true,
|
optional: true,
|
||||||
customType: null as unknown as ZeroCustomType<
|
customType: null as unknown as CustomType<
|
||||||
ZeroSchema,
|
typeof drizzleSchema,
|
||||||
"users",
|
"users",
|
||||||
"updatedAt"
|
"updatedAt"
|
||||||
>,
|
>,
|
||||||
@@ -414,11 +349,6 @@ export type Schema = typeof schema;
|
|||||||
* This type is auto-generated from your Drizzle schema definition.
|
* This type is auto-generated from your Drizzle schema definition.
|
||||||
*/
|
*/
|
||||||
export type Balance = Row<Schema["tables"]["balance"]>;
|
export type Balance = Row<Schema["tables"]["balance"]>;
|
||||||
/**
|
|
||||||
* Represents a row from the "plaidAccessTokens" table.
|
|
||||||
* This type is auto-generated from your Drizzle schema definition.
|
|
||||||
*/
|
|
||||||
export type PlaidAccessToken = Row<Schema["tables"]["plaidAccessTokens"]>;
|
|
||||||
/**
|
/**
|
||||||
* Represents a row from the "plaidLink" table.
|
* Represents a row from the "plaidLink" table.
|
||||||
* This type is auto-generated from your Drizzle schema definition.
|
* This type is auto-generated from your Drizzle schema definition.
|
||||||
@@ -1,4 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {},
|
"extends": "expo/tsconfig.base",
|
||||||
"extends": "expo/tsconfig.base"
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||