@marktiderman/genesis-cli 1.19.0 → 1.21.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 (42) hide show
  1. package/README.md +98 -1
  2. package/dist/cli.js +682 -74
  3. package/dist/cli.js.map +1 -1
  4. package/dist/doctor.d.ts +1 -1
  5. package/dist/doctor.js +270 -8
  6. package/dist/doctor.js.map +1 -1
  7. package/dist/eslint.cjs +99 -0
  8. package/dist/eslint.cjs.map +1 -0
  9. package/dist/eslint.d.cts +68 -0
  10. package/dist/eslint.d.ts +68 -0
  11. package/dist/eslint.js +72 -0
  12. package/dist/eslint.js.map +1 -0
  13. package/dist/genesis-catalog.json +86 -14
  14. package/dist/index.js +278 -16
  15. package/dist/index.js.map +1 -1
  16. package/dist/starter/README.md +17 -5
  17. package/dist/starter/__tests__/components/setup.ts +11 -0
  18. package/dist/starter/__tests__/starter.test.ts +19 -0
  19. package/dist/starter/eslint.config.js +8 -1
  20. package/dist/starter/nativewind-env.d.ts +1 -0
  21. package/dist/starter/package.json +5 -3
  22. package/dist/starter/src/lib/app.ts +13 -5
  23. package/dist/starter/src/lib/define-starter.ts +1 -1
  24. package/dist/starter/src/lib/devtools-overlay.ts +3 -4
  25. package/dist/starter/src/lib/native-modules.ts +5 -1
  26. package/dist/starter/src/lib/offline.ts +14 -0
  27. package/dist/starter/supabase/migrations/20261024000750_support_default_tenant.sql +18 -0
  28. package/dist/starter/supabase/migrations/20261024000800_genesis_support_tickets.sql +800 -0
  29. package/dist/starter/supabase/migrations/20261025000070_starter_tenancy.sql +26 -0
  30. package/dist/starter/supabase/migrations/20261025000080_genesis_chat_tenants.sql +716 -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_coaching.test.sql +8 -0
  34. package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +8 -0
  35. package/dist/starter/supabase/tests/database/genesis_chat_tenants.test.sql +259 -0
  36. package/dist/starter/supabase/tests/database/genesis_support.test.sql +15 -3
  37. package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +10 -0
  38. package/dist/starter/supabase/tests/database/genesis_support_tickets.test.sql +327 -0
  39. package/dist/starter/supabase/tests/database/starter_tenancy.test.sql +19 -0
  40. package/dist/vite.js +270 -8
  41. package/dist/vite.js.map +1 -1
  42. package/package.json +18 -4
