rightsize 0.1.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 (216) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +255 -0
  4. package/dist/backend-docker/backend.d.ts +53 -0
  5. package/dist/backend-docker/backend.d.ts.map +1 -0
  6. package/dist/backend-docker/backend.js +336 -0
  7. package/dist/backend-docker/backend.js.map +1 -0
  8. package/dist/backend-docker/client.d.ts +82 -0
  9. package/dist/backend-docker/client.d.ts.map +1 -0
  10. package/dist/backend-docker/client.js +190 -0
  11. package/dist/backend-docker/client.js.map +1 -0
  12. package/dist/backend-docker/frames.d.ts +44 -0
  13. package/dist/backend-docker/frames.d.ts.map +1 -0
  14. package/dist/backend-docker/frames.js +105 -0
  15. package/dist/backend-docker/frames.js.map +1 -0
  16. package/dist/backend-docker/index.d.ts +5 -0
  17. package/dist/backend-docker/index.d.ts.map +1 -0
  18. package/dist/backend-docker/index.js +20 -0
  19. package/dist/backend-docker/index.js.map +1 -0
  20. package/dist/backend-docker/json.d.ts +13 -0
  21. package/dist/backend-docker/json.d.ts.map +1 -0
  22. package/dist/backend-docker/json.js +47 -0
  23. package/dist/backend-docker/json.js.map +1 -0
  24. package/dist/backend-docker/labels.d.ts +11 -0
  25. package/dist/backend-docker/labels.d.ts.map +1 -0
  26. package/dist/backend-docker/labels.js +13 -0
  27. package/dist/backend-docker/labels.js.map +1 -0
  28. package/dist/backend-docker/port-conflict.d.ts +9 -0
  29. package/dist/backend-docker/port-conflict.d.ts.map +1 -0
  30. package/dist/backend-docker/port-conflict.js +12 -0
  31. package/dist/backend-docker/port-conflict.js.map +1 -0
  32. package/dist/backend-docker/provider.d.ts +22 -0
  33. package/dist/backend-docker/provider.d.ts.map +1 -0
  34. package/dist/backend-docker/provider.js +36 -0
  35. package/dist/backend-docker/provider.js.map +1 -0
  36. package/dist/backend-msb/backend.d.ts +169 -0
  37. package/dist/backend-msb/backend.d.ts.map +1 -0
  38. package/dist/backend-msb/backend.js +664 -0
  39. package/dist/backend-msb/backend.js.map +1 -0
  40. package/dist/backend-msb/commands.d.ts +28 -0
  41. package/dist/backend-msb/commands.d.ts.map +1 -0
  42. package/dist/backend-msb/commands.js +67 -0
  43. package/dist/backend-msb/commands.js.map +1 -0
  44. package/dist/backend-msb/exec-tunnel.d.ts +33 -0
  45. package/dist/backend-msb/exec-tunnel.d.ts.map +1 -0
  46. package/dist/backend-msb/exec-tunnel.js +163 -0
  47. package/dist/backend-msb/exec-tunnel.js.map +1 -0
  48. package/dist/backend-msb/follow-replay.d.ts +14 -0
  49. package/dist/backend-msb/follow-replay.d.ts.map +1 -0
  50. package/dist/backend-msb/follow-replay.js +20 -0
  51. package/dist/backend-msb/follow-replay.js.map +1 -0
  52. package/dist/backend-msb/image-cache.d.ts +25 -0
  53. package/dist/backend-msb/image-cache.d.ts.map +1 -0
  54. package/dist/backend-msb/image-cache.js +27 -0
  55. package/dist/backend-msb/image-cache.js.map +1 -0
  56. package/dist/backend-msb/index.d.ts +6 -0
  57. package/dist/backend-msb/index.d.ts.map +1 -0
  58. package/dist/backend-msb/index.js +21 -0
  59. package/dist/backend-msb/index.js.map +1 -0
  60. package/dist/backend-msb/invoke.d.ts +24 -0
  61. package/dist/backend-msb/invoke.d.ts.map +1 -0
  62. package/dist/backend-msb/invoke.js +73 -0
  63. package/dist/backend-msb/invoke.js.map +1 -0
  64. package/dist/backend-msb/ls-json.d.ts +23 -0
  65. package/dist/backend-msb/ls-json.d.ts.map +1 -0
  66. package/dist/backend-msb/ls-json.js +113 -0
  67. package/dist/backend-msb/ls-json.js.map +1 -0
  68. package/dist/backend-msb/network-links.d.ts +7 -0
  69. package/dist/backend-msb/network-links.d.ts.map +1 -0
  70. package/dist/backend-msb/network-links.js +31 -0
  71. package/dist/backend-msb/network-links.js.map +1 -0
  72. package/dist/backend-msb/platform.d.ts +29 -0
  73. package/dist/backend-msb/platform.d.ts.map +1 -0
  74. package/dist/backend-msb/platform.js +128 -0
  75. package/dist/backend-msb/platform.js.map +1 -0
  76. package/dist/backend-msb/port-conflict.d.ts +10 -0
  77. package/dist/backend-msb/port-conflict.d.ts.map +1 -0
  78. package/dist/backend-msb/port-conflict.js +16 -0
  79. package/dist/backend-msb/port-conflict.js.map +1 -0
  80. package/dist/backend-msb/provider.d.ts +10 -0
  81. package/dist/backend-msb/provider.d.ts.map +1 -0
  82. package/dist/backend-msb/provider.js +40 -0
  83. package/dist/backend-msb/provider.js.map +1 -0
  84. package/dist/backend-msb/provisioner.d.ts +19 -0
  85. package/dist/backend-msb/provisioner.d.ts.map +1 -0
  86. package/dist/backend-msb/provisioner.js +332 -0
  87. package/dist/backend-msb/provisioner.js.map +1 -0
  88. package/dist/backend-msb/reaper.d.ts +10 -0
  89. package/dist/backend-msb/reaper.d.ts.map +1 -0
  90. package/dist/backend-msb/reaper.js +73 -0
  91. package/dist/backend-msb/reaper.js.map +1 -0
  92. package/dist/core/backend.d.ts +98 -0
  93. package/dist/core/backend.d.ts.map +1 -0
  94. package/dist/core/backend.js +2 -0
  95. package/dist/core/backend.js.map +1 -0
  96. package/dist/core/backends.d.ts +37 -0
  97. package/dist/core/backends.d.ts.map +1 -0
  98. package/dist/core/backends.js +127 -0
  99. package/dist/core/backends.js.map +1 -0
  100. package/dist/core/cleanup.d.ts +37 -0
  101. package/dist/core/cleanup.d.ts.map +1 -0
  102. package/dist/core/cleanup.js +86 -0
  103. package/dist/core/cleanup.js.map +1 -0
  104. package/dist/core/errors.d.ts +51 -0
  105. package/dist/core/errors.d.ts.map +1 -0
  106. package/dist/core/errors.js +66 -0
  107. package/dist/core/errors.js.map +1 -0
  108. package/dist/core/free-ports.d.ts +23 -0
  109. package/dist/core/free-ports.d.ts.map +1 -0
  110. package/dist/core/free-ports.js +63 -0
  111. package/dist/core/free-ports.js.map +1 -0
  112. package/dist/core/generic-container.d.ts +145 -0
  113. package/dist/core/generic-container.d.ts.map +1 -0
  114. package/dist/core/generic-container.js +385 -0
  115. package/dist/core/generic-container.js.map +1 -0
  116. package/dist/core/model.d.ts +60 -0
  117. package/dist/core/model.d.ts.map +1 -0
  118. package/dist/core/model.js +2 -0
  119. package/dist/core/model.js.map +1 -0
  120. package/dist/core/mountable-file.d.ts +25 -0
  121. package/dist/core/mountable-file.d.ts.map +1 -0
  122. package/dist/core/mountable-file.js +64 -0
  123. package/dist/core/mountable-file.js.map +1 -0
  124. package/dist/core/network.d.ts +58 -0
  125. package/dist/core/network.d.ts.map +1 -0
  126. package/dist/core/network.js +84 -0
  127. package/dist/core/network.js.map +1 -0
  128. package/dist/core/run-id.d.ts +18 -0
  129. package/dist/core/run-id.d.ts.map +1 -0
  130. package/dist/core/run-id.js +18 -0
  131. package/dist/core/run-id.js.map +1 -0
  132. package/dist/core/wait.d.ts +59 -0
  133. package/dist/core/wait.d.ts.map +1 -0
  134. package/dist/core/wait.js +239 -0
  135. package/dist/core/wait.js.map +1 -0
  136. package/dist/index.d.ts +26 -0
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +22 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/modules/arango.d.ts +14 -0
  141. package/dist/modules/arango.d.ts.map +1 -0
  142. package/dist/modules/arango.js +37 -0
  143. package/dist/modules/arango.js.map +1 -0
  144. package/dist/modules/clickhouse.d.ts +37 -0
  145. package/dist/modules/clickhouse.d.ts.map +1 -0
  146. package/dist/modules/clickhouse.js +69 -0
  147. package/dist/modules/clickhouse.js.map +1 -0
  148. package/dist/modules/flink.d.ts +65 -0
  149. package/dist/modules/flink.d.ts.map +1 -0
  150. package/dist/modules/flink.js +125 -0
  151. package/dist/modules/flink.js.map +1 -0
  152. package/dist/modules/floci.d.ts +46 -0
  153. package/dist/modules/floci.d.ts.map +1 -0
  154. package/dist/modules/floci.js +62 -0
  155. package/dist/modules/floci.js.map +1 -0
  156. package/dist/modules/index.d.ts +31 -0
  157. package/dist/modules/index.d.ts.map +1 -0
  158. package/dist/modules/index.js +31 -0
  159. package/dist/modules/index.js.map +1 -0
  160. package/dist/modules/kafka.d.ts +11 -0
  161. package/dist/modules/kafka.d.ts.map +1 -0
  162. package/dist/modules/kafka.js +41 -0
  163. package/dist/modules/kafka.js.map +1 -0
  164. package/dist/modules/keycloak.d.ts +40 -0
  165. package/dist/modules/keycloak.d.ts.map +1 -0
  166. package/dist/modules/keycloak.js +67 -0
  167. package/dist/modules/keycloak.js.map +1 -0
  168. package/dist/modules/mariadb.d.ts +56 -0
  169. package/dist/modules/mariadb.d.ts.map +1 -0
  170. package/dist/modules/mariadb.js +89 -0
  171. package/dist/modules/mariadb.js.map +1 -0
  172. package/dist/modules/memcached.d.ts +24 -0
  173. package/dist/modules/memcached.d.ts.map +1 -0
  174. package/dist/modules/memcached.js +105 -0
  175. package/dist/modules/memcached.js.map +1 -0
  176. package/dist/modules/mongodb.d.ts +19 -0
  177. package/dist/modules/mongodb.d.ts.map +1 -0
  178. package/dist/modules/mongodb.js +69 -0
  179. package/dist/modules/mongodb.js.map +1 -0
  180. package/dist/modules/mysql.d.ts +61 -0
  181. package/dist/modules/mysql.d.ts.map +1 -0
  182. package/dist/modules/mysql.js +101 -0
  183. package/dist/modules/mysql.js.map +1 -0
  184. package/dist/modules/neo4j.d.ts +60 -0
  185. package/dist/modules/neo4j.d.ts.map +1 -0
  186. package/dist/modules/neo4j.js +83 -0
  187. package/dist/modules/neo4j.js.map +1 -0
  188. package/dist/modules/pinot.d.ts +30 -0
  189. package/dist/modules/pinot.d.ts.map +1 -0
  190. package/dist/modules/pinot.js +49 -0
  191. package/dist/modules/pinot.js.map +1 -0
  192. package/dist/modules/postgres.d.ts +29 -0
  193. package/dist/modules/postgres.d.ts.map +1 -0
  194. package/dist/modules/postgres.js +73 -0
  195. package/dist/modules/postgres.js.map +1 -0
  196. package/dist/modules/rabbitmq.d.ts +46 -0
  197. package/dist/modules/rabbitmq.d.ts.map +1 -0
  198. package/dist/modules/rabbitmq.js +68 -0
  199. package/dist/modules/rabbitmq.js.map +1 -0
  200. package/dist/modules/redis.d.ts +15 -0
  201. package/dist/modules/redis.d.ts.map +1 -0
  202. package/dist/modules/redis.js +24 -0
  203. package/dist/modules/redis.js.map +1 -0
  204. package/dist/modules/redpanda.d.ts +27 -0
  205. package/dist/modules/redpanda.d.ts.map +1 -0
  206. package/dist/modules/redpanda.js +58 -0
  207. package/dist/modules/redpanda.js.map +1 -0
  208. package/dist/modules/spring-cloud-config.d.ts +18 -0
  209. package/dist/modules/spring-cloud-config.d.ts.map +1 -0
  210. package/dist/modules/spring-cloud-config.js +28 -0
  211. package/dist/modules/spring-cloud-config.js.map +1 -0
  212. package/dist/modules/wiremock.d.ts +21 -0
  213. package/dist/modules/wiremock.d.ts.map +1 -0
  214. package/dist/modules/wiremock.js +32 -0
  215. package/dist/modules/wiremock.js.map +1 -0
  216. package/package.json +104 -0
