@di-framework/pglite-component 6.0.9 → 6.0.12

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.
@@ -3,13 +3,16 @@ di-framework embedded PGlite component
3
3
  The provider bundles PostgreSQL 17.5 (PGlite WASI), originally maintained by
4
4
  ElectricSQL. PostgreSQL's license is reproduced in POSTGRESQL-COPYRIGHT.
5
5
  The upstream bindings license and WASI adapter license are reproduced in
6
- PGLITE-BINDINGS-LICENSE and WASMTIME-LICENSE.
6
+ PGLITE-BINDINGS-LICENSE and WASMTIME-LICENSE. The engine statically links
7
+ the pgcrypto extension and OpenSSL libcrypto; their notices are in
8
+ PGCRYPTO-NOTICES and the OpenSSL license (Apache-2.0) in OPENSSL-LICENSE.
7
9
 
8
10
  Sources:
9
11
  https://github.com/electric-sql/postgres-pglite
10
12
  https://github.com/electric-sql/pglite-bindings
11
13
  https://github.com/moznion/wasipg
12
14
  https://github.com/bytecodealliance/wasmtime/tree/v29.0.1
15
+ https://github.com/openssl/openssl/releases/tag/openssl-3.5.9
13
16
 
14
17
  The engine is compiled with PostgreSQL setjmp/longjmp recovery lowered to
15
18
  standardized WebAssembly exceptions. di-framework adds a private canonical
@@ -102,6 +105,270 @@ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
102
105
  AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
103
106
  ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
104
107
  PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
