create-expo-updates-server 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/template/Dockerfile +4 -6
- package/dist/template/README.md +4 -9
- package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
- package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
- package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
- package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
- package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
- package/dist/template/app/api/admin/updates/route.test.ts +21 -0
- package/dist/template/app/api/admin/updates/route.ts +12 -1
- package/dist/template/app/globals.css +65 -68
- package/dist/template/app/login/page.tsx +66 -42
- package/dist/template/app/updates/[encodedKey]/page.tsx +375 -263
- package/dist/template/app/updates/devices/page.tsx +188 -152
- package/dist/template/app/updates/embedded/page.tsx +63 -29
- package/dist/template/app/updates/emergency-redirects/page.tsx +93 -58
- package/dist/template/app/updates/layout.tsx +2 -1
- package/dist/template/app/updates/page.tsx +381 -283
- package/dist/template/app/updates/releases.test.tsx +156 -0
- package/dist/template/components/admin/admin-role.ts +5 -0
- package/dist/template/components/admin/admin-shell.tsx +166 -101
- package/dist/template/components/admin/confirm-action.tsx +123 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -17
- package/dist/template/components/admin/release-badges.test.tsx +50 -0
- package/dist/template/components/admin/release-badges.tsx +101 -0
- package/dist/template/components/ui/alert.tsx +10 -3
- package/dist/template/components/ui/avatar.tsx +108 -0
- package/dist/template/components/ui/badge.tsx +2 -2
- package/dist/template/components/ui/breadcrumb.tsx +108 -0
- package/dist/template/components/ui/button.tsx +5 -5
- package/dist/template/components/ui/card.tsx +2 -2
- package/dist/template/components/ui/chart.tsx +1 -1
- package/dist/template/components/ui/collapsible.tsx +7 -0
- package/dist/template/components/ui/empty.tsx +103 -0
- package/dist/template/components/ui/field.tsx +248 -0
- package/dist/template/components/ui/input-group.tsx +170 -0
- package/dist/template/components/ui/input.tsx +1 -1
- package/dist/template/components/ui/native-select.tsx +1 -1
- package/dist/template/components/ui/radio-group.tsx +41 -0
- package/dist/template/components/ui/status-tones.ts +15 -0
- package/dist/template/components/ui/table.tsx +1 -1
- package/dist/template/components/ui/textarea.tsx +1 -1
- package/dist/template/docs/admin-ui.md +7 -3
- package/dist/template/docs/device-targeting.md +2 -7
- package/dist/template/docs/doctor.md +2 -2
- package/dist/template/docs/expo-app-setup.md +9 -27
- package/dist/template/docs/getting-started.md +3 -4
- package/dist/template/docs/installation-telemetry.md +2 -8
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
- package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
- package/dist/template/docs/migrations/schema.sql +349 -0
- package/dist/template/docs/npm-installer.md +3 -3
- package/dist/template/docs/operations-guide.md +8 -6
- package/dist/template/docs/ota-client-lifecycle.md +30 -68
- package/dist/template/docs/ota-update-policy.md +9 -20
- package/dist/template/docs/ru/admin-ui.md +7 -3
- package/dist/template/docs/ru/device-targeting.md +2 -2
- package/dist/template/docs/ru/doctor.md +2 -2
- package/dist/template/docs/ru/expo-app-setup.md +9 -9
- package/dist/template/docs/ru/getting-started.md +3 -3
- package/dist/template/docs/ru/installation-telemetry.md +2 -2
- package/dist/template/docs/ru/npm-installer.md +3 -3
- package/dist/template/docs/ru/operations-guide.md +8 -3
- package/dist/template/docs/ru/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/ru/ota-update-policy.md +9 -7
- package/dist/template/docs/ru/publishing-npm-installer.md +2 -2
- package/dist/template/docs/uk/admin-ui.md +7 -3
- package/dist/template/docs/uk/device-targeting.md +2 -2
- package/dist/template/docs/uk/doctor.md +2 -2
- package/dist/template/docs/uk/expo-app-setup.md +9 -9
- package/dist/template/docs/uk/getting-started.md +3 -3
- package/dist/template/docs/uk/installation-telemetry.md +2 -2
- package/dist/template/docs/uk/npm-installer.md +3 -3
- package/dist/template/docs/uk/operations-guide.md +8 -3
- package/dist/template/docs/uk/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/uk/ota-update-policy.md +9 -7
- package/dist/template/docs/uk/publishing-npm-installer.md +2 -2
- package/dist/template/lib/audience-ids.ts +4 -0
- package/dist/template/package-lock.json +46 -0
- package/dist/template/package.json +3 -1
- package/dist/template/scripts/configure-expo-app.mjs +3 -3
- package/dist/template/scripts/create-access-token.mjs +1 -1
- package/dist/template/scripts/lib/doctor.mjs +10 -7
- package/dist/template/scripts/lib/doctor.test.mjs +7 -5
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
- package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
- package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
- package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
- package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
- package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
- package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
- package/dist/template/scripts/tests/e2e/console.mjs +86 -0
- package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
- package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
- package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
- package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
- package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
- package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
- package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
- package/dist/template/scripts/tests/e2e/run.mjs +224 -0
- package/dist/template/scripts/tests/manifest-identity.sql +7 -5
- package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
- package/dist/template/src/client/admin-api.ts +45 -10
- package/dist/template/src/client/admin-types.ts +35 -1
- package/dist/template/src/client/devices/analytics.tsx +168 -231
- package/dist/template/src/client/devices/cohorts.tsx +181 -0
- package/dist/template/src/client/devices/device-name.tsx +37 -23
- package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
- package/dist/template/src/client/devices/registry.tsx +258 -245
- package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
- package/dist/template/src/client/devices/use-devices-report.ts +53 -82
- package/dist/template/src/client/devices/version-adoption-chart.tsx +47 -49
- package/dist/template/src/client/distribution-control.tsx +89 -57
- package/dist/template/src/client/distribution-history.tsx +353 -0
- package/dist/template/src/client/guard-action-catalog.tsx +183 -0
- package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
- package/dist/template/src/client/guard-action-combobox.tsx +133 -239
- package/dist/template/src/client/guard-action-options.ts +4 -6
- package/dist/template/src/client/i18n/en.json +133 -2
- package/dist/template/src/client/i18n/language-switching.test.tsx +12 -3
- package/dist/template/src/client/i18n/ru.json +133 -2
- package/dist/template/src/client/i18n/uk.json +133 -2
- package/dist/template/src/client/logout-button.tsx +3 -3
- package/dist/template/src/client/policy-draft.ts +138 -0
- package/dist/template/src/client/update-audience-editor.tsx +597 -206
- package/dist/template/src/client/update-policy-editor.test.ts +101 -29
- package/dist/template/src/client/update-policy-editor.tsx +454 -320
- package/dist/template/src/client/use-filtered-results.ts +55 -0
- package/dist/template/src/server/controllers/manifest.test.ts +23 -3
- package/dist/template/src/server/controllers/manifest.ts +15 -1
- package/dist/template/src/server/devices/audience.ts +9 -5
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
- package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
- package/dist/template/src/server/lib/admin-updates.ts +160 -534
- package/dist/template/src/server/lib/distribution-history.ts +97 -0
- package/dist/template/src/server/lib/supabase.js +24 -0
- package/dist/template/src/server/lib/supabase.test.ts +38 -1
- package/dist/template/src/server/lib/update-policy.test.ts +20 -0
- package/dist/template/src/server/lib/update-policy.ts +23 -10
- package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
- package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
- package/dist/template/src/server/manifest/manifest-values.ts +21 -13
- package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
- package/dist/template/tsconfig.json +2 -2
- package/dist/template-manifest.json +446 -301
- package/package.json +1 -1
- package/dist/template/scripts/lib/device-identity.test.ts +0 -29
- package/dist/template/scripts/lib/ota-client.test.ts +0 -55
- package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
- package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
- package/dist/template/templates/expo-app/ota-client/README.md +0 -73
- package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
- package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
- package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
- package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
|
@@ -179,7 +179,7 @@ begin
|
|
|
179
179
|
raise exception 'Historical mapping was modified';
|
|
180
180
|
end if;
|
|
181
181
|
|
|
182
|
-
--
|
|
182
|
+
-- Legacy publishers asking for an active insert still create only a draft.
|
|
183
183
|
insert into public.ota_update_channels (runtime_version, channel, platform)
|
|
184
184
|
values (test_scope, test_scope || '-insert', 'android')
|
|
185
185
|
returning served_manifest_id, served_manifest_changed_at
|
|
@@ -193,10 +193,12 @@ begin
|
|
|
193
193
|
);
|
|
194
194
|
select * into strict current_channel from public.ota_update_channels
|
|
195
195
|
where runtime_version = test_scope and channel = test_scope || '-insert';
|
|
196
|
-
if current_channel.served_manifest_id
|
|
197
|
-
or
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
if current_channel.served_manifest_id <> previous_epoch
|
|
197
|
+
or current_channel.served_manifest_changed_at <> previous_time or exists (
|
|
198
|
+
select 1 from public.ota_updates where runtime_version=test_scope and channel=test_scope||'-insert'
|
|
199
|
+
and (is_active or policy_published_at is not null)
|
|
200
|
+
) then
|
|
201
|
+
raise exception 'Draft insert changed delivery state';
|
|
200
202
|
end if;
|
|
201
203
|
end;
|
|
202
204
|
$$;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Run against an empty disposable database owned by the connection role.
|
|
2
|
+
// OTA_TEST_DATABASE_URL=... node scripts/tests/public-distribution-history.mjs
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { Pool } from "pg";
|
|
7
|
+
import { writeDatabaseRecords } from "../../templates/expo-app/scripts/ota-publish/api/database-client.mjs";
|
|
8
|
+
|
|
9
|
+
if (!process.env.OTA_TEST_DATABASE_URL) throw new Error("Set OTA_TEST_DATABASE_URL to an empty disposable database");
|
|
10
|
+
const db = new Pool({ connectionString: process.env.OTA_TEST_DATABASE_URL, max: 4, statement_timeout: 15000 });
|
|
11
|
+
const schema = await readFile(new URL("../../docs/migrations/schema.sql", import.meta.url), "utf8");
|
|
12
|
+
const migration = await readFile(new URL("../../docs/migrations/2026-11-25-public-distribution-history.sql", import.meta.url), "utf8");
|
|
13
|
+
const marker = schema.indexOf(migration.trim());
|
|
14
|
+
assert.ok(marker > 0, "Migration must match the canonical schema");
|
|
15
|
+
const runtime = "history-" + randomUUID();
|
|
16
|
+
const device = "c".repeat(64);
|
|
17
|
+
const changes = (id, action, rev = null) => db.query("select * from ota_change_distribution($1,$2,$3)", [id, action, rev]);
|
|
18
|
+
const history = async () => (await db.query("select * from ota_distribution_history where runtime_version=$1", [runtime])).rows[0];
|
|
19
|
+
const eligible = async (identity = null) => (await db.query("select update_id from ota_latest_eligible_update($1,'test','ios',null,$2)", [runtime, identity])).rows[0]?.update_id;
|
|
20
|
+
let count = 0;
|
|
21
|
+
function artifact() {
|
|
22
|
+
const id = randomUUID();
|
|
23
|
+
return {
|
|
24
|
+
id, updateId: id, runtimeVersion: runtime, channel: "test", platform: "ios", assets: [],
|
|
25
|
+
launchAsset: { path: "bundle.js" }, createdAt: new Date(Date.UTC(2024, 0, 1, 0, ++count)).toISOString(),
|
|
26
|
+
createdAtPath: id, storageBucket: "fixture", storageBasePath: id, comment: "Fixture",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const publish = async () => {
|
|
30
|
+
const u = artifact();
|
|
31
|
+
await writeDatabaseRecords(db, u, u);
|
|
32
|
+
return u;
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
assert.equal((await db.query("select to_regclass('public.ota_updates') as existing")).rows[0].existing, null,
|
|
36
|
+
"Refusing a database with OTA tables");
|
|
37
|
+
await db.query(schema.slice(0, marker));
|
|
38
|
+
const dormant = await publish();
|
|
39
|
+
const legacyA = await publish();
|
|
40
|
+
const legacyB = await publish();
|
|
41
|
+
await db.query("update ota_updates set is_active=true,disabled_at=null where update_id=$1", [legacyA.id]);
|
|
42
|
+
await db.query("select * from ota_replace_audience($1,'devices','[]',$2,1)", [legacyB.id, JSON.stringify([device])]);
|
|
43
|
+
await db.query("update ota_updates set is_active=true,disabled_at=null where update_id=$1", [legacyB.id]);
|
|
44
|
+
await db.query("select * from ota_replace_audience($1,'all','[]','[]',2)", [legacyB.id]);
|
|
45
|
+
await db.query("update ota_update_channels set latest_update_id=$1 where runtime_version=$2", [legacyB.id, runtime]);
|
|
46
|
+
assert.equal((await db.query("select count(*)::int as n from ota_updates where is_active")).rows[0].n, 2);
|
|
47
|
+
|
|
48
|
+
await db.query(migration);
|
|
49
|
+
await db.query(migration);
|
|
50
|
+
const baseline = await history();
|
|
51
|
+
assert.equal(baseline.current_release.updateId, legacyB.id);
|
|
52
|
+
assert.equal(baseline.current_release.activatedAt, null);
|
|
53
|
+
assert.equal(baseline.previous_release, null, "historical public audiences cannot be inferred on upgrade");
|
|
54
|
+
assert.equal((await db.query("select count(*)::int as n from ota_public_distribution_events")).rows[0].n, 1);
|
|
55
|
+
assert.equal((await db.query("select is_active from ota_updates where update_id=$1", [legacyA.id])).rows[0].is_active, false);
|
|
56
|
+
await assert.rejects(changes(dormant.id, "restore", baseline.revision), /DISTRIBUTION_CONFLICT/);
|
|
57
|
+
|
|
58
|
+
const smoke = await publish();
|
|
59
|
+
await db.query("select * from ota_replace_audience($1,'devices','[]',$2,1)", [smoke.id, JSON.stringify([device])]);
|
|
60
|
+
await changes(smoke.id, "activate");
|
|
61
|
+
assert.equal((await history()).revision, baseline.revision);
|
|
62
|
+
assert.equal(await eligible(device), smoke.id);
|
|
63
|
+
const b = await publish();
|
|
64
|
+
await changes(b.id, "activate");
|
|
65
|
+
await writeDatabaseRecords(db, b, b);
|
|
66
|
+
assert.equal(await eligible(), b.id, "publisher retry must leave the active release intact");
|
|
67
|
+
for (let i = 0; i < 5; i++) await publish();
|
|
68
|
+
assert.equal((await history()).previous_release.updateId, legacyB.id);
|
|
69
|
+
await changes(b.id, "stop");
|
|
70
|
+
assert.equal(await eligible(), undefined);
|
|
71
|
+
const stopped = await history();
|
|
72
|
+
assert.equal(stopped.current_release, null);
|
|
73
|
+
assert.equal(stopped.previous_release.updateId, legacyB.id);
|
|
74
|
+
await db.query("update ota_distribution_control set blocked=true,reason='private test' where singleton_id=1");
|
|
75
|
+
await publish(); // draft uploads during an incident cannot touch serving pointers
|
|
76
|
+
await assert.rejects(changes(legacyB.id, "restore", stopped.revision), /OTA_DISTRIBUTION_BLOCKED/);
|
|
77
|
+
assert.equal((await history()).revision, stopped.revision);
|
|
78
|
+
await db.query("update ota_distribution_control set blocked=false,reason=null where singleton_id=1");
|
|
79
|
+
const results = await Promise.allSettled([
|
|
80
|
+
changes(legacyB.id, "restore", stopped.revision), changes(legacyB.id, "restore", stopped.revision),
|
|
81
|
+
]);
|
|
82
|
+
assert.equal(results.filter((r) => r.status === "fulfilled").length, 1);
|
|
83
|
+
assert.match(results.find((r) => r.status === "rejected").reason.message, /DISTRIBUTION_CONFLICT/);
|
|
84
|
+
const restored = await history();
|
|
85
|
+
assert.equal(restored.current_release.updateId, legacyB.id);
|
|
86
|
+
assert.ok(restored.current_release.activatedAt);
|
|
87
|
+
assert.equal(restored.previous_release.updateId, b.id);
|
|
88
|
+
assert.equal(await eligible(), legacyB.id);
|
|
89
|
+
assert.equal(await eligible(device), smoke.id, "public restoration leaves the smoke audience intact");
|
|
90
|
+
await db.query("select * from ota_replace_audience($1,'devices','[]',$2,1)", [b.id, JSON.stringify([device])]);
|
|
91
|
+
await assert.rejects(changes(b.id, "restore", restored.revision), /DISTRIBUTION_CONFLICT/);
|
|
92
|
+
await changes(legacyB.id, "retire");
|
|
93
|
+
await assert.rejects(changes(legacyB.id, "activate"), /being deleted/);
|
|
94
|
+
await changes(legacyB.id, "retire"); // a failed storage request can retry cleanup
|
|
95
|
+
await changes(legacyB.id, "delete");
|
|
96
|
+
await assert.rejects(changes(legacyB.id, "restore", restored.revision), /no longer exists/);
|
|
97
|
+
assert.equal(await eligible(), undefined);
|
|
98
|
+
assert.equal((await history()).current_release, null);
|
|
99
|
+
console.log("PASS: duplicate legacy public rows, honest baseline, inactive publication and retry, scoped smoke, public replacement/stop, blocked/stale/concurrent restore, deletion and changed audience");
|
|
100
|
+
} finally {
|
|
101
|
+
await db.end();
|
|
102
|
+
}
|
|
@@ -2,12 +2,14 @@ import {
|
|
|
2
2
|
AdminSessionResponse,
|
|
3
3
|
DistributionControlResponse,
|
|
4
4
|
DistributionControlState,
|
|
5
|
+
DistributionHistoryResponse,
|
|
5
6
|
EmbeddedUpdatesListResponse,
|
|
6
7
|
EmergencyRedirectInput,
|
|
7
8
|
EmergencyRedirectItem,
|
|
8
9
|
EmergencyRedirectsListResponse,
|
|
9
10
|
GuardActionItem,
|
|
10
11
|
GuardActionsListResponse,
|
|
12
|
+
ReleaseFilters,
|
|
11
13
|
UpdateDetail,
|
|
12
14
|
UpdatePolicy,
|
|
13
15
|
UpdatesListResponse,
|
|
@@ -33,6 +35,26 @@ async function parseJson<T>(response: Response): Promise<T> {
|
|
|
33
35
|
return data as T;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
export async function getDistributionHistory(signal?: AbortSignal) {
|
|
39
|
+
const response = await fetch("/api/admin/distribution-history", {
|
|
40
|
+
cache: "no-store",
|
|
41
|
+
signal,
|
|
42
|
+
});
|
|
43
|
+
return parseJson<DistributionHistoryResponse>(response);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function restorePreviousRelease(
|
|
47
|
+
updateId: string,
|
|
48
|
+
expectedRevision: string,
|
|
49
|
+
) {
|
|
50
|
+
const response = await fetch("/api/admin/distribution-history/restore", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: { "Content-Type": "application/json" },
|
|
53
|
+
body: JSON.stringify({ updateId, expectedRevision }),
|
|
54
|
+
});
|
|
55
|
+
return parseJson<{ ok: true }>(response);
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
export async function getDistributionControl() {
|
|
37
59
|
const response = await fetch("/api/admin/distribution-control", {
|
|
38
60
|
cache: "no-store",
|
|
@@ -73,12 +95,15 @@ export async function getAdminSession() {
|
|
|
73
95
|
return parseJson<AdminSessionResponse>(response);
|
|
74
96
|
}
|
|
75
97
|
|
|
76
|
-
export async function getUpdates(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
export async function getUpdates(
|
|
99
|
+
params: Partial<ReleaseFilters> & {
|
|
100
|
+
page: number;
|
|
101
|
+
pageSize: number;
|
|
102
|
+
sortBy: string;
|
|
103
|
+
order: "asc" | "desc";
|
|
104
|
+
},
|
|
105
|
+
signal?: AbortSignal,
|
|
106
|
+
) {
|
|
82
107
|
const query = new URLSearchParams({
|
|
83
108
|
page: String(params.page),
|
|
84
109
|
pageSize: String(params.pageSize),
|
|
@@ -86,15 +111,27 @@ export async function getUpdates(params: {
|
|
|
86
111
|
order: params.order,
|
|
87
112
|
});
|
|
88
113
|
|
|
114
|
+
for (const key of [
|
|
115
|
+
"q",
|
|
116
|
+
"platform",
|
|
117
|
+
"channel",
|
|
118
|
+
"runtime",
|
|
119
|
+
"status",
|
|
120
|
+
"audience",
|
|
121
|
+
] as const) {
|
|
122
|
+
if (params[key]) query.set(key, params[key]);
|
|
123
|
+
}
|
|
89
124
|
const response = await fetch(`/api/admin/updates?${query.toString()}`, {
|
|
125
|
+
signal,
|
|
90
126
|
cache: "no-store",
|
|
91
127
|
});
|
|
92
128
|
|
|
93
129
|
return parseJson<UpdatesListResponse>(response);
|
|
94
130
|
}
|
|
95
131
|
|
|
96
|
-
export async function getUpdate(encodedKey: string) {
|
|
132
|
+
export async function getUpdate(encodedKey: string, signal?: AbortSignal) {
|
|
97
133
|
const response = await fetch(`/api/admin/updates/${encodedKey}`, {
|
|
134
|
+
signal,
|
|
98
135
|
cache: "no-store",
|
|
99
136
|
});
|
|
100
137
|
|
|
@@ -199,9 +236,7 @@ export async function getEmergencyRedirects() {
|
|
|
199
236
|
return parseJson<EmergencyRedirectsListResponse>(response);
|
|
200
237
|
}
|
|
201
238
|
|
|
202
|
-
export async function createEmergencyRedirect(
|
|
203
|
-
input: EmergencyRedirectInput,
|
|
204
|
-
) {
|
|
239
|
+
export async function createEmergencyRedirect(input: EmergencyRedirectInput) {
|
|
205
240
|
const response = await fetch("/api/admin/emergency-redirects", {
|
|
206
241
|
method: "POST",
|
|
207
242
|
headers: { "Content-Type": "application/json" },
|
|
@@ -24,7 +24,7 @@ export type UpdateItem = {
|
|
|
24
24
|
policyEditable: boolean;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export type UpdateDeliveryMode = "manual" | "background";
|
|
27
|
+
export type UpdateDeliveryMode = "manual" | "background" | "manual-postpone";
|
|
28
28
|
export type UpdatePolicyGuard = {
|
|
29
29
|
action: string;
|
|
30
30
|
payload?: unknown;
|
|
@@ -37,7 +37,17 @@ export type UpdatePolicy = {
|
|
|
37
37
|
editable: boolean;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
export type ReleaseFilters = {
|
|
41
|
+
q: string;
|
|
42
|
+
platform: string;
|
|
43
|
+
channel: string;
|
|
44
|
+
runtime: string;
|
|
45
|
+
status: string;
|
|
46
|
+
audience: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
40
49
|
export type UpdatesListResponse = {
|
|
50
|
+
filters: { channels: string[]; runtimes: string[] };
|
|
41
51
|
items: UpdateItem[];
|
|
42
52
|
total: number;
|
|
43
53
|
page: number;
|
|
@@ -56,6 +66,7 @@ export type UpdatesListResponse = {
|
|
|
56
66
|
};
|
|
57
67
|
|
|
58
68
|
export interface UpdateDetail extends UpdateItem {
|
|
69
|
+
isNewestInScope: boolean;
|
|
59
70
|
updateInfo: Record<string, unknown>;
|
|
60
71
|
updateMeta: {
|
|
61
72
|
isActive: boolean;
|
|
@@ -142,3 +153,26 @@ export type GuardActionsListResponse = {
|
|
|
142
153
|
items: GuardActionItem[];
|
|
143
154
|
canWrite: boolean;
|
|
144
155
|
};
|
|
156
|
+
|
|
157
|
+
export type DistributionHistoryRelease = {
|
|
158
|
+
updateId: string;
|
|
159
|
+
encodedKey: string;
|
|
160
|
+
appVersion: string | null;
|
|
161
|
+
comment: string | null;
|
|
162
|
+
createdAt: string;
|
|
163
|
+
activatedAt: string | null;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type DistributionHistoryScope = {
|
|
167
|
+
runtimeVersion: string;
|
|
168
|
+
platform: string;
|
|
169
|
+
channel: string;
|
|
170
|
+
revision: string;
|
|
171
|
+
current: DistributionHistoryRelease | null;
|
|
172
|
+
previous: DistributionHistoryRelease | null;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type DistributionHistoryResponse = {
|
|
176
|
+
canWrite: boolean;
|
|
177
|
+
scopes: DistributionHistoryScope[];
|
|
178
|
+
};
|