create-expo-updates-server 0.1.3 → 0.1.5

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 (84) hide show
  1. package/dist/template/.env.docker.example +1 -0
  2. package/dist/template/.env.example +2 -0
  3. package/dist/template/README.md +16 -8
  4. package/dist/template/app/api/admin/distribution-control/route.test.ts +153 -0
  5. package/dist/template/app/api/admin/distribution-control/route.ts +111 -0
  6. package/dist/template/app/api/admin/embedded-updates/route.test.ts +36 -1
  7. package/dist/template/app/api/admin/guard-actions/[id]/route.test.ts +60 -0
  8. package/dist/template/app/api/admin/guard-actions/[id]/route.ts +32 -0
  9. package/dist/template/app/api/admin/guard-actions/route.test.ts +123 -0
  10. package/dist/template/app/api/admin/guard-actions/route.ts +66 -0
  11. package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +4 -1
  12. package/dist/template/app/api/admin/updates/[encodedKey]/policy/route.test.ts +171 -0
  13. package/dist/template/app/api/admin/updates/[encodedKey]/policy/route.ts +75 -0
  14. package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +4 -1
  15. package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +4 -1
  16. package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +4 -1
  17. package/dist/template/app/api/admin/updates/route.test.ts +29 -1
  18. package/dist/template/app/updates/[encodedKey]/page.tsx +74 -6
  19. package/dist/template/app/updates/embedded/page.tsx +6 -2
  20. package/dist/template/app/updates/page.tsx +28 -3
  21. package/dist/template/docs/expo-app-setup.md +14 -3
  22. package/dist/template/docs/getting-started.md +13 -7
  23. package/dist/template/docs/getting-started.ru.md +15 -7
  24. package/dist/template/docs/migrations/2026-09-01-app-version-columns.sql +23 -0
  25. package/dist/template/docs/migrations/2026-09-01-ota-update-policy.sql +108 -0
  26. package/dist/template/docs/migrations/2026-09-01-p1-guard-actions.sql +19 -0
  27. package/dist/template/docs/migrations/2026-09-01-p2-simplify-ota-guard-policy.sql +69 -0
  28. package/dist/template/docs/migrations/2026-09-01-policy-publication-correction.sql +44 -0
  29. package/dist/template/docs/migrations/2026-09-02-ota-distribution-control.sql +377 -0
  30. package/dist/template/docs/migrations/schema.sql +561 -2
  31. package/dist/template/docs/operations-guide.md +52 -1
  32. package/dist/template/docs/ota-emergency-recovery.md +22 -0
  33. package/dist/template/docs/ota-update-policy.md +89 -0
  34. package/dist/template/docs/supabase-setup.md +2 -1
  35. package/dist/template/package-lock.json +2 -2
  36. package/dist/template/package.json +1 -1
  37. package/dist/template/scripts/configure-expo-app.mjs +6 -0
  38. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +383 -3
  39. package/dist/template/scripts/lib/expo-app-configurator.mjs +165 -9
  40. package/dist/template/scripts/lib/expo-app-configurator.test.ts +658 -9
  41. package/dist/template/src/client/admin-api.ts +80 -1
  42. package/dist/template/src/client/admin-types.ts +52 -2
  43. package/dist/template/src/client/distribution-control.tsx +231 -0
  44. package/dist/template/src/client/guard-action-combobox.test.ts +26 -0
  45. package/dist/template/src/client/guard-action-combobox.tsx +267 -0
  46. package/dist/template/src/client/guard-action-options.test.ts +62 -0
  47. package/dist/template/src/client/guard-action-options.ts +70 -0
  48. package/dist/template/src/client/update-policy-editor.test.ts +36 -0
  49. package/dist/template/src/client/update-policy-editor.tsx +436 -0
  50. package/dist/template/src/server/controllers/assets.test.ts +87 -0
  51. package/dist/template/src/server/controllers/assets.ts +26 -0
  52. package/dist/template/src/server/controllers/manifest.test.ts +413 -2
  53. package/dist/template/src/server/controllers/manifest.ts +103 -38
  54. package/dist/template/src/server/lib/admin-distribution-guard.test.ts +61 -0
  55. package/dist/template/src/server/lib/admin-embedded-updates.test.ts +57 -0
  56. package/dist/template/src/server/lib/admin-embedded-updates.ts +42 -25
  57. package/dist/template/src/server/lib/admin-update-policy.test.ts +176 -0
  58. package/dist/template/src/server/lib/admin-updates.test.ts +133 -0
  59. package/dist/template/src/server/lib/admin-updates.ts +174 -9
  60. package/dist/template/src/server/lib/distribution-control-migration.test.ts +94 -0
  61. package/dist/template/src/server/lib/distribution-control.test.ts +160 -0
  62. package/dist/template/src/server/lib/distribution-control.ts +250 -0
  63. package/dist/template/src/server/lib/guard-actions-migration.test.ts +56 -0
  64. package/dist/template/src/server/lib/guard-actions.test.ts +142 -0
  65. package/dist/template/src/server/lib/guard-actions.ts +106 -0
  66. package/dist/template/src/server/lib/ota-policy-migrations.test.ts +64 -0
  67. package/dist/template/src/server/lib/simple-policy-migration.test.ts +97 -0
  68. package/dist/template/src/server/lib/supabase.js +95 -8
  69. package/dist/template/src/server/lib/supabase.test.ts +194 -0
  70. package/dist/template/src/server/lib/update-policy.test.ts +98 -0
  71. package/dist/template/src/server/lib/update-policy.ts +171 -0
  72. package/dist/template/src/server/manifest/manifest-repository.ts +10 -1
  73. package/dist/template/src/server/manifest/manifest-response.ts +0 -16
  74. package/dist/template/src/server/manifest/manifest-values.test.ts +54 -0
  75. package/dist/template/src/server/manifest/manifest-values.ts +145 -0
  76. package/dist/template/templates/expo-app/ci_scripts/ci_post_xcodebuild.sh +23 -1
  77. package/dist/template/templates/expo-app/plugins/with-ota-embedded-registration.js +13 -4
  78. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +53 -7
  79. package/dist/template/templates/expo-app/scripts/ota-register-embedded/register-ios.sh +87 -0
  80. package/dist/template/tsconfig.json +4 -1
  81. package/dist/template-manifest.json +283 -88
  82. package/package.json +1 -1
  83. package/dist/template/templates/expo-app/ci_scripts/register-embedded-update.sh +0 -36
  84. /package/dist/template/templates/expo-app/scripts/ota-register-embedded/{android-register-embedded-update.sh → register-android.sh} +0 -0
