@marktiderman/genesis-cli 1.20.0 → 1.22.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 (43) hide show
  1. package/README.md +168 -9
  2. package/dist/cli.js +1114 -103
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{config-Dj_f9T7J.d.ts → config-HOmiOLQc.d.ts} +2 -0
  5. package/dist/doctor.d.ts +10 -5
  6. package/dist/doctor.js +1515 -1095
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/expo.d.ts +2 -2
  9. package/dist/expo.js +10 -0
  10. package/dist/expo.js.map +1 -1
  11. package/dist/genesis-catalog.json +140 -20
  12. package/dist/index.d.ts +114 -2
  13. package/dist/index.js +1538 -1099
  14. package/dist/index.js.map +1 -1
  15. package/dist/starter/README.md +8 -5
  16. package/dist/starter/__tests__/components/setup.ts +11 -0
  17. package/dist/starter/__tests__/starter.test.ts +28 -0
  18. package/dist/starter/package.json +4 -3
  19. package/dist/starter/pnpm-workspace.yaml +22 -0
  20. package/dist/starter/src/lib/app.ts +13 -5
  21. package/dist/starter/src/lib/check-in.ts +5 -3
  22. package/dist/starter/src/lib/define-starter.ts +1 -1
  23. package/dist/starter/src/lib/devtools-overlay.ts +3 -4
  24. package/dist/starter/src/lib/native-modules.ts +9 -2
  25. package/dist/starter/src/lib/offline.ts +14 -0
  26. package/dist/starter/supabase/migrations/20261024000750_support_default_tenant.sql +18 -0
  27. package/dist/starter/supabase/migrations/20261024000800_genesis_support_tickets.sql +800 -0
  28. package/dist/starter/supabase/migrations/20261025000070_starter_tenancy.sql +26 -0
  29. package/dist/starter/supabase/migrations/20261025000080_genesis_chat_tenants.sql +716 -0
  30. package/dist/starter/supabase/migrations/20261025000090_genesis_chat_attachment_paths.sql +80 -0
  31. package/dist/starter/supabase/tests/database/chat_people.test.sql +1 -1
  32. package/dist/starter/supabase/tests/database/genesis_chat.test.sql +10 -2
  33. package/dist/starter/supabase/tests/database/genesis_chat_attachment_paths.test.sql +111 -0
  34. package/dist/starter/supabase/tests/database/genesis_chat_coaching.test.sql +8 -0
  35. package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +8 -0
  36. package/dist/starter/supabase/tests/database/genesis_chat_tenants.test.sql +259 -0
  37. package/dist/starter/supabase/tests/database/genesis_support.test.sql +15 -3
  38. package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +10 -0
  39. package/dist/starter/supabase/tests/database/genesis_support_tickets.test.sql +327 -0
  40. package/dist/starter/supabase/tests/database/starter_tenancy.test.sql +19 -0
  41. package/dist/vite.js +1514 -1094
  42. package/dist/vite.js.map +1 -1
  43. package/package.json +3 -3
@@ -68,7 +68,7 @@ Each line of `features` in `starter.config.ts` is one feature, `true` by default
68
68
  | `googleSignIn` | Native Google sign-in (`signInWithGoogle`, `googleProvider`). **Off by default**: it needs client ids and setup, see [Google sign-in](#google-sign-in). Needs `appleSignIn` on. | No Google button. |
69
69
  | `accountDeletion` | "Delete account" in Settings (`deleteMyAccount`). | No delete row. App Review requires it for apps with accounts. |
70
70
  | `notifications` | The Notifications tab (`NotificationsPage`). | The tab is hidden, its route redirects home and links to it open `/`. Drop `/notifications` from `links.paths` in `genesis.config.json` too. |
71
- | `queryPersistence` | The `persistedQueryKeys` queries (`src/lib/app.ts`) saved to the phone for 24 hours, per user. | Cache in memory only. |
71
+ | `queryPersistence` | The `persistedResources` reads (`src/lib/app.ts`) kept on the phone in SQLite for 7 days, per user, so their lists and records open at once. | Cache in memory only. |
72
72
  | `queryLifecycle` | Refetch when the app comes to the front; follow the network (AppState + NetInfo). | Queries refetch only on mount. |
73
73
  | `keyboardScroll` | The focused field stays above the keyboard on form screens, with the previous / next / done bar (`KeyboardToolbar`) above it. | `KeyboardAvoidingView` fallback, no bar. |
74
74
  | `deepLinks` | `scheme://` and universal links open their screen, after sign-in if needed (`normalizeLink`). | Every link opens `/`. Universal links still open the app until you also delete the `links` block in `genesis.config.json`. |
@@ -178,10 +178,13 @@ manifest for the packages installed, export compliance and the fingerprint runti
178
178
  has an example). To get an issue or a webhook per report, or to remove deleted screenshots from
