create-expo-updates-server 0.6.0 → 0.6.2

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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/template/README.md +1 -1
  3. package/dist/template/app/updates/devices/page.tsx +3 -3
  4. package/dist/template/docs/device-targeting.md +15 -0
  5. package/dist/template/docs/getting-started.md +1 -1
  6. package/dist/template/docs/migrations/2026-11-25-device-id-search.sql +159 -0
  7. package/dist/template/docs/migrations/schema.sql +160 -0
  8. package/dist/template/docs/npm-installer.md +3 -3
  9. package/dist/template/docs/operations-guide.md +1 -1
  10. package/dist/template/docs/ru/device-targeting.md +15 -0
  11. package/dist/template/docs/ru/getting-started.md +1 -1
  12. package/dist/template/docs/ru/npm-installer.md +3 -3
  13. package/dist/template/docs/ru/operations-guide.md +1 -1
  14. package/dist/template/docs/ru/publishing-npm-installer.md +1 -1
  15. package/dist/template/docs/uk/device-targeting.md +15 -0
  16. package/dist/template/docs/uk/getting-started.md +1 -1
  17. package/dist/template/docs/uk/npm-installer.md +3 -3
  18. package/dist/template/docs/uk/operations-guide.md +1 -1
  19. package/dist/template/docs/uk/publishing-npm-installer.md +1 -1
  20. package/dist/template/lib/audience-ids.ts +1 -0
  21. package/dist/template/scripts/tests/device-analytics-migrations.mjs +4 -0
  22. package/dist/template/scripts/tests/device-analytics.mjs +10 -1
  23. package/dist/template/scripts/tests/e2e/installations.mjs +7 -1
  24. package/dist/template/scripts/tests/e2e/release-matrix.mjs +23 -27
  25. package/dist/template/src/client/devices/registry.tsx +5 -0
  26. package/dist/template/src/client/devices/use-devices-report.ts +3 -2
  27. package/dist/template/src/client/i18n/en.json +2 -1
  28. package/dist/template/src/client/i18n/ru.json +2 -1
  29. package/dist/template/src/client/i18n/uk.json +2 -1
  30. package/dist/template/src/server/controllers/manifest.test.ts +2 -0
  31. package/dist/template/src/server/controllers/manifest.ts +1 -16
  32. package/dist/template/src/server/devices/report.test.ts +5 -1
  33. package/dist/template/src/server/devices/report.ts +2 -1
  34. package/dist/template/src/server/manifest/manifest-repository.ts +2 -10
  35. package/dist/template-manifest.json +63 -58
  36. package/package.json +1 -1
