@gadicc/loom 1.31.0 → 1.32.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/db/neon.js CHANGED
@@ -1,15 +1,12 @@
1
1
  import "server-only";
2
2
  import { neon, neonConfig } from "@neondatabase/serverless";
3
3
  import { drizzle } from "drizzle-orm/neon-http";
4
+ import { resolveNeonFetchEndpoint } from "./neonEndpoint.js";
4
5
 
5
6
  const env = globalThis.process?.env ?? {};
6
7
 
7
- neonConfig.fetchEndpoint = (host) => {
8
- const [protocol, port] = host === "db.localtest.me"
9
- ? ["http", 4444]
10
- : ["https", 443];
11
- return `${protocol}://${host}:${port}/sql`;
12
- };
8
+ neonConfig.fetchEndpoint = (host) =>
9
+ resolveNeonFetchEndpoint(host, env.LOOM_DB_LOCAL_HTTP_ENDPOINT);
13
10
 
14
11
  if (!env.DATABASE_URL) {
15
12
  throw new Error("DATABASE_URL is not set");
@@ -0,0 +1,32 @@
1
+ const LOCAL_DATABASE_HOST = "db.localtest.me";
2
+ const DEFAULT_LOCAL_ENDPOINT = "http://db.localtest.me:4444/sql";
3
+ const LOCAL_ENDPOINT_PATTERN =
4
+ /^https?:\/\/(?:db\.localtest\.me|localhost|127\.0\.0\.1|\[::1\])(?::[0-9]+)?\/sql$/i;
5
+
6
+ /**
7
+ * Resolve the Neon HTTP endpoint, allowing a local proxy override only for the
8
+ * existing db.localtest.me development database host.
9
+ * @param {string} host Host passed by the Neon HTTP client.
10
+ * @param {string | undefined} localEndpoint LOOM_DB_LOCAL_HTTP_ENDPOINT value.
11
+ * @returns {string} SQL endpoint URL.
12
+ */
13
+ export function resolveNeonFetchEndpoint(host, localEndpoint) {
14
+ if (host !== LOCAL_DATABASE_HOST) {
15
+ return `https://${host}:443/sql`;
16
+ }
17
+ if (localEndpoint === undefined) {
18
+ return DEFAULT_LOCAL_ENDPOINT;
19
+ }
20
+
21
+ if (!LOCAL_ENDPOINT_PATTERN.test(localEndpoint)) {
22
+ throw new Error(
23
+ "LOOM_DB_LOCAL_HTTP_ENDPOINT must be a local http(s) URL ending in /sql without credentials, query, or fragment",
24
+ );
25
+ }
26
+
27
+ try {
28
+ return new URL(localEndpoint).href;
29
+ } catch {
30
+ throw new Error("LOOM_DB_LOCAL_HTTP_ENDPOINT has an invalid URL or port");
31
+ }
32
+ }
@@ -0,0 +1,51 @@
1
+ import { expect } from "@std/expect";
2
+ import { describe, it } from "@std/testing/bdd";
3
+ import { resolveNeonFetchEndpoint } from "./neonEndpoint.js";
4
+
5
+ describe("resolveNeonFetchEndpoint", () => {
6
+ it("preserves the existing local and remote defaults", () => {
7
+ expect(resolveNeonFetchEndpoint("db.localtest.me", undefined)).toBe(
8
+ "http://db.localtest.me:4444/sql",
9
+ );
10
+ expect(resolveNeonFetchEndpoint("ep-neon.example", undefined)).toBe(
11
+ "https://ep-neon.example:443/sql",
12
+ );
13
+ });
14
+
15
+ it("uses an explicit local endpoint without affecting remote hosts", () => {
16
+ const override = "http://db.localtest.me:4445/sql";
17
+ expect(resolveNeonFetchEndpoint("db.localtest.me", override)).toBe(
18
+ override,
19
+ );
20
+ expect(resolveNeonFetchEndpoint("ep-neon.example", override)).toBe(
21
+ "https://ep-neon.example:443/sql",
22
+ );
23
+ expect(resolveNeonFetchEndpoint("ep-neon.example", "invalid override"))
24
+ .toBe(
25
+ "https://ep-neon.example:443/sql",
26
+ );
27
+ expect(resolveNeonFetchEndpoint("db.localtest.me", "http://[::1]:4445/sql"))
28
+ .toBe("http://[::1]:4445/sql");
29
+ });
30
+
31
+ it("rejects malformed or nonlocal overrides without exposing their values", () => {
32
+ for (
33
+ const override of [
34
+ "",
35
+ " ",
36
+ "http://db.localtest.me:99999/sql",
37
+ "ftp://db.localtest.me:4445/sql",
38
+ "http://remote.example:4445/sql",
39
+ "http://db.localtest.me.example:4445/sql",
40
+ "http://@db.localtest.me:4445/sql",
41
+ "http://user:password@db.localtest.me:4445/sql",
42
+ "http://db.localtest.me:4445/sql?token=secret",
43
+ "http://db.localtest.me:4445/sql#secret",
44
+ "http://db.localtest.me:4445/other",
45
+ ]
46
+ ) {
47
+ expect(() => resolveNeonFetchEndpoint("db.localtest.me", override))
48
+ .toThrow("LOOM_DB_LOCAL_HTTP_ENDPOINT");
49
+ }
50
+ });
51
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"vercelProjectRelease.d.ts","sourceRoot":"","sources":["../../../src/src/cli/vercelProjectRelease.ts"],"names":[],"mappings":"AA2BA,KAAK,SAAS,GAAG;IACf,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC;AAQF,KAAK,WAAW,GAAG,OAAO,KAAK,CAAC;AAEhC,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,UAatD;AA2JD,4EAA4E;AAC5E,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAsChC;AAgND,gFAAgF;AAChF,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,qBAAqB,EAC9B,EAAE,GAAE,SAAgD;;;;GAkGrD;AAyGD,iFAAiF;AACjF,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,cAAc,EACvB,EAAE,GAAE,SAAgD;;;GAuGrD"}
@@ -532,7 +532,8 @@ export async function promoteVercelProjectRelease(options, io = { out: (line) =>
532
532
  ((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)));
533
533
  const requestTimeoutMs = Math.min(FETCH_TIMEOUT_MS, timeoutMs);
534
534
  const teamId = identity.orgId;
535
- const projectUrl = query(`/v9/projects/${encodeURIComponent(identity.projectId)}`, { teamId });
535
+ // Vercel exposes promotion operation state through this rollback projection.
536
+ const projectUrl = query(`/v9/projects/${encodeURIComponent(identity.projectId)}`, { rollbackInfo: "true", teamId });
536
537
  const deployment = deploymentFromResponse(await fetchJson(identity, query(`/v13/deployments/${encodeURIComponent(options.deploymentId)}`, {
537
538
  teamId,
538
539
  }), { fetchImpl, maxBytes: MAX_PROJECT_BYTES, timeoutMs: requestTimeoutMs }), identity, options.deploymentId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gadicc/loom",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "Deno-first shared helpers for extracting common Next.js app code.",
5
5
  "homepage": "https://github.com/gadicc/loom#readme",
6
6
  "repository": {
@@ -244,7 +244,7 @@
244
244
  },
245
245
  "scripts": {},
246
246
  "loom": {
247
- "gitCommit": "a5809c0861257be6ba98d96f7bc4894594abc3eb"
247
+ "gitCommit": "305a8f35a662d0033fea1ef5d539a51c179ff598"
248
248
  },
249
249
  "bin": {
250
250
  "loom": "script/bin/loom.js"
@@ -1 +1 @@
1
- {"version":3,"file":"vercelProjectRelease.d.ts","sourceRoot":"","sources":["../../../src/src/cli/vercelProjectRelease.ts"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elProjectRelease(options, io = { out: (line) => consol
538
538
  ((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)));
539
539
  const requestTimeoutMs = Math.min(FETCH_TIMEOUT_MS, timeoutMs);
540
540
  const teamId = identity.orgId;
541
- const projectUrl = query(`/v9/projects/${encodeURIComponent(identity.projectId)}`, { teamId });
541
+ // Vercel exposes promotion operation state through this rollback projection.
542
+ const projectUrl = query(`/v9/projects/${encodeURIComponent(identity.projectId)}`, { rollbackInfo: "true", teamId });
542
543
  const deployment = deploymentFromResponse(await fetchJson(identity, query(`/v13/deployments/${encodeURIComponent(options.deploymentId)}`, {
543
544
  teamId,
544
545
  }), { fetchImpl, maxBytes: MAX_PROJECT_BYTES, timeoutMs: requestTimeoutMs }), identity, options.deploymentId);
@@ -20,6 +20,15 @@ It does not own:
20
20
  - domain-specific Valibot refinements
21
21
  - fixture table selection policy
22
22
 
23
+ For a local Neon HTTP proxy on a different port, set
24
+ `LOOM_DB_LOCAL_HTTP_ENDPOINT=http://db.localtest.me:4445/sql` in the consumer's
25
+ local environment. The override applies only when `DATABASE_URL` uses
26
+ `db.localtest.me`. Without it, Loom uses `http://db.localtest.me:4444/sql`;
27
+ remote database hosts still use HTTPS port 443. The override accepts only an
28
+ HTTP(S) `/sql` URL at `db.localtest.me`, `localhost`, `127.0.0.1`, or `[::1]`,
29
+ without credentials, query parameters, or a fragment. An invalid value fails
30
+ when the local HTTP endpoint is used.
31
+
23
32
  Schema-bearing Loom features may own versioned blueprints that are materialized
24
33
  into committed app-local schema files. `loom db schemas sync` refreshes those
25
34
  files only when the current file still matches the hash recorded in `loom.json`;