@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.
- package/LICENSE +21 -0
- package/LICENSE-APACHE-2.0 +202 -0
- package/NOTICE +111 -0
- package/README.md +56 -0
- package/dist/build/index.d.ts +8 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +21 -0
- package/dist/build/index.js.map +9 -0
- package/dist/build/seam.d.ts +174 -0
- package/dist/build/seam.d.ts.map +1 -0
- package/dist/chunk-0w227vw2.js +233 -0
- package/dist/chunk-0w227vw2.js.map +11 -0
- package/dist/chunk-74gcrk47.js +563 -0
- package/dist/chunk-74gcrk47.js.map +14 -0
- package/dist/chunk-at1py5s5.js +373 -0
- package/dist/chunk-at1py5s5.js.map +12 -0
- package/dist/chunk-cpsnmzrf.js +126 -0
- package/dist/chunk-cpsnmzrf.js.map +10 -0
- package/dist/chunk-d82gg1hx.js +306 -0
- package/dist/chunk-d82gg1hx.js.map +10 -0
- package/dist/chunk-gjf102c9.js +1005 -0
- package/dist/chunk-gjf102c9.js.map +16 -0
- package/dist/chunk-kb3rsr7n.js +19 -0
- package/dist/chunk-kb3rsr7n.js.map +9 -0
- package/dist/chunk-tdvrvgt5.js +83 -0
- package/dist/chunk-tdvrvgt5.js.map +11 -0
- package/dist/chunk-z0c40tja.js +50 -0
- package/dist/chunk-z0c40tja.js.map +10 -0
- package/dist/core/data-dir-archive.d.ts +17 -0
- package/dist/core/data-dir-archive.d.ts.map +1 -0
- package/dist/core/internals.d.ts +59 -0
- package/dist/core/internals.d.ts.map +1 -0
- package/dist/core/marker.d.ts +35 -0
- package/dist/core/marker.d.ts.map +1 -0
- package/dist/core/mutex.d.ts +9 -0
- package/dist/core/mutex.d.ts.map +1 -0
- package/dist/core/names.d.ts +11 -0
- package/dist/core/names.d.ts.map +1 -0
- package/dist/core/parse.d.ts +11 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/core/pgwasm.d.ts +53 -0
- package/dist/core/pgwasm.d.ts.map +1 -0
- package/dist/core/storage.d.ts +14 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/create.d.ts +10 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/drizzle/codecs.d.ts +9 -0
- package/dist/drizzle/codecs.d.ts.map +1 -0
- package/dist/drizzle/driver.d.ts +50 -0
- package/dist/drizzle/driver.d.ts.map +1 -0
- package/dist/drizzle/index.d.ts +4 -0
- package/dist/drizzle/index.d.ts.map +1 -0
- package/dist/drizzle/index.js +261 -0
- package/dist/drizzle/index.js.map +12 -0
- package/dist/drizzle/session.d.ts +39 -0
- package/dist/drizzle/session.d.ts.map +1 -0
- package/dist/errors.d.ts +115 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/fs/base-filesystem.d.ts +118 -0
- package/dist/fs/base-filesystem.d.ts.map +1 -0
- package/dist/fs/index.d.ts +2 -0
- package/dist/fs/index.d.ts.map +1 -0
- package/dist/fs/index.js +11 -0
- package/dist/fs/index.js.map +9 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +9 -0
- package/dist/interface.d.ts +165 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/live/debounce-mutex.d.ts +6 -0
- package/dist/live/debounce-mutex.d.ts.map +1 -0
- package/dist/live/format-query.d.ts +8 -0
- package/dist/live/format-query.d.ts.map +1 -0
- package/dist/live/index.d.ts +9 -0
- package/dist/live/index.d.ts.map +1 -0
- package/dist/live/index.js +601 -0
- package/dist/live/index.js.map +12 -0
- package/dist/live/interface.d.ts +86 -0
- package/dist/live/interface.d.ts.map +1 -0
- package/dist/opfs/broker/client.d.ts +163 -0
- package/dist/opfs/broker/client.d.ts.map +1 -0
- package/dist/opfs/broker/protocol.d.ts +326 -0
- package/dist/opfs/broker/protocol.d.ts.map +1 -0
- package/dist/opfs/broker/server.d.ts +84 -0
- package/dist/opfs/broker/server.d.ts.map +1 -0
- package/dist/opfs/core/checksum.d.ts +3 -0
- package/dist/opfs/core/checksum.d.ts.map +1 -0
- package/dist/opfs/core/codec.d.ts +73 -0
- package/dist/opfs/core/codec.d.ts.map +1 -0
- package/dist/opfs/core/errors.d.ts +80 -0
- package/dist/opfs/core/errors.d.ts.map +1 -0
- package/dist/opfs/core/limits.d.ts +35 -0
- package/dist/opfs/core/limits.d.ts.map +1 -0
- package/dist/opfs/core/memory-port.d.ts +51 -0
- package/dist/opfs/core/memory-port.d.ts.map +1 -0
- package/dist/opfs/core/metadata-store.d.ts +19 -0
- package/dist/opfs/core/metadata-store.d.ts.map +1 -0
- package/dist/opfs/core/mounted-vfs.d.ts +119 -0
- package/dist/opfs/core/mounted-vfs.d.ts.map +1 -0
- package/dist/opfs/core/path.d.ts +14 -0
- package/dist/opfs/core/path.d.ts.map +1 -0
- package/dist/opfs/core/port.d.ts +30 -0
- package/dist/opfs/core/port.d.ts.map +1 -0
- package/dist/opfs/core/repacked-vfs.d.ts +138 -0
- package/dist/opfs/core/repacked-vfs.d.ts.map +1 -0
- package/dist/opfs/core/state-machine.d.ts +296 -0
- package/dist/opfs/core/state-machine.d.ts.map +1 -0
- package/dist/opfs/create.d.ts +50 -0
- package/dist/opfs/create.d.ts.map +1 -0
- package/dist/opfs/file-port.d.ts +14 -0
- package/dist/opfs/file-port.d.ts.map +1 -0
- package/dist/opfs/index.d.ts +37 -0
- package/dist/opfs/index.d.ts.map +1 -0
- package/dist/opfs/index.js +6671 -0
- package/dist/opfs/index.js.map +28 -0
- package/dist/opfs/opfs-port.d.ts +34 -0
- package/dist/opfs/opfs-port.d.ts.map +1 -0
- package/dist/opfs/opfs-repacked-fs.d.ts +55 -0
- package/dist/opfs/opfs-repacked-fs.d.ts.map +1 -0
- package/dist/opfs/wasi/preview1.d.ts +228 -0
- package/dist/opfs/wasi/preview1.d.ts.map +1 -0
- package/dist/protocol/index.d.ts +15 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +23 -0
- package/dist/protocol/index.js.map +10 -0
- package/dist/protocol/wire/buffer-reader.d.ts +13 -0
- package/dist/protocol/wire/buffer-reader.d.ts.map +1 -0
- package/dist/protocol/wire/buffer-writer.d.ts +12 -0
- package/dist/protocol/wire/buffer-writer.d.ts.map +1 -0
- package/dist/protocol/wire/index.d.ts +5 -0
- package/dist/protocol/wire/index.d.ts.map +1 -0
- package/dist/protocol/wire/messages.d.ts +194 -0
- package/dist/protocol/wire/messages.d.ts.map +1 -0
- package/dist/protocol/wire/parser.d.ts +12 -0
- package/dist/protocol/wire/parser.d.ts.map +1 -0
- package/dist/protocol/wire/serializer.d.ts +61 -0
- package/dist/protocol/wire/serializer.d.ts.map +1 -0
- package/dist/protocol/wire/string-utils.d.ts +6 -0
- package/dist/protocol/wire/string-utils.d.ts.map +1 -0
- package/dist/protocol/wire/types.d.ts +7 -0
- package/dist/protocol/wire/types.d.ts.map +1 -0
- package/dist/tar/gzip.d.ts +7 -0
- package/dist/tar/gzip.d.ts.map +1 -0
- package/dist/tar/tar.d.ts +39 -0
- package/dist/tar/tar.d.ts.map +1 -0
- package/dist/templating.d.ts +42 -0
- package/dist/templating.d.ts.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +69 -0
- package/skills/opfs/SKILL.md +138 -0
- package/src/build/index.ts +23 -0
- package/src/build/seam.ts +179 -0
- package/src/core/data-dir-archive.ts +68 -0
- package/src/core/internals.ts +87 -0
- package/src/core/marker.ts +94 -0
- package/src/core/mutex.ts +16 -0
- package/src/core/names.ts +26 -0
- package/src/core/parse.ts +79 -0
- package/src/core/pgwasm.ts +876 -0
- package/src/core/storage.ts +70 -0
- package/src/create.ts +134 -0
- package/src/drizzle/codecs.ts +114 -0
- package/src/drizzle/driver.ts +141 -0
- package/src/drizzle/index.ts +15 -0
- package/src/drizzle/session.ts +133 -0
- package/src/errors.ts +201 -0
- package/src/fs/base-filesystem.ts +149 -0
- package/src/fs/index.ts +7 -0
- package/src/index.ts +44 -0
- package/src/interface.ts +186 -0
- package/src/live/debounce-mutex.ts +45 -0
- package/src/live/format-query.ts +47 -0
- package/src/live/index.ts +707 -0
- package/src/live/interface.ts +109 -0
- package/src/opfs/broker/client.ts +482 -0
- package/src/opfs/broker/protocol.ts +624 -0
- package/src/opfs/broker/server.ts +522 -0
- package/src/opfs/core/checksum.ts +85 -0
- package/src/opfs/core/codec.ts +1051 -0
- package/src/opfs/core/errors.ts +134 -0
- package/src/opfs/core/limits.ts +68 -0
- package/src/opfs/core/memory-port.ts +459 -0
- package/src/opfs/core/metadata-store.ts +512 -0
- package/src/opfs/core/mounted-vfs.ts +407 -0
- package/src/opfs/core/path.ts +82 -0
- package/src/opfs/core/port.ts +114 -0
- package/src/opfs/core/repacked-vfs.ts +1464 -0
- package/src/opfs/core/state-machine.ts +1699 -0
- package/src/opfs/create.ts +125 -0
- package/src/opfs/file-port.ts +183 -0
- package/src/opfs/index.ts +113 -0
- package/src/opfs/opfs-port.ts +90 -0
- package/src/opfs/opfs-repacked-fs.ts +210 -0
- package/src/opfs/wasi/preview1.ts +1016 -0
- package/src/protocol/index.ts +24 -0
- package/src/protocol/wire/buffer-reader.ts +60 -0
- package/src/protocol/wire/buffer-writer.ts +93 -0
- package/src/protocol/wire/index.ts +15 -0
- package/src/protocol/wire/messages.ts +332 -0
- package/src/protocol/wire/parser.ts +373 -0
- package/src/protocol/wire/serializer.ts +233 -0
- package/src/protocol/wire/string-utils.ts +18 -0
- package/src/protocol/wire/types.ts +12 -0
- package/src/tar/gzip.ts +36 -0
- package/src/tar/tar.ts +253 -0
- package/src/templating.ts +103 -0
- package/src/types.ts +283 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pgxsinkit contributors
|
|
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.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
@pgxsinkit/pgwasm
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
This package includes software that began as a copy of third-party code. It is owned
|
|
5
|
+
outright and diverges freely (ADR-0062); these attributions are permanent.
|
|
6
|
+
|
|
7
|
+
------------------------------------------------------------------------------
|
|
8
|
+
ElectricSQL — @electric-sql/pglite (packages `pglite`, `pg-protocol`, `pglite-utils`)
|
|
9
|
+
------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
The Postgres runtime under `packages/pgwasm/src/` (`@pgxsinkit/pgwasm`) and the C
|
|
12
|
+
build's host code under `packages/pgwasm-c/src/` (`@pgxsinkit/pgwasm-c`) began as a
|
|
13
|
+
copy of ElectricSQL's PGlite monorepo:
|
|
14
|
+
|
|
15
|
+
Source: https://github.com/electric-sql/pglite
|
|
16
|
+
License: PostgreSQL License. PGlite is dual-licensed under the Apache License 2.0
|
|
17
|
+
and the PostgreSQL License, at the licensee's choice; pgxsinkit takes it
|
|
18
|
+
under the PostgreSQL License.
|
|
19
|
+
Copyright (c) ElectricSQL and contributors
|
|
20
|
+
|
|
21
|
+
The code is owned outright (ADR-0062) and diverges freely; compatibility with PGlite
|
|
22
|
+
is an explicit anti-goal. This attribution is retained because the code began as a
|
|
23
|
+
copy. The PostgreSQL License text, as PGlite ships it (POSTGRES-LICENSE):
|
|
24
|
+
|
|
25
|
+
Copyright (c) ElectricSQL and contributors
|
|
26
|
+
|
|
27
|
+
PostgreSQL Database Management System
|
|
28
|
+
(formerly known as Postgres, then as Postgres95)
|
|
29
|
+
|
|
30
|
+
Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
|
|
31
|
+
|
|
32
|
+
Portions Copyright (c) 1994, The Regents of the University of California
|
|
33
|
+
|
|
34
|
+
Permission to use, copy, modify, and distribute this software and its
|
|
35
|
+
documentation for any purpose, without fee, and without a written agreement
|
|
36
|
+
is hereby granted, provided that the above copyright notice and this
|
|
37
|
+
paragraph and the following two paragraphs appear in all copies.
|
|
38
|
+
|
|
39
|
+
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
|
40
|
+
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
|
41
|
+
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
|
42
|
+
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
|
43
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
44
|
+
|
|
45
|
+
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
|
46
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
47
|
+
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
48
|
+
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
|
49
|
+
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
50
|
+
|
|
51
|
+
------------------------------------------------------------------------------
|
|
52
|
+
node-postgres — pg-protocol (via ElectricSQL's `@electric-sql/pg-protocol`)
|
|
53
|
+
------------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
The wire-protocol codec under `packages/pgwasm/src/protocol/wire/` began as a copy of
|
|
56
|
+
ElectricSQL's `@electric-sql/pg-protocol`, itself adapted from Brian Carlson's
|
|
57
|
+
node-postgres `pg-protocol`. ElectricSQL's changes are taken under the PostgreSQL
|
|
58
|
+
License (the PGlite entry above); the original is MIT-licensed:
|
|
59
|
+
|
|
60
|
+
Source: https://github.com/brianc/node-postgres/tree/master/packages/pg-protocol
|
|
61
|
+
License: MIT
|
|
62
|
+
|
|
63
|
+
MIT License
|
|
64
|
+
|
|
65
|
+
Copyright (c) 2010 - 2021 Brian Carlson
|
|
66
|
+
|
|
67
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
68
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
69
|
+
in the Software without restriction, including without limitation the rights
|
|
70
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
71
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
72
|
+
furnished to do so, subject to the following conditions:
|
|
73
|
+
|
|
74
|
+
The above copyright notice and this permission notice shall be included in all
|
|
75
|
+
copies or substantial portions of the Software.
|
|
76
|
+
|
|
77
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
78
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
79
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
80
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
81
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
82
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
83
|
+
SOFTWARE.
|
|
84
|
+
|
|
85
|
+
------------------------------------------------------------------------------
|
|
86
|
+
Drizzle Team — drizzle-orm, driver `drizzle-orm/pglite`
|
|
87
|
+
------------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
The Drizzle driver under `packages/pgwasm/src/drizzle/` (`@pgxsinkit/pgwasm/drizzle`)
|
|
90
|
+
began as a copy of drizzle-orm's PGlite driver (`src/pglite/driver.ts`,
|
|
91
|
+
`src/pglite/session.ts`, `src/pglite/codecs.ts` at 1.0.0-rc.4), rebound to pgwasm:
|
|
92
|
+
|
|
93
|
+
Source: https://github.com/drizzle-team/drizzle-orm
|
|
94
|
+
License: Apache License 2.0
|
|
95
|
+
Copyright (c) Drizzle Team and contributors
|
|
96
|
+
|
|
97
|
+
Changes: the session, transaction and database classes are rebound from PGlite to
|
|
98
|
+
pgwasm; the driver never constructs its own database; it has its own JIT capability
|
|
99
|
+
probe; `$cache.invalidate` is bound without changing the caller's cache. The Apache-2.0 terms are
|
|
100
|
+
permanent. A copy of the Apache License 2.0 ships with this package in
|
|
101
|
+
LICENSE-APACHE-2.0 (from https://www.apache.org/licenses/LICENSE-2.0.txt).
|
|
102
|
+
|
|
103
|
+
------------------------------------------------------------------------------
|
|
104
|
+
postgres.js — type parsers and serializers
|
|
105
|
+
------------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
`packages/pgwasm/src/types.ts` is based on postgres.js `types.js`, which is published
|
|
108
|
+
under the Unlicense (no conditions; credited as a courtesy):
|
|
109
|
+
|
|
110
|
+
Source: https://github.com/porsager/postgres/blob/master/src/types.js
|
|
111
|
+
License: The Unlicense
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @pgxsinkit/pgwasm
|
|
2
|
+
|
|
3
|
+
The Postgres runtime of [pgxsinkit](https://pgxsinkit.github.io): queries, transactions, live
|
|
4
|
+
queries, `LISTEN`/`NOTIFY` and a Drizzle driver, in the browser and on Bun, over whichever
|
|
5
|
+
compiled Postgres build you hand it. The build is its own package; the C build is
|
|
6
|
+
[`@pgxsinkit/pgwasm-c`](https://www.npmjs.com/package/@pgxsinkit/pgwasm-c).
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
bun add @pgxsinkit/pgwasm @pgxsinkit/pgwasm-c
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { createPgwasm } from "@pgxsinkit/pgwasm";
|
|
14
|
+
import { live } from "@pgxsinkit/pgwasm/live";
|
|
15
|
+
import { cBuild } from "@pgxsinkit/pgwasm-c";
|
|
16
|
+
|
|
17
|
+
const pg = await createPgwasm({ build: cBuild, dataDir: "idb://my-app", extensions: { live } });
|
|
18
|
+
await pg.exec("CREATE TABLE IF NOT EXISTS todo (id serial PRIMARY KEY, title text)");
|
|
19
|
+
const { rows } = await pg.query<{ id: number; title: string }>("SELECT * FROM todo");
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Storage
|
|
23
|
+
|
|
24
|
+
`dataDir` names where the data directory lives, always with a scheme:
|
|
25
|
+
|
|
26
|
+
- `memory://` (or no `dataDir`): in memory, gone on `close()`;
|
|
27
|
+
- `idb://<name>`: IndexedDB, in a browser;
|
|
28
|
+
- `file://<path>`: a directory on disk, on Bun.
|
|
29
|
+
|
|
30
|
+
A build states which of these it supports. `opfs-ahp://` is not supported.
|
|
31
|
+
|
|
32
|
+
A data directory records the Postgres build that created it, and opening it with a different
|
|
33
|
+
build fails with `BuildMismatchError` before anything is written. A store backup
|
|
34
|
+
(`dumpDataDir()`, restored through the `loadDataDir` option) carries the same record, so it
|
|
35
|
+
restores only into its own build.
|
|
36
|
+
|
|
37
|
+
## Entry points
|
|
38
|
+
|
|
39
|
+
| Import | What it gives you |
|
|
40
|
+
| ---------------------------- | --------------------------------------------------------------------------------------- |
|
|
41
|
+
| `@pgxsinkit/pgwasm` | `createPgwasm`, the result and option types, the typed errors |
|
|
42
|
+
| `@pgxsinkit/pgwasm/live` | the `live` extension: `live.query`, `live.incrementalQuery`, `live.changes` |
|
|
43
|
+
| `@pgxsinkit/pgwasm/drizzle` | a Drizzle ORM driver (`drizzle(pg)`); needs `drizzle-orm` |
|
|
44
|
+
| `@pgxsinkit/pgwasm/protocol` | `protocol(pg)`: wire-level access and an exclusive session, for tools such as `pg_dump` |
|
|
45
|
+
| `@pgxsinkit/pgwasm/fs` | the filesystem contract a custom storage implements |
|
|
46
|
+
| `@pgxsinkit/pgwasm/build` | the contract a Postgres build package implements |
|
|
47
|
+
|
|
48
|
+
ESM only, for Bun and browsers (pages, dedicated workers, SharedWorkers and extension pages).
|
|
49
|
+
|
|
50
|
+
See the [documentation](https://pgxsinkit.github.io) for the full toolkit.
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT, except the Drizzle driver (`src/drizzle/`, `@pgxsinkit/pgwasm/drizzle`), which began as drizzle-orm's
|
|
55
|
+
PGlite driver and stays under the Apache License 2.0 (`LICENSE-APACHE-2.0`); the package license is
|
|
56
|
+
`MIT AND Apache-2.0`. `NOTICE` has every attribution.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract a Postgres build implements (ADR-0062 decision 3), and the helpers a build package
|
|
3
|
+
* shares with pgwasm.
|
|
4
|
+
*/
|
|
5
|
+
export type { BlobDevice, BootRequest, BuildCapabilities, BuildIdentity, DataDirEntry, DebugLevel, FilesystemKind, MountedDataDirectory, PostgresBuild, RunningPostgres, ServerExtension, StartOptions, StorageRequest, WireSession, } from "./seam";
|
|
6
|
+
export { readTar, writeTar, TarFormatError, type TarEntry } from "../tar/tar";
|
|
7
|
+
export { gunzip, gunzipIfCompressed, gzip, isGzip } from "../tar/gzip";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
isGzip2,
|
|
4
|
+
gzip2,
|
|
5
|
+
gunzip2,
|
|
6
|
+
gunzipIfCompressed2,
|
|
7
|
+
TarFormatError2,
|
|
8
|
+
writeTar2,
|
|
9
|
+
readTar2
|
|
10
|
+
} from "../chunk-0w227vw2.js";
|
|
11
|
+
export {
|
|
12
|
+
TarFormatError2 as TarFormatError,
|
|
13
|
+
gunzip2 as gunzip,
|
|
14
|
+
gunzipIfCompressed2 as gunzipIfCompressed,
|
|
15
|
+
gzip2 as gzip,
|
|
16
|
+
isGzip2 as isGzip,
|
|
17
|
+
readTar2 as readTar,
|
|
18
|
+
writeTar2 as writeTar
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//# debugId=0AE54698C47411A164756E2164756E21
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seam between pgwasm and a Postgres build (ADR-0062 decision 3).
|
|
3
|
+
*
|
|
4
|
+
* pgwasm owns everything above the wire protocol once: queries, transactions, notifications, live
|
|
5
|
+
* queries, the persist scheduler, the failure latch, the backup format and the build marker. A build
|
|
6
|
+
* provides a boot in two phases (mount storage, then start Postgres), a byte channel per session, and a
|
|
7
|
+
* record of its capabilities. Anything that differs between builds is a capability; shared code never
|
|
8
|
+
* tests a build's name.
|
|
9
|
+
*/
|
|
10
|
+
import type { BaseFilesystem } from "../fs/base-filesystem";
|
|
11
|
+
/** pgwasm's log level, passed through to the build. */
|
|
12
|
+
export type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5;
|
|
13
|
+
/** Who a build is. Recorded in every data directory it creates (ADR-0063 decision 1). */
|
|
14
|
+
export interface BuildIdentity {
|
|
15
|
+
/** Stable name, never renamed; the `storage.build` vocabulary: `"c"`, later `"pgrust"`. */
|
|
16
|
+
readonly name: string;
|
|
17
|
+
/** On-disk compatibility version. A data directory opens only under the same name AND format. */
|
|
18
|
+
readonly dataFormat: number;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a data directory WITHOUT a marker is this build's. True for the C build only: every data
|
|
21
|
+
* directory made before builds were marked was made by it (ADR-0063).
|
|
22
|
+
*/
|
|
23
|
+
readonly claimsUnmarkedDirectories: boolean;
|
|
24
|
+
/** Informational release label, never compared. */
|
|
25
|
+
readonly release: string;
|
|
26
|
+
}
|
|
27
|
+
/** The storage kinds pgwasm knows. A build lists the ones it mounts. */
|
|
28
|
+
export type FilesystemKind = "memory" | "idb" | "file" | "vfs";
|
|
29
|
+
/** Everything that differs between builds, as data. */
|
|
30
|
+
export interface BuildCapabilities {
|
|
31
|
+
/** How many sessions `openSession()` hands out at once. */
|
|
32
|
+
readonly sessions: number;
|
|
33
|
+
/** Needs a cross-origin-isolated context (SharedArrayBuffer) in a browser. */
|
|
34
|
+
readonly requiresCrossOriginIsolation: boolean;
|
|
35
|
+
/** The storage kinds `boot()` accepts. */
|
|
36
|
+
readonly filesystems: readonly FilesystemKind[];
|
|
37
|
+
/**
|
|
38
|
+
* Whether `exchange()` completes inside the call in this context. A tool that bridges a blocking wasm
|
|
39
|
+
* callback to the wire (pg_dump) needs it.
|
|
40
|
+
*/
|
|
41
|
+
readonly synchronousExchange: boolean;
|
|
42
|
+
/** Whether `COPY … FROM/TO '/dev/blob'` works (the `blob` query option). */
|
|
43
|
+
readonly blobDevice: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Where a data directory lives, as pgwasm resolved it from `dataDir` / `fs`. */
|
|
46
|
+
export type StorageRequest = {
|
|
47
|
+
readonly kind: "memory";
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: "idb";
|
|
50
|
+
readonly name: string;
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "file";
|
|
53
|
+
readonly path: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "vfs";
|
|
56
|
+
readonly vfs: BaseFilesystem;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Files a build installs before Postgres starts, shipped by a build package (for example
|
|
60
|
+
* `@pgxsinkit/pgwasm-c/contrib/amcheck`). Pass it in `extensions` like any other extension.
|
|
61
|
+
*/
|
|
62
|
+
export interface ServerExtension {
|
|
63
|
+
readonly kind: "server";
|
|
64
|
+
readonly name: string;
|
|
65
|
+
/** The {@link BuildIdentity.name} it was compiled for; another build refuses it before boot. */
|
|
66
|
+
readonly build: string;
|
|
67
|
+
/** A gzipped tar of the extension's `lib/` and `share/` files. */
|
|
68
|
+
readonly bundle: URL;
|
|
69
|
+
readonly sharedPreloadLibraries?: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One entry of a data directory. `path` is relative to the data directory with a leading `/`
|
|
73
|
+
* (`/PG_VERSION`, `/base/1/1259`): the layout Store backups have always had.
|
|
74
|
+
*/
|
|
75
|
+
export interface DataDirEntry {
|
|
76
|
+
readonly path: string;
|
|
77
|
+
readonly type: "file" | "directory";
|
|
78
|
+
/** Permission bits. */
|
|
79
|
+
readonly mode: number;
|
|
80
|
+
readonly mtimeSeconds: number;
|
|
81
|
+
/** The file's bytes; empty for a directory. */
|
|
82
|
+
readonly data: Uint8Array;
|
|
83
|
+
}
|
|
84
|
+
export interface BootRequest {
|
|
85
|
+
readonly storage: StorageRequest;
|
|
86
|
+
readonly extensions: readonly ServerExtension[];
|
|
87
|
+
readonly user: string;
|
|
88
|
+
readonly database: string;
|
|
89
|
+
readonly debug: DebugLevel;
|
|
90
|
+
}
|
|
91
|
+
/** A compiled Postgres, as pgwasm drives it. */
|
|
92
|
+
export interface PostgresBuild {
|
|
93
|
+
readonly identity: BuildIdentity;
|
|
94
|
+
readonly capabilities: BuildCapabilities;
|
|
95
|
+
/**
|
|
96
|
+
* Optional: settles once everything a {@link boot} would wait on before its own work is ready (artefacts
|
|
97
|
+
* fetched and compiled ahead, e.g. by a warm started on an earlier screen). A caller that times a boot
|
|
98
|
+
* awaits it first, so the timing measures the boot, never an unfinished warm. Never rejects: a failed
|
|
99
|
+
* warm means the build loads its artefacts itself during the boot.
|
|
100
|
+
*/
|
|
101
|
+
prepare?(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Boot, phase 1: bring the host up and mount the storage (IndexedDB read in, a filesystem initially
|
|
104
|
+
* synced). When this resolves, Postgres has not run and nothing in the data directory was written.
|
|
105
|
+
*/
|
|
106
|
+
boot(request: BootRequest): Promise<MountedDataDirectory>;
|
|
107
|
+
}
|
|
108
|
+
/** Phase 1 of a boot: storage is mounted, Postgres has not started. */
|
|
109
|
+
export interface MountedDataDirectory {
|
|
110
|
+
/** A file in the data directory, or `undefined` when it does not exist. Never writes. */
|
|
111
|
+
readFile(path: string): Promise<Uint8Array | undefined>;
|
|
112
|
+
/** Create a fresh cluster (initdb) in an empty data directory. */
|
|
113
|
+
createCluster(): Promise<void>;
|
|
114
|
+
/** Write a data-directory image into an empty data directory (a restore, a seed). */
|
|
115
|
+
writeEntries(entries: readonly DataDirEntry[]): Promise<void>;
|
|
116
|
+
/** Write one file into the data directory. */
|
|
117
|
+
writeFile(path: string, data: Uint8Array): Promise<void>;
|
|
118
|
+
/** Strictly persist everything written so far. */
|
|
119
|
+
persist(): Promise<void>;
|
|
120
|
+
/** Boot, phase 2: start Postgres. */
|
|
121
|
+
start(options: StartOptions): Promise<RunningPostgres>;
|
|
122
|
+
/** Give up without starting: release the storage (locks, handles) and the host. */
|
|
123
|
+
release(): Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
export interface StartOptions {
|
|
126
|
+
/** Server settings (GUCs), `shared_preload_libraries` already merged. */
|
|
127
|
+
readonly settings: Readonly<Record<string, string>>;
|
|
128
|
+
}
|
|
129
|
+
/** Phase 2 of a boot: Postgres is running. */
|
|
130
|
+
export interface RunningPostgres {
|
|
131
|
+
/** A session, already past startup. Calls beyond `capabilities.sessions` reject. */
|
|
132
|
+
openSession(): Promise<WireSession>;
|
|
133
|
+
/**
|
|
134
|
+
* Persist storage after a statement. pgwasm serializes calls and owns the policy: `relaxed` is a
|
|
135
|
+
* background persist whose failure pgwasm latches; `false` is awaited by the statement.
|
|
136
|
+
*/
|
|
137
|
+
persist(relaxed: boolean): Promise<void>;
|
|
138
|
+
/** Walk the data directory for a Store backup. pgwasm holds its query lock around the call. */
|
|
139
|
+
readEntries(): Promise<DataDirEntry[]>;
|
|
140
|
+
/** The `/dev/blob` device, present iff `capabilities.blobDevice`. */
|
|
141
|
+
readonly blob: BlobDevice | undefined;
|
|
142
|
+
/** Stop Postgres cleanly. Never called after a failure. */
|
|
143
|
+
shutdown(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Release the storage and the host. Always the last call, after a failure too. `afterFailedBoot` is
|
|
146
|
+
* set when the boot failed after `start()` (a filesystem gets `cleanupFailedInit` instead of `closeFs`).
|
|
147
|
+
*/
|
|
148
|
+
release(options?: {
|
|
149
|
+
readonly afterFailedBoot?: boolean;
|
|
150
|
+
}): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
/** One session's byte channel carrying the wire protocol. */
|
|
153
|
+
export interface WireSession {
|
|
154
|
+
/**
|
|
155
|
+
* Send frontend bytes and stream every byte of the COMPLETE reply into `onData`; settle when it is
|
|
156
|
+
* complete. A build on a real wire frames the reply itself (a Flush after a non-terminal message, then
|
|
157
|
+
* read to its terminator). Returns `undefined` when it completed synchronously, which it always does
|
|
158
|
+
* when `capabilities.synchronousExchange`. A chunk is only valid during the callback: copy it to keep
|
|
159
|
+
* it. A throw is a failure of the build, never an SQL error (those arrive in-band as ErrorResponse),
|
|
160
|
+
* and pgwasm fails the instance. A message starting with a 0 byte is a startup packet.
|
|
161
|
+
*/
|
|
162
|
+
exchange(message: Uint8Array, onData: (chunk: Uint8Array) => void): void | Promise<void>;
|
|
163
|
+
/** Set by pgwasm: backend bytes that arrive between exchanges (another session's NOTIFY). */
|
|
164
|
+
onUnsolicited: ((chunk: Uint8Array) => void) | undefined;
|
|
165
|
+
close(): Promise<void>;
|
|
166
|
+
}
|
|
167
|
+
/** The `COPY … '/dev/blob'` device. */
|
|
168
|
+
export interface BlobDevice {
|
|
169
|
+
/** What `COPY … FROM '/dev/blob'` reads, or `undefined` to clear it. */
|
|
170
|
+
setReadSource(data: Uint8Array | undefined): void;
|
|
171
|
+
/** What `COPY … TO '/dev/blob'` wrote since the last call, or `undefined` when nothing was. */
|
|
172
|
+
takeWritten(): Uint8Array<ArrayBuffer>[] | undefined;
|
|
173
|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