create-expo-updates-server 0.1.6 → 0.2.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 (139) hide show
  1. package/dist/template/.dockerignore +16 -0
  2. package/dist/template/README.md +51 -660
  3. package/dist/template/app/api/admin/device-targets/route.test.ts +43 -0
  4. package/dist/template/app/api/admin/device-targets/route.ts +91 -0
  5. package/dist/template/app/api/admin/devices/route.test.ts +41 -0
  6. package/dist/template/app/api/admin/devices/route.ts +15 -0
  7. package/dist/template/app/api/admin/updates/[encodedKey]/audience/route.ts +75 -0
  8. package/dist/template/app/api/device-heartbeat/route.ts +2 -0
  9. package/dist/template/app/globals.css +114 -15
  10. package/dist/template/app/layout.tsx +12 -4
  11. package/dist/template/app/login/page.tsx +22 -18
  12. package/dist/template/app/updates/[encodedKey]/page.tsx +112 -88
  13. package/dist/template/app/updates/devices/page.tsx +264 -0
  14. package/dist/template/app/updates/embedded/page.tsx +102 -68
  15. package/dist/template/app/updates/emergency-redirects/page.tsx +144 -111
  16. package/dist/template/app/updates/layout.tsx +6 -1
  17. package/dist/template/app/updates/page.tsx +262 -212
  18. package/dist/template/components/admin/admin-shell.tsx +196 -0
  19. package/dist/template/components/admin/language-switcher.tsx +25 -0
  20. package/dist/template/components/admin/theme-provider.tsx +15 -0
  21. package/dist/template/components/ui/alert.tsx +65 -0
  22. package/dist/template/components/ui/badge.tsx +47 -0
  23. package/dist/template/components/ui/button.tsx +63 -0
  24. package/dist/template/components/ui/card.tsx +91 -0
  25. package/dist/template/components/ui/chart.tsx +373 -0
  26. package/dist/template/components/ui/checkbox.tsx +31 -0
  27. package/dist/template/components/ui/dialog.tsx +158 -0
  28. package/dist/template/components/ui/dropdown-menu.tsx +256 -0
  29. package/dist/template/components/ui/input.tsx +20 -0
  30. package/dist/template/components/ui/label.tsx +23 -0
  31. package/dist/template/components/ui/native-select.tsx +61 -0
  32. package/dist/template/components/ui/popover.tsx +88 -0
  33. package/dist/template/components/ui/scroll-area.tsx +57 -0
  34. package/dist/template/components/ui/select.tsx +189 -0
  35. package/dist/template/components/ui/separator.tsx +27 -0
  36. package/dist/template/components/ui/sheet.tsx +142 -0
  37. package/dist/template/components/ui/sidebar.tsx +736 -0
  38. package/dist/template/components/ui/skeleton.tsx +13 -0
  39. package/dist/template/components/ui/switch.tsx +34 -0
  40. package/dist/template/components/ui/table.tsx +115 -0
  41. package/dist/template/components/ui/tabs.tsx +90 -0
  42. package/dist/template/components/ui/textarea.tsx +17 -0
  43. package/dist/template/components/ui/tooltip.tsx +56 -0
  44. package/dist/template/components.json +22 -0
  45. package/dist/template/docs/admin-ui.md +35 -0
  46. package/dist/template/docs/device-targeting.md +129 -0
  47. package/dist/template/docs/doctor.md +137 -0
  48. package/dist/template/docs/expo-app-setup.md +174 -47
  49. package/dist/template/docs/getting-started.md +105 -146
  50. package/dist/template/docs/getting-started.ru.md +106 -191
  51. package/dist/template/docs/index.md +14 -33
  52. package/dist/template/docs/installation-telemetry.md +233 -0
  53. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +89 -0
  54. package/dist/template/docs/migrations/2026-10-19-device-heartbeat.sql +131 -0
  55. package/dist/template/docs/migrations/2026-10-22-device-analytics.sql +264 -0
  56. package/dist/template/docs/migrations/2026-10-22-device-targeting-activation.sql +108 -0
  57. package/dist/template/docs/migrations/2026-10-22-device-targeting.sql +130 -0
  58. package/dist/template/docs/migrations/2026-10-22-device-version-metadata.sql +154 -0
  59. package/dist/template/docs/migrations/schema.sql +868 -6
  60. package/dist/template/docs/npm-installer.md +15 -30
  61. package/dist/template/docs/operations-guide.md +87 -0
  62. package/dist/template/docs/ota-client-lifecycle.md +263 -0
  63. package/dist/template/docs/ota-update-policy.md +36 -2
  64. package/dist/template/docs/supabase-setup.md +4 -0
  65. package/dist/template/hooks/use-mobile.ts +21 -0
  66. package/dist/template/lib/utils.ts +6 -0
  67. package/dist/template/package-lock.json +2325 -101
  68. package/dist/template/package.json +13 -3
  69. package/dist/template/scripts/configure-expo-app.mjs +11 -15
  70. package/dist/template/scripts/doctor.mjs +51 -0
  71. package/dist/template/scripts/ensure-test-bucket.mjs +21 -0
  72. package/dist/template/scripts/lib/device-identity.test.ts +29 -0
  73. package/dist/template/scripts/lib/doctor-probes.mjs +139 -0
  74. package/dist/template/scripts/lib/doctor.mjs +208 -0
  75. package/dist/template/scripts/lib/doctor.test.mjs +262 -0
  76. package/dist/template/scripts/lib/expo-app-configurator.mjs +14 -9
  77. package/dist/template/scripts/lib/expo-app-configurator.test.ts +3 -2
  78. package/dist/template/scripts/lib/ota-client-configurator.mjs +69 -0
  79. package/dist/template/scripts/lib/ota-client-configurator.test.ts +88 -0
  80. package/dist/template/scripts/lib/ota-client.test.ts +55 -0
  81. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +173 -0
  82. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +123 -0
  83. package/dist/template/scripts/lib/ota-update-controller.test.ts +231 -0
  84. package/dist/template/scripts/tests/device-analytics-migrations.mjs +80 -0
  85. package/dist/template/scripts/tests/device-analytics.mjs +126 -0
  86. package/dist/template/scripts/tests/device-heartbeat.mjs +86 -0
  87. package/dist/template/scripts/tests/device-targeting-activation.mjs +111 -0
  88. package/dist/template/scripts/tests/device-targeting.mjs +39 -0
  89. package/dist/template/scripts/tests/device-version-metadata.mjs +31 -0
  90. package/dist/template/scripts/tests/manifest-identity-concurrency.mjs +106 -0
  91. package/dist/template/scripts/tests/manifest-identity.sql +204 -0
  92. package/dist/template/src/client/admin-types.ts +1 -0
  93. package/dist/template/src/client/devices/analytics.tsx +429 -0
  94. package/dist/template/src/client/devices/device-name.tsx +82 -0
  95. package/dist/template/src/client/devices/registry.tsx +399 -0
  96. package/dist/template/src/client/devices/use-devices-report.ts +108 -0
  97. package/dist/template/src/client/devices/version-adoption-chart.tsx +269 -0
  98. package/dist/template/src/client/devices/version-groups.test.ts +57 -0
  99. package/dist/template/src/client/devices/version-groups.ts +101 -0
  100. package/dist/template/src/client/distribution-control.tsx +135 -81
  101. package/dist/template/src/client/guard-action-combobox.tsx +13 -24
  102. package/dist/template/src/client/i18n/en.json +286 -0
  103. package/dist/template/src/client/i18n/messages.test.ts +42 -0
  104. package/dist/template/src/client/i18n/messages.ts +31 -0
  105. package/dist/template/src/client/i18n/provider.tsx +55 -0
  106. package/dist/template/src/client/i18n/use-formatters.ts +38 -0
  107. package/dist/template/src/client/logout-button.tsx +3 -1
  108. package/dist/template/src/client/update-audience-editor.tsx +285 -0
  109. package/dist/template/src/client/update-policy-editor.tsx +53 -41
  110. package/dist/template/src/server/controllers/manifest.test.ts +250 -7
  111. package/dist/template/src/server/controllers/manifest.ts +39 -31
  112. package/dist/template/src/server/devices/audience.test.ts +48 -0
  113. package/dist/template/src/server/devices/audience.ts +86 -0
  114. package/dist/template/src/server/devices/heartbeat.test.ts +39 -0
  115. package/dist/template/src/server/devices/heartbeat.ts +75 -0
  116. package/dist/template/src/server/devices/report-types.ts +114 -0
  117. package/dist/template/src/server/devices/report.test.ts +29 -0
  118. package/dist/template/src/server/devices/report.ts +27 -0
  119. package/dist/template/src/server/lib/admin-audience-activation.test.ts +94 -0
  120. package/dist/template/src/server/lib/admin-updates.ts +32 -168
  121. package/dist/template/src/server/lib/supabase.js +10 -10
  122. package/dist/template/src/server/lib/supabase.test.ts +11 -0
  123. package/dist/template/src/server/manifest/manifest-identity.test.ts +30 -0
  124. package/dist/template/src/server/manifest/manifest-identity.ts +24 -0
  125. package/dist/template/src/server/manifest/manifest-repository.ts +31 -102
  126. package/dist/template/src/server/manifest/manifest-response.ts +1 -1
  127. package/dist/template/templates/expo-app/ota-client/README.md +59 -0
  128. package/dist/template/templates/expo-app/ota-client/controller.js +60 -0
  129. package/dist/template/templates/expo-app/ota-client/device-identity.js +26 -0
  130. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +52 -0
  131. package/dist/template/templates/expo-app/ota-client/index.d.ts +47 -0
  132. package/dist/template/templates/expo-app/ota-client/index.js +3 -0
  133. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +48 -0
  134. package/dist/template/templates/expo-app/ota-client/model/update-controller.js +182 -0
  135. package/dist/template/templates/expo-app/ota-client/runtime.js +112 -0
  136. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +56 -0
  137. package/dist/template-manifest.json +578 -73
  138. package/lib/cli.mjs +4 -6
  139. package/package.json +1 -1
