@jini-ai/db 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE.pglite-socket +176 -0
  3. package/NOTICE.md +27 -0
  4. package/README.md +210 -0
  5. package/dist/core/artifact-naming.d.ts +34 -0
  6. package/dist/core/artifact-naming.js +34 -0
  7. package/dist/core/index.d.ts +8 -0
  8. package/dist/core/index.js +10 -0
  9. package/dist/core/messages.d.ts +43 -0
  10. package/dist/core/messages.js +26 -0
  11. package/dist/core/pg-types.d.ts +22 -0
  12. package/dist/core/pg-types.js +26 -0
  13. package/dist/core/ports.d.ts +70 -0
  14. package/dist/core/ports.js +22 -0
  15. package/dist/core/row-values.d.ts +32 -0
  16. package/dist/core/row-values.js +42 -0
  17. package/dist/core/socket.d.ts +8 -0
  18. package/dist/core/socket.js +8 -0
  19. package/dist/kernel/dialect.d.ts +83 -0
  20. package/dist/kernel/dialect.js +191 -0
  21. package/dist/kernel/index.d.ts +15 -0
  22. package/dist/kernel/index.js +15 -0
  23. package/dist/kernel/kernel-core.d.ts +43 -0
  24. package/dist/kernel/kernel-core.js +98 -0
  25. package/dist/kernel/ops.d.ts +48 -0
  26. package/dist/kernel/ops.js +49 -0
  27. package/dist/kernel/pg-types.d.ts +22 -0
  28. package/dist/kernel/pg-types.js +26 -0
  29. package/dist/kernel/pglite/dialect.d.ts +11 -0
  30. package/dist/kernel/pglite/dialect.js +88 -0
  31. package/dist/kernel/pglite/driver.d.ts +30 -0
  32. package/dist/kernel/pglite/driver.js +47 -0
  33. package/dist/kernel/pglite/index.d.ts +5 -0
  34. package/dist/kernel/pglite/index.js +5 -0
  35. package/dist/kernel/pglite/ops.d.ts +39 -0
  36. package/dist/kernel/pglite/ops.js +78 -0
  37. package/dist/kernel/port.d.ts +82 -0
  38. package/dist/kernel/port.js +11 -0
  39. package/dist/kernel/postgres/driver.d.ts +23 -0
  40. package/dist/kernel/postgres/driver.js +42 -0
  41. package/dist/kernel/postgres/index.d.ts +5 -0
  42. package/dist/kernel/postgres/index.js +5 -0
  43. package/dist/kernel/postgres/ops.d.ts +12 -0
  44. package/dist/kernel/postgres/ops.js +46 -0
  45. package/dist/kernel/postgres/pglite-socket.d.ts +23 -0
  46. package/dist/kernel/postgres/pglite-socket.js +52 -0
  47. package/dist/kernel/postgres-lock.d.ts +8 -0
  48. package/dist/kernel/postgres-lock.js +10 -0
  49. package/dist/kernel/schema-scope.d.ts +14 -0
  50. package/dist/kernel/schema-scope.js +20 -0
  51. package/dist/kernel/schema-shape.d.ts +26 -0
  52. package/dist/kernel/schema-shape.js +83 -0
  53. package/dist/kernel/socket.d.ts +8 -0
  54. package/dist/kernel/socket.js +8 -0
  55. package/dist/kernel/sqlite/driver.d.ts +71 -0
  56. package/dist/kernel/sqlite/driver.js +132 -0
  57. package/dist/kernel/sqlite/index.d.ts +4 -0
  58. package/dist/kernel/sqlite/index.js +4 -0
  59. package/dist/kernel/sqlite/ops.d.ts +12 -0
  60. package/dist/kernel/sqlite/ops.js +40 -0
  61. package/dist/kernel/store-copy.d.ts +82 -0
  62. package/dist/kernel/store-copy.js +240 -0
  63. package/dist/kernel/turn-lock.d.ts +21 -0
  64. package/dist/kernel/turn-lock.js +42 -0
  65. package/dist/kernel/typegen.d.ts +13 -0
  66. package/dist/kernel/typegen.js +76 -0
  67. package/dist/migrate/checksum.d.ts +11 -0
  68. package/dist/migrate/checksum.js +14 -0
  69. package/dist/migrate/index.d.ts +8 -0
  70. package/dist/migrate/index.js +8 -0
  71. package/dist/migrate/runner.d.ts +33 -0
  72. package/dist/migrate/runner.js +126 -0
  73. package/dist/migrate/step.d.ts +37 -0
  74. package/dist/migrate/step.js +31 -0
  75. package/dist/pglite/dialect.d.ts +11 -0
  76. package/dist/pglite/dialect.js +88 -0
  77. package/dist/pglite/driver.d.ts +30 -0
  78. package/dist/pglite/driver.js +46 -0
  79. package/dist/pglite/index.d.ts +5 -0
  80. package/dist/pglite/index.js +4 -0
  81. package/dist/pglite/ops.d.ts +39 -0
  82. package/dist/pglite/ops.js +78 -0
  83. package/dist/pglite/owner.d.ts +107 -0
  84. package/dist/pglite/owner.js +359 -0
  85. package/dist/pglite/socket-server.d.ts +38 -0
  86. package/dist/pglite/socket-server.js +375 -0
  87. package/dist/pglite/types.d.ts +9 -0
  88. package/dist/pglite/types.js +2 -0
  89. package/dist/postgres/driver.d.ts +23 -0
  90. package/dist/postgres/driver.js +41 -0
  91. package/dist/postgres/index.d.ts +3 -0
  92. package/dist/postgres/index.js +3 -0
  93. package/dist/postgres/ops.d.ts +12 -0
  94. package/dist/postgres/ops.js +46 -0
  95. package/dist/postgres/pglite-socket.d.ts +23 -0
  96. package/dist/postgres/pglite-socket.js +51 -0
  97. package/dist/postgres/types.d.ts +53 -0
  98. package/dist/postgres/types.js +14 -0
  99. package/dist/sqlite/db-ops.d.ts +59 -0
  100. package/dist/sqlite/db-ops.js +82 -0
  101. package/dist/sqlite/driver.d.ts +71 -0
  102. package/dist/sqlite/driver.js +132 -0
  103. package/dist/sqlite/index.d.ts +9 -0
  104. package/dist/sqlite/index.js +4 -0
  105. package/dist/sqlite/inspect.d.ts +60 -0
  106. package/dist/sqlite/inspect.js +153 -0
  107. package/dist/sqlite/open.d.ts +58 -0
  108. package/dist/sqlite/open.js +43 -0
  109. package/dist/sqlite/ops.d.ts +12 -0
  110. package/dist/sqlite/ops.js +40 -0
  111. package/dist/sqlite/restore-types.d.ts +42 -0
  112. package/dist/sqlite/restore-types.js +2 -0
  113. package/dist/sqlite/sync-types.d.ts +34 -0
  114. package/dist/sqlite/sync-types.js +2 -0
  115. package/dist/sqlite/types.d.ts +37 -0
  116. package/dist/sqlite/types.js +8 -0
  117. package/dist/tools/database-catalog.d.ts +61 -0
  118. package/dist/tools/database-catalog.js +201 -0
  119. package/dist/tools/destination-port.d.ts +27 -0
  120. package/dist/tools/destination-port.js +2 -0
  121. package/dist/tools/index.d.ts +13 -0
  122. package/dist/tools/index.js +11 -0
  123. package/dist/tools/plan-store.d.ts +61 -0
  124. package/dist/tools/plan-store.js +39 -0
  125. package/dist/tools/read-tools.d.ts +53 -0
  126. package/dist/tools/read-tools.js +97 -0
  127. package/dist/tools/registration.d.ts +18 -0
  128. package/dist/tools/registration.js +10 -0
  129. package/dist/tools/restore-points.d.ts +125 -0
  130. package/dist/tools/restore-points.js +54 -0
  131. package/dist/tools/surface-port.d.ts +43 -0
  132. package/dist/tools/surface-port.js +2 -0
  133. package/dist/tools/timeline.d.ts +63 -0
  134. package/dist/tools/timeline.js +46 -0
  135. package/dist/tools/transfer-catalog.d.ts +25 -0
  136. package/dist/tools/transfer-catalog.js +59 -0
  137. package/dist/tools/transfer-tools.d.ts +82 -0
  138. package/dist/tools/transfer-tools.js +346 -0
  139. package/dist/transfer/copy-engine.d.ts +129 -0
  140. package/dist/transfer/copy-engine.js +233 -0
  141. package/dist/transfer/index.d.ts +9 -0
  142. package/dist/transfer/index.js +9 -0
  143. package/dist/transfer/internal-ddl.d.ts +23 -0
  144. package/dist/transfer/internal-ddl.js +119 -0
  145. package/dist/transfer/plan.d.ts +28 -0
  146. package/dist/transfer/plan.js +19 -0
  147. package/dist/transfer/postgres-ddl.d.ts +36 -0
  148. package/dist/transfer/postgres-ddl.js +16 -0
  149. package/dist/transfer/postgres-target.d.ts +65 -0
  150. package/dist/transfer/postgres-target.js +95 -0
  151. package/dist/transfer/sqlite-source.d.ts +78 -0
  152. package/dist/transfer/sqlite-source.js +79 -0
  153. package/dist/transfer/table-catalog.d.ts +44 -0
  154. package/dist/transfer/table-catalog.js +109 -0
  155. package/dist/transfer/types.d.ts +47 -0
  156. package/dist/transfer/types.js +2 -0
  157. package/package.json +184 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ ## Unreleased