@@ -4,6 +4,7 @@ import {
4
4
  setUpdateDisabledByKey,
5
5
  } from "@/src/server/lib/admin-updates";
6
6
  import { NextRequest, NextResponse } from "next/server";
7
+ import { OtaDistributionBlockedError } from "@/src/server/lib/distribution-control";
7
8
 
8
9
  type RouteContext = {
9
10
  params: Promise<{ encodedKey: string }>;
@@ -27,7 +28,9 @@ export async function POST(request: NextRequest, context: RouteContext) {
27
28
  } catch (error: unknown) {
28
29
  return NextResponse.json(
29
30
  { error: (error as Error).message || "Failed to deactivate update" },
30
- { status: 500 },
31
+ {
32
+ status: error instanceof OtaDistributionBlockedError ? 409 : 500,
33
+ },
31
34
  );
32
35
  }
33
36
  }
@@ -0,0 +1,171 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { NextRequest } from "next/server";
3
+
4
+ const auth = vi.hoisted(() => ({
5
+ scopes: [] as string[],
6
+ }));
7
+ const getPolicy = vi.hoisted(() =>
8
+ vi.fn(async () => ({
9
+ delivery: "manual",
10
+ guard: null,
11
+ policyVersion: 1,
12
+ publishedAt: null,
13
+ editable: true,
14
+ })),
15
+ );
16
+ const replacePolicy = vi.hoisted(() => vi.fn());
17
+
18
+ vi.mock("@/src/server/lib/admin-access-tokens", () => ({
19
+ authenticateAccessToken: vi.fn(async () => ({
20
+ id: "token",
21
+ name: "test",
22
+ scopes: auth.scopes,
23
+ })),
24
+ }));
25
+ vi.mock("@/src/server/lib/admin-auth", () => ({
26
+ getAdminSessionFromRequest: vi.fn(async () => null),
27
+ }));
28
+ vi.mock("@/src/server/lib/admin-updates", () => ({
29
+ decodeUpdateKey: (value: string) => value,
30
+ getUpdatePolicyByKey: getPolicy,
31
+ replaceUpdatePolicyByKey: replacePolicy,
32
+ UpdatePolicyConflictError: class UpdatePolicyConflictError extends Error {},
33
+ UpdatePolicyPublishedError: class UpdatePolicyPublishedError extends Error {},
34
+ }));
35
+
36
+ const context = {
37
+ params: Promise.resolve({ encodedKey: "encoded-update" }),
38
+ };
39
+ function request(method = "GET", body?: unknown) {
40
+ return new NextRequest(
41
+ "https://updates.example.com/api/admin/updates/encoded-update/policy",
42
+ {
43
+ method,
44
+ headers: {
45
+ authorization: "Bearer ota_test",
46
+ ...(body ? { "content-type": "application/json" } : {}),
47
+ },
48
+ ...(body ? { body: JSON.stringify(body) } : {}),
49
+ },
50
+ );
51
+ }
52
+
53
+ describe("update policy API", () => {
54
+ beforeEach(() => {
55
+ auth.scopes = [];
56
+ getPolicy.mockClear();
57
+ replacePolicy.mockReset();
58
+ });
59
+
60
+ it("requires updates:read for GET", async () => {
61
+ const { GET } = await import("./route");
62
+ expect((await GET(request(), context)).status).toBe(403);
63
+ expect(getPolicy).not.toHaveBeenCalled();
64
+
65
+ auth.scopes = ["updates:read"];
66
+ expect((await GET(request(), context)).status).toBe(200);
67
+ expect(getPolicy).toHaveBeenCalledWith("encoded-update");
68
+ });
69
+
70
+ it("requires updates:write for PUT", async () => {
71
+ auth.scopes = ["updates:read"];
72
+ const { PUT } = await import("./route");
73
+ const response = await PUT(
74
+ request("PUT", { delivery: "manual", guard: null }),
75
+ context,
76
+ );
77
+ expect(response.status).toBe(403);
78
+ expect(replacePolicy).not.toHaveBeenCalled();
79
+ });
80
+
81
+ it("performs complete replacement with optimistic policy version", async () => {
82
+ auth.scopes = ["updates:write"];
83
+ const guard = {
84
+ action: "require-confirmation",
85
+ payload: { message: "Ready" },
86
+ };
87
+ replacePolicy.mockResolvedValueOnce({
88
+ delivery: "background",
89
+ guard,
90
+ policyVersion: 4,
91
+ publishedAt: null,
92
+ editable: true,
93
+ });
94
+ const { PUT } = await import("./route");
95
+ const response = await PUT(
96
+ request("PUT", {
97
+ delivery: "background",
98
+ guard,
99
+ expectedPolicyVersion: 3,
100
+ }),
101
+ context,
102
+ );
103
+ expect(response.status).toBe(200);
104
+ expect(replacePolicy).toHaveBeenCalledWith(
105
+ "encoded-update",
106
+ { delivery: "background", guard },
107
+ 3,
108
+ );
109
+ });
110
+
111
+ it.each([
112
+ ["missing", undefined],
113
+ ["zero", 0],
114
+ ["fractional", 1.5],
115
+ ])("returns 400 for a %s expected policy version", async (_case, version) => {
116
+ auth.scopes = ["updates:write"];
117
+ const { PUT } = await import("./route");
118
+ const response = await PUT(
119
+ request("PUT", {
120
+ delivery: "manual",
121
+ guard: null,
122
+ ...(version === undefined
123
+ ? {}
124
+ : { expectedPolicyVersion: version }),
125
+ }),
126
+ context,
127
+ );
128
+
129
+ expect(response.status).toBe(400);
130
+ expect(replacePolicy).not.toHaveBeenCalled();
131
+ });
132
+
133
+ it("returns 409 for publication and stale version conflicts", async () => {
134
+ auth.scopes = ["updates:write"];
135
+ const { PUT } = await import("./route");
136
+ const { UpdatePolicyPublishedError, UpdatePolicyConflictError } =
137
+ await import("@/src/server/lib/admin-updates");
138
+
139
+ replacePolicy.mockRejectedValueOnce(
140
+ new UpdatePolicyPublishedError("published"),
141
+ );
142
+ expect(
143
+ (
144
+ await PUT(
145
+ request("PUT", {
146
+ delivery: "manual",
147
+ guard: null,
148
+ expectedPolicyVersion: 1,
149
+ }),
150
+ context,
151
+ )
152
+ ).status,
153
+ ).toBe(409);
154
+
155
+ replacePolicy.mockRejectedValueOnce(
156
+ new UpdatePolicyConflictError("conflict"),
157
+ );
158
+ expect(
159
+ (
160
+ await PUT(
161
+ request("PUT", {
162
+ delivery: "manual",
163
+ guard: null,
164
+ expectedPolicyVersion: 1,
165
+ }),
166
+ context,
167
+ )
168
+ ).status,
169
+ ).toBe(409);
170
+ });
171
+ });
@@ -0,0 +1,75 @@
1
+ import { requireAdminAccess } from "@/src/server/lib/admin-api";
2
+ import {
3
+ decodeUpdateKey,
4
+ getUpdatePolicyByKey,
5
+ replaceUpdatePolicyByKey,
6
+ UpdatePolicyConflictError,
7
+ UpdatePolicyPublishedError,
8
+ } from "@/src/server/lib/admin-updates";
9
+ import { UpdatePolicyValidationError } from "@/src/server/lib/update-policy";
10
+ import { NextRequest, NextResponse } from "next/server";
11
+
12
+ type RouteContext = {
13
+ params: Promise<{ encodedKey: string }>;
14
+ };
15
+
16
+ export async function GET(request: NextRequest, context: RouteContext) {
17
+ const session = await requireAdminAccess(request, "updates:read");
18
+ if (session instanceof NextResponse) {
19
+ return session;
20
+ }
21
+ try {
22
+ const { encodedKey } = await context.params;
23
+ return NextResponse.json(
24
+ await getUpdatePolicyByKey(decodeUpdateKey(encodedKey)),
25
+ );
26
+ } catch (error: unknown) {
27
+ return NextResponse.json(
28
+ { error: (error as Error).message || "Failed to fetch update policy" },
29
+ { status: 500 },
30
+ );
31
+ }
32
+ }
33
+
34
+ export async function PUT(request: NextRequest, context: RouteContext) {
35
+ const session = await requireAdminAccess(request, "updates:write");
36
+ if (session instanceof NextResponse) {
37
+ return session;
38
+ }
39
+ try {
40
+ const { encodedKey } = await context.params;
41
+ const body = await request.json();
42
+ if (
43
+ !Number.isInteger(body?.expectedPolicyVersion) ||
44
+ body.expectedPolicyVersion < 1
45
+ ) {
46
+ return NextResponse.json(
47
+ { error: "expectedPolicyVersion must be a positive integer." },
48
+ { status: 400 },
49
+ );
50
+ }
51
+ const policy = await replaceUpdatePolicyByKey(
52
+ decodeUpdateKey(encodedKey),
53
+ { delivery: body?.delivery, guard: body?.guard },
54
+ body?.expectedPolicyVersion,
55
+ );
56
+ return NextResponse.json(policy);
57
+ } catch (error: unknown) {
58
+ if (
59
+ error instanceof UpdatePolicyConflictError ||
60
+ error instanceof UpdatePolicyPublishedError
61
+ ) {
62
+ return NextResponse.json({ error: error.message }, { status: 409 });
63
+ }
64
+ if (
65
+ error instanceof UpdatePolicyValidationError ||
66
+ error instanceof SyntaxError
67
+ ) {
68
+ return NextResponse.json({ error: error.message }, { status: 400 });
69
+ }
70
+ return NextResponse.json(
71
+ { error: (error as Error).message || "Failed to update policy" },
72
+ { status: 500 },
73
+ );
74
+ }
75
+ }
@@ -4,6 +4,7 @@ import {
4
4
  promoteLatestByKey,
5
5
  } from "@/src/server/lib/admin-updates";
