@powerhousedao/reactor-api 6.2.3-dev.44 → 6.2.3-dev.45
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/dist/{adapter-http-express-CWqziB1p.mjs → adapter-http-express-P0t-mdMV.mjs} +6 -6
- package/dist/{adapter-http-express-CWqziB1p.mjs.map → adapter-http-express-P0t-mdMV.mjs.map} +1 -1
- package/dist/{adapter-http-fastify-CYZQ6FFv.mjs → adapter-http-fastify-D0OP5q9K.mjs} +6 -6
- package/dist/{adapter-http-fastify-CYZQ6FFv.mjs.map → adapter-http-fastify-D0OP5q9K.mjs.map} +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +46 -51
- package/dist/index.mjs.map +1 -1
- package/dist/pglite-node-Ow9i5Rb4.mjs +573 -0
- package/dist/pglite-node-Ow9i5Rb4.mjs.map +1 -0
- package/dist/src/pglite/pglite-node.d.mts +130 -0
- package/dist/src/pglite/pglite-node.d.mts.map +1 -0
- package/dist/src/pglite/pglite-node.mjs +4 -0
- package/package.json +18 -14
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ILogger } from "document-model";
|
|
2
|
+
import nodeFs from "node:fs";
|
|
3
|
+
import { PGlite } from "@electric-sql/pglite";
|
|
4
|
+
import { NodeFS } from "@electric-sql/pglite/nodefs";
|
|
5
|
+
//#region src/pglite/maintenance.d.ts
|
|
6
|
+
export declare const DEFAULT_MAINTENANCE_INTERVAL_MS: number;
|
|
7
|
+
export declare const DEFAULT_VACUUM_FULL_ABOVE_BYTES: number;
|
|
8
|
+
type MaintenanceOutcome = "vacuum" | "vacuum-full" | "idle" | "not-ready" | "in-transaction" | "failed";
|
|
9
|
+
interface MaintenanceLogger {
|
|
10
|
+
warn(message: string): void;
|
|
11
|
+
}
|
|
12
|
+
interface MaintenanceOptions {
|
|
13
|
+
/** VACUUM + CHECKPOINT cadence; PGlite has no autovacuum. Default 5 min; 0 disables. */
|
|
14
|
+
intervalMs?: number;
|
|
15
|
+
/** First pass runs VACUUM FULL when `base/` exceeds this at open. Default 256 MB; 0 disables. */
|
|
16
|
+
vacuumFullAboveBytes?: number;
|
|
17
|
+
logger?: MaintenanceLogger;
|
|
18
|
+
}
|
|
19
|
+
export declare class PgliteMaintenance {
|
|
20
|
+
private readonly intervalMs;
|
|
21
|
+
private readonly vacuumFullAboveBytes;
|
|
22
|
+
private readonly logger?;
|
|
23
|
+
private pg?;
|
|
24
|
+
private label;
|
|
25
|
+
private closing;
|
|
26
|
+
private syncsSinceMaintenance;
|
|
27
|
+
private vacuumFullPending;
|
|
28
|
+
private timer?;
|
|
29
|
+
private inFlight?;
|
|
30
|
+
constructor(options?: MaintenanceOptions);
|
|
31
|
+
get scheduled(): boolean;
|
|
32
|
+
get running(): boolean;
|
|
33
|
+
start(pg: PGlite, label: string, baseBytes: number): void;
|
|
34
|
+
noteSync(): void;
|
|
35
|
+
stop(): Promise<void>;
|
|
36
|
+
run(): Promise<MaintenanceOutcome>;
|
|
37
|
+
private schedule;
|
|
38
|
+
private cancel;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/pglite/durable-node-fs.d.ts
|
|
42
|
+
type NodeFsClass = typeof NodeFS;
|
|
43
|
+
interface DurableNodeFsOptions {
|
|
44
|
+
/** Default true; `PH_PGLITE_FSYNC=0` turns it off (power-loss durability off). */
|
|
45
|
+
fsync?: boolean;
|
|
46
|
+
/** Default 5 min; 0 disables. */
|
|
47
|
+
maintenanceIntervalMs?: number;
|
|
48
|
+
/** `base/` size at open; default 256 MB; 0 disables. */
|
|
49
|
+
vacuumFullAboveBytes?: number;
|
|
50
|
+
logger?: {
|
|
51
|
+
warn(message: string): void;
|
|
52
|
+
};
|
|
53
|
+
/** Emscripten abort (a Postgres PANIC, e.g. ENOSPC on WAL). */
|
|
54
|
+
onAbort?: (what: unknown) => void;
|
|
55
|
+
hostFs?: Pick<typeof nodeFs, "fsyncSync" | "fdatasyncSync">;
|
|
56
|
+
}
|
|
57
|
+
type DurableNodeFs = InstanceType<NodeFsClass> & {
|
|
58
|
+
readonly maintenance: PgliteMaintenance;
|
|
59
|
+
};
|
|
60
|
+
export declare function resolvePgliteFsync(env: Record<string, string | undefined>): boolean;
|
|
61
|
+
/** Built over the passed-in class so PG16 dirs on `pglite-legacy-02` get the same behaviour. */
|
|
62
|
+
export declare function createDurableNodeFs(Base: NodeFsClass, dataDir: string, options?: DurableNodeFsOptions): DurableNodeFs;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/pglite/sync-tree.d.ts
|
|
65
|
+
interface SyncTreeHostFs {
|
|
66
|
+
fsyncSync(fd: number): void;
|
|
67
|
+
}
|
|
68
|
+
interface SyncTreeResult {
|
|
69
|
+
files: number;
|
|
70
|
+
dirs: number;
|
|
71
|
+
}
|
|
72
|
+
/** One pass over a finished tree; interleaving fsync with writes costs seconds. */
|
|
73
|
+
export declare function syncTree(root: string, hostFs?: SyncTreeHostFs): SyncTreeResult;
|
|
74
|
+
/** fsyncs a directory's entries; false where the platform refuses (Windows). */
|
|
75
|
+
export declare function syncDirectory(dir: string, hostFs?: SyncTreeHostFs): boolean;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/pglite/snapshot-reader.d.ts
|
|
78
|
+
export declare const SNAPSHOT_FILE_NAME = "snapshot.bin";
|
|
79
|
+
interface ExtractSnapshotOptions {
|
|
80
|
+
chunkSize?: number;
|
|
81
|
+
/** Default true: one fsync pass over the tree after the last write. */
|
|
82
|
+
sync?: boolean;
|
|
83
|
+
hostFs?: SyncTreeHostFs;
|
|
84
|
+
}
|
|
85
|
+
interface ExtractedSnapshot {
|
|
86
|
+
pgVersionMajor: number;
|
|
87
|
+
/** `global/pg_control` bytes; absent only in synthetic trees. */
|
|
88
|
+
pgControl?: Buffer;
|
|
89
|
+
/** Entries written to disk; skipped entries are not counted. */
|
|
90
|
+
entries: number;
|
|
91
|
+
/** Size of the snapshot file. */
|
|
92
|
+
bytes: number;
|
|
93
|
+
}
|
|
94
|
+
/** Unpacks a snapshot into the existing `outDir`. */
|
|
95
|
+
export declare function extractSnapshot(snapshotPath: string, outDir: string, options?: ExtractSnapshotOptions): Promise<ExtractedSnapshot>;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/pglite/convert-snapshot-dir.d.ts
|
|
98
|
+
interface VerifyHandle {
|
|
99
|
+
query<T>(sql: string): Promise<{
|
|
100
|
+
rows: T[];
|
|
101
|
+
}>;
|
|
102
|
+
close(): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
type ConversionStep = "extract" | "verify" | "renameOld" | "renameNew" | "removeOld";
|
|
105
|
+
interface ConversionDeps {
|
|
106
|
+
/** Opens `dataDir` with the stock NodeFS of the PGlite module for `major`. */
|
|
107
|
+
openForVerify: (major: number, dataDir: string) => Promise<VerifyHandle>;
|
|
108
|
+
logger: ILogger;
|
|
109
|
+
/** Test hook: throw after a named step to simulate a crash there. */
|
|
110
|
+
afterStep?: (step: ConversionStep) => void | Promise<void>;
|
|
111
|
+
hostFs?: SyncTreeHostFs;
|
|
112
|
+
}
|
|
113
|
+
/** Settles the debris of an interrupted conversion; runs before it at boot. */
|
|
114
|
+
export declare function recoverConversion(dir: string, deps: ConversionDeps): Promise<void>;
|
|
115
|
+
/** Extracts into `.converting`, verifies by opening it, swaps through `.old`. */
|
|
116
|
+
export declare function convertSnapshotDir(dir: string, deps: ConversionDeps): Promise<"converted" | "none">;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/pglite/preflight.d.ts
|
|
119
|
+
/** PG major of the pinned @electric-sql/pglite; it exports none, so the test checks initdb. */
|
|
120
|
+
export declare const CURRENT_PGLITE_MAJOR = 17;
|
|
121
|
+
/** `openForVerify` over the loaded PGlite module only. */
|
|
122
|
+
export declare function openCurrentPgliteForVerify(major: number, dataDir: string): Promise<VerifyHandle>;
|
|
123
|
+
/** Converts a snapshot store and clears the files a previous run leaves behind. */
|
|
124
|
+
export declare function preparePgliteDataDir(dir: string, deps: ConversionDeps): Promise<void>;
|
|
125
|
+
/** PGlite leaves `postmaster.pid` after every close and `pg_wal/xlogtemp.*` after some. */
|
|
126
|
+
export declare function removeStalePgliteFiles(dir: string, logger: Pick<ILogger, "debug">): Promise<void>;
|
|
127
|
+
//#endregion
|
|
128
|
+
export type { ConversionDeps, ConversionStep, DurableNodeFs, DurableNodeFsOptions, ExtractSnapshotOptions, ExtractedSnapshot, MaintenanceLogger, MaintenanceOptions, MaintenanceOutcome, NodeFsClass, SyncTreeHostFs, SyncTreeResult, VerifyHandle };
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=pglite-node.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pglite-node.d.mts","names":[],"sources":["../../../src/pglite/maintenance.ts","../../../src/pglite/durable-node-fs.ts","../../../src/pglite/sync-tree.ts","../../../src/pglite/snapshot-reader.ts","../../../src/pglite/convert-snapshot-dir.ts","../../../src/pglite/preflight.ts"],"mappings":";;;;;qBAIa;qBACA;KAGD;UAQK;EACf,KAAK;;UAGU;;EAEf;;EAEA;EACA,SAAS;;qBAGE;mBACM;mBACA;mBACA;UAET;UACA;UACA;UACA;UACA;UACA;UACA;EAER,YAAY,UAAS;MAYjB;MAIA;EAIJ,MAAM,IAAI,QAAQ,eAAe;EAQjC;EAIM,QAAQ;EAMR,OAAO,QAAQ;UA+Cb;UAoBA;;;;KC1IE,qBAAqB;UAKhB;;EAEf;;EAEA;;EAEA;EACA;IAAW,KAAK;;;EAEhB,WAAW;EACX,SAAS,YAAY;;KAGX,gBAAgB,aAAa;WAC9B,aAAa;;wBAGR,mBACd,KAAK;;wBAmES,oBACd,MAAM,aACN,iBACA,UAAS,uBACR;;;UCnGc;EACf,UAAU;;UAGK;EACf;EACA;;;wBAIc,SACd,cACA,SAAQ,iBACP;;wBA+Ba,cACd,aACA,SAAQ;;;qBC3CG;UASI;EACf;;EAEA;EACA,SAAS;;UAGM;EACf;;EAEA,YAAY;;EAEZ;;EAEA;;;wBAIoB,gBACpB,sBACA,gBACA,UAAS,yBACR,QAAQ;;;UC/BM;EACf,MAAM,GAAG,cAAc;IAAU,MAAM;;EACvC,SAAS;;KAGC;UAOK;;EAEf,gBAAgB,eAAe,oBAAoB,QAAQ;EAC3D,QAAQ;;EAER,aAAa,MAAM,0BAA0B;EAC7C,SAAS;;;wBA6BW,kBACpB,aACA,MAAM,iBACL;;wBA6CmB,mBACpB,aACA,MAAM,iBACL;;;;qBC3FU;;wBAGS,2BACpB,eACA,kBACC,QAAQ;;wBAYW,qBACpB,aACA,MAAM,iBACL;;wBAOmB,uBACpB,aACA,QAAQ,KAAK,oBACZ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as convertSnapshotDir, c as extractSnapshot, d as syncDirectory, f as syncTree, h as PgliteMaintenance, i as removeStalePgliteFiles, l as createDurableNodeFs, m as DEFAULT_VACUUM_FULL_ABOVE_BYTES, n as openCurrentPgliteForVerify, o as recoverConversion, p as DEFAULT_MAINTENANCE_INTERVAL_MS, r as preparePgliteDataDir, s as SNAPSHOT_FILE_NAME, t as CURRENT_PGLITE_MAJOR, u as resolvePgliteFsync } from "../../pglite-node-Ow9i5Rb4.mjs";
|
|
2
|
+
export { CURRENT_PGLITE_MAJOR, DEFAULT_MAINTENANCE_INTERVAL_MS, DEFAULT_VACUUM_FULL_ABOVE_BYTES, PgliteMaintenance, SNAPSHOT_FILE_NAME, convertSnapshotDir, createDurableNodeFs, extractSnapshot, openCurrentPgliteForVerify, preparePgliteDataDir, recoverConversion, removeStalePgliteFiles, resolvePgliteFsync, syncDirectory, syncTree };
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6dd4c09b-2fd7-5402-83f6-a92c933064b1")}catch(e){}}();
|
|
4
|
+
//# debugId=6dd4c09b-2fd7-5402-83f6-a92c933064b1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/reactor-api",
|
|
3
|
-
"version": "6.2.3-dev.
|
|
3
|
+
"version": "6.2.3-dev.45",
|
|
4
4
|
"description": "GraphQL API layer for the Powerhouse reactor  auto-generated subgraphs per document model plus the core reactor subgraph for drive and document management.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"types": "./dist/https-hooks.d.mts",
|
|
25
25
|
"import": "./dist/src/packages/https-hooks.mjs"
|
|
26
26
|
},
|
|
27
|
+
"./pglite-node": {
|
|
28
|
+
"source": "./src/pglite/pglite-node.ts",
|
|
29
|
+
"types": "./dist/src/pglite/pglite-node.d.mts",
|
|
30
|
+
"import": "./dist/src/pglite/pglite-node.mjs"
|
|
31
|
+
},
|
|
27
32
|
"./test": {
|
|
28
33
|
"import": "./test/index.ts"
|
|
29
34
|
}
|
|
@@ -59,24 +64,23 @@
|
|
|
59
64
|
"@graphql-tools/schema": "10.0.31",
|
|
60
65
|
"@graphql-tools/utils": "11.0.0",
|
|
61
66
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
62
|
-
"@powerhousedao/analytics-engine-core": "6.2.3-dev.
|
|
63
|
-
"@powerhousedao/analytics-engine-graphql": "6.2.3-dev.
|
|
64
|
-
"@powerhousedao/analytics-engine-pg": "6.2.3-dev.
|
|
65
|
-
"@powerhousedao/config": "6.2.3-dev.
|
|
67
|
+
"@powerhousedao/analytics-engine-core": "6.2.3-dev.45",
|
|
68
|
+
"@powerhousedao/analytics-engine-graphql": "6.2.3-dev.45",
|
|
69
|
+
"@powerhousedao/analytics-engine-pg": "6.2.3-dev.45",
|
|
70
|
+
"@powerhousedao/config": "6.2.3-dev.45",
|
|
66
71
|
"@powerhousedao/document-engineering": "1.40.5",
|
|
67
|
-
"@powerhousedao/
|
|
68
|
-
"@powerhousedao/reactor": "6.2.3-dev.
|
|
69
|
-
"@powerhousedao/reactor-
|
|
70
|
-
"@powerhousedao/reactor-
|
|
71
|
-
"@powerhousedao/reactor-
|
|
72
|
-
"@powerhousedao/
|
|
73
|
-
"@
|
|
74
|
-
"@renown/sdk": "6.2.3-dev.44",
|
|
72
|
+
"@powerhousedao/reactor": "6.2.3-dev.45",
|
|
73
|
+
"@powerhousedao/reactor-attachments": "6.2.3-dev.45",
|
|
74
|
+
"@powerhousedao/reactor-drive": "6.2.3-dev.45",
|
|
75
|
+
"@powerhousedao/reactor-group": "6.2.3-dev.45",
|
|
76
|
+
"@powerhousedao/reactor-mcp": "6.2.3-dev.45",
|
|
77
|
+
"@powerhousedao/shared": "6.2.3-dev.45",
|
|
78
|
+
"@renown/sdk": "6.2.3-dev.45",
|
|
75
79
|
"body-parser": "^1.20.3",
|
|
76
80
|
"change-case": "5.4.4",
|
|
77
81
|
"cors": "^2.8.5",
|
|
78
82
|
"devcert": "^1.2.2",
|
|
79
|
-
"document-model": "6.2.3-dev.
|
|
83
|
+
"document-model": "6.2.3-dev.45",
|
|
80
84
|
"dotenv": "^16.4.5",
|
|
81
85
|
"es-module-lexer": "^2.0.0",
|
|
82
86
|
"express": "^4.22.1",
|