108
+
109
+ --------------------------------------------------------------------------
110
+ pgcrypto (PostgreSQL 17.5 contrib/pgcrypto)
111
+ --------------------------------------------------------------------------
112
+
113
+ pgcrypto is part of PostgreSQL and is distributed under the PostgreSQL
114
+ License (POSTGRESQL-COPYRIGHT). Several of its source files carry these
115
+ additional notices, reproduced as their licenses require for binary
116
+ distribution.
117
+
118
+ px.c, px-hmac.c, px-crypt.c, mbuf.c, openssl.c, pgcrypto.c, pgp*.c and
119
+ their headers:
120
+
121
+ Copyright (c) 2001 Marko Kreen
122
+ Copyright (c) 2005 Marko Kreen
123
+ All rights reserved.
124
+
125
+ Redistribution and use in source and binary forms, with or without
126
+ modification, are permitted provided that the following conditions
127
+ are met:
128
+ 1. Redistributions of source code must retain the above copyright
129
+ notice, this list of conditions and the following disclaimer.
130
+ 2. Redistributions in binary form must reproduce the above copyright
131
+ notice, this list of conditions and the following disclaimer in the
132
+ documentation and/or other materials provided with the distribution.
133
+
134
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
135
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
136
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
137
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
138
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
139
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
140
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
141
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
142
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
143
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
144
+ SUCH DAMAGE.
145
+
146
+ crypt-des.c (FreeSec: libcrypt for NetBSD):
147
+
148
+ Copyright (c) 1994 David Burren
149
+ All rights reserved.
150
+
151
+ Redistribution and use in source and binary forms, with or without
152
+ modification, are permitted provided that the following conditions
153
+ are met:
154
+ 1. Redistributions of source code must retain the above copyright
155
+ notice, this list of conditions and the following disclaimer.
156
+ 2. Redistributions in binary form must reproduce the above copyright
157
+ notice, this list of conditions and the following disclaimer in the
158
+ documentation and/or other materials provided with the distribution.
159
+ 3. Neither the name of the author nor the names of other contributors
160
+ may be used to endorse or promote products derived from this software
161
+ without specific prior written permission.
162
+
163
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
164
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
165
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
166
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
167
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
168
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
169
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
170
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
171
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
172
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
173
+ SUCH DAMAGE.
174
+
175
+ crypt-md5.c: imported from FreeBSD, original by Poul-Henning Kamp.
176
+
177
+ crypt-blowfish.c and crypt-gensalt.c: written by Solar Designer
178
+ <solar at openwall.com> in 1998-2002 and placed in the public domain.
179
+
180
+ --------------------------------------------------------------------------
181
+ OpenSSL 3.5.9 (libcrypto)
182
+ --------------------------------------------------------------------------
183
+
184
+ pgcrypto links a static libcrypto built from the OpenSSL 3.5.9 release
185
+ source (https://github.com/openssl/openssl/releases/tag/openssl-3.5.9),
186
+ distributed under the Apache License, Version 2.0, reproduced in
187
+ OPENSSL-LICENSE:
188
+
189
+ Copyright (c) 1998-2026 The OpenSSL Project Authors
190
+ Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
191
+
192
+ It is compiled for wasm32-wasip1 without assembly, threads, sockets,
193
+ engines, loadable modules or configuration autoloading; no OpenSSL source
194
+ file is modified.
195
+
196
+ Apache License
197
+ Version 2.0, January 2004
198
+ https://www.apache.org/licenses/
199
+
200
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
201
+
202
+ 1. Definitions.
203
+
204
+ "License" shall mean the terms and conditions for use, reproduction,
205
+ and distribution as defined by Sections 1 through 9 of this document.
206
+
207
+ "Licensor" shall mean the copyright owner or entity authorized by
208
+ the copyright owner that is granting the License.
209
+
210
+ "Legal Entity" shall mean the union of the acting entity and all
211
+ other entities that control, are controlled by, or are under common
212
+ control with that entity. For the purposes of this definition,
213
+ "control" means (i) the power, direct or indirect, to cause the
214
+ direction or management of such entity, whether by contract or
215
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
216
+ outstanding shares, or (iii) beneficial ownership of such entity.
217
+
218
+ "You" (or "Your") shall mean an individual or Legal Entity
219
+ exercising permissions granted by this License.
220
+
221
+ "Source" form shall mean the preferred form for making modifications,
222
+ including but not limited to software source code, documentation
223
+ source, and configuration files.
224
+
225
+ "Object" form shall mean any form resulting from mechanical
226
+ transformation or translation of a Source form, including but
227
+ not limited to compiled object code, generated documentation,
228
+ and conversions to other media types.
229
+
230
+ "Work" shall mean the work of authorship, whether in Source or
231
+ Object form, made available under the License, as indicated by a
232
+ copyright notice that is included in or attached to the work
233
+ (an example is provided in the Appendix below).
234
+
235
+ "Derivative Works" shall mean any work, whether in Source or Object
236
+ form, that is based on (or derived from) the Work and for which the
237
+ editorial revisions, annotations, elaborations, or other modifications
238
+ represent, as a whole, an original work of authorship. For the purposes
239
+ of this License, Derivative Works shall not include works that remain
240
+ separable from, or merely link (or bind by name) to the interfaces of,
241
+ the Work and Derivative Works thereof.
242
+
243
+ "Contribution" shall mean any work of authorship, including
244
+ the original version of the Work and any modifications or additions
245
+ to that Work or Derivative Works thereof, that is intentionally
246
+ submitted to Licensor for inclusion in the Work by the copyright owner
247
+ or by an individual or Legal Entity authorized to submit on behalf of
248
+ the copyright owner. For the purposes of this definition, "submitted"
249
+ means any form of electronic, verbal, or written communication sent
250
+ to the Licensor or its representatives, including but not limited to
251
+ communication on electronic mailing lists, source code control systems,
252
+ and issue tracking systems that are managed by, or on behalf of, the
253
+ Licensor for the purpose of discussing and improving the Work, but
254
+ excluding communication that is conspicuously marked or otherwise
255
+ designated in writing by the copyright owner as "Not a Contribution."
256
+
257
+ "Contributor" shall mean Licensor and any individual or Legal Entity
258
+ on behalf of whom a Contribution has been received by Licensor and
259
+ subsequently incorporated within the Work.
260
+
261
+ 2. Grant of Copyright License. Subject to the terms and conditions of
262
+ this License, each Contributor hereby grants to You a perpetual,
263
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
264
+ copyright license to reproduce, prepare Derivative Works of,
265
+ publicly display, publicly perform, sublicense, and distribute the
266
+ Work and such Derivative Works in Source or Object form.
267
+
268
+ 3. Grant of Patent License. Subject to the terms and conditions of
269
+ this License, each Contributor hereby grants to You a perpetual,
270
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
271
+ (except as stated in this section) patent license to make, have made,
272
+ use, offer to sell, sell, import, and otherwise transfer the Work,
273
+ where such license applies only to those patent claims licensable
274
+ by such Contributor that are necessarily infringed by their
275
+ Contribution(s) alone or by combination of their Contribution(s)
276
+ with the Work to which such Contribution(s) was submitted. If You
277
+ institute patent litigation against any entity (including a
278
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
279
+ or a Contribution incorporated within the Work constitutes direct
280
+ or contributory patent infringement, then any patent licenses
281
+ granted to You under this License for that Work shall terminate
282
+ as of the date such litigation is filed.
283
+
284
+ 4. Redistribution. You may reproduce and distribute copies of the
285
+ Work or Derivative Works thereof in any medium, with or without
286
+ modifications, and in Source or Object form, provided that You
287
+ meet the following conditions:
288
+
289
+ (a) You must give any other recipients of the Work or
290
+ Derivative Works a copy of this License; and
291
+
292
+ (b) You must cause any modified files to carry prominent notices
293
+ stating that You changed the files; and
294
+
295
+ (c) You must retain, in the Source form of any Derivative Works
296
+ that You distribute, all copyright, patent, trademark, and
297
+ attribution notices from the Source form of the Work,
298
+ excluding those notices that do not pertain to any part of
299
+ the Derivative Works; and
300
+
301
+ (d) If the Work includes a "NOTICE" text file as part of its
302
+ distribution, then any Derivative Works that You distribute must
303
+ include a readable copy of the attribution notices contained
304
+ within such NOTICE file, excluding those notices that do not
305
+ pertain to any part of the Derivative Works, in at least one
306
+ of the following places: within a NOTICE text file distributed
307
+ as part of the Derivative Works; within the Source form or
308
+ documentation, if provided along with the Derivative Works; or,
309
+ within a display generated by the Derivative Works, if and
310
+ wherever such third-party notices normally appear. The contents
311
+ of the NOTICE file are for informational purposes only and
312
+ do not modify the License. You may add Your own attribution
313
+ notices within Derivative Works that You distribute, alongside
314
+ or as an addendum to the NOTICE text from the Work, provided
315
+ that such additional attribution notices cannot be construed
316
+ as modifying the License.
317
+
318
+ You may add Your own copyright statement to Your modifications and
319
+ may provide additional or different license terms and conditions
320
+ for use, reproduction, or distribution of Your modifications, or
321
+ for any such Derivative Works as a whole, provided Your use,
322
+ reproduction, and distribution of the Work otherwise complies with
323
+ the conditions stated in this License.
324
+
325
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
326
+ any Contribution intentionally submitted for inclusion in the Work
327
+ by You to the Licensor shall be under the terms and conditions of
328
+ this License, without any additional terms or conditions.
329
+ Notwithstanding the above, nothing herein shall supersede or modify
330
+ the terms of any separate license agreement you may have executed
331
+ with Licensor regarding such Contributions.
332
+
333
+ 6. Trademarks. This License does not grant permission to use the trade
334
+ names, trademarks, service marks, or product names of the Licensor,
335
+ except as required for reasonable and customary use in describing the
336
+ origin of the Work and reproducing the content of the NOTICE file.
337
+
338
+ 7. Disclaimer of Warranty. Unless required by applicable law or
339
+ agreed to in writing, Licensor provides the Work (and each
340
+ Contributor provides its Contributions) on an "AS IS" BASIS,
341
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
342
+ implied, including, without limitation, any warranties or conditions
343
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
344
+ PARTICULAR PURPOSE. You are solely responsible for determining the
345
+ appropriateness of using or redistributing the Work and assume any
346
+ risks associated with Your exercise of permissions under this License.
347
+
348
+ 8. Limitation of Liability. In no event and under no legal theory,
349
+ whether in tort (including negligence), contract, or otherwise,
350
+ unless required by applicable law (such as deliberate and grossly
351
+ negligent acts) or agreed to in writing, shall any Contributor be
352
+ liable to You for damages, including any direct, indirect, special,
353
+ incidental, or consequential damages of any character arising as a
354
+ result of this License or out of the use or inability to use the
355
+ Work (including but not limited to damages for loss of goodwill,
356
+ work stoppage, computer failure or malfunction, or any and all
357
+ other commercial damages or losses), even if such Contributor
358
+ has been advised of the possibility of such damages.
359
+
360
+ 9. Accepting Warranty or Additional Liability. While redistributing
361
+ the Work or Derivative Works thereof, You may choose to offer,
362
+ and charge a fee for, acceptance of support, warranty, indemnity,
363
+ or other liability obligations and/or rights consistent with this
364
+ License. However, in accepting such obligations, You may act only
365
+ on Your own behalf and on Your sole responsibility, not on behalf
366
+ of any other Contributor, and only if You agree to indemnify,
367
+ defend, and hold each Contributor harmless for any liability
368
+ incurred by, or claims asserted against, such Contributor by reason
369
+ of your accepting any such warranty or additional liability.
370
+
371
+ END OF TERMS AND CONDITIONS
105
372
  MIT License
106
373
 
107
374
  Copyright (c) 2024 ElectricSQL
Binary file
@@ -20,8 +20,8 @@ world root {
20
20
  import wasi:filesystem/preopens@0.2.9;
21
21
  import wasi:random/random@0.2.3;
22
22
 
23
- export di-framework:pglite/types@0.1.0;
24
- export di-framework:pglite/database@0.1.0;
23
+ export di-framework:pglite/types@0.2.0;
24
+ export di-framework:pglite/database@0.2.0;
25
25
  }
26
26
  package wasi:io@0.2.9 {
27
27
  interface poll {
@@ -289,7 +289,7 @@ package wasi:random@0.2.3 {
289
289
  }
290
290
 
291
291
 
292
- package di-framework:pglite@0.1.0 {
292
+ package di-framework:pglite@0.2.0 {
293
293
  interface types {
294
294
  record pg-error {
295
295
  code: string,
@@ -315,6 +315,8 @@ package di-framework:pglite@0.1.0 {
315
315
  text(string),
316
316
  blob(list<u8>),
317
317
  boolean(bool),
318
+ json(string),
319
+ timestamp(string),
318
320
  }
319
321
 
320
322
  type row = list<tuple<string, value>>;
@@ -0,0 +1,171 @@
1
+ import { type SqlDatabase, type SqlRow, type WasmMaybeResult, type WasmResult } from '@di-framework/repo';
2
+ export declare const WASM_PGLITE_MODULE_ID = "di-framework:pglite/database@0.2.0";
3
+ /** Database root the provider selects when `open` receives an empty path. */
4
+ export declare const WASM_PGLITE_DEFAULT_ROOT = "/data/pglite";
5
+ export type WasmPgValue = {
6
+ tag: 'null';
7
+ val?: undefined;
8
+ } | {
9
+ tag: 'integer';
10
+ val: bigint | number;
11
+ } | {
12
+ tag: 'real';
13
+ val: number;
14
+ } | {
15
+ tag: 'text';
16
+ val: string;
17
+ } | {
18
+ tag: 'blob';
19
+ val: Uint8Array | ArrayLike<number>;
20
+ } | {
21
+ tag: 'boolean';
22
+ val: boolean;
23
+ } | {
24
+ tag: 'json';
25
+ val: string;
26
+ } | {
27
+ tag: 'timestamp';
28
+ val: string;
29
+ };
30
+ export type WasmPgRow = Array<[string, WasmPgValue]>;
31
+ /**
32
+ * Guest-side view of the `connection` resource.
33
+ *
34
+ * TODO(#153): members use method syntax, so `tsc` compares their parameters
35
+ * bivariantly and the drift guard does not notice a removed or narrowed `value`
36
+ * case. Declare them as property signatures (`strictFunctionTypes`) once
37
+ * `integer` stops allowing `number`.
38
+ */
39
+ export interface WasmPgliteConnection {
40
+ exec(sql: string): WasmMaybeResult<void>;
41
+ run(sql: string, params: WasmPgValue[]): WasmMaybeResult<bigint | number>;
42
+ query(sql: string, params: WasmPgValue[]): WasmMaybeResult<WasmPgRow[]>;
43
+ first(sql: string, params: WasmPgValue[]): WasmMaybeResult<WasmPgRow | undefined | null>;
44
+ begin(): WasmMaybeResult<void>;
45
+ commit(): WasmMaybeResult<void>;
46
+ rollback(): WasmMaybeResult<void>;
47
+ savepoint(name: string): WasmMaybeResult<void>;
48
+ releaseSavepoint(name: string): WasmMaybeResult<void>;
49
+ rollbackToSavepoint(name: string): WasmMaybeResult<void>;
50
+ close(): WasmMaybeResult<void>;
51
+ }
52
+ /** The `open-options` record. Every field is optional. */
53
+ export interface WasmPgliteOpenOptions {
54
+ /** Session database. The provider currently accepts only `template1`. */
55
+ database?: string;
56
+ /** Reserved by the provider: only `0` (or unset) is accepted. */
57
+ statementTimeoutMs?: number;
58
+ }
59
+ /** Guest-side view of the `database` interface module. */
60
+ export interface WasmPgliteModule {
61
+ open(path: string, options?: WasmPgliteOpenOptions): WasmMaybeResult<WasmPgliteConnection>;
62
+ }
63
+ /** The `pg-error` record carried by `execution-failed`. */
64
+ export interface WasmPgliteErrorRecord {
65
+ code?: string;
66
+ message?: string;
67
+ }
68
+ export interface WasmPgliteErrorPayload {
69
+ tag: string;
70
+ val?: string | WasmPgliteErrorRecord;
71
+ }
72
+ /**
73
+ * A provider error. `code` is the SQLSTATE for `execution-failed` (for example
74
+ * `23505` for a unique violation). The message then starts with
75
+ * `PostgreSQL <code>`, the format `isUniqueViolation` from `@di-framework/repo` reads.
76
+ */
77
+ export declare class WasmPgliteError extends Error {
78
+ readonly tag: string;
79
+ readonly detail?: string;
80
+ readonly code?: string;
81
+ constructor(payload: WasmPgliteErrorPayload, cause?: unknown);
82
+ }
83
+ /** Normalizes a thrown binding error or an `err` payload into an `Error`. */
84
+ export declare function normalizeWasmPgliteError(error: unknown): Error;
85
+ /** Unwraps `{ tag: 'ok' | 'err' }` records; passes bare values through. */
86
+ export declare function unwrapWasmPgliteResult<T>(value: T | WasmResult<T>): T;
87
+ /**
88
+ * Converts a bound JavaScript parameter into a `value` variant.
89
+ *
90
+ * - `bigint` in the safe integer range becomes `integer`; a larger one is sent
91
+ * as `text` (OID 0), so PostgreSQL parses it for an `int8`/`numeric` column
92
+ * without rounding through a double.
93
+ * - A `number` that is an integer outside the safe range throws a `TypeError`
94
+ * (pass a `bigint` or string for `int8`); other non-safe numbers, including
95
+ * NaN and Infinity, are `real` (`float8`).
96
+ * - `Date` becomes `timestamp` (RFC 3339 UTC); plain objects and arrays become
97
+ * `json`. Arrays are not PostgreSQL arrays: pass a literal such as `'{a,b}'`.
98
+ */
99
+ export declare function toWasmPgValue(value: unknown): WasmPgValue;
100
+ /**
101
+ * Formats a `timestamp` variant the way the `wasmcloud:postgres` codec does:
102
+ * `YYYY-MM-DDTHH:MM:SS.mmmZ`. Microseconds are truncated to milliseconds.
103
+ * `infinity`, `-infinity`, and BC dates are returned unchanged.
104
+ */
105
+ export declare function pgliteTimestampIso(value: string): string;
106
+ /** Converts a `value` variant into what the `wasmcloud:postgres` codec in `@di-framework/repo` returns. */
107
+ export declare function fromWasmPgValue(value: WasmPgValue): unknown;
108
+ export declare function toWasmPgParams(params?: readonly unknown[]): WasmPgValue[];
109
+ export declare function fromWasmPgRow(row: WasmPgRow): SqlRow;
110
+ /**
111
+ * Rewrites `?` placeholders to `$1`, `$2`, ... in order.
112
+ *
113
+ * Skipped: `'...'` and `E'...'` strings, `"..."` identifiers, `$tag$...$tag$`
114
+ * dollar quotes, `--` and nested `/* *\/` comments, and the `?|` / `?&` jsonb
115
+ * operators. The bare jsonb `?` (key exists) operator cannot be told apart
116
+ * from a placeholder: write `jsonb_exists(col, ?)` instead. The adapter does
117
+ * not rewrite statements bound without parameters, so a literal `?` operator
118
+ * still works there. Mixing `?` with explicit `$n` placeholders throws.
119
+ */
120
+ export declare function toPgPlaceholders(sql: string): string;
121
+ /**
122
+ * Wraps an open WIT `connection` resource as a `SqlDatabase`.
123
+ *
124
+ * Every statement holds one mutex. `transaction(fn)` runs `begin` … `commit`
125
+ * and calls `rollback` when `fn` throws. Statements issued from inside `fn`,
126
+ * through the callback view or the outer handle, join the transaction; other
127
+ * tasks wait. A nested `transaction()` opens a savepoint: its failure rolls
128
+ * back to the savepoint, and its work commits only with the outer transaction.
129
+ * Sibling savepoints started concurrently run one at a time; a plain statement
130
+ * issued while a sibling savepoint is open joins that savepoint.
131
+ *
132
+ * Inside `fn`, prefer the callback view: while its transaction or savepoint is
133
+ * open it joins from any async context. The outer handle joins only from
134
+ * `fn`'s own async context (tracked with AsyncLocalStorage); from anywhere else
135
+ * it waits for the mutex, which deadlocks if `fn` awaits it.
136
+ *
137
+ * Sibling savepoints are queued on their parent. `transaction()` on a view,
138
+ * called from an async context outside an open sibling savepoint, waits for
139
+ * that sibling to finish; if the sibling awaits that call, it waits forever.
140
+ *
141
+ * Joining lasts only while a transaction is open. A savepoint view kept after
142
+ * its savepoint ends joins the nearest open ancestor, so its work commits or
143
+ * rolls back with that ancestor. Once the root transaction has ended, a
144
+ * retained view, like a timer scheduled inside `fn`, takes the mutex like any
145
+ * other caller.
146
+ */
147
+ export declare function createSqlDatabaseFromWasmPgliteConnection(connection: WasmPgliteConnection): SqlDatabase;
148
+ export interface WasmPgliteDatabaseOptions extends WasmPgliteOpenOptions {
149
+ /** Pre-loaded module; skips the dynamic import of the WIT interface. */
150
+ module?: WasmPgliteModule;
151
+ /** Custom loader for the WIT interface module (primarily for tests). */
152
+ loadModule?: () => Promise<WasmPgliteModule>;
153
+ }
154
+ /**
155
+ * Imports `di-framework:pglite/database@0.2.0`, provided by the composed provider component.
156
+ *
157
+ * The module's types come from `wit.d.ts`, generated from `wit/world.wit`. The
158
+ * conversion below has no cast, so a WIT change that breaks the adapter's view
159
+ * of the interface fails the typecheck. The check covers method names, arity
160
+ * and result types, not the parameter variants (see the TODO on
161
+ * `WasmPgliteConnection`).
162
+ */
163
+ export declare function loadWasmPgliteModule(): Promise<WasmPgliteModule>;
164
+ /**
165
+ * Opens a persistent PGlite database root through the provider component and
166
+ * adapts it to `SqlDatabase`. `path` is the root directory inside a writable
167
+ * WASI preopen (for example `/data/identity`); an empty path selects
168
+ * {@link WASM_PGLITE_DEFAULT_ROOT}. The provider allows one open connection per
169
+ * component instance, so keep one handle and share it.
170
+ */
171
+ export declare function createWasmPgliteDatabase(path?: string, options?: WasmPgliteDatabaseOptions): Promise<SqlDatabase>;