@pgxsinkit/client 0.3.0 → 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 +81 -0
- package/README.md +10 -3
- package/dist/boot-report.d.ts +6 -6
- package/dist/circuits/envelope-to-change.d.ts +9 -5
- package/dist/circuits/envelope-to-change.d.ts.map +1 -1
- package/dist/circuits/group-sync.d.ts +2 -2
- package/dist/circuits/group-sync.d.ts.map +1 -1
- package/dist/circuits/stream-source.d.ts +6 -0
- package/dist/circuits/stream-source.d.ts.map +1 -1
- package/dist/circuits/sync-engine.d.ts +2 -2
- package/dist/circuits/sync-engine.d.ts.map +1 -1
- package/dist/event-lane.d.ts +32 -1
- package/dist/event-lane.d.ts.map +1 -1
- package/dist/export-data.d.ts +3 -3
- package/dist/export-dump.d.ts +9 -9
- package/dist/export-dump.d.ts.map +1 -1
- package/dist/export-store.d.ts +13 -13
- package/dist/index.d.ts +191 -95
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +989 -432
- package/dist/index.js.map +39 -36
- package/dist/local-store.d.ts +1 -1
- package/dist/local-store.d.ts.map +1 -1
- package/dist/local-tables.d.ts +58 -0
- package/dist/local-tables.d.ts.map +1 -1
- package/dist/mutation.d.ts +2 -2
- package/dist/mutation.d.ts.map +1 -1
- package/dist/mutations-api.d.ts.map +1 -1
- package/dist/opfs-effects.d.ts +30 -2
- package/dist/opfs-effects.d.ts.map +1 -1
- package/dist/schema.d.ts +12 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/store-boot.d.ts +30 -2
- package/dist/store-boot.d.ts.map +1 -1
- package/dist/store-build.d.ts +19 -0
- package/dist/store-build.d.ts.map +1 -0
- package/dist/store-engine.d.ts +22 -0
- package/dist/store-engine.d.ts.map +1 -0
- package/dist/store-meta.d.ts +29 -3
- package/dist/store-meta.d.ts.map +1 -1
- package/dist/store-ownership-lock.d.ts +33 -0
- package/dist/store-ownership-lock.d.ts.map +1 -0
- package/dist/store-path.d.ts +40 -28
- package/dist/store-path.d.ts.map +1 -1
- package/dist/sync/apply.d.ts +5 -5
- package/dist/sync/apply.d.ts.map +1 -1
- package/dist/sync/copy.d.ts +82 -6
- package/dist/sync/copy.d.ts.map +1 -1
- package/dist/sync/drizzle-executor.d.ts +4 -4
- package/dist/sync/drizzle-executor.d.ts.map +1 -1
- package/dist/sync/subscription-state.d.ts +5 -5
- package/dist/sync/subscription-state.d.ts.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +4 -4
- package/dist/worker/attach-sync-client.d.ts +24 -13
- package/dist/worker/attach-sync-client.d.ts.map +1 -1
- package/dist/worker/define-sync-worker.d.ts +35 -18
- package/dist/worker/define-sync-worker.d.ts.map +1 -1
- package/dist/worker/live-query-manager.d.ts +3 -3
- package/dist/worker/live-query-manager.d.ts.map +1 -1
- package/dist/worker/live-query-params-guard.d.ts +5 -5
- package/dist/worker/protocol.d.ts +26 -7
- package/dist/worker/protocol.d.ts.map +1 -1
- package/package.json +11 -8
- package/skills/core/SKILL.md +80 -15
- package/skills/operating/SKILL.md +129 -129
- package/skills/operating/references/postgres-builds.md +48 -0
- package/src/boot-report.ts +9 -9
- package/src/circuits/envelope-to-change.ts +121 -12
- package/src/circuits/group-sync.ts +2 -2
- package/src/circuits/stream-source.ts +35 -9
- package/src/circuits/sync-engine.ts +6 -4
- package/src/event-lane.ts +132 -14
- package/src/export-data.ts +4 -4
- package/src/export-dump.ts +21 -26
- package/src/export-store.ts +17 -17
- package/src/index.ts +520 -284
- package/src/live-rows-sql.ts +1 -1
- package/src/local-store.ts +2 -2
- package/src/local-tables.ts +70 -6
- package/src/mutation.ts +9 -8
- package/src/mutations-api.ts +2 -2
- package/src/opfs-effects.ts +74 -10
- package/src/schema.ts +124 -18
- package/src/store-boot.ts +71 -7
- package/src/store-build.ts +37 -0
- package/src/store-engine.ts +94 -0
- package/src/store-lifecycle.ts +1 -1
- package/src/store-meta.ts +155 -4
- package/src/store-ownership-lock.ts +109 -0
- package/src/store-path.ts +56 -40
- package/src/sync/apply.ts +32 -46
- package/src/sync/copy.ts +108 -13
- package/src/sync/drizzle-executor.ts +13 -14
- package/src/sync/metadata-tables.ts +1 -1
- package/src/sync/subscription-state.ts +7 -7
- package/src/testing.ts +3 -3
- package/src/worker/attach-sync-client.ts +142 -56
- package/src/worker/define-sync-worker.ts +204 -75
- package/src/worker/engine-router.ts +1 -1
- package/src/worker/live-query-fingerprint.ts +4 -4
- package/src/worker/live-query-manager.ts +12 -12
- package/src/worker/live-query-params-guard.ts +10 -10
- package/src/worker/protocol.ts +38 -7
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,81 @@
|
|
|
1
|
+
@pgxsinkit/client
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
This package includes software that began as a copy, or is a port, of third-party
|
|
5
|
+
code. It is owned outright and diverges freely (ADR-0009, ADR-0028); these
|
|
6
|
+
attributions are permanent.
|
|
7
|
+
|
|
8
|
+
------------------------------------------------------------------------------
|
|
9
|
+
ElectricSQL — @electric-sql/pglite, package `pglite-sync`
|
|
10
|
+
------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
The read-path sync engine began as a copy of ElectricSQL's `@electric-sql/pglite`
|
|
13
|
+
monorepo, package `packages/pglite-sync`:
|
|
14
|
+
|
|
15
|
+
Source: https://github.com/electric-sql/pglite/tree/main/packages/pglite-sync
|
|
16
|
+
License: Apache License 2.0
|
|
17
|
+
Copyright (c) ElectricSQL and contributors
|
|
18
|
+
|
|
19
|
+
These files derive from it, and each carries a header saying so:
|
|
20
|
+
|
|
21
|
+
- src/sync/apply.ts
|
|
22
|
+
- src/sync/subscription-state.ts
|
|
23
|
+
- src/sync/types.ts
|
|
24
|
+
- src/circuits/sync-engine.ts
|
|
25
|
+
|
|
26
|
+
Their compiled form ships in `dist/`.
|
|
27
|
+
|
|
28
|
+
Changes: the engine reads each shape from a durable stream rather than Electric's
|
|
29
|
+
shape API (ADR-0055); commits each consistency group atomically through a
|
|
30
|
+
single-flight commit queue that holds a failed batch instead of dropping it
|
|
31
|
+
(ADR-0009); applies through an apply ladder chosen from the registry's column types,
|
|
32
|
+
folding each batch to one operation per primary key (ADR-0014); serializes COPY in
|
|
33
|
+
Postgres' TEXT format; keeps its metadata in its own `pgxsinkit` schema; and builds
|
|
34
|
+
its statements with Drizzle (ADR-0028). The Apache-2.0 terms are permanent. A copy of
|
|
35
|
+
the Apache License 2.0 ships with this package in LICENSE-APACHE-2.0 (from
|
|
36
|
+
https://www.apache.org/licenses/LICENSE-2.0.txt).
|
|
37
|
+
|
|
38
|
+
------------------------------------------------------------------------------
|
|
39
|
+
PostgreSQL — COPY TEXT field escaping and array literals
|
|
40
|
+
------------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
`src/sync/copy.ts`, the COPY TEXT serializer, ports two PostgreSQL backend routines
|
|
43
|
+
to TypeScript, with PostgreSQL 18 as the reference:
|
|
44
|
+
|
|
45
|
+
- `CopyAttributeOutText` (src/backend/commands/copyto.c): COPY TEXT field escaping
|
|
46
|
+
- `array_out` (src/backend/utils/adt/arrayfuncs.c): array literals
|
|
47
|
+
|
|
48
|
+
Source: https://www.postgresql.org
|
|
49
|
+
License: PostgreSQL License
|
|
50
|
+
Copyright (c) The PostgreSQL Global Development Group and The Regents of the
|
|
51
|
+
University of California
|
|
52
|
+
|
|
53
|
+
The file carries a header saying so, and its compiled form ships in `dist/`.
|
|
54
|
+
PostgreSQL's notice, copied from its COPYRIGHT file as PostgreSQL 18.3 ships it
|
|
55
|
+
(https://github.com/electric-sql/postgres-pglite at
|
|
56
|
+
b133782cd759f08b3aeb263b80a963b39c7b7af1, file COPYRIGHT, unchanged from PostgreSQL's
|
|
57
|
+
own; the same copy @pgxsinkit/pgwasm-c's NOTICE reproduces):
|
|
58
|
+
|
|
59
|
+
PostgreSQL Database Management System
|
|
60
|
+
(also known as Postgres, formerly known as Postgres95)
|
|
61
|
+
|
|
62
|
+
Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
|
|
63
|
+
|
|
64
|
+
Portions Copyright (c) 1994, The Regents of the University of California
|
|
65
|
+
|
|
66
|
+
Permission to use, copy, modify, and distribute this software and its
|
|
67
|
+
documentation for any purpose, without fee, and without a written agreement
|
|
68
|
+
is hereby granted, provided that the above copyright notice and this
|
|
69
|
+
paragraph and the following two paragraphs appear in all copies.
|
|
70
|
+
|
|
71
|
+
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
|
72
|
+
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
|
73
|
+
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
|
74
|
+
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
|
75
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
76
|
+
|
|
77
|
+
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
|
78
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
79
|
+
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
80
|
+
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
|
81
|
+
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @pgxsinkit/client
|
|
2
2
|
|
|
3
3
|
The [pgxsinkit](https://pgxsinkit.github.io) client: `createSyncClient` stages writes
|
|
4
|
-
into a local
|
|
4
|
+
into a local pgwasm overlay and a durable mutation journal, flushes them to the write
|
|
5
5
|
API, and subscribes through the read path's control plane to read durable-streams into
|
|
6
|
-
local
|
|
6
|
+
local pgwasm store.
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
bun add @pgxsinkit/client @pgxsinkit/contracts
|
|
@@ -13,7 +13,7 @@ See the [documentation](https://pgxsinkit.github.io) for the read and write path
|
|
|
13
13
|
|
|
14
14
|
## Browser storage and worker placement
|
|
15
15
|
|
|
16
|
-
`createSyncClient` is the in-process client. For browser apps, worker mode moves
|
|
16
|
+
`createSyncClient` is the in-process client. For browser apps, worker mode moves pgwasm off the
|
|
17
17
|
main thread with capability-driven placement (ADR-0049) as the default:
|
|
18
18
|
|
|
19
19
|
- real macOS/iOS Safari grants synchronous OPFS handles in a `SharedWorker`, so the engine runs there
|
|
@@ -32,3 +32,10 @@ placement from the browser name.
|
|
|
32
32
|
|
|
33
33
|
See [Worker mode](https://pgxsinkit.github.io/concepts/worker-mode/) for the complete factory,
|
|
34
34
|
relocation, adoption, destruction, and durability contract.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT, except the parts of the read-path sync engine that began as ElectricSQL's
|
|
39
|
+
`@electric-sql/pglite-sync`, which stay under the Apache License 2.0 (`LICENSE-APACHE-2.0`); the
|
|
40
|
+
package license is `MIT AND Apache-2.0`. The COPY serializer ports two PostgreSQL routines and keeps
|
|
41
|
+
PostgreSQL's notice. `NOTICE` lists those files and has every attribution.
|
package/dist/boot-report.d.ts
CHANGED
|
@@ -67,18 +67,18 @@ export interface BootReport {
|
|
|
67
67
|
writeReadyMs: number | null;
|
|
68
68
|
/**
|
|
69
69
|
* Present only when the store was pre-provisioned (a spare's initdb ran off-thread before this boot
|
|
70
|
-
* adopted it); `null` otherwise. When present, `phases.
|
|
70
|
+
* adopted it); `null` otherwise. When present, `phases.pgwasmCreateMs` is `null` — the create cost is
|
|
71
71
|
* reported here instead.
|
|
72
72
|
*/
|
|
73
73
|
provision: {
|
|
74
|
-
/** The spare's
|
|
74
|
+
/** The spare's pgwasm create (initdb) cost, paid at provision time. */
|
|
75
75
|
initdbMs: number;
|
|
76
76
|
/** How long the provisioned store sat ready before this boot adopted it. */
|
|
77
77
|
provisionedMsBeforeBoot: number;
|
|
78
78
|
} | null;
|
|
79
79
|
phases: {
|
|
80
|
-
/**
|
|
81
|
-
|
|
80
|
+
/** pgwasm create cost, or `null` when the store was adopted from a spare (see {@link BootReport.provision}). */
|
|
81
|
+
pgwasmCreateMs: number | null;
|
|
82
82
|
schemaExecMs: number;
|
|
83
83
|
journalRecoveryMs: number;
|
|
84
84
|
storeVersionReconcileMs: number;
|
|
@@ -143,7 +143,7 @@ export interface BootReport {
|
|
|
143
143
|
*/
|
|
144
144
|
fetchMs: number;
|
|
145
145
|
/**
|
|
146
|
-
* Wall around this group's batch commits into
|
|
146
|
+
* Wall around this group's batch commits into pgwasm. Includes waiting behind another group's
|
|
147
147
|
* transaction on the shared connection (single writer), so concurrent groups' `applyMs` can overlap.
|
|
148
148
|
*/
|
|
149
149
|
applyMs: number;
|
|
@@ -159,7 +159,7 @@ type PhaseKey = "schemaExec" | "journalRecovery" | "storeVersionReconcile" | "sy
|
|
|
159
159
|
export interface GroupBootStamp {
|
|
160
160
|
/** A batch was delivered to the group's subscribe callback (one response). `changeCount` = its change rows. */
|
|
161
161
|
onBatchDelivered: (changeCount: number) => void;
|
|
162
|
-
/** A commit transaction applied `ms` of work into
|
|
162
|
+
/** A commit transaction applied `ms` of work into pgwasm for this group. */
|
|
163
163
|
onApply: (ms: number) => void;
|
|
164
164
|
/** The group reached its initial sync — stamp `readyAtMs` and freeze accumulation. */
|
|
165
165
|
markReady: () => void;
|
|
@@ -9,12 +9,16 @@ export interface ChangeLike {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Rebuild the primary-key columns of a row from the stream key.
|
|
12
|
+
* Rebuild the LOCAL primary-key columns of a row from the stream key.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* The key is the SERVER identity: composite keys are joined in server primary-key declaration order
|
|
15
|
+
* (escaped per component — see {@link unescapeKeyComponent}), single keys are the raw value. Under a
|
|
16
|
+
* `clientProjection.localPrimaryKey` narrowing the local key is a subset of the server key, so the
|
|
17
|
+
* split runs over `serverPrimaryKey` and only the local components are kept — the dropped ones are
|
|
18
|
+
* predicate-pinned (subscribe-time compile refuses the narrowing otherwise), so within this shape
|
|
19
|
+
* the narrowed key is still unique. A count mismatch is thrown rather than tolerated: a silently
|
|
20
|
+
* short split would produce a `WHERE` over only part of the key, and a delete matching more rows
|
|
21
|
+
* than it should is data loss, not a stale row.
|
|
18
22
|
*/
|
|
19
23
|
export declare function primaryKeyFromStreamKey(target: ApplyTarget, key: string): Record<string, unknown>;
|
|
20
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope-to-change.d.ts","sourceRoot":"","sources":["../../src/circuits/envelope-to-change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"envelope-to-change.d.ts","sourceRoot":"","sources":["../../src/circuits/envelope-to-change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAwCnD,yFAAyF;AACzF,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,EAAE;QAAE,SAAS,EAAE,aAAa,CAAA;KAAE,CAAC;CACvC;AA0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA0BjG;AAoDD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,GAAG,UAAU,CAiC1F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PGliteInterface } from "@electric-sql/pglite";
|
|
2
1
|
import type { PredicateValue, SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
2
|
+
import type { Pgwasm } from "@pgxsinkit/pgwasm";
|
|
3
3
|
import type { BootStampCollector } from "../boot-report";
|
|
4
4
|
import { ControlPlaneError, type RefusedStream } from "./subscription-client";
|
|
5
5
|
export interface CircuitsGroupSyncOptions {
|
|
@@ -119,5 +119,5 @@ export interface CircuitsGroupSyncResult {
|
|
|
119
119
|
* is the thing a later subscribe matches a grant against.
|
|
120
120
|
*/
|
|
121
121
|
export declare function logicalShapeName(shapeKey: string, scope?: readonly PredicateValue[]): string;
|
|
122
|
-
export declare function startCircuitsSync(pg:
|
|
122
|
+
export declare function startCircuitsSync(pg: Pgwasm, options: CircuitsGroupSyncOptions): Promise<CircuitsGroupSyncResult>;
|
|
123
123
|
//# sourceMappingURL=group-sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-sync.d.ts","sourceRoot":"","sources":["../../src/circuits/group-sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"group-sync.d.ts","sourceRoot":"","sources":["../../src/circuits/group-sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAkB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAC;AASzE,OAAO,EACL,iBAAiB,EAGjB,KAAK,aAAa,EAEnB,MAAM,u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KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IAChD;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD;;;;OAIG;IACH,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC3D;;;;OAIG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;CAC3B;AA6ED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAE5F;AAgED,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA+pBlC"}
|
|
@@ -82,6 +82,12 @@ export interface ShapeStreamSubscription {
|
|
|
82
82
|
* read is over and nothing failed"; `onEnd(error)` is the mid-session reset (ADR-0056 decision 7)
|
|
83
83
|
* that a caller must answer with a re-subscribe.
|
|
84
84
|
*
|
|
85
|
+
* ORDERING GUARANTEE: `onEnd(null)` is called only AFTER `onBatch` has been handed the batch that
|
|
86
|
+
* ends the read (the up-to-date batch of a `live: false` read; the `Stream-Closed` batch of any
|
|
87
|
+
* read). `closed` alone does not give that — it settles when the transport's fetch loop is done,
|
|
88
|
+
* which for a non-live read can be before the subscriber has consumed the final response — so the
|
|
89
|
+
* normal end is reported off the terminal batch, and a caller may close on `onEnd` without losing it.
|
|
90
|
+
*
|
|
85
91
|
* The transport only. Everything above it — the fold, apply modes, the boot gate — stays
|
|
86
92
|
* pgxsinkit's, which is ADR-0009's precedent applied to a new substrate: keep the transport,
|
|
87
93
|
* internalize the semantics.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-source.d.ts","sourceRoot":"","sources":["../../src/circuits/stream-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,6EAA6E;AAC7E,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IACrC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,2FAA2F;IAC3F,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7E,iFAAiF;IACjF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,WAAW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AgB,mBAAmB,CACjC,eAAe,EAAE,WAAW,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,GACnE,kBAAkB,CAcpB;AAED,sGAAsG;AACtG,MAAM,WAAW,uBAAuB;IACtC,+CAA+C;IAC/C,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACrD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GACpC,OAAO,CAAC,uBAAuB,CAAC,CAqElC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PGliteInterface } from "@electric-sql/pglite";
|
|
2
1
|
import { type PredicateValue, type SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
2
|
+
import type { Pgwasm } from "@pgxsinkit/pgwasm";
|
|
3
3
|
import { type GroupBootStamp } from "../boot-report";
|
|
4
4
|
import { drizzleOverPg } from "../sync/drizzle-executor";
|
|
5
5
|
import type { InitialInsertMethod } from "../sync/types";
|
|
@@ -64,7 +64,7 @@ export interface CircuitsShapeSpec {
|
|
|
64
64
|
initialInsertMethod?: InitialInsertMethod;
|
|
65
65
|
}
|
|
66
66
|
export interface CircuitsSyncOptions {
|
|
67
|
-
pg:
|
|
67
|
+
pg: Pgwasm;
|
|
68
68
|
registry: SyncTableRegistry;
|
|
69
69
|
/** Subscription key for persisted resume state; `null` disables persistence. */
|
|
70
70
|
key: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-engine.d.ts","sourceRoot":"","sources":["../../src/circuits/sync-engine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-engine.d.ts","sourceRoot":"","sources":["../../src/circuits/sync-engine.ts"],"names":[],"mappings":"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AE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACpC,eAAe,CAAC,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IACzD,mGAAmG;IACnG,WAAW,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACrC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/D;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,IAAI,IAAI,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAqBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA2XlG"}
|
package/dist/event-lane.d.ts
CHANGED
|
@@ -18,9 +18,15 @@
|
|
|
18
18
|
* client-side quarantine (ADR-0053 decision 4): terminal deletion happens only on `acked`/`refused`/
|
|
19
19
|
* `rejected`. A batch that keeps failing backs off at a ceiling, observably, while the Outbox keeps
|
|
20
20
|
* absorbing appends — it is designed to hold offline weeks.
|
|
21
|
+
*
|
|
22
|
+
* ADR-0060 adds one wrinkle to that second invariant's `acked` half: with `events.ackedRetentionMs > 0` an
|
|
23
|
+
* acked row is STAMPED (`acked_at_us`) and retained for the retention rather than deleted at once, so a
|
|
24
|
+
* best-guess view can keep counting it across the ack→fold→sync window. It is a delayed delete, not a
|
|
25
|
+
* changed verdict — a stamped row is no longer PENDING anywhere in this file (assembly skips it, the drain
|
|
26
|
+
* signal ignores it), and the sweep retires it.
|
|
21
27
|
*/
|
|
22
28
|
import { type EventAckStatus, type SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
23
|
-
/** The raw local-store seam the Event lane executes through (structurally
|
|
29
|
+
/** The raw local-store seam the Event lane executes through (structurally pgwasm; mirrors `MutationDb`). */
|
|
24
30
|
export interface EventLaneDb {
|
|
25
31
|
query: <TRow extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: unknown[]) => Promise<{
|
|
26
32
|
rows: TRow[];
|
|
@@ -77,6 +83,28 @@ export interface EventLaneOptions {
|
|
|
77
83
|
intervalMs?: number;
|
|
78
84
|
/** Backoff tuning for deferred rows and for batch-level faults. */
|
|
79
85
|
backoff?: EventBackoffOptions;
|
|
86
|
+
/**
|
|
87
|
+
* How long an **acked** row is RETAINED in the Outbox after the server accepts it, in ms (ADR-0060).
|
|
88
|
+
* Defaults to `0`.
|
|
89
|
+
*
|
|
90
|
+
* `0` is exactly the lane's original behaviour: an `acked` verdict DELETES the row on the spot, in the
|
|
91
|
+
* same statement that retires the terminal `refused`/`rejected` ones — no stamp, no sweep, no added cost
|
|
92
|
+
* on the default path. Anything greater turns on the **acked ledger**: the row stays, stamped with
|
|
93
|
+
* `acked_at_us`, until a sweep retires it that many ms later.
|
|
94
|
+
*
|
|
95
|
+
* It exists for ONE consumer shape — a best-guess view composing pending Outbox rows with down-synced
|
|
96
|
+
* aggregates. The server accepts an event well BEFORE its consumer folds it, and the folded row syncs
|
|
97
|
+
* back down later still, so a composition that drops the event at the ack dips for the whole ack→fold→sync
|
|
98
|
+
* window. With a retention the acked row is still there to be counted during it. The library takes no
|
|
99
|
+
* position on when the fold landed (it cannot know); the view keeps the row until its own synced value
|
|
100
|
+
* accounts for it, and the retention is the backstop.
|
|
101
|
+
*
|
|
102
|
+
* Retained rows are NOT pending: they are invisible to batch assembly (never re-posted), to the drain
|
|
103
|
+
* signal `{ empty }`, to `diagnostics().outbox`, and to the non-forced `destroy()` refusal. Size it to
|
|
104
|
+
* the deployment's ack→fold→sync latency plus margin, not to "how long I want the history" — the Outbox
|
|
105
|
+
* is not an archive.
|
|
106
|
+
*/
|
|
107
|
+
ackedRetentionMs?: number;
|
|
80
108
|
/** Per-Event-stream overrides, keyed by Event-stream name. */
|
|
81
109
|
streams?: Record<string, EventStreamFlushOptions>;
|
|
82
110
|
}
|
|
@@ -93,6 +121,9 @@ export interface EventAppendResult {
|
|
|
93
121
|
* The **drain signal** (ADR-0053 decision 2): whether the Outbox is empty. Deliberately no count — a count
|
|
94
122
|
* that updates only on transitions is stale by construction, and a count updated per append is a worse live
|
|
95
123
|
* query. Richer detail is a query against the Outbox table.
|
|
124
|
+
*
|
|
125
|
+
* "Empty" is "nothing AWAITS A SERVER VERDICT", so acked rows the ledger is retaining (ADR-0060) do not
|
|
126
|
+
* hold it `false` — they have had their verdict.
|
|
96
127
|
*/
|
|
97
128
|
export interface OutboxStatus {
|
|
98
129
|
empty: boolean;
|
package/dist/event-lane.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-lane.d.ts","sourceRoot":"","sources":["../src/event-lane.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"event-lane.d.ts","sourceRoot":"","sources":["../src/event-lane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAUL,KAAK,cAAc,EAGnB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAM9B,4GAA4G;AAC5G,MAAM,WAAW,WAAW;IAC1B,KA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;IACpB,mEAAmE;IACnE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,uGAAuG;IACvG,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,+FAA+F;IAC/F,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,gBAAgB,CA2EzF"}
|
package/dist/export-data.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MutationDiagnostics } from "@pgxsinkit/contracts";
|
|
2
2
|
import { type DataExportReport } from "./export-store";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PgwasmClient } from "./index";
|
|
4
4
|
/** The default drain budget: actively flush + await the convergence barrier for up to 15s before failing. */
|
|
5
5
|
export declare const DEFAULT_DRAIN_TIMEOUT_MS = 15000;
|
|
6
6
|
/** The drain guard's tuning: the wait budget for reaching a fully-drained journal. */
|
|
@@ -61,7 +61,7 @@ export declare class DataExportDrainError extends Error {
|
|
|
61
61
|
/** The dependencies {@link performDataExport} needs from the owning client — narrow, so it is unit-testable. */
|
|
62
62
|
export interface DataExportDeps {
|
|
63
63
|
/** The live store to checkpoint and dump (the clone source; the live engine is never suspended). */
|
|
64
|
-
|
|
64
|
+
pgwasm: Pick<PgwasmClient, "exec" | "dumpDataDir">;
|
|
65
65
|
/** The Mutation diagnostics seam (`client.diagnostics().mutation` / `readMutationStats`). */
|
|
66
66
|
readMutationStats: () => Promise<MutationDiagnostics>;
|
|
67
67
|
/** The optimistic flush (`client.flush()`), driven during the drain to send drainable rows. */
|
|
@@ -84,7 +84,7 @@ export interface DataExportDeps {
|
|
|
84
84
|
cloneCleanupSql: string;
|
|
85
85
|
/**
|
|
86
86
|
* The store's configured plain store PATH (ADR-0036) — reduced to the `storeId` in the default artefact
|
|
87
|
-
* file name. The resolved
|
|
87
|
+
* file name. The resolved pgwasm dataDir URL is deliberately NOT used: internal plumbing, never an
|
|
88
88
|
* artefact-name seed.
|
|
89
89
|
*/
|
|
90
90
|
storePath?: string;
|