6
6
  import { NextRequest, NextResponse } from "next/server";
7
+ import { OtaDistributionBlockedError } from "@/src/server/lib/distribution-control";
7
8
 
8
9
  type RouteContext = {
9
10
  params: Promise<{ encodedKey: string }>;
@@ -23,7 +24,9 @@ export async function POST(request: NextRequest, context: RouteContext) {
23
24
  } catch (error: unknown) {
24
25
  return NextResponse.json(
25
26
  { error: (error as Error).message || "Failed to promote latest update" },
26
- { status: 500 },
27
+ {
28
+ status: error instanceof OtaDistributionBlockedError ? 409 : 500,
29
+ },
27
30
  );
28
31
  }
29
32
  }
@@ -4,6 +4,7 @@ import {
4
4
  rollbackToUpdateByKey,
5
5
  } from "@/src/server/lib/admin-updates";
6
6
  import { NextRequest, NextResponse } from "next/server";
7
+ import { OtaDistributionBlockedError } from "@/src/server/lib/distribution-control";
7
8
 
8
9
  type RouteContext = {
9
10
  params: Promise<{ encodedKey: string }>;
@@ -23,7 +24,9 @@ export async function POST(request: NextRequest, context: RouteContext) {
23
24
  } catch (error: unknown) {
24
25
  return NextResponse.json(
25
26
  { error: (error as Error).message || "Failed to rollback update" },
26
- { status: 500 },
27
+ {
28
+ status: error instanceof OtaDistributionBlockedError ? 409 : 500,
29
+ },
27
30
  );
28
31
  }
29
32
  }
