@pgpmjs/pglite-adapter 1.8.2 → 1.9.1

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/README.md CHANGED
@@ -60,6 +60,32 @@ await migrate.verify({ modulePath: './my-module' });
60
60
  await close(); // restores the previous factory and closes PGlite
61
61
  ```
62
62
 
63
+ ### As a pgpm CLI engine
64
+
65
+ The package also exports the pgpm driver-plugin entrypoint (`createPgpmDriver`),
66
+ so the `pgpm` CLI can deploy into PGlite with no server once this package is
67
+ installed in the workspace being deployed:
68
+
69
+ ```sh
70
+ pgpm deploy --engine pglite --package pets --database anything --yes
71
+ pgpm deploy --pglite=./.pglite --package pets --database anything --yes # persisted
72
+ ```
73
+
74
+ Or make it the workspace default in `pgpm.json`:
75
+
76
+ ```json
77
+ {
78
+ "packages": ["packages/*"],
79
+ "engine": "pglite",
80
+ "engines": { "pglite": { "options": { "dataDir": "./.pglite" } } }
81
+ }
82
+ ```
83
+
84
+ The options are the same `PgliteAdapterOptions` as `registerPglite`. The
85
+ driver reports `createdb`/`dump`/`serverLifecycle`/`multiConnection` as false, so
86
+ pgpm skips `deploy --createdb` and refuses `pgpm dump`, `pgpm docker`, `pgpm kill`,
87
+ `pgpm tune` and `pgpm admin-users` on this engine.
88
+
63
89
  ### Extensions
64
90
 
65
91
  pgpm's `cleanSql` strips `CREATE EXTENSION` from migrations, so extensions are
package/esm/index.js CHANGED
@@ -33,3 +33,26 @@ export const registerPglite = async (options = {}) => {
33
33
  }
34
34
  };
35
35
  };
36
+ /**
37
+ * The pgpm driver-plugin entrypoint (`createPgpmDriver`), which is how the pgpm
38
+ * CLI activates this backend for `--engine pglite` / `--driver
39
+ * @pgpmjs/pglite-adapter`. It registers the in-process PGlite instance as the
40
+ * pool factory — exactly what {@link registerPglite} does — and describes what
41
+ * PGlite cannot do so the CLI skips server-only steps generically.
42
+ *
43
+ * PGlite is one WASM instance with a single superuser session, so: the instance
44
+ * *is* the database (no `createdb`), there is no `pg_dump` binary and no server
45
+ * to manage, and a second concurrent connection is not available.
46
+ */
47
+ export const createPgpmDriver = async (options = {}) => {
48
+ const handle = await registerPglite(options);
49
+ return {
50
+ capabilities: {
51
+ createdb: false,
52
+ dump: false,
53
+ serverLifecycle: false,
54
+ multiConnection: false
55
+ },
56
+ teardown: () => handle.close()
57
+ };
58
+ };
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PGlite } from '@electric-sql/pglite';
2
+ import type { PgpmDriverSession } from '@pgpmjs/types';
2
3
  export { createPgliteClient, type QueryablePgClient } from './client';
3
4
  export { createPglitePool } from './pool';
4
5
  export type { PgResultLike } from './runner';
@@ -41,3 +42,15 @@ export interface PgliteAdapterHandle {
41
42
  * await close();
42
43
  */
43
44
  export declare const registerPglite: (options?: PgliteAdapterOptions) => Promise<PgliteAdapterHandle>;
45
+ /**
46
+ * The pgpm driver-plugin entrypoint (`createPgpmDriver`), which is how the pgpm
47
+ * CLI activates this backend for `--engine pglite` / `--driver
48
+ * @pgpmjs/pglite-adapter`. It registers the in-process PGlite instance as the
49
+ * pool factory — exactly what {@link registerPglite} does — and describes what
50
+ * PGlite cannot do so the CLI skips server-only steps generically.
51
+ *
52
+ * PGlite is one WASM instance with a single superuser session, so: the instance
53
+ * *is* the database (no `createdb`), there is no `pg_dump` binary and no server
54
+ * to manage, and a second concurrent connection is not available.
55
+ */
56
+ export declare const createPgpmDriver: (options?: PgliteAdapterOptions) => Promise<PgpmDriverSession>;
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerPglite = exports.createPglitePool = exports.createPgliteClient = void 0;
3
+ exports.createPgpmDriver = exports.registerPglite = exports.createPglitePool = exports.createPgliteClient = void 0;
4
4
  const pglite_1 = require("@electric-sql/pglite");
5
5
  const pg_cache_1 = require("pg-cache");
6
6
  const pool_1 = require("./pool");
@@ -39,3 +39,27 @@ const registerPglite = async (options = {}) => {
39
39
  };
40
40
  };
41
41
  exports.registerPglite = registerPglite;
42
+ /**
43
+ * The pgpm driver-plugin entrypoint (`createPgpmDriver`), which is how the pgpm
44
+ * CLI activates this backend for `--engine pglite` / `--driver
45
+ * @pgpmjs/pglite-adapter`. It registers the in-process PGlite instance as the
46
+ * pool factory — exactly what {@link registerPglite} does — and describes what
47
+ * PGlite cannot do so the CLI skips server-only steps generically.
48
+ *
49
+ * PGlite is one WASM instance with a single superuser session, so: the instance
50
+ * *is* the database (no `createdb`), there is no `pg_dump` binary and no server
51
+ * to manage, and a second concurrent connection is not available.
52
+ */
53
+ const createPgpmDriver = async (options = {}) => {
54
+ const handle = await (0, exports.registerPglite)(options);
55
+ return {
56
+ capabilities: {
57
+ createdb: false,
58
+ dump: false,
59
+ serverLifecycle: false,
60
+ multiConnection: false
61
+ },
62
+ teardown: () => handle.close()
63
+ };
64
+ };
65
+ exports.createPgpmDriver = createPgpmDriver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpmjs/pglite-adapter",
3
- "version": "1.8.2",
3
+ "version": "1.9.1",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PGlite driver for pgpm — registers an in-process PGlite instance as the pg-cache pool factory so the unmodified pgpm engine deploys into PGlite (WASM Postgres) with no server",
6
6
  "main": "index.js",
@@ -41,15 +41,17 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@electric-sql/pglite": "0.5.4",
44
- "@pgpmjs/core": "^7.15.0",
44
+ "@pgpmjs/core": "^7.17.0",
45
+ "@pgpmjs/types": "^2.48.0",
45
46
  "@types/pg": "^8.20.0",
46
- "makage": "^0.3.0"
47
+ "makage": "^0.3.0",
48
+ "pgpm": "^5.15.1"
47
49
  },
48
50
  "dependencies": {
49
- "pg-cache": "^3.23.1"
51
+ "pg-cache": "^3.23.3"
50
52
  },
51
53
  "peerDependencies": {
52
54
  "@electric-sql/pglite": ">=0.5.0"
53
55
  },
54
- "gitHead": "5ef8341033a8fbd85841b770e996e468dd15333b"
56
+ "gitHead": "2832d5632d11eb22e1437df773706ac6a99175fe"
55
57
  }