@marktiderman/genesis-cli 1.7.0 → 1.9.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 (68) hide show
  1. package/README.md +26 -4
  2. package/dist/cli.js +933 -319
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-CrZbM3jD.d.ts → config-QC_Ewwwp.d.ts} +27 -3
  5. package/dist/doctor.d.ts +68 -4
  6. package/dist/doctor.js +654 -87
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +2 -2
  9. package/dist/expo.js.map +1 -1
  10. package/dist/genesis-catalog.json +164 -14
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +666 -101
  13. package/dist/index.js.map +1 -1
  14. package/dist/starter/.env.example +3 -0
  15. package/dist/starter/README.md +7 -0
  16. package/dist/starter/__tests__/app-config.test.ts +27 -0
  17. package/dist/starter/__tests__/chat-outboxes.test.ts +64 -0
  18. package/dist/starter/__tests__/check-in-photos.test.ts +5 -3
  19. package/dist/starter/__tests__/components/fake-supabase.ts +8 -0
  20. package/dist/starter/__tests__/components/messages.test.tsx +33 -0
  21. package/dist/starter/__tests__/components/settings.test.tsx +34 -0
  22. package/dist/starter/__tests__/components/setup.ts +13 -0
  23. package/dist/starter/__tests__/components/tabs-feature-off.test.tsx +1 -1
  24. package/dist/starter/__tests__/components/tabs.test.tsx +2 -2
  25. package/dist/starter/__tests__/inline-copy.ts +1 -1
  26. package/dist/starter/__tests__/starter.test.ts +117 -3
  27. package/dist/starter/app.config.ts +19 -2
  28. package/dist/starter/genesis.config.json +2 -2
  29. package/dist/starter/jest.config.js +2 -1
  30. package/dist/starter/metro.config.js +1 -1
  31. package/dist/starter/package.json +9 -0
  32. package/dist/starter/src/app/(app)/(home)/check-in.tsx +4 -38
  33. package/dist/starter/src/app/(app)/_layout.tsx +25 -3
  34. package/dist/starter/src/app/(app)/messages/[id].tsx +63 -0
  35. package/dist/starter/src/app/(app)/messages/_layout.tsx +11 -0
  36. package/dist/starter/src/app/(app)/messages/check-in.tsx +9 -0
  37. package/dist/starter/src/app/(app)/messages/index.tsx +38 -0
  38. package/dist/starter/src/app/(app)/messages/search.tsx +39 -0
  39. package/dist/starter/src/app/(app)/notifications/index.tsx +7 -13
  40. package/dist/starter/src/app/(app)/settings/availability.tsx +16 -0
  41. package/dist/starter/src/app/(app)/settings/index.tsx +8 -3
  42. package/dist/starter/src/app/(app)/settings/notifications.tsx +6 -3
  43. package/dist/starter/src/copy.ts +19 -0
  44. package/dist/starter/src/lib/chat-outboxes.ts +50 -0
  45. package/dist/starter/src/lib/chat-video.ts +57 -0
  46. package/dist/starter/src/lib/chat.tsx +319 -0
  47. package/dist/starter/src/lib/check-in-screen.tsx +43 -0
  48. package/dist/starter/src/lib/define-starter.ts +9 -0
  49. package/dist/starter/src/lib/env.ts +4 -0
  50. package/dist/starter/src/lib/links.ts +2 -0
  51. package/dist/starter/src/lib/notifications.ts +30 -12
  52. package/dist/starter/src/lib/push.ts +21 -5
  53. package/dist/starter/starter.config.ts +1 -0
  54. package/dist/starter/supabase/config.toml +5 -0
  55. package/dist/starter/supabase/migrations/20261025000000_genesis_chat.sql +1836 -0
  56. package/dist/starter/supabase/migrations/20261025000050_genesis_chat_coaching.sql +934 -0
  57. package/dist/starter/supabase/migrations/20261025000060_genesis_chat_search_threads.sql +85 -0
  58. package/dist/starter/supabase/migrations/20261025000100_genesis_notifications.sql +2057 -0
  59. package/dist/starter/supabase/migrations/20261026000000_chat_people.sql +57 -0
  60. package/dist/starter/supabase/tests/database/chat_people.test.sql +112 -0
  61. package/dist/starter/supabase/tests/database/genesis_chat.test.sql +254 -0
  62. package/dist/starter/supabase/tests/database/genesis_chat_coaching.test.sql +269 -0
  63. package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +50 -0
  64. package/dist/starter/supabase/tests/database/genesis_notifications.test.sql +473 -0
  65. package/dist/vite.js +651 -86
  66. package/dist/vite.js.map +1 -1
  67. package/package.json +3 -3
  68. package/dist/starter/supabase/tests/database/genesis_push.test.sql +0 -407
@@ -9,3 +9,6 @@ EXPO_PUBLIC_SENTRY_DSN=
9
9
  # Services -> Credentials: the Web client id and the iOS client id. Public: they ship in the app.
10
10
  EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID=
11
11
  EXPO_PUBLIC_GOOGLE_IOS_CLIENT_ID=
12
+ # Optional: chat video messages through Mux. Your server's createVideoUploadHandler URL
13
+ # (@marktiderman/genesis-chat/server). Empty: videos go to Supabase Storage as files.
14
+ EXPO_PUBLIC_CHAT_VIDEO_UPLOAD_URL=
@@ -177,6 +177,13 @@ manifest for the packages installed, export compliance and the fingerprint runti
177
177
  has an example). To get an issue or a webhook per report, or to remove deleted screenshots from
178
178
  storage, copy the `genesis-support-notify` and `genesis-support-cleanup` templates: see "Support"
