@intentius/chant-lexicon-sql 0.124.24 → 0.124.26

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "4e51745dab5620b066bb56c64dd42e13aca79ad24b0da5d2995f123498024783",
4
+ "manifest.json": "4b71c644a9deaf6fe1399be5b88121e0311dcf9e4208f7abcceaf45e95f2fd69",
5
5
  "meta.json": "59ca03876cce0d293e15a7f0a90ef7f250d133e46773c73fedede4a2ec792119",
6
6
  "types/index.d.ts": "0286ebb367773e84c76818b0f69cb14cff8328fd2f8c65ed87563c8d5815458c",
7
7
  "rules/postgres-templates.ts": "082da542239ab9f9627026972281102a61ca269cb79e2514f402dfc400ccdcde",
@@ -79,5 +79,5 @@
79
79
  "rules/sqlpg125.ts": "cc7411c57c525613dc720ba00e986bbc4e5a84b8b0bcfa7a6ce0d058f039f025",
80
80
  "rules/sqlpg126.ts": "d57b82a5842273876510131d67bf4418cbd61eff821e245edebc644dafd502bb"
81
81
  },
82
- "composite": "196ca842183748f111a4a69d0236c249177a3c036f7538a7514a51091e31aba3"
82
+ "composite": "ba7ce0b2d454e12132bc5f1c87ae1ba71a978a13dae9f861a13d2eea98de8cd8"
83
83
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sql",
3
- "version": "0.124.24",
3
+ "version": "0.124.26",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "SQL",
6
6
  "intrinsics": [],
@@ -28,6 +28,15 @@ export declare class PostgresQueryError extends Error {
28
28
  readonly position?: number | undefined;
29
29
  constructor(message: string, code?: string | undefined, position?: number | undefined);
30
30
  }
31
+ /**
32
+ * The URL with libpq's meaning of `sslmode`. pg-connection-string reads
33
+ * `sslmode=require` as verify-full unless `uselibpqcompat=true` is set, so an
34
+ * RDS host without its CA bundle, or a tunnel whose host name doesn't match
35
+ * the certificate, fails to connect. In psql, `require` encrypts without
36
+ * verifying, and a profile url means what it means there. A url that sets
37
+ * `uselibpqcompat` itself is left alone.
38
+ */
39
+ export declare function withLibpqSslMode(url: URL): URL;
31
40
  /** Connect to `endpoint` and set the catalog-reading session up. */