179
179
  storage, copy the `genesis-support-notify` and `genesis-support-cleanup` templates: see "Support"
180
180
  in [`@marktiderman/genesis-supabase`](../../packages/supabase/README.md#support-the-support-block).
181
- - **Chat:** `supabase/migrations/20261025000000_genesis_chat.sql` and
182
- `20261025000050_genesis_chat_coaching.sql` are genesis-chat's migrations 0001 and 0002 (topics,
183
- scheduled send, availability, broadcast, search, link previews, moderation), copied and
184
- drift-tested the same way. Scheduled messages, link previews, moderation and chat pushes are
181
+ - **Chat:** `supabase/migrations/20261025000000_genesis_chat.sql`,
182
+ `20261025000050_genesis_chat_coaching.sql`, `20261025000060_genesis_chat_search_threads.sql`,
183
+ `20261025000080_genesis_chat_tenants.sql` and `20261025000090_genesis_chat_attachment_paths.sql`
184
+ are genesis-chat's migrations 0001 to 0005 (topics, scheduled send, availability, broadcast,
185
+ search, link previews, moderation; every conversation in a tenant; tightened attachment paths), copied and drift-tested the same way. The starter is single-tenant:
186
+ `20261025000070_starter_tenancy.sql` puts every login in one tenant
187
+ (`private.genesis_viewer_people`); replace it when you add organizations. Scheduled messages, link previews, moderation and chat pushes are
185
188
  worked by genesis-chat's runner (`createChatRunner` from `@marktiderman/genesis-chat/server`),
186
189
  which the starter doesn't deploy: until you run it on a schedule, a scheduled message waits in
187
190
  its thread's Scheduled list.
@@ -50,6 +50,17 @@ jest.mock("expo-notifications", () => {
50
50
  };
51
51
  });
52
52
  // jest-expo's expo-updates mock answers `checkForUpdateAsync` with nothing; the server has no update.
