create-expo-updates-server 0.1.5 → 0.1.6

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.
@@ -5,7 +5,7 @@ const database = vi.hoisted(() => ({
5
5
  blocked: false,
6
6
  version: 1,
7
7
  reason: null as string | null,
8
- changed_at: "2026-09-02T00:00:00.000Z",
8
+ changed_at: "2026-09-02T00:00:00.000Z" as string | Date,
9
9
  changed_by: {
10
10
  type: "system",
11
11
  id: "migration",
@@ -41,7 +41,7 @@ vi.mock("./supabase.js", () => ({
41
41
  version: database.row.version + 1,
42
42
  reason:
43
43
  typeof params.p_reason === "string" ? params.p_reason : null,
44
- changed_at: "2026-09-02T00:01:00.000Z",
44
+ changed_at: new Date("2026-09-02T00:01:00.000Z"),
45
45
  changed_by: params.p_changed_by as typeof database.row.changed_by,
46
46
  };
47
47
  return { data: [database.row], error: null };
@@ -91,6 +91,26 @@ describe("OTA distribution control service", () => {
91
91
  await expect(isOtaDistributionBlocked()).resolves.toBe(false);
92
92
  });
93
93
 
94
+ it("normalizes a PostgreSQL timestamptz Date to an ISO string", async () => {
95
+ database.row.changed_at = new Date("2026-09-01T21:31:08.722Z");
96
+
97
+ await expect(getDistributionControlState()).resolves.toMatchObject({
98
+ changedAt: "2026-09-01T21:31:08.722Z",
99
+ });
100
+ });
101
+
102
+ it("rejects invalid changed_at strings and Dates", async () => {
103
+ database.row.changed_at = "not-a-date";
104
+ await expect(getDistributionControlState()).rejects.toThrow(
105
+ "Invalid OTA distribution control changed_at.",
106
+ );
107
+
108
+ database.row.changed_at = new Date(Number.NaN);
109
+ await expect(getDistributionControlState()).rejects.toThrow(
110
+ "Invalid OTA distribution control changed_at.",
111
+ );
112
+ });
113
+
94
114
  it("does not interpret a database error or missing singleton as active", async () => {
95
115
  database.readError = { message: "relation does not exist" };
96
116
  await expect(isOtaDistributionBlocked()).rejects.toThrow(
@@ -116,6 +136,7 @@ describe("OTA distribution control service", () => {
116
136
  blocked: true,
117
137
  version: 2,
118
138
  reason: "INC-42 bad rollout",
139
+ changedAt: "2026-09-02T00:01:00.000Z",
119
140
  changedBy: principal,
120
141
  });
121
142
  expect(database.rpcParams).toMatchObject({
@@ -92,6 +92,18 @@ function parsePrincipal(value: unknown): DistributionControlPrincipal {
92
92
  };
93
93
  }
94
94
 
95
+ function parseChangedAt(value: unknown): string {
96
+ const changedAt =
97
+ value instanceof Date
98
+ ? value
99
+ : new Date(requiredString(value, "changed_at", 100));
100
+
101
+ if (Number.isNaN(changedAt.getTime())) {
102
+ throw new Error("Invalid OTA distribution control changed_at.");
103
+ }
104
+ return changedAt.toISOString();
105
+ }
106
+
95
107
  function parseStateRow(value: unknown): DistributionControlState {
96
108
  if (!isRecord(value)) {
97
109
  throw new Error("OTA distribution control state is missing.");
@@ -106,10 +118,7 @@ function parseStateRow(value: unknown): DistributionControlState {
106
118
  throw new Error("Invalid OTA distribution control state.");
107
119
  }
108
120
 
109
- const changedAt = requiredString(value.changed_at, "changed_at", 100);
110
- if (Number.isNaN(Date.parse(changedAt))) {
111
- throw new Error("Invalid OTA distribution control changed_at.");
112
- }
121
+ const changedAt = parseChangedAt(value.changed_at);
113
122
 
114
123
  const reason =
115
124
  value.reason === null
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "installerVersion": "0.1.5",
4
- "sourceCommit": "441297605ec522de0cbc58881e145e37a1120b8a",
5
- "totalSize": 1146664,
3
+ "installerVersion": "0.1.6",
4
+ "sourceCommit": "8c02b5f5974d917cba116627047f97de257d3827",
5
+ "totalSize": 1147628,
6
6
  "files": [
7
7
  {
8
8
  "path": ".env.docker.example",
@@ -577,13 +577,13 @@
577
577
  },
578
578
  {
579
579
  "path": "src/server/lib/distribution-control.test.ts",
580
- "size": 4453,
581
- "sha256": "5e2d5e9fb04c962ed6b493af2c29aa2c86455944ec8527204454404282b3fb86"
580
+ "size": 5230,
581
+ "sha256": "18926879515a7364176c726645d3a0ef5d7d1b3057e97a677b30661be8acf873"
582
582
  },
583
583
  {
584
584
  "path": "src/server/lib/distribution-control.ts",
585
- "size": 6687,
586
- "sha256": "d2f0ae088680176a17af5efdac2b73c95197bb010b4463ab6fa3fae25d9c650e"
585
+ "size": 6874,
586
+ "sha256": "e6d5e6ed59d5b831172518ecc20c496037945aabb8801d8a0f3fd42426bd93ef"
587
587
  },
588
588
  {
589
589
  "path": "src/server/lib/emergency-channel-redirects.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-expo-updates-server",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Create a standalone Expo Updates Server project",
5
5
  "license": "MIT",
6
6
  "type": "module",