32
41
  export declare function connectPostgres(endpoint: PostgresEndpoint, options?: {
33
42
  applicationName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/postgres/live/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oGAAoG;IACpG,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3F,gDAAgD;IAChD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AAED,uEAAuE;AACvE,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM;gBAF1B,OAAO,EAAE,MAAM,EACN,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,QAAQ,CAAC,EAAE,MAAM,YAAA;CAK7B;AAgBD,oEAAoE;AACpE,wBAAsB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CA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;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,GAAE,MAAgC,GAAG,OAAO,CAAC,cAAc,CAAC,CAkB7I"}
@@ -18,6 +18,7 @@ export declare class ApprovingLedger {
18
18
  appended: import("@intentius/chant/point-decision").PendingGateRecord[];
19
19
  resolved: import("@intentius/chant/point-decision").GateResolutionRecord[];
20
20
  applied: import("@intentius/chant/gate-decision").AppliedGateRecord[];
21
+ checkpoints: Map<string, string>;
21
22
  };
22
23
  approveLast(): void;
23
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/postgres/testing/migration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoD,KAAK,UAAU,EAAE,KAAK,cAAc,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE9J,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAuB,KAAK,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAEpF,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,qBAAqB,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAO/F;AAED,gFAAgF;AAChF,wBAAsB,cAAc,CAAC,MAAM,EAAE,yBAAyB,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,CAItJ;AAED,uIAAuI;AACvI,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,WAAW,CAAiB;IACpC,IAAI;;;;MAA0B;IAE9B,WAAW,IAAI,IAAI;CAcpB;AAED,2CAA2C;AAC3C,eAAO,MAAM,UAAU,GAAI,GAAG,WAAW,EAAE,MAAM,MAAM,KAAG,OAAyF,CAAC"}
1
+ {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/postgres/testing/migration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoD,KAAK,UAAU,EAAE,KAAK,cAAc,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE9J,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAuB,KAAK,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAEpF,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,qBAAqB,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAO/F;AAED,gFAAgF;AAChF,wBAAsB,cAAc,CAAC,MAAM,EAAE,yBAAyB,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,CAItJ;AAED,uIAAuI;AACvI,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,WAAW,CAAiB;IACpC,IAAI;;;;;MAA0B;IAE9B,WAAW,IAAI,IAAI;CAcpB;AAED,2CAA2C;AAC3C,eAAO,MAAM,UAAU,GAAI,GAAG,WAAW,EAAE,MAAM,MAAM,KAAG,OAAyF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-sql",
3
- "version": "0.124.24",
3
+ "version": "0.124.26",
4
4
  "description": "SQL lexicon for chant — database schema as typed declarations, one dialect at a time; ClickHouse first, with types read from a pinned server's catalog",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -72,6 +72,6 @@
72
72
  "typescript": "^5.9.3"
73
73
  },
74
74
  "peerDependencies": {
75
- "@intentius/chant": "^0.124.24"
75
+ "@intentius/chant": "^0.124.26"
76
76
  }
77
77
  }
@@ -0,0 +1,25 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { parse } from "pg-connection-string";
3
+ import { withLibpqSslMode } from "./client";
4
+
5
+ const ssl = (url: string) => parse(withLibpqSslMode(new URL(url)).toString()).ssl;
6
+
7
+ describe("withLibpqSslMode", () => {
8
+ test("sslmode=require encrypts without verifying the certificate, as in psql", () => {
9
+ expect(ssl("postgres://shop.abc123.eu-west-1.rds.amazonaws.com:5432/shop?sslmode=require")).toEqual({ rejectUnauthorized: false });
10
+ });
11
+
12
+ test("sslmode=verify-full still verifies", () => {
13
+ expect(ssl("postgres://localhost:5432/shop?sslmode=verify-full")).toEqual({});
14
+ });
15
+
16
+ test("a url that sets uselibpqcompat itself is left alone", () => {
17
+ const url = "postgres://localhost:5432/shop?sslmode=require&uselibpqcompat=false";
18
+ expect(withLibpqSslMode(new URL(url)).toString()).toBe(url);
19
+ });
20
+
21
+ test("a url without sslmode is left alone", () => {
22
+ const url = "postgres://localhost:5432/shop";
23
+ expect(withLibpqSslMode(new URL(url)).toString()).toBe(url);
24
+ });
25
+ });
@@ -52,11 +52,24 @@ const wrap = (err: unknown): PostgresQueryError => {
52
52
  return new PostgresQueryError(e.message ?? String(err), e.code, e.position !== undefined ? Number(e.position) : undefined);
53
53
  };
54
54
 
55
+ /**
56
+ * The URL with libpq's meaning of `sslmode`. pg-connection-string reads
57
+ * `sslmode=require` as verify-full unless `uselibpqcompat=true` is set, so an
58
+ * RDS host without its CA bundle, or a tunnel whose host name doesn't match
59
+ * the certificate, fails to connect. In psql, `require` encrypts without
60
+ * verifying, and a profile url means what it means there. A url that sets
61
+ * `uselibpqcompat` itself is left alone.
62
+ */
63
+ export function withLibpqSslMode(url: URL): URL {
64
+ if (url.searchParams.has("sslmode") && !url.searchParams.has("uselibpqcompat")) url.searchParams.set("uselibpqcompat", "true");
65
+ return url;
66
+ }
67
+
55
68
  /** Connect to `endpoint` and set the catalog-reading session up. */
56
69
  export async function connectPostgres(endpoint: PostgresEndpoint, options: { applicationName?: string } = {}): Promise<PostgresClient> {
57
70
  const pg = await pgModule();
58
71
  // node-postgres lets the connection string's fields win over the config's, so the credentials go into the URL.
59
- const url = new URL(endpoint.url);
72
+ const url = withLibpqSslMode(new URL(endpoint.url));
60
73
  if (endpoint.user !== undefined) url.username = encodeURIComponent(endpoint.user);
61
74
  const password = endpoint.token ? await endpoint.token.get() : endpoint.password;
62
75
  if (password !== undefined) url.password = encodeURIComponent(password);