@shivaedev/local-postgres 0.14.1 → 0.16.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 +12 -0
- package/README.md +2 -0
- package/dist/server/assertLocalDatabase.d.ts +1 -1
- package/dist/server/assertLocalDatabase.d.ts.map +1 -1
- package/dist/server/assertLocalDatabase.js +7 -6
- package/dist/server/assertLocalDatabase.js.map +1 -1
- package/package.json +6 -6
- package/src/server/assertLocalDatabase.ts +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.0 - 2026-11-07
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Allow an explicit list of ports in `assertLocalDatabase` so test configuration can accept a loopback PostgreSQL CI service while shared development setup keeps port 55432 as its default.
|
|
8
|
+
|
|
9
|
+
## 0.15.0 - 2026-11-05
|
|
10
|
+
|
|
11
|
+
### Breaking
|
|
12
|
+
|
|
13
|
+
- Require Effect 4.1.0 and its matching companion packages. Move `effect`, `@effect/platform-node`, `@effect/platform-node-shared`, `@effect/sql-pg`, `@effect/sql-sqlite-node`, `@effect/atom-react` and `@effect/vitest` to exactly 4.1.0 together.
|
|
14
|
+
|
|
3
15
|
## 0.14.1 - 2026-11-04
|
|
4
16
|
|
|
5
17
|
### Changed
|
package/README.md
CHANGED
|
@@ -71,6 +71,8 @@ const setup = Effect.gen(function* () {
|
|
|
71
71
|
|
|
72
72
|
`assertLocalDatabase` applies the same local-target checks and also rejects a database name outside the caller's allowlist. The fixed names above provide an independent application policy.
|
|
73
73
|
|
|
74
|
+
`assertLocalDatabase(value, names, ports)` accepts an explicit allowed-port list when validating test configuration. Repository CI and generated app tests read `TEST_DATABASE_URL` through Effect Config and validate it with ports `["55432", "5432"]`, accepting the shared development service or a loopback PostgreSQL CI service. Remote hosts and redirecting connection parameters are refused. Omitting `ports` retains the shared setup restriction to port 55432. Service preparation always retains that restriction.
|
|
75
|
+
|
|
74
76
|
### 2. Once per feature: prepare its schema in application tooling
|
|
75
77
|
|
|
76
78
|
After `prepareDatabases`, run the application's own schema or migration entry point. This package provides no schema model, migration ledger, fixture catalogue or seed convention. `@shivaedev/sql` owns the SQL and migration APIs.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Result } from "effect";
|
|
2
2
|
import { LocalPostgresError } from "#server/LocalPostgresError.ts";
|
|
3
|
-
export declare function assertLocalDatabase(value: string, names: readonly string[]): Result.Result<import("url").URL, LocalPostgresError>;
|
|
3
|
+
export declare function assertLocalDatabase(value: string, names: readonly string[], ports?: readonly string[]): Result.Result<import("url").URL, LocalPostgresError>;
|
|
4
4
|
//# sourceMappingURL=assertLocalDatabase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertLocalDatabase.d.ts","sourceRoot":"","sources":["../../src/server/assertLocalDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"assertLocalDatabase.d.ts","sourceRoot":"","sources":["../../src/server/assertLocalDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,GAAE,SAAS,MAAM,EAAc,wDAiBhH"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Result } from "effect";
|
|
2
2
|
import { LocalPostgresError } from "#server/LocalPostgresError.ts";
|
|
3
|
-
export function assertLocalDatabase(value, names) {
|
|
3
|
+
export function assertLocalDatabase(value, names, ports = ["55432"]) {
|
|
4
4
|
return Result.gen(function* () {
|
|
5
|
-
const message = `Use a local database on 127.0.0.1
|
|
5
|
+
const message = `Use a local database on 127.0.0.1:${ports.join(" or ")} named ${names.join(" or ")}.`;
|
|
6
6
|
const url = yield* Result.try({ catch: () => new LocalPostgresError({ message }), try: () => new URL(value) });
|
|
7
|
-
if (!(["postgres:", "postgresql:"].includes(url.protocol)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
if (!(["postgres:", "postgresql:"].includes(url.protocol)
|
|
8
|
+
&& ["localhost", "127.0.0.1"].includes(url.hostname)
|
|
9
|
+
&& ports.includes(url.port)
|
|
10
|
+
&& names.includes(url.pathname.slice(1)))
|
|
11
|
+
|| ["host", "hostaddr", "port", "dbname", "service"].some((key) => url.searchParams.has(key))) {
|
|
11
12
|
return yield* Result.fail(new LocalPostgresError({ message }));
|
|
12
13
|
}
|
|
13
14
|
return url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertLocalDatabase.js","sourceRoot":"","sources":["../../src/server/assertLocalDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,KAAwB;
|
|
1
|
+
{"version":3,"file":"assertLocalDatabase.js","sourceRoot":"","sources":["../../src/server/assertLocalDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,KAAwB,EAAE,KAAK,GAAsB,CAAC,OAAO,CAAC;IAChH,OAAO,MAAM,CAAC,G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able 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,16 +40,16 @@
|
|
|
40
40
|
"README.md"
|
|
41
41
|
],
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@effect/platform-node": "4.
|
|
44
|
-
"@shivaedev/quality": "0.
|
|
45
|
-
"@shivaedev/test-story": "0.
|
|
43
|
+
"@effect/platform-node": "4.1.1",
|
|
44
|
+
"@shivaedev/quality": "0.69.5",
|
|
45
|
+
"@shivaedev/test-story": "0.45.1",
|
|
46
46
|
"@types/node": "24.19.2",
|
|
47
|
-
"effect": "4.
|
|
47
|
+
"effect": "4.1.1",
|
|
48
48
|
"typescript": "7.0.2",
|
|
49
49
|
"vitest": "5.0.5"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"effect": "4.
|
|
52
|
+
"effect": "4.1.1"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=24"
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Result } from "effect";
|
|
2
2
|
import { LocalPostgresError } from "#server/LocalPostgresError.ts";
|
|
3
3
|
|
|
4
|
-
export function assertLocalDatabase(value: string, names: readonly string[]) {
|
|
4
|
+
export function assertLocalDatabase(value: string, names: readonly string[], ports: readonly string[] = ["55432"]) {
|
|
5
5
|
return Result.gen(function* () {
|
|
6
|
-
const message = `Use a local database on 127.0.0.1
|
|
6
|
+
const message = `Use a local database on 127.0.0.1:${ports.join(" or ")} named ${names.join(" or ")}.`;
|
|
7
7
|
const url = yield* Result.try({ catch: () => new LocalPostgresError({ message }), try: () => new URL(value) });
|
|
8
8
|
if (
|
|
9
|
-
!(
|
|
10
|
-
|
|
9
|
+
!(
|
|
10
|
+
["postgres:", "postgresql:"].includes(url.protocol)
|
|
11
|
+
&& ["localhost", "127.0.0.1"].includes(url.hostname)
|
|
12
|
+
&& ports.includes(url.port)
|
|
13
|
+
&& names.includes(url.pathname.slice(1))
|
|
14
|
+
)
|
|
11
15
|
|| ["host", "hostaddr", "port", "dbname", "service"].some((key) => url.searchParams.has(key))
|
|
12
|
-
|| !names.includes(url.pathname.slice(1))
|
|
13
16
|
) {
|
|
14
17
|
return yield* Result.fail(new LocalPostgresError({ message }));
|
|
15
18
|
}
|