package/LICENSE ADDED
@@ -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,4 @@
1
+ Copyright 2026 the rightsize authors
2
+
3
+ Licensed under the Apache License, Version 2.0. See LICENSE for the full
4
+ license text.
package/README.md ADDED
@@ -0,0 +1,255 @@
1
+ # rightsize
2
+
3
+ [![CI](https://github.com/ngriaznov/rightsize-node/actions/workflows/ci.yml/badge.svg)](https://github.com/ngriaznov/rightsize-node/actions/workflows/ci.yml)
4
+
5
+ **Testcontainers-style integration testing on microVMs. No Docker required.**
6
+
7
+ rightsize runs your integration-test containers as hardware-isolated
8
+ [microsandbox](https://github.com/superradcompany/microsandbox) microVMs —
9
+ one microVM per container — behind a strict-mode ESM TypeScript API whose
10
+ flagship lifecycle is TC39 explicit resource management. The runtime
11
+ self-provisions on first use (no install step), and a hand-rolled Docker
12
+ backend covers the platforms microVMs can't reach.
13
+
14
+ ```ts runnable
15
+ import "rightsize/backend-msb";
16
+ import "rightsize/backend-docker";
17
+ import { RedisContainer } from "rightsize/modules";
18
+
19
+ async function main(): Promise<void> {
20
+ await using redis = await RedisContainer.start(); // boots a real microVM
21
+ console.log("redis is up at", redis.uri); // redis://127.0.0.1:<mapped port>
22
+ // ... your test ...
23
+ }
24
+
25
+ await main();
26
+ ```
27
+
28
+ `await using` is the whole story: `redis` is disposed automatically at the
29
+ end of its scope — stopped, removed, its port freed — ordered and awaited,
30
+ the same way a `try`/`finally` would, with none of the boilerplate.
31
+
32
+ ## Why microVMs
33
+
34
+ | | Docker + Testcontainers | rightsize |
35
+ |---|---|---|
36
+ | Isolation | shared kernel (containers) | **hardware-level (microVM per container)** |
37
+ | Runtime install | Docker Desktop / daemon required | **none — self-provisions on first use** |
38
+ | Licensing | Docker Desktop licensing in orgs | Apache-2.0 all the way down |
39
+ | Lifecycle | manual `try`/`finally` | **`await using` explicit resource management** |
40
+ | Docker client | a general-purpose SDK over a shared HTTP stack | **hand-rolled, unix-socket-only — can't be misrouted onto TCP** |
41
+
42
+ The lifecycle and Docker-client rows above aren't incidental implementation
43
+ choices — see [Lifecycle](https://github.com/ngriaznov/rightsize-node/blob/main/docs/guide/lifecycle.md)
44
+ and [Backends](https://github.com/ngriaznov/rightsize-node/blob/main/docs/guide/backends.md)
45
+ for why each one is the way it is. (If you've used Testcontainers, the
46
+ builder shape — `withEnv`, `withExposedPorts`, `waitingFor`, `getMappedPort`
47
+ — will feel familiar; the lifecycle is where this library departs from it
48
+ most.)
49
+
50
+ ## Quickstart
51
+
52
+ ```sh
53
+ npm install --save-dev rightsize
54
+ ```
55
+
56
+ Importing a backend subpath registers it as a side effect — import whichever
57
+ one(s) you want considered, and `rightsize` picks the best supported one
58
+ automatically (or `RIGHTSIZE_BACKEND` forces a specific one):
59
+
60
+ ```ts
61
+ import "rightsize/backend-msb";
62
+ import "rightsize/backend-docker";
63
+ ```
64
+
65
+ Drive any image directly with `GenericContainer`, or use one of eighteen
66
+ preconfigured modules:
67
+
68
+ ```ts
69
+ import { GenericContainer, Wait } from "rightsize";
70
+
71
+ await using arango = await new GenericContainer("arangodb:3.11")
72
+ .withEnv("ARANGO_NO_AUTH", "1")
73
+ .withExposedPorts(8529)
74
+ .waitingFor(Wait.forHttp("/_api/version").forPort(8529))
75
+ .start();
76
+
77
+ const port = arango.getMappedPort(8529); // published on 127.0.0.1
78
+ ```
79
+
80
+ Full guide: [Quickstart](https://github.com/ngriaznov/rightsize-node/blob/main/docs/guide/quickstart.md).
81
+
82
+ ## Modules
83
+
84
+ Preconfigured containers with sensible waits and connection helpers. Each is
85
+ a `GenericContainer` subclass, so the fluent builders (`withEnv`,
86
+ `withExposedPorts`, `waitingFor`, …) are available on every one.
87
+
88
+ | Module | Helpers |
89
+ |---|---|
90
+ | `RedisContainer` | `uri` |
91
+ | `MemcachedContainer` | `address` |
92
+ | `ArangoContainer` | `endpoint`; `withRootPassword(...)` to enable auth (default: no-auth) |
93
+ | `MongoDBContainer` | `connectionString`, `replicaSetUrl` (alias) — single-node replica set, auto-initiated |
94
+ | `PostgresContainer` | `connectionString`, `username`, `password`, `databaseName`; `withUsername`/`withPassword`/`withDatabase(...)` |
95
+ | `MySQLContainer` | `connectionString`, `username`, `password`, `databaseName`; `withUsername`/`withPassword`/`withDatabase(...)` |
96
+ | `MariaDBContainer` | `connectionString`, `username`, `password`, `databaseName`; `withUsername`/`withPassword`/`withDatabase(...)` |
97
+ | `RedpandaContainer` | `bootstrapServers`, `schemaRegistryUrl` |
98
+ | `KafkaContainer` | `bootstrapServers` — KRaft single node |
99
+ | `RabbitMQContainer` | `amqpUrl`, `managementUrl`, `username`, `password`; `withUsername`/`withPassword(...)` — management plugin enabled |
100
+ | `PinotContainer` | `controllerUrl`, `brokerUrl` — single-container QuickStart cluster |
101
+ | `SpringCloudConfigContainer` | `uri` |
102
+ | `WireMockContainer` | `baseUrl`, `adminUrl` — stub via the `/__admin` API |
103
+ | `KeycloakContainer` | `authServerUrl`, `adminUsername`, `adminPassword`; `withAdminUsername`/`withAdminPassword(...)` |
104
+ | `ClickHouseContainer` | `httpUrl`, `username`, `password`, `databaseName`; `withUsername`/`withPassword`/`withDatabase(...)` |
105
+ | `Neo4jContainer` | `httpUrl`, `boltUrl`, `username`, `password`; `withPassword(...)` — HTTP Cypher endpoint (username fixed at `neo4j`) |
106
+ | `FlociContainer` | `FlociContainer.aws()`/`.azure()`/`.gcp()` factories, `endpointUrl` — [floci.io](https://floci.io) cloud emulators (unsigned REST, no SDK needed) |
107
+ | `FlinkContainer` | `restUrl`; `withTaskManager()` for a full session cluster — **Docker only**¹ |
108
+
109
+ Some modules raise a memory floor for their image (`withMemoryLimit`):
110
+ heavyweight JVM images — Spring Cloud Config, Keycloak, Neo4j, Flink
111
+ (1024 MB) — and Pinot's multi-JVM QuickStart cluster (4096 MB) — need more
112
+ than the microVM default. That's baked into the module; you don't set it.
113
+ Every module's page under [`docs/modules/`](https://github.com/ngriaznov/rightsize-node/tree/main/docs/modules)
114
+ documents its exact image tag, wait strategy, and the measured reasoning
115
+ behind these choices.
116
+
117
+ ¹ `withTaskManager()` throws `UnsupportedByBackendError` on microsandbox (the
118
+ Flink image carries no `nc`/busybox for network-link emulation — see
119
+ [Networking](https://github.com/ngriaznov/rightsize-node/blob/main/docs/guide/networking.md));
120
+ a bare JobManager still runs on microsandbox. Run TaskManager topologies
121
+ under `RIGHTSIZE_BACKEND=docker`.
122
+
123
+ ## Backends
124
+
125
+ rightsize picks a backend automatically; override with
126
+ `RIGHTSIZE_BACKEND=microsandbox|docker`.
127
+
128
+ | Platform | Backend used |
129
+ |---|---|
130
+ | macOS (Apple Silicon) | microsandbox (microVMs) |
131
+ | Linux x86_64 / arm64 with `/dev/kvm` | microsandbox (microVMs) |
132
+ | Windows x86_64 / arm64 (WHP enabled) | microsandbox (microVMs)¹ |
133
+ | Intel Mac | Docker (auto-fallback) |
134
+ | Windows without WHP | Docker (auto-fallback) |
135
+ | Linux without KVM | Docker (auto-fallback) |
136
+
137
+ ¹ Verified in CI on `windows-2025` hosted runners, where Windows Hypervisor
138
+ Platform is enabled by default. If WHP isn't enabled on your machine, run
139
+ `msb doctor --fix` in an elevated terminal (may require a reboot) or use
140
+ `RIGHTSIZE_BACKEND=docker`.
141
+
142
+ Both backends satisfy one behavioral contract, verified by a shared test
143
+ suite — the code you write runs unchanged on either. A few edges are
144
+ backend-specific rather than behavioral divergences:
145
+
146
+ - **Network-alias tunnels on microsandbox have real limits** versus Docker's
147
+ native bridge networking — see
148
+ [Networking](https://github.com/ngriaznov/rightsize-node/blob/main/docs/guide/networking.md).
149
+ - **Read-only file mounts aren't enforced in-guest on microsandbox 0.6.3.**
150
+ `withCopyFileToContainer`'s read-only flag is honored by Docker; on
151
+ microsandbox the guest currently gets a writable mount regardless. Don't
152
+ rely on guest-side write protection under `RIGHTSIZE_BACKEND=microsandbox`.
153
+ - **`followOutput` delivers the same ordered, no-duplicate log stream on
154
+ both backends**, but on microsandbox the final tail can arrive shortly
155
+ after the sandbox reports stopped, rather than exactly at stream EOF
156
+ (`msb logs -f` doesn't close on sandbox stop in 0.6.3, so the backend
157
+ replays the not-yet-delivered tail once stop is confirmed).
158
+
159
+ ## How it works
160
+
161
+ - **Self-provisioning runtime.** A pinned `msb` release (binary + libkrunfw)
162
+ is downloaded once, SHA-256-verified against the release manifest, and
163
+ installed atomically under `~/.cache/rightsize/` (`%LOCALAPPDATA%\rightsize`
164
+ on Windows) — the binary lands last, so a crashed install is detected and
165
+ repaired, never half-trusted. A cross-process file lock keeps parallel
166
+ processes from racing.
167
+ - **Attached-mode supervision.** Each container is a held child process
168
+ supervising its microVM; the image's ENTRYPOINT runs exactly as it would
169
+ under Docker.
170
+ - **Pre-allocated ports.** Host ports are chosen before boot, so brokers
171
+ like Redpanda/Kafka get their advertised listeners baked in — no restart
172
+ dance. A backend binds the ports it's given; it never allocates its own.
173
+ - **Two-tier cleanup, no async `Drop`.** The happy path is `await using` or
174
+ an explicit, awaited `stop()`. The fallback — a process that exits before
175
+ either runs — falls back to a synchronous, blocking teardown registered
176
+ per container (Node's `"exit"` handler can't `await`), with a run-id-scoped
177
+ orphan reaper at backend startup as the backstop for a hard `SIGKILL` that
178
+ bypasses even that.
179
+ - **One interface, two backends.** `SandboxBackend` is a small interface;
180
+ the shared contract suite is the referee, with the Docker backend doubling
181
+ as the correctness oracle for the microVM backend.
182
+
183
+ Full detail: [How It Works](https://github.com/ngriaznov/rightsize-node/blob/main/docs/guide/how-it-works.md).
184
+
185
+ ## Configuration
186
+
187
+ | Env var | Effect |
188
+ |---|---|
189
+ | `RIGHTSIZE_BACKEND` | Force `microsandbox` or `docker` |
190
+ | `MSB_PATH` | Use a pre-installed `msb` binary; skip downloads |
191
+ | `RIGHTSIZE_CACHE_DIR` | Relocate the runtime cache (default `~/.cache/rightsize`; `%LOCALAPPDATA%\rightsize` on Windows) |
192
+ | `RIGHTSIZE_MSB_SKIP_DOWNLOAD` | `true` = fail instead of downloading (air-gapped CI) |
193
+
194
+ ## Runtime support
195
+
196
+ | Runtime | Minimum |
197
+ |---|---|
198
+ | Node.js | `>=22.11` (the 22.x "Jod" LTS line) |
199
+ | Bun | `>=1.1` |
200
+
201
+ Authored in TypeScript using `await using`; `tsc` emits ES2022 plus the
202
+ downlevelled explicit-resource-management helpers, so the shipped
203
+ `dist/**.js` runs unmodified on both runtimes with no flags.
204
+
205
+ ## Examples
206
+
207
+ Three self-contained, runnable examples live under
208
+ [`examples/`](https://github.com/ngriaznov/rightsize-node/tree/main/examples).
209
+ Each builds the library once, then runs directly against the compiled
210
+ `dist/` — no separate example-specific setup beyond `npm install`.
211
+
212
+ | Example | What it shows | Run |
213
+ |---|---|---|
214
+ | [`redis-quickstart.ts`](https://github.com/ngriaznov/rightsize-node/blob/main/examples/redis-quickstart.ts) | The `await using` lifecycle — the library's signature | `npm run example:redis` |
215
+ | [`network-alias.ts`](https://github.com/ngriaznov/rightsize-node/blob/main/examples/network-alias.ts) | Two containers on one `Network`, reachable by alias | `npm run example:network` |
216
+ | [`redis.test.ts`](https://github.com/ngriaznov/rightsize-node/blob/main/examples/redis.test.ts) | A `node:test` suite using a module container, gated behind `RIGHTSIZE_IT=1` the same way this repo's own integration tests are | `npm run example:test` |
217
+
218
+ Run all three back to back with `npm run examples:run`. Every example picks
219
+ a backend automatically; force one explicitly the same way you would for
220
+ any `rightsize` program:
221
+
222
+ ```bash
223
+ RIGHTSIZE_BACKEND=docker npm run example:redis
224
+ RIGHTSIZE_BACKEND=microsandbox npm run example:redis
225
+ ```
226
+
227
+ `redis.test.ts` skips its container-backed assertions unless `RIGHTSIZE_IT=1`
228
+ is set, so `npm run example:test` is safe to run on a machine with no
229
+ container runtime — pass the flag to actually exercise it:
230
+ `RIGHTSIZE_IT=1 npm run example:test`.
231
+
232
+ ## Development
233
+
234
+ ```bash
235
+ npm install # installs dependencies
236
+ npm run build # compiles src/ to dist/
237
+ npm run typecheck # tsc --noEmit
238
+ npm test # unit suite, both runtimes
239
+ npm run coverage:core # core coverage, 80% line floor
240
+ RIGHTSIZE_BACKEND=microsandbox npm run test:node:it # needs Apple Silicon or Linux+KVM
241
+ RIGHTSIZE_BACKEND=docker npm run test:node:it # needs a reachable Docker daemon
242
+ npm run docs:build # static docs site
243
+ npm run docs:verify # typechecks every doc/README sample
244
+ ```
245
+
246
+ CI runs the matrix on Linux (KVM), macOS (Apple Silicon), and a Docker-only
247
+ job, both Node and Bun.
248
+
249
+ See [`CONTRIBUTING.md`](https://github.com/ngriaznov/rightsize-node/blob/main/.github/CONTRIBUTING.md)
250
+ for what each `tsconfig*.json` is for, the full npm script reference, and
251
+ integration-test conventions.
252
+
253
+ ## License
254
+
255
+ [Apache-2.0](LICENSE)
@@ -0,0 +1,53 @@
1
+ import type { FollowHandle, NetworkLink, SandboxBackend, SandboxHandle } from "../core/backend.js";
2
+ import type { ContainerSpec, ExecResult } from "../core/model.js";
3
+ import { DockerClient } from "./client.js";
4
+ /**
5
+ * Drives the Docker daemon over `DockerClient`. This is also the
6
+ * correctness oracle other backends are checked against, since Docker
7
+ * enforces semantics (read-only mounts, native networks) microsandbox only
8
+ * emulates.
9
+ *
10
+ * Unlike the msb backend, a `SandboxHandle` here carries no companion
11
+ * mutable state keyed by id: every operation is a stateless HTTP call
12
+ * against the daemon-assigned container id already on the handle, so
13
+ * there's nothing to look up in a side table.
14
+ */
15
+ export declare class DockerBackend implements SandboxBackend {
16
+ private readonly client;
17
+ /** `"docker"` — matched against `RIGHTSIZE_BACKEND`. */
18
+ readonly name = "docker";
19
+ readonly supportsNativeNetworks = true;
20
+ private readonly networkIds;
21
+ constructor(client: DockerClient);
22
+ /** Exposed for the transport regression test: the socket path this backend's client actually dials. */
23
+ socketPathForTest(): string;
24
+ private pullIfMissing;
25
+ private connectNetwork;
26
+ private ensureNetworkGetId;
27
+ create(spec: ContainerSpec): Promise<SandboxHandle>;
28
+ start(handle: SandboxHandle): Promise<void>;
29
+ stop(handle: SandboxHandle): Promise<void>;
30
+ remove(handle: SandboxHandle): Promise<void>;
31
+ exec(handle: SandboxHandle, cmd: ReadonlyArray<string>): Promise<ExecResult>;
32
+ logs(handle: SandboxHandle): Promise<string>;
33
+ /** Docker's stream ends cleanly on its own once the workload stops — unlike msb's `logs -f`, so no watchdog is needed here. */
34
+ followLogs(handle: SandboxHandle, consumer: (line: string) => void): Promise<FollowHandle>;
35
+ /** No-op: docker relies entirely on native networks (`ensureNetwork`/`create`'s connect step) — there is nothing to emulate here, unlike msb's exec-tunnel links. */
36
+ installNetworkLinks(_handle: SandboxHandle, _links: ReadonlyArray<NetworkLink>): Promise<void>;
37
+ ensureNetwork(networkId: string): Promise<void>;
38
+ removeNetwork(networkId: string): Promise<void>;
39
+ /** Removes every container carrying this run's label — the reaper safety net's normal-exit counterpart. */
40
+ close(): Promise<void>;
41
+ /**
42
+ * Synchronous, blocking teardown for the process-exit path. Node has no
43
+ * synchronous HTTP client, so this shells out to `curl --unix-socket` via
44
+ * `child_process.spawnSync` — curl ships on macOS and virtually every
45
+ * Linux CI image, and `spawnSync` genuinely blocks the exiting process the
46
+ * way the `"exit"` handler requires. If curl is unavailable, this is a
47
+ * silent no-op: the label-scoped orphan reaper each backend runs at
48
+ * startup (`close()`'s own reaping plus the next run's sweep) is the real
49
+ * safety net for that case, not this best-effort fast path.
50
+ */
51
+ cleanupSync(id: string): void;
52
+ }
53
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/backend-docker/backend.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA4F3C;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,YAAW,cAAc;IAOtC,OAAO,CAAC,QAAQ,CAAC,MAAM;IANnC,wDAAwD;IACxD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,sBAAsB,QAAQ;IAEvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;gBAE3B,MAAM,EAAE,YAAY;IAEjD,uGAAuG;IACvG,iBAAiB,IAAI,MAAM;YAIb,aAAa;YAcb,cAAc;YAWd,kBAAkB;IAkC1B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IA0BnD,KAAK,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAa3C,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA0C5E,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BlD,+HAA+H;IACzH,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAkDhG,qKAAqK;IAC/J,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAE9F,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD,2GAA2G;IACrG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAa5B;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;CAiB9B"}