@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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "packages": {
3
3
  "@marktiderman/genesis-ai": {
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "blocks": {
6
6
  "ai-providers": {
7
7
  "feature": {
@@ -35,7 +35,7 @@
35
35
  "version": "0.1.2"
36
36
  },
37
37
  "@marktiderman/genesis-chat": {
38
- "version": "0.7.0",
38
+ "version": "0.10.0",
39
39
  "blocks": {
40
40
  "chat": {
41
41
  "feature": {
@@ -73,12 +73,27 @@
73
73
  {
74
74
  "file": "migrations/0003_genesis_chat_search_threads.sql",
75
75
  "test": "migrations/tests/0003_genesis_chat_search_threads.test.sql"
76
+ },
77
+ {
78
+ "file": "migrations/0004_genesis_chat_tenants.sql",
79
+ "test": "migrations/tests/0004_genesis_chat_tenants.test.sql",
80
+ "needs": [
81
+ {
82
+ "function": "private.genesis_viewer_people",
83
+ "how": "every conversation is in a tenant from chat 0004. Add a migration before it that defines private.genesis_viewer_people(viewer uuid) returns table (tenant_id uuid, person_id uuid): one row per tenant the login is in (a single-tenant app returns its one tenant id; a personal record's tenant can be its own id). See genesis-supabase 0016's header."
84
+ }
85
+ ]
86
+ },
87
+ {
88
+ "file": "migrations/0005_genesis_chat_attachment_paths.sql",
89
+ "test": "migrations/tests/0005_genesis_chat_attachment_paths.test.sql"
76
90
  }
77
91
  ],
78
92
  "install": [
79
93
  "@supabase/supabase-js@^2.118.0"
80
94
  ],
81
95
  "steps": [
96
+ "Say who belongs to which tenant: private.genesis_viewer_people(viewer uuid) returns table (tenant_id uuid, person_id uuid), the hook genesis-supabase's 0016 documents (a single-tenant app returns its one tenant). Every conversation belongs to a tenant from migration 0004.",
82
97
  "Expose the genesis_chat schema to the API: add it to `schemas` under [api] in supabase/config.toml, and to Exposed schemas in the dashboard.",
83
98
  "Register your kinds' rules in a migration of your own, after this one: a start check for direct (who may message whom) and any kinds of your own, with an observer check where staff read without being members (genesis-chat README, Kinds and rules).",
84
99
  "Run the outbox: call createChatRunner from @marktiderman/genesis-chat/server on a schedule (every minute) or from a database webhook on genesis_chat.effects, with your push sender."
@@ -93,19 +108,19 @@
93
108
  "version": "0.3.0"
94
109
  },
95
110
  "@marktiderman/genesis-core": {
96
- "version": "2.10.0"
111
+ "version": "2.13.0"
97
112
  },
98
113
  "@marktiderman/genesis-design-system": {
99
- "version": "1.7.0"
114
+ "version": "1.9.0"
100
115
  },
101
116
  "@marktiderman/genesis-extension": {
102
117
  "version": "0.2.2"
103
118
  },
104
119
  "@marktiderman/genesis-features": {
105
- "version": "0.8.1"
120
+ "version": "0.8.2"
106
121
  },
107
122
  "@marktiderman/genesis-forms": {
108
- "version": "0.11.0"
123
+ "version": "0.11.1"
109
124
  },
110
125
  "@marktiderman/genesis-forms-builder": {
111
126
  "version": "0.6.6"
@@ -114,7 +129,7 @@
114
129
  "version": "0.1.4"
115
130
  },
116
131
  "@marktiderman/genesis-forms-native": {
117
- "version": "0.2.3"
132
+ "version": "0.3.0"
118
133
  },
119
134
  "@marktiderman/genesis-forms-react": {
120
135
  "version": "0.3.3"
@@ -123,19 +138,19 @@
123
138
  "version": "0.6.3"
124
139
  },
125
140
  "@marktiderman/genesis-forms-web": {
126
- "version": "0.7.0"
141
+ "version": "0.8.0"
127
142
  },
128
143
  "@marktiderman/genesis": {
129
- "version": "0.10.14"
144
+ "version": "0.10.18"
130
145
  },
131
146
  "@marktiderman/genesis-cli": {
132
- "version": "1.20.0"
147
+ "version": "1.22.0"
133
148
  },
134
149
  "@marktiderman/genesis-media": {
135
150
  "version": "0.2.0"
136
151
  },
137
152
  "@marktiderman/genesis-native": {
138
- "version": "0.8.0",
153
+ "version": "0.10.0",
139
154
  "blocks": {
140
155
  "push": {
141
156
  "feature": {
@@ -378,7 +393,7 @@
378
393
  }
379
394
  },
380
395
  "@marktiderman/genesis-product": {
381
- "version": "0.1.0",
396
+ "version": "0.2.0",
382
397
  "blocks": {
383
398
  "product-board": {
384
399
  "feature": {
@@ -408,7 +423,7 @@
408
423
  }
409
424
  },
410
425
  "@marktiderman/genesis-sites": {
411
- "version": "0.5.2",
426
+ "version": "0.6.0",
412
427
  "blocks": {
413
428
  "sites": {
414
429
  "feature": {
@@ -452,13 +467,13 @@
452
467
  }
453
468
  },
454
469
  "@marktiderman/genesis-studio": {
455
- "version": "0.2.8"
470
+ "version": "0.4.0"
456
471
  },
457
472
  "@marktiderman/genesis-studio-server": {
458
473
  "version": "0.5.3"
459
474
  },
460
475
  "@marktiderman/genesis-supabase": {
461
- "version": "0.13.0",
476
+ "version": "0.14.1",
462
477
  "blocks": {
463
478
  "account": {
464
479
  "feature": {
@@ -663,11 +678,41 @@
663
678
  "web",
664
679
  "native"
665
680
  ]
681
+ },
682
+ "versioned-writes": {
683
+ "feature": {
684
+ "name": "Versioned writes",
685
+ "summary": "A trigger that advances a row's version on every update, so the Supabase data provider refuses an edit made on a stale copy as a conflict instead of overwriting someone else's.",
686
+ "keywords": [
687
+ "optimistic concurrency",
688
+ "version",
689
+ "conflict",
690
+ "lost update",
691
+ "offline"
692
+ ],
693
+ "audience": [
694
+ "developer"
695
+ ]
696
+ },
697
+ "platforms": [
698
+ "web",
699
+ "native"
700
+ ],
701
+ "migrations": [
702
+ {
703
+ "file": "migrations/0019_genesis_version_bump.sql",
704
+ "test": "migrations/tests/0019_genesis_version_bump.test.sql"
705
+ }
706
+ ],
707
+ "steps": [
708
+ "For each table to check: add `version bigint not null default 1` and `create trigger <table>_version_bump before update on <table> for each row execute function public.genesis_version_bump('version')`.",
709
+ "Give the resource a version rule in createSupabaseProvider: `resources: { tasks: { version: { field: \"version\", kind: \"integer\" } } }`. The Genesis write hooks then send the version they read, and a stale edit comes back as a conflict."
710
+ ]
666
711
  }
667
712
  }
668
713
  },
669
714
  "@marktiderman/genesis-support": {
670
- "version": "0.4.0",
715
+ "version": "0.6.0",
671
716
  "blocks": {
672
717
  "support-feedback": {
673
718
  "feature": {
@@ -709,6 +754,20 @@
709
754
  {
710
755
  "file": "migrations/0003_genesis_support_findings.sql",
711
756
  "test": "migrations/tests/0003_genesis_support_findings.test.sql"
757
+ },
758
+ {
759
+ "file": "migrations/0004_genesis_support_tickets.sql",
760
+ "test": "migrations/tests/0004_genesis_support_tickets.test.sql",
761
+ "needs": [
762
+ {
763
+ "function": "private.genesis_support_default_tenant",
764
+ "how": "tickets have a tenant from support 0004. Add a migration before it that defines private.genesis_support_default_tenant() returns uuid: your own tenant, where your own support lives (a single-tenant app returns its one tenant id). See 0004's header."
765
+ },
766
+ {
767
+ "function": "private.genesis_viewer_people",
768
+ "how": "a ticket's agents and the tenants a sender may write to come from it. Add a migration before support 0004 that defines private.genesis_viewer_people(viewer uuid) returns table (tenant_id uuid, person_id uuid). See genesis-supabase 0016's header."
769
+ }
770
+ ]
712
771
  }
713
772
  ],
714
773
  "functions": [
@@ -847,17 +906,74 @@
847
906
  ],
848
907
  "migrations": [
849
908
  {
850
- "file": "migrations/0001_genesis_support_chat.sql",
909
+ "file": "migrations/0005_genesis_support_chat_on_tickets.sql",
851
910
  "test": "migrations/tests/0001_genesis_support_chat.test.sql"
911
+ },
912
+ {
913
+ "file": "migrations/0006_genesis_support_chat_tenants.sql",
914
+ "test": "migrations/tests/0006_genesis_support_chat_tenants.test.sql",
915
+ "runsBefore": [
916
+ {
917
+ "package": "@marktiderman/genesis-chat",
918
+ "file": "migrations/0004_genesis_chat_tenants.sql"
919
+ }
920
+ ]
921
+ },
922
+ {
923
+ "file": "migrations/0009_genesis_support_inbox.sql",
924
+ "test": "migrations/tests/0009_genesis_support_inbox.test.sql"
852
925
  }
853
926
  ],
854
927
  "steps": [
855
928
  "Apply this block's migration after 0006_genesis_support.sql and genesis-chat's 0001 and 0002 (genesis add support-chat orders them). It gives every existing report its conversation and copies support_replies into it, with no push.",
856
929
  "Pass genesis-chat's client to support: createSupport({ ..., chat: createChatClient(supabase) }) on native, createSupportClient(supabase, { chat }) on the web. Without it, threads stay on support_replies.",
857
930
  "Web: render SupportReportThread (the person) or SupportStaffThread (staff: status, assignee, internal notes) from @marktiderman/genesis-support/web-chat under genesis-chat's ChatProvider.",
931
+ "Web agent inbox: render SupportAgentInbox from @marktiderman/genesis-support/web-chat at a route of your own, with the open ticket in its URL.",
858
932
  "Keep genesis-chat's runner going (push for replies). support_replies stays mirrored for one release, for older app builds; a later migration removes it."
859
933
  ]
860
934
  },
935
+ "support-helpdesk": {
936
+ "feature": {
937
+ "name": "Help desk",
938
+ "summary": "A help desk any tenant of the app can run: a messenger (Home, Messages, Help), a help center with optional AI answers that cite its articles and hand off to a person, and an agent inbox.",
939
+ "keywords": [
940
+ "help desk",
941
+ "messenger",
942
+ "help center",
943
+ "knowledge base",
944
+ "ai answers",
945
+ "agent inbox"
946
+ ],
947
+ "audience": [
948
+ "person",
949
+ "admin"
950
+ ]
951
+ },
952
+ "requires": [
953
+ "support-feedback",
954
+ "support-chat"
955
+ ],
956
+ "platforms": [
957
+ "web",
958
+ "native"
959
+ ],
960
+ "packages": [
961
+ "@marktiderman/genesis-support"
962
+ ],
963
+ "migrations": [
964
+ {
965
+ "file": "migrations/0010_genesis_support_help_center.sql",
966
+ "test": "migrations/tests/0010_genesis_support_help_center.test.sql"
967
+ }
968
+ ],
969
+ "steps": [
970
+ "Turn a tenant's help desk on with an enabled support-helpdesk row in tenant_features, and make its agents with client.setAgent. The app's own tenant is always on.",
971
+ "Web: render SupportMessengerLauncher for people, and SupportAgentInbox and SupportHelpCenterAdmin at routes of your own, from @marktiderman/genesis-support/web-chat.",
972
+ "Phone: use useMessengerHome, useHelpCenter, useHelpArticle and useStartConversation from @marktiderman/genesis-support/native at the block's routes.",
973
+ "AI answers, optional and off by default: give defineAi your safety protocol, serve answerHelpQuestion from @marktiderman/genesis-support/ai at an endpoint of yours, pass askAi to the messenger, and enable support-helpdesk-ai in tenant_features for each tenant that opts in.",
974
+ "A public help center: pass helpCenterPages' pages to your site (genesis-sites) and publish it."
975
+ ]
976
+ },
861
977
  "support-email": {
862
978
  "feature": {
863
979
  "name": "Support over email",
@@ -887,8 +1003,12 @@
887
1003
  ],
888
1004
  "migrations": [
889
1005
  {
890
- "file": "migrations/0002_genesis_support_email.sql",
1006
+ "file": "migrations/0007_genesis_support_email_on_tickets.sql",
891
1007
  "test": "migrations/tests/0002_genesis_support_email.test.sql"
1008
+ },
1009
+ {
1010
+ "file": "migrations/0008_genesis_support_email_tenants.sql",
1011
+ "test": "migrations/tests/0008_genesis_support_email_tenants.test.sql"
892
1012
  }
893
1013
  ],
894
1014
  "steps": [
@@ -903,10 +1023,10 @@
903
1023
  "version": "2.1.3"
904
1024
  },
905
1025
  "@marktiderman/genesis-ui": {
906
- "version": "2.30.0"
1026
+ "version": "2.32.0"
907
1027
  },
908
1028
  "@marktiderman/genesis-ui-native": {
909
- "version": "3.5.1"
1029
+ "version": "3.9.0"
910
1030
  }
911
1031
  }
912
1032
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { FileSystem, ScaffoldLogger, ScaffoldOptions, ScaffoldResult, planScaffold, runScaffold, validateConsumerName } from './scaffolder.js';
2
2
  import postgres from 'postgres';
3
3
  export { RunDoctorOptions, defineDoctorPlugin, formatReport, runDoctor } from './doctor.js';
4
- export { D as DoctorConfig, f as DoctorConfigError, g as DoctorContext, h as DoctorPlugin, i as DoctorResult, F as Finding, c as GenesisConfigError, j as GenesisConfigFile, b as GenesisLinks, k as GenesisSupabase, r as readGenesisConfig, v as validateLinks } from './config-Dj_f9T7J.js';
4
+ export { D as DoctorConfig, f as DoctorConfigError, g as DoctorContext, h as DoctorPlugin, i as DoctorResult, F as Finding, c as GenesisConfigError, j as GenesisConfigFile, b as GenesisLinks, k as GenesisSupabase, r as readGenesisConfig, v as validateLinks } from './config-HOmiOLQc.js';
5
5
  import '@marktiderman/genesis-features';
6
6
 
7
7
  type StorageType = "string" | "number" | "boolean" | "datetime" | "json";
@@ -164,4 +164,116 @@ interface InitPlan {
164
164
  declare function detectHost(facts: ProjectFacts): StudioHost;
165
165
  declare function planStudioInit(facts: ProjectFacts, options?: InitOptions): InitPlan;
166
166
 
167
- export { CommentSettingsError, EmitError, type EmitOptions, type FieldSettings, type InitOptions, type InitPlan, type IntrospectedColumn, type IntrospectedTable, type OpenApiDocument, type PlannedFile, type ProjectFacts, type StorageType, type StudioHost, type TableSettings, detectHost, emitContracts, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planStudioInit };
167
+ type Platform = "web" | "native";
168
+ interface FigmaConfig {
169
+ /** The app file's key (from its URL: figma.com/design/<key>/…). */
170
+ file: string;
171
+ /** The page that holds each platform's route frames. */
172
+ pages: Partial<Record<Platform, string>>;
173
+ /** The page proposals live on. Default `Proposals`. */
174
+ proposalsPage: string;
175
+ }
176
+ declare class FigmaConfigError extends Error {
177
+ }
178
+ /** Check the `figma` block of genesis.config.json. */
179
+ declare function validateFigmaConfig(raw: unknown, source?: string): FigmaConfig;
180
+ /** The `figma` block of the app's genesis.config.json, or null when there is none. */
181
+ declare function readFigmaConfig(root: string): FigmaConfig | null;
182
+ interface AppRoute {
183
+ /** As written, without a leading slash: `(tabs)/settings`, `courses/$id`, `index` for the root. */
184
+ route: string;
185
+ platform: Platform;
186
+ /** App-relative, POSIX. */
187
+ file: string;
188
+ /** From a `// figma: <node-id>` line in the file's first lines. */
189
+ figmaId?: string;
190
+ }
191
+ /** The app's routes: Expo Router (`src/app` or `app`, native) and TanStack file routes (`src/routes`, web). */
192
+ declare function appRoutes(root: string): AppRoute[];
193
+ interface NavTarget {
194
+ /** App-relative file holding the call. */
195
+ file: string;
196
+ line: number;
197
+ target: string;
198
+ }
199
+ /** Every navigation target in the app's code (`src/`, `app/`). */
200
+ declare function appNavTargets(root: string): NavTarget[];
201
+ interface Frame {
202
+ id: string;
203
+ name: string;
204
+ page: string;
205
+ /** For a frame inside a section (every Proposals frame), the section's name. */
206
+ section?: string;
207
+ /** The route part of the name (before ` · `), and the state after it. */
208
+ route: string;
209
+ state?: string;
210
+ }
211
+ interface Hotspot {
212
+ /** The top-level frame the hotspot sits in. */
213
+ from: string;
214
+ /** The destination node. */
215
+ to: string;
216
+ }
217
+ interface FigmaFacts {
218
+ pages: string[];
219
+ frames: Frame[];
220
+ hotspots: Hotspot[];
221
+ }
222
+ type FetchLike = (url: string, init: {
223
+ headers: Record<string, string>;
224
+ signal?: AbortSignal;
225
+ }) => Promise<{
226
+ ok: boolean;
227
+ status: number;
228
+ json(): Promise<unknown>;
229
+ }>;
230
+ /** Read pages, frames and prototype links. The token goes in a header and nowhere else. */
231
+ declare function readFigma(config: FigmaConfig, token: string, fetchImpl?: FetchLike, timeoutMs?: number): Promise<FigmaFacts>;
232
+ interface MissingHotspot extends NavTarget {
233
+ from: string;
234
+ to: string;
235
+ /** False when the destination route has no frame either (it is also under routesWithoutFrame). */
236
+ targetHasFrame: boolean;
237
+ }
238
+ interface CoverageReport {
239
+ file: string;
240
+ summary: {
241
+ routes: number;
242
+ frames: number;
243
+ covered: number;
244
+ coveredPercent: number;
245
+ hotspots: number;
246
+ missing: number;
247
+ };
248
+ /** Pages the config names that the file doesn't have. */
249
+ missingPages: string[];
250
+ routesWithoutFrame: AppRoute[];
251
+ /** Frames on a route page whose name is no route: candidates for the Proposals page. */
252
+ framesWithoutRoute: Frame[];
253
+ /** The Proposals page's frames, by section. */
254
+ proposals: Record<string, Frame[]>;
255
+ missingHotspots: MissingHotspot[];
256
+ deadHotspots: {
257
+ from: Frame;
258
+ to: Frame;
259
+ }[];
260
+ idMismatches: (AppRoute & {
261
+ frames: string[];
262
+ })[];
263
+ /** Navigation in a route file the check can't resolve (a template literal, a `{ pathname }` object): not checked. */
264
+ uncheckedNavigation: NavTarget[];
265
+ }
266
+ declare function compare(config: FigmaConfig, routes: AppRoute[], targets: NavTarget[], figma: FigmaFacts, dynamicTargets?: NavTarget[]): CoverageReport;
267
+ interface CheckOptions {
268
+ root: string;
269
+ /** Default `process.env.FIGMA_ACCESS_TOKEN`. */
270
+ token?: string;
271
+ fetch?: FetchLike;
272
+ config?: FigmaConfig;
273
+ }
274
+ /** Read everything and compare. Throws FigmaConfigError when there is no config or no token. */
275
+ declare function checkFigmaRoutes(options: CheckOptions): Promise<CoverageReport>;
276
+ /** The report as text: a summary line, then one table per kind of finding. */
277
+ declare function formatCoverage(r: CoverageReport): string;
278
+
279
+ export { type AppRoute, CommentSettingsError, type CoverageReport, EmitError, type EmitOptions, type FieldSettings, type FigmaConfig, FigmaConfigError, type FigmaFacts, type InitOptions, type InitPlan, type IntrospectedColumn, type IntrospectedTable, type NavTarget, type OpenApiDocument, type PlannedFile, type ProjectFacts, type StorageType, type StudioHost, type TableSettings, appNavTargets, appRoutes, checkFigmaRoutes, compare as compareFigmaRoutes, detectHost, emitContracts, formatCoverage, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planStudioInit, readFigma, readFigmaConfig, validateFigmaConfig };