@lakutata/docker 3.0.0-beta.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 (305) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +309 -0
  3. package/THIRD_PARTY_NOTICES.md +299 -0
  4. package/dist/cjs/client/BuildContext.d.ts +22 -0
  5. package/dist/cjs/client/BuildContext.js +76 -0
  6. package/dist/cjs/client/BuildKitProgress.d.ts +81 -0
  7. package/dist/cjs/client/BuildKitProgress.js +195 -0
  8. package/dist/cjs/client/DockerClient.d.ts +196 -0
  9. package/dist/cjs/client/DockerClient.js +312 -0
  10. package/dist/cjs/client/DockerConnection.d.ts +154 -0
  11. package/dist/cjs/client/DockerConnection.js +397 -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/DockerRequestError.d.ts +17 -0
  15. package/dist/cjs/client/DockerRequestError.js +24 -0
  16. package/dist/cjs/client/DockerStreams.d.ts +35 -0
  17. package/dist/cjs/client/DockerStreams.js +117 -0
  18. package/dist/cjs/client/types/ContainerCreateResponse.d.ts +7 -0
  19. package/dist/cjs/client/types/ContainerCreateResponse.js +2 -0
  20. package/dist/cjs/client/types/ContainerStopQuery.d.ts +13 -0
  21. package/dist/cjs/client/types/ContainerStopQuery.js +2 -0
  22. package/dist/cjs/client/types/DeviceMapping.d.ts +8 -0
  23. package/dist/cjs/client/types/DeviceMapping.js +2 -0
  24. package/dist/cjs/client/types/IdResponse.d.ts +6 -0
  25. package/dist/cjs/client/types/IdResponse.js +2 -0
  26. package/dist/cjs/client/types/NetworkCreateResponse.d.ts +7 -0
  27. package/dist/cjs/client/types/NetworkCreateResponse.js +2 -0
  28. package/dist/cjs/client/types/PortBinding.d.ts +10 -0
  29. package/dist/cjs/client/types/PortBinding.js +2 -0
  30. package/dist/cjs/docker/ConnectionOptionsBuilder.d.ts +128 -0
  31. package/dist/cjs/docker/ConnectionOptionsBuilder.js +150 -0
  32. package/dist/cjs/docker/Docker.d.ts +301 -0
  33. package/dist/cjs/docker/Docker.js +703 -0
  34. package/dist/cjs/docker/exceptions/DockerConnectionException.d.ts +9 -0
  35. package/dist/cjs/docker/exceptions/DockerConnectionException.js +16 -0
  36. package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
  37. package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.js +16 -0
  38. package/dist/cjs/docker/exceptions/DockerImageBuildException.d.ts +9 -0
  39. package/dist/cjs/docker/exceptions/DockerImageBuildException.js +16 -0
  40. package/dist/cjs/docker/exceptions/DockerImageImportException.d.ts +9 -0
  41. package/dist/cjs/docker/exceptions/DockerImageImportException.js +16 -0
  42. package/dist/cjs/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
  43. package/dist/cjs/docker/exceptions/DockerImageNotFoundException.js +17 -0
  44. package/dist/cjs/docker/exceptions/DockerImagePullException.d.ts +9 -0
  45. package/dist/cjs/docker/exceptions/DockerImagePullException.js +16 -0
  46. package/dist/cjs/docker/exceptions/DockerImagePushException.d.ts +8 -0
  47. package/dist/cjs/docker/exceptions/DockerImagePushException.js +15 -0
  48. package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
  49. package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.js +15 -0
  50. package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
  51. package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.js +16 -0
  52. package/dist/cjs/docker/exceptions/DockerRequestException.d.ts +22 -0
  53. package/dist/cjs/docker/exceptions/DockerRequestException.js +24 -0
  54. package/dist/cjs/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
  55. package/dist/cjs/docker/interfaces/IDockerConnectionOptions.js +2 -0
  56. package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
  57. package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.js +2 -0
  58. package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
  59. package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.js +2 -0
  60. package/dist/cjs/docker/interfaces/IDockerKeyObject.d.ts +14 -0
  61. package/dist/cjs/docker/interfaces/IDockerKeyObject.js +2 -0
  62. package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
  63. package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.js +2 -0
  64. package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
  65. package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.js +2 -0
  66. package/dist/cjs/docker/lib/DockerContainer.d.ts +315 -0
  67. package/dist/cjs/docker/lib/DockerContainer.js +742 -0
  68. package/dist/cjs/docker/lib/DockerContainerTTY.d.ts +99 -0
  69. package/dist/cjs/docker/lib/DockerContainerTTY.js +157 -0
  70. package/dist/cjs/docker/lib/DockerImage.d.ts +153 -0
  71. package/dist/cjs/docker/lib/DockerImage.js +273 -0
  72. package/dist/cjs/docker/lib/EngineSettings.d.ts +41 -0
  73. package/dist/cjs/docker/lib/EngineSettings.js +86 -0
  74. package/dist/cjs/docker/lib/ParseBaseImages.d.ts +9 -0
  75. package/dist/cjs/docker/lib/ParseBaseImages.js +50 -0
  76. package/dist/cjs/docker/lib/ParseEnvToRecord.d.ts +14 -0
  77. package/dist/cjs/docker/lib/ParseEnvToRecord.js +25 -0
  78. package/dist/cjs/docker/lib/ParseRepositoryTag.d.ts +17 -0
  79. package/dist/cjs/docker/lib/ParseRepositoryTag.js +48 -0
  80. package/dist/cjs/docker/lib/RegistryAuth.d.ts +8 -0
  81. package/dist/cjs/docker/lib/RegistryAuth.js +15 -0
  82. package/dist/cjs/docker/options/DockerPruneOptions.d.ts +38 -0
  83. package/dist/cjs/docker/options/DockerPruneOptions.js +47 -0
  84. package/dist/cjs/docker/options/auth/DockerAuthOptions.d.ts +46 -0
  85. package/dist/cjs/docker/options/auth/DockerAuthOptions.js +59 -0
  86. package/dist/cjs/docker/options/container/ContainerCommitOptions.d.ts +28 -0
  87. package/dist/cjs/docker/options/container/ContainerCommitOptions.js +39 -0
  88. package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
  89. package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.js +43 -0
  90. package/dist/cjs/docker/options/container/ContainerExecOptions.d.ts +26 -0
  91. package/dist/cjs/docker/options/container/ContainerExecOptions.js +38 -0
  92. package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
  93. package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.js +39 -0
  94. package/dist/cjs/docker/options/container/ContainerKillOptions.d.ts +25 -0
  95. package/dist/cjs/docker/options/container/ContainerKillOptions.js +36 -0
  96. package/dist/cjs/docker/options/container/ContainerLogsOptions.d.ts +48 -0
  97. package/dist/cjs/docker/options/container/ContainerLogsOptions.js +56 -0
  98. package/dist/cjs/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
  99. package/dist/cjs/docker/options/container/ContainerRemoveOptions.js +34 -0
  100. package/dist/cjs/docker/options/container/ContainerSettingOptions.d.ts +137 -0
  101. package/dist/cjs/docker/options/container/ContainerSettingOptions.js +136 -0
  102. package/dist/cjs/docker/options/container/ContainerStopOptions.d.ts +28 -0
  103. package/dist/cjs/docker/options/container/ContainerStopOptions.js +40 -0
  104. package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  105. package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
  106. package/dist/cjs/docker/options/image/ImageBuildOptions.d.ts +117 -0
  107. package/dist/cjs/docker/options/image/ImageBuildOptions.js +111 -0
  108. package/dist/cjs/docker/options/image/ImageExportOptions.d.ts +33 -0
  109. package/dist/cjs/docker/options/image/ImageExportOptions.js +44 -0
  110. package/dist/cjs/docker/options/image/ImageImportOptions.d.ts +28 -0
  111. package/dist/cjs/docker/options/image/ImageImportOptions.js +42 -0
  112. package/dist/cjs/docker/options/image/ImagePullOptions.d.ts +49 -0
  113. package/dist/cjs/docker/options/image/ImagePullOptions.js +63 -0
  114. package/dist/cjs/docker/options/image/ImagePushOptions.d.ts +41 -0
  115. package/dist/cjs/docker/options/image/ImagePushOptions.js +56 -0
  116. package/dist/cjs/docker/options/image/ImageRemoveOptions.d.ts +26 -0
  117. package/dist/cjs/docker/options/image/ImageRemoveOptions.js +38 -0
  118. package/dist/cjs/docker/options/image/ImageTagOptions.d.ts +25 -0
  119. package/dist/cjs/docker/options/image/ImageTagOptions.js +38 -0
  120. package/dist/cjs/docker/options/network/NetworkCreateOptions.d.ts +54 -0
  121. package/dist/cjs/docker/options/network/NetworkCreateOptions.js +63 -0
  122. package/dist/cjs/docker/types/ContainerBind.d.ts +19 -0
  123. package/dist/cjs/docker/types/ContainerBind.js +2 -0
  124. package/dist/cjs/docker/types/ContainerCapability.d.ts +286 -0
  125. package/dist/cjs/docker/types/ContainerCapability.js +290 -0
  126. package/dist/cjs/docker/types/ContainerConfig.d.ts +67 -0
  127. package/dist/cjs/docker/types/ContainerConfig.js +2 -0
  128. package/dist/cjs/docker/types/ContainerDevice.d.ts +19 -0
  129. package/dist/cjs/docker/types/ContainerDevice.js +2 -0
  130. package/dist/cjs/docker/types/ContainerExecResult.d.ts +20 -0
  131. package/dist/cjs/docker/types/ContainerExecResult.js +2 -0
  132. package/dist/cjs/docker/types/ContainerNetwork.d.ts +46 -0
  133. package/dist/cjs/docker/types/ContainerNetwork.js +2 -0
  134. package/dist/cjs/docker/types/ContainerPort.d.ts +25 -0
  135. package/dist/cjs/docker/types/ContainerPort.js +2 -0
  136. package/dist/cjs/docker/types/ContainerRestartPolicy.d.ts +11 -0
  137. package/dist/cjs/docker/types/ContainerRestartPolicy.js +2 -0
  138. package/dist/cjs/docker/types/ContainerState.d.ts +48 -0
  139. package/dist/cjs/docker/types/ContainerState.js +2 -0
  140. package/dist/cjs/docker/types/ContainerStats.d.ts +408 -0
  141. package/dist/cjs/docker/types/ContainerStats.js +2 -0
  142. package/dist/cjs/docker/types/DockerOutputCallback.d.ts +8 -0
  143. package/dist/cjs/docker/types/DockerOutputCallback.js +2 -0
  144. package/dist/cjs/docker/types/ImageConfig.d.ts +34 -0
  145. package/dist/cjs/docker/types/ImageConfig.js +2 -0
  146. package/dist/cjs/docker/types/ImageExposePort.d.ts +17 -0
  147. package/dist/cjs/docker/types/ImageExposePort.js +2 -0
  148. package/dist/cjs/docker/types/NetworkInfo.d.ts +59 -0
  149. package/dist/cjs/docker/types/NetworkInfo.js +2 -0
  150. package/dist/cjs/docker/types/RepositoryTag.d.ts +15 -0
  151. package/dist/cjs/docker/types/RepositoryTag.js +2 -0
  152. package/dist/cjs/exports/Docker.d.ts +73 -0
  153. package/dist/cjs/exports/Docker.js +92 -0
  154. package/dist/cjs/package.json +1 -0
  155. package/dist/esm/client/BuildContext.js +70 -0
  156. package/dist/esm/client/BuildKitProgress.js +190 -0
  157. package/dist/esm/client/DockerClient.js +307 -0
  158. package/dist/esm/client/DockerConnection.js +355 -0
  159. package/dist/esm/client/DockerIgnore.js +179 -0
  160. package/dist/esm/client/DockerRequestError.js +20 -0
  161. package/dist/esm/client/DockerStreams.js +111 -0
  162. package/dist/esm/client/types/ContainerCreateResponse.js +1 -0
  163. package/dist/esm/client/types/ContainerStopQuery.js +1 -0
  164. package/dist/esm/client/types/DeviceMapping.js +1 -0
  165. package/dist/esm/client/types/IdResponse.js +1 -0
  166. package/dist/esm/client/types/NetworkCreateResponse.js +1 -0
  167. package/dist/esm/client/types/PortBinding.js +1 -0
  168. package/dist/esm/docker/ConnectionOptionsBuilder.js +142 -0
  169. package/dist/esm/docker/Docker.js +697 -0
  170. package/dist/esm/docker/exceptions/DockerConnectionException.js +12 -0
  171. package/dist/esm/docker/exceptions/DockerContainerNotFoundException.js +12 -0
  172. package/dist/esm/docker/exceptions/DockerImageBuildException.js +12 -0
  173. package/dist/esm/docker/exceptions/DockerImageImportException.js +12 -0
  174. package/dist/esm/docker/exceptions/DockerImageNotFoundException.js +13 -0
  175. package/dist/esm/docker/exceptions/DockerImagePullException.js +12 -0
  176. package/dist/esm/docker/exceptions/DockerImagePushException.js +11 -0
  177. package/dist/esm/docker/exceptions/DockerImageRepoTagNotFoundException.js +11 -0
  178. package/dist/esm/docker/exceptions/DockerNetworkNotFoundException.js +12 -0
  179. package/dist/esm/docker/exceptions/DockerRequestException.js +20 -0
  180. package/dist/esm/docker/interfaces/IDockerConnectionOptions.js +1 -0
  181. package/dist/esm/docker/interfaces/IDockerHttpConnectionOptions.js +1 -0
  182. package/dist/esm/docker/interfaces/IDockerHttpsConnectionOptions.js +1 -0
  183. package/dist/esm/docker/interfaces/IDockerKeyObject.js +1 -0
  184. package/dist/esm/docker/interfaces/IDockerSSHConnectionOptions.js +1 -0
  185. package/dist/esm/docker/interfaces/IDockerSocketConnectionOptions.js +1 -0
  186. package/dist/esm/docker/lib/DockerContainer.js +739 -0
  187. package/dist/esm/docker/lib/DockerContainerTTY.js +154 -0
  188. package/dist/esm/docker/lib/DockerImage.js +270 -0
  189. package/dist/esm/docker/lib/EngineSettings.js +78 -0
  190. package/dist/esm/docker/lib/ParseBaseImages.js +47 -0
  191. package/dist/esm/docker/lib/ParseEnvToRecord.js +22 -0
  192. package/dist/esm/docker/lib/ParseRepositoryTag.js +45 -0
  193. package/dist/esm/docker/lib/RegistryAuth.js +12 -0
  194. package/dist/esm/docker/options/DockerPruneOptions.js +43 -0
  195. package/dist/esm/docker/options/auth/DockerAuthOptions.js +55 -0
  196. package/dist/esm/docker/options/container/ContainerCommitOptions.js +35 -0
  197. package/dist/esm/docker/options/container/ContainerCreateTTYOptions.js +39 -0
  198. package/dist/esm/docker/options/container/ContainerExecOptions.js +34 -0
  199. package/dist/esm/docker/options/container/ContainerExportDirectoryOptions.js +35 -0
  200. package/dist/esm/docker/options/container/ContainerKillOptions.js +32 -0
  201. package/dist/esm/docker/options/container/ContainerLogsOptions.js +52 -0
  202. package/dist/esm/docker/options/container/ContainerRemoveOptions.js +30 -0
  203. package/dist/esm/docker/options/container/ContainerSettingOptions.js +132 -0
  204. package/dist/esm/docker/options/container/ContainerStopOptions.js +36 -0
  205. package/dist/esm/docker/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
  206. package/dist/esm/docker/options/image/ImageBuildOptions.js +107 -0
  207. package/dist/esm/docker/options/image/ImageExportOptions.js +40 -0
  208. package/dist/esm/docker/options/image/ImageImportOptions.js +38 -0
  209. package/dist/esm/docker/options/image/ImagePullOptions.js +59 -0
  210. package/dist/esm/docker/options/image/ImagePushOptions.js +52 -0
  211. package/dist/esm/docker/options/image/ImageRemoveOptions.js +34 -0
  212. package/dist/esm/docker/options/image/ImageTagOptions.js +34 -0
  213. package/dist/esm/docker/options/network/NetworkCreateOptions.js +59 -0
  214. package/dist/esm/docker/types/ContainerBind.js +1 -0
  215. package/dist/esm/docker/types/ContainerCapability.js +287 -0
  216. package/dist/esm/docker/types/ContainerConfig.js +1 -0
  217. package/dist/esm/docker/types/ContainerDevice.js +1 -0
  218. package/dist/esm/docker/types/ContainerExecResult.js +1 -0
  219. package/dist/esm/docker/types/ContainerNetwork.js +1 -0
  220. package/dist/esm/docker/types/ContainerPort.js +1 -0
  221. package/dist/esm/docker/types/ContainerRestartPolicy.js +1 -0
  222. package/dist/esm/docker/types/ContainerState.js +1 -0
  223. package/dist/esm/docker/types/ContainerStats.js +1 -0
  224. package/dist/esm/docker/types/DockerOutputCallback.js +1 -0
  225. package/dist/esm/docker/types/ImageConfig.js +1 -0
  226. package/dist/esm/docker/types/ImageExposePort.js +1 -0
  227. package/dist/esm/docker/types/NetworkInfo.js +1 -0
  228. package/dist/esm/docker/types/RepositoryTag.js +1 -0
  229. package/dist/esm/exports/Docker.js +73 -0
  230. package/dist/types/client/BuildContext.d.ts +22 -0
  231. package/dist/types/client/BuildKitProgress.d.ts +81 -0
  232. package/dist/types/client/DockerClient.d.ts +196 -0
  233. package/dist/types/client/DockerConnection.d.ts +154 -0
  234. package/dist/types/client/DockerIgnore.d.ts +44 -0
  235. package/dist/types/client/DockerRequestError.d.ts +17 -0
  236. package/dist/types/client/DockerStreams.d.ts +35 -0
  237. package/dist/types/client/types/ContainerCreateResponse.d.ts +7 -0
  238. package/dist/types/client/types/ContainerStopQuery.d.ts +13 -0
  239. package/dist/types/client/types/DeviceMapping.d.ts +8 -0
  240. package/dist/types/client/types/IdResponse.d.ts +6 -0
  241. package/dist/types/client/types/NetworkCreateResponse.d.ts +7 -0
  242. package/dist/types/client/types/PortBinding.d.ts +10 -0
  243. package/dist/types/docker/ConnectionOptionsBuilder.d.ts +128 -0
  244. package/dist/types/docker/Docker.d.ts +301 -0
  245. package/dist/types/docker/exceptions/DockerConnectionException.d.ts +9 -0
  246. package/dist/types/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
  247. package/dist/types/docker/exceptions/DockerImageBuildException.d.ts +9 -0
  248. package/dist/types/docker/exceptions/DockerImageImportException.d.ts +9 -0
  249. package/dist/types/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
  250. package/dist/types/docker/exceptions/DockerImagePullException.d.ts +9 -0
  251. package/dist/types/docker/exceptions/DockerImagePushException.d.ts +8 -0
  252. package/dist/types/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
  253. package/dist/types/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
  254. package/dist/types/docker/exceptions/DockerRequestException.d.ts +22 -0
  255. package/dist/types/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
  256. package/dist/types/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
  257. package/dist/types/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
  258. package/dist/types/docker/interfaces/IDockerKeyObject.d.ts +14 -0
  259. package/dist/types/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
  260. package/dist/types/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
  261. package/dist/types/docker/lib/DockerContainer.d.ts +315 -0
  262. package/dist/types/docker/lib/DockerContainerTTY.d.ts +99 -0
  263. package/dist/types/docker/lib/DockerImage.d.ts +153 -0
  264. package/dist/types/docker/lib/EngineSettings.d.ts +41 -0
  265. package/dist/types/docker/lib/ParseBaseImages.d.ts +9 -0
  266. package/dist/types/docker/lib/ParseEnvToRecord.d.ts +14 -0
  267. package/dist/types/docker/lib/ParseRepositoryTag.d.ts +17 -0
  268. package/dist/types/docker/lib/RegistryAuth.d.ts +8 -0
  269. package/dist/types/docker/options/DockerPruneOptions.d.ts +38 -0
  270. package/dist/types/docker/options/auth/DockerAuthOptions.d.ts +46 -0
  271. package/dist/types/docker/options/container/ContainerCommitOptions.d.ts +28 -0
  272. package/dist/types/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
  273. package/dist/types/docker/options/container/ContainerExecOptions.d.ts +26 -0
  274. package/dist/types/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
  275. package/dist/types/docker/options/container/ContainerKillOptions.d.ts +25 -0
  276. package/dist/types/docker/options/container/ContainerLogsOptions.d.ts +48 -0
  277. package/dist/types/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
  278. package/dist/types/docker/options/container/ContainerSettingOptions.d.ts +137 -0
  279. package/dist/types/docker/options/container/ContainerStopOptions.d.ts +28 -0
  280. package/dist/types/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  281. package/dist/types/docker/options/image/ImageBuildOptions.d.ts +117 -0
  282. package/dist/types/docker/options/image/ImageExportOptions.d.ts +33 -0
  283. package/dist/types/docker/options/image/ImageImportOptions.d.ts +28 -0
  284. package/dist/types/docker/options/image/ImagePullOptions.d.ts +49 -0
  285. package/dist/types/docker/options/image/ImagePushOptions.d.ts +41 -0
  286. package/dist/types/docker/options/image/ImageRemoveOptions.d.ts +26 -0
  287. package/dist/types/docker/options/image/ImageTagOptions.d.ts +25 -0
  288. package/dist/types/docker/options/network/NetworkCreateOptions.d.ts +54 -0
  289. package/dist/types/docker/types/ContainerBind.d.ts +19 -0
  290. package/dist/types/docker/types/ContainerCapability.d.ts +286 -0
  291. package/dist/types/docker/types/ContainerConfig.d.ts +67 -0
  292. package/dist/types/docker/types/ContainerDevice.d.ts +19 -0
  293. package/dist/types/docker/types/ContainerExecResult.d.ts +20 -0
  294. package/dist/types/docker/types/ContainerNetwork.d.ts +46 -0
  295. package/dist/types/docker/types/ContainerPort.d.ts +25 -0
  296. package/dist/types/docker/types/ContainerRestartPolicy.d.ts +11 -0
  297. package/dist/types/docker/types/ContainerState.d.ts +48 -0
  298. package/dist/types/docker/types/ContainerStats.d.ts +408 -0
  299. package/dist/types/docker/types/DockerOutputCallback.d.ts +8 -0
  300. package/dist/types/docker/types/ImageConfig.d.ts +34 -0
  301. package/dist/types/docker/types/ImageExposePort.d.ts +17 -0
  302. package/dist/types/docker/types/NetworkInfo.d.ts +59 -0
  303. package/dist/types/docker/types/RepositoryTag.d.ts +15 -0
  304. package/dist/types/exports/Docker.d.ts +73 -0
  305. package/package.json +57 -0
@@ -0,0 +1,179 @@
1
+ /*
2
+ * The rules of the .dockerignore files, rewritten from @balena/dockerignore (Copyright 2020 Balena Ltd., Apache License
3
+ * 2.0, and Copyright 2018 Zeit, Inc., MIT License, see THIRD_PARTY_NOTICES.md), which follows the implementation of
4
+ * Docker (moby/moby builder/dockerignore and pkg/fileutils)
5
+ */
6
+ import path from 'node:path';
7
+ /**
8
+ * The separators of the paths of the platform: on Windows, "/" and "\" separate the paths and "\" does not escape
9
+ */
10
+ const SEPARATOR = path.sep;
11
+ /**
12
+ * filepath.Clean of Go
13
+ * @param file
14
+ */
15
+ function cleanPath(file) {
16
+ return path.normalize(file).replace(SEPARATOR === '\\' ? /(?<=.)\\$/ : /(?<=.)\/$/, '');
17
+ }
18
+ /**
19
+ * filepath.ToSlash of Go
20
+ * @param file
21
+ */
22
+ function toSlash(file) {
23
+ return SEPARATOR === '/' ? file : file.replace(/\\/g, '/');
24
+ }
25
+ /**
26
+ * filepath.FromSlash of Go
27
+ * @param file
28
+ */
29
+ function fromSlash(file) {
30
+ return SEPARATOR === '/' ? file : file.replace(/\//g, SEPARATOR);
31
+ }
32
+ /**
33
+ * The rules of a .dockerignore file: the files of a build context they exclude
34
+ */
35
+ export class DockerIgnore {
36
+ #rules = [];
37
+ #cache = new Map();
38
+ /**
39
+ * @param content the content of a .dockerignore file
40
+ * @param ignoreCase match the case-insensitively, as Docker does not (false by default)
41
+ */
42
+ constructor(content = '', ignoreCase = false) {
43
+ this.ignoreCase = ignoreCase;
44
+ this.add(content);
45
+ }
46
+ /**
47
+ * Add the rules of a content
48
+ * @param content
49
+ */
50
+ add(content) {
51
+ for (const line of content.split(/\r?\n/)) {
52
+ if (!line.trim() || line.startsWith('#'))
53
+ continue;
54
+ const rule = this.rule(line.trim());
55
+ if (rule)
56
+ this.#rules.push(rule);
57
+ }
58
+ this.#cache.clear();
59
+ return this;
60
+ }
61
+ /**
62
+ * A rule of a line (moby/moby builder/dockerignore/dockerignore.go and pkg/fileutils/fileutils.go)
63
+ * @param line
64
+ */
65
+ rule(line) {
66
+ let pattern = line;
67
+ let negative = false;
68
+ if (pattern.startsWith('!')) {
69
+ negative = true;
70
+ pattern = pattern.substring(1).trim();
71
+ }
72
+ if (pattern.length > 0) {
73
+ pattern = toSlash(cleanPath(pattern));
74
+ if (pattern.length > 1 && pattern.startsWith('/'))
75
+ pattern = pattern.slice(1);
76
+ }
77
+ if (negative)
78
+ pattern = `!${pattern}`;
79
+ pattern = pattern.trim();
80
+ if (!pattern)
81
+ return undefined;
82
+ pattern = cleanPath(pattern);
83
+ if (pattern.startsWith('!')) {
84
+ if (pattern.length === 1)
85
+ return undefined;
86
+ negative = true;
87
+ pattern = pattern.substring(1);
88
+ }
89
+ else {
90
+ negative = false;
91
+ }
92
+ return { pattern: pattern, directories: pattern.split(SEPARATOR), negative: negative };
93
+ }
94
+ /**
95
+ * The regular expression of a rule (fileutils.go regexpMatch)
96
+ * @param rule
97
+ */
98
+ expression(rule) {
99
+ if (rule.expression)
100
+ return rule.expression;
101
+ const separator = SEPARATOR === '\\' ? '\\\\' : SEPARATOR;
102
+ let source = '^';
103
+ const pattern = rule.pattern;
104
+ for (let index = 0; index < pattern.length; index++) {
105
+ const character = pattern[index];
106
+ if (character === '*') {
107
+ if (pattern[index + 1] === '*') {
108
+ index++;
109
+ //"**/" is "**"
110
+ if (pattern[index + 1] === SEPARATOR)
111
+ index++;
112
+ source += pattern[index + 1] === undefined ? '.*' : `(.*${separator})?`;
113
+ }
114
+ else {
115
+ source += `[^${separator}]*`;
116
+ }
117
+ }
118
+ else if (character === '?') {
119
+ source += `[^${separator}]`;
120
+ }
121
+ else if (character === '.' || character === '$') {
122
+ source += `\\${character}`;
123
+ }
124
+ else if (character === '\\') {
125
+ if (SEPARATOR === '\\') {
126
+ source += separator;
127
+ }
128
+ else if (pattern[index + 1] !== undefined) {
129
+ source += `\\${pattern[++index]}`;
130
+ }
131
+ else {
132
+ source += '\\';
133
+ }
134
+ }
135
+ else {
136
+ source += character;
137
+ }
138
+ }
139
+ return rule.expression = new RegExp(`${source}$`, this.ignoreCase ? 'i' : '');
140
+ }
141
+ /**
142
+ * Whether a file of the context is excluded by the rules (its path relative to the context, "/" separated)
143
+ * @param file
144
+ */
145
+ ignores(file) {
146
+ if (!file)
147
+ return true;
148
+ let ignored = this.#cache.get(file);
149
+ if (ignored === undefined)
150
+ this.#cache.set(file, ignored = this.test(file));
151
+ return ignored;
152
+ }
153
+ /**
154
+ * Whether a file is excluded: the last rule matching it or one of its parent directories decides
155
+ * @param file
156
+ */
157
+ test(file) {
158
+ const local = fromSlash(file);
159
+ const parent = cleanPath(path.dirname(local));
160
+ const parentDirectories = parent.split(SEPARATOR);
161
+ let matched = false;
162
+ for (const rule of this.#rules) {
163
+ let match = this.expression(rule).test(local);
164
+ if (!match && parent !== '.') {
165
+ if (rule.directories.includes('**')) {
166
+ for (let index = rule.directories.filter((directory) => directory !== '**').length; index <= parentDirectories.length; index++) {
167
+ match = match || this.expression(rule).test(parentDirectories.slice(0, index).join(SEPARATOR));
168
+ }
169
+ }
170
+ else if (rule.directories.length <= parentDirectories.length) {
171
+ match = this.expression(rule).test(parentDirectories.slice(0, rule.directories.length).join(SEPARATOR));
172
+ }
173
+ }
174
+ if (match)
175
+ matched = !rule.negative;
176
+ }
177
+ return matched;
178
+ }
179
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A request to the Docker Engine API which failed: its message is the one of docker-modem, "(HTTP code 404) no such
3
+ * container - No such container: x", the status and the body of the response are given
4
+ */
5
+ export class DockerRequestError extends Error {
6
+ /**
7
+ * @param statusCode the status of the response
8
+ * @param reason the meaning of the status for the request
9
+ * @param detail the message of the daemon
10
+ * @param json the body of the response
11
+ */
12
+ constructor(statusCode, reason, detail, json) {
13
+ super(`(HTTP code ${statusCode}) ${reason} - ${detail} `);
14
+ this.statusCode = statusCode;
15
+ this.reason = reason;
16
+ this.detail = detail;
17
+ this.json = json;
18
+ this.name = 'DockerRequestError';
19
+ }
20
+ }
@@ -0,0 +1,111 @@
1
+ /*
2
+ * The streams of the Docker Engine API, rewritten from docker-modem (Copyright Pedro Dias, Apache License 2.0, see
3
+ * THIRD_PARTY_NOTICES.md): the multiplexed output of the containers without TTY, and the JSON lines of the progresses
4
+ */
5
+ import { Transform } from 'node:stream';
6
+ /**
7
+ * The stream of a frame of a multiplexed output
8
+ */
9
+ export var DockerStreamType;
10
+ (function (DockerStreamType) {
11
+ DockerStreamType[DockerStreamType["STDIN"] = 0] = "STDIN";
12
+ DockerStreamType[DockerStreamType["STDOUT"] = 1] = "STDOUT";
13
+ DockerStreamType[DockerStreamType["STDERR"] = 2] = "STDERR";
14
+ })(DockerStreamType || (DockerStreamType = {}));
15
+ /**
16
+ * The output of a container without TTY is multiplexed: each frame is a header of 8 bytes (the stream, 3 zeros, the
17
+ * size as a big endian uint32) and its content. The decoder gives the contents, in their order; its "frame" event
18
+ * gives each content with its stream
19
+ */
20
+ export class DockerStreamDecoder extends Transform {
21
+ #pending = Buffer.alloc(0);
22
+ _transform(chunk, _encoding, callback) {
23
+ this.#pending = this.#pending.length ? Buffer.concat([this.#pending, chunk]) : chunk;
24
+ while (this.#pending.length >= 8) {
25
+ const size = this.#pending.readUInt32BE(4);
26
+ if (this.#pending.length < 8 + size)
27
+ break;
28
+ const type = this.#pending.readUInt8(0);
29
+ const content = this.#pending.subarray(8, 8 + size);
30
+ this.#pending = this.#pending.subarray(8 + size);
31
+ if (content.length) {
32
+ this.emit('frame', type, content);
33
+ this.push(content);
34
+ }
35
+ }
36
+ callback();
37
+ }
38
+ _flush(callback) {
39
+ //A truncated frame is given as it is
40
+ if (this.#pending.length)
41
+ this.push(this.#pending);
42
+ callback();
43
+ }
44
+ }
45
+ /**
46
+ * The output of a multiplexed stream (or buffer), and its outputs by stream
47
+ * @param input
48
+ */
49
+ export async function readMultiplexed(input) {
50
+ const decoder = new DockerStreamDecoder();
51
+ const output = [];
52
+ const streams = { [DockerStreamType.STDOUT]: [], [DockerStreamType.STDERR]: [] };
53
+ decoder.on('frame', (type, content) => (streams[type] ??= []).push(content));
54
+ decoder.on('data', (content) => output.push(content));
55
+ await new Promise((resolve, reject) => {
56
+ decoder.once('end', resolve).once('error', reject);
57
+ if (Buffer.isBuffer(input)) {
58
+ decoder.end(input);
59
+ }
60
+ else {
61
+ input.once('error', (error) => decoder.destroy(error));
62
+ input.pipe(decoder);
63
+ }
64
+ });
65
+ return {
66
+ output: Buffer.concat(output).toString(),
67
+ stdout: Buffer.concat(streams[DockerStreamType.STDOUT]).toString(),
68
+ stderr: Buffer.concat(streams[DockerStreamType.STDERR]).toString()
69
+ };
70
+ }
71
+ /**
72
+ * Read the JSON lines of a progress (a pull, a push, a build, a load): each object is given to the callback, all of them
73
+ * are given back once the stream ends. The lines which are not JSON are skipped
74
+ * @param input
75
+ * @param onProgress
76
+ */
77
+ export async function followProgress(input, onProgress) {
78
+ const objects = [];
79
+ let pending = '';
80
+ const line = (text) => {
81
+ const trimmed = text.trim();
82
+ if (!trimmed)
83
+ return;
84
+ let object;
85
+ try {
86
+ object = JSON.parse(trimmed);
87
+ }
88
+ catch {
89
+ return;
90
+ }
91
+ objects.push(object);
92
+ onProgress?.(object);
93
+ };
94
+ await new Promise((resolve, reject) => {
95
+ input.on('data', (chunk) => {
96
+ pending += chunk.toString();
97
+ let position;
98
+ while ((position = pending.indexOf('\n')) >= 0) {
99
+ line(pending.slice(0, position));
100
+ pending = pending.slice(position + 1);
101
+ }
102
+ });
103
+ input.once('end', () => {
104
+ line(pending);
105
+ resolve();
106
+ });
107
+ input.once('close', resolve);
108
+ input.once('error', reject);
109
+ });
110
+ return objects;
111
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,142 @@
1
+ import { Docker } from './Docker.js';
2
+ /**
3
+ * Build the component options of a {@link Docker} connected as the options say, to register it in the `components` of
4
+ * an application under the name of your choice. Without `socketPath` nor `host`, it connects to the Docker of the
5
+ * environment (`DOCKER_HOST`, else the local socket). The options are validated when the component is created, not
6
+ * here.
7
+ * @param options The connection options: a socket (`socketPath`), or a `host` and `port` reached with `protocol`
8
+ * (`'http'`, `'https'` or `'ssh'`), with their TLS, SSH, timeout and API version options.
9
+ * @returns The component options (`{class: Docker, ...options}`).
10
+ * @example
11
+ * ```typescript
12
+ * import {Application} from 'lakutata'
13
+ * import {buildDockerConnectionOptions} from 'lakutata/com/docker'
14
+ *
15
+ * Application.run(() => ({
16
+ * id: 'docker.app',
17
+ * name: 'Docker',
18
+ * components: {
19
+ * //The Docker of the environment (DOCKER_HOST, else the local socket), with the API version 1.47
20
+ * docker: buildDockerConnectionOptions({version: '1.47'})
21
+ * }
22
+ * }))
23
+ * ```
24
+ */
25
+ export const buildDockerConnectionOptions = (options) => ({
26
+ ...options,
27
+ class: Docker
28
+ });
29
+ /**
30
+ * Build the component options of a {@link Docker} connected to the Unix socket of a daemon (or its named pipe on
31
+ * Windows), to register it in the `components` of an application. The options are validated when the component is
32
+ * created, not here.
33
+ * @param options The path of the socket (`socketPath`), with the timeout and the API version. Without `socketPath`, the
34
+ * Docker of the environment is used, with the other options applied over it.
35
+ * @returns The component options (`{class: Docker, ...options}`).
36
+ * @example
37
+ * ```typescript
38
+ * import {Application} from 'lakutata'
39
+ * import {buildDockerSocketConnectionOptions} from 'lakutata/com/docker'
40
+ *
41
+ * Application.run(() => ({
42
+ * id: 'docker.app',
43
+ * name: 'Docker',
44
+ * components: {
45
+ * docker: buildDockerSocketConnectionOptions({socketPath: '/var/run/docker.sock', timeout: 60000})
46
+ * }
47
+ * }))
48
+ * ```
49
+ */
50
+ export const buildDockerSocketConnectionOptions = (options) => ({
51
+ ...options,
52
+ class: Docker
53
+ });
54
+ /**
55
+ * Build the component options of a {@link Docker} connected to a daemon over plain HTTP (`dockerd -H tcp://0.0.0.0:2375`),
56
+ * to register it in the `components` of an application. The connection is neither encrypted nor authenticated: keep it
57
+ * to trusted networks. The options are validated when the component is created, not here.
58
+ * @param options The `host` and `port` of the daemon, with the headers, the timeout and the API version; the `protocol`
59
+ * is set to `'http'`.
60
+ * @returns The component options (`{class: Docker, protocol: 'http', ...options}`).
61
+ * @example
62
+ * ```typescript
63
+ * import {Application} from 'lakutata'
64
+ * import {buildDockerHttpConnectionOptions} from 'lakutata/com/docker'
65
+ *
66
+ * Application.run(() => ({
67
+ * id: 'docker.app',
68
+ * name: 'Docker',
69
+ * components: {
70
+ * docker: buildDockerHttpConnectionOptions({host: '192.168.1.10', port: 2375})
71
+ * }
72
+ * }))
73
+ * ```
74
+ */
75
+ export const buildDockerHttpConnectionOptions = (options) => ({
76
+ ...options,
77
+ protocol: 'http',
78
+ class: Docker
79
+ });
80
+ /**
81
+ * Build the component options of a {@link Docker} connected to a daemon over HTTPS (`dockerd --tlsverify -H
82
+ * tcp://0.0.0.0:2376`), to register it in the `components` of an application. The options are validated when the
83
+ * component is created, not here.
84
+ * @param options The `host` and `port` of the daemon, with the PEM contents of the authority (`ca`), the client
85
+ * certificate (`cert`) and its key (`key`), the headers, the timeout and the API version; the `protocol` is set to
86
+ * `'https'`.
87
+ * @returns The component options (`{class: Docker, protocol: 'https', ...options}`).
88
+ * @example
89
+ * ```typescript
90
+ * import {readFileSync} from 'node:fs'
91
+ * import {Application} from 'lakutata'
92
+ * import {buildDockerHttpsConnectionOptions} from 'lakutata/com/docker'
93
+ *
94
+ * Application.run(() => ({
95
+ * id: 'docker.app',
96
+ * name: 'Docker',
97
+ * components: {
98
+ * //The PEM contents, not the file paths
99
+ * docker: buildDockerHttpsConnectionOptions({
100
+ * host: 'docker.example.com',
101
+ * port: 2376,
102
+ * ca: readFileSync('/etc/docker/certs/ca.pem'),
103
+ * cert: readFileSync('/etc/docker/certs/cert.pem'),
104
+ * key: readFileSync('/etc/docker/certs/key.pem')
105
+ * })
106
+ * }
107
+ * }))
108
+ * ```
109
+ */
110
+ export const buildDockerHttpsConnectionOptions = (options) => ({
111
+ ...options,
112
+ protocol: 'https',
113
+ class: Docker
114
+ });
115
+ /**
116
+ * Build the component options of a {@link Docker} connected to a remote daemon over SSH, as `DOCKER_HOST=ssh://user@host`
117
+ * does, to register it in the `components` of an application. The requests go through `docker system dial-stdio` run on
118
+ * the remote host, which needs the Docker CLI; locally, the optional package `ssh2` must be installed. The SSH connection
119
+ * authenticates through the SSH agent (no password). The options are validated when the component is created, not here.
120
+ * @param options The `host` and `port` (the SSH port, usually 22) of the remote host, the `username`, the SSH agent's
121
+ * socket (`sshAuthAgent`; `SSH_AUTH_SOCK` by default), the timeout and the API version; the `protocol` is set to
122
+ * `'ssh'`.
123
+ * @returns The component options (`{class: Docker, protocol: 'ssh', ...options}`).
124
+ * @example
125
+ * ```typescript
126
+ * import {Application} from 'lakutata'
127
+ * import {buildDockerSSHConnectionOptions} from 'lakutata/com/docker'
128
+ *
129
+ * Application.run(() => ({
130
+ * id: 'docker.app',
131
+ * name: 'Docker',
132
+ * components: {
133
+ * docker: buildDockerSSHConnectionOptions({host: 'docker.example.com', port: 22, username: 'deploy'})
134
+ * }
135
+ * }))
136
+ * ```
137
+ */
138
+ export const buildDockerSSHConnectionOptions = (options) => ({
139
+ ...options,
140
+ protocol: 'ssh',
141
+ class: Docker
142
+ });