179
179
  in [`@marktiderman/genesis-supabase`](../../packages/supabase/README.md#support-the-support-block).
180
+ - **Chat:** `supabase/migrations/20261025000000_genesis_chat.sql` and
181
+ `20261025000050_genesis_chat_coaching.sql` are genesis-chat's migrations 0001 and 0002 (topics,
182
+ scheduled send, availability, broadcast, search, link previews, moderation), copied and
183
+ drift-tested the same way. Scheduled messages, link previews, moderation and chat pushes are
184
+ worked by genesis-chat's runner (`createChatRunner` from `@marktiderman/genesis-chat/server`),
185
+ which the starter doesn't deploy: until you run it on a schedule, a scheduled message waits in
186
+ its thread's Scheduled list.
180
187
  - **Auth providers:** email works with Supabase's defaults (confirmation on: sign-up asks the
181
188
  person to confirm, then sign in; the confirmation link opens `site_url`, not the app). For Apple, enable the Apple provider with the bundle ids of all
182
189
  three variants as client ids; `supabase/config.toml` does this for a local stack.
@@ -49,3 +49,30 @@ describe("app.config.ts per APP_VARIANT", () => {
49
49
  expect(new Set(links)).toEqual(new Set([scheme]));
50
50
  });
51
51
  });
52
+
53
+ describe("chat's video messages", () => {
54
+ // The plugins write these in their mods, so the config is introspected the way `expo config --type introspect` does.
55
+ it("ask for the camera and microphone with the app's own sentences, which no other plugin deletes", async () => {
56
+ vi.spyOn(console, "warn").mockImplementation(() => {});
57
+ const load = createRequire(join(root, "package.json"));
58
+ const { getPrebuildConfigAsync } = load("@expo/prebuild-config") as { getPrebuildConfigAsync: (root: string, o: object) => Promise<{ exp: object }> };
59
+ const { compileModsAsync } = load("@expo/config-plugins") as { compileModsAsync: (exp: object, o: object) => Promise<{ ios?: { infoPlist?: Record<string, string> } }> };
60
+ const { exp } = await getPrebuildConfigAsync(root, { platforms: ["ios"] });
61
+ const plist = (await compileModsAsync(exp, { projectRoot: root, introspect: true, platforms: ["ios"], assertMissingModProviders: false })).ios?.infoPlist ?? {};
62
+ expect(plist.NSCameraUsageDescription).toBe("Record video messages to send in a conversation.");
63
+ expect(plist.NSMicrophoneUsageDescription).toBe("Record voice and video messages to send in a conversation.");
64
+ });
65
+ });
66
+
67
+ describe("iOS rich push (in the build whichever way the chat switch is)", () => {
68
+ it.each([
69
+ ["development", "com.example.genesisstarter.dev.NotificationService"],
70
+ ["production", "com.example.genesisstarter.NotificationService"],
71
+ ])("%s: Communication Notifications on the app, and the extension for EAS with the variant's id", (variant, extensionId) => {
72
+ const config = configFor(variant);
73
+ expect(config.ios?.entitlements?.["com.apple.developer.usernotifications.communication"]).toBe(true);
74
+ expect(config.ios?.infoPlist?.NSUserActivityTypes).toContain("INSendMessageIntent");
75
+ const extensions = (config.extra as { eas?: { build?: { experimental?: { ios?: { appExtensions?: { targetName: string; bundleIdentifier: string }[] } } } } })?.eas?.build?.experimental?.ios?.appExtensions;
76
+ expect(extensions).toEqual([expect.objectContaining({ targetName: "GenesisNotificationService", bundleIdentifier: extensionId })]);
77
+ });
78
+ });
@@ -0,0 +1,64 @@
1
+ // @feat:chat
2
+ /**
3
+ * Unsent chat messages never outlive the person who wrote them on this phone
4
+ * (`src/lib/chat-outboxes.ts`, used by `useClearChatOnSignOut`).
5
+ */
6
+ import { readFileSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ import { describe, expect, it, vi } from "vitest";
9
+ import { createChatOutboxes, outboxKey, type OutboxKeyStorage } from "../src/lib/chat-outboxes";
10
+
11
+ function memory(entries: Record<string, string>): OutboxKeyStorage & { data: Map<string, string> } {
12
+ const data = new Map(Object.entries(entries));
13
+ return {
14
+ data,
15
+ getAllKeys: async () => [...data.keys()],
16
+ removeItem: async (k) => void data.delete(k),
17
+ multiRemove: async (keys) => keys.forEach((k) => data.delete(k)),
18
+ };
19
+ }
20
+
21
+ describe("chat outboxes", () => {
22
+ it("sign-out empties that person's live outbox and its saved copy, even after Messages unmounted", async () => {
23
+ const storage = memory({ [outboxKey("a")]: "[1]", [outboxKey("b")]: "[2]", "genesis-chat:drafts:a:c1": "{}" });
24
+ const outboxes = createChatOutboxes(storage);
25
+ const clearA = vi.fn(async () => undefined);
26
+ outboxes.register("a", clearA);
27
+ await outboxes.clear("a");
28
+ expect(clearA).toHaveBeenCalledTimes(1);
29
+ expect(storage.data.has(outboxKey("a"))).toBe(false);
30
+ expect(storage.data.get(outboxKey("b"))).toBe("[2]");
31
+ // Drafts are clearDrafts' job.
32
+ expect(storage.data.has("genesis-chat:drafts:a:c1")).toBe(true);
33
+ // Used once: signing out again doesn't clear a later outbox through a stale handle.
34
+ await outboxes.clear("a");
35
+ expect(clearA).toHaveBeenCalledTimes(1);
36
+ });
37
+
38
+ it("clears the saved copy when Messages was never opened", async () => {
39
+ const storage = memory({ [outboxKey("a")]: "[1]" });
40
+ await createChatOutboxes(storage).clear("a");
41
+ expect(storage.data.size).toBe(0);
42
+ });
43
+
44
+ it("sign-in forgets everyone else's, live and saved, and keeps your own", async () => {
45
+ const storage = memory({ [outboxKey("a")]: "[1]", [outboxKey("b")]: "[2]", [outboxKey("c")]: "[3]", other: "x" });
46
+ const outboxes = createChatOutboxes(storage);
47
+ const clearA = vi.fn(async () => undefined);
48
+ const clearB = vi.fn(async () => undefined);
49
+ outboxes.register("a", clearA);
50
+ outboxes.register("b", clearB);
51
+ await outboxes.clearOthers("b");
52
+ expect(clearA).toHaveBeenCalled();
53
+ expect(clearB).not.toHaveBeenCalled();
54
+ expect([...storage.data.keys()].sort()).toEqual([outboxKey("b"), "other"]);
55
+ });
56
+
57
+ it("is what the signed-in layout's hook uses on sign-out and sign-in", () => {
58
+ const chat = readFileSync(join(__dirname, "..", "src/lib/chat.tsx"), "utf8");
59
+ expect(chat).toMatch(/outboxes\.clear\(who\)/);
60
+ expect(chat).toMatch(/outboxes\.clearOthers\(userId\)/);
61
+ expect(chat).toMatch(/outboxes\.register\(userId, clearOutbox\)/);
62
+ expect(chat).toContain("forgetRecentEmoji(who)");
63
+ });
64
+ });
@@ -50,8 +50,10 @@ describe("check-in photos", () => {
50
50
  });
51
51
  });
