feat(db): mesh data model — meshes, members, invites, audit log

- pgSchema "mesh" with 4 tables isolating the peer mesh domain
- Enums: visibility, transport, tier, role
- audit_log is metadata-only (E2E encryption enforced at broker/client)
- Cascade on mesh delete, soft-delete via archivedAt/revokedAt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-04 21:19:32 +01:00
commit d3163a5bff
1384 changed files with 314925 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
/* eslint-disable turbo/no-undeclared-env-vars */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { defineEnv } from "envin";
import * as z from "zod";
import { envConfig } from "@turbostarter/shared/constants";
import type { Preset } from "envin/types";
export const preset = {
id: "posthog",
clientPrefix: "EXPO_PUBLIC_",
client: {
EXPO_PUBLIC_POSTHOG_KEY: z.string(),
EXPO_PUBLIC_POSTHOG_HOST: z
.string()
.optional()
.default("https://us.i.posthog.com"),
},
} as const satisfies Preset;
export const env = defineEnv({
...envConfig,
...preset,
env: {
EXPO_PUBLIC_POSTHOG_KEY: process.env.EXPO_PUBLIC_POSTHOG_KEY,
EXPO_PUBLIC_POSTHOG_HOST: process.env.EXPO_PUBLIC_POSTHOG_HOST,
},
});

View File

@@ -0,0 +1,73 @@
import PostHog, { PostHogProvider } from "posthog-react-native";
import { useEffect } from "react";
import { useTrackingPermissions } from "../../hooks";
import { env } from "./env";
import type { AnalyticsProviderClientStrategy } from "@turbostarter/analytics";
let client: PostHog | null = null;
const getClient = () => {
if (client) {
return client;
}
client = new PostHog(env.EXPO_PUBLIC_POSTHOG_KEY, {
host: env.EXPO_PUBLIC_POSTHOG_HOST,
defaultOptIn: false,
});
return client;
};
const Wrapper = ({ children }: { children: React.ReactNode }) => {
const client = getClient();
return (
<PostHogProvider client={client} autocapture>
{children}
</PostHogProvider>
);
};
const Setup = () => {
const client = getClient();
const granted = useTrackingPermissions();
useEffect(() => {
if (granted) {
void client.optIn();
} else {
void client.optOut();
}
}, [granted, client]);
return null;
};
const ProviderComponent = ({ children }: { children: React.ReactNode }) => {
return (
<Wrapper>
<Setup />
{children}
</Wrapper>
);
};
export const { Provider, track, identify, reset } = {
Provider: ProviderComponent,
track: (name, params) => {
const client = getClient();
client.capture(name, params);
},
identify: (userId, traits) => {
const client = getClient();
client.identify(userId, traits);
},
reset: () => {
const client = getClient();
client.reset();
},
} satisfies AnalyticsProviderClientStrategy;