@@ -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` and
183
+ `20261025000080_genesis_chat_tenants.sql` are genesis-chat's migrations 0001 to 0004 (topics,
184
+ scheduled send, availability, broadcast, search, link previews, moderation; every conversation in
185
+ a tenant), 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.
@@ -208,6 +211,15 @@ sign-in, the tabs, Settings and account deletion. Supabase is the fake in
208
211
  native modules use jest-expo's mocks or their library's own. A test fails when the app reports an
209
212
  error (`[push]`, `[updates]`, `[observability]`) or React warns about act(); see `reports.ts`.
210
213
  Add a screen's test there; tests that only read files stay in vitest, outside that folder.
214
+ In React Native Testing Library 14, `render`, `renderHook`, `fireEvent`, `act`, `rerender` and
215
+ `unmount` return promises: always `await` them, or the test reads a stale screen and React logs
216
+ "overlapping act() calls". `pnpm lint` catches a missed one in test files: `eslint.config.js`
217
+ spreads `genesis("native")` from `@marktiderman/genesis-cli/eslint`, which brings testing-library's
218
+ `await-async-events` and a `no-restricted-syntax` rule for the render calls, `act`, `rerender` and
219
+ `unmount` (it needs `eslint-plugin-testing-library` in devDependencies). The rules ship with the
220
+ CLI, so `genesis upgrade` brings new and changed ones without an edit here; a render helper of your
221
+ own goes in `genesis("native", { renders: ["renderWithStore"] })`. See the
222
+ [genesis-cli README](../../packages/genesis-cli/README.md#lint-rules).
211
223
 
212
224
  Gestures and animations run in these tests as they are written, on Gesture Handler's mocks
213
225
  (`react-native-gesture-handler/jestSetup.js`, in `jest.config.js`) and Reanimated's test mode
@@ -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,25 @@ 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 0003 and 0004 migrations and their pgTAP tests unchanged, with a single-tenant hook before 0004", () => {
411
+ const order = filesUnder("supabase/migrations").sort();
412
+ const search = order.filter((f) => f.endsWith("_genesis_chat_search_threads.sql"));
413
+ const tenants = order.filter((f) => f.endsWith("_genesis_chat_tenants.sql"));
414
+ const hook = order.filter((f) => f.endsWith("_starter_tenancy.sql"));
415
+ expect(search).toHaveLength(1);
416
+ expect(tenants).toHaveLength(1);
417
+ expect(hook).toHaveLength(1);
418
+ expect(read(search[0]!)).toBe(chatSql("0003_genesis_chat_search_threads.sql"));
419
+ expect(read("supabase/tests/database/genesis_chat_search_threads.test.sql")).toBe(chatSql("tests/0003_genesis_chat_search_threads.test.sql"));
420
+ expect(read(tenants[0]!)).toBe(chatSql("0004_genesis_chat_tenants.sql"));
421
+ expect(read("supabase/tests/database/genesis_chat_tenants.test.sql")).toBe(chatSql("tests/0004_genesis_chat_tenants.test.sql"));
422
+ // 0004 places every conversation in a tenant through the hook, so the hook comes first.
423
+ expect(order.indexOf(hook[0]!)).toBeLessThan(order.indexOf(tenants[0]!));
424
+ expect(order.indexOf(search[0]!)).toBeLessThan(order.indexOf(tenants[0]!));
425
+ expect(read(hook[0]!)).toContain("create or replace function private.genesis_viewer_people(viewer uuid)");
426
+ expect(read("supabase/tests/database/starter_tenancy.test.sql")).toContain("select plan(");
427
+ });
428
+
410
429
  it("puts one chat over every signed-in tab, with Availability under Settings and search and broadcast in Messages", () => {
411
430
  expect(read("src/app/(app)/_layout.tsx")).toContain("starter.features.chat ? <ChatRoot>{app}</ChatRoot> : app");
412
431
  expect(read("src/app/(app)/messages/_layout.tsx")).not.toContain("<ChatRoot");
@@ -1,5 +1,12 @@
1
1
  // https://docs.expo.dev/guides/using-eslint/
2
2
  const { defineConfig } = require("eslint/config");
3
3
  const expoConfig = require("eslint-config-expo/flat");
4
+ // Genesis's lint rules, shipped with the CLI so `genesis upgrade` brings new ones (React Native
5
+ // Testing Library 14's await rules today; they need eslint-plugin-testing-library).
6
+ const { genesis } = require("@marktiderman/genesis-cli/eslint");
4
7
 
5
- module.exports = defineConfig([expoConfig, { ignores: ["dist/*", ".expo/*", "supabase/functions/**"] }]);
8
+ module.exports = defineConfig([
9
+ expoConfig,
10
+ { ignores: ["dist/*", ".expo/*", "supabase/functions/**"] },
11
+ ...genesis("native"),
12
+ ]);
@@ -0,0 +1 @@
1
+ /// <reference types="nativewind/types" />
@@ -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",
@@ -94,6 +95,7 @@
94
95
  "babel-plugin-react-compiler": "^1.0.0",
95
96
  "eslint": "^9.0.0",
96
97
  "eslint-config-expo": "~58.0.4",
98
+ "eslint-plugin-testing-library": "^7.16.2",
97
99
  "jest": "~30.5.2",
98
100
  "jest-expo": "~58.0.12",
99
101
  "tailwindcss": "^3.4.17",
@@ -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,
@@ -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,7 +5,8 @@
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
12
  import DateTimePicker from "@expo/ui/community/datetime-picker";
@@ -14,6 +15,7 @@ import * as GlassEffect from "expo-glass-effect";
14
15
  import { Image } from "expo-image";
15
16
  import { DarkTheme, DefaultTheme, ThemeProvider } from "expo-router";
16
17
  import { SymbolView } from "expo-symbols";
18
+ import { KeyboardAvoidingView } from "react-native-keyboard-controller";
17
19
  import * as Reanimated from "react-native-reanimated";
18
20
  import type { GenesisModules } from "@marktiderman/genesis-ui-native";
19
21
  import { lucideIcons } from "@marktiderman/genesis-ui-native/icons/lucide";
@@ -28,4 +30,6 @@ export const nativeModules: GenesisModules = {
28
30
  icons: lucideIcons,
29
31
  datePicker: DateTimePicker as unknown as GenesisModules["datePicker"],
30
32
  navigation: { ThemeProvider, DefaultTheme, DarkTheme },
33
+ // ThreadPage's composer follows the keyboard frame by frame.
34
+ keyboardAvoidingView: KeyboardAvoidingView,
31
35
  };
@@ -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;