@lakutata/containerd 0.0.0-stage → 3.0.0-beta.1

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 (301) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +409 -2
  3. package/THIRD_PARTY_NOTICES.md +310 -0
  4. package/dist/cjs/client/BuildKit.d.ts +176 -0
  5. package/dist/cjs/client/BuildKit.js +536 -0
  6. package/dist/cjs/client/BuildKitMessages.d.ts +35 -0
  7. package/dist/cjs/client/BuildKitMessages.js +123 -0
  8. package/dist/cjs/client/ContainerStore.d.ts +558 -0
  9. package/dist/cjs/client/ContainerStore.js +1384 -0
  10. package/dist/cjs/client/ContainerdClient.d.ts +244 -0
  11. package/dist/cjs/client/ContainerdClient.js +455 -0
  12. package/dist/cjs/client/DockerIgnore.d.ts +44 -0
  13. package/dist/cjs/client/DockerIgnore.js +186 -0
  14. package/dist/cjs/client/Fifo.d.ts +31 -0
  15. package/dist/cjs/client/Fifo.js +66 -0
  16. package/dist/cjs/client/ImageStore.d.ts +258 -0
  17. package/dist/cjs/client/ImageStore.js +636 -0
  18. package/dist/cjs/client/Messages.d.ts +103 -0
  19. package/dist/cjs/client/Messages.js +397 -0
  20. package/dist/cjs/client/Networks.d.ts +221 -0
  21. package/dist/cjs/client/Networks.js +630 -0
  22. package/dist/cjs/client/Platforms.d.ts +53 -0
  23. package/dist/cjs/client/Platforms.js +169 -0
  24. package/dist/cjs/client/Reference.d.ts +33 -0
  25. package/dist/cjs/client/Reference.js +70 -0
  26. package/dist/cjs/client/Registry.d.ts +145 -0
  27. package/dist/cjs/client/Registry.js +272 -0
  28. package/dist/cjs/client/Rootfs.d.ts +83 -0
  29. package/dist/cjs/client/Rootfs.js +245 -0
  30. package/dist/cjs/client/Seccomp.d.ts +36 -0
  31. package/dist/cjs/client/Seccomp.js +156 -0
  32. package/dist/cjs/client/Spec.d.ts +151 -0
  33. package/dist/cjs/client/Spec.js +227 -0
  34. package/dist/cjs/client/Volumes.d.ts +42 -0
  35. package/dist/cjs/client/Volumes.js +80 -0
  36. package/dist/cjs/containerd/Containerd.d.ts +442 -0
  37. package/dist/cjs/containerd/Containerd.js +929 -0
  38. package/dist/cjs/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
  39. package/dist/cjs/containerd/exceptions/ContainerdConnectionException.js +16 -0
  40. package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
  41. package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.js +15 -0
  42. package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
  43. package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.js +16 -0
  44. package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
  45. package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.js +17 -0
  46. package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
  47. package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.js +16 -0
  48. package/dist/cjs/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
  49. package/dist/cjs/containerd/exceptions/ContainerdImageExportException.js +16 -0
  50. package/dist/cjs/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
  51. package/dist/cjs/containerd/exceptions/ContainerdImageImportException.js +16 -0
  52. package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
  53. package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.js +16 -0
  54. package/dist/cjs/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
  55. package/dist/cjs/containerd/exceptions/ContainerdImagePullException.js +16 -0
  56. package/dist/cjs/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
  57. package/dist/cjs/containerd/exceptions/ContainerdImagePushException.js +15 -0
  58. package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
  59. package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.js +16 -0
  60. package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
  61. package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.js +16 -0
  62. package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
  63. package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.js +15 -0
  64. package/dist/cjs/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
  65. package/dist/cjs/containerd/exceptions/ContainerdPlatformException.js +16 -0
  66. package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
  67. package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.js +15 -0
  68. package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
  69. package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.js +15 -0
  70. package/dist/cjs/containerd/lib/ContainerdContainer.d.ts +292 -0
  71. package/dist/cjs/containerd/lib/ContainerdContainer.js +536 -0
  72. package/dist/cjs/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
  73. package/dist/cjs/containerd/lib/ContainerdContainerTTY.js +178 -0
  74. package/dist/cjs/containerd/lib/ContainerdErrors.d.ts +6 -0
  75. package/dist/cjs/containerd/lib/ContainerdErrors.js +37 -0
  76. package/dist/cjs/containerd/lib/ContainerdImage.d.ts +149 -0
  77. package/dist/cjs/containerd/lib/ContainerdImage.js +222 -0
  78. package/dist/cjs/containerd/options/ContainerdPruneOptions.d.ts +44 -0
  79. package/dist/cjs/containerd/options/ContainerdPruneOptions.js +51 -0
  80. package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
  81. package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.js +45 -0
  82. package/dist/cjs/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
  83. package/dist/cjs/containerd/options/container/ContainerCommitOptions.js +66 -0
  84. package/dist/cjs/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
  85. package/dist/cjs/containerd/options/container/ContainerCreateOptions.js +239 -0
  86. package/dist/cjs/containerd/options/container/ContainerExecOptions.d.ts +53 -0
  87. package/dist/cjs/containerd/options/container/ContainerExecOptions.js +63 -0
  88. package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
  89. package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.js +45 -0
  90. package/dist/cjs/containerd/options/container/ContainerKillOptions.d.ts +30 -0
  91. package/dist/cjs/containerd/options/container/ContainerKillOptions.js +41 -0
  92. package/dist/cjs/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
  93. package/dist/cjs/containerd/options/container/ContainerLogsOptions.js +44 -0
  94. package/dist/cjs/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
  95. package/dist/cjs/containerd/options/container/ContainerRemoveOptions.js +34 -0
  96. package/dist/cjs/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
  97. package/dist/cjs/containerd/options/container/ContainerResourceOptions.js +67 -0
  98. package/dist/cjs/containerd/options/container/ContainerStopOptions.d.ts +30 -0
  99. package/dist/cjs/containerd/options/container/ContainerStopOptions.js +41 -0
  100. package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  101. package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
  102. package/dist/cjs/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
  103. package/dist/cjs/containerd/options/container/ContainerTTYOptions.js +63 -0
  104. package/dist/cjs/containerd/options/image/ImageBuildOptions.d.ts +88 -0
  105. package/dist/cjs/containerd/options/image/ImageBuildOptions.js +95 -0
  106. package/dist/cjs/containerd/options/image/ImageExportOptions.d.ts +25 -0
  107. package/dist/cjs/containerd/options/image/ImageExportOptions.js +39 -0
  108. package/dist/cjs/containerd/options/image/ImageImportOptions.d.ts +38 -0
  109. package/dist/cjs/containerd/options/image/ImageImportOptions.js +47 -0
  110. package/dist/cjs/containerd/options/image/ImagePullOptions.d.ts +53 -0
  111. package/dist/cjs/containerd/options/image/ImagePullOptions.js +66 -0
  112. package/dist/cjs/containerd/options/image/ImagePushOptions.d.ts +44 -0
  113. package/dist/cjs/containerd/options/image/ImagePushOptions.js +58 -0
  114. package/dist/cjs/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
  115. package/dist/cjs/containerd/options/network/NetworkCreateOptions.js +83 -0
  116. package/dist/cjs/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
  117. package/dist/cjs/containerd/options/volume/VolumeCreateOptions.js +40 -0
  118. package/dist/cjs/containerd/types/ContainerdBind.d.ts +28 -0
  119. package/dist/cjs/containerd/types/ContainerdBind.js +2 -0
  120. package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
  121. package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.js +2 -0
  122. package/dist/cjs/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
  123. package/dist/cjs/containerd/types/ContainerdContainerNetwork.js +2 -0
  124. package/dist/cjs/containerd/types/ContainerdContainerPort.d.ts +22 -0
  125. package/dist/cjs/containerd/types/ContainerdContainerPort.js +2 -0
  126. package/dist/cjs/containerd/types/ContainerdContainerState.d.ts +42 -0
  127. package/dist/cjs/containerd/types/ContainerdContainerState.js +2 -0
  128. package/dist/cjs/containerd/types/ContainerdContainerStats.d.ts +107 -0
  129. package/dist/cjs/containerd/types/ContainerdContainerStats.js +2 -0
  130. package/dist/cjs/containerd/types/ContainerdDevice.d.ts +25 -0
  131. package/dist/cjs/containerd/types/ContainerdDevice.js +2 -0
  132. package/dist/cjs/containerd/types/ContainerdExecResult.d.ts +18 -0
  133. package/dist/cjs/containerd/types/ContainerdExecResult.js +2 -0
  134. package/dist/cjs/containerd/types/ContainerdImageConfig.d.ts +46 -0
  135. package/dist/cjs/containerd/types/ContainerdImageConfig.js +2 -0
  136. package/dist/cjs/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
  137. package/dist/cjs/containerd/types/ContainerdNetworkInfo.js +2 -0
  138. package/dist/cjs/containerd/types/ContainerdProgressCallback.d.ts +29 -0
  139. package/dist/cjs/containerd/types/ContainerdProgressCallback.js +2 -0
  140. package/dist/cjs/containerd/types/ContainerdPruneResult.d.ts +21 -0
  141. package/dist/cjs/containerd/types/ContainerdPruneResult.js +2 -0
  142. package/dist/cjs/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
  143. package/dist/cjs/containerd/types/ContainerdRestartPolicy.js +2 -0
  144. package/dist/cjs/containerd/types/ContainerdTmpfs.d.ts +20 -0
  145. package/dist/cjs/containerd/types/ContainerdTmpfs.js +2 -0
  146. package/dist/cjs/containerd/types/ContainerdVolume.d.ts +19 -0
  147. package/dist/cjs/containerd/types/ContainerdVolume.js +2 -0
  148. package/dist/cjs/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
  149. package/dist/cjs/containerd/types/ContainerdVolumeInfo.js +2 -0
  150. package/dist/cjs/exports/Containerd.d.ts +69 -0
  151. package/dist/cjs/exports/Containerd.js +87 -0
  152. package/dist/cjs/package.json +1 -0
  153. package/dist/esm/client/BuildKit.js +488 -0
  154. package/dist/esm/client/BuildKitMessages.js +120 -0
  155. package/dist/esm/client/ContainerStore.js +1339 -0
  156. package/dist/esm/client/ContainerdClient.js +416 -0
  157. package/dist/esm/client/DockerIgnore.js +179 -0
  158. package/dist/esm/client/Fifo.js +59 -0
  159. package/dist/esm/client/ImageStore.js +628 -0
  160. package/dist/esm/client/Messages.js +393 -0
  161. package/dist/esm/client/Networks.js +621 -0
  162. package/dist/esm/client/Platforms.js +156 -0
  163. package/dist/esm/client/Reference.js +66 -0
  164. package/dist/esm/client/Registry.js +263 -0
  165. package/dist/esm/client/Rootfs.js +234 -0
  166. package/dist/esm/client/Seccomp.js +152 -0
  167. package/dist/esm/client/Spec.js +220 -0
  168. package/dist/esm/client/Volumes.js +73 -0
  169. package/dist/esm/containerd/Containerd.js +923 -0
  170. package/dist/esm/containerd/exceptions/ContainerdConnectionException.js +12 -0
  171. package/dist/esm/containerd/exceptions/ContainerdContainerNameConflictException.js +11 -0
  172. package/dist/esm/containerd/exceptions/ContainerdContainerNotFoundException.js +12 -0
  173. package/dist/esm/containerd/exceptions/ContainerdContainerStateException.js +13 -0
  174. package/dist/esm/containerd/exceptions/ContainerdImageBuildException.js +12 -0
  175. package/dist/esm/containerd/exceptions/ContainerdImageExportException.js +12 -0
  176. package/dist/esm/containerd/exceptions/ContainerdImageImportException.js +12 -0
  177. package/dist/esm/containerd/exceptions/ContainerdImageNotFoundException.js +12 -0
  178. package/dist/esm/containerd/exceptions/ContainerdImagePullException.js +12 -0
  179. package/dist/esm/containerd/exceptions/ContainerdImagePushException.js +11 -0
  180. package/dist/esm/containerd/exceptions/ContainerdNetworkConflictException.js +12 -0
  181. package/dist/esm/containerd/exceptions/ContainerdNetworkNotFoundException.js +12 -0
  182. package/dist/esm/containerd/exceptions/ContainerdPathNotFoundException.js +11 -0
  183. package/dist/esm/containerd/exceptions/ContainerdPlatformException.js +12 -0
  184. package/dist/esm/containerd/exceptions/ContainerdVolumeInUseException.js +11 -0
  185. package/dist/esm/containerd/exceptions/ContainerdVolumeNotFoundException.js +11 -0
  186. package/dist/esm/containerd/lib/ContainerdContainer.js +533 -0
  187. package/dist/esm/containerd/lib/ContainerdContainerTTY.js +175 -0
  188. package/dist/esm/containerd/lib/ContainerdErrors.js +34 -0
  189. package/dist/esm/containerd/lib/ContainerdImage.js +219 -0
  190. package/dist/esm/containerd/options/ContainerdPruneOptions.js +47 -0
  191. package/dist/esm/containerd/options/ContainerdRegistryAuthOptions.js +41 -0
  192. package/dist/esm/containerd/options/container/ContainerCommitOptions.js +62 -0
  193. package/dist/esm/containerd/options/container/ContainerCreateOptions.js +235 -0
  194. package/dist/esm/containerd/options/container/ContainerExecOptions.js +59 -0
  195. package/dist/esm/containerd/options/container/ContainerExportDirectoryOptions.js +41 -0
  196. package/dist/esm/containerd/options/container/ContainerKillOptions.js +37 -0
  197. package/dist/esm/containerd/options/container/ContainerLogsOptions.js +40 -0
  198. package/dist/esm/containerd/options/container/ContainerRemoveOptions.js +30 -0
  199. package/dist/esm/containerd/options/container/ContainerResourceOptions.js +63 -0
  200. package/dist/esm/containerd/options/container/ContainerStopOptions.js +37 -0
  201. package/dist/esm/containerd/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
  202. package/dist/esm/containerd/options/container/ContainerTTYOptions.js +59 -0
  203. package/dist/esm/containerd/options/image/ImageBuildOptions.js +91 -0
  204. package/dist/esm/containerd/options/image/ImageExportOptions.js +35 -0
  205. package/dist/esm/containerd/options/image/ImageImportOptions.js +43 -0
  206. package/dist/esm/containerd/options/image/ImagePullOptions.js +62 -0
  207. package/dist/esm/containerd/options/image/ImagePushOptions.js +54 -0
  208. package/dist/esm/containerd/options/network/NetworkCreateOptions.js +79 -0
  209. package/dist/esm/containerd/options/volume/VolumeCreateOptions.js +36 -0
  210. package/dist/esm/containerd/types/ContainerdBind.js +1 -0
  211. package/dist/esm/containerd/types/ContainerdBuildOutputCallback.js +1 -0
  212. package/dist/esm/containerd/types/ContainerdContainerNetwork.js +1 -0
  213. package/dist/esm/containerd/types/ContainerdContainerPort.js +1 -0
  214. package/dist/esm/containerd/types/ContainerdContainerState.js +1 -0
  215. package/dist/esm/containerd/types/ContainerdContainerStats.js +1 -0
  216. package/dist/esm/containerd/types/ContainerdDevice.js +1 -0
  217. package/dist/esm/containerd/types/ContainerdExecResult.js +1 -0
  218. package/dist/esm/containerd/types/ContainerdImageConfig.js +1 -0
  219. package/dist/esm/containerd/types/ContainerdNetworkInfo.js +1 -0
  220. package/dist/esm/containerd/types/ContainerdProgressCallback.js +1 -0
  221. package/dist/esm/containerd/types/ContainerdPruneResult.js +1 -0
  222. package/dist/esm/containerd/types/ContainerdRestartPolicy.js +1 -0
  223. package/dist/esm/containerd/types/ContainerdTmpfs.js +1 -0
  224. package/dist/esm/containerd/types/ContainerdVolume.js +1 -0
  225. package/dist/esm/containerd/types/ContainerdVolumeInfo.js +1 -0
  226. package/dist/esm/exports/Containerd.js +68 -0
  227. package/dist/types/client/BuildKit.d.ts +176 -0
  228. package/dist/types/client/BuildKitMessages.d.ts +35 -0
  229. package/dist/types/client/ContainerStore.d.ts +558 -0
  230. package/dist/types/client/ContainerdClient.d.ts +244 -0
  231. package/dist/types/client/DockerIgnore.d.ts +44 -0
  232. package/dist/types/client/Fifo.d.ts +31 -0
  233. package/dist/types/client/ImageStore.d.ts +258 -0
  234. package/dist/types/client/Messages.d.ts +103 -0
  235. package/dist/types/client/Networks.d.ts +221 -0
  236. package/dist/types/client/Platforms.d.ts +53 -0
  237. package/dist/types/client/Reference.d.ts +33 -0
  238. package/dist/types/client/Registry.d.ts +145 -0
  239. package/dist/types/client/Rootfs.d.ts +83 -0
  240. package/dist/types/client/Seccomp.d.ts +36 -0
  241. package/dist/types/client/Spec.d.ts +151 -0
  242. package/dist/types/client/Volumes.d.ts +42 -0
  243. package/dist/types/containerd/Containerd.d.ts +442 -0
  244. package/dist/types/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
  245. package/dist/types/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
  246. package/dist/types/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
  247. package/dist/types/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
  248. package/dist/types/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
  249. package/dist/types/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
  250. package/dist/types/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
  251. package/dist/types/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
  252. package/dist/types/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
  253. package/dist/types/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
  254. package/dist/types/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
  255. package/dist/types/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
  256. package/dist/types/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
  257. package/dist/types/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
  258. package/dist/types/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
  259. package/dist/types/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
  260. package/dist/types/containerd/lib/ContainerdContainer.d.ts +292 -0
  261. package/dist/types/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
  262. package/dist/types/containerd/lib/ContainerdErrors.d.ts +6 -0
  263. package/dist/types/containerd/lib/ContainerdImage.d.ts +149 -0
  264. package/dist/types/containerd/options/ContainerdPruneOptions.d.ts +44 -0
  265. package/dist/types/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
  266. package/dist/types/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
  267. package/dist/types/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
  268. package/dist/types/containerd/options/container/ContainerExecOptions.d.ts +53 -0
  269. package/dist/types/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
  270. package/dist/types/containerd/options/container/ContainerKillOptions.d.ts +30 -0
  271. package/dist/types/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
  272. package/dist/types/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
  273. package/dist/types/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
  274. package/dist/types/containerd/options/container/ContainerStopOptions.d.ts +30 -0
  275. package/dist/types/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  276. package/dist/types/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
  277. package/dist/types/containerd/options/image/ImageBuildOptions.d.ts +88 -0
  278. package/dist/types/containerd/options/image/ImageExportOptions.d.ts +25 -0
  279. package/dist/types/containerd/options/image/ImageImportOptions.d.ts +38 -0
  280. package/dist/types/containerd/options/image/ImagePullOptions.d.ts +53 -0
  281. package/dist/types/containerd/options/image/ImagePushOptions.d.ts +44 -0
  282. package/dist/types/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
  283. package/dist/types/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
  284. package/dist/types/containerd/types/ContainerdBind.d.ts +28 -0
  285. package/dist/types/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
  286. package/dist/types/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
  287. package/dist/types/containerd/types/ContainerdContainerPort.d.ts +22 -0
  288. package/dist/types/containerd/types/ContainerdContainerState.d.ts +42 -0
  289. package/dist/types/containerd/types/ContainerdContainerStats.d.ts +107 -0
  290. package/dist/types/containerd/types/ContainerdDevice.d.ts +25 -0
  291. package/dist/types/containerd/types/ContainerdExecResult.d.ts +18 -0
  292. package/dist/types/containerd/types/ContainerdImageConfig.d.ts +46 -0
  293. package/dist/types/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
  294. package/dist/types/containerd/types/ContainerdProgressCallback.d.ts +29 -0
  295. package/dist/types/containerd/types/ContainerdPruneResult.d.ts +21 -0
  296. package/dist/types/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
  297. package/dist/types/containerd/types/ContainerdTmpfs.d.ts +20 -0
  298. package/dist/types/containerd/types/ContainerdVolume.d.ts +19 -0
  299. package/dist/types/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
  300. package/dist/types/exports/Containerd.d.ts +69 -0
  301. package/package.json +51 -4
@@ -0,0 +1,536 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ContainerdContainer = void 0;
13
+ const core_1 = require("@lakutata/core");
14
+ const di_1 = require("@lakutata/core/decorator/di");
15
+ const dto_1 = require("@lakutata/core/decorator/dto");
16
+ const Time_1 = require("@lakutata/utils/Time");
17
+ const node_fs_1 = require("node:fs");
18
+ const ContainerStore_js_1 = require("../../client/ContainerStore.js");
19
+ const ContainerStopOptions_js_1 = require("../options/container/ContainerStopOptions.js");
20
+ const ContainerKillOptions_js_1 = require("../options/container/ContainerKillOptions.js");
21
+ const ContainerRemoveOptions_js_1 = require("../options/container/ContainerRemoveOptions.js");
22
+ const ContainerExecOptions_js_1 = require("../options/container/ContainerExecOptions.js");
23
+ const ContainerLogsOptions_js_1 = require("../options/container/ContainerLogsOptions.js");
24
+ const ContainerdContainerNotFoundException_js_1 = require("../exceptions/ContainerdContainerNotFoundException.js");
25
+ const ContainerdErrors_js_1 = require("./ContainerdErrors.js");
26
+ const ContainerdContainerTTY_js_1 = require("./ContainerdContainerTTY.js");
27
+ const ContainerTTYOptions_js_1 = require("../options/container/ContainerTTYOptions.js");
28
+ const ContainerResourceOptions_js_1 = require("../options/container/ContainerResourceOptions.js");
29
+ const ContainerCommitOptions_js_1 = require("../options/container/ContainerCommitOptions.js");
30
+ const ContainerExportDirectoryOptions_js_1 = require("../options/container/ContainerExportDirectoryOptions.js");
31
+ const ContainerdContainerStateException_js_1 = require("../exceptions/ContainerdContainerStateException.js");
32
+ const Reference_js_1 = require("../../client/Reference.js");
33
+ /**
34
+ * A container of the {@link Containerd} component's namespace, with the operations of a Docker container: start, stop,
35
+ * kill, pause, exec, terminals, logs, stats, live updates or updates by recreation, commit and file export. Get it from
36
+ * {@link Containerd.getContainer}, {@link Containerd.listContainers} or {@link Containerd.createContainer}; do not create
37
+ * it yourself. Each call returns a new object (transient).
38
+ *
39
+ * Its properties are a snapshot taken when it was obtained: the operations changing the container (`start()`, `stop()`,
40
+ * `kill()`, `pause()`, `wait()`, `update()`…) take a new one when they end, and {@link ContainerdContainer.syncContainerInfo}
41
+ * takes one on demand. The state the container is in decides what works: `exec()`, `createTTY()` and `stats()` need it
42
+ * running, and `remove()` refuses a running container unless forced.
43
+ * @example
44
+ * ```typescript
45
+ * import {Containerd, type ContainerdContainer, type ContainerdContainerStats} from 'lakutata/com/containerd'
46
+ *
47
+ * declare const containerd: Containerd
48
+ *
49
+ * const container: ContainerdContainer = await containerd.getContainer('worker')
50
+ * if (!container.state.running) await container.start()
51
+ * //The last 100 lines, without following the output
52
+ * for await (const chunk of await container.logs({tail: 100, follow: false})) process.stdout.write(chunk)
53
+ * const stats: ContainerdContainerStats = await container.stats()
54
+ * console.log(stats.cpu.percent, stats.memory.usage)
55
+ * //Live, without a restart
56
+ * await container.update({memoryLimit: 256 * 1024 * 1024})
57
+ * //Its stop signal, then SIGKILL after 5 seconds
58
+ * await container.stop({timeout: 5})
59
+ * await container.remove()
60
+ * ```
61
+ */
62
+ let ContainerdContainer = class ContainerdContainer extends core_1.Provider {
63
+ #abortController = new AbortController();
64
+ /**
65
+ * Read the container's information.
66
+ * @throws {ContainerdContainerNotFoundException} No container matches the identifier or name.
67
+ * @protected
68
+ */
69
+ async init() {
70
+ await this.syncContainerInfo();
71
+ }
72
+ /**
73
+ * End the log streams followed and the waits of the object.
74
+ * @protected
75
+ */
76
+ async destroy() {
77
+ this.#abortController.abort();
78
+ }
79
+ /**
80
+ * Read the container's information and state again from containerd into the object's properties.
81
+ * @throws {ContainerdContainerNotFoundException} The container no longer exists.
82
+ */
83
+ async syncContainerInfo() {
84
+ const record = await this.getStore().find(this.id);
85
+ if (!record)
86
+ throw new ContainerdContainerNotFoundException_js_1.ContainerdContainerNotFoundException(`The container ${this.id} does not exist`);
87
+ this.record = record;
88
+ this.id = record.id;
89
+ this.labels = record.labels ?? {};
90
+ this.name = ContainerStore_js_1.ContainerStore.Name(record);
91
+ this.hostname = this.labels[ContainerStore_js_1.ContainerLabels.HOSTNAME] ?? '';
92
+ this.imageName = record.image ?? '';
93
+ this.platform = this.labels[ContainerStore_js_1.ContainerLabels.PLATFORM] ?? '';
94
+ this.restartPolicy = (this.labels[ContainerStore_js_1.ContainerLabels.RESTART_POLICY] ?? 'no');
95
+ this.createdAt = new Time_1.Time(record.createdAt ? Number(record.createdAt.seconds ?? 0) * 1000 : Date.now());
96
+ try {
97
+ this.networkNames = JSON.parse(this.labels[ContainerStore_js_1.ContainerLabels.NETWORKS] ?? '[]');
98
+ }
99
+ catch {
100
+ this.networkNames = [];
101
+ }
102
+ this.networks = (await this.getStore().interfaces(record)).map((item) => ({
103
+ networkName: item.network,
104
+ interface: item.interface,
105
+ mac: item.mac ?? '',
106
+ ip: item.ip ?? '',
107
+ gateway: item.gateway ?? '',
108
+ ipPrefixLen: item.prefixLength ?? 0,
109
+ ipv6: item.ipv6 ?? '',
110
+ ipv6Gateway: item.ipv6Gateway ?? ''
111
+ }));
112
+ const ports = new Map();
113
+ try {
114
+ for (const port of JSON.parse(this.labels[ContainerStore_js_1.ContainerLabels.PORTS] ?? '[]')) {
115
+ const key = `${port.HostIP}/${port.ContainerPort}/${port.Protocol}`;
116
+ const known = ports.get(key) ?? { host: port.HostIP, port: port.ContainerPort, type: port.Protocol, hostPorts: [] };
117
+ known.hostPorts.push(port.HostPort);
118
+ ports.set(key, known);
119
+ }
120
+ }
121
+ catch {
122
+ //Not the labels of nerdctl
123
+ }
124
+ this.ports = [...ports.values()];
125
+ this.volumes = ContainerStore_js_1.ContainerStore.Volumes(record);
126
+ const state = await this.getStore().state(record);
127
+ this.state = {
128
+ status: state.status,
129
+ running: state.running,
130
+ paused: state.paused,
131
+ restarting: state.status === 'restarting',
132
+ pid: state.pid,
133
+ exitCode: state.exitCode,
134
+ startedAt: state.startedAt ? new Time_1.Time(state.startedAt) : null,
135
+ finishedAt: state.finishedAt ? new Time_1.Time(state.finishedAt) : null
136
+ };
137
+ }
138
+ /**
139
+ * Run an operation on the container, then read its information again (also when the operation fails).
140
+ * @param operation The operation, given the container's record.
141
+ * @returns What the operation returns.
142
+ * @throws {ContainerdContainerStateException} The container is not in the state the operation needs.
143
+ * @protected
144
+ */
145
+ async operate(operation) {
146
+ try {
147
+ return await operation(this.record);
148
+ }
149
+ catch (error) {
150
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
151
+ }
152
+ finally {
153
+ await this.syncContainerInfo().catch(() => undefined);
154
+ }
155
+ }
156
+ /**
157
+ * Get the container's image.
158
+ * @returns The image.
159
+ * @throws {ContainerdImageNotFoundException} The image was removed since the container was created.
160
+ */
161
+ async image() {
162
+ return await this.getContainerd().getImage(this.imageName);
163
+ }
164
+ /**
165
+ * Start the container: a new task of its root file system, its output appended to its log file (rotated first beyond
166
+ * the component's `logMaxSize`), its CNI networks set up. Its restart policy applies from now on. A running container
167
+ * is left as it is.
168
+ * @throws {ContainerdContainerStateException} The container is paused: unpause it.
169
+ * @throws {Error} The task cannot be created or started (the command is not found, seccomp refuses it…).
170
+ */
171
+ async start() {
172
+ await this.operate((record) => this.getStore().start(record));
173
+ }
174
+ /**
175
+ * Stop the container: send its stop signal (the one of `options`, else its `stopSignal`, else `SIGTERM`), wait for it
176
+ * to exit, then kill all its processes with `SIGKILL` when the timeout ends. Its exit code is kept, and the restart
177
+ * monitor no longer restarts it. A paused container is resumed first; a stopped one is left as it is.
178
+ * @param options The time to wait in seconds (10 by default) and the signal.
179
+ */
180
+ async stop(options) {
181
+ if (!options)
182
+ return await this.stop({});
183
+ await this.operate((record) => this.getStore().stop(record, { timeout: options.timeout, signal: options.signal }));
184
+ }
185
+ /**
186
+ * Restart the container: stop it as {@link ContainerdContainer.stop} does, then start it.
187
+ * @param options How it is stopped: the time to wait in seconds (10 by default) and the signal.
188
+ * @throws {Error} The task cannot be started again.
189
+ */
190
+ async restart(options) {
191
+ if (!options)
192
+ return await this.restart({});
193
+ await this.stop(options);
194
+ await this.start();
195
+ }
196
+ /**
197
+ * Send a signal to the container's main process, or to all its processes. `SIGKILL` also tells the restart monitor
198
+ * not to restart it; other signals do not.
199
+ * @param options The signal (`SIGKILL` by default; a name or a number) and `all`.
200
+ * @throws {ContainerdContainerStateException} The container is not running.
201
+ */
202
+ async kill(options) {
203
+ if (!options)
204
+ return await this.kill({});
205
+ await this.operate((record) => this.getStore().kill(record, options.signal, options.all));
206
+ }
207
+ /**
208
+ * Pause all the processes of the running container (cgroup freezer).
209
+ * @throws {ContainerdContainerStateException} The container is not running.
210
+ */
211
+ async pause() {
212
+ await this.operate((record) => this.getStore().pause(record));
213
+ }
214
+ /**
215
+ * Resume the processes of the paused container.
216
+ * @throws {ContainerdContainerStateException} The container is not running.
217
+ */
218
+ async unpause() {
219
+ await this.operate((record) => this.getStore().resume(record));
220
+ }
221
+ /**
222
+ * Wait for the container's main process to exit, as `docker wait` does. A container that is not running resolves at
223
+ * once: with the exit code of its last run when it exited or was stopped by {@link ContainerdContainer.stop}, with
224
+ * `0` when it was never started (or when the component did not keep its exit code: a container created by nerdctl
225
+ * or by another `dataRoot`). The wait ends with an error when the object is destroyed.
226
+ * @returns The exit code.
227
+ * @throws {GRPCError} The wait was aborted (from `@lakutata/grpc`, its `code` is `CANCELLED`).
228
+ */
229
+ async wait() {
230
+ try {
231
+ return await this.getStore().wait(this.record, this.#abortController.signal);
232
+ }
233
+ catch (error) {
234
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
235
+ }
236
+ finally {
237
+ await this.syncContainerInfo().catch(() => undefined);
238
+ }
239
+ }
240
+ /**
241
+ * Remove the container: its task, its CNI network interfaces, its record, its snapshot and its state directory (its
242
+ * logs included). The named volumes it mounts are kept. With `force`, a running or paused container is killed first.
243
+ * @param options `force` (false by default).
244
+ * @throws {ContainerdContainerStateException} The container is running and `force` is not set.
245
+ */
246
+ async remove(options) {
247
+ if (!options)
248
+ return await this.remove({});
249
+ try {
250
+ await this.getStore().remove(this.record, !!options.force);
251
+ }
252
+ catch (error) {
253
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
254
+ }
255
+ }
256
+ /**
257
+ * Run a command in the running container and wait for it to exit, its outputs captured in memory. The process gets
258
+ * the container's environment (with `env` added), working directory and user unless given. Its standard output and
259
+ * error are kept apart through FIFOs (`mkfifo` of the host); without `mkfifo`, both are in `stdout`.
260
+ * @param options The command (a string is run by `/bin/sh -c`, an array as is), `env`, `workingDir`, `user` (`name`,
261
+ * `uid`, `name:group`), `stdin` (written then closed) and `timeout` (milliseconds, then the process is killed with
262
+ * `SIGKILL`).
263
+ * @returns The exit code and the outputs; a command killed by its timeout resolves with exit code `137`.
264
+ * @throws {ContainerdContainerStateException} The container is not running (stopped or paused).
265
+ * @throws {Error} `stdin` is given and the host has no `mkfifo`; the user is not found in the container.
266
+ */
267
+ async exec(options) {
268
+ try {
269
+ return await this.getStore().exec(this.record, {
270
+ cmd: typeof options.cmd === 'string' ? ['/bin/sh', '-c', options.cmd] : options.cmd,
271
+ env: options.env,
272
+ workingDir: options.workingDir,
273
+ user: options.user,
274
+ stdin: options.stdin,
275
+ timeout: options.timeout
276
+ });
277
+ }
278
+ catch (error) {
279
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
280
+ }
281
+ }
282
+ /**
283
+ * Read the container's logs: its standard output and error interleaved in one stream, without timestamps, from its
284
+ * log file (and the previous rotated file). By default the stream follows the new output while the container runs
285
+ * (or is being restarted by the restart monitor), and ends once it stopped or when the object is destroyed.
286
+ * @param options `tail`, the number of last lines to start with (all by default), and `follow` (true by default).
287
+ * @returns A readable stream of buffers.
288
+ */
289
+ async logs(options) {
290
+ if (!options)
291
+ return await this.logs({});
292
+ return this.getStore().logs(this.record, { tail: options.tail, follow: options.follow, signal: this.#abortController.signal });
293
+ }
294
+ /**
295
+ * Read the resources the running or paused container uses: its cgroup counters and its network interface counters,
296
+ * sampled twice to compute its CPU use over the interval.
297
+ * @param interval The time between the two samples, in milliseconds; `0` takes one sample and reports a CPU use of
298
+ * 0. 1000 by default.
299
+ * @returns The counters of the last sample, with the CPU use over the interval.
300
+ * @throws {ContainerdContainerStateException} The container is not running.
301
+ */
302
+ async stats(interval = 1000) {
303
+ try {
304
+ return await this.getStore().stats(this.record, interval);
305
+ }
306
+ catch (error) {
307
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
308
+ }
309
+ }
310
+ /**
311
+ * Open an interactive terminal in the running container: a process with a pseudo terminal (`TERM=xterm`), its input
312
+ * and output through FIFOs (`mkfifo` of the host). Close it with {@link ContainerdContainerTTY.close} when done.
313
+ * @param options The command (a string is run by `/bin/sh -c` as {@link ContainerdContainer.exec} runs it, an array
314
+ * as is; `['/bin/sh']` by default, so the image needs a shell), the initial console size, `env`, `workingDir` and
315
+ * `user`.
316
+ * @returns The terminal, its process started.
317
+ * @throws {ContainerdContainerStateException} The container is not running.
318
+ * @throws {Error} The host has no `mkfifo`; the user is not found in the container.
319
+ */
320
+ async createTTY(options) {
321
+ return await this.getObject(ContainerdContainerTTY_js_1.ContainerdContainerTTY, {
322
+ getStore: this.getStore,
323
+ getRecord: () => this.record,
324
+ cmd: options?.cmd ?? ['/bin/sh'],
325
+ initialConsoleSize: options?.consoleSize,
326
+ env: options?.env,
327
+ workingDir: options?.workingDir,
328
+ user: options?.user
329
+ });
330
+ }
331
+ /**
332
+ * Update the container's settings. When only resources and the restart policy change (`memoryLimit`, `memorySwap`,
333
+ * `cpus`, `cpuShares`, `cpuSet`, `pidsLimit`, `OOMKillDisable`, `restartPolicy`), they are applied live, without a
334
+ * restart, as `docker update` does: `0` (`[]` for `cpuSet`) removes a limit, from the running container too, and from
335
+ * the settings it is created again with ({@link ContainerResourceOptions}). Any other setting creates the container
336
+ * again with its creation settings and the changes: a new container with the same name (and a new identifier, which
337
+ * this object follows), started when the old one was running; the old one is removed. The recreation only works for
338
+ * the containers created by the component, whose settings it kept.
339
+ * @param options The settings to change, as {@link Containerd.createContainer} takes them.
340
+ * @throws {InvalidValueException} A live update gives a `memorySwap` (positive) to a container without a memory
341
+ * limit, or leaves its `memorySwap` below its `memoryLimit` (from `@lakutata/core`).
342
+ * @throws {ContainerdContainerStateException} The container must be created again but was not created by the
343
+ * component (nerdctl's, or created by another `dataRoot`).
344
+ * @throws {ContainerdImageNotFoundException} From the recreation, as {@link Containerd.createContainer} throws.
345
+ */
346
+ async update(options) {
347
+ const keys = Object.keys(options).filter((key) => options[key] !== undefined);
348
+ const resourceKeys = ['memoryLimit', 'memorySwap', 'cpus', 'cpuShares', 'cpuSet', 'pidsLimit', 'OOMKillDisable', 'restartPolicy'];
349
+ if (keys.every((key) => resourceKeys.includes(key))) {
350
+ const resources = ContainerResourceOptions_js_1.ContainerResourceOptions.validate(options);
351
+ await this.operate((record) => this.getStore().updateResources(record, {
352
+ memory: resources.memoryLimit,
353
+ memorySwap: resources.memorySwap,
354
+ cpus: resources.cpus,
355
+ cpuShares: resources.cpuShares,
356
+ cpuset: resources.cpuSet?.join(','),
357
+ pidsLimit: resources.pidsLimit,
358
+ oomKillDisable: resources.OOMKillDisable,
359
+ restart: resources.restartPolicy
360
+ }));
361
+ //Kept by its settings: the ones it is created again with, a limit removed (0, []) not kept
362
+ const current = await this.getStore().readSettings(this.id);
363
+ if (!current)
364
+ return;
365
+ const settings = { ...current, ...Object.fromEntries(keys.map((key) => [key, options[key]])) };
366
+ if (!settings.memoryLimit)
367
+ delete settings.memoryLimit;
368
+ //No swap limit: unlimited swap with a memory limit (twice the memory without memorySwap)
369
+ if (!settings.memoryLimit)
370
+ delete settings.memorySwap;
371
+ else if (settings.memorySwap === 0)
372
+ settings.memorySwap = -1;
373
+ for (const key of ['cpus', 'cpuShares', 'pidsLimit'])
374
+ if (!settings[key])
375
+ delete settings[key];
376
+ if (!settings.cpuSet?.length)
377
+ delete settings.cpuSet;
378
+ await this.getStore().writeSettings(this.id, settings);
379
+ return;
380
+ }
381
+ const settings = await this.getStore().readSettings(this.id);
382
+ if (!settings)
383
+ throw new ContainerdContainerStateException_js_1.ContainerdContainerStateException(`The container ${this.name} was not created by the component (its settings are unknown): create it again`);
384
+ this.id = (await this.getContainerd().recreateContainer(this.record, { ...settings, ...options, name: options.name ?? this.name })).id;
385
+ await this.syncContainerInfo();
386
+ }
387
+ /**
388
+ * Commit the container: save the changes of its root file system (not its mounts) as a new layer on its image,
389
+ * with configuration changes, as `docker commit` does. A running container is paused meanwhile by default.
390
+ * @param options The name of the new image (`<registry>/<repository>:commit-<milliseconds>` of the container's image
391
+ * by default), `pauseBeforeCommitting` (true by default), the configuration `changes`, `comment` and `author`.
392
+ * @returns The new image.
393
+ * @throws {ContainerdImageNotFoundException} The container's image was removed.
394
+ */
395
+ async commit(options) {
396
+ if (!options)
397
+ return await this.commit({});
398
+ let name;
399
+ if (options.repoTag) {
400
+ name = options.repoTag;
401
+ }
402
+ else {
403
+ const reference = (0, Reference_js_1.parseReference)(this.imageName);
404
+ name = `${reference.registry}/${reference.repository}:commit-${Date.now()}`;
405
+ }
406
+ try {
407
+ name = await this.getStore().commit(this.record, {
408
+ name: name,
409
+ pause: options.pauseBeforeCommitting,
410
+ changes: options.changes ? { ...options.changes, env: options.changes.env ? Object.entries(options.changes.env).map(([key, value]) => `${key}=${value}`) : undefined } : undefined,
411
+ comment: options.comment,
412
+ author: options.author
413
+ });
414
+ }
415
+ catch (error) {
416
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
417
+ }
418
+ return await this.getContainerd().getImage(name);
419
+ }
420
+ /**
421
+ * Copy a file or directory of the container out as a tar archive, as `docker cp` does: from the running process's
422
+ * file system (its mounts included), or from its root file system when it is not running (without its mounts). The
423
+ * symbolic links of the path are resolved inside the container; the devices, sockets and pipes are not archived.
424
+ * @param options The absolute path in the container, and the destination (a file path, created or replaced, or a
425
+ * writable stream).
426
+ * @throws {ContainerdPathNotFoundException} The path does not exist in the container.
427
+ * @throws {Error} The archive cannot be written.
428
+ */
429
+ async exportDirectory(options) {
430
+ try {
431
+ await this.getStore().archive(this.record, options.path, typeof options.destination === 'string' ? (0, node_fs_1.createWriteStream)(options.destination) : options.destination);
432
+ }
433
+ catch (error) {
434
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
435
+ }
436
+ }
437
+ /**
438
+ * List the processes of the running container.
439
+ * @returns Their process identifiers on the host.
440
+ * @throws {ContainerdContainerStateException} The container is not running.
441
+ */
442
+ async processes() {
443
+ try {
444
+ return await this.getStore().processes(this.record);
445
+ }
446
+ catch (error) {
447
+ throw (0, ContainerdErrors_js_1.containerdError)(error);
448
+ }
449
+ }
450
+ };
451
+ exports.ContainerdContainer = ContainerdContainer;
452
+ __decorate([
453
+ (0, di_1.Configurable)(core_1.DTO.Function()),
454
+ __metadata("design:type", Function)
455
+ ], ContainerdContainer.prototype, "getStore", void 0);
456
+ __decorate([
457
+ (0, di_1.Configurable)(core_1.DTO.Function()),
458
+ __metadata("design:type", Function)
459
+ ], ContainerdContainer.prototype, "getClient", void 0);
460
+ __decorate([
461
+ (0, di_1.Configurable)(core_1.DTO.Function()),
462
+ __metadata("design:type", Function)
463
+ ], ContainerdContainer.prototype, "getContainerd", void 0);
464
+ __decorate([
465
+ (0, di_1.Configurable)(core_1.DTO.String()),
466
+ __metadata("design:type", String)
467
+ ], ContainerdContainer.prototype, "id", void 0);
468
+ __decorate([
469
+ (0, dto_1.Accept)(ContainerStopOptions_js_1.ContainerStopOptions.optional()),
470
+ __metadata("design:type", Function),
471
+ __metadata("design:paramtypes", [ContainerStopOptions_js_1.ContainerStopOptions]),
472
+ __metadata("design:returntype", Promise)
473
+ ], ContainerdContainer.prototype, "stop", null);
474
+ __decorate([
475
+ (0, dto_1.Accept)(ContainerStopOptions_js_1.ContainerStopOptions.optional()),
476
+ __metadata("design:type", Function),
477
+ __metadata("design:paramtypes", [ContainerStopOptions_js_1.ContainerStopOptions]),
478
+ __metadata("design:returntype", Promise)
479
+ ], ContainerdContainer.prototype, "restart", null);
480
+ __decorate([
481
+ (0, dto_1.Accept)(ContainerKillOptions_js_1.ContainerKillOptions.optional()),
482
+ __metadata("design:type", Function),
483
+ __metadata("design:paramtypes", [ContainerKillOptions_js_1.ContainerKillOptions]),
484
+ __metadata("design:returntype", Promise)
485
+ ], ContainerdContainer.prototype, "kill", null);
486
+ __decorate([
487
+ (0, dto_1.Accept)(ContainerRemoveOptions_js_1.ContainerRemoveOptions.optional()),
488
+ __metadata("design:type", Function),
489
+ __metadata("design:paramtypes", [ContainerRemoveOptions_js_1.ContainerRemoveOptions]),
490
+ __metadata("design:returntype", Promise)
491
+ ], ContainerdContainer.prototype, "remove", null);
492
+ __decorate([
493
+ (0, dto_1.Accept)(ContainerExecOptions_js_1.ContainerExecOptions.required()),
494
+ __metadata("design:type", Function),
495
+ __metadata("design:paramtypes", [ContainerExecOptions_js_1.ContainerExecOptions]),
496
+ __metadata("design:returntype", Promise)
497
+ ], ContainerdContainer.prototype, "exec", null);
498
+ __decorate([
499
+ (0, dto_1.Accept)(ContainerLogsOptions_js_1.ContainerLogsOptions.optional()),
500
+ __metadata("design:type", Function),
501
+ __metadata("design:paramtypes", [ContainerLogsOptions_js_1.ContainerLogsOptions]),
502
+ __metadata("design:returntype", Promise)
503
+ ], ContainerdContainer.prototype, "logs", null);
504
+ __decorate([
505
+ (0, dto_1.Accept)(core_1.DTO.Number().integer().min(0).optional()),
506
+ __metadata("design:type", Function),
507
+ __metadata("design:paramtypes", [Number]),
508
+ __metadata("design:returntype", Promise)
509
+ ], ContainerdContainer.prototype, "stats", null);
510
+ __decorate([
511
+ (0, dto_1.Accept)(ContainerTTYOptions_js_1.ContainerTTYOptions.optional()),
512
+ __metadata("design:type", Function),
513
+ __metadata("design:paramtypes", [ContainerTTYOptions_js_1.ContainerTTYOptions]),
514
+ __metadata("design:returntype", Promise)
515
+ ], ContainerdContainer.prototype, "createTTY", null);
516
+ __decorate([
517
+ (0, dto_1.Accept)(core_1.DTO.Object().required()),
518
+ __metadata("design:type", Function),
519
+ __metadata("design:paramtypes", [Object]),
520
+ __metadata("design:returntype", Promise)
521
+ ], ContainerdContainer.prototype, "update", null);
522
+ __decorate([
523
+ (0, dto_1.Accept)(ContainerCommitOptions_js_1.ContainerCommitOptions.optional()),
524
+ __metadata("design:type", Function),
525
+ __metadata("design:paramtypes", [ContainerCommitOptions_js_1.ContainerCommitOptions]),
526
+ __metadata("design:returntype", Promise)
527
+ ], ContainerdContainer.prototype, "commit", null);
528
+ __decorate([
529
+ (0, dto_1.Accept)(ContainerExportDirectoryOptions_js_1.ContainerExportDirectoryOptions.required()),
530
+ __metadata("design:type", Function),
531
+ __metadata("design:paramtypes", [ContainerExportDirectoryOptions_js_1.ContainerExportDirectoryOptions]),
532
+ __metadata("design:returntype", Promise)
533
+ ], ContainerdContainer.prototype, "exportDirectory", null);
534
+ exports.ContainerdContainer = ContainerdContainer = __decorate([
535
+ (0, di_1.Transient)()
536
+ ], ContainerdContainer);
@@ -0,0 +1,116 @@
1
+ import { Provider } from '@lakutata/core';
2
+ import { Duplex, type Readable, type Writable } from 'node:stream';
3
+ import { type Message } from '@lakutata/grpc';
4
+ import type { ContainerStore } from '../../client/ContainerStore.js';
5
+ import { ContainerTTYConsoleSizeOptions } from '../options/container/ContainerTTYConsoleSizeOptions.js';
6
+ /**
7
+ * An interactive terminal in a running container: a process (a shell by default) run with a pseudo terminal, as
8
+ * `docker exec -it` does. Get it from {@link ContainerdContainer.createTTY}; do not create it yourself. Write its input
9
+ * with {@link ContainerdContainerTTY.write} (or {@link ContainerdContainerTTY.writable}), read its output with
10
+ * {@link ContainerdContainerTTY.onData} (or {@link ContainerdContainerTTY.readable}), or pipe a socket into
11
+ * {@link ContainerdContainerTTY.raw}. The terminal ends when its process exits or when it is closed; it is closed when
12
+ * the object is destroyed.
13
+ * @example
14
+ * ```typescript
15
+ * import {type Containerd, type ContainerdContainer, type ContainerdContainerTTY} from 'lakutata/com/containerd'
16
+ *
17
+ * declare const containerd: Containerd
18
+ *
19
+ * const container: ContainerdContainer = await containerd.getContainer('worker')
20
+ * const tty: ContainerdContainerTTY = await container.createTTY({cmd: ['/bin/sh', '-l'], consoleSize: {cols: 120, rows: 40}})
21
+ * tty.onData((chunk: Buffer): void => {
22
+ * process.stdout.write(chunk)
23
+ * })
24
+ * tty.write('ls -la\n')
25
+ * await tty.resize({cols: 100, rows: 30})
26
+ * tty.write('exit\n')
27
+ * //The exit code of the shell
28
+ * console.log(await tty.wait())
29
+ * ```
30
+ */
31
+ export declare class ContainerdContainerTTY extends Provider {
32
+ #private;
33
+ /**
34
+ * Gives the component's container store; set by the container.
35
+ */
36
+ protected readonly getStore: () => ContainerStore;
37
+ /**
38
+ * Gives the container's record in containerd; set by the container.
39
+ */
40
+ protected readonly getRecord: () => Message;
41
+ /**
42
+ * The command run in the terminal: a command line run by `/bin/sh -c`, or an executable and its arguments.
43
+ */
44
+ protected readonly cmd: string | string[];
45
+ /**
46
+ * The console size the terminal starts with, in columns and rows.
47
+ * @default the runtime's default size
48
+ */
49
+ protected readonly initialConsoleSize?: ContainerTTYConsoleSizeOptions;
50
+ /**
51
+ * The environment variables added to the container's (`TERM` is `xterm` unless given).
52
+ * @default none
53
+ */
54
+ protected readonly env?: Record<string, string>;
55
+ /**
56
+ * The working directory of the process.
57
+ * @default the container's working directory
58
+ */
59
+ protected readonly workingDir?: string;
60
+ /**
61
+ * The user running the process (`name`, `uid`, `name:group`), looked up in the container's `/etc/passwd`.
62
+ * @default the container's user
63
+ */
64
+ protected readonly user?: string;
65
+ /**
66
+ * Start the terminal's process in the container.
67
+ * @throws {ContainerdContainerStateException} The container is not running.
68
+ * @throws {Error} The host has no `mkfifo`; the user is not found in the container.
69
+ * @protected
70
+ */
71
+ protected init(): Promise<void>;
72
+ /**
73
+ * Close the terminal, as {@link ContainerdContainerTTY.close} does.
74
+ * @protected
75
+ */
76
+ protected destroy(): Promise<void>;
77
+ /**
78
+ * The terminal as one duplex stream: writing sends input to the process, reading gives its output (to pipe a
79
+ * WebSocket or a socket into it). It is created at the first access and consumes the output from then on.
80
+ */
81
+ get raw(): Duplex;
82
+ /**
83
+ * The terminal's input: what is written is sent to the process, as typed on a keyboard (`\x03` for Ctrl+C).
84
+ */
85
+ get writable(): Writable;
86
+ /**
87
+ * The terminal's output: what the process prints, its standard error included; it ends when the process exits.
88
+ */
89
+ get readable(): Readable;
90
+ /**
91
+ * Resize the terminal's console; the process receives `SIGWINCH`.
92
+ * @param options The new size, in columns and rows (positive integers).
93
+ * @throws {GRPCError} The process has exited (from `@lakutata/grpc`).
94
+ */
95
+ resize(options: ContainerTTYConsoleSizeOptions): Promise<void>;
96
+ /**
97
+ * Listen to the terminal's output. Each call adds a listener.
98
+ * @param handler Called with each chunk of output.
99
+ */
100
+ onData(handler: (chunk: Buffer) => void): void;
101
+ /**
102
+ * Send input to the terminal's process.
103
+ * @param data The input, as text or bytes (`'ls\n'`, a newline to submit a line).
104
+ */
105
+ write(data: string | Buffer): void;
106
+ /**
107
+ * Wait for the terminal's process to exit; the terminal is then closed.
108
+ * @returns Its exit code (`137` when it was closed by {@link ContainerdContainerTTY.close}).
109
+ */
110
+ wait(): Promise<number>;
111
+ /**
112
+ * Close the terminal: kill its process with `SIGKILL` and release its FIFOs. Nothing happens when it is already
113
+ * closed.
114
+ */
115
+ close(): Promise<void>;
116
+ }