readpst 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Philip van Burleigh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # readpst
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Convert Outlook `.pst` (and `.ost`) files to `.eml` files from Node.js, using [libpst](https://www.five-ten-sg.com/libpst/)'s `readpst`.
4
+
5
+ ## Install
6
+
7
+ The `readpst` binary must be on your `PATH`:
8
+
9
+ ```sh
10
+ brew install libpst # macOS
11
+ apt install pst-utils # Debian/Ubuntu
12
+ apk add libpst # Alpine
13
+ ```
14
+
15
+ ```sh
16
+ npm install readpst
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```js
22
+ import { extract } from "readpst";
23
+
24
+ const files = await extract("mailbox.pst", { outDir: "out" });
25
+ // ["/abs/out/Inbox/1.eml", "/abs/out/Sent Items/1.eml", ...]
26
+ ```
27
+
28
+ `outDir` mirrors the PST's folder tree, with one RFC 822 `.eml` per message and attachments kept inline as MIME parts. Text is written as UTF-8.
29
+
30
+ ### Options
31
+
32
+ | Option | Default | Description |
33
+ | ------------- | ------------- | ----------------------------------------------------------------- |
34
+ | `outDir` | (required) | Output directory, created if missing |
35
+ | `types` | `["email"]` | Any of `"email"`, `"appointment"`, `"journal"`, `"contact"` |
36
+ | `readpstPath` | `"readpst"` | Path to the binary |
37
+
38
+ `readpst` needs a seekable file on local disk, so download a remote PST to a temp file first. Cleaning up `outDir` is up to you.
39
+
40
+ ## License
41
+
42
+ MIT. libpst itself is GPL-2.0; this package only runs it as a separate program and does not bundle it.
package/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export type ItemType = "email" | "appointment" | "journal" | "contact";
2
+
3
+ export interface ExtractOptions {
4
+ /** Directory to write into. Created if missing; mirrors the PST's folder tree. */
5
+ outDir: string;
6
+ /** Item types to export. Defaults to ["email"]. */
7
+ types?: ItemType[];
8
+ /** Path to the readpst binary. Defaults to "readpst" on PATH. */
9
+ readpstPath?: string;
10
+ }
11
+
12
+ /** Converts a .pst/.ost into one .eml per item and resolves to the absolute paths of the written files. */
13
+ export function extract(pstPath: string, options: ExtractOptions): Promise<string[]>;
package/index.js ADDED
@@ -0,0 +1,32 @@
1
+ import { execFile } from "node:child_process";
2
+ import { mkdir, readdir } from "node:fs/promises";
3
+ import { join, resolve } from "node:path";
4
+ import { promisify } from "node:util";
5
+
6
+ const run = promisify(execFile);
7
+
8
+ const TYPE_CODES = { email: "e", appointment: "a", journal: "j", contact: "c" };
9
+
10
+ export async function extract(pstPath, { outDir, types = ["email"], readpstPath = "readpst" }) {
11
+ const dir = resolve(outDir);
12
+ await mkdir(dir, { recursive: true });
13
+
14
+ const typeCodes = types.map((type) => {
15
+ if (!TYPE_CODES[type]) throw new Error(`Unknown item type "${type}"`);
16
+ return TYPE_CODES[type];
17
+ });
18
+
19
+ try {
20
+ await run(readpstPath, ["-e", "-8", "-q", "-t", typeCodes.join(","), "-o", dir, resolve(pstPath)]);
21
+ } catch (error) {
22
+ if (error.code === "ENOENT") {
23
+ throw new Error(
24
+ `"${readpstPath}" not found. Install libpst: brew install libpst, apt install pst-utils or apk add libpst`
25
+ );
26
+ }
27
+ throw new Error(`readpst failed: ${(error.stderr || error.stdout)?.trim() || error.message}`, { cause: error });
28
+ }
29
+
30
+ const entries = await readdir(dir, { recursive: true, withFileTypes: true });
31
+ return entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name));
32
+ }
package/package.json CHANGED
@@ -1,6 +1,20 @@
1
1
  {
2
2
  "name": "readpst",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Convert Outlook .pst files to .eml files with libpst's readpst",
5
+ "keywords": ["pst", "ost", "outlook", "eml", "email", "readpst", "libpst"],
6
+ "author": "Philip van Burleigh",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "exports": {
10
+ "types": "./index.d.ts",
11
+ "default": "./index.js"
12
+ },
13
+ "files": ["index.js", "index.d.ts"],
14
+ "engines": {
15
+ "node": ">=20.12"
16
+ },
17
+ "scripts": {
18
+ "test": "node --test"
19
+ }
20
+ }