@shivaedev/local-postgres 0.4.2 → 0.5.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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/server/PostgresVersionMismatch.d.ts +7 -0
- package/dist/server/PostgresVersionMismatch.d.ts.map +1 -0
- package/dist/server/PostgresVersionMismatch.js +10 -0
- package/dist/server/PostgresVersionMismatch.js.map +1 -0
- package/dist/server/localPostgres.d.ts.map +1 -1
- package/dist/server/localPostgres.js +2 -1
- package/dist/server/localPostgres.js.map +1 -1
- package/package.json +3 -3
- package/src/server/PostgresVersionMismatch.ts +10 -0
- package/src/server/localPostgres.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 - 2026-10-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `PostgresVersionMismatch` from `@shivaedev/local-postgres/PostgresVersionMismatch.ts` identifies a refused running version through `_tag`, `expectedVersion` and `observedVersion`, retaining the existing error message.
|
|
8
|
+
|
|
3
9
|
## 0.4.2 - 2026-10-18
|
|
4
10
|
|
|
5
11
|
### Changed
|
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ The shared baseline is PostgreSQL 18.6 on loopback port 55432. Docker preparatio
|
|
|
114
114
|
postgres:18.6-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
A newly created container uses username and password `postgres`; connection URLs supply credentials for client commands. Setup
|
|
117
|
+
A newly created container uses username and password `postgres`; connection URLs supply credentials for client commands. Setup refuses a running version other than 18.6 with `PostgresVersionMismatch` from `@shivaedev/local-postgres/PostgresVersionMismatch.ts`. The error carries `_tag: "PostgresVersionMismatch"`, `expectedVersion` and `observedVersion`. A running PostgreSQL 17 service is refused without losing its existing rows; upgrading it while preserving its data is your job. Container preparation and container-client fallback also check the managed image; a successful host-`psql` version probe does not inspect that image.
|
|
118
118
|
|
|
119
119
|
Pass the process's actual Docker settings to `localPostgres`, as `process.env` in the examples does. With `DOCKER_CONTEXT`, endpoint validation uses that context and ignores `DOCKER_HOST`; otherwise it validates `DOCKER_HOST` or the active context. Remote endpoints are rejected before a Docker operation. Docker subprocesses inherit the process environment. Supplying a different object does not configure those subprocesses.
|
|
120
120
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class PostgresVersionMismatch extends Error {
|
|
2
|
+
readonly _tag = "PostgresVersionMismatch";
|
|
3
|
+
readonly expectedVersion = "18.6";
|
|
4
|
+
readonly observedVersion: string | undefined;
|
|
5
|
+
constructor(observedVersion: string | undefined);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=PostgresVersionMismatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresVersionMismatch.d.ts","sourceRoot":"","sources":["../../src/server/PostgresVersionMismatch.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,6BAA6B;IAC1C,QAAQ,CAAC,eAAe,UAAU;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7C,YAAY,eAAe,EAAE,MAAM,GAAG,SAAS,EAG9C;CACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class PostgresVersionMismatch extends Error {
|
|
2
|
+
_tag = "PostgresVersionMismatch";
|
|
3
|
+
expectedVersion = "18.6";
|
|
4
|
+
observedVersion;
|
|
5
|
+
constructor(observedVersion) {
|
|
6
|
+
super("Expected local PostgreSQL 18.6. Check the existing service; setup never removes containers or data.");
|
|
7
|
+
this.observedVersion = observedVersion;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=PostgresVersionMismatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresVersionMismatch.js","sourceRoot":"","sources":["../../src/server/PostgresVersionMismatch.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,IAAI,GAAG,yBAAyB,CAAC;IACjC,eAAe,GAAG,MAAM,CAAC;IACzB,eAAe,CAAqB;IAE7C,YAAY,eAAmC;QAC9C,KAAK,CAAC,qGAAqG,CAAC,CAAC;QAC7G,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACxC,CAAC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localPostgres.d.ts","sourceRoot":"","sources":["../../src/server/localPostgres.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAU,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"localPostgres.d.ts","sourceRoot":"","sources":["../../src/server/localPostgres.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAU,MAAM,kBAAkB,CAAC;AAGlE,eAAO,MAAM,WAAW,mDAAmD,CAAC;AAE5E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,qBAY1E;AAQD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,iBAAiB,EAAE,EAAE,QAAa,EAAE,WAAkB,EAAE,GAAE,gBAAqB;+BAmEvF,SAAS,MAAM,EAAE;iBA/D/B,MAAM,GAAG,GAAG,SAAS,MAAM;;EAmF/C"}
|
|
@@ -3,6 +3,7 @@ import { env } from "node:process";
|
|
|
3
3
|
import { ensureConnections } from "./localConnections.js";
|
|
4
4
|
import { sqlInContainer, startContainer } from "./localContainer.js";
|
|
5
5
|
import { docker } from "./localDocker.js";
|
|
6
|
+
import { PostgresVersionMismatch } from "./PostgresVersionMismatch.js";
|
|
6
7
|
export const localServer = "postgresql://postgres:postgres@127.0.0.1:55432";
|
|
7
8
|
export function assertLocalDatabase(value, names) {
|
|
8
9
|
const url = new URL(value);
|
|
@@ -69,7 +70,7 @@ export function localPostgres(environment, { attempts = 30, delayMillis = 1000 }
|
|
|
69
70
|
}
|
|
70
71
|
function confirmVersion(observed) {
|
|
71
72
|
if (observed !== "18.6") {
|
|
72
|
-
throw new
|
|
73
|
+
throw new PostgresVersionMismatch(observed);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
let version;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localPostgres.js","sourceRoot":"","sources":["../../src/server/localPostgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAA0B,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"localPostgres.js","sourceRoot":"","sources":["../../src/server/localPostgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAA0B,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,MAAM,CAAC,MAAM,WAAW,GAAG,g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AAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACnC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC;YAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,8CAA8C,IAAI,GAAG,CAAC,EAAE,CAAC;gBACzE,GAAG,CAAC,MAAM,EAAE,oBAAoB,IAAI,GAAG,CAAC,CAAC;YAC1C,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/local-postgres",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Repeatable local PostgreSQL preparation with one shared persistent service",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/local-postgres#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"README.md"
|
|
41
41
|
],
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@shivaedev/quality": "0.
|
|
44
|
-
"@shivaedev/test-story": "0.
|
|
43
|
+
"@shivaedev/quality": "0.29.0",
|
|
44
|
+
"@shivaedev/test-story": "0.15.0",
|
|
45
45
|
"@types/node": "24.19.2",
|
|
46
46
|
"effect": "4.0.4",
|
|
47
47
|
"typescript": "7.0.2",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class PostgresVersionMismatch extends Error {
|
|
2
|
+
readonly _tag = "PostgresVersionMismatch";
|
|
3
|
+
readonly expectedVersion = "18.6";
|
|
4
|
+
readonly observedVersion: string | undefined;
|
|
5
|
+
|
|
6
|
+
constructor(observedVersion: string | undefined) {
|
|
7
|
+
super("Expected local PostgreSQL 18.6. Check the existing service; setup never removes containers or data.");
|
|
8
|
+
this.observedVersion = observedVersion;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -3,6 +3,7 @@ import { env } from "node:process";
|
|
|
3
3
|
import { ensureConnections } from "./localConnections.ts";
|
|
4
4
|
import { sqlInContainer, startContainer } from "./localContainer.ts";
|
|
5
5
|
import { type DockerEnvironment, docker } from "./localDocker.ts";
|
|
6
|
+
import { PostgresVersionMismatch } from "./PostgresVersionMismatch.ts";
|
|
6
7
|
|
|
7
8
|
export const localServer = "postgresql://postgres:postgres@127.0.0.1:55432";
|
|
8
9
|
|
|
@@ -80,7 +81,7 @@ export function localPostgres(environment: DockerEnvironment, { attempts = 30, d
|
|
|
80
81
|
}
|
|
81
82
|
function confirmVersion(observed: string | undefined) {
|
|
82
83
|
if (observed !== "18.6") {
|
|
83
|
-
throw new
|
|
84
|
+
throw new PostgresVersionMismatch(observed);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
let version: string | undefined;
|