@@ -0,0 +1,13 @@
1
+ import { cn } from "@/lib/utils";
2
+
3
+ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
+ return (
5
+ <div
6
+ data-slot="skeleton"
7
+ className={cn("animate-pulse rounded-md bg-accent", className)}
8
+ {...props}
9
+ />
10
+ );
11
+ }
12
+
13
+ export { Skeleton };
@@ -0,0 +1,34 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cn } from "@/lib/utils";
5
+ import { Switch as SwitchPrimitive } from "radix-ui";
6
+
7
+ function Switch({
8
+ className,
9
+ size = "default",
10
+ ...props
11
+ }: React.ComponentProps<typeof SwitchPrimitive.Root> & {
12
+ size?: "sm" | "default";
13
+ }) {
14
+ return (
15
+ <SwitchPrimitive.Root
16
+ data-slot="switch"
17
+ data-size={size}
18
+ className={cn(
19
+ "peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
20
+ className,
21
+ )}
22
+ {...props}
23
+ >
24
+ <SwitchPrimitive.Thumb
25
+ data-slot="switch-thumb"
26
+ className={cn(
27
+ "pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground",
28
+ )}
29
+ />
30
+ </SwitchPrimitive.Root>
31
+ );
32
+ }
33
+
34
+ export { Switch };
@@ -0,0 +1,115 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cn } from "@/lib/utils";
5
+
6
+ function Table({ className, ...props }: React.ComponentProps<"table">) {
7
+ return (
8
+ <div
9
+ data-slot="table-container"
10
+ className="relative w-full overflow-x-auto"
11
+ >
12
+ <table
13
+ data-slot="table"
14
+ className={cn("w-full caption-bottom text-sm", className)}
15
+ {...props}
16
+ />
17
+ </div>
18
+ );
19
+ }
20
+
21
+ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
22
+ return (
23
+ <thead
24
+ data-slot="table-header"
25
+ className={cn("[&_tr]:border-b", className)}
26
+ {...props}
27
+ />
28
+ );
29
+ }
30
+
31
+ function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
32
+ return (
33
+ <tbody
34
+ data-slot="table-body"
35
+ className={cn("[&_tr:last-child]:border-0", className)}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
42
+ return (
43
+ <tfoot
44
+ data-slot="table-footer"
45
+ className={cn(
46
+ "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
47
+ className,
48
+ )}
49
+ {...props}
50
+ />
51
+ );
52
+ }
53
+
54
+ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
55
+ return (
56
+ <tr
57
+ data-slot="table-row"
58
+ className={cn(
59
+ "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
60
+ className,
61
+ )}
62
+ {...props}
63
+ />
64
+ );
65
+ }
66
+
67
+ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
68
+ return (
69
+ <th
70
+ data-slot="table-head"
71
+ className={cn(
72
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
73
+ className,
74
+ )}
75
+ {...props}
76
+ />
77
+ );
78
+ }
79
+
80
+ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
81
+ return (
82
+ <td
83
+ data-slot="table-cell"
84
+ className={cn(
85
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
86
+ className,
87
+ )}
88
+ {...props}
89
+ />
90
+ );
91
+ }
92
+
93
+ function TableCaption({
94
+ className,
95
+ ...props
96
+ }: React.ComponentProps<"caption">) {
97
+ return (
98
+ <caption
99
+ data-slot="table-caption"
100
+ className={cn("mt-4 text-sm text-muted-foreground", className)}
101
+ {...props}
102
+ />
103
+ );
104
+ }
105
+
106
+ export {
107
+ Table,
108
+ TableHeader,
109
+ TableBody,
110
+ TableFooter,
111
+ TableHead,
112
+ TableRow,
113
+ TableCell,
114
+ TableCaption,
115
+ };
@@ -0,0 +1,90 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import { cn } from "@/lib/utils";
6
+ import { Tabs as TabsPrimitive } from "radix-ui";
7
+
8
+ function Tabs({
9
+ className,
10
+ orientation = "horizontal",
11
+ ...props
12
+ }: React.ComponentProps<typeof TabsPrimitive.Root>) {
13
+ return (
14
+ <TabsPrimitive.Root
15
+ data-slot="tabs"
16
+ data-orientation={orientation}
17
+ orientation={orientation}
18
+ className={cn(
19
+ "group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",
20
+ className,
21
+ )}
22
+ {...props}
23
+ />
24
+ );
25
+ }
26
+
27
+ const tabsListVariants = cva(
28
+ "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",
29
+ {
30
+ variants: {
31
+ variant: {
32
+ default: "bg-muted",
33
+ line: "gap-1 bg-transparent",
34
+ },
35
+ },
36
+ defaultVariants: {
37
+ variant: "default",
38
+ },
39
+ },
40
+ );
41
+
42
+ function TabsList({
43
+ className,
44
+ variant = "default",
45
+ ...props
46
+ }: React.ComponentProps<typeof TabsPrimitive.List> &
47
+ VariantProps<typeof tabsListVariants>) {
48
+ return (
49
+ <TabsPrimitive.List
50
+ data-slot="tabs-list"
51
+ data-variant={variant}
52
+ className={cn(tabsListVariants({ variant }), className)}
53
+ {...props}
54
+ />
55
+ );
56
+ }
57
+
58
+ function TabsTrigger({
59
+ className,
60
+ ...props
61
+ }: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
62
+ return (
63
+ <TabsPrimitive.Trigger
64
+ data-slot="tabs-trigger"
65
+ className={cn(
66
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
67
+ "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
68
+ "data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground",
69
+ "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
70
+ className,
71
+ )}
72
+ {...props}
73
+ />
74
+ );
75
+ }
76
+
77
+ function TabsContent({
78
+ className,
79
+ ...props
80
+ }: React.ComponentProps<typeof TabsPrimitive.Content>) {
81
+ return (
82
+ <TabsPrimitive.Content
83
+ data-slot="tabs-content"
84
+ className={cn("flex-1 outline-none", className)}
85
+ {...props}
86
+ />
87
+ );
88
+ }
89
+
90
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { cn } from "@/lib/utils";
3
+
4
+ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
5
+ return (
6
+ <textarea
7
+ data-slot="textarea"
8
+ className={cn(
9
+ "flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
10
+ className,
11
+ )}
12
+ {...props}
13
+ />
14
+ );
15
+ }
16
+
17
+ export { Textarea };
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cn } from "@/lib/utils";
5
+ import { Tooltip as TooltipPrimitive } from "radix-ui";
6
+
7
+ function TooltipProvider({
8
+ delayDuration = 0,
9
+ ...props
10
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
11
+ return (
12
+ <TooltipPrimitive.Provider
13
+ data-slot="tooltip-provider"
14
+ delayDuration={delayDuration}
15
+ {...props}
16
+ />
17
+ );
18
+ }
19
+
20
+ function Tooltip({
21
+ ...props
22
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
23
+ return <TooltipPrimitive.Root data-slot="tooltip" {...props} />;
24
+ }
25
+
26
+ function TooltipTrigger({
27
+ ...props
28
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
29
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
30
+ }
31
+
32
+ function TooltipContent({
33
+ className,
34
+ sideOffset = 0,
35
+ children,
36
+ ...props
37
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
38
+ return (
39
+ <TooltipPrimitive.Portal>
40
+ <TooltipPrimitive.Content
41
+ data-slot="tooltip-content"
42
+ sideOffset={sideOffset}
43
+ className={cn(
44
+ "z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
45
+ className,
46
+ )}
47
+ {...props}
48
+ >
49
+ {children}
50
+ <TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
51
+ </TooltipPrimitive.Content>
52
+ </TooltipPrimitive.Portal>
53
+ );
54
+ }
55
+
56
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": true,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "app/globals.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "iconLibrary": "lucide",
14
+ "aliases": {
15
+ "components": "@/components",
16
+ "utils": "@/lib/utils",
17
+ "ui": "@/components/ui",
18
+ "lib": "@/lib",
19
+ "hooks": "@/hooks"
20
+ },
21
+ "registries": {}
22
+ }
@@ -0,0 +1,35 @@
1
+ # Панель управления
2
+
3
+ Админка использует общий UI kit shadcn/ui (Radix), Tailwind CSS 4, Lucide и Recharts. Исходники компонентов находятся в `components/ui`, тема — в `app/globals.css`, оболочка — в `components/admin`. Светлая и тёмная темы используют одни семантические токены. Новые страницы должны использовать эти компоненты и токены, сохраняя серверную проверку сессии в `app/updates/layout.tsx`.
4
+
5
+ ## Навигация и данные
6
+
7
+ - **Установки** (`/updates/devices`): общие серверные фильтры, KPI, дневная активность, распределение версий, когорты и реестр. Часть Installation ID можно использовать для поиска конкретной установки. Полные идентификаторы и диагностика доступны по нажатию на ID.
8
+ - **OTA-обновления** (`/updates`): список публикаций, сортировка, пагинация и переход к редактированию. Аварийная остановка распространения находится в раскрываемой панели «Управление».
9
+ - **Embedded-сборки** и **Аварийные маршруты** сохраняют существующие ограничения по ролям и действия управления.
10
+
11
+ Фильтры применяются кнопкой «Применить» ко всей выборке. Ошибка запроса оставляет предыдущий результат с явным сообщением. Если последняя страница исчезла при обновлении, реестр переходит на последнюю существующую страницу. Статистика считает установки, а не уникальных людей.
12
+
13
+ Подробная семантика дневных данных, когорт, возвращаемости и миграция существующей базы: [Телеметрия установок](./installation-telemetry.md). Для существующей базы нужна миграция `2026-10-22-device-analytics.sql`; новая база получает её из канонического `schema.sql`.
14
+
15
+ ## Проверка интерфейса
16
+
17
+ При изменениях проверяйте ширины 1440 и 390 px, обе темы, фильтры с пустым результатом, сброс фильтров, раскрытие и копирование ID, клавиатурное закрытие боковых панелей с возвратом фокуса, повтор пагинации после ошибки и уменьшение числа записей на последней странице. Таблицы могут прокручиваться внутри карточки; горизонтальная прокрутка всей страницы не нужна. Историю до начала сбора нельзя заменять нулями или демонстрационными данными.
18
+
19
+ Команды проверки: `npm run lint`, `npx tsc --noEmit`, `npm test`, `npm run build`, `npm run installer:check`. Новые папки UI включены в шаблон npm-инсталлятора, поэтому панель получает тот же интерфейс при установке из коробки.
20
+
21
+ ## Interface language
22
+
23
+ The admin panel defaults to English, including when the browser prefers another
24
+ language. Select **English** or **Русский** on the sign-in screen or in the admin
25
+ header. The choice persists in the `ota-locale` cookie for one year and is applied
26
+ on the server for the next page load. Unknown locale values fall back to English.
27
+ Switching languages preserves filters and unsaved form data; number/date formatting
28
+ follows the selected locale. Analytics date boundaries remain UTC.
29
+
30
+ UI translations live in `src/client/i18n/`. Russian source messages are catalog keys
31
+ and `en.json` supplies their English equivalents. Use `useI18n().t` for interface
32
+ copy and `useFormatters()` for analytics values. Keep interpolation slots intact.
33
+ Do not translate API enum values, IDs, JSON, device names or user-written messages.
34
+ Adding a language requires an explicit supported locale, catalog and selector option;
35
+ browser language detection is deliberately not used for the default.
@@ -0,0 +1,129 @@
1
+ # Device-targeted OTA releases
2
+
3
+ A release has an audience (`all` or `devices`) independently of its delivery/guard policy.
4
+ The audience is checked before choosing a manifest. Runtime, channel and platform still
5
+ have to match. A force-update guard does not bypass the audience.
6
+
7
+ ## Smoke test, then release
8
+
9
+ 1. Configure the application with `npm run configure-app`. The generated `ota-entry.js`
10
+ starts the client before the original Router/custom entry; no manual hook or ID wiring
11
+ is required. Existing generated files can be refreshed with `--force` (review local edits).
12
+ 2. Rebuild the native app after adding `expo-secure-store`; use a new runtime so older
13
+ binaries cannot download JavaScript importing a missing native module.
14
+ 3. Open the app. In **Установки → installation details**, copy its Device ID or name it
15
+ **Мой телефон**. Older clients still report Installation ID and can be targeted by it.
16
+ 4. Publish with the generated `npm run ota:publish -- --platform android --message "Smoke"`.
17
+ Publishing creates a draft. In its detail page select **Аудитория обновления → Только
18
+ выбранные устройства / установки**, choose your phone, and **save before activation**.
19
+ 5. Activate the draft. Your device gets it; other compatible devices get the previous
20
+ eligible public update, or no update if one does not exist.
21
+ 6. After testing, set the audience to **Все совместимые устройства** and save. The same
22
+ artifact is now eligible for everyone. No second publish is needed.
23
+
24
+ Changing an active audience affects future checks immediately. It does not uninstall or
25
+ revoke cached/downloaded OTA bundles. Use the existing rollback flow to change the running
26
+ version. Targeting is a rollout mechanism, not authentication or confidential asset storage:
27
+ client IDs can be supplied by a modified client and asset URLs remain accessible.
28
+
29
+ ## Two identities
30
+
31
+ - **Installation ID**: random UUID in AsyncStorage. Continues through OTA, changes after
32
+ uninstall/clear data. It remains the unit counted in installation/cohort analytics.
33
+ - **Device ID**: SHA-256 value scoped to the app ID and an OTA-server namespace. On Android,
34
+ the input is `expo-application.getAndroidId()` (signing key + Android user + device). On
35
+ iOS, the input is a random UUID stored through `expo-secure-store` with
36
+ `WHEN_UNLOCKED_THIS_DEVICE_ONLY`, so a backup restored on a different phone does not
37
+ deliberately copy this identity. Raw platform IDs are never sent to the server.
38
+
39
+ Android reinstall with the same signing key normally keeps Device ID. Factory reset,
40
+ Android user/profile or signing key changes can change it. iOS Keychain often survives
41
+ reinstall with the same bundle ID, but persistence across uninstall is not guaranteed.
42
+ If Device ID changes, select the new device in the audience again. There is no universal,
43
+ permanent physical-device identity. The admin name belongs to Device ID, not Installation ID.
44
+
45
+ `ota-client/config.json.identityNamespace` is preserved on reconfiguration, including
46
+ server/tunnel URL changes. Keep this generated file with application source. Runtime and
47
+ channel are deliberately not part of Device ID. A separate application or server should
48
+ use its own namespace.
49
+
50
+ Official API references: [Expo Application](https://docs.expo.dev/versions/v58.0.0/sdk/application/),
51
+ [Expo SecureStore](https://docs.expo.dev/versions/v58.0.0/sdk/securestore/),
52
+ [Expo extra parameters](https://docs.expo.dev/versions/v58.0.0/sdk/updates/#updatessetextraparamasynckey-value).
53
+
54
+ ## Client initialization
55
+
56
+ Generated entry calls `start()` automatically, persists installation identity and sets
57
+ `installation_id` / `device_id` via `Updates.setExtraParamAsync`. Heartbeat adds optional
58
+ `deviceId`. The durable queue and monotonic per-installation sequence are unchanged.
59
+ An unavailable Device ID does not stop installation telemetry; device targeting fails closed.
60
+ The iOS identity read retries after temporary Keychain failure without replacing its seed.
61
+
62
+ For custom check/download UI use the generated `checkForUpdateAsync` and `fetchUpdateAsync`:
63
+ these wait for initialization. Direct calls to `expo-updates` before initialization can
64
+ perform an anonymous check; anonymous clients only receive public updates. Configuration
65
+ sets `checkAutomatically: NEVER`, preserving explicit update-check control. The initializer
66
+ itself does not download/reload updates or alter application navigation.
67
+
68
+ Optional `getInstallationId()` / `getDeviceId()` exports are for displaying diagnostics,
69
+ not required to register the device. Both return null when updates are disabled (web/dev).
70
+
71
+ ## Server migration and behavior
72
+
73
+ Apply `docs/migrations/2026-10-22-device-targeting.sql` after the analytics/version migrations,
74
+ before deploying the server. Fresh installations use `docs/migrations/schema.sql`.
75
+ Then apply `docs/migrations/2026-10-22-device-targeting-activation.sql` before deploying
76
+ server changes from the cross review. It atomically applies the public/targeted activation
77
+ rules, preserves deactivation during a global stop, and adds the `ota-force-update` guard
78
+ catalog entry alongside the separate native/store update action. Both migrations are
79
+ repeatable and do not change the audience or active state of existing releases.
80
+
81
+ The targeting migration removes the single-active-release index because a targeted
82
+ release must coexist with its public fallback. Existing releases have audience `all`.
83
+
84
+ Activation, rollback and promotion of a targeted release preserve other active releases.
85
+ Normal public activation keeps the previous behavior of disabling older releases.
86
+ Widening an already-active targeted release leaves the prior public fallback eligible;
87
+ the newer release wins selection. Disabling the targeted release restores fallback selection.
88
+ Explicit rollback has priority, subject to the same audience and compatibility checks.
89
+ Emergency pinned redirects still fail closed when the selected artifact differs.
90
+
91
+ Admin API:
92
+
93
+ - `GET/PUT /api/admin/updates/:encodedKey/audience` uses existing read/write permissions.
94
+ PUT replaces mode and both ID lists with `audience_version` for optimistic concurrency.
95
+ At least one target is required in `devices` mode; maximum 100 IDs of each type.
96
+ The DB serializes audience changes with the emergency distribution switch.
97
+ - `GET /api/admin/device-targets?platform=android|ios` requires an admin session and lists
98
+ the latest 500 installations, including old runtimes. UI search shows up to 50 matches;
99
+ older IDs can be entered manually.
100
+ - `PUT /api/admin/device-targets` names a Device ID (admin/operator session only).
101
+
102
+ Manifest requests read the Expo Structured Field Dictionary `Expo-Extra-Params`.
103
+ Missing/malformed IDs never match a private audience. Responses use `private, no-store`.
104
+ Selection applies eligibility before the latest-active fallback query, never after taking
105
+ only one unfiltered row. Accepted heartbeats can associate a new installation with the same
106
+ Device ID; duplicate/stale events do not relink it or merge installation history.
107
+
108
+ For isolated local Docker configurations, `configure-app --server-env .env.ota-test` uses
109
+ that file's published database/storage ports when generating `.env.ota`.
110
+
111
+ ## Verification
112
+
113
+ `npm test`, `npm run lint`, `npx tsc --noEmit` and `npm run installer:check` cover server and
114
+ packaging checks. Run `OTA_TEST_DATABASE_URL=... node scripts/tests/device-targeting.mjs`
115
+ against a migrated disposable/test DB for real PostgreSQL eligibility, compatibility,
116
+ CAS, global block and reinstall tests. Fixtures are rolled back. Device reinstall/Keychain
117
+ behavior additionally requires physical-device testing with the native build.
118
+
119
+ Activation and audience changes are serialized in PostgreSQL. Public activation disables
120
+ other active releases in the same scope within the same statement; a failed activation
121
+ cannot partially disable the previous public release. This also covers the existing
122
+ `update-meta.json` editor. Targeted activation preserves other audiences. During a global
123
+ stop, deactivation can repair stale pointers to the remaining active fallback; activating,
124
+ promoting a live rollback, and changing audiences stay blocked.
125
+
126
+ Run `scripts/tests/device-targeting-activation.mjs` against an **empty disposable database**
127
+ with the complete schema to check concurrent audience changes, failed activation atomicity,
128
+ and incident deactivation. It refuses a database containing releases. The analytics
129
+ migration runner also checks this suite for both fresh and upgrade paths.
@@ -0,0 +1,137 @@
1
+ # Diagnose setup with doctor
2
+
3
+ Run `doctor` from the **server directory**. It checks the server and optionally an
4
+ Expo app without changing files, starting containers, applying migrations, uploading
5
+ assets or activating updates. Node.js 24 is recommended; the env parser requires
6
+ Node.js 20.12+. Certificate usage checks also need the OpenSSL executable.
7
+
8
+ ```bash
9
+ npm ci
10
+ npm run doctor -- --app ../my-expo-app
11
+ ```
12
+
13
+ The default is **Docker mode**, with `.env` and `docker-compose.yml`. The `app`
14
+ service must be running. Database, bucket and signing-key probes execute inside
15
+ that container as its normal user, so they test actual container access rather
16
+ than the host's permission to read a bind-mounted key.
17
+
18
+ To check only server files before startup:
19
+
20
+ ```bash
21
+ npm run doctor -- --offline --certificate ./local-certificates/code-signing-certificate.pem
22
+ ```
23
+
24
+ Offline Docker checks use the standard template's env mapping and host key location
25
+ `secrets/code-signing-private-key.pem`. They do not evaluate custom Compose overrides
26
+ or prove that the container can read the key.
27
+
28
+ ## Remote or npm deployment
29
+
30
+ Choose remote mode explicitly. It reads **only** the selected env file, without
31
+ merging shell credentials or loading another `.env.local` implicitly:
32
+
33
+ ```bash
34
+ npm run doctor -- \
35
+ --mode remote \
36
+ --server-env ./server.env \
37
+ --app ../my-expo-app
38
+ ```
39
+
40
+ This mode supports PostgreSQL/S3 and Supabase configurations. Run it where the env
41
+ file, private key, database and storage are accessible. Relative private-key paths
42
+ resolve from the server directory. No SSH connection or remote filesystem access
43
+ is inferred from a hostname. Env variable interpolation is not evaluated in remote
44
+ mode; use explicit values. PostgreSQL URLs must include user/password and database;
45
+ only `sslmode` is supported in URL query parameters. The default port is explicitly
46
+ 5432, so ambient `PG*` credentials/ports cannot silently select another connection.
47
+
48
+ ## Custom Docker project
49
+
50
+ Pass the same project and Compose files used to start the stack, in the same order:
51
+
52
+ ```bash
53
+ npm run doctor -- \
54
+ --server-env .env.ota-test \
55
+ --project ota-test \
56
+ --compose-file docker-compose.yml \
57
+ --compose-file docker-compose.ota-test.yml \
58
+ --app ../rn-app-ota-test
59
+ ```
60
+
61
+ `--compose-file` is repeatable. These example test files belong to a local test
62
+ stand; use your own files for a generated project. Docker connection/context
63
+ settings are forwarded, but arbitrary shell application env overrides are not.
64
+ The online probe reads the running app's environment and reports a public URL
65
+ mismatch with the selected env file.
66
+
67
+ ## What is checked
68
+
69
+ | Area | Checks |
70
+ | --- | --- |
71
+ | Runtime | Node env parser and server dependencies |
72
+ | Environment | Explicit env file, placeholder values, Docker escaping caveats |
73
+ | Signing | Readable RSA key, at least 2048 bits, current non-CA public certificate, Digital Signature / Code Signing usage, matching public keys |
74
+ | Server URL | Valid public URL, host access to `/api/health`, loopback/HTTP caveat |
75
+ | PostgreSQL | Connection, read access to core OTA/telemetry/targeting columns, required table/function signatures and enabled audience-activation trigger |
76
+ | Supabase | Read access to core REST tables/columns and storage bucket; SQL function bodies are not inspected |
77
+ | Storage | Existing accessible bucket via S3 HEAD or Supabase bucket GET; no writes |
78
+ | Expo app | Static config, installed client dependencies, implementation files, URL/channel/runtime, native check mode, identity namespace and telemetry URL |
79
+ | Root | Recognized root hook/gate wiring and generated bootstrap metadata; custom roots need manual verification |
80
+ | Publisher/registrar | Presence and basic shape of `.env.ota` credentials, publisher command, channel and registration URL consistency |
81
+
82
+ Without `--app`, app checks are skipped. Without an app certificate or an explicit
83
+ `--certificate`, key-pair comparison is skipped. An explicit certificate takes
84
+ precedence over the app's certificate and produces a warning if it is a different
85
+ file. Doctor never evaluates `app.config.*`; those projects report the current
86
+ static-config limitation.
87
+
88
+ Each check reports `pass`, `fail`, `warn` or `skip`, plus an actionable remedy where
89
+ needed. Raw exceptions, credentials, private keys and connection strings are not
90
+ included in the output.
91
+
92
+ ## CI and timeouts
93
+
94
+ ```bash
95
+ npm run --silent doctor -- --mode remote --server-env ./server.env --json
96
+ ```
97
+
98
+ Use `--silent` so npm's command banner does not precede the JSON document.
99
+ Output has a versioned shape:
100
+
101
+ ```json
102
+ {
103
+ "version": 1,
104
+ "mode": "remote",
105
+ "offline": false,
106
+ "status": "fail",
107
+ "checks": [
108
+ {
109
+ "id": "signing.key",
110
+ "status": "fail",
111
+ "message": "Signing key is missing, unreadable or invalid.",
112
+ "remedy": "Check the signing key configuration and read permissions."
113
+ }
114
+ ]
115
+ }
116
+ ```
117
+
118
+ Exit codes: `0` means no detected blockers (warnings/skips may remain), `1` means
119
+ failed checks, and `2` means invalid arguments or an unexpected diagnostic failure.
120
+ Use `--timeout 10000` to allow 10 seconds per network operation; supported values
121
+ are 500–30000 ms. Several probes run sequentially, so the total duration can exceed
122
+ one timeout. Docker execution also has an overall bound.
123
+
124
+ ## What a pass does not prove
125
+
126
+ Doctor does not validate native SDK toolchains, execute builds, compare every
127
+ migration definition or exercise write permissions. A token's presence does not
128
+ prove its scope. App credentials may differ from server credentials; publisher and
129
+ registrar authorization still need the real build/publish flow. Container settings
130
+ other than the public URL are checked as currently running, not compared exhaustively
131
+ with pending Compose changes.
132
+
133
+ The host reaching a URL does not prove that a phone can reach it. Source configuration
134
+ also cannot prove which URL/runtime/certificate is installed in a native binary.
135
+ After fixing configuration, follow the [Quick Start](./getting-started.md) or
136
+ [fresh app verification](./expo-app-setup.md#verify-generation-in-a-fresh-application)
137
+ for the final build → install → publish → activate → download → restart check.