@@ -24,6 +24,8 @@ assert.ok(schema.includes(favoritesMigration.trim()), 'Canonical favorites SQL m
24
24
  assert.ok(schema.includes(historyMigration.trim()), 'Canonical public distribution SQL must match migration');
25
25
  assert.ok(schema.includes(targetingMigration.trim()), 'Canonical targeting SQL must match migration');
26
26
  assert.ok(schema.includes(activationMigration.trim()), 'Canonical activation SQL must match migration');
27
+ const searchMigration = readFileSync(new URL('../../docs/migrations/2026-11-25-device-id-search.sql', import.meta.url), 'utf8');
28
+ assert.ok(schema.includes(searchMigration.trim()), 'Canonical Device ID search SQL must match migration');
27
29
  const marker = '-- Daily device analytics (2026-10-22).';
28
30
  assert.ok(schema.includes(marker), 'Canonical schema must contain the analytics migration marker');
29
31
  assert.ok(schema.split(marker)[1].trimStart().startsWith(migration.trim()), 'Canonical analytics SQL must match the standalone migration');
@@ -67,6 +69,8 @@ try {
67
69
  await pool.query(targetingMigration);
68
70
  await pool.query(activationMigration);
69
71
  await pool.query(activationMigration);
72
+ await pool.query(searchMigration);
73
+ await pool.query(searchMigration);
70
74
  await pool.query(favoritesMigration);
71
75
  await pool.query(historyMigration);
72
76
  await pool.query(historyMigration);
@@ -33,7 +33,8 @@ try {
33
33
  assert.equal(empty.activity.at(-1).activeInstallations, 0);
34
34
  assert.equal(empty.activity[0].activeInstallations, null, 'Do not manufacture activity before collection');
35
35
 
36
- assert.equal(await send(), 'accepted');
36
+ const deviceId = 'a7b8c9d0e1f2' + '3'.repeat(52);
37
+ assert.equal(await send({ deviceId }), 'accepted');
37
38
  const first = await facts();
38
39
  assert.equal(first.length, 1);
39
40
  assert.equal(first[0].activity_date, empty.activity.at(-1).date, 'Use receipt UTC day, not client timestamp');
@@ -68,6 +69,14 @@ try {
68
69
  await pool.query("update ota_device_state set first_seen_at=now()-interval '50 days' where installation_id=$1", [ids[1]]);
69
70
  await send({ installationId: ids[1], sequence: 2, eventId: randomUUID() });
70
71
  assert.equal((await facts(ids[1])).length, 1);
72
+ for (const search of [deviceId, deviceId.slice(0, 12).toUpperCase()]) {
73
+ const matches = await report({ search });
74
+ assert.deepEqual(matches.devices.map(d => d.device_id), [deviceId]);
75
+ assert.equal(matches.total, 1);
76
+ assert.equal(matches.activity.at(-1).activeInstallations, 1);
77
+ assert.equal(matches.cohorts[0].installations, 1);
78
+ assert.equal((await report({ search, platform: 'ios' })).total, 0);
79
+ }
71
80
  assert.equal((await pool.query('select count(*)::int as n from ota_device_activity_cohorts where installation_id=$1', [ids[1]])).rows[0].n, 0);
72
81
  assert.equal((await report()).adoptionCohorts.reduce((sum, c) => sum + c.installations, 0), 2);
73
82
 
@@ -7,6 +7,7 @@ export async function exerciseInstallations(page) {
7
7
  const origin = new URL(page.url()).origin;
8
8
  const runtime = "browser-installations";
9
9
  const id = randomUUID();
10
+ const deviceId = "123456789abc" + "f".repeat(52);
10
11
  for (const [installationId, channel, nativeBuild] of [
11
12
  [id, "analytics-ios", "12"],
12
13
  [randomUUID(), "analytics-ios", "13"],
@@ -15,6 +16,7 @@ export async function exerciseInstallations(page) {
15
16
  const response = await page.request.post(origin + "/api/device-heartbeat", {
16
17
  data: {
17
18
  installationId,
19
+ ...(installationId === id ? { deviceId } : {}),
18
20
  eventId: randomUUID(),
19
21
  sequence: 1,
20
22
  observedAt: new Date().toISOString(),
@@ -84,14 +86,18 @@ export async function exerciseInstallations(page) {
84
86
  const detailsButton = page.getByRole("button", {
85
87
  name: "Installation details " + id,
86
88
  });
89
+ const search = page.getByLabel("Device ID / Installation ID", { exact: true });
90
+ await search.fill(deviceId.slice(0, 12));
91
+ await expect(page.getByRole("table", { name: "Installation registry" }).getByRole("row")).toHaveCount(2);
87
92
  await detailsButton.click();
88
93
  const sheet = page.getByRole("dialog", { name: "Installation details" });
89
94
  await expect(sheet.getByText(id, { exact: true })).toBeVisible();
95
+ await expect(sheet.getByText(deviceId, { exact: true })).toBeVisible();
90
96
  await page.keyboard.press("Escape");
91
97
  await expect(sheet).toBeHidden();
92
98
  await expect(detailsButton).toBeFocused();
93
99
 
94
- await page.getByLabel("Installation ID", { exact: true }).fill(randomUUID());
100
+ await search.fill(randomUUID());
95
101
  await expect(
96
102
  page.getByText("No installations found", { exact: true }),
97
103
  ).toBeVisible();
@@ -152,24 +152,10 @@ export async function exerciseReleaseMatrix({
152
152
  assert.deepEqual(candidate.extra.updatePolicy.guard, guard);
153
153
  await request(v2.path + "/deactivate", "POST", { disabled: true });
154
154
 
155
- // #27–31: clients that skipped the release stay put. A client already on
156
- // the retired release gets the older bundle, its own policy, and a fresh native timestamp.
155
+ // Retiring v2 leaves v1 available to eligible clients but cannot downgrade a running v2.
156
+ await expectRelease(v1, deviceHeaders);
157
157
  await expectNone(platform, originalRuntime, running(first));
158
- const fallback = await expectRelease(v1, {
159
- ...deviceHeaders,
160
- ...running(candidate),
161
- });
162
- assert.notEqual(fallback.id, candidate.id);
163
- assert.ok(
164
- Date.parse(fallback.createdAt) > Date.parse(candidate.createdAt),
165
- "fallback must be newer to Expo",
166
- );
167
- assert.equal(fallback.extra.updatePolicy.delivery, "manual");
168
- assert.equal(fallback.extra.updatePolicy.guard, undefined);
169
- await expectNone(platform, originalRuntime, {
170
- ...deviceHeaders,
171
- ...running(fallback),
172
- });
158
+ await expectNone(platform, originalRuntime, { ...deviceHeaders, ...running(candidate) });
173
159
 
174
160
  const embedded = randomUUID();
175
161
  await request(
@@ -186,20 +172,14 @@ export async function exerciseReleaseMatrix({
186
172
  );
187
173
  await expectNone(platform, originalRuntime, {
188
174
  ...deviceHeaders,
189
- ...running(candidate),
190
175
  "expo-embedded-update-id": embedded,
191
176
  });
192
177
  await request("/api/admin/embedded-updates/" + embedded, "DELETE");
193
178
 
194
179
  // #25–26, #32–33: reactivation, ignored draft, and a direct jump to the latest eligible patch.
195
180
  await request(v2.path + "/deactivate", "POST", { disabled: false });
196
- const reactivated = await expectRelease(v2, {
197
- ...deviceHeaders,
198
- ...running(fallback),
199
- });
200
- assert.ok(
201
- Date.parse(reactivated.createdAt) > Date.parse(fallback.createdAt),
202
- );
181
+ await expectRelease(v2, { ...deviceHeaders, ...running(first) });
182
+ await expectNone(platform, originalRuntime, { ...deviceHeaders, ...running(candidate) });
203
183
  const v3 = await publish(platform, originalRuntime, 3, {
204
184
  active: false,
205
185
  targeted: true,
@@ -231,6 +211,18 @@ export async function exerciseReleaseMatrix({
231
211
  const iosLatest = await expectRelease(iosV2);
232
212
  const androidSecond = await expectRelease(androidV2);
233
213
  assert.notEqual(iosLatest.launchAsset.hash, androidSecond.launchAsset.hash);
214
+ // #28–30: only an explicit rollback offers public v1 to a device running public v2.
215
+ for (const [v2, current] of [[iosV2, iosLatest], [androidV2, androidSecond]]) {
216
+ const v1 = releases[v2.platform];
217
+ await request(v1.path + "/rollback", "POST", {});
218
+ const rolledBack = await expectRelease(v1, running(current));
219
+ assert.ok(Date.parse(rolledBack.createdAt) > Date.parse(current.createdAt));
220
+ assert.equal(rolledBack.extra.updatePolicy.delivery, "manual");
221
+ assert.equal(rolledBack.extra.updatePolicy.guard, undefined);
222
+ await expectNone(v2.platform, upgradedRuntime, running(rolledBack));
223
+ await request(v2.path + "/promote", "POST", {});
224
+ await expectRelease(v2, running(rolledBack));
225
+ }
234
226
  let androidLatest = androidV2;
235
227
  for (const number of [3, 4, 5])
236
228
  androidLatest = await publish("android", upgradedRuntime, number);
@@ -298,10 +290,14 @@ export async function exerciseReleaseMatrix({
298
290
  const restored = await historyScope();
299
291
  assert.equal(restored.current.updateId, publicA.id);
300
292
  assert.equal(restored.previous.updateId, publicB.id);
301
- await expectRelease(publicA, running(runningB));
293
+ await expectRelease(publicA);
294
+ await expectNone("android", originalRuntime, {
295
+ "expo-channel-name": historyChannel,
296
+ ...running(runningB),
297
+ });
302
298
  await restore(publicA.id, stopped.revision, 409);
303
299
 
304
300
  console.log(
305
- "PASS signed HTTP release matrix: both platform stacks, active/draft selection, scoped retired-build fallback, embedded floor, skipped versions, native runtime transition, normalized/empty/unknown channels and targeted channel isolation",
301
+ "PASS signed HTTP release matrix: both platform stacks, active/draft selection, disabled-release downgrade protection, explicit rollback, embedded floor, skipped versions, native runtime transition, normalized/empty/unknown channels and targeted channel isolation",
306
302
  );
307
303
  }
@@ -146,6 +146,11 @@ export function Registry({
146
146
  {d.installation_id.slice(0, 8)}…
147
147
  {d.installation_id.slice(-4)}
148
148
  </Button>
149
+ {d.device_id && (
150
+ <p className="font-mono text-xs text-muted-foreground">
151
+ {t("Device ID")} · {d.device_id.slice(0, 12)}
152
+ </p>
153
+ )}
149
154
  <p className="mt-1 text-xs text-muted-foreground">
150
155
  {t("С ")}
151
156
  {calendarDate(d.first_seen_at)}
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
 
3
+ import { registryIdSearchPattern } from "@/lib/audience-ids";
3
4
  import { useFilteredResults } from "@/src/client/use-filtered-results";
4
5
  import type { DevicesReport } from "@/src/server/devices/report-types";
5
6
  export type Filters = {
@@ -24,8 +25,8 @@ async function loadReport(
24
25
  query: typeof initialQuery,
25
26
  signal: AbortSignal,
26
27
  ): Promise<DevicesReport> {
27
- if (!/^[a-f0-9-]{0,36}$/i.test(query.search.trim()))
28
- throw new Error("Часть UUID: цифры, буквы a–f и дефисы");
28
+ if (query.search.trim() && !registryIdSearchPattern.test(query.search.trim()))
29
+ throw new Error("Enter a Device ID prefix or part of an Installation ID");
29
30
 
30
31
  const params = new URLSearchParams();
31
32
  for (const [key, value] of Object.entries(query)) {
@@ -177,7 +177,8 @@
177
177
  "Все runtime": "All runtimes",
178
178
  "Все типы": "All launch types",
179
179
  "ID или часть ID": "ID or part of an ID",
180
- "Часть UUID: цифры, буквы a–f и дефисы": "Partial UUID: digits, letters a–f and hyphens",
180
+ "Enter a Device ID prefix or part of an Installation ID": "Enter a Device ID prefix or part of an Installation ID",
181
+ "Device ID / Installation ID": "Device ID / Installation ID",
181
182
  "Применить": "Apply",
182
183
  "Сбросить": "Reset",
183
184
  "Есть неприменённые изменения": "There are unapplied changes",
@@ -177,7 +177,8 @@
177
177
  "Все runtime": "Все runtime",
178
178
  "Все типы": "Все типы",
179
179
  "ID или часть ID": "ID или часть ID",
180
- "Часть UUID: цифры, буквы a–f и дефисы": "Часть UUID: цифры, буквы a–f и дефисы",
180
+ "Enter a Device ID prefix or part of an Installation ID": "Введите начало ID устройства или часть ID установки",
181
+ "Device ID / Installation ID": "ID устройства / ID установки",
181
182
  "Применить": "Применить",
182
183
  "Сбросить": "Сбросить",
183
184
  "Есть неприменённые изменения": "Есть неприменённые изменения",
@@ -177,7 +177,8 @@
177
177
  "Все runtime": "Усі runtime",
178
178
  "Все типы": "Усі типи",
179
179
  "ID или часть ID": "ID або частина ID",
180
- "Часть UUID: цифры, буквы a–f и дефисы": "Частина UUID: цифри, літери a–f і дефіси",
180
+ "Enter a Device ID prefix or part of an Installation ID": "Введіть початок ID пристрою або частину ID встановлення",
181
+ "Device ID / Installation ID": "ID пристрою / ID встановлення",
181
182
  "Применить": "Застосувати",
182
183
  "Сбросить": "Скинути",
183
184
  "Есть неприменённые изменения": "Є незастосовані зміни",
@@ -1046,6 +1046,8 @@ describe("GET /api/manifest", () => {
1046
1046
  });
1047
1047
 
1048
1048
  it.each([
1049
+ ["a disabled newer OTA in the same scope", {}],
1050
+ ["a disabled later OTA with the same app version", { manifest: { expoClient: { version: "2.1.0" } } }],
1049
1051
  ["a still-active OTA", { is_active: true }],
1050
1052
  ["a disabled OTA on another channel", { channel: "beta" }],
1051
1053
  ["a disabled OTA on another runtime", { runtime_version: "2.0.0" }],
@@ -302,21 +302,7 @@ const manifestController = async (req: NextRequest) => {
302
302
  )
303
303
  : null;
304
304
  const embeddedVersionBlocks = embeddedAppVersionComparison === 1;
305
- // A disabled, previously installed OTA can return to an older eligible
306
- // release in its own scope. An embedded floor and a rollback targeting
307
- // somebody else still take precedence.
308
- const recoveringDisabledOta =
309
- !rollbackUpdateId &&
310
- currentInstalledUpdateMeta?.ota?.is_active === false &&
311
- currentInstalledUpdateMeta.ota.runtime_version === runtimeVersion &&
312
- currentInstalledUpdateMeta.platform === platform &&
313
- currentInstalledUpdateMeta.channel === channel &&
314
- isSameOrNewerDate(
315
- normalizeExpoManifestDate(currentInstalledUpdateMeta.created_at),
316
- selectedCreatedAt,
317
- );
318
- const currentInstalledVersionBlocks =
319
- !recoveringDisabledOta && currentInstalledAppVersionComparison === 1;
305
+ const currentInstalledVersionBlocks = currentInstalledAppVersionComparison === 1;
320
306
 
321
307
  const embeddedTimestampBlocks = Boolean(
322
308
  embeddedUpdateMeta &&
@@ -330,7 +316,6 @@ const manifestController = async (req: NextRequest) => {
330
316
  ),
331
317
  );
332
318
  const currentInstalledTimestampBlocks = Boolean(
333
- !recoveringDisabledOta &&
334
319
  currentInstalledUpdateMeta &&
335
320
  currentInstalledUpdateMeta.platform === platform &&
336
321
  currentInstalledUpdateMeta.channel === channel &&
@@ -14,10 +14,14 @@ describe("device analytics filters", () => {
14
14
  expect(rpc).toHaveBeenCalledWith("ota_devices_report_v2", filters);
15
15
  });
16
16
 
17
- it.each(["days=7&days=30", "platform=ios&platform=android", "launchKind=all", "search=%25", "search=abcdef_", `search=${"a".repeat(37)}`, "search=%00", "runtime=%09", "offset=Infinity"])("rejects invalid or nonscalar filters: %s", (query) => {
17
+ it.each(["days=7&days=30", "platform=ios&platform=android", "launchKind=all", "search=%25", "search=abcdef_", `search=${"a".repeat(65)}`, "search=%00", "runtime=%09", "offset=Infinity"])("rejects invalid or nonscalar filters: %s", (query) => {
18
18
  expect(() => parseDeviceFilters(new URLSearchParams(query))).toThrow("Invalid filters");
19
19
  });
20
20
 
21
+ it("accepts a full Device ID copied from the registry", () => {
22
+ expect(parseDeviceFilters(new URLSearchParams({ search: "AB".repeat(32) })).p_search).toBe("ab".repeat(32));
23
+ });
24
+
21
25
  it("keeps empty optional controls unfiltered", () => {
22
26
  expect(parseDeviceFilters(new URLSearchParams("launchKind=&search=%20%20"))).toMatchObject({ p_launch_kind: null, p_search: null });
23
27
  });
@@ -1,3 +1,4 @@
1
+ import { registryIdSearchPattern } from "@/lib/audience-ids";
1
2
  import { supabase } from "../lib/supabase.js";
2
3
  import type { DevicesReport } from "./report-types";
3
4
 
@@ -17,7 +18,7 @@ export function parseDeviceFilters(params: URLSearchParams) {
17
18
  (channel !== null && (channel.length > 64 || !/^[a-z0-9][a-z0-9._-]*$/.test(channel))) ||
18
19
  (runtime !== null && (runtime.length > 100 || runtime.trim() !== runtime || /[\x00-\x1f\x7f]/.test(runtime))) ||
19
20
  (launchKind !== null && !["ota", "embedded", "unknown"].includes(launchKind)) ||
20
- (search !== null && !/^[a-f0-9-]{1,36}$/.test(search))) throw new Error("Invalid filters");
21
+ (search !== null && !registryIdSearchPattern.test(search))) throw new Error("Invalid filters");
21
22
  return { p_days: days, p_platform: platform, p_channel: channel, p_runtime: runtime, p_offset: offset, p_launch_kind: launchKind, p_search: search };
22
23
  }
23
24
  export async function getDevicesReport(filters: ReturnType<typeof parseDeviceFilters>): Promise<DevicesReport> {
@@ -164,16 +164,8 @@ async function resolveDeviceUpdateRow(
164
164
  return getUpdateByUpdateId(resolvedUpdateId);
165
165
  }
166
166
 
167
- type DeviceBaselineMeta = EmbeddedUpdateMeta & {
168
- ota?: Pick<OtaUpdateRow, "is_active" | "runtime_version">;
169
- };
170
-
171
- function toDeviceBaselineMeta(updateRow: OtaUpdateRow): DeviceBaselineMeta {
167
+ function toDeviceBaselineMeta(updateRow: OtaUpdateRow): EmbeddedUpdateMeta {
172
168
  return {
173
- ota: {
174
- is_active: updateRow.is_active,
175
- runtime_version: updateRow.runtime_version,
176
- },
177
169
  embedded_update_id: updateRow.update_id,
178
170
  created_at: updateRow.created_at,
179
171
  channel: updateRow.channel,
@@ -184,7 +176,7 @@ function toDeviceBaselineMeta(updateRow: OtaUpdateRow): DeviceBaselineMeta {
184
176
 
185
177
  export async function resolveDeviceBaselineMeta(
186
178
  deviceUpdateId: string,
187
- ): Promise<DeviceBaselineMeta | null> {
179
+ ): Promise<EmbeddedUpdateMeta | null> {
188
180
  const otaUpdate = await resolveDeviceUpdateRow(deviceUpdateId);
189
181
  return otaUpdate
190
182
  ? toDeviceBaselineMeta(otaUpdate)