From f4170f2d8a4a45bce000fe2bcc606bbbccdaa1f8 Mon Sep 17 00:00:00 2001 From: Max Koon <22125083+k2on@users.noreply.github.com> Date: Tue, 14 Oct 2025 20:52:53 -0400 Subject: [PATCH] feat: use uuid --- .npmrc | 2 ++ app/index.tsx | 2 ++ package.json | 1 + pnpm-lock.yaml | 3 +++ shared/src/mutators.ts | 6 +++--- 5 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..42287e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +ignore-workspace-root-check=true + diff --git a/app/index.tsx b/app/index.tsx index 49da189..c641029 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -3,6 +3,7 @@ import { authClient } from '@/lib/auth-client'; import { Button, Text } from 'react-native'; import { useQuery, useZero } from "@rocicorp/zero/react"; import { queries, type Mutators, type Schema } from '@money/shared'; +import { randomUUID } from "expo-crypto"; export default function HomeScreen() { const { data: session } = authClient.useSession(); @@ -16,6 +17,7 @@ export default function HomeScreen() { const onNew = () => { z.mutate.transaction.create({ + id: randomUUID(), name: "Uber", amount: 100, }) diff --git a/package.json b/package.json index 8e4cad7..3154a0a 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d8c498..a0eb54a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: expo-constants: specifier: ~18.0.9 version: 18.0.9(expo@54.0.13)(react-native@0.81.4(@babel/core@7.28.4)(@types/react@19.1.17)(react@19.1.0)) + expo-crypto: + specifier: ~15.0.7 + version: 15.0.7(expo@54.0.13) expo-font: specifier: ~14.0.9 version: 14.0.9(expo@54.0.13)(react-native@0.81.4(@babel/core@7.28.4)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0) diff --git a/shared/src/mutators.ts b/shared/src/mutators.ts index 641dc78..8e6519a 100644 --- a/shared/src/mutators.ts +++ b/shared/src/mutators.ts @@ -1,6 +1,6 @@ import type { Transaction } from "@rocicorp/zero"; import type { AuthData } from "./auth"; -import type { Schema } from "./schema"; +import type { Schema } from "."; import { isLoggedIn } from "./zql"; type Tx = Transaction; @@ -8,10 +8,10 @@ type Tx = Transaction; export function createMutators(authData: AuthData | null) { return { transaction: { - async create(tx: Tx, { name, amount }: { name: string, amount: number }) { + async create(tx: Tx, { id, name, amount }: { id: string, name: string, amount: number }) { isLoggedIn(authData); await tx.mutate.transaction.insert({ - id: 'id-' + Math.random().toString(), + id, user_id: authData.user.id, name, amount,