@@ -6,6 +6,7 @@ import {
6
6
  updateJsonFileByKey,
7
7
  } from "@/src/server/lib/admin-updates";
8
8
  import { NextRequest, NextResponse } from "next/server";
9
+ import { OtaDistributionBlockedError } from "@/src/server/lib/distribution-control";
9
10
 
10
11
  type RouteContext = {
11
12
  params: Promise<{ encodedKey: string }>;
@@ -90,7 +91,9 @@ export async function PATCH(request: NextRequest, context: RouteContext) {
90
91
  } catch (error: unknown) {
91
92
  return NextResponse.json(
92
93
  { error: (error as Error).message || "Failed to update JSON" },
93
- { status: 500 },
94
+ {
95
+ status: error instanceof OtaDistributionBlockedError ? 409 : 500,
96
+ },
94
97
  );
95
98
  }
96
99
  }
@@ -22,7 +22,14 @@ const sessionAuth = vi.hoisted(() => ({
22
22
  }));
23
23
 
24
24
  const getUpdatesPage = vi.hoisted(() =>
25
- vi.fn(async () => ({
25
+ vi.fn(async (): Promise<{
26
+ items: Array<Record<string, unknown>>;
27
+ total: number;
28
+ page: number;
29
+ pageSize: number;
30
+ totalPages: number;
31
+ rollbackLockByScope: Array<Record<string, unknown>>;
32
+ }> => ({
26
33
  items: [],
27
34
  total: 0,
28
35
  page: 1,
@@ -89,6 +96,27 @@ describe("GET /api/admin/updates authorization", () => {
89
96
  expect(getUpdatesPage).toHaveBeenCalledOnce();
90
97
  });
91
98
 
99
+ it("returns the app version associated with each update", async () => {
100
+ tokenAuth.result = {
101
+ id: "token-id",
102
+ name: "CI",
103
+ scopes: ["updates:read"],
104
+ };
105
+ getUpdatesPage.mockResolvedValueOnce({
106
+ items: [{ updateId: "update-id", appVersion: "2.4.1" }],
107
+ total: 1,
108
+ page: 1,
109
+ pageSize: 20,
110
+ totalPages: 1,
111
+ rollbackLockByScope: [],
112
+ });
113
+ const { GET } = await import("./route");
114
+ const response = await GET(makeRequest("ota_test_token"));
115
+
116
+ expect(response.status).toBe(200);
117
+ expect((await response.json()).items[0].appVersion).toBe("2.4.1");
118
+ });
119
+
92
120
  it("rejects a bearer token without updates:read scope", async () => {
93
121
  tokenAuth.result = {
94
122
  id: "token-id",
@@ -10,9 +10,14 @@ import {
10
10
  } from "@/src/client/admin-api";
11
11
  import { UpdateDetail } from "@/src/client/admin-types";
12
12
  import LogoutButton from "@/src/client/logout-button";
13
+ import UpdatePolicyEditor from "@/src/client/update-policy-editor";
13
14
  import Link from "next/link";
14
15
  import { useParams, useRouter } from "next/navigation";
15
16
  import { useEffect, useMemo, useState } from "react";
17
+ import {
18
+ DistributionControlBanner,
19
+ useDistributionControlState,
20
+ } from "@/src/client/distribution-control";
16
21
 
17
22
  type EditableFile =
18
23
  | "update-info.json"
@@ -37,6 +42,13 @@ export default function UpdateDetailsPage() {
37
42
  const [selectedFile, setSelectedFile] =
38
43
  useState<EditableFile>("update-info.json");
39
44
  const [editorValue, setEditorValue] = useState("{}");
45
+ const distributionControl = useDistributionControlState();
46
+ const distributionUnavailable =
47
+ distributionControl.loading ||
48
+ Boolean(distributionControl.error) ||
49
+ !distributionControl.state;
50
+ const distributionBlocked =
51
+ distributionControl.state?.blocked === true || distributionUnavailable;
40
52
 
41
53
  const channelState = useMemo(() => {
42
54
  const latestUpdateId =
@@ -75,10 +87,13 @@ export default function UpdateDetailsPage() {
75
87
  }, [detail]);
76
88
 
77
89
  const canPromote = Boolean(
78
- channelState.isNewestInScope && channelState.rollbackActive,
90
+ !distributionBlocked &&
91
+ channelState.isNewestInScope &&
92
+ channelState.rollbackActive,
79
93
  );
80
94
  const canRollback = Boolean(
81
95
  detail &&
96
+ !distributionBlocked &&
82
97
  !channelState.isNewestInScope &&
83
98
  channelState.currentServedUpdateId &&
84
99
  detail.updateId !== channelState.currentServedUpdateId,
@@ -88,6 +103,7 @@ export default function UpdateDetailsPage() {
88
103
  );
89
104
  const canDirectActivate = Boolean(
90
105
  detail &&
106
+ !distributionBlocked &&
91
107
  detail.status === "disabled" &&
92
108
  channelState.isNewestInScope &&
93
109
  !channelState.rollbackActive,
@@ -98,7 +114,26 @@ export default function UpdateDetailsPage() {
98
114
  const showToggleDisabledButton = canDirectActivate || canDirectDeactivate;
99
115
  const canDelete = Boolean(detail && detail.status !== "active");
100
116
  const channelLatestLocked =
101
- selectedFile === "channel-latest.json" && channelState.rollbackActive;
117
+ selectedFile === "channel-latest.json" &&
118
+ (channelState.rollbackActive || distributionBlocked);
119
+
120
+ const updateMetaDistributionLocked = useMemo(() => {
121
+ if (selectedFile !== "update-meta.json" || !distributionBlocked) {
122
+ return false;
123
+ }
124
+ try {
125
+ const value: unknown = JSON.parse(editorValue);
126
+ return (
127
+ !value ||
128
+ typeof value !== "object" ||
129
+ Array.isArray(value) ||
130
+ !("isActive" in value) ||
131
+ value.isActive !== false
132
+ );
133
+ } catch {
134
+ return true;
135
+ }
136
+ }, [distributionBlocked, editorValue, selectedFile]);
102
137
 
103
138
  const fileContent = useMemo(() => {
104
139
  if (!detail) {
@@ -301,6 +336,12 @@ export default function UpdateDetailsPage() {
301
336
  </div>
302
337
  ) : null}
303
338
 
339
+ <DistributionControlBanner
340
+ state={distributionControl.state}
341
+ loading={distributionControl.loading}
342
+ error={distributionControl.error}
343
+ />
344
+
304
345
  {!loading && detail ? (
305
346
  <>
306
347
  {channelState.rollbackActive ? (
@@ -347,7 +388,18 @@ export default function UpdateDetailsPage() {
347
388
  />
348
389
  <Info
349
390
  label="Доставка"
350
- value={detail.isIgnoredByRollback ? "Ignored" : "Auto"}
391
+ value={
392
+ detail.isIgnoredByRollback
393
+ ? "Ignored by rollback"
394
+ : detail.deliveryMode === "background"
395
+ ? "Background"
396
+ : "Manual"
397
+ }
398
+ />
399
+ <Info label="Guard" value={detail.hasGuard ? "Yes" : "None"} />
400
+ <Info
401
+ label="Policy"
402
+ value={`v${detail.policyVersion} · ${detail.policyEditable ? "draft" : "published"}`}
351
403
  />
352
404
  <Info label="Assets" value={String(detail.assetsCount)} />
353
405
  <Info
@@ -367,6 +419,12 @@ export default function UpdateDetailsPage() {
367
419
  />
368
420
  </section>
369
421
 
422
+ <UpdatePolicyEditor
423
+ key={`${encodedKey}-${detail.policyVersion}-${detail.policyPublishedAt || "draft"}`}
424
+ encodedKey={encodedKey}
425
+ onSaved={reload}
426
+ />
427
+
370
428
  <section className="rounded-xl border border-zinc-200 bg-white p-4 dark:border-zinc-800 dark:bg-zinc-900">
371
429
  <div className="flex flex-wrap gap-2">
372
430
  {canRollback ? (
@@ -435,7 +493,11 @@ export default function UpdateDetailsPage() {
435
493
  <button
436
494
  type="button"
437
495
  onClick={handleSaveJson}
438
- disabled={saving || channelLatestLocked}
496
+ disabled={
497
+ saving ||
498
+ channelLatestLocked ||
499
+ updateMetaDistributionLocked
500
+ }
439
501
  className="rounded-md border border-zinc-300 px-4 py-4 text-sm hover:bg-zinc-100 disabled:cursor-not-allowed disabled:opacity-60 dark:border-zinc-700 dark:hover:bg-zinc-800"
440
502
  >
441
503
  Сохранить JSON
@@ -443,8 +505,14 @@ export default function UpdateDetailsPage() {
443
505
  </div>
444
506
  {channelLatestLocked ? (
445
507
  <p className="mt-2 text-xs text-orange-700 dark:text-orange-300">
446
- Редактирование channel latest.json заблокировано: rollback
447
- активен. Используйте Promote.
508
+ Редактирование channel latest.json заблокировано: активен
509
+ rollback или глобальный аварийный выключатель.
510
+ </p>
511
+ ) : null}
512
+ {updateMetaDistributionLocked ? (
513
+ <p className="mt-2 text-xs text-red-700 dark:text-red-300">
514
+ Активация через update-meta.json недоступна при глобальной
515
+ блокировке. Деактивация с isActive=false остаётся доступна.
448
516
  </p>
449
517
  ) : null}
450
518
  <textarea
@@ -102,6 +102,7 @@ export default function EmbeddedUpdatesPage() {
102
102
  <thead className="bg-zinc-100 dark:bg-zinc-800">
103
103
  <tr>
104
104
  <th className="px-4 py-4 text-left">Created At</th>
105
+ <th className="px-4 py-4 text-left">App version</th>
105
106
  <th className="px-4 py-4 text-left">Platform</th>
106
107
  <th className="px-4 py-4 text-left">Channel</th>
107
108
  <th className="px-4 py-4 text-left">Embedded ID</th>
@@ -111,7 +112,7 @@ export default function EmbeddedUpdatesPage() {
111
112
  <tbody>
112
113
  {loading ? (
113
114
  <tr>
114
- <td className="px-3 py-4 text-zinc-500" colSpan={5}>
115
+ <td className="px-3 py-4 text-zinc-500" colSpan={6}>
115
116
  Загрузка...
116
117
  </td>
117
118
  </tr>
@@ -119,7 +120,7 @@ export default function EmbeddedUpdatesPage() {
119
120
 
120
121
  {!loading && items.length === 0 ? (
121
122
  <tr>
122
- <td className="px-3 py-4 text-zinc-500" colSpan={5}>
123
+ <td className="px-3 py-4 text-zinc-500" colSpan={6}>
123
124
  Embedded записи не найдены
124
125
  </td>
125
126
  </tr>
@@ -134,6 +135,9 @@ export default function EmbeddedUpdatesPage() {
134
135
  <td className="px-4 py-4">
135
136
  {new Date(item.createdAt).toLocaleString("uk-UA")}
136
137
  </td>
138
+ <td className="px-4 py-4">
139
+ {item.appVersion || "—"}
140
+ </td>
137
141
  <td className="px-4 py-4">{item.platform}</td>
138
142
  <td className="px-4 py-4">{item.channel}</td>
139
143
  <td className="px-4 py-4 font-mono text-xs">
@@ -3,6 +3,7 @@
3
3
  import { getUpdates } from "@/src/client/admin-api";
4
4
  import { UpdateItem } from "@/src/client/admin-types";
5
5
  import LogoutButton from "@/src/client/logout-button";
6
+ import DistributionControl from "@/src/client/distribution-control";
6
7
  import Link from "next/link";
7
8
  import { useCallback, useEffect, useState } from "react";
8
9
 
@@ -124,6 +125,8 @@ export default function UpdatesPage() {
124
125
  </div>
125
126
  </header>
126
127
 
128
+ <DistributionControl />
129
+
127
130
  {error ? (
128
131
  <div className="rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300">
129
132
  {error}
@@ -160,6 +163,7 @@ export default function UpdatesPage() {
160
163
  <tr>
161
164
  <th className="px-4 py-4 text-left">Дата</th>
162
165
  <th className="px-4 py-4 text-left">Runtime</th>
166
+ <th className="px-4 py-4 text-left">App version</th>
163
167
  <th className="px-4 py-4 text-left">Платформа</th>
164
168
  <th className="px-4 py-4 text-left">Канал</th>
165
169
  <th className="px-4 py-4 text-left">Комментарий</th>
@@ -174,7 +178,7 @@ export default function UpdatesPage() {
174
178
  <tbody>
175
179
  {loading ? (
176
180
  <tr>
177
- <td className="px-3 py-4 text-zinc-500" colSpan={11}>
181
+ <td className="px-3 py-4 text-zinc-500" colSpan={12}>
178
182
  Загрузка...
179
183
  </td>
180
184
  </tr>
@@ -182,7 +186,7 @@ export default function UpdatesPage() {
182
186
 
183
187
  {!loading && items.length === 0 ? (
184
188
  <tr>
185
- <td className="px-3 py-4 text-zinc-500" colSpan={11}>
189
+ <td className="px-3 py-4 text-zinc-500" colSpan={12}>
186
190
  Апдейты не найдены
187
191
  </td>
188
192
  </tr>
@@ -203,6 +207,9 @@ export default function UpdatesPage() {
203
207
  item.createdAtPath}
204
208
  </td>
205
209
  <td className="px-4 py-4">{item.runtimeVersion}</td>
210
+ <td className="px-4 py-4">
211
+ {item.appVersion || "—"}
212
+ </td>
206
213
  <td className="px-4 py-4">{item.platform}</td>
207
214
  <td className="px-4 py-4">{item.channel}</td>
208
215
  <td className="px-4 py-4">
@@ -216,6 +223,23 @@ export default function UpdatesPage() {
216
223
  <td className="px-4 py-4">{item.stage}</td>
217
224
  <td className="px-4 py-4">{item.status}</td>
218
225
  <td className="px-4 py-4">
226
+ <div className="flex flex-wrap gap-1">
227
+ <span
228
+ className={`rounded border px-2 py-0.5 text-xs ${
229
+ item.deliveryMode === "background"
230
+ ? "border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300"
231
+ : "border-zinc-300 text-zinc-700 dark:border-zinc-600 dark:text-zinc-300"
232
+ }`}
233
+ >
234
+ {item.deliveryMode === "background"
235
+ ? "Background"
236
+ : "Manual"}
237
+ </span>
238
+ {item.hasGuard ? (
239
+ <span className="rounded border border-violet-300 px-2 py-0.5 text-xs text-violet-700 dark:border-violet-700 dark:text-violet-300">
240
+ Guard
241
+ </span>
242
+ ) : null}
219
243
  {item.isRollbackActive ? (
220
244
  <span className="rounded border border-amber-300 px-2 py-0.5 text-xs text-amber-800 dark:border-amber-700 dark:text-amber-300">
221
245
  rollback
@@ -226,9 +250,10 @@ export default function UpdatesPage() {
226
250
  </span>
227
251
  ) : (
228
252
  <span className="rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 dark:border-emerald-700 dark:text-emerald-300">
229
- auto
253
+ scope open
230
254
  </span>
231
255
  )}
256
+ </div>
232
257
  </td>
233
258
  <td className="px-4 py-4">
234
259
  {item.isLatest ? "Да" : "Нет"}
@@ -372,6 +372,7 @@ native binary registers its embedded update:
372
372
 
373
373
  ```text
374
374
  embedded_update_id
375
+ app_version
375
376
  created_at
376
377
  channel
377
378
  platform
@@ -383,6 +384,12 @@ Register the value after each iOS and Android release build in
383
384
  generated Expo embedded manifest, not from a random value created before the
384
385
  build.
385
386
 
387
+ For `app_version`, the registrar keeps a version found in the embedded
388
+ manifest as the highest-priority value. Expo SDKs that omit it there fall back
389
+ to the trimmed string `expo.version` from the project's static `app.json`.
390
+ Missing, blank, malformed or unreadable fallback configuration leaves
391
+ `app_version` null without blocking an otherwise valid registration.
392
+
386
393
  The MIEX application contains a reference implementation:
387
394
 
388
395
  ```text
@@ -457,9 +464,13 @@ Create a dedicated access token with `npm run create-access-token` (or
457
464
 
458
465
  The app configurator installs:
459
466
 
460
- - Android APK/AAB build commands that register `app.manifest` after Gradle;
461
- - an iOS Xcode Build Phase for local Release/Archive builds;
462
- - `ci_scripts/ci_post_xcodebuild.sh` for Xcode Cloud.
467
+ - Android APK/AAB build commands that invoke
468
+ `scripts/ota-register-embedded/register-android.sh` after Gradle;
469
+ - an iOS Xcode Build Phase that invokes
470
+ `scripts/ota-register-embedded/register-ios.sh` for local Release/Archive
471
+ builds;
472
+ - `ci_scripts/ci_post_xcodebuild.sh`, a thin Xcode Cloud adapter that invokes
473
+ the same `register-ios.sh`.
463
474
 
464
475
  Registered binaries are visible at `/updates/embedded`.
465
476