@marktiderman/genesis-cli 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +224 -3
  2. package/dist/cli.js +4602 -1549
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-Ci-_Ue-1.d.ts → config-CrZbM3jD.d.ts} +73 -4
  5. package/dist/doctor.d.ts +31 -4
  6. package/dist/doctor.js +976 -30
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +91 -8
  9. package/dist/expo.js +207 -14
  10. package/dist/expo.js.map +1 -1
  11. package/dist/genesis-catalog.json +502 -0
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +987 -38
  14. package/dist/index.js.map +1 -1
  15. package/dist/scaffolder.d.ts +1 -1
  16. package/dist/scaffolder.js +9 -6
  17. package/dist/scaffolder.js.map +1 -1
  18. package/dist/starter/.eas/scripts/rollout-health.mjs +85 -0
  19. package/dist/starter/.eas/workflows/deploy-production.yml +149 -0
  20. package/dist/starter/.eas/workflows/e2e.yml +77 -0
  21. package/dist/starter/.eas/workflows/pr-preview.yml +117 -0
  22. package/dist/starter/.eas/workflows/rollout.yml +120 -0
  23. package/dist/starter/.env.example +11 -0
  24. package/dist/starter/.fingerprintignore +7 -0
  25. package/dist/starter/.maestro/README.md +38 -0
  26. package/dist/starter/.maestro/config.yaml +5 -0
  27. package/dist/starter/.maestro/flows/deep-link.yaml +22 -0
  28. package/dist/starter/.maestro/flows/launch.yaml +17 -0
  29. package/dist/starter/.maestro/flows/settings-version.yaml +28 -0
  30. package/dist/starter/.maestro/flows/sign-in-screen.yaml +17 -0
  31. package/dist/starter/.maestro/subflows/sign-in.yaml +20 -0
  32. package/dist/starter/README.md +314 -0
  33. package/dist/starter/__tests__/app-config.test.ts +51 -0
  34. package/dist/starter/__tests__/check-in-photos.test.ts +57 -0
  35. package/dist/starter/__tests__/components/css-stub.js +2 -0
  36. package/dist/starter/__tests__/components/fake-supabase.ts +136 -0
  37. package/dist/starter/__tests__/components/links.test.ts +25 -0
  38. package/dist/starter/__tests__/components/render-app.ts +22 -0
  39. package/dist/starter/__tests__/components/reports.ts +10 -0
  40. package/dist/starter/__tests__/components/resolver.js +12 -0
  41. package/dist/starter/__tests__/components/root-layout.test.tsx +55 -0
  42. package/dist/starter/__tests__/components/session-storage.test.tsx +81 -0
  43. package/dist/starter/__tests__/components/settings.test.tsx +134 -0
  44. package/dist/starter/__tests__/components/setup.ts +69 -0
  45. package/dist/starter/__tests__/components/sign-in.test.tsx +90 -0
  46. package/dist/starter/__tests__/components/tabs-feature-off.test.tsx +19 -0
  47. package/dist/starter/__tests__/components/tabs.test.tsx +43 -0
  48. package/dist/starter/__tests__/components/tabs.ts +12 -0
  49. package/dist/starter/__tests__/entry.test.ts +28 -0
  50. package/dist/starter/__tests__/inline-copy.ts +59 -0
  51. package/dist/starter/__tests__/starter.test.ts +319 -0
  52. package/dist/starter/_gitignore +13 -0
  53. package/dist/starter/app.config.ts +44 -0
  54. package/dist/starter/babel.config.js +9 -0
  55. package/dist/starter/eas.json +47 -0
  56. package/dist/starter/eslint.config.js +5 -0
  57. package/dist/starter/genesis.config.json +12 -0
  58. package/dist/starter/global.css +3 -0
  59. package/dist/starter/index.ts +14 -0
  60. package/dist/starter/jest.config.js +36 -0
  61. package/dist/starter/metro.config.js +38 -0
  62. package/dist/starter/package.json +93 -0
  63. package/dist/starter/pnpm-workspace.yaml +73 -0
  64. package/dist/starter/src/app/(app)/(home)/_layout.tsx +6 -0
  65. package/dist/starter/src/app/(app)/(home)/check-in.tsx +41 -0
  66. package/dist/starter/src/app/(app)/(home)/index.tsx +34 -0
  67. package/dist/starter/src/app/(app)/_layout.tsx +27 -0
  68. package/dist/starter/src/app/(app)/notifications/_layout.tsx +6 -0
  69. package/dist/starter/src/app/(app)/notifications/index.tsx +36 -0
  70. package/dist/starter/src/app/(app)/settings/_layout.tsx +6 -0
  71. package/dist/starter/src/app/(app)/settings/index.tsx +96 -0
  72. package/dist/starter/src/app/(app)/settings/notifications.tsx +16 -0
  73. package/dist/starter/src/app/(app)/settings/support/[id].tsx +23 -0
  74. package/dist/starter/src/app/(app)/settings/support/ideas.tsx +20 -0
  75. package/dist/starter/src/app/(app)/settings/support/index.tsx +20 -0
  76. package/dist/starter/src/app/(app)/settings/support/new.tsx +35 -0
  77. package/dist/starter/src/app/(app)/settings/support/shipped.tsx +20 -0
  78. package/dist/starter/src/app/+native-intent.ts +11 -0
  79. package/dist/starter/src/app/_layout.tsx +20 -0
  80. package/dist/starter/src/app/sign-in.tsx +69 -0
  81. package/dist/starter/src/copy.ts +118 -0
  82. package/dist/starter/src/forms/check-in.json +121 -0
  83. package/dist/starter/src/lib/account.ts +42 -0
  84. package/dist/starter/src/lib/app.ts +52 -0
  85. package/dist/starter/src/lib/auth.ts +80 -0
  86. package/dist/starter/src/lib/check-in-photos.ts +66 -0
  87. package/dist/starter/src/lib/check-in.ts +85 -0
  88. package/dist/starter/src/lib/define-starter.ts +148 -0
  89. package/dist/starter/src/lib/devtools-overlay.ts +34 -0
  90. package/dist/starter/src/lib/devtools.ts +23 -0
  91. package/dist/starter/src/lib/env.ts +33 -0
  92. package/dist/starter/src/lib/google-signin.ts +23 -0
  93. package/dist/starter/src/lib/links.ts +40 -0
  94. package/dist/starter/src/lib/native-modules.ts +27 -0
  95. package/dist/starter/src/lib/notifications.ts +15 -0
  96. package/dist/starter/src/lib/observability.ts +45 -0
  97. package/dist/starter/src/lib/push.ts +49 -0
  98. package/dist/starter/src/lib/supabase.ts +65 -0
  99. package/dist/starter/src/lib/support.ts +44 -0
  100. package/dist/starter/src/lib/updates.ts +61 -0
  101. package/dist/starter/starter.config.ts +37 -0
  102. package/dist/starter/supabase/config.toml +26 -0
  103. package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +237 -0
  104. package/dist/starter/supabase/functions/genesis-apple-revoke/handler.ts +227 -0
  105. package/dist/starter/supabase/functions/genesis-apple-revoke/index.ts +55 -0
  106. package/dist/starter/supabase/functions/genesis-push-send/expo.ts +117 -0
  107. package/dist/starter/supabase/functions/genesis-push-send/handler.ts +462 -0
  108. package/dist/starter/supabase/functions/genesis-push-send/index.ts +54 -0
  109. package/dist/starter/supabase/migrations/20261024000000_genesis_account_deletion.sql +133 -0
  110. package/dist/starter/supabase/migrations/20261024000100_genesis_app_release_policy.sql +82 -0
  111. package/dist/starter/supabase/migrations/20261024000200_genesis_apple_token_revocation.sql +205 -0
  112. package/dist/starter/supabase/migrations/20261024000400_genesis_push.sql +524 -0
  113. package/dist/starter/supabase/migrations/20261024000600_genesis_support.sql +846 -0
  114. package/dist/starter/supabase/tests/database/genesis_account_deletion.test.sql +138 -0
  115. package/dist/starter/supabase/tests/database/genesis_app_release_policy.test.sql +148 -0
  116. package/dist/starter/supabase/tests/database/genesis_apple_token_revocation.test.sql +230 -0
  117. package/dist/starter/supabase/tests/database/genesis_push.test.sql +407 -0
  118. package/dist/starter/supabase/tests/database/genesis_support.test.sql +552 -0
  119. package/dist/starter/tailwind.config.mjs +15 -0
  120. package/dist/starter/tsconfig.json +14 -0
  121. package/dist/starter/vitest.config.mts +7 -0
  122. package/dist/templates/ci/app-ci.yml +17 -0
  123. package/dist/templates/ci/genesis-upgrade.yml +21 -0
  124. package/dist/templates/ci/supabase-ci.yml +20 -0
  125. package/dist/templates/eas/eas.json +47 -0
  126. package/dist/templates/eas/scripts/rollout-health.mjs +85 -0
  127. package/dist/templates/eas/workflows/deploy-production.yml +149 -0
  128. package/dist/templates/eas/workflows/e2e.yml +77 -0
  129. package/dist/templates/eas/workflows/pr-preview.yml +117 -0
  130. package/dist/templates/eas/workflows/rollout.yml +120 -0
  131. package/dist/templates/maestro/config.yaml +5 -0
  132. package/dist/templates/maestro/flows/deep-link.yaml +22 -0
  133. package/dist/templates/maestro/flows/launch.yaml +17 -0
  134. package/dist/templates/maestro/flows/settings-version.yaml +28 -0
  135. package/dist/templates/maestro/flows/sign-in-screen.yaml +17 -0
  136. package/dist/templates/maestro/subflows/sign-in.yaml +20 -0
  137. package/dist/vite.js +975 -29
  138. package/dist/vite.js.map +1 -1
  139. package/package.json +4 -4
@@ -0,0 +1,96 @@
1
+ import { useState } from "react";
2
+ import { Stack, router, type Href } from "expo-router";
3
+ import { Alert } from "react-native";
4
+ import type { Session } from "@supabase/supabase-js";
5
+ import { useBlockSettings, useSession } from "@marktiderman/genesis-native";
6
+ import { useBlockReload } from "@marktiderman/genesis-native/updates";
7
+ import { SettingsPage, getSettingsPageStackOptions, type SettingsPageDangerousAction } from "@marktiderman/genesis-ui-native";
8
+ import starter from "../../../../starter.config";
9
+ import { copy } from "@/copy";
10
+ import { deleteAccount } from "@/lib/account";
11
+ import { devtools } from "@/lib/devtools";
12
+ import { observability } from "@/lib/observability";
13
+ import { supabase } from "@/lib/supabase";
14
+ import { useAppVersion } from "@/lib/updates";
15
+
16
+ const t = copy.settings;
17
+
18
+ /** The Settings tab: who is signed in, the version signature (`features.updates`), sign out and (`features.accountDeletion`) delete account. */
19
+ export default function SettingsScreen() {
20
+ const { session } = useSession<Session>();
21
+ // While the request runs, "Delete account" does nothing (each try also goes through the confirmation).
22
+ const [busy, setBusy] = useState(false);
23
+ // An update never reloads the app while the deletion request runs.
24
+ useBlockReload(busy);
25
+ const version = useAppVersion();
26
+ const blockSettings = useBlockSettings(
27
+ [
28
+ { id: "account", title: t.accountSection, rows: [{ id: "email", title: t.signedInAs, subtitle: session?.user.email ?? "" }] },
29
+ { id: "general", rows: [] },
30
+ // The support block's Send feedback and Help rows (`features.support`).
31
+ { id: "support", title: copy.support.settings.section, rows: [] },
32
+ {
33
+ id: "about",
34
+ title: t.aboutSection,
35
+ rows: [
36
+ { id: "version", title: t.version, subtitle: version },
37
+ // Development and preview builds only (`features.devtools`).
38
+ ...(devtools?.enabled ? [{ id: "devtools", title: t.devtools, showChevron: true, onPress: devtools.open, testID: "open-devtools" }] : []),
39
+ ],
40
+ },
41
+ ],
42
+ { navigate: (href) => router.push(href as Href) },
43
+ );
44
+
45
+ const runDelete = async () => {
46
+ setBusy(true);
47
+ try {
48
+ const result = await deleteAccount();
49
+ if (result.ok) {
50
+ observability?.track("account.deleted");
51
+ // Signed out: the tabs' layout is already on its way to sign-in.
52
+ Alert.alert(t.deletedTitle, t.deletedBody);
53
+ return;
54
+ }
55
+ const buttons = result.signInAgain
56
+ ? [{ text: t.cancel, style: "cancel" as const }, { text: t.signInAgain, onPress: () => void supabase.auth.signOut() }]
57
+ : [{ text: t.ok }];
58
+ Alert.alert(t.deleteFailedTitle, t.deleteErrors[result.reason], buttons);
59
+ } finally {
60
+ setBusy(false);
61
+ }
62
+ };
63
+
64
+ // Asks first: deleting the account can't be undone (App Store Review Guideline 5.1.1(v)).
65
+ const confirmDelete = () =>
66
+ Alert.alert(t.deleteConfirmTitle, t.deleteConfirmBody, [
67
+ { text: t.cancel, style: "cancel" },
68
+ { text: t.deleteConfirm, style: "destructive", onPress: () => void runDelete() },
69
+ ]);
70
+
71
+ const dangerousActions: SettingsPageDangerousAction[] = [
72
+ {
73
+ label: t.signOut,
74
+ testID: "sign-out",
75
+ onPress: () => {
76
+ observability?.track("auth.signed_out");
77
+ void supabase.auth.signOut();
78
+ },
79
+ },
80
+ ];
81
+ if (starter.features.accountDeletion) {
82
+ dangerousActions.push({ label: t.deleteAccount, testID: "delete-account", emphasized: true, onPress: busy ? () => {} : confirmDelete });
83
+ }
84
+ // Blocks add their rows (push's Notifications row in `general`, support's in `support`); a section left empty is dropped.
85
+ const sections = blockSettings.filter((section) => section.rows.length > 0);
86
+ return (
87
+ <>
88
+ <Stack.Screen options={getSettingsPageStackOptions({ headerTitle: t.title })} />
89
+ <SettingsPage
90
+ testID="settings"
91
+ sections={sections}
92
+ dangerousActions={dangerousActions}
93
+ />
94
+ </>
95
+ );
96
+ }
@@ -0,0 +1,16 @@
1
+ import { Redirect, Stack } from "expo-router";
2
+ import { NotificationSettings } from "@marktiderman/genesis-native/push";
3
+ import { getSettingsPageStackOptions } from "@marktiderman/genesis-ui-native";
4
+ import starter from "../../../../starter.config";
5
+ import { copy } from "@/copy";
6
+
7
+ /** Settings → Notifications (`features.push`): categories, quiet hours and previews, on the push block. */
8
+ export default function NotificationSettingsScreen() {
9
+ if (!starter.features.push) return <Redirect href="/settings" />;
10
+ return (
11
+ <>
12
+ <Stack.Screen options={getSettingsPageStackOptions({ headerTitle: copy.push.settingsTitle, large: false })} />
13
+ <NotificationSettings testID="notification-settings" />
14
+ </>
15
+ );
16
+ }
@@ -0,0 +1,23 @@
1
+ import { Redirect, Stack, useLocalSearchParams } from "expo-router";
2
+ import { useSupportThread } from "@marktiderman/genesis-support/native";
3
+ import { ThreadPage, getThreadPageStackOptions } from "@marktiderman/genesis-ui-native";
4
+ import starter from "../../../../../starter.config";
5
+
6
+ /** One report as a conversation with support (`features.support`): its screenshots, the replies, and yours. */
7
+ export default function SupportThreadScreen() {
8
+ const { id } = useLocalSearchParams<{ id: string }>();
9
+ if (!starter.features.support || !id) return <Redirect href="/settings" />;
10
+ return <Thread id={id} />;
11
+ }
12
+
13
+ function Thread({ id }: { id: string }) {
14
+ const { headerTitle, notFound, ...thread } = useSupportThread(id);
15
+ // Deleted, or not yours: back to the list.
16
+ if (notFound) return <Redirect href="/settings/support" />;
17
+ return (
18
+ <>
19
+ <Stack.Screen options={getThreadPageStackOptions({ headerTitle })} />
20
+ <ThreadPage {...thread} />
21
+ </>
22
+ );
23
+ }
@@ -0,0 +1,20 @@
1
+ import { Redirect, Stack } from "expo-router";
2
+ import { useIdeaBoard } from "@marktiderman/genesis-support/native";
3
+ import { InboxPage, getInboxPageStackOptions } from "@marktiderman/genesis-ui-native";
4
+ import starter from "../../../../../starter.config";
5
+
6
+ /** The idea board (`features.support`): suggest an idea, vote once on each, see what's planned. */
7
+ export default function IdeaBoardScreen() {
8
+ if (!starter.features.support) return <Redirect href="/settings" />;
9
+ return <Board />;
10
+ }
11
+
12
+ function Board() {
13
+ const { headerTitle, ...board } = useIdeaBoard();
14
+ return (
15
+ <>
16
+ <Stack.Screen options={getInboxPageStackOptions({ headerTitle, large: false })} />
17
+ <InboxPage {...board} />
18
+ </>
19
+ );
20
+ }
@@ -0,0 +1,20 @@
1
+ import { Redirect, Stack } from "expo-router";
2
+ import { useSupportInbox } from "@marktiderman/genesis-support/native";
3
+ import { InboxPage, getInboxPageStackOptions } from "@marktiderman/genesis-ui-native";
4
+ import starter from "../../../../../starter.config";
5
+
6
+ /** Settings → Help (`features.support`): your reports, newest first, with staff replies; Send feedback and the idea board. */
7
+ export default function SupportInboxScreen() {
8
+ if (!starter.features.support) return <Redirect href="/settings" />;
9
+ return <Inbox />;
10
+ }
11
+
12
+ function Inbox() {
13
+ const { headerTitle, ...inbox } = useSupportInbox();
14
+ return (
15
+ <>
16
+ <Stack.Screen options={getInboxPageStackOptions({ headerTitle, large: false })} />
17
+ <InboxPage {...inbox} />
18
+ </>
19
+ );
20
+ }
@@ -0,0 +1,35 @@
1
+ import { Redirect, Stack, router } from "expo-router";
2
+ import { FeedbackForm } from "@marktiderman/genesis-support/native";
3
+ import { SettingsSubPage, getSettingsSubPageStackOptions, useToast } from "@marktiderman/genesis-ui-native";
4
+ import starter from "../../../../../starter.config";
5
+ import { copy } from "@/copy";
6
+
7
+ /**
8
+ * Send feedback (`features.support`): type, message and the screenshot a shake captured, marked up
9
+ * if you like. Once it's sent, a toast says so (GenesisNativeApp mounts the toast provider) and the
10
+ * screen closes.
11
+ */
12
+ export default function SendFeedbackScreen() {
13
+ const toast = useToast();
14
+ if (!starter.features.support) return <Redirect href="/settings" />;
15
+ return (
16
+ <>
17
+ <Stack.Screen options={getSettingsSubPageStackOptions({ headerTitle: copy.support.feedback.title })} />
18
+ <SettingsSubPage testID="support-feedback" onConfirmLeave={null}>
19
+ <FeedbackForm
20
+ sentAlert={false}
21
+ onSent={(delivery) => {
22
+ toast.show({
23
+ title: copy.toasts.feedbackSent,
24
+ description: delivery.attachmentsDropped ? copy.toasts.feedbackSentWithoutScreenshot : undefined,
25
+ variant: "success",
26
+ testID: "feedback-sent-toast",
27
+ });
28
+ if (router.canGoBack()) router.back();
29
+ else router.replace("/settings/support");
30
+ }}
31
+ />
32
+ </SettingsSubPage>
33
+ </>
34
+ );
35
+ }
@@ -0,0 +1,20 @@
1
+ import { Redirect, Stack } from "expo-router";
2
+ import { useShippedIdeas } from "@marktiderman/genesis-support/native";
3
+ import { InboxPage, getInboxPageStackOptions } from "@marktiderman/genesis-ui-native";
4
+ import starter from "../../../../../starter.config";
5
+
6
+ /** You asked, we shipped (`features.support`): ideas you suggested or voted for that shipped, with the feature each shipped as. */
7
+ export default function ShippedIdeasScreen() {
8
+ if (!starter.features.support) return <Redirect href="/settings" />;
9
+ return <Shipped />;
10
+ }
11
+
12
+ function Shipped() {
13
+ const { headerTitle, ...shipped } = useShippedIdeas();
14
+ return (
15
+ <>
16
+ <Stack.Screen options={getInboxPageStackOptions({ headerTitle, large: false })} />
17
+ <InboxPage {...shipped} />
18
+ </>
19
+ );
20
+ }
@@ -0,0 +1,11 @@
1
+ import { normalizeLink } from "@marktiderman/genesis-native";
2
+ import starter from "../../starter.config";
3
+ import { linkHold, links } from "@/lib/links";
4
+
5
+ /** Every incoming link becomes a known app path (unknown ones open `/`), held until the person has signed in. */
6
+ export function redirectSystemPath({ path }: { path: string; initial: boolean }) {
7
+ if (!starter.features.deepLinks) return "/";
8
+ const to = normalizeLink(path, links);
9
+ if (to && to !== "/") linkHold.hold(to);
10
+ return to;
11
+ }
@@ -0,0 +1,20 @@
1
+ import "../../global.css";
2
+ import * as SplashScreen from "expo-splash-screen";
3
+ import { Stack } from "expo-router";
4
+ import { GenesisNativeApp } from "@marktiderman/genesis-native";
5
+ import { shell } from "@/lib/app";
6
+ import { wrapRoot } from "@/lib/observability";
7
+
8
+ SplashScreen.preventAutoHideAsync();
9
+
10
+ // The whole root: GenesisNativeApp owns theme, data, boot, errors and the session. Keep it short (a test holds it to 30 lines).
11
+ function RootLayout() {
12
+ return (
13
+ <GenesisNativeApp {...shell} splash={SplashScreen}>
14
+ <Stack screenOptions={{ headerShown: false }} />
15
+ </GenesisNativeApp>
16
+ );
17
+ }
18
+
19
+ // Sentry's touch and profiler boundaries, when observability is on.
20
+ export default wrapRoot(RootLayout);
@@ -0,0 +1,69 @@
1
+ import { useState } from "react";
2
+ import { Alert } from "react-native";
3
+ import { Redirect } from "expo-router";
4
+ import { useSession } from "@marktiderman/genesis-native";
5
+ import { useBlockReload } from "@marktiderman/genesis-native/updates";
6
+ import { AuthScreen, NativeButton, appleProvider, googleProvider } from "@marktiderman/genesis-ui-native";
7
+ import starter from "../../starter.config";
8
+ import { copy, format } from "@/copy";
9
+ import { AppleAuthentication, appleSignIn, emailSignIn, googleSignIn } from "@/lib/auth";
10
+
11
+ const t = copy.signIn;
12
+ const { features } = starter;
13
+
14
+ /** Sign in (or create an account) with email, Google when it is on and, on iOS, Apple. A signed-in person goes home. */
15
+ export default function SignInScreen() {
16
+ const { status } = useSession();
17
+ const [create, setCreate] = useState(false);
18
+ const [error, setError] = useState<string>();
19
+ const [busy, setBusy] = useState(false);
20
+ // An update never reloads the app mid sign-in.
21
+ useBlockReload(busy);
22
+ if (status === "signedIn") return <Redirect href="/" />;
23
+
24
+ const onEmail = async ({ email, password }: { email: string; password: string }) => {
25
+ setError(undefined);
26
+ setBusy(true);
27
+ const result = await emailSignIn(email, password, create).finally(() => setBusy(false));
28
+ if (!result.ok) return setError(result.message);
29
+ if (result.confirmEmail) {
30
+ Alert.alert(t.checkInboxTitle, format(t.checkInboxBody, { email }));
31
+ setCreate(false);
32
+ }
33
+ };
34
+ const onApple = async () => {
35
+ setError(undefined);
36
+ setBusy(true);
37
+ const message = await appleSignIn().finally(() => setBusy(false));
38
+ if (message) setError(message);
39
+ };
40
+ const onGoogle = async () => {
41
+ setError(undefined);
42
+ setBusy(true);
43
+ const message = await googleSignIn().finally(() => setBusy(false));
44
+ if (message) setError(message);
45
+ };
46
+
47
+ return (
48
+ <AuthScreen
49
+ branding={{ headline: t.headline, subhead: create ? t.createSubhead : t.subhead }}
50
+ providers={[
51
+ features.appleSignIn && appleProvider({ apple: AppleAuthentication, onPress: onApple }),
52
+ googleProvider({ enabled: features.googleSignIn, onPress: onGoogle, disabled: busy }),
53
+ ]}
54
+ form={{
55
+ onSubmit: onEmail,
56
+ submitLabel: create ? t.createSubmit : t.submit,
57
+ loading: busy,
58
+ errorMessage: error,
59
+ validate: ({ email, password }) => (!email ? t.emailRequired : !password ? t.passwordRequired : null),
60
+ }}
61
+ slots={features.emailSignIn ? undefined : { form: null, footer: null }}
62
+ footer={
63
+ <NativeButton variant="ghost" testID="sign-in-switch" onPress={() => setCreate((c) => !c)}>
64
+ {create ? t.switchToSignIn : t.switchToCreate}
65
+ </NativeButton>
66
+ }
67
+ />
68
+ );
69
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Every string the starter shows a person, in one typed catalog. Screens read
3
+ * `copy`; none of them holds user-facing text of its own (the starter's tests
4
+ * fail on JSX text or a literal label in `src/app`).
5
+ *
6
+ * To translate: add a catalog of the same shape (`const fr: Catalog = { … }`;
7
+ * TypeScript lists any key it misses) and export the one for the device's
8
+ * locale as `copy` (`expo-localization`'s `getLocales()[0].languageCode`).
9
+ */
10
+
11
+ const en = {
12
+ tabs: {
13
+ home: "Home",
14
+ notifications: "Notifications",
15
+ settings: "Settings",
16
+ },
17
+ signIn: {
18
+ headline: "Welcome",
19
+ subhead: "Sign in to continue.",
20
+ createSubhead: "Create an account to get started.",
21
+ submit: "Sign in",
22
+ createSubmit: "Create account",
23
+ switchToCreate: "New here? Create an account",
24
+ switchToSignIn: "Have an account? Sign in",
25
+ emailRequired: "Enter your email.",
26
+ passwordRequired: "Enter your password.",
27
+ checkInboxTitle: "Check your email",
28
+ checkInboxBody: "We sent a confirmation link to {email}. Open it, then sign in.",
29
+ errors: {
30
+ invalid_credentials: "That email and password don't match an account.",
31
+ email_not_confirmed: "Confirm your email first: open the link we sent you.",
32
+ user_already_exists: "There's already an account with that email. Sign in instead.",
33
+ weak_password: "Choose a longer password.",
34
+ over_request_rate_limit: "Too many tries. Wait a minute, then try again.",
35
+ apple_unavailable: "Sign in with Apple isn't available on this device.",
36
+ default: "Sign-in didn't work. Try again.",
37
+ },
38
+ },
39
+ home: {
40
+ title: "Home",
41
+ emptyTitle: "Your app starts here",
42
+ emptyBody: "This is the first tab. Replace this screen with your own.",
43
+ checkIn: "Try the check-in",
44
+ checkInFromLink: "Check in at Hilltop Gym",
45
+ },
46
+ checkIn: {
47
+ done: "Done",
48
+ },
49
+ notifications: {
50
+ title: "Notifications",
51
+ emptyTitle: "No notifications yet",
52
+ emptyBody: "When something needs your attention, it shows up here.",
53
+ },
54
+ settings: {
55
+ title: "Settings",
56
+ accountSection: "Account",
57
+ signedInAs: "Signed in as",
58
+ aboutSection: "About",
59
+ version: "Version",
60
+ devtools: "Developer tools",
61
+ signOut: "Sign out",
62
+ deleteAccount: "Delete account",
63
+ deleteConfirmTitle: "Delete your account?",
64
+ deleteConfirmBody: "This removes your account and its data for good. It can't be undone.",
65
+ deleteConfirm: "Delete",
66
+ cancel: "Cancel",
67
+ deleteFailedTitle: "Your account wasn't deleted",
68
+ deleteErrors: {
69
+ recentSignIn: "For your security, sign in again, then delete your account.",
70
+ notAllowed: "Sign in again (with your second factor, if you use one), then delete your account.",
71
+ refused: "This account can't be deleted yet. Contact support for help.",
72
+ inUse: "Some of your data couldn't be removed. Contact support to finish deleting your account.",
73
+ unknown: "Something went wrong. Check your connection and try again.",
74
+ },
75
+ signInAgain: "Sign in again",
76
+ ok: "OK",
77
+ deletedTitle: "Account deleted",
78
+ deletedBody: "Your account and its data have been deleted.",
79
+ notifications: "Notifications",
80
+ },
81
+ push: {
82
+ settingsTitle: "Notifications",
83
+ activityTitle: "Activity",
84
+ activityDescription: "When something needs you",
85
+ promptReason: "when something needs you",
86
+ status: {
87
+ unknown: "Checking…",
88
+ undetermined: "Off",
89
+ granted: "On",
90
+ provisional: "Delivered quietly",
91
+ denied: "Off in Settings",
92
+ unavailable: "Not available on this device",
93
+ },
94
+ },
95
+ toasts: {
96
+ feedbackSent: "Thanks. Your feedback was sent.",
97
+ feedbackSentWithoutScreenshot: "The screenshot couldn't be sent with it.",
98
+ },
99
+ // The support block's own strings (genesis-support's catalog); the ones here override its English.
100
+ // Add any key from `supportCopy` to reword or translate it.
101
+ support: {
102
+ settings: { section: "Support", sendFeedback: "Send feedback", help: "Help" },
103
+ inbox: { title: "Help" },
104
+ feedback: { title: "Send feedback" },
105
+ ideas: { title: "Idea board" },
106
+ shipped: { title: "You asked, we shipped" },
107
+ },
108
+ } as const;
109
+
110
+ /** The shape every translation fills: the English catalog's keys, with any string as the value. */
111
+ export type Catalog<T = typeof en> = { readonly [K in keyof T]: T[K] extends string ? string : Catalog<T[K]> };
112
+
113
+ export const copy: Catalog = en;
114
+
115
+ /** Fill `{name}` placeholders: `format(copy.signIn.checkInboxBody, { email })`. */
116
+ export function format(template: string, values: Readonly<Record<string, string>>): string {
117
+ return template.replace(/\{(\w+)\}/g, (token, name: string) => values[name] ?? token);
118
+ }
@@ -0,0 +1,121 @@
1
+ {
2
+ "definition": {
3
+ "schemaVersion": 1,
4
+ "id": "weekly-check-in",
5
+ "title": "Weekly check-in",
6
+ "description": "About two minutes. Your coach reads every answer.",
7
+ "layout": { "mode": "focus" },
8
+ "settings": { "saveProgress": true },
9
+ "blocks": [
10
+ { "kind": "content", "id": "welcome", "type": "heading", "text": "How was your week?" },
11
+ { "kind": "content", "id": "intro", "type": "text", "text": "One question at a time. You can go back, and your answers are kept on this phone until you send them." },
12
+ {
13
+ "kind": "field",
14
+ "id": "gym",
15
+ "key": "gym",
16
+ "type": "single-choice",
17
+ "label": "Which gym do you train at?",
18
+ "required": true,
19
+ "props": {
20
+ "options": [
21
+ { "value": "riverside", "label": "Riverside Gym", "description": "12 Mill Lane" },
22
+ { "value": "hilltop", "label": "Hilltop Gym", "description": "3 Summit Road" },
23
+ { "value": "harbour", "label": "Harbour Gym", "description": "Pier 4" }
24
+ ],
25
+ "prefill": { "param": "gym", "hideWhenPrefilled": true }
26
+ }
27
+ },
28
+ {
29
+ "kind": "field",
30
+ "id": "coach",
31
+ "key": "coach",
32
+ "type": "single-choice",
33
+ "label": "Who coached you this week?",
34
+ "description": "Only the coaches at your gym are listed.",
35
+ "required": true,
36
+ "props": { "optionsFrom": { "source": "host", "key": "coaches", "filter": { "attribute": "gym", "field": "gym" } } }
37
+ },
38
+ { "kind": "field", "id": "name", "key": "name", "type": "short-text", "label": "What should we call you?", "required": true },
39
+ {
40
+ "kind": "field",
41
+ "id": "sessions",
42
+ "key": "sessions",
43
+ "type": "number",
44
+ "label": "How many sessions did you train, {{field:name}}?",
45
+ "required": true,
46
+ "props": { "min": 0, "max": 21, "step": 1 }
47
+ },
48
+ { "kind": "field", "id": "started", "key": "started", "type": "date", "label": "When did your current programme start?" },
49
+ {
50
+ "kind": "field",
51
+ "id": "energy",
52
+ "key": "energy",
53
+ "type": "rating",
54
+ "label": "How was your energy?",
55
+ "required": true,
56
+ "props": { "max": 5, "display": "stars", "lowLabel": "Drained", "highLabel": "Buzzing" }
57
+ },
58
+ { "kind": "field", "id": "slept", "key": "slept", "type": "yes-no", "label": "Did you sleep seven hours most nights?" },
59
+ {
60
+ "kind": "field",
61
+ "id": "focus",
62
+ "key": "focus",
63
+ "type": "multi-choice",
64
+ "label": "What did you work on?",
65
+ "props": {
66
+ "options": [
67
+ { "value": "strength", "label": "Strength" },
68
+ { "value": "mobility", "label": "Mobility" },
69
+ { "value": "endurance", "label": "Endurance" },
70
+ { "value": "skills", "label": "Skills" }
71
+ ],
72
+ "other": { "label": "Something else" }
73
+ }
74
+ },
75
+ {
76
+ "kind": "field",
77
+ "id": "class",
78
+ "key": "class",
79
+ "type": "single-choice",
80
+ "label": "Which class did you enjoy most?",
81
+ "props": {
82
+ "options": [
83
+ { "value": "c01", "label": "Barbell basics" },
84
+ { "value": "c02", "label": "Kettlebell flow" },
85
+ { "value": "c03", "label": "Rowing intervals" },
86
+ { "value": "c04", "label": "Open gym" },
87
+ { "value": "c05", "label": "Olympic lifting" },
88
+ { "value": "c06", "label": "Gymnastics skills" },
89
+ { "value": "c07", "label": "Yoga for athletes" },
90
+ { "value": "c08", "label": "Sprint club" },
91
+ { "value": "c09", "label": "Strongman Saturday" },
92
+ { "value": "c10", "label": "Core and conditioning" },
93
+ { "value": "c11", "label": "Masters class" },
94
+ { "value": "c12", "label": "Mobility lab" }
95
+ ],
96
+ "other": true
97
+ }
98
+ },
99
+ {
100
+ "kind": "content",
101
+ "id": "tip",
102
+ "type": "callout",
103
+ "text": "Nearly done. The next questions help your coach plan next week.",
104
+ "props": { "title": "Almost there", "tone": "success" }
105
+ },
106
+ { "kind": "field", "id": "recommend", "key": "recommend", "type": "nps", "label": "How likely are you to recommend us to a friend?" },
107
+ { "kind": "field", "id": "email", "key": "email", "type": "email", "label": "Email for your weekly summary" },
108
+ { "kind": "field", "id": "phone", "key": "phone", "type": "phone", "label": "A phone number your coach can text" },
109
+ { "kind": "field", "id": "photo", "key": "photo", "type": "photo", "label": "A progress photo, if you like" },
110
+ { "kind": "field", "id": "notes", "key": "notes", "type": "long-text", "label": "Anything else your coach should know?" }
111
+ ],
112
+ "endings": [{ "id": "done", "title": "Thanks, {{field:name}}", "description": "Your coach will reply before your next session." }]
113
+ },
114
+ "contentTypes": [{ "type": "callout", "label": "Callout" }],
115
+ "coaches": [
116
+ { "value": "ada", "label": "Ada Park", "description": "Strength", "attributes": { "gym": "riverside" } },
117
+ { "value": "grace", "label": "Grace Okafor", "description": "Mobility", "attributes": { "gym": ["riverside", "hilltop"] } },
118
+ { "value": "alan", "label": "Alan Reyes", "description": "Endurance", "attributes": { "gym": "hilltop" } },
119
+ { "value": "mina", "label": "Mina Sato", "description": "Olympic lifting", "attributes": { "gym": "harbour" } }
120
+ ]
121
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Deleting the account (`features.accountDeletion`). `deleteMyAccount` runs the
3
+ * `delete_my_account` RPC, then signs this device out; the result tells the
4
+ * screen which of the two failed, so a refusal is never reported as a
5
+ * deletion and a deletion is never reported as a refusal.
6
+ */
7
+ import { SupabaseQueryError, deleteMyAccount } from "@marktiderman/genesis-supabase";
8
+ import { copy } from "@/copy";
9
+ import { supabase } from "./supabase";
10
+
11
+ export type DeleteRefusal = keyof typeof copy.settings.deleteErrors;
12
+
13
+ export type DeleteResult =
14
+ | { ok: true }
15
+ /** The database refused (nothing was deleted). `reason` picks the copy; `signInAgain` offers a fresh sign-in. */
16
+ | { ok: false; reason: DeleteRefusal; signInAgain: boolean };
17
+
18
+ /** `SupabaseQueryError.code` from `delete_my_account` → why, in the catalog's words. See the package README. */
19
+ const REASONS: Record<string, DeleteRefusal> = {
20
+ GA002: "recentSignIn", // the app requires a recent sign-in
21
+ "42501": "notAllowed", // not signed in, or a verified MFA factor and an aal1 session
22
+ GA001: "refused", // the app's own hook refused
23
+ "23503": "inUse", // a row (or a Storage file) still points at the login
24
+ };
25
+
26
+ export async function deleteAccount(): Promise<DeleteResult> {
27
+ try {
28
+ // The delete queues the person's Apple tokens; this asks genesis-apple-revoke to revoke them now.
29
+ await deleteMyAccount(supabase, { revokeAppleTokens: true });
30
+ return { ok: true };
31
+ } catch (error) {
32
+ if (error instanceof SupabaseQueryError) {
33
+ const code = error.code ?? "";
34
+ const reason: DeleteRefusal = REASONS[code] ?? (code.startsWith("GA") ? "refused" : "unknown");
35
+ return { ok: false, reason, signInAgain: reason === "recentSignIn" || reason === "notAllowed" };
36
+ }
37
+ // Not the database's refusal: the RPC succeeded and the local sign-out failed. The login is
38
+ // gone, so clear this device's copy again and report the deletion.
39
+ await supabase.auth.signOut({ scope: "local" }).catch(() => {});
40
+ return { ok: true };
41
+ }
42
+ }