2
+
3
+ ### BREAKING
4
+
5
+ - `DatabaseReadToolPorts.clock` now takes core `Clock.nowMs()`; restore-point timestamps use `nowIso({ clock })` at the existing sampling point.
6
+
7
+ ### Fixed
8
+
9
+ - Add a `default` condition to every JavaScript subpath, pointing to its existing ESM entry, so tsx CommonJS bootstraps can resolve the package without `ERR_PACKAGE_PATH_NOT_EXPORTED`.
10
+
11
+ - `databaseFile<DB>` accepts `StorageKernel<DB>` so hosts can pass typed kernels without casting or erasing their schema. Query and null behavior are unchanged.
12
+
13
+ - Align transfer handlers with core's second-argument `ToolExecutionOptions.emitSurface` and canonical `SurfaceEmitter`; preserve fail-closed confirmation behavior. Forward resolved catalog messages and adapt native SQLite snapshot fixtures with explicit raw-row result types.
14
+ - Move the canonical `defaultDbMessages` definition to a driver-free core module and export `DbMessages` through the existing tools entry. Extend optional host copy to the 16 remaining consumer-facing prose sites, including read-tool registration and copy preflight.
15
+ - Neutral runtime defaults now refer to the source; hosts can supply their exact prior wording. Tool IDs, permissions, refusal/cost gates, persisted naming, SQL bytes and schema vectors are unchanged.
16
+
17
+
18
+ ## 0.2.0 — 2026-10-02
19
+
20
+ ### BREAKING
21
+
22
+ - Driver-only storage entries and native runtime licenses remain explicit; extraction ledgers are archived outside distributable packages.
23
+ - Distribution includes runtime output, release documentation and required assets only. Process records and per-job neutrality checks are no longer part of the package surface.
24
+
25
+ - BREAKING: Import AgentToolDefinition, AgentToolSideEffect and AgentToolActorClassRule from core; db no longer declares or exports duplicate catalog types.
26
+ - Transfer descriptions derive from host naming and replaceable `defaultDbMessages`; the display catalog defaults to neutral `app` / `app_` names. Persisted naming is unchanged.
27
+
28
+
29
+ ## Unreleased — C2 generic additions
30
+
31
+ - Remove specification identifiers from timeline and restore-point errors and restore-point tool descriptions; limits, refusal behavior and error classes stay unchanged.
32
+ - Moved generic SQLite inspection and synchronous structural contracts into `./sqlite`.
33
+ - Moved unchanged tolerant JSON and row helpers into `./core`; kernel types remain unchanged.
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/NOTICE.md ADDED
@@ -0,0 +1,27 @@
1
+ # Vendored: @electric-sql/pglite-socket
2
+
3
+ - Upstream: `@electric-sql/pglite-socket` **0.2.11** (npm), `packages/pglite-socket/src/index.ts` in
4
+ github.com/electric-sql/pglite. Copyright Electric DB Limited. Apache License 2.0: `LICENSE.pglite-socket` beside this file.
5
+ - Vendored 2026-09-28 into `src/pglite/socket-server.ts`, used with `@electric-sql/pglite` **0.5.8** (pinned).
6
+ - Why vendored: the fixes below, and to drop the 7 extension packages the upstream CLI pulls in
7
+ (age, pgtap, pg_ivm, pgvector, pg_uuidv7, pg_hashids, pg_textsearch).
8
+
9
+ ## Changes from upstream
10
+
11
+ 1. **ReadyForQuery filter.** PGlite 0.5.8 answers an error in Parse/Bind/Execute with ErrorResponse +
12
+ ReadyForQuery and the later Sync with a second ReadyForQuery, which shifts every later answer on the
13
+ connection by one. `Z` frames are dropped from the answer to every typed message except Sync, Query,
14
+ FunctionCall, CopyDone and CopyFail. Re-check on any PGlite upgrade (the "RED evidence" test in
15
+ `src/pglite/__tests__/socket-server.test.ts` fails once PGlite fixes it).
16
+ 2. **Queue wedge.** Upstream's `processQueue` returned on a PGlite exception with `processing` still true,
17
+ so nothing was ever served again. Now the failing message's job rejects alone (its connection closes).
18
+ 3. **Idle-in-transaction timeout** (new; default 30 s): FATAL 25P03, disconnect, roll back.
19
+ 4. **`runExclusive(fn)`** (new): the owning process's only way to query while it serves.
20
+ 5. **Disconnect rollback goes through the queue** (upstream ran `ROLLBACK` directly, beside the queue).
21
+ 6. **Per-connection ordering**: a connection's data chunks are handled strictly one after another
22
+ (upstream started each chunk's handler on its own `setImmediate`).
23
+ 7. **Unix socket only** (TCP listener removed). Owner-only permissions are set by `src/pglite/owner.ts`.
24
+ 8. **Refusals speak the protocol**: over the connection cap a client gets FATAL 53300 (upstream wrote plain
25
+ text); a CancelRequest closes its connection; GSSENC requests are answered `N` like SSL.
26
+ 9. Removed: hex `inspect` dumps, `EventTarget` events, debug `console.log` (replaced by an optional `log`
27
+ callback), TCP host/port options, stats beyond connections/queued.
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # `@jini-ai/db`
2
+
3
+ Database ports, connection helpers, ownership, Kysely kernels and migrations in one package.
4
+ This package absorbs the database code from `@jini-ai/infra`. Infra 0.4.0 keeps its old two
5
+ subpaths as deprecated re-export shims for one release; import db directly in new code.
6
+
7
+ | Subpath | What it holds | Needs at load |
8
+ | --- | --- | --- |
9
+ | `./core` | `DbOpsPort`, restore-point types and naming, `PGLITE_SOCKET_FILE`, `PG_OID`, `PG_PARSERS`, `parseInt8` | Nothing |
10
+ | `./sqlite` | Structural SQLite client/opener types, `openSqliteConnection`, `DEFAULT_PRAGMAS`, `SqliteDbOpsAdapter` and restore types | Nothing |
11
+ | `./pglite` | Owner process, owner lock, private socket paths, low-memory settings, `PgliteSocketServer`, `PgliteClass` | Nothing |
12
+ | `./postgres` | Structural pool/module types and `pgTypesFor` | Nothing |
13
+ | `./kernel` | `StorageKernel`, `buildKernel`, `TurnLock`, dialect helpers, schema introspection and type generation, `StorageOps`, errors, `postgresLockKey` | `kysely` |
14
+ | `./kernel/sqlite` | `sqliteKernel`, file/memory kernels, connection lookup/close, `sqliteOps` | `kysely` |
15
+ | `./kernel/pglite` | `openPgliteKernel`, `PgKernel`, `PgliteDialect`, `pgliteOps`, served-data copy and restore types | `kysely` |
16
+ | `./kernel/postgres` | `openPostgresKernel`, `openPgliteSocketKernel`, `postgresOps` | `kysely` |
17
+ | `./migrate` | `runMigrations`, `assertValidSteps`, `hasLedger`, `sourceChecksum`, step/error types | `kysely` |
18
+ | `./transfer` | Snapshot sources, completeness, DDL and transactional psql COPY | Nothing |
19
+ | `./kernel/store-copy` | Scope-selected Postgres store copy over borrowed kernels | `kysely` |
20
+ | `./tools` | DB catalogs, portable read/restore-point/transfer handlers and injected ports | `@jini-ai/core` |
21
+
22
+ There is no `.` export. Each part loads only its own files and its explicitly shared dependencies.
23
+ The connection subpaths load no optional peer. Kernels need Kysely at load time, but all drivers
24
+ are injected when a connection is opened. Transfer and database tools have their own isolated subpaths.
25
+
26
+ Each JavaScript subpath declares `types`, `import` and `default` export conditions.
27
+ The `default` condition points to the same ESM file as `import`, so loaders such as
28
+ the tsx CommonJS bootstrap can resolve the subpaths without an active `import` condition.
29
+
30
+ ## Import and driver isolation
31
+
32
+ `kysely` is an optional peer (`^0.29.6`), imported as a value or type only under `src/kernel/`
33
+ and `src/migrate/`. `better-sqlite3`, `pg` and `@electric-sql/pglite` are also optional peers.
34
+ Production code never imports a driver at runtime. PGlite type imports are confined to
35
+ `src/pglite/` and `src/kernel/pglite/`; SQLite and Postgres use structural types.
36
+
37
+ `src/core` is closed under relative imports and imports no optional peers, including type-only
38
+ imports. `pnpm guard`'s R12 checks it. `import-isolation.test.ts` parses every production TypeScript
39
+ file and checks the remaining boundaries, including re-exports and dynamic imports, with forbidden
40
+ fixture strings as positive controls. `loads-without-driver.test.ts` copies the built package into
41
+ two isolated installs: one with Kysely and core, and one with core but no database peers. It checks actual behavior and
42
+ resolved module directories for each subpath, and proves kernel entries fail without Kysely.
43
+
44
+ The consumer opens with its own driver copy. This also avoids loading two SQLite libraries in one
45
+ process, which would share POSIX file locks.
46
+
47
+ ```ts
48
+ import Database from 'better-sqlite3';
49
+ import { PGlite } from '@electric-sql/pglite';
50
+ import pg from 'pg';
51
+ import { openSqliteConnection, SqliteDbOpsAdapter } from '@jini-ai/db/sqlite';
52
+ import { sqliteKernel } from '@jini-ai/db/kernel/sqlite';
53
+ import { openPgliteKernel } from '@jini-ai/db/kernel/pglite';
54
+ import { openPostgresKernel } from '@jini-ai/db/kernel/postgres';
55
+ import { runMigrations } from '@jini-ai/db/migrate';
56
+
57
+ const connection = openSqliteConnection({
58
+ filePath: 'app.db',
59
+ open: (filePath, options) => new Database(filePath, options),
60
+ });
61
+ const local = sqliteKernel<MyDb>(connection);
62
+ const embedded = openPgliteKernel<MyDb>({ PGlite }, { dataDir: './pgdata' });
63
+ const server = openPostgresKernel<MyDb>({ pg, connectionString: process.env.DATABASE_URL! });
64
+ await runMigrations(local, steps, { ledgerTable: 'app_migrations', appName: 'My app' });
65
+ const restore = new SqliteDbOpsAdapter({
66
+ connection,
67
+ filePath: 'app.db',
68
+ readWatermark: () => readApplicationWatermark(local),
69
+ });
70
+ ```
71
+
72
+ `MyDb`, `steps` and `readApplicationWatermark` above are supplied by the host. `openSqliteConnection`
73
+ now requires `open`; its returned type preserves the injected handle's additional methods. The
74
+ recovery hook runs before opening. A supplied `pragmas` array replaces the defaults. The defaults
75
+ are `journal_mode = WAL`, `foreign_keys = ON`, and `busy_timeout = 5000`. WAL is the observable
76
+ change from better-sqlite3's file-backed defaults.
77
+
78
+ ## Host wiring and names
79
+
80
+ A host composition root imports connections from `./sqlite`, owner lifecycle from
81
+ `./pglite`, kernel bindings from `./kernel/<backend>`, shared constants from `./core`, and migrations
82
+ from `./migrate`. It supplies its own DB interface, schemas, ordered migration steps, ledger name,
83
+ application name, owner lock filename, run directory name, driver modules and watermark reader.
84
+
85
+ - `runMigrations(kernel, steps, { ledgerTable, appName })`: the ledger name is required.
86
+ - `startPgliteOwner({ dataDir, PGlite, lockFileName, runDirName })`: both filesystem names belong to
87
+ the consumer. The socket uses a private short Unix path rather than TCP.
88
+ - `pgliteOps(kernel, { PGlite, ledgerTable, ownerLockFileName }, { pgliteOwner })` and
89
+ `postgresOps(kernel, { ledgerTable })`: compaction verifies the host's ledger.
90
+
91
+ `DbOpsPort` is the restore-point contract with an injected watermark reader. `StorageOps` is the
92
+ kernel copy/compaction contract. They remain distinct because their operations and inputs differ.
93
+
94
+ Owner-lock release handles are idempotent and bound to the acquired inode. Stale-lock reapers use
95
+ an empty `<lockFileName>.reaping-<inode>` directory to serialize removal of that inode. A process
96
+ interrupted during this short removal window can leave the guard behind; acquisition then fails
97
+ closed. After confirming that no owner or starter is running for the data directory, the operator
98
+ may remove that empty guard and retry. Ordinary owner crashes leave the pid lock, which is still
99
+ automatically taken over once its process is dead.
100
+
101
+ ## Tests
102
+
103
+ ```sh
104
+ pnpm --filter @jini-ai/db build
105
+ cd packages/db
106
+ npx tsc -p tsconfig.json --noEmit
107
+ npx vitest run
108
+ pnpm test:postgres
109
+ ```
110
+
111
+ The default suite excludes `**/*.postgres.test.ts`. `test:postgres` runs the copied
112
+ real-Postgres suites (transactions/advisory locks, idle-pool reconnection, storage ops and transfer
113
+ ownership/rollback) plus the transfer child-before-parent and multi-source cases. They
114
+ fail, never skip, when Postgres is unavailable. They require `psql` and a server accepting database
115
+ creation. `PGHOST` defaults to `/tmp`, `PGUSER` to `os.userInfo().username`, and `PGPORT` and
116
+ `PGPASSWORD` follow libpq. Fixtures under `src/testing/` are neither built nor exported.
117
+ PGlite socket integration tests require permission to bind Unix sockets.
118
+
119
+ ## Types across a linked install
120
+
121
+ The dev copy of Kysely is exactly `0.29.6`. Match that in linked consumers: Kysely classes carry
122
+ `#private` fields, so different versions are incompatible nominal types. SQLite and Postgres types
123
+ are structural. `PgliteClass` is `typeof PGlite`, so the peer and dev copies remain exactly `0.5.8`.
124
+
125
+ ## License
126
+
127
+ Apache-2.0. `src/pglite/socket-server.ts` is derived from `@electric-sql/pglite-socket` 0.2.11
128
+ (Apache-2.0): see `LICENSE.pglite-socket` and `NOTICE.md`.
129
+
130
+ ## Synchronous SQLite compatibility and inspection
131
+
132
+ `./sqlite` additionally exports structural `SqliteSyncClient`, `SqliteSyncStatement`,
133
+ `SqliteSyncTransaction`, `SqliteSyncOpener` and the old `SqliteDb` alias. These are separate from
134
+ the kernel's minimal `SqliteClient`; no driver type import or broader kernel requirements were added.
135
+ `inspectSqliteDatabase`/`verifySqliteIntegrity` receive borrowed handles and preserve the existing
136
+ file/table/integrity reports. Neither opens a connection. `./core` exports the generic `DbRow`,
137
+ `JsonObject`, `parseJsonOrUndef`, `row`, and `rows` helpers, without driver/Kysely dependencies.
138
+
139
+
140
+ ## Transfer and assistant tools (j03)
141
+
142
+ `@jini-ai/db/transfer` imports without Kysely, a driver, or core. Supply an opener to
143
+ `openSqliteSnapshotSource({ bytes }, { open })`. A consumer owns its table layouts, order,
144
+ exclusion reasons and all four required `TransferNaming` fields (`defaultSchema`, `markerTable`,
145
+ `unvalidatedTable`, `schemaPrefix`). `planTransfer({ sources })` raises
146
+ `IncompleteTransferPlanError` for every source table lacking a copied layout or a nonblank
147
+ exclusion reason. No source table names or application schema names are library defaults.
148
+
149
+ `runCopy({ sources, target, naming, schema, marker, replaceExisting })` creates and loads every
150
+ table before adding indexes and validating CHECK/FK constraints. Caller order is retained,
151
+ including child-before-parent loads. Multiple physical snapshots share one destination
152
+ transaction. Copies retain the existing marker protocol; a consumer must supply its existing
153
+ marker name to keep re-copy ownership protection. A precomputed count may be supplied on each
154
+ source; its coverage is checked before SQL and its values are checked inside the transaction.
155
+ The psql adapter keeps credentials out of argv and clears inherited PG variables.
156
+
157
+ `@jini-ai/db/kernel/store-copy` uses Kysely and borrowed kernels. Supply
158
+ `{ source, target, scope: { schemas, ledgers } }`; ledgers are compared, never copied. No second
159
+ connection/kernel is opened by this entry.
160
+
161
+ `@jini-ai/db/tools` uses the regular `@jini-ai/core` dependency. Catalog types (`AgentToolDefinition`,
162
+ `AgentToolActorClassRule`, `AgentToolSideEffect`) are imported directly from core. It exports
163
+ DB tool catalogs plus `createDatabaseReadTools(ports)` and `createDatabaseTransferTools(ports)`.
164
+ The host injects authorization, input readers, introspection, repositories, clocks, catalogs,
165
+ snapshot capture, plan/destination storage, and surface protocol/builders. The host migration
166
+ plan/execute handlers and their gateway, lock and confirmation policy remain host composition.
167
+ The restore-guidance descriptor remains declared without a handler. Hosts retain their own
168
+ independent risk checks and error adapters around the returned registrations.
169
+
170
+ `DatabaseReadToolPorts.clock` uses `Clock` from `@jini-ai/core/primitives` and exposes
171
+ `nowMs()`. Restore-point timestamps use the canonical `nowIso({ clock })` helper.
172
+ `databaseFile<DB>(kernel: StorageKernel<DB>)` accepts a typed kernel without erasing
173
+ its database schema; SQLite file lookup and null results are unchanged.
174
+
175
+ Interactive transfer handlers follow core's two-object invocation contract:
176
+ `registration.handler(context, { emitSurface })`. Supply the emitter in the second argument
177
+ for destination forms and replacement confirmation; omitted channels still fail closed.
178
+ `TransferSurfacePorts.open` receives core's canonical `SurfaceEmitter`.
179
+
180
+ Transfer planning snapshots content and chat separately; they are not a cross-database atomic
181
+ snapshot. The exact captured bytes are held in a principal/workspace-bound, single-use plan
182
+ until expiration. No migration, driver installation, live cutover, or publishing occurs here.
183
+
184
+ Transfer descriptions use `defaultDbMessages`, replaceable as a whole through
185
+ `createDatabaseTransferTools(ports, { messages })`. The factory describes the actual
186
+ `ports.naming.defaultSchema` and `schemaPrefix`; persisted naming and schema/exclusion policy
187
+ remain required host inputs. `getDatabaseTransferAgentToolCatalog({}, { naming, messages })`
188
+ builds the same four definitions for catalog inspection; its display-only default is `app` /
189
+ `app_`. `databaseTransferAgentToolCatalog` remains the neutral default display catalog.
190
+
191
+
192
+ ## Design decisions
193
+
194
+ - [Operational history is a bounded read surface](docs/decisions/DR-001-bounded-operational-timeline.md).
195
+ - [Unavailable restore mechanisms have no attestation override](docs/decisions/DR-002-restore-point-precondition.md).
196
+ - [Storage copying takes its schemas from the host](docs/decisions/DR-003-host-owned-schema-copy.md).
197
+
198
+ ### Host database prose
199
+
200
+ `defaultDbMessages` and `DbMessages` are exported from `@jini-ai/db/tools`.
201
+ The neutral defaults say “the source”; hosts may pass their existing wording explicitly.
202
+ `getDatabaseAgentToolCatalog({}, { messages })`, `createDatabaseReadTools(ports, { messages })`
203
+ and `createRestorePoint(required, { messages })` render catalog/cost/refusal copy.
204
+ `createDatabaseTransferTools(ports, { messages })` also forwards copy-preflight errors and
205
+ transfer refusal, unchecked-link and saved-destination messages. Existing transfer-only
206
+ message replacements remain supported; unspecified runtime fields retain neutral defaults.
207
+ `countSourceRows(required, { messages })` and `runCopy(required, { messages })` accept the
208
+ missing-source-table/column formatter subset. Messages never select a schema or rewrite SQL.
209
+ Persisted `TransferNaming` remains required with no fallback; its display-only catalog
210
+ examples still default to `app` / `app_`. Keep each host's existing wire names explicit.
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file Restore-point artifact naming — pure, driver-neutral string construction.
3
+ *
4
+ * Why this is in `core` rather than in the SQLite driver that currently calls it: the naming
5
+ * scheme is a wire contract, not an implementation detail. An operator reading a directory
6
+ * listing, and any future second driver that also writes file artifacts, both need the same
7
+ * scheme. Keeping it here means a second driver cannot drift into a different one.
8
+ *
9
+ * Purity is deliberate — `timestamp` is a parameter rather than a `Date.now()` call inside, so
10
+ * the function is fully deterministic and the driver owns the one impure read.
11
+ */
12
+ /**
13
+ * Reduces a caller-supplied identifier to characters that cannot alter a filesystem path.
14
+ *
15
+ * The replaced set is everything outside `[A-Za-z0-9_-]`, which removes `/` and `\` (path
16
+ * traversal / nesting) and `.` (so a `scopeId` of `..` cannot climb a directory). Replacement
17
+ * rather than rejection: a `scopeId` is an internal routing key, and failing a backup because a
18
+ * workspace slug contains a colon would be the worse outcome.
19
+ */
20
+ export declare function sanitizeForFilename(value: string): string;
21
+ /**
22
+ * Builds the artifact filename for one restore point.
23
+ *
24
+ * The watermark is embedded in the name, not just tracked in the returned metadata, so an
25
+ * operator sorting a directory can see how far each artifact lags without opening any of them —
26
+ * and so a lost ledger row does not render the files on disk anonymous.
27
+ */
28
+ export declare function restorePointFilename(parts: {
29
+ scopeId: string;
30
+ watermarkAtCapture: number;
31
+ timestamp: number;
32
+ extension?: string;
33
+ }): string;
34
+ //# sourceMappingURL=artifact-naming.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file Restore-point artifact naming — pure, driver-neutral string construction.
3
+ *
4
+ * Why this is in `core` rather than in the SQLite driver that currently calls it: the naming
5
+ * scheme is a wire contract, not an implementation detail. An operator reading a directory
6
+ * listing, and any future second driver that also writes file artifacts, both need the same
7
+ * scheme. Keeping it here means a second driver cannot drift into a different one.
8
+ *
9
+ * Purity is deliberate — `timestamp` is a parameter rather than a `Date.now()` call inside, so
10
+ * the function is fully deterministic and the driver owns the one impure read.
11
+ */
12
+ /**
13
+ * Reduces a caller-supplied identifier to characters that cannot alter a filesystem path.
14
+ *
15
+ * The replaced set is everything outside `[A-Za-z0-9_-]`, which removes `/` and `\` (path
16
+ * traversal / nesting) and `.` (so a `scopeId` of `..` cannot climb a directory). Replacement
17
+ * rather than rejection: a `scopeId` is an internal routing key, and failing a backup because a
18
+ * workspace slug contains a colon would be the worse outcome.
19
+ */
20
+ export function sanitizeForFilename(value) {
21
+ return value.replace(/[^a-zA-Z0-9_-]/g, '_');
22
+ }
23
+ /**
24
+ * Builds the artifact filename for one restore point.
25
+ *
26
+ * The watermark is embedded in the name, not just tracked in the returned metadata, so an
27
+ * operator sorting a directory can see how far each artifact lags without opening any of them —
28
+ * and so a lost ledger row does not render the files on disk anonymous.
29
+ */
30
+ export function restorePointFilename(parts) {
31
+ const extension = parts.extension ?? 'db';
32
+ return `restore-point-${sanitizeForFilename(parts.scopeId)}-wm${parts.watermarkAtCapture}-${parts.timestamp}.${extension}`;
33
+ }
34
+ //# sourceMappingURL=artifact-naming.js.map
@@ -0,0 +1,8 @@
1
+ /** Driver-neutral ports, artifact naming, and shared wire constants. No optional peers. */
2
+ export { restorePointFilename, sanitizeForFilename } from "./artifact-naming.js";
3
+ export type { DbOpsPort, RestorePoint, RestoreCapability, RestoreCostClass, RestoreKind, WatermarkReader } from "./ports.js";
4
+ export { PGLITE_SOCKET_FILE } from "./socket.js";
5
+ export { PG_OID, PG_PARSERS, parseInt8 } from "./pg-types.js";
6
+ export { parseJsonOrUndef, row, rows } from "./row-values.js";
7
+ export type { DbRow, JsonObject } from "./row-values.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ /** Driver-neutral ports, artifact naming, and shared wire constants. No optional peers. */
2
+ // Connections may depend on core; core must never import a driver or ORM, so hosts using
3
+ // another backend can load these contracts without resolving a native dependency.
4
+ // There is deliberately no package-root barrel combining core and connection entries:
5
+ // Node executes every reachable static import rather than tree-shaking unused exports.
6
+ export { restorePointFilename, sanitizeForFilename } from "./artifact-naming.js";
7
+ export { PGLITE_SOCKET_FILE } from "./socket.js";
8
+ export { PG_OID, PG_PARSERS, parseInt8 } from "./pg-types.js";
9
+ export { parseJsonOrUndef, row, rows } from "./row-values.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,43 @@
1
+ import type { TransferNaming } from "../transfer/types.js";
2
+ /** Copy-only display defaults; actual persisted schema/marker names remain required host inputs. */
3
+ export interface DbTransferMessages {
4
+ plan(required: {
5
+ naming: Pick<TransferNaming, "defaultSchema" | "schemaPrefix">;
6
+ }): string;
7
+ readonly setDestination: string;
8
+ readonly status: string;
9
+ readonly run: string;
10
+ readonly planIdDescription: string;
11
+ }
12
+ /** Host-replaceable runtime prose only. Persisted names, codes and SQL bytes are separate required inputs. */
13
+ export interface DbMessages extends DbTransferMessages {
14
+ readonly restorePointUnavailable: string;
15
+ readonly restorePointCostAck: string;
16
+ readonly databaseHealth: string;
17
+ readonly databaseSchemaState: string;
18
+ readonly databasePendingMigrations: string;
19
+ readonly databaseRestorePoints: string;
20
+ readonly databasePlanMigrate: string;
21
+ readonly databaseExecuteMigrate: string;
22
+ readonly databaseCreateRestorePoint: string;
23
+ readonly databaseRestoreGuidance: string;
24
+ privateAreasTaken(required: {
25
+ where: string;
26
+ }): string;
27
+ readonly noDestination: string;
28
+ readonly uncheckedLinks: string;
29
+ destinationSaved(required: {
30
+ database: string;
31
+ host: string;
32
+ }): string;
33
+ missingSourceTable(required: {
34
+ table: string;
35
+ }): string;
36
+ missingSourceColumn(required: {
37
+ table: string;
38
+ column: string;
39
+ }): string;
40
+ }
41
+ /** Neutral model-facing copy, replaceable as a whole by the host. No UI navigation assumptions. */
42
+ export declare const defaultDbMessages: DbMessages;
43
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1,26 @@
1
+ /** Neutral model-facing copy, replaceable as a whole by the host. No UI navigation assumptions. */
2
+ export const defaultDbMessages = {
3
+ planIdDescription: "The planId database_transfer_plan returned. Single-use; valid for 10 minutes.",
4
+ plan: ({ naming }) => `Plans a COPY of the source's data into a Postgres database (for example 'move/transfer/copy my data to Postgres'). The source keeps running on its built-in storage; this only makes a copy, into the source's own private area (Postgres schema) on that database: '${naming.defaultSchema}' for the first source copied there, '${naming.schemaPrefix}<source name>' for any other, and always the same one for this source afterwards. Several sources can share one database; each copy replaces only its own area. Read-only: it snapshots the source database, connects to the saved destination, and counts what would be copied. Logins, saved keys and secret settings are never copied; photos and files stay where they are. No input: the destination is the one the human saved with database_transfer_set_destination. Returns {planned: true, planId, expiresAt, destination: {host, port, database, user}, area (the schema), snapshotAt, tableCount, rowCount, replaces (the earlier copy's time, or null), leftOut, notes, nextStep}, or {planned: false, code, message} (codes: NO_DESTINATION, UNREACHABLE, SERVER_TOO_OLD, NO_CREATE_PERMISSION, TARGET_NOT_OURS, DATABASE_SNAPSHOT_FAILED, SCHEMA_MISMATCH, UNAVAILABLE). Tell the human in plain words what will be copied, then call database_transfer_run with the planId.`,
5
+ setDestination: "Asks the human where a copy of the source's data should go: shows a private form where they paste a Postgres database address. HUMAN-GATED: this one call shows the form and WAITS. You never see the address, and must never ask for it in chat; if the human pastes one into the chat anyway, do not repeat it, call this tool, and suggest they change that database password. Checks that the database can be reached before saving it (one destination per source; saving replaces the earlier one). Returns {saved: true, destination: {host, port, database, user}, replaces (the time of a copy this source already made there, or null)}, {saved: false, code, message} (INVALID_CONNECTION_STRING, UNREACHABLE, SERVER_TOO_OLD, NO_CREATE_PERMISSION, TARGET_NOT_OURS), or {saved: false, reason} (cancelled, expired, abandoned). Then call database_transfer_plan.",
6
+ status: "Reports where the source's data copy goes and how the last copy went ('is my data copied?', 'when was the last copy?'). Read-only. Returns {destination: {host, port, database, user} or null, lastRun: {copied: true, snapshotAt, tableCount, rowCount} or {copied: false, snapshotAt, code, message} or null (since the server started), copyOnDestination: {site, snapshotAt} or null, or {unreachable: message}}.",
7
+ run: "Copies the data planned by database_transfer_plan. A first copy runs immediately without a confirmation card. Replacing an earlier copy permanently deletes its destination schema: this one call shows a Copy/Cancel card and WAITS; there is no second call. On Copy it writes the planned snapshot as one transaction into the source's private area (the source's earlier copy is replaced; other sources' copies and anything else in the database are untouched), checks every table's row count, and returns {copied: true, destination, area, snapshotAt, tableCount, rowCount, tables: [{name, rows}]}. Any failure throws the copy away and keeps the earlier one: {copied: false, cancelled: false, code, message} (TARGET_NOT_OURS, COPY_FAILED, COUNT_MISMATCH, PLAN_NOT_FOUND, PLAN_EXPIRED). Cancel returns {copied: false, cancelled: true}.",
8
+ restorePointUnavailable: "no restore-point mechanism is available for the source; migration is refused with no attestation override",
9
+ restorePointCostAck: "Explicit cost acknowledgment. Required (must be true) only when the source's restore-point cost class is 'expensive'; ignored when 'cheap'. The call is refused with no override at all when cost class is 'unavailable' (no attestation override).",
10
+ databaseHealth: "Reports a summary of the source's database health (connectivity, disk headroom, pending-migration/interrupted-migration state).",
11
+ databaseSchemaState: "Reports the source's schema drift status (in-sync/ahead/diverged/behind) between its persisted schema snapshot and the runtime's current schema.",
12
+ databasePendingMigrations: "Lists migrations pending against the source that have not yet been applied.",
13
+ databaseRestorePoints: "Lists every restore point recorded for the source, newest first, with its trigger, cost class, and capture time.",
14
+ databasePlanMigrate: "Previews what forward-migrating the source's schema would do — cost class and a plan hash — without applying anything.",
15
+ databaseExecuteMigrate: "Moves the source's database forward to the current schema. Shows the user a confirm dialog first and only runs if they " +
16
+ "confirm. A restore point is taken first. Call database_plan_migrate_forward first to see the cost class.",
17
+ databaseCreateRestorePoint: "Mints a new restore point for the source independent of any migration, subject to the source's cost-acknowledgment rule.",
18
+ databaseRestoreGuidance: "Returns a deep-link routing envelope pointing at a host-provided restore destination for restoring the source to an earlier snapshot. Never itself a restore lever.",
19
+ privateAreasTaken: ({ where }) => `every private area the source could use in ${where} already holds other data. Nothing will be overwritten.`,
20
+ noDestination: "no destination database is saved for the source yet",
21
+ uncheckedLinks: "Some copied rows point at records that no longer exist in the source's data. Those links are kept but marked unchecked on the destination; everything was still copied.",
22
+ destinationSaved: ({ database, host }) => `Copies of the source's data will go to ${database} on ${host}.`,
23
+ missingSourceTable: ({ table }) => `the source's database has no '${table}' table`,
24
+ missingSourceColumn: ({ table, column }) => `the source's database has no '${table}.${column}' column`,
25
+ };
26
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @file How every Postgres transport turns column text into JS values where the defaults differ
3
+ * from what the repos (and SQLite) expect. One table, used by the PGlite and node-postgres drivers,
4
+ * so a row reads the same on both.
5
+ *
6
+ * - `json`/`jsonb` stay JSON TEXT: the repos store and parse JSON themselves (SQLite has no JSON
7
+ * type), so a `string` column type holds on every dialect. The text is re-serialised compactly
8
+ * (`{"a":1}`, as `JSON.stringify` writes it) instead of Postgres's own spelling (`{"a": 1}`), so a
9
+ * value written compactly reads back byte-identical.
10
+ * Key order is jsonb's (it does not keep insertion order); compare parsed values, not text.
11
+ * - `int8` (`bigint`) is a `number` when it fits in a double exactly, else a `bigint` — PGlite's own
12
+ * rule, which node-postgres (default: string) is aligned to.
13
+ */
14
+ export declare const PG_OID: {
15
+ readonly int8: 20;
16
+ readonly json: 114;
17
+ readonly jsonb: 3802;
18
+ };
19
+ export declare function parseInt8(text: string): number | bigint;
20
+ /** Parser overrides by type oid. */
21
+ export declare const PG_PARSERS: Readonly<Record<number, (text: string) => unknown>>;
22
+ //# sourceMappingURL=pg-types.d.ts.map