53
+ // expo-sqlite's native module isn't in Jest: an empty database for the device cache, which
54
+ // starts every test with nothing kept (as a fresh install does).
55
+ jest.mock("expo-sqlite", () => {
56
+ const db = {
57
+ execAsync: async () => undefined,
58
+ runAsync: async () => ({ changes: 0, lastInsertRowId: 0 }),
59
+ getAllAsync: async () => [],
60
+ withExclusiveTransactionAsync: async (task: (txn: unknown) => Promise<void>) => task(db),
61
+ };
62
+ return { openDatabaseSync: () => db };
63
+ });
53
64
  jest.mock("expo-updates", () => ({
54
65
  ...jest.requireActual<object>("expo-updates"),
55
66
  checkForUpdateAsync: async () => ({ isAvailable: false, isRollBackToEmbedded: false }),
@@ -407,6 +407,34 @@ describe("chat", () => {
407
407
  expect(order.indexOf(copies[0]!)).toBe(order.findIndex((f) => f.endsWith("_genesis_chat.sql")) + 1);
408
408
  });
409
409
 
410
+ it.runIf(chat && database)("carries chat's 0005 migration and its pgTAP test unchanged, after 0004", () => {
411
+ const order = filesUnder("supabase/migrations").sort();
412
+ const paths = order.filter((f) => f.endsWith("_genesis_chat_attachment_paths.sql"));
413
+ expect(paths).toHaveLength(1);
414
+ expect(read(paths[0]!)).toBe(chatSql("0005_genesis_chat_attachment_paths.sql"));
415
+ expect(read("supabase/tests/database/genesis_chat_attachment_paths.test.sql")).toBe(chatSql("tests/0005_genesis_chat_attachment_paths.test.sql"));
416
+ expect(order.indexOf(paths[0]!)).toBeGreaterThan(order.findIndex((f) => f.endsWith("_genesis_chat_tenants.sql")));
417
+ });
418
+
419
+ it.runIf(chat && database)("carries chat's 0003 and 0004 migrations and their pgTAP tests unchanged, with a single-tenant hook before 0004", () => {
420
+ const order = filesUnder("supabase/migrations").sort();
421
+ const search = order.filter((f) => f.endsWith("_genesis_chat_search_threads.sql"));
422
+ const tenants = order.filter((f) => f.endsWith("_genesis_chat_tenants.sql"));
423
+ const hook = order.filter((f) => f.endsWith("_starter_tenancy.sql"));
424
+ expect(search).toHaveLength(1);
425
+ expect(tenants).toHaveLength(1);
426
+ expect(hook).toHaveLength(1);
427
+ expect(read(search[0]!)).toBe(chatSql("0003_genesis_chat_search_threads.sql"));
428
+ expect(read("supabase/tests/database/genesis_chat_search_threads.test.sql")).toBe(chatSql("tests/0003_genesis_chat_search_threads.test.sql"));
429
+ expect(read(tenants[0]!)).toBe(chatSql("0004_genesis_chat_tenants.sql"));
430
+ expect(read("supabase/tests/database/genesis_chat_tenants.test.sql")).toBe(chatSql("tests/0004_genesis_chat_tenants.test.sql"));
431
+ // 0004 places every conversation in a tenant through the hook, so the hook comes first.
432
+ expect(order.indexOf(hook[0]!)).toBeLessThan(order.indexOf(tenants[0]!));
433
+ expect(order.indexOf(search[0]!)).toBeLessThan(order.indexOf(tenants[0]!));
434
+ expect(read(hook[0]!)).toContain("create or replace function private.genesis_viewer_people(viewer uuid)");
435
+ expect(read("supabase/tests/database/starter_tenancy.test.sql")).toContain("select plan(");
436
+ });
437
+
410
438
  it("puts one chat over every signed-in tab, with Availability under Settings and search and broadcast in Messages", () => {
411
439
  expect(read("src/app/(app)/_layout.tsx")).toContain("starter.features.chat ? <ChatRoot>{app}</ChatRoot> : app");
412
440
  expect(read("src/app/(app)/messages/_layout.tsx")).not.toContain("<ChatRoot");
@@ -37,9 +37,9 @@
37
37
  "@sentry/react-native": "~8.32.0",
38
38
  "@shopify/flash-list": "2.3.3",
39
39
  "@supabase/supabase-js": "^2.118.0",
40
- "@tanstack/query-async-storage-persister": "5.104.5",
41
- "@tanstack/query-persist-client-core": "5.104.5",
42
- "@tanstack/react-query": "5.104.5",
40
+ "@tanstack/query-async-storage-persister": "5.105.0",
41
+ "@tanstack/query-persist-client-core": "5.105.0",
42
+ "@tanstack/react-query": "5.105.0",
43
43
  "clsx": "^2.1.1",
44
44
  "expo": "~58.0.19",
45
45
  "expo-apple-authentication": "~58.0.2",
@@ -61,6 +61,7 @@
61
61
  "expo-sensors": "~58.0.4",
62
62
  "expo-sharing": "~58.0.20",
63
63
  "expo-splash-screen": "~58.0.11",
64
+ "expo-sqlite": "~58.0.14",
64
65
  "expo-status-bar": "~58.0.4",
65
66
  "expo-symbols": "~58.0.4",
66
67
  "expo-updates": "~58.0.18",
@@ -62,6 +62,28 @@ overrides:
62
62
  react-dom: 19.3.0
63
63
  "@types/react": 19.3.0
64
64
  react-native: 0.88.0
65
+ # Security floors for transitive dependencies (Dependabot). Each dependent's own range would
66
+ # hold the vulnerable version, or a fresh lockfile could fall back to it. A range-keyed override
67
+ # touches only the versions below the fix. Overrides apply at the workspace root only: a package
68
+ # consumer doesn't get them, but `genesis init` copies this block into a new native app's
69
+ # settings, where the same floors are just as welcome. Drop an entry when its dependents' own
70
+ # ranges exclude the vulnerable versions.
71
+ "@xmldom/xmldom@<0.8.15": ^0.8.15
72
+ "@xmldom/xmldom@>=0.9.0 <0.9.12": ^0.9.12
73
+ "brace-expansion@<1.1.21": ^1.1.21
74
+ "brace-expansion@>=2.0.0 <2.1.7": ^2.1.7
75
+ "brace-expansion@>=4.0.0 <5.0.12": ^5.0.12
76
+ "esbuild@>=0.27.3 <0.28.1": ^0.28.2
77
+ "fast-uri@>=3.0.0 <3.1.9": ^3.1.9
78
+ # glob 7 is not affected. 14 is a major, and the only change the dependents see is the fix.
79
+ "glob@>=9.0.0 <14.0.2": ^14.0.3
80
+ # @tiptap/html and @puckeditor/core ask for ^20; the fix only exists on 21.
81
+ "happy-dom@<21.0.4": ^21.0.4
82
+ "js-yaml@>=3.0.0 <3.15.2": ^3.15.2
83
+ "js-yaml@>=4.0.0 <4.3.2": ^4.3.2
84
+ "morgan@<1.12.1": ^1.12.1
85
+ # xcode only calls uuid.v4(), so the v3/v5/v6 flaw never ran; 11.1.1 is the first fixed version.
86
+ "uuid@<11.1.1": ^11.1.1
65
87
 
66
88
  patchedDependencies:
67
89
  # tsup 8.5.1's declaration build forces `baseUrl: "."` into the compiler options, and TypeScript 6
@@ -4,7 +4,6 @@
4
4
  */
5
5
  // First: Sentry starts here, before the rest of the app loads.
6
6
  import { observability } from "./observability";
7
- import AsyncStorage from "@react-native-async-storage/async-storage";
8
7
  import NetInfo from "@react-native-community/netinfo";
9
8
  import Constants from "expo-constants";
10
9
  import { router, type Href } from "expo-router";
@@ -12,11 +11,12 @@ import { AppState } from "react-native";
12
11
  import { KeyboardAwareScrollView, KeyboardProvider, KeyboardToolbar } from "react-native-keyboard-controller";
13
12
  import { genesisBrand } from "@marktiderman/genesis-design-system";
14
13
  import type { GenesisNativeAppProps } from "@marktiderman/genesis-native";
15
- import { persistQueries } from "@marktiderman/genesis-native/persist";
14
+ import { persistOffline } from "@marktiderman/genesis-native/offline";
16
15
  import starter from "../../starter.config";
17
16
  import { assertEnv } from "./env";
18
17
  import { linkHold } from "./links";
19
18
  import { nativeModules } from "./native-modules";
19
+ import { offlineCache } from "./offline";
20
20
  import { sessionReady, supabase } from "./supabase";
21
21
  import { devtools } from "./devtools";
22
22
  import { createStarterPush } from "./push";
@@ -25,8 +25,12 @@ import { updatesBlock } from "./updates";
25
25
 
26
26
  const { features } = starter;
27
27
 
28
- /** The query-key roots saved to the phone when `queryPersistence` is on. Add yours: `["me", "projects"]`. */
29
- export const persistedQueryKeys = ["me"] as const;
28
+ /**
29
+ * The resources whose reads are kept on the phone when `queryPersistence` is on, so their lists
30
+ * and records open at once. The starter has no resource lists yet, so nothing is kept: add yours
31
+ * (`["projects"]`) as you add their views. Only what may sit on a phone unencrypted.
32
+ */
33
+ export const persistedResources: readonly string[] = [];
30
34
 
31
35
  export const shell: Omit<GenesisNativeAppProps, "children" | "splash"> = {
32
36
  brand: genesisBrand,
@@ -36,7 +40,11 @@ export const shell: Omit<GenesisNativeAppProps, "children" | "splash"> = {
36
40
  { id: "starter:session-storage", run: sessionReady },
37
41
  ],
38
42
  persist: features.queryPersistence
39
- ? persistQueries({ storage: AsyncStorage, keys: persistedQueryKeys, buster: Constants.expoConfig?.version ?? "0" })
43
+ ? persistOffline({
44
+ cache: offlineCache(),
45
+ resources: persistedResources,
46
+ buster: Constants.expoConfig?.version ?? "0",
47
+ })
40
48
  : undefined,
41
49
  lifecycle: features.queryLifecycle ? { appState: AppState, netInfo: NetInfo } : undefined,
42
50
  keyboardProvider: features.keyboardScroll ? KeyboardProvider : undefined,
@@ -13,6 +13,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
13
13
  import NetInfo from "@react-native-community/netinfo";
14
14
  import * as Crypto from "expo-crypto";
15
15
  import * as Haptics from "expo-haptics";
16
+ import { playHaptic, type GenesisHapticsModule } from "@marktiderman/genesis-ui-native/hooks";
16
17
  import * as ImagePicker from "expo-image-picker";
17
18
  import {
18
19
  createDraftStore,
@@ -78,8 +79,9 @@ NetInfo.addEventListener((state) => checkInOutbox.setOnline(state.isConnected !=
78
79
  export const checkInPhotos = createCheckInPhotos(ImagePicker.launchImageLibraryAsync as LaunchLibrary, stubUpload(Crypto.randomUUID));
79
80
 
80
81
  /** A pick, a sent check-in and a refused step, felt. */
82
+ const haptics = Haptics as unknown as GenesisHapticsModule;
81
83
  export const checkInHaptics: FormHaptics = {
82
- selection: () => void Haptics.selectionAsync(),
83
- success: () => void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success),
84
- error: () => void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error),
84
+ selection: () => playHaptic(haptics, "select"),
85
+ success: () => playHaptic(haptics, "success"),
86
+ error: () => playHaptic(haptics, "error"),
85
87
  };
@@ -38,7 +38,7 @@ export interface StarterFeatures {
38
38
  accountDeletion: boolean;
39
39
  /** The Notifications tab (`NotificationsPage`). */
40
40
  notifications: boolean;
41
- /** Save the listed queries to the phone for 24 hours, per user (`persistQueries`). */
41
+ /** Keep the listed resources' reads on the phone, per user, so they open at once (`persistOffline` + `sqliteLocalCache`). */
42
42
  queryPersistence: boolean;
43
43
  /** Refetch when the app comes to the front and follow the network (`lifecycle`: AppState + NetInfo). */
44
44
  queryLifecycle: boolean;
@@ -4,11 +4,11 @@
4
4
  * with a three-finger hold, "Open devtools" in the dev menu, or Settings >
5
5
  * About > Developer tools.
6
6
  */
7
- import AsyncStorage from "@react-native-async-storage/async-storage";
8
7
  import * as Application from "expo-application";
9
8
  import { DevSettings } from "react-native";
10
9
  import { createDevtools } from "@marktiderman/genesis-native/devtools";
11
10
  import starter from "../../starter.config";
11
+ import { offlineCache } from "./offline";
12
12
  import { env } from "./env";
13
13
  import { observability } from "./observability";
14
14
  import { supabase } from "./supabase";
@@ -17,8 +17,6 @@ import { updatesBlock } from "./updates";
17
17
  /** The variants (withGenesis bundle id suffixes) that may open the overlay. */
18
18
  const TEST_BUILD = /\.(dev|preview)$/;
19
19
 
20
- /** The persisted query cache's key (`persistQueries`' default). */
21
- const QUERY_CACHE_KEY = "genesis-query-cache";
22
20
 
23
21
  export function createStarterDevtools() {
24
22
  return createDevtools({
@@ -28,7 +26,8 @@ export function createStarterDevtools() {
28
26
  baseUrl: env.supabaseUrl,
29
27
  flags: starter.features,
30
28
  devSettings: __DEV__ ? DevSettings : undefined,
31
- clearCache: () => AsyncStorage.removeItem(QUERY_CACHE_KEY),
29
+ // The device cache (`persistOffline`'s, in app.ts), every person's.
30
+ clearCache: () => offlineCache().clear(),
32
31
  signOut: () => supabase.auth.signOut(),
33
32
  });
34
33
  }
@@ -5,15 +5,18 @@
5
5
  * surfaces on iOS 26, SF Symbols on iOS with lucide everywhere else, and the
6
6
  * @expo/ui (SwiftUI / Jetpack Compose) date picker, and React Navigation's
7
7
  * theming (GenesisNativeApp themes headers and tab bars in the brand's light
8
- * and dark colors). To fall back to plain
8
+ * and dark colors), and keyboard-controller's KeyboardAvoidingView for
9
+ * ThreadPage's composer. To fall back to plain
9
10
  * React Native for one, delete its line, its import below and its package.
10
11
  */
11
- import DateTimePicker from "@expo/ui/community/datetime-picker";
12
+ import { DateTimePicker } from "@expo/ui/community/datetime-picker";
12
13
  import { FlashList } from "@shopify/flash-list";
13
14
  import * as GlassEffect from "expo-glass-effect";
15
+ import * as Haptics from "expo-haptics";
14
16
  import { Image } from "expo-image";
15
17
  import { DarkTheme, DefaultTheme, ThemeProvider } from "expo-router";
16
18
  import { SymbolView } from "expo-symbols";
19
+ import { KeyboardAvoidingView } from "react-native-keyboard-controller";
17
20
  import * as Reanimated from "react-native-reanimated";
18
21
  import type { GenesisModules } from "@marktiderman/genesis-ui-native";
19
22
  import { lucideIcons } from "@marktiderman/genesis-ui-native/icons/lucide";
@@ -28,4 +31,8 @@ export const nativeModules: GenesisModules = {
28
31
  icons: lucideIcons,
29
32
  datePicker: DateTimePicker as unknown as GenesisModules["datePicker"],
30
33
  navigation: { ThemeProvider, DefaultTheme, DarkTheme },
34
+ // ThreadPage's composer follows the keyboard frame by frame.
35
+ keyboardAvoidingView: KeyboardAvoidingView,
36
+ // expo-haptics, once: useHaptics(), playHaptic and NativeButton's `haptic` play through it.
37
+ haptics: Haptics as unknown as GenesisModules["haptics"],
31
38
  };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The phone's device cache (`queryPersistence`): reads kept in SQLite so lists and records open at
3
+ * once. One database, opened on first use; app.ts hands it to `persistOffline`, and the devtools
4
+ * overlay's "Clear cache" empties it.
5
+ */
6
+ import * as SQLite from "expo-sqlite";
7
+ import { sqliteLocalCache, type LocalCache } from "@marktiderman/genesis-native/offline";
8
+
9
+ let cache: LocalCache | undefined;
10
+
11
+ export function offlineCache(): LocalCache {
12
+ cache ??= sqliteLocalCache({ db: SQLite.openDatabaseSync("genesis-offline.db") });
13
+ return cache;
14
+ }
@@ -0,0 +1,18 @@
1
+ -- @feat:support-feedback
2
+ -- This app's own tenant, for genesis-support (needed before 0004_genesis_support_tickets.sql).
3
+ --
4
+ -- The starter is a single-tenant app: every ticket and idea belongs to this one tenant, and your
5
+ -- support staff (private.genesis_support_staff) handle them. A multi-tenant app returns its own
6
+ -- organization's id here instead, and lists its tenants in private.genesis_viewer_people.
7
+ create schema if not exists private;
8
+
9
+ create or replace function private.genesis_support_default_tenant()
10
+ returns uuid
11
+ language sql
12
+ stable
13
+ set search_path = ''
14
+ as $$
15
+ select '00000000-0000-4000-8000-0000000000a1'::uuid
16
+ $$;
17
+
18
+ revoke execute on function private.genesis_support_default_tenant() from public, anon, authenticated;