@marktiderman/genesis-cli 1.20.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.
- package/README.md +28 -0
- package/dist/cli.js +89 -2
- package/dist/cli.js.map +1 -1
- package/dist/doctor.js +34 -0
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +83 -14
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/starter/README.md +8 -5
- package/dist/starter/__tests__/components/setup.ts +11 -0
- package/dist/starter/__tests__/starter.test.ts +19 -0
- package/dist/starter/package.json +4 -3
- package/dist/starter/src/lib/app.ts +13 -5
- package/dist/starter/src/lib/define-starter.ts +1 -1
- package/dist/starter/src/lib/devtools-overlay.ts +3 -4
- package/dist/starter/src/lib/native-modules.ts +5 -1
- package/dist/starter/src/lib/offline.ts +14 -0
- package/dist/starter/supabase/migrations/20261024000750_support_default_tenant.sql +18 -0
- package/dist/starter/supabase/migrations/20261024000800_genesis_support_tickets.sql +800 -0
- package/dist/starter/supabase/migrations/20261025000070_starter_tenancy.sql +26 -0
- package/dist/starter/supabase/migrations/20261025000080_genesis_chat_tenants.sql +716 -0
- package/dist/starter/supabase/tests/database/chat_people.test.sql +1 -1
- package/dist/starter/supabase/tests/database/genesis_chat.test.sql +10 -2
- package/dist/starter/supabase/tests/database/genesis_chat_coaching.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_tenants.test.sql +259 -0
- package/dist/starter/supabase/tests/database/genesis_support.test.sql +15 -3
- package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +10 -0
- package/dist/starter/supabase/tests/database/genesis_support_tickets.test.sql +327 -0
- package/dist/starter/supabase/tests/database/starter_tenancy.test.sql +19 -0
- package/dist/vite.js +34 -0
- package/dist/vite.js.map +1 -1
- package/package.json +2 -2
package/dist/starter/README.md
CHANGED
|
@@ -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 `
|
|
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
|
|
182
|
-
`20261025000050_genesis_chat_coaching.sql`
|
|
183
|
-
|
|
184
|
-
|
|
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.
|
|
@@ -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");
|
|
@@ -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.
|
|
41
|
-
"@tanstack/query-persist-client-core": "5.
|
|
42
|
-
"@tanstack/react-query": "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",
|
|
@@ -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 {
|
|
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
|
-
/**
|
|
29
|
-
|
|
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
|
-
?
|
|
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
|
-
/**
|
|
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
|
-
|
|
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)
|
|
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;
|