52
52
 
53
- it("is wired into the check-in screen, with a photo-library sentence and no camera permission", () => {
54
- expect(read("src/app/(app)/(home)/check-in.tsx")).toMatch(/photos=\{checkInPhotos\}/);
55
- expect(read("app.config.ts")).toMatch(/\["expo-image-picker", \{ photosPermission: "[^"]{20,}", cameraPermission: false, microphonePermission: false \}\]/);
53
+ it("is wired into the check-in screen, with a photo-library sentence", () => {
54
+ expect(read("src/lib/check-in-screen.tsx")).toMatch(/photos=\{checkInPhotos\}/);
55
+ // The check-in picks from the library only. The camera and microphone sentences are chat's video
56
+ // and voice messages, the same as expo-camera's and expo-audio's, or the picker would delete them.
57
+ expect(read("app.config.ts")).toMatch(/\["expo-image-picker", \{ photosPermission: "[^"]{20,}", cameraPermission: CAMERA, microphonePermission: MICROPHONE \}\]/);
56
58
  });
57
59
  });
@@ -107,6 +107,14 @@ export const fakeSupabase = {
107
107
  rpc: jest.fn((fn: string, _args?: object) => (fn === "delete_my_account" ? deleteMyAccount() : query({ data: null, error: null, count: 0 }))),
108
108
  // Edge Functions (genesis-apple-revoke): every call succeeds.
109
109
  functions: { invoke: jest.fn(async (_name: string, _options?: object) => ({ data: { ok: true }, error: null })) },
110
+ // genesis-chat's tables and functions (the Messages tab): an empty inbox.
111
+ schema: jest.fn((_schema: string) => ({ from: fakeSupabase.from, rpc: fakeSupabase.rpc })),
112
+ // Realtime (chat's live hints): channels that join and never hear anything.
113
+ channel: jest.fn((_topic: string, _options?: object) => {
114
+ const channel = { on: () => channel, subscribe: () => channel, send: async () => "ok" };
115
+ return channel;
116
+ }),
117
+ removeChannel: jest.fn(async (_channel: unknown) => "ok"),
110
118
  };
111
119
 
112
120
  /** `sessionReady` from `src/lib/supabase.ts`, the boot step that wipes a session left by an earlier install. */
@@ -0,0 +1,33 @@
1
+ import { describe, expect, it } from "@jest/globals";
2
+ import { screen } from "@testing-library/react-native";
3
+ import type { ChatAttachment } from "@marktiderman/genesis-chat";
4
+ import { copy } from "@/copy";
5
+ import { attachmentKinds, kindAllowsTopics } from "@/lib/chat";
6
+ import { expectPathname, renderApp } from "./render-app";
7
+
8
+ const checkIn = { id: "a1", kind: "check_in", ref: { title: "Hilltop Gym" } } as unknown as ChatAttachment;
9
+
10
+ describe("Messages", () => {
11
+ it("opens a check-in from a conversation inside the Messages stack, so Back returns to it", async () => {
12
+ const app = await renderApp("/messages/check-in", "person@example.com");
13
+ expect(await screen.findByTestId("check-in")).toBeOnTheScreen();
14
+ await expectPathname(app, "/messages/check-in");
15
+ });
16
+
17
+ it("shows the sender Sent on their own check-in card, and the others Answer", () => {
18
+ const kind = attachmentKinds.check_in!;
19
+ const call = <R,>(fn: unknown, mine: boolean) => (fn as (a: ChatAttachment, ctx: { mine: boolean }) => R)(checkIn, { mine });
20
+ expect(call<{ label: string } | null>(kind.action, false)?.label).toBe(copy.messages.checkInAnswer);
21
+ expect(call(kind.action, true)).toBeNull();
22
+ expect(call(kind.subtitle, true)).toBe(`${copy.messages.checkInSent} · Hilltop Gym`);
23
+ expect(call(kind.subtitle, false)).toBe("Hilltop Gym");
24
+ expect(kind.title(checkIn)).toBe(copy.messages.checkInCard);
25
+ });
26
+
27
+ it("offers topics in a group, not in a direct conversation", () => {
28
+ expect(kindAllowsTopics({ maxMembers: null })).toBe(true);
29
+ expect(kindAllowsTopics({ maxMembers: 12 })).toBe(true);
30
+ expect(kindAllowsTopics({ maxMembers: 2 })).toBe(false);
31
+ expect(kindAllowsTopics(null)).toBe(false);
32
+ });
33
+ });
@@ -1,6 +1,8 @@
1
1
  import { afterEach, describe, expect, it, jest } from "@jest/globals";
2
2
  import { Alert, type AlertButton } from "react-native";
3
3
  import { act, screen, userEvent, within } from "@testing-library/react-native";
4
+ import AsyncStorage from "@react-native-async-storage/async-storage";
5
+ import { draftKey } from "@marktiderman/genesis-chat/native";
4
6
  import { copy } from "@/copy";
5
7
  import { fakeSupabase, next, releaseDelete } from "./fake-supabase";
6
8
  import { expectPathname, renderApp } from "./render-app";
@@ -45,6 +47,15 @@ describe("settings screen", () => {
45
47
  expect(within(screen.getByTestId("delete-account")).getByText(t.deleteAccount)).toBeOnTheScreen();
46
48
  });
47
49
 
50
+ it("opens Availability (chat's away message and working hours) from its row", async () => {
51
+ const app = await renderApp("/settings", "person@example.com");
52
+ const row = await screen.findByTestId("open-availability");
53
+ expect(within(row).getByText(t.availability)).toBeOnTheScreen();
54
+ await userEvent.setup().press(row);
55
+ await expectPathname(app, "/settings/availability");
56
+ expect(await screen.findByTestId("chat-availability")).toBeOnTheScreen();
57
+ });
58
+
48
59
  it("signs out, and the app goes back to sign-in", async () => {
49
60
  const app = await renderApp("/settings", "person@example.com");
50
61
  await userEvent.setup().press(await screen.findByTestId("sign-out"));
@@ -55,6 +66,29 @@ describe("settings screen", () => {
55
66
  await expectPathname(app, "/sign-in");
56
67
  });
57
68
 
69
+ it("signing out takes that person's chat drafts off the phone, and nothing else of the app's", async () => {
70
+ const mine = draftKey("user-person@example.com", "c1");
71
+ const theirs = "genesis-starter:something-else";
72
+ await AsyncStorage.multiSet([[mine, JSON.stringify({ text: "half written" })], [theirs, "kept"]]);
73
+ await renderApp("/settings", "person@example.com");
74
+ await userEvent.setup().press(await screen.findByTestId("sign-out"));
75
+ expect(await screen.findByText(copy.signIn.headline)).toBeOnTheScreen();
76
+ await act(async () => undefined);
77
+ expect(await AsyncStorage.getItem(mine)).toBeNull();
78
+ expect(await AsyncStorage.getItem(theirs)).not.toBeNull();
79
+ });
80
+
81
+ it("signing in takes other people's chat drafts off the phone (a session that ended while the app was closed)", async () => {
82
+ const mine = draftKey("user-person@example.com", "c1");
83
+ const left = draftKey("user-before@example.com", "c1");
84
+ await AsyncStorage.multiSet([[mine, JSON.stringify({ text: "mine" })], [left, JSON.stringify({ text: "left behind" })]]);
85
+ await renderApp("/settings", "person@example.com");
86
+ await screen.findByTestId("sign-out");
87
+ await act(async () => undefined);
88
+ expect(await AsyncStorage.getItem(left)).toBeNull();
89
+ expect(await AsyncStorage.getItem(mine)).not.toBeNull();
90
+ });
91
+
58
92
  it("asks before deleting the account, and Cancel deletes nothing", async () => {
59
93
  const alerts = captureAlerts();
60
94
  await renderApp("/settings", "person@example.com");
@@ -12,6 +12,16 @@ process.env.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY = "test-publishable-key";
12
12
  jest.mock("@react-native-async-storage/async-storage", () => require("@react-native-async-storage/async-storage/jest/async-storage-mock"));
13
13
  jest.mock("@react-native-community/netinfo", () => require("@react-native-community/netinfo/jest/netinfo-mock.js"));
14
14
  jest.mock("react-native-keyboard-controller", () => require("react-native-keyboard-controller/jest"));
15
+ // expo-audio (chat's voice notes) builds its classes on the native module at import; chat only
16
+ // reaches it from the Messages screens, so the stand-in names what it exports.
17
+ jest.mock("expo-audio", () => ({
18
+ useAudioRecorder: () => ({ prepareToRecordAsync: async () => {}, record: () => {}, stop: async () => {}, getStatus: () => ({ isRecording: false, durationMillis: 0, url: null }), uri: null }),
19
+ useAudioPlayer: () => ({ play: () => {}, pause: () => {}, seekTo: async () => {}, setPlaybackRate: () => {} }),
20
+ useAudioPlayerStatus: () => ({ currentTime: 0, duration: 0, playing: false, didJustFinish: false, isLoaded: false, playbackRate: 1 }),
21
+ RecordingPresets: { HIGH_QUALITY: {} },
22
+ requestRecordingPermissionsAsync: async () => ({ granted: false, canAskAgain: true }),
23
+ setAudioModeAsync: async () => {},
24
+ }));
15
25
  // jest-expo's expo-notifications mock returns listener subscriptions without `remove`, which the
16
26
  // push block calls; this one is the subset the block uses, on a device that hasn't been asked yet.
17
27
  jest.mock("expo-notifications", () => {
@@ -27,6 +37,9 @@ jest.mock("expo-notifications", () => {
27
37
  getLastNotificationResponse: () => null,
28
38
  clearLastNotificationResponse: () => {},
29
39
  setBadgeCountAsync: async () => true,
40
+ // Chat's Reply and Mark read actions.
41
+ setNotificationCategoryAsync: async () => null,
42
+ dismissNotificationAsync: async () => {},
30
43
  getBadgeCountAsync: async () => 0,
31
44
  AndroidImportance: { DEFAULT: 3 },
32
45
  };
@@ -14,6 +14,6 @@ describe("tabs with a feature off", () => {
14
14
  it("hides the Notifications tab when features.notifications is off", async () => {
15
15
  await renderApp("/", "person@example.com");
16
16
  await screen.findByTestId("home");
17
- expect(tabTitles()).toEqual([copy.tabs.home, copy.tabs.settings]);
17
+ expect(tabTitles()).toEqual([copy.tabs.home, copy.tabs.messages, copy.tabs.settings]);
18
18
  });
19
19
  });
@@ -7,11 +7,11 @@ import { expectPathname, renderApp } from "./render-app";
7
7
  import { tabTitles } from "./tabs";
8
8
 
9
9
  describe("tabs", () => {
10
- it("opens a signed-in person on Home, with Home, Notifications and Settings in the tab bar", async () => {
10
+ it("opens a signed-in person on Home, with Home, Notifications, Messages and Settings in the tab bar", async () => {
11
11
  const app = await renderApp("/", "person@example.com");
12
12
  expect(await screen.findByTestId("home")).toBeOnTheScreen();
13
13
  expect(app.getPathname()).toBe("/");
14
- expect(tabTitles()).toEqual([copy.tabs.home, copy.tabs.notifications, copy.tabs.settings]);
14
+ expect(tabTitles()).toEqual([copy.tabs.home, copy.tabs.notifications, copy.tabs.messages, copy.tabs.settings]);
15
15
  });
16
16
 
17
17
  it("routes each tab to its screen", async () => {
@@ -14,7 +14,7 @@ import ts from "typescript";
14
14
  const NON_COPY_ATTRIBUTES = new Set([
15
15
  "testID", "nativeID", "id", "key", "name", "href", "src", "md", "sf", "variant", "size", "mode", "type", "appearance",
16
16
  "className", "contentClassName", "textClassName", "style", "autoComplete", "textContentType", "keyboardType",
17
- "returnKeyType", "autoCapitalize", "accessibilityRole", "behavior", "statusBar", "themeMode", "pointerEvents",
17
+ "returnKeyType", "autoCapitalize", "accessibilityRole", "behavior", "statusBar", "themeMode", "pointerEvents", "icon",
18
18
  ]);
19
19
 
20
20
  /** Object keys whose string values are shown to people. */
@@ -1,4 +1,4 @@
1
- // @feat:native-starter @feat:app-updates @feat:push @feat:observability @feat:devtools-overlay @feat:support-feedback
1
+ // @feat:native-starter @feat:app-updates @feat:push @feat:observability @feat:devtools-overlay @feat:support-feedback @feat:chat
2
2
  import { readFileSync, readdirSync, statSync } from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import { dirname, join } from "node:path";
@@ -12,7 +12,10 @@ const root = join(__dirname, "..");
12
12
  const read = (path: string) => readFileSync(join(root, path), "utf8");
13
13
  // Wherever the package manager put it (hoisted to the workspace root here).
14
14
  const supabasePackage = dirname(createRequire(join(root, "package.json")).resolve("@marktiderman/genesis-supabase/package.json"));
15
+ const notificationsPackage = dirname(createRequire(join(root, "package.json")).resolve("@marktiderman/genesis-notifications/package.json"));
15
16
  const shippedSql = (path: string) => readFileSync(join(supabasePackage, "migrations", path), "utf8");
17
+ const chatPackage = dirname(createRequire(join(root, "package.json")).resolve("@marktiderman/genesis-chat/package.json"));
18
+ const chatSql = (path: string) => readFileSync(join(chatPackage, "migrations", path), "utf8");
16
19
 
17
20
  function filesUnder(dir: string): string[] {
18
21
  return readdirSync(join(root, dir)).flatMap((name) => {
@@ -29,6 +32,13 @@ describe("root layout", () => {
29
32
  });
30
33
  });
31
34
 
35
+ describe("migrations", () => {
36
+ it("each has its own version, so a new app's database applies every one", () => {
37
+ const versions = filesUnder("supabase/migrations").map((f) => f.split("/").pop()!.split("_")[0]!);
38
+ expect(new Set(versions).size).toBe(versions.length);
39
+ });
40
+ });
41
+
32
42
  describe("starter.config.ts", () => {
33
43
  it("refuses a config with no way to sign in", () => {
34
44
  const none: StarterConfig = { ...starter, features: { ...starter.features, emailSignIn: false, appleSignIn: false } };
@@ -233,15 +243,28 @@ describe("supabase/migrations", () => {
233
243
  expect(read("supabase/tests/database/genesis_apple_token_revocation.test.sql")).toBe(shippedSql("tests/0003_genesis_apple_token_revocation.test.sql"));
234
244
  });
235
245
 
236
- it("carries the push migration and its pgTAP test unchanged (the push block reads it), after the Apple one", () => {
246
+ it("carries the push migration unchanged, after the Apple one, without its pgTAP test (superseded by the notifications migration)", () => {
237
247
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_push.sql"));
238
248
  expect(copies).toHaveLength(1);
239
249
  expect(read(copies[0]!)).toBe(shippedSql("0005_genesis_push.sql"));
240
- expect(read("supabase/tests/database/genesis_push.test.sql")).toBe(shippedSql("tests/0005_genesis_push.test.sql"));
250
+ // Two of its assertions describe the token move and forget answer the notifications migration replaces.
251
+ expect(filesUnder("supabase/tests/database").some((f) => f.endsWith("genesis_push.test.sql"))).toBe(false);
241
252
  const order = filesUnder("supabase/migrations").sort();
242
253
  expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_apple_token_revocation.sql")));
243
254
  });
244
255
 
256
+ it("carries @marktiderman/genesis-notifications' migration and its pgTAP test unchanged, after every other package's (it adopts the push tables)", () => {
257
+ const shipped = (rel: string) => readFileSync(join(notificationsPackage, "migrations", rel), "utf8");
258
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_notifications.sql"));
259
+ expect(copies).toHaveLength(1);
260
+ expect(read(copies[0]!)).toBe(shipped("0001_genesis_notifications.sql"));
261
+ expect(read("supabase/tests/database/genesis_notifications.test.sql")).toBe(shipped("tests/0001_genesis_notifications.test.sql"));
262
+ const order = filesUnder("supabase/migrations").sort();
263
+ // The starter's own migrations (chat_people) may follow; every package's copy comes first.
264
+ const packaged = order.filter((f) => /_genesis_[a-z_]+\.sql$/.test(f));
265
+ expect(packaged.at(-1)).toBe(copies[0]);
266
+ });
267
+
245
268
  it("carries the support migration and its pgTAP test unchanged (the support block reads it), after the push one", () => {
246
269
  const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_support.sql"));
247
270
  expect(copies).toHaveLength(1);
@@ -317,3 +340,94 @@ describe("support", () => {
317
340
  expect(Object.keys(pkg.dependencies)).toEqual(expect.arrayContaining(["react-native-view-shot", "expo-sensors", "@marktiderman/genesis-support"]));
318
341
  });
319
342
  });
343
+
344
+ describe("chat", () => {
345
+ it("ships with chat on, its migration and pgTAP test copied unchanged after the support one, and genesis_chat served by the API", () => {
346
+ expect(starter.features.chat).toBe(true);
347
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_chat.sql"));
348
+ expect(copies).toHaveLength(1);
349
+ expect(read(copies[0]!)).toBe(chatSql("0001_genesis_chat.sql"));
350
+ expect(read("supabase/tests/database/genesis_chat.test.sql")).toBe(chatSql("tests/0001_genesis_chat.test.sql"));
351
+ const order = filesUnder("supabase/migrations").sort();
352
+ expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_support.sql")));
353
+ // Every chat migration the package ships, in order: without one, the starter's database lacks
354
+ // what the client calls, and `genesis init` leaves the chat block out.
355
+ const shipped = readdirSync(join(chatPackage, "migrations")).filter((f) => f.endsWith(".sql")).sort();
356
+ for (const file of shipped) {
357
+ const stem = file.replace(/^\d{4}_/, "");
358
+ const copy = filesUnder("supabase/migrations").filter((f) => f.endsWith(`_${stem}`));
359
+ expect(copy, file).toHaveLength(1);
360
+ expect(read(copy[0]!)).toBe(chatSql(file));
361
+ expect(read(`supabase/tests/database/${stem.replace(/\.sql$/, ".test.sql")}`)).toBe(chatSql(`tests/${file.replace(/\.sql$/, ".test.sql")}`));
362
+ }
363
+ expect(read("supabase/config.toml")).toMatch(/schemas = \[[^\]]*"genesis_chat"/);
364
+ expect(JSON.parse(read("genesis.config.json")).doctor.supabase.exposedSchemas).toContain("genesis_chat");
365
+ });
366
+
367
+ it("carries chat's 0002 migration (topics, scheduled send, availability, broadcast, search) and its pgTAP test unchanged, after 0001", () => {
368
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_genesis_chat_coaching.sql"));
369
+ expect(copies).toHaveLength(1);
370
+ expect(read(copies[0]!)).toBe(chatSql("0002_genesis_chat_coaching.sql"));
371
+ expect(read("supabase/tests/database/genesis_chat_coaching.test.sql")).toBe(chatSql("tests/0002_genesis_chat_coaching.test.sql"));
372
+ const order = filesUnder("supabase/migrations").sort();
373
+ expect(order.indexOf(copies[0]!)).toBe(order.findIndex((f) => f.endsWith("_genesis_chat.sql")) + 1);
374
+ });
375
+
376
+ it("puts one chat over every signed-in tab, with Availability under Settings and search and broadcast in Messages", () => {
377
+ expect(read("src/app/(app)/_layout.tsx")).toContain("starter.features.chat ? <ChatRoot>{app}</ChatRoot> : app");
378
+ expect(read("src/app/(app)/messages/_layout.tsx")).not.toContain("<ChatRoot");
379
+ expect(read("src/app/(app)/settings/availability.tsx")).toContain('if (!starter.features.chat) return <Redirect href="/settings" />');
380
+ expect(read("src/app/(app)/settings/index.tsx")).toContain('router.push("/settings/availability" as Href)');
381
+ expect(read("src/app/(app)/messages/index.tsx")).toContain("<ChatBroadcastSheet");
382
+ expect(read("src/app/(app)/messages/[id].tsx")).toMatch(/<ChatThreadScreen key=\{id\} conversationId=\{id\} jumpTo=\{jumpTo\}/);
383
+ });
384
+
385
+ it("has the Messages tab and its routes, each sending you home when chat is off", () => {
386
+ expect(read("src/app/(app)/_layout.tsx")).toContain('name="messages" hidden={!starter.features.chat}');
387
+ for (const route of ["_layout", "index", "[id]", "search"]) {
388
+ expect(read(join("src/app/(app)/messages", `${route}.tsx`)), route).toContain("if (!starter.features.chat) return <Redirect");
389
+ }
390
+ });
391
+
392
+ it("starts each conversation's thread fresh: the screen is keyed by the conversation id", () => {
393
+ expect(read("src/app/(app)/messages/[id].tsx")).toMatch(/<ChatThreadScreen key=\{id\} conversationId=\{id\}/);
394
+ });
395
+
396
+ it("opens a message's push in its thread, and adds the messages category with Reply and Mark read when push is on", () => {
397
+ expect(read("src/lib/links.ts")).toContain('"/messages/:id": "/messages/:id"');
398
+ expect(read("src/lib/push.ts")).toContain("starter.features.chat ? [chatPushCategory()] : []");
399
+ expect(read("src/lib/push.ts")).toContain("onResponse: onChatPushResponse");
400
+ expect(read("src/lib/chat.tsx")).toContain("starter.features.chat && starter.features.push");
401
+ });
402
+
403
+ it("names people from their auth metadata through chat_people, after the chat migration, with its pgTAP test", () => {
404
+ const copies = filesUnder("supabase/migrations").filter((f) => f.endsWith("_chat_people.sql"));
405
+ expect(copies).toHaveLength(1);
406
+ const order = filesUnder("supabase/migrations").sort();
407
+ expect(order.indexOf(copies[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_chat.sql")));
408
+ const sql = read(copies[0]!);
409
+ expect(sql).toContain("security definer");
410
+ expect(sql).toContain("set search_path = ''");
411
+ expect(sql).toMatch(/revoke execute on function public\.chat_people\(uuid\[\]\) from public, anon;/);
412
+ expect(read("supabase/tests/database/chat_people.test.sql")).toContain("select plan(");
413
+ const chat = read("src/lib/chat.tsx");
414
+ expect(chat).toContain('supabase.rpc("chat_people"');
415
+ expect(chat).toContain("loadPeople = loadChatPeople");
416
+ // An untitled two-person thread is called by the other person's name.
417
+ expect(read("src/app/(app)/messages/[id].tsx")).toContain("conversation?.title ?? otherName ?? copy.messages.threadTitle");
418
+ });
419
+
420
+ it("forgets unsent messages on sign-out and retries them on return and reconnect", () => {
421
+ const chat = read("src/lib/chat.tsx");
422
+ expect(chat).not.toContain("TODO(chat clearOutbox)");
423
+ expect(chat).toContain("void outboxes.clear(who)");
424
+ expect(chat).toContain("<ChatAutoRetry />");
425
+ expect(chat).toMatch(/netInfo: NetInfo/);
426
+ });
427
+
428
+ it("keeps expo-audio, expo-image-picker and expo-clipboard in the build whichever way the switch is", () => {
429
+ expect(read("app.config.ts")).not.toContain("features.chat");
430
+ const pkg = JSON.parse(read("package.json")) as { dependencies: Record<string, string> };
431
+ expect(Object.keys(pkg.dependencies)).toEqual(expect.arrayContaining(["expo-audio", "expo-image-picker", "expo-clipboard", "@marktiderman/genesis-chat"]));
432
+ });
433
+ });
@@ -2,6 +2,9 @@
2
2
  import "tsx/cjs";
3
3
  import type { ConfigContext, ExpoConfig } from "expo/config";
4
4
  import starter from "./starter.config";
5
+
6
+ const MICROPHONE = "Record voice and video messages to send in a conversation.";
7
+ const CAMERA = "Record video messages to send in a conversation.";
5
8
  import { easConfig, nativePlatforms, privacyBlocks } from "./src/lib/define-starter";
6
9
 
7
10
  // Name, ids and plugins only. The Genesis plugin (`@marktiderman/genesis-cli`) adds the rest:
@@ -31,10 +34,24 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
31
34
  "expo-secure-store",
32
35
  "expo-updates",
33
36
  "expo-notifications",
34
- // The check-in's photo question picks from the library only: no camera, so no camera or microphone prompt.
35
- ["expo-image-picker", { photosPermission: "Choose a photo to add to your check-in.", cameraPermission: false, microphonePermission: false }],
37
+ // The check-in's photo question picks from the library only. The camera and microphone sentences
38
+ // are set on every plugin that writes them: plugins' mods run in reverse order, so the picker's
39
+ // `cameraPermission: false` would delete the one expo-camera adds, as its
40
+ // `microphonePermission: false` deleted expo-audio's (seen in a simulator build).
41
+ ["expo-image-picker", { photosPermission: "Choose photos to add to a check-in or a message.", cameraPermission: CAMERA, microphonePermission: MICROPHONE }],
42
+ // Video messages in chat (expo-camera records, expo-video plays).
43
+ ["expo-camera", { cameraPermission: CAMERA, microphonePermission: MICROPHONE, recordAudioAndroid: true }],
44
+ "expo-video",
45
+ // Voice messages in chat. Kept whichever way the chat switch is, so it stays JavaScript only.
46
+ ["expo-audio", { microphonePermission: MICROPHONE }],
36
47
  // The privacy manifest declares the data of the blocks that are on (account, observability, push).
37
48
  ["@marktiderman/genesis-cli", { privacy: { blocks: privacyBlocks(starter.features) } }],
49
+ // iOS rich push for chat: a Notification Service Extension that shows the sender's photo, makes
50
+ // message pushes Communication Notifications (Focus treats them as messages) and attaches photos.
51
+ // Kept whichever way the chat and push switches are, so they stay JavaScript only: it does nothing
52
+ // until a push carries chatPushPayload's fields. After the Genesis plugin, so the extension's
53
+ // bundle id follows the APP_VARIANT suffix.
54
+ "@marktiderman/genesis-native/rich-push-plugin",
38
55
  // Optional: upload source maps to Sentry from EAS builds (the observability block). Set your
39
56
  // organization and project slugs, add SENTRY_AUTH_TOKEN as an EAS secret, set "@sentry/cli" to
40
57
  // true under allowBuilds in pnpm-workspace.yaml, and switch metro.config.js to
@@ -2,11 +2,11 @@
2
2
  "doctor": {
3
3
  "packs": ["native", "supabase"],
4
4
  "native": { "routerRoot": "src/app" },
5
- "supabase": { "migrations": "supabase/migrations", "base": "origin/main", "exposedSchemas": ["public"] },
5
+ "supabase": { "migrations": "supabase/migrations", "base": "origin/main", "exposedSchemas": ["public", "genesis_chat"] },
6
6
  "src": ["src", "starter.config.ts", "app.config.ts"]
7
7
  },
8
8
  "links": {
9
9
  "hosts": ["example.com"],
10
- "paths": ["/notifications", "/settings"]
10
+ "paths": ["/notifications", "/messages", "/settings"]
11
11
  }
12
12
  }
@@ -32,5 +32,6 @@ module.exports = {
32
32
  },
33
33
  transformIgnorePatterns: [extended, ...rest],
34
34
  // A file's first render loads the whole app through Babel; on a cold cache (CI) that alone can pass 5 s.
35
- testTimeout: 30_000,
35
+ // Whole-app renders: about 2 s each here, but shared CI runners (every package testing at once) have taken 80 s a file.
36
+ testTimeout: 90_000,
36
37
  };
@@ -13,7 +13,7 @@ const config = getDefaultConfig(projectRoot);
13
13
  // The workspace packages the app imports, so edits to them reload the app.
14
14
  config.watchFolders = [
15
15
  ...(config.watchFolders || []),
16
- ...["core", "design-system", "features", "forms", "forms-native", "forms-react", "native", "supabase", "support", "ui-native"].map((name) => path.resolve(monorepoRoot, "packages", name)),
16
+ ...["chat", "core", "design-system", "features", "forms", "forms-native", "forms-react", "native", "supabase", "support", "ui-native"].map((name) => path.resolve(monorepoRoot, "packages", name)),
17
17
  ];
18
18
 
19
19
  config.resolver.nodeModulesPaths = [
@@ -19,12 +19,14 @@
19
19
  "@expo/metro-runtime": "~58.0.15",
20
20
  "@expo/ui": "~58.0.23",
21
21
  "@hookform/resolvers": "^5.0.1",
22
+ "@marktiderman/genesis-chat": "workspace:^",
22
23
  "@marktiderman/genesis-core": "workspace:^",
23
24
  "@marktiderman/genesis-design-system": "workspace:^",
24
25
  "@marktiderman/genesis-forms": "workspace:^",
25
26
  "@marktiderman/genesis-forms-native": "workspace:^",
26
27
  "@marktiderman/genesis-forms-react": "workspace:^",
27
28
  "@marktiderman/genesis-native": "workspace:^",
29
+ "@marktiderman/genesis-notifications": "workspace:^",
28
30
  "@marktiderman/genesis-supabase": "workspace:^",
29
31
  "@marktiderman/genesis-support": "workspace:^",
30
32
  "@marktiderman/genesis-ui-native": "workspace:^",
@@ -41,8 +43,12 @@
41
43
  "expo": "~58.0.19",
42
44
  "expo-apple-authentication": "~58.0.2",
43
45
  "expo-application": "~58.1.2",
46
+ "expo-audio": "~58.0.10",
47
+ "expo-camera": "~58.0.12",
48
+ "expo-clipboard": "~58.0.4",
44
49
  "expo-constants": "~58.0.13",
45
50
  "expo-crypto": "~58.0.7",
51
+ "expo-file-system": "~58.0.11",
46
52
  "expo-glass-effect": "~58.0.5",
47
53
  "expo-haptics": "~58.0.7",
48
54
  "expo-image": "~58.0.17",
@@ -52,10 +58,13 @@
52
58
  "expo-router": "~58.0.26",
53
59
  "expo-secure-store": "~58.0.2",
54
60
  "expo-sensors": "~58.0.4",
61
+ "expo-sharing": "~58.0.20",
55
62
  "expo-splash-screen": "~58.0.11",
56
63
  "expo-status-bar": "~58.0.4",
57
64
  "expo-symbols": "~58.0.4",
58
65
  "expo-updates": "~58.0.18",
66
+ "expo-video": "~58.0.12",
67
+ "expo-web-browser": "~58.0.6",
59
68
  "lucide-react-native": ">=0.475.0",
60
69
  "nativewind": "^4.2.7",
61
70
  "react": "19.3.0",
@@ -1,41 +1,7 @@
1
- import { Redirect, Stack, router, useLocalSearchParams } from "expo-router";
2
- import type { Session } from "@supabase/supabase-js";
3
- import { useSession } from "@marktiderman/genesis-native";
4
- import { FormFocus, Button } from "@marktiderman/genesis-forms-native";
5
- import { useFormDraft } from "@marktiderman/genesis-forms-react";
6
- import { ScreenContainer } from "@marktiderman/genesis-ui-native";
7
- import starter from "../../../../starter.config";
8
1
  import { copy } from "@/copy";
9
- import { checkInDrafts, checkInForm, checkInHaptics, checkInHostOptions, checkInKey, checkInOutbox, checkInPhotos } from "@/lib/check-in";
2
+ import { CheckInScreen } from "@/lib/check-in-screen";
10
3
 
11
- /**
12
- * The check-in example (`features.checkIn`): one question per screen, the title in the native
13
- * header, a draft per signed-in user and the offline outbox. Open it with a link to fill in the
14
- * gym: `genesis-starter://check-in?gym=hilltop`.
15
- */
16
- export default function CheckInScreen() {
17
- const params = useLocalSearchParams<{ gym?: string }>();
18
- const { session } = useSession<Session>();
19
- const draft = useFormDraft(checkInForm, {
20
- store: checkInDrafts,
21
- respondent: session?.user.id ?? "signed-out",
22
- hostOptions: checkInHostOptions,
23
- linkParams: params.gym ? { gym: params.gym } : undefined,
24
- });
25
- if (!starter.features.checkIn) return <Redirect href="/" />;
26
- return (
27
- <ScreenContainer testID="check-in">
28
- <FormFocus
29
- draft={draft}
30
- outbox={checkInOutbox}
31
- createKey={checkInKey}
32
- haptics={checkInHaptics}
33
- photos={checkInPhotos}
34
- screen={Stack.Screen}
35
- headerOptions={{ headerBackTitle: copy.home.title }}
36
- testID="check-in-form"
37
- slotProps={{ ending: { actions: <Button onPress={() => router.back()} testID="check-in-done">{copy.checkIn.done}</Button> } }}
38
- />
39
- </ScreenContainer>
40
- );
4
+ /** The check-in from Home (and its link, `genesis-starter://check-in?gym=hilltop`). */
5
+ export default function HomeCheckIn() {
6
+ return <CheckInScreen backTitle={copy.home.title} />;
41
7
  }