@pgxsinkit/pgwasm 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.
Files changed (209) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-APACHE-2.0 +202 -0
  3. package/NOTICE +111 -0
  4. package/README.md +56 -0
  5. package/dist/build/index.d.ts +8 -0
  6. package/dist/build/index.d.ts.map +1 -0
  7. package/dist/build/index.js +21 -0
  8. package/dist/build/index.js.map +9 -0
  9. package/dist/build/seam.d.ts +174 -0
  10. package/dist/build/seam.d.ts.map +1 -0
  11. package/dist/chunk-0w227vw2.js +233 -0
  12. package/dist/chunk-0w227vw2.js.map +11 -0
  13. package/dist/chunk-74gcrk47.js +563 -0
  14. package/dist/chunk-74gcrk47.js.map +14 -0
  15. package/dist/chunk-at1py5s5.js +373 -0
  16. package/dist/chunk-at1py5s5.js.map +12 -0
  17. package/dist/chunk-cpsnmzrf.js +126 -0
  18. package/dist/chunk-cpsnmzrf.js.map +10 -0
  19. package/dist/chunk-d82gg1hx.js +306 -0
  20. package/dist/chunk-d82gg1hx.js.map +10 -0
  21. package/dist/chunk-gjf102c9.js +1005 -0
  22. package/dist/chunk-gjf102c9.js.map +16 -0
  23. package/dist/chunk-kb3rsr7n.js +19 -0
  24. package/dist/chunk-kb3rsr7n.js.map +9 -0
  25. package/dist/chunk-tdvrvgt5.js +83 -0
  26. package/dist/chunk-tdvrvgt5.js.map +11 -0
  27. package/dist/chunk-z0c40tja.js +50 -0
  28. package/dist/chunk-z0c40tja.js.map +10 -0
  29. package/dist/core/data-dir-archive.d.ts +17 -0
  30. package/dist/core/data-dir-archive.d.ts.map +1 -0
  31. package/dist/core/internals.d.ts +59 -0
  32. package/dist/core/internals.d.ts.map +1 -0
  33. package/dist/core/marker.d.ts +35 -0
  34. package/dist/core/marker.d.ts.map +1 -0
  35. package/dist/core/mutex.d.ts +9 -0
  36. package/dist/core/mutex.d.ts.map +1 -0
  37. package/dist/core/names.d.ts +11 -0
  38. package/dist/core/names.d.ts.map +1 -0
  39. package/dist/core/parse.d.ts +11 -0
  40. package/dist/core/parse.d.ts.map +1 -0
  41. package/dist/core/pgwasm.d.ts +53 -0
  42. package/dist/core/pgwasm.d.ts.map +1 -0
  43. package/dist/core/storage.d.ts +14 -0
  44. package/dist/core/storage.d.ts.map +1 -0
  45. package/dist/create.d.ts +10 -0
  46. package/dist/create.d.ts.map +1 -0
  47. package/dist/drizzle/codecs.d.ts +9 -0
  48. package/dist/drizzle/codecs.d.ts.map +1 -0
  49. package/dist/drizzle/driver.d.ts +50 -0
  50. package/dist/drizzle/driver.d.ts.map +1 -0
  51. package/dist/drizzle/index.d.ts +4 -0
  52. package/dist/drizzle/index.d.ts.map +1 -0
  53. package/dist/drizzle/index.js +261 -0
  54. package/dist/drizzle/index.js.map +12 -0
  55. package/dist/drizzle/session.d.ts +39 -0
  56. package/dist/drizzle/session.d.ts.map +1 -0
  57. package/dist/errors.d.ts +115 -0
  58. package/dist/errors.d.ts.map +1 -0
  59. package/dist/fs/base-filesystem.d.ts +118 -0
  60. package/dist/fs/base-filesystem.d.ts.map +1 -0
  61. package/dist/fs/index.d.ts +2 -0
  62. package/dist/fs/index.d.ts.map +1 -0
  63. package/dist/fs/index.js +11 -0
  64. package/dist/fs/index.js.map +9 -0
  65. package/dist/index.d.ts +8 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +53 -0
  68. package/dist/index.js.map +9 -0
  69. package/dist/interface.d.ts +165 -0
  70. package/dist/interface.d.ts.map +1 -0
  71. package/dist/live/debounce-mutex.d.ts +6 -0
  72. package/dist/live/debounce-mutex.d.ts.map +1 -0
  73. package/dist/live/format-query.d.ts +8 -0
  74. package/dist/live/format-query.d.ts.map +1 -0
  75. package/dist/live/index.d.ts +9 -0
  76. package/dist/live/index.d.ts.map +1 -0
  77. package/dist/live/index.js +601 -0
  78. package/dist/live/index.js.map +12 -0
  79. package/dist/live/interface.d.ts +86 -0
  80. package/dist/live/interface.d.ts.map +1 -0
  81. package/dist/opfs/broker/client.d.ts +163 -0
  82. package/dist/opfs/broker/client.d.ts.map +1 -0
  83. package/dist/opfs/broker/protocol.d.ts +326 -0
  84. package/dist/opfs/broker/protocol.d.ts.map +1 -0
  85. package/dist/opfs/broker/server.d.ts +84 -0
  86. package/dist/opfs/broker/server.d.ts.map +1 -0
  87. package/dist/opfs/core/checksum.d.ts +3 -0
  88. package/dist/opfs/core/checksum.d.ts.map +1 -0
  89. package/dist/opfs/core/codec.d.ts +73 -0
  90. package/dist/opfs/core/codec.d.ts.map +1 -0
  91. package/dist/opfs/core/errors.d.ts +80 -0
  92. package/dist/opfs/core/errors.d.ts.map +1 -0
  93. package/dist/opfs/core/limits.d.ts +35 -0
  94. package/dist/opfs/core/limits.d.ts.map +1 -0
  95. package/dist/opfs/core/memory-port.d.ts +51 -0
  96. package/dist/opfs/core/memory-port.d.ts.map +1 -0
  97. package/dist/opfs/core/metadata-store.d.ts +19 -0
  98. package/dist/opfs/core/metadata-store.d.ts.map +1 -0
  99. package/dist/opfs/core/mounted-vfs.d.ts +119 -0
  100. package/dist/opfs/core/mounted-vfs.d.ts.map +1 -0
  101. package/dist/opfs/core/path.d.ts +14 -0
  102. package/dist/opfs/core/path.d.ts.map +1 -0
  103. package/dist/opfs/core/port.d.ts +30 -0
  104. package/dist/opfs/core/port.d.ts.map +1 -0
  105. package/dist/opfs/core/repacked-vfs.d.ts +138 -0
  106. package/dist/opfs/core/repacked-vfs.d.ts.map +1 -0
  107. package/dist/opfs/core/state-machine.d.ts +296 -0
  108. package/dist/opfs/core/state-machine.d.ts.map +1 -0
  109. package/dist/opfs/create.d.ts +50 -0
  110. package/dist/opfs/create.d.ts.map +1 -0
  111. package/dist/opfs/file-port.d.ts +14 -0
  112. package/dist/opfs/file-port.d.ts.map +1 -0
  113. package/dist/opfs/index.d.ts +37 -0
  114. package/dist/opfs/index.d.ts.map +1 -0
  115. package/dist/opfs/index.js +6671 -0
  116. package/dist/opfs/index.js.map +28 -0
  117. package/dist/opfs/opfs-port.d.ts +34 -0
  118. package/dist/opfs/opfs-port.d.ts.map +1 -0
  119. package/dist/opfs/opfs-repacked-fs.d.ts +55 -0
  120. package/dist/opfs/opfs-repacked-fs.d.ts.map +1 -0
  121. package/dist/opfs/wasi/preview1.d.ts +228 -0
  122. package/dist/opfs/wasi/preview1.d.ts.map +1 -0
  123. package/dist/protocol/index.d.ts +15 -0
  124. package/dist/protocol/index.d.ts.map +1 -0
  125. package/dist/protocol/index.js +23 -0
  126. package/dist/protocol/index.js.map +10 -0
  127. package/dist/protocol/wire/buffer-reader.d.ts +13 -0
  128. package/dist/protocol/wire/buffer-reader.d.ts.map +1 -0
  129. package/dist/protocol/wire/buffer-writer.d.ts +12 -0
  130. package/dist/protocol/wire/buffer-writer.d.ts.map +1 -0
  131. package/dist/protocol/wire/index.d.ts +5 -0
  132. package/dist/protocol/wire/index.d.ts.map +1 -0
  133. package/dist/protocol/wire/messages.d.ts +194 -0
  134. package/dist/protocol/wire/messages.d.ts.map +1 -0
  135. package/dist/protocol/wire/parser.d.ts +12 -0
  136. package/dist/protocol/wire/parser.d.ts.map +1 -0
  137. package/dist/protocol/wire/serializer.d.ts +61 -0
  138. package/dist/protocol/wire/serializer.d.ts.map +1 -0
  139. package/dist/protocol/wire/string-utils.d.ts +6 -0
  140. package/dist/protocol/wire/string-utils.d.ts.map +1 -0
  141. package/dist/protocol/wire/types.d.ts +7 -0
  142. package/dist/protocol/wire/types.d.ts.map +1 -0
  143. package/dist/tar/gzip.d.ts +7 -0
  144. package/dist/tar/gzip.d.ts.map +1 -0
  145. package/dist/tar/tar.d.ts +39 -0
  146. package/dist/tar/tar.d.ts.map +1 -0
  147. package/dist/templating.d.ts +42 -0
  148. package/dist/templating.d.ts.map +1 -0
  149. package/dist/types.d.ts +76 -0
  150. package/dist/types.d.ts.map +1 -0
  151. package/package.json +69 -0
  152. package/skills/opfs/SKILL.md +138 -0
  153. package/src/build/index.ts +23 -0
  154. package/src/build/seam.ts +179 -0
  155. package/src/core/data-dir-archive.ts +68 -0
  156. package/src/core/internals.ts +87 -0
  157. package/src/core/marker.ts +94 -0
  158. package/src/core/mutex.ts +16 -0
  159. package/src/core/names.ts +26 -0
  160. package/src/core/parse.ts +79 -0
  161. package/src/core/pgwasm.ts +876 -0
  162. package/src/core/storage.ts +70 -0
  163. package/src/create.ts +134 -0
  164. package/src/drizzle/codecs.ts +114 -0
  165. package/src/drizzle/driver.ts +141 -0
  166. package/src/drizzle/index.ts +15 -0
  167. package/src/drizzle/session.ts +133 -0
  168. package/src/errors.ts +201 -0
  169. package/src/fs/base-filesystem.ts +149 -0
  170. package/src/fs/index.ts +7 -0
  171. package/src/index.ts +44 -0
  172. package/src/interface.ts +186 -0
  173. package/src/live/debounce-mutex.ts +45 -0
  174. package/src/live/format-query.ts +47 -0
  175. package/src/live/index.ts +707 -0
  176. package/src/live/interface.ts +109 -0
  177. package/src/opfs/broker/client.ts +482 -0
  178. package/src/opfs/broker/protocol.ts +624 -0
  179. package/src/opfs/broker/server.ts +522 -0
  180. package/src/opfs/core/checksum.ts +85 -0
  181. package/src/opfs/core/codec.ts +1051 -0
  182. package/src/opfs/core/errors.ts +134 -0
  183. package/src/opfs/core/limits.ts +68 -0
  184. package/src/opfs/core/memory-port.ts +459 -0
  185. package/src/opfs/core/metadata-store.ts +512 -0
  186. package/src/opfs/core/mounted-vfs.ts +407 -0
  187. package/src/opfs/core/path.ts +82 -0
  188. package/src/opfs/core/port.ts +114 -0
  189. package/src/opfs/core/repacked-vfs.ts +1464 -0
  190. package/src/opfs/core/state-machine.ts +1699 -0
  191. package/src/opfs/create.ts +125 -0
  192. package/src/opfs/file-port.ts +183 -0
  193. package/src/opfs/index.ts +113 -0
  194. package/src/opfs/opfs-port.ts +90 -0
  195. package/src/opfs/opfs-repacked-fs.ts +210 -0
  196. package/src/opfs/wasi/preview1.ts +1016 -0
  197. package/src/protocol/index.ts +24 -0
  198. package/src/protocol/wire/buffer-reader.ts +60 -0
  199. package/src/protocol/wire/buffer-writer.ts +93 -0
  200. package/src/protocol/wire/index.ts +15 -0
  201. package/src/protocol/wire/messages.ts +332 -0
  202. package/src/protocol/wire/parser.ts +373 -0
  203. package/src/protocol/wire/serializer.ts +233 -0
  204. package/src/protocol/wire/string-utils.ts +18 -0
  205. package/src/protocol/wire/types.ts +12 -0
  206. package/src/tar/gzip.ts +36 -0
  207. package/src/tar/tar.ts +253 -0
  208. package/src/templating.ts +103 -0
  209. package/src/types.ts +283 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/protocol/wire/messages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,MAAM,WAAW,GACnB,eAAe,GACf,cAAc,GACd,eAAe,GACf,QAAQ,GACR,iBAAiB,GACjB,kBAAkB,GAClB,YAAY,GACZ,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,sBAAsB,GACtB,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,iBAAiB,GACjB,SAAS,GACT,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,2BAA2B,GAC3B,iCAAiC,GACjC,oBAAoB,GACpB,4BAA4B,GAC5B,yBAAyB,GACzB,OAAO,GACP,QAAQ,CAAC;AAEb,oGAAoG;AACpG,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,aAAa,EAAE,cAAqD,CAAC;AAClF,eAAO,MAAM,YAAY,EAAE,cAAoD,CAAC;AAChF,eAAO,MAAM,aAAa,EAAE,cAAqD,CAAC;AAClF,eAAO,MAAM,MAAM,EAAE,cAA8C,CAAC;AACpE,eAAO,MAAM,eAAe,EAAE,cAAuD,CAAC;AACtF,eAAO,MAAM,gBAAgB,EA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GAAG,SAAS,CAAC;IAC5B,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAGtD;CACF"}
@@ -0,0 +1,12 @@
1
+ import { type BackendMessage } from "./messages";
2
+ import { type BufferParameter } from "./types";
3
+ export type MessageCallback = (msg: BackendMessage) => void;
4
+ /**
5
+ * Parses backend messages out of a byte stream that may arrive in arbitrary chunks: a message split
6
+ * across calls is buffered until the rest arrives.
7
+ */
8
+ export declare class Parser {
9
+ #private;
10
+ parse(buffer: BufferParameter, callback: MessageCallback): void;
11
+ }
12
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/protocol/wire/parser.ts"],"names":[],"mappings":"AAKA,OAAO,EA6BL,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAkCtD,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;AAE5D;;;GAGG;AACH,qBAAa,MAAM;;IAMjB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAgC9D;CAiQF"}
@@ -0,0 +1,61 @@
1
+ /** A bind parameter: text, raw bytes (sent as binary), or SQL NULL. */
2
+ export type LegalValue = string | ArrayBuffer | ArrayBufferView | null;
3
+ declare function startup(opts: Record<string, string>): Uint8Array<ArrayBuffer>;
4
+ declare function requestSsl(): Uint8Array<ArrayBuffer>;
5
+ declare function password(value: string): Uint8Array<ArrayBuffer>;
6
+ declare function sendSASLInitialResponseMessage(mechanism: string, initialResponse: string): Uint8Array<ArrayBuffer>;
7
+ declare function sendSCRAMClientFinalMessage(additionalData: string): Uint8Array<ArrayBuffer>;
8
+ declare function query(text: string): Uint8Array<ArrayBuffer>;
9
+ export interface ParseOpts {
10
+ name?: string;
11
+ types?: readonly number[];
12
+ text: string;
13
+ }
14
+ declare function parse(opts: ParseOpts): Uint8Array<ArrayBuffer>;
15
+ type ValueMapper = (param: unknown, index: number) => LegalValue;
16
+ export interface BindOpts {
17
+ portal?: string;
18
+ binary?: boolean;
19
+ statement?: string;
20
+ values?: readonly LegalValue[];
21
+ /** Optional map from a JS value to the value sent, per parameter. */
22
+ valueMapper?: ValueMapper;
23
+ }
24
+ declare function bind(config?: BindOpts): Uint8Array<ArrayBuffer>;
25
+ export interface ExecOpts {
26
+ portal?: string;
27
+ rows?: number;
28
+ }
29
+ declare function execute(config?: ExecOpts): Uint8Array<ArrayBuffer>;
30
+ declare function cancel(processID: number, secretKey: number): Uint8Array<ArrayBuffer>;
31
+ export interface PortalOpts {
32
+ type: "S" | "P";
33
+ name?: string;
34
+ }
35
+ declare function describe(msg: PortalOpts): Uint8Array<ArrayBuffer>;
36
+ declare function close(msg: PortalOpts): Uint8Array<ArrayBuffer>;
37
+ declare function copyData(chunk: ArrayBuffer | ArrayBufferView): Uint8Array<ArrayBuffer>;
38
+ declare function copyFail(message: string): Uint8Array<ArrayBuffer>;
39
+ /** Frontend message builders. */
40
+ export declare const serialize: {
41
+ startup: typeof startup;
42
+ password: typeof password;
43
+ requestSsl: typeof requestSsl;
44
+ sendSASLInitialResponseMessage: typeof sendSASLInitialResponseMessage;
45
+ sendSCRAMClientFinalMessage: typeof sendSCRAMClientFinalMessage;
46
+ query: typeof query;
47
+ parse: typeof parse;
48
+ bind: typeof bind;
49
+ execute: typeof execute;
50
+ describe: typeof describe;
51
+ close: typeof close;
52
+ flush: () => Uint8Array<ArrayBuffer>;
53
+ sync: () => Uint8Array<ArrayBuffer>;
54
+ end: () => Uint8Array<ArrayBuffer>;
55
+ copyData: typeof copyData;
56
+ copyDone: () => Uint8Array<ArrayBuffer>;
57
+ copyFail: typeof copyFail;
58
+ cancel: typeof cancel;
59
+ };
60
+ export {};
61
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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A2BD,iBAAS,IAAI,CAAC,MAAM,GAAE,QAAa,GAAG,UAAU,CAAC,WAAW,CAAC,CAe5D;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAID,iBAAS,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,CAe3D;AAED,iBAAS,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAQ7E;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AASD,iBAAS,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAG1D;AAED,iBAAS,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAEvD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,GAAG,UAAU,CAAC,WAAW,CAAC,CAE/E;AAED,iBAAS,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAE1D;AAUD,iCAAiC;AACjC,eAAO,MAAM,SAAS;;;;;;;;;;;;iBAYT,UAAU,CAAC,WAAW,CAAC;gBACxB,UAAU,CAAC,WAAW,CAAC;eACxB,UAAU,CAAC,WAAW,CAAC;;oBAElB,UAAU,CAAC,WAAW,CAAC;;;CAGtC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The byte length of a string once UTF-8 encoded.
3
+ * Adapted from https://stackoverflow.com/a/23329386
4
+ */
5
+ export declare function byteLengthUtf8(str: string): number;
6
+ //# sourceMappingURL=string-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../../src/protocol/wire/string-utils.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASlD"}
@@ -0,0 +1,7 @@
1
+ export declare const Modes: {
2
+ readonly text: 0;
3
+ readonly binary: 1;
4
+ };
5
+ export type Mode = (typeof Modes)[keyof typeof Modes];
6
+ export type BufferParameter = ArrayBuffer | ArrayBufferView;
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/protocol/wire/types.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK;aAChB,IAAI,EAAE,CAAC;aACP,MAAM,EAAE,CAAC;CACD,CAAC;AAEX,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** Whether the bytes start with the gzip magic number. */
2
+ export declare function isGzip(bytes: Uint8Array): boolean;
3
+ export declare function gzip(bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
4
+ export declare function gunzip(bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
5
+ /** Decompress when the bytes are gzip (by magic number), otherwise return them unchanged. */
6
+ export declare function gunzipIfCompressed(bytes: Uint8Array): Promise<Uint8Array>;
7
+ //# sourceMappingURL=gzip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../../src/tar/gzip.ts"],"names":[],"mappings":"AAWA,0DAA0D;AAC1D,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEjD;AAED,wBAAsB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAE9E;AAED,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAEhF;AAED,6FAA6F;AAC7F,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/E"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A minimal ustar codec: regular files and directories, which is everything a Postgres data
3
+ * directory and an npm tarball hold.
4
+ *
5
+ * Writing produces the layout pgwasm's Store backups have always had: a 512-byte ustar header per
6
+ * entry, the name in the `name` field when it fits (99 bytes), the payload padded to a record, and
7
+ * two zero records at the end. Reading also accepts what other writers add around that: a name
8
+ * split into `prefix` + `name`, PAX extended headers (`x`, per entry; `g`, global and ignored) and GNU
9
+ * long names (`L`). Links, devices and FIFOs are refused rather than skipped, so an archive with
10
+ * content this codec cannot represent fails loudly instead of restoring partially.
11
+ *
12
+ * Reading is strict about completeness, for the same reason: a data directory restored from part of
13
+ * a backup is a corrupt database. A header or payload cut short, a size that is not a number, a
14
+ * header whose checksum fails and an archive without its two zero end records are all refused. The
15
+ * end records are required because every writer whose archives reach this reader writes them: every
16
+ * PGlite Store backup came from tinytar's `tar()`, which always appends them (checked for the fork's
17
+ * dumps and the prepopulated data directory), as do npm's tarballs and the extension bundles.
18
+ */
19
+ /** One archive member. */
20
+ export interface TarEntry {
21
+ /** The member's path as stored, `/`-separated. */
22
+ readonly name: string;
23
+ readonly type: "file" | "directory";
24
+ /** Permission bits (the `0o7777` part of the mode). */
25
+ readonly mode: number;
26
+ /** Modification time, whole seconds since the epoch. */
27
+ readonly mtimeSeconds: number;
28
+ /** The file's bytes; empty for a directory. */
29
+ readonly data: Uint8Array;
30
+ }
31
+ /** An archive this codec cannot read or represent. */
32
+ export declare class TarFormatError extends Error {
33
+ readonly name = "TarFormatError";
34
+ }
35
+ /** Serialize entries into an uncompressed ustar archive. */
36
+ export declare function writeTar(entries: readonly TarEntry[]): Uint8Array;
37
+ /** Parse an uncompressed ustar archive. Throws {@link TarFormatError} for anything it cannot represent. */
38
+ export declare function readTar(archive: Uint8Array): TarEntry[];
39
+ //# sourceMappingURL=tar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../src/tar/tar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,0BAA0B;AAC1B,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAED,sDAAsD;AACtD,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAkB,IAAI,oBAAoB;CAC3C;AAQD,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,GAAG,UAAU,CAajE;AAED,2GAA2G;AAC3G,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,QAAQ,EAAE,CA+DvD"}
@@ -0,0 +1,42 @@
1
+ declare const TemplateType: {
2
+ readonly part: "part";
3
+ readonly container: "container";
4
+ };
5
+ /** A literal piece of SQL (an identifier or raw text) spliced into a template without a parameter. */
6
+ export interface TemplatePart {
7
+ readonly _templateType: typeof TemplateType.part;
8
+ readonly str: string;
9
+ }
10
+ /** A nested template: its strings and its parameter values. */
11
+ export interface TemplateContainer {
12
+ readonly _templateType: typeof TemplateType.container;
13
+ readonly strings: TemplateStringsArray;
14
+ readonly values: unknown[];
15
+ }
16
+ /** A parametrized query: `$1`-numbered text and its parameters. */
17
+ export interface TemplatedQuery {
18
+ readonly query: string;
19
+ readonly params: unknown[];
20
+ }
21
+ /**
22
+ * Nest SQL templates without losing their parametrization:
23
+ *
24
+ * ```ts
25
+ * pg.sql`SELECT * FROM tale ${withFilter ? sql`WHERE foo = ${fooVar}` : sql``}`
26
+ * ```
27
+ */
28
+ export declare function sql(strings: TemplateStringsArray, ...values: unknown[]): TemplateContainer;
29
+ /**
30
+ * An identifier spliced into a template, double-quoted and not parametrized:
31
+ *
32
+ * ```ts
33
+ * pg.sql`SELECT * FROM ${identifier`foo`} WHERE ${identifier`id`} = ${id}`
34
+ * ```
35
+ */
36
+ export declare function identifier(strings: TemplateStringsArray, ...values: unknown[]): TemplatePart;
37
+ /** Raw SQL spliced into a template as it is, neither parametrized nor escaped. */
38
+ export declare function raw(strings: TemplateStringsArray, ...values: unknown[]): TemplatePart;
39
+ /** Turn a template into `$1`-numbered query text and its parameters. */
40
+ export declare function query(strings: TemplateStringsArray, ...values: unknown[]): TemplatedQuery;
41
+ export {};
42
+ //# sourceMappingURL=templating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templating.d.ts","sourceRoot":"","sources":["../src/templating.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,YAAY;aAChB,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,WAAW;CACd,CAAC;AAEX,sGAAsG;AACtG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,YAAY,CAAC,IAAI,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,YAAY,CAAC,SAAS,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAED,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAoBD;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAyB1F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAE5F;AAED,kFAAkF;AAClF,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAErF;AAED,wEAAwE;AACxE,wBAAgB,KAAK,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAMzF"}
@@ -0,0 +1,76 @@
1
+ import type { ParserOptions } from "./interface";
2
+ /** Built-in type OIDs. */
3
+ export declare const BOOL = 16, BYTEA = 17, CHAR = 18, INT8 = 20, INT2 = 21, INT4 = 23, REGPROC = 24, TEXT = 25, OID = 26, TID = 27, XID = 28, CID = 29, JSON = 114, XML = 142, PG_NODE_TREE = 194, SMGR = 210, PATH = 602, POLYGON = 604, CIDR = 650, FLOAT4 = 700, FLOAT8 = 701, ABSTIME = 702, RELTIME = 703, TINTERVAL = 704, CIRCLE = 718, MACADDR8 = 774, MONEY = 790, MACADDR = 829, INET = 869, ACLITEM = 1033, BPCHAR = 1042, VARCHAR = 1043, DATE = 1082, TIME = 1083, TIMESTAMP = 1114, TIMESTAMPTZ = 1184, INTERVAL = 1186, TIMETZ = 1266, BIT = 1560, VARBIT = 1562, NUMERIC = 1700, REFCURSOR = 1790, REGPROCEDURE = 2202, REGOPER = 2203, REGOPERATOR = 2204, REGCLASS = 2205, REGTYPE = 2206, UUID = 2950, TXID_SNAPSHOT = 2970, PG_LSN = 3220, PG_NDISTINCT = 3361, PG_DEPENDENCIES = 3402, TSVECTOR = 3614, TSQUERY = 3615, GTSVECTOR = 3642, REGCONFIG = 3734, REGDICTIONARY = 3769, JSONB = 3802, REGNAMESPACE = 4089, REGROLE = 4096;
4
+ /** Turns a value's text representation into a JS value. */
5
+ export type Parser = (value: string, typeId?: number) => unknown;
6
+ /** Turns a JS value into its text representation. */
7
+ export type Serializer = (value: unknown) => string;
8
+ declare function serializeString(value: unknown): string;
9
+ declare function serializeBoolean(value: unknown): string;
10
+ declare function serializeDate(value: unknown): string;
11
+ declare function serializeBytea(value: unknown): string;
12
+ declare function parseBytea(value: string): Uint8Array;
13
+ declare function parseBigint(value: string): number | bigint;
14
+ declare function serializeJson(value: unknown): string;
15
+ /** The default handlers, by the name pgwasm has always used for each family. */
16
+ export declare const types: {
17
+ string: {
18
+ to: number;
19
+ from: number[];
20
+ serialize: typeof serializeString;
21
+ parse: (x: string) => string;
22
+ };
23
+ number: {
24
+ to: number;
25
+ from: number[];
26
+ serialize: typeof toText;
27
+ parse: (x: string) => number;
28
+ };
29
+ bigint: {
30
+ to: number;
31
+ from: number[];
32
+ serialize: typeof toText;
33
+ parse: typeof parseBigint;
34
+ };
35
+ json: {
36
+ to: number;
37
+ from: number[];
38
+ serialize: typeof serializeJson;
39
+ parse: (x: string) => unknown;
40
+ };
41
+ boolean: {
42
+ to: number;
43
+ from: number[];
44
+ serialize: typeof serializeBoolean;
45
+ parse: (x: string) => x is "t";
46
+ };
47
+ date: {
48
+ to: number;
49
+ from: number[];
50
+ serialize: typeof serializeDate;
51
+ parse: (x: string) => Date;
52
+ };
53
+ bytea: {
54
+ to: number;
55
+ from: number[];
56
+ serialize: typeof serializeBytea;
57
+ parse: typeof parseBytea;
58
+ };
59
+ };
60
+ /** The default parsers, by OID (and by family name). */
61
+ export declare const parsers: Record<string | number, Parser>;
62
+ /** The default serializers, by OID (and by family name). */
63
+ export declare const serializers: Record<string | number, Serializer>;
64
+ /**
65
+ * The text form of a value that has no serializer for its type: the value's own `toString()`, which
66
+ * for a primitive is its usual text.
67
+ */
68
+ export declare function toText(value: unknown): string;
69
+ /** Parse one text value of the given type OID (`null` stays `null`; an unknown type stays text). */
70
+ export declare function parseType(value: string | null, type: number, overrides?: ParserOptions): unknown;
71
+ /** Serialize a (nested) JS array to a Postgres array literal. A non-array is returned as it is. */
72
+ export declare function arraySerializer(xs: unknown, serializer: Serializer | undefined, typarray: number): string;
73
+ /** Parse a Postgres array literal, applying `parser` to each element. */
74
+ export declare function arrayParser(x: string, parser: Parser | undefined, typarray: number): unknown;
75
+ export {};
76
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,KAAK,EACpB,KAAK,KAAK,EACV,IAAI,KAAK,EACT,IAAI,KAAK,EACT,IAAI,KAAK,EACT,IAAI,KAAK,EACT,OAAO,KAAK,EACZ,IAAI,KAAK,EACT,GAAG,KAAK,EACR,GAAG,KAAK,EACR,GAAG,KAAK,EACR,GAAG,KAAK,EACR,IAAI,MAAM,EACV,GAAG,MAAM,EACT,YAAY,MAAM,EAClB,IAAI,MAAM,EACV,IAAI,MAAM,EACV,OAAO,MAAM,EACb,IAAI,MAAM,EACV,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,OAAO,MAAM,EACb,OAAO,MAAM,EACb,SAAS,MAAM,EACf,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,KAAK,MAAM,EACX,OAAO,MAAM,EACb,IAAI,MAAM,EACV,OAAO,OAAO,EACd,MAAM,OAAO,EACb,OAAO,OAAO,EACd,IAAI,OAAO,EACX,IAAI,OAAO,EACX,SAAS,OAAO,EAChB,WAAW,OAAO,EAClB,QAAQ,OAAO,EACf,MAAM,OAAO,EACb,GAAG,OAAO,EACV,MAAM,OAAO,EACb,OAAO,OAAO,EACd,SAAS,OAAO,EAChB,YAAY,OAAO,EACnB,OAA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4D;AAC5D,eAAO,MAAM,WAAW,qCAA8B,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAG7C;AAED,oGAAoG;AACpG,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,OAAO,CAIhG;AASD,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgBzG;AAWD,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG5F"}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@pgxsinkit/pgwasm",
3
+ "version": "0.5.0",
4
+ "keywords": [
5
+ "tanstack-intent"
6
+ ],
7
+ "license": "MIT AND Apache-2.0",
8
+ "files": [
9
+ "dist",
10
+ "src",
11
+ "skills",
12
+ "README.md",
13
+ "LICENSE",
14
+ "LICENSE-APACHE-2.0",
15
+ "NOTICE"
16
+ ],
17
+ "type": "module",
18
+ "sideEffects": false,
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./build": {
27
+ "types": "./dist/build/index.d.ts",
28
+ "default": "./dist/build/index.js"
29
+ },
30
+ "./drizzle": {
31
+ "types": "./dist/drizzle/index.d.ts",
32
+ "default": "./dist/drizzle/index.js"
33
+ },
34
+ "./fs": {
35
+ "types": "./dist/fs/index.d.ts",
36
+ "default": "./dist/fs/index.js"
37
+ },
38
+ "./live": {
39
+ "types": "./dist/live/index.d.ts",
40
+ "default": "./dist/live/index.js"
41
+ },
42
+ "./opfs": {
43
+ "types": "./dist/opfs/index.d.ts",
44
+ "default": "./dist/opfs/index.js"
45
+ },
46
+ "./protocol": {
47
+ "types": "./dist/protocol/index.d.ts",
48
+ "default": "./dist/protocol/index.js"
49
+ }
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "build": "bun --cwd ../.. run build:public-packages"
56
+ },
57
+ "peerDependencies": {
58
+ "drizzle-orm": "1.0.0-rc.4"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "drizzle-orm": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "git+https://github.com/pgxsinkit/pgxsinkit.git"
68
+ }
69
+ }
@@ -0,0 +1,138 @@
1
+ ---
2
+ name: opfs
3
+ description: >-
4
+ Load when wiring @pgxsinkit/pgwasm/opfs (the OPFS-repacked store) into a browser worker, choosing a worker scope,
5
+ choosing relaxed or strict
6
+ durability, handling store-open failures, or deleting and recreating a store after a format identity
7
+ change. Covers the createOpfsPgwasm factory as the only construction seam (it takes the Postgres build),
8
+ dedicated-directory ownership, the constant four OPFS handles, worker requirements, extent-size identity,
9
+ awaited pgwasm host syncs, strictSync(pg), close behavior, the supported browser-termination model, the
10
+ stable error remedies, and the lower-level parts. Load before constructing, operating, or recovering a
11
+ pgwasm database on an OPFS-repacked store.
12
+ metadata:
13
+ type: task
14
+ library: "@pgxsinkit/pgwasm"
15
+ library_version: "0.5.0"
16
+ source: https://pgxsinkit.github.io/packages/pgwasm/
17
+ ---
18
+
19
+ # Operating a pgwasm database on an OPFS-repacked store
20
+
21
+ Use `createOpfsPgwasm` from `@pgxsinkit/pgwasm/opfs` and no other construction path. The factory takes the
22
+ Postgres build, retains the store, forces pgwasm onto its awaited sync path, performs a strict sync before
23
+ returning a successfully initialized database, and closes all four handles after failed initialization or
24
+ shutdown.
25
+
26
+ ## Construct it in a capability-proven worker
27
+
28
+ Create one otherwise-empty OPFS directory per database and pass its handle to the factory with the build:
29
+
30
+ ```ts
31
+ import { createOpfsPgwasm, strictSync } from "@pgxsinkit/pgwasm/opfs";
32
+ import { live } from "@pgxsinkit/pgwasm/live";
33
+ import { cBuild } from "@pgxsinkit/pgwasm-c";
34
+
35
+ const root = await navigator.storage.getDirectory();
36
+ const directory = await root.getDirectoryHandle("app-database", { create: true });
37
+ const pg = await createOpfsPgwasm({
38
+ build: cBuild,
39
+ directory,
40
+ durability: "relaxed",
41
+ extentSize: 64 * 1024,
42
+ pgwasm: { extensions: { live } },
43
+ });
44
+ ```
45
+
46
+ Require a successful `createSyncAccessHandle()` open in the executing scope; method presence is not
47
+ proof. Chromium and Firefox grant it in dedicated workers and deny it in SharedWorkers. Real macOS
48
+ and iOS Safari grant it in SharedWorkers (full boot/persist/reopen verified 2026-07-21). Do not run
49
+ the database on the window main thread. A store owns exactly four handles regardless of its virtual
50
+ file count.
51
+
52
+ The store accepts a directory handle and does not choose placement. For a cross-browser
53
+ pgxsinkit app, use `@pgxsinkit/client`: capability-driven placement is automatic (there is no placement
54
+ option), and a boot-time OPFS probe decides the engine's home — Safari runs the engine in the
55
+ SharedWorker; Chromium and Firefox elect a dedicated engine worker. Playwright WebKitGTK denies the
56
+ capability in both scopes and exercises the IndexedDB fallback; do not generalize that result to Safari.
57
+
58
+ `build` is required: the Postgres build the database runs on (e.g. `cBuild` from `@pgxsinkit/pgwasm-c`).
59
+ A data directory belongs to the build that created it, so reopening it with another build is refused
60
+ (`BuildMismatchError`, `DataFormatMismatchError`, `BuildMarkerUnreadableError`, all from `@pgxsinkit/pgwasm`);
61
+ these refusals are permanent — never retry them. The `pgwasm` option accepts every other `createPgwasm`
62
+ option, such as extensions. The store owns `build`, `dataDir`, `fs` and `relaxedDurability`, so `pgwasm`
63
+ excludes all four (the types forbid them).
64
+
65
+ The optional `onPhase` callback reports `"store-opened"` (handles acquired, the repacked filesystem open) and
66
+ then `"pgwasm-ready"` (the database's boot completed), once each and only on success — diagnosability only,
67
+ for attributing a create that never returns to a step. It carries no policy and must not throw.
68
+
69
+ ## Choose durability once
70
+
71
+ - `durability: "relaxed"` (default): an ordinary awaited host sync asserts health and performs any due
72
+ deferred repack without running the per-query strict sequence. After at least 4 MiB of accumulated
73
+ arena writes it may perform an extra arena-only amortization flush. Termination may lose an unflushed
74
+ suffix, but recovery keeps the longest valid metadata-log prefix and never crosses extent owners.
75
+ - `durability: "strict"`: every awaited host sync flushes arena data before metadata. Successful query
76
+ completion is a strict durability boundary.
77
+
78
+ pgwasm itself is always configured to await the store's sync. A non-awaited sync proves construction
79
+ was bypassed, raises `DurabilityModeMismatchError`, and poisons the instance. Do not introduce another
80
+ durability option at a call site.
81
+
82
+ `strictSync(pg)` (from `/opfs`, the same pattern as `protocol(pg)`) stabilizes every preceding operation in
83
+ strict order on demand, under the database's exclusive lock. It throws `UnsupportedFeatureError` for a
84
+ database `createOpfsPgwasm` did not create.
85
+
86
+ Successful initialization, repack activation, and close from an open instance always use strict
87
+ ordering. Close from a poisoned instance attempts no persistence and still releases all handles.
88
+
89
+ A platform write the store could not complete (an arena write rejected before a single byte was
90
+ confirmed, or a failed metadata-log append) poisons the instance: that call and every later one throw
91
+ `StoreFailedError`, whose `code` is 29 (`EIO`), so Postgres sees an I/O error and a commit whose write
92
+ failed is never acknowledged. A write the platform accepted in part returns the short count and does not poison. Close and reopen; do not retry on the live instance.
93
+
94
+ ## Reopen and recreate
95
+
96
+ `extentSize` is chosen only for a new store: 8 KiB–16 MiB, aligned to 8 KiB, default 64 KiB. The persisted
97
+ identity controls reopen. Omit the option or pass the same value; a different valid value raises
98
+ `ExtentSizeMismatchError` without changing the store.
99
+
100
+ `StoreRecreationRequiredError` means this build does not accept the directory's format identity. Close
101
+ all owners, delete the complete directory externally, and create fresh:
102
+
103
+ ```ts
104
+ await pg.close();
105
+ await root.removeEntry("app-database", { recursive: true });
106
+ ```
107
+
108
+ Never copy individual owned files into the fresh directory. `CorruptStoreError` is different: the
109
+ activated authority is invalid, so restore an external backup or recreate. The VFS fails closed and
110
+ does not select another apparent generation.
111
+
112
+ ## Handle errors by class
113
+
114
+ - `FsError`: fix the caller operation; non-terminal.
115
+ - `StoreLimitError`: recover space or let repack run; some exhausted identities require recreation.
116
+ - `StoreOwnedError`: another live instance owns an exclusive handle; close it and retry.
117
+ - `UnexpectedStoreEntryError`: the directory is not dedicated and empty; choose a correct directory.
118
+ - `ExtentSizeMismatchError`: omit `extentSize` or use the stored value.
119
+ - `DurabilityModeMismatchError`: terminal factory-wiring error; close and rebuild through the factory.
120
+ - `StoreFailedError` (`code` 29, `EIO`): the live instance is poisoned; close/reopen and inspect `cause`.
121
+ - `StoreClosedError`: stop using the adapter.
122
+
123
+ The guaranteed model covers worker, tab, process, and browser termination; unflushed writes may be
124
+ absent, partial, or independently present; completed flushes remain stable. Power loss, media failure,
125
+ arbitrary external edits, and mysteriously missing activated files are outside the guarantee and fail
126
+ closed.
127
+
128
+ ## Lower-level parts
129
+
130
+ `/opfs` also exports what the factory is built from, for a host that owns a store itself: the storage ports
131
+ (`OpfsRepackedPort`, `FileRepackedPort` on Bun, `MemoryRepackedPort` with fault injection), the engine-agnostic
132
+ core (`RepackedVfs` over any `RepackedPort`), the mounted filesystem (`MountedRepackedVfs`, `OpfsRepackedFS`),
133
+ a synchronous broker that lets one coordinator worker own a store while other threads reach it over a
134
+ `SharedArrayBuffer` channel (`RepackedSyncBroker`, `RepackedSyncClient`), and a WASI preview1 filesystem
135
+ adapter (`createWasiPreview1Fs`) routing a wasm engine's file calls to one store through that broker. Store-level
136
+ errors carry a string `storeCode`; wrapped errors retain `cause`.
137
+
138
+ Full prose: <https://pgxsinkit.github.io/packages/pgwasm/#the-opfs-repacked-store-pgxsinkitpgwasmopfs>.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The contract a Postgres build implements (ADR-0062 decision 3), and the helpers a build package
3
+ * shares with pgwasm.
4
+ */
5
+
6
+ export type {
7
+ BlobDevice,
8
+ BootRequest,
9
+ BuildCapabilities,
10
+ BuildIdentity,
11
+ DataDirEntry,
12
+ DebugLevel,
13
+ FilesystemKind,
14
+ MountedDataDirectory,
15
+ PostgresBuild,
16
+ RunningPostgres,
17
+ ServerExtension,
18
+ StartOptions,
19
+ StorageRequest,
20
+ WireSession,
21
+ } from "./seam";
22
+ export { readTar, writeTar, TarFormatError, type TarEntry } from "../tar/tar";
23
+ export { gunzip, gunzipIfCompressed, gzip, isGzip } from "../tar/gzip";