@zukhruf/docker 0.0.0-stage → 0.3.34

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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +902 -2
  3. package/dist/api-version.d.ts +7 -0
  4. package/dist/api-version.d.ts.map +1 -0
  5. package/dist/api-version.js +22 -0
  6. package/dist/api-version.js.map +1 -0
  7. package/dist/container-process.d.ts +35 -0
  8. package/dist/container-process.d.ts.map +1 -0
  9. package/dist/container-process.js +91 -0
  10. package/dist/container-process.js.map +1 -0
  11. package/dist/containers.d.ts +160 -0
  12. package/dist/containers.d.ts.map +1 -0
  13. package/dist/containers.js +700 -0
  14. package/dist/containers.js.map +1 -0
  15. package/dist/context-store.d.ts +22 -0
  16. package/dist/context-store.d.ts.map +1 -0
  17. package/dist/context-store.js +128 -0
  18. package/dist/context-store.js.map +1 -0
  19. package/dist/docker.d.ts +57 -0
  20. package/dist/docker.d.ts.map +1 -0
  21. package/dist/docker.js +96 -0
  22. package/dist/docker.js.map +1 -0
  23. package/dist/engine-api.d.ts +390 -0
  24. package/dist/engine-api.d.ts.map +1 -0
  25. package/dist/engine-api.js +4 -0
  26. package/dist/engine-api.js.map +1 -0
  27. package/dist/engine-client.d.ts +74 -0
  28. package/dist/engine-client.d.ts.map +1 -0
  29. package/dist/engine-client.js +253 -0
  30. package/dist/engine-client.js.map +1 -0
  31. package/dist/errors.d.ts +133 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +214 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/host.d.ts +13 -0
  36. package/dist/host.d.ts.map +1 -0
  37. package/dist/host.js +22 -0
  38. package/dist/host.js.map +1 -0
  39. package/dist/images.d.ts +40 -0
  40. package/dist/images.d.ts.map +1 -0
  41. package/dist/images.js +173 -0
  42. package/dist/images.js.map +1 -0
  43. package/dist/index.d.ts +14 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +6 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/multiplexed-stream.d.ts +11 -0
  48. package/dist/multiplexed-stream.d.ts.map +1 -0
  49. package/dist/multiplexed-stream.js +81 -0
  50. package/dist/multiplexed-stream.js.map +1 -0
  51. package/dist/ndjson.d.ts +7 -0
  52. package/dist/ndjson.d.ts.map +1 -0
  53. package/dist/ndjson.js +21 -0
  54. package/dist/ndjson.js.map +1 -0
  55. package/dist/networks.d.ts +46 -0
  56. package/dist/networks.d.ts.map +1 -0
  57. package/dist/networks.js +170 -0
  58. package/dist/networks.js.map +1 -0
  59. package/dist/options.d.ts +7 -0
  60. package/dist/options.d.ts.map +1 -0
  61. package/dist/options.js +2 -0
  62. package/dist/options.js.map +1 -0
  63. package/dist/output.d.ts +18 -0
  64. package/dist/output.d.ts.map +1 -0
  65. package/dist/output.js +21 -0
  66. package/dist/output.js.map +1 -0
  67. package/dist/progress.d.ts +9 -0
  68. package/dist/progress.d.ts.map +1 -0
  69. package/dist/progress.js +20 -0
  70. package/dist/progress.js.map +1 -0
  71. package/dist/ssh-connection.d.ts +23 -0
  72. package/dist/ssh-connection.d.ts.map +1 -0
  73. package/dist/ssh-connection.js +225 -0
  74. package/dist/ssh-connection.js.map +1 -0
  75. package/dist/tar-reader.d.ts +22 -0
  76. package/dist/tar-reader.d.ts.map +1 -0
  77. package/dist/tar-reader.js +163 -0
  78. package/dist/tar-reader.js.map +1 -0
  79. package/dist/tar-writer.d.ts +16 -0
  80. package/dist/tar-writer.d.ts.map +1 -0
  81. package/dist/tar-writer.js +114 -0
  82. package/dist/tar-writer.js.map +1 -0
  83. package/dist/transport.d.ts +29 -0
  84. package/dist/transport.d.ts.map +1 -0
  85. package/dist/transport.js +56 -0
  86. package/dist/transport.js.map +1 -0
  87. package/dist/volumes.d.ts +41 -0
  88. package/dist/volumes.d.ts.map +1 -0
  89. package/dist/volumes.js +119 -0
  90. package/dist/volumes.js.map +1 -0
  91. package/package.json +43 -4
package/dist/host.js ADDED
@@ -0,0 +1,22 @@
1
+ import { UnsupportedHostError } from "./errors.js";
2
+ /** Parses a unix://, npipe:// or ssh:// host. Each other host is an UnsupportedHostError. */
3
+ export function parseHost(host) {
4
+ if (host.startsWith('unix://')) {
5
+ const socketPath = host.slice('unix://'.length);
6
+ if (socketPath)
7
+ return { kind: 'unix', host, socketPath };
8
+ }
9
+ else if (host.startsWith('npipe://')) {
10
+ // npipe:////./pipe/docker_engine is the pipe \\.\pipe\docker_engine.
11
+ const socketPath = host.slice('npipe://'.length).replaceAll('/', '\\');
12
+ if (socketPath)
13
+ return { kind: 'npipe', host, socketPath };
14
+ }
15
+ else if (host.startsWith('ssh://') && URL.canParse(host)) {
16
+ const url = new URL(host);
17
+ if (url.hostname)
18
+ return { kind: 'ssh', host, url };
19
+ }
20
+ throw new UnsupportedHostError(host);
21
+ }
22
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAOnD,6FAA6F;AAC7F,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,UAAU;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC5D,CAAC;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,qEAAqE;QACrE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACvE,IAAI,UAAU;YAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC7D,CAAC;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,GAAG,CAAC,QAAQ;YAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IACtD,CAAC;IACD,MAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type * as EngineApi from './engine-api.ts';
2
+ import { type EngineClient } from './engine-client.ts';
3
+ import type { CancelOptions, Filters } from './options.ts';
4
+ /** The images of one engine. Images have no owner, so no handle removes one on disposal. */
5
+ export declare class Images {
6
+ #private;
7
+ constructor(client: EngineClient);
8
+ /** undefined for 404. */
9
+ inspect(reference: string, options?: CancelOptions): Promise<EngineApi.ImageInspect | undefined>;
10
+ /** Pulls the image and reads the progress of the engine to its end. */
11
+ pull(reference: string, options?: CancelOptions & {
12
+ platform?: string;
13
+ auth?: EngineApi.AuthConfig;
14
+ }): Promise<void>;
15
+ list(options?: CancelOptions & {
16
+ all?: boolean;
17
+ filters?: Filters;
18
+ }): Promise<EngineApi.ImageSummary[]>;
19
+ /** Gives the image a second name, such as a registry name before a push. target: 'repository:tag'; with no tag, the tag is 'latest', as the Docker CLI does. */
20
+ tag(reference: string, target: string, options?: CancelOptions): Promise<void>;
21
+ /**
22
+ * Pushes the image and reads the progress of the engine to its end. The
23
+ * engine answers a push of an image that it does not have with 200, and
24
+ * then reports the error in the progress: an inspect of the reference tells
25
+ * a missing image from another error.
26
+ */
27
+ push(reference: string, options: CancelOptions & {
28
+ auth: EngineApi.AuthConfig;
29
+ }): Promise<void>;
30
+ /** A tar archive of the images, as `docker save` writes it. */
31
+ save(references: string[], options?: CancelOptions): Promise<ReadableStream<Uint8Array>>;
32
+ /** Loads the images of a tar archive and reads the progress of the engine to its end. */
33
+ load(archive: ReadableStream<Uint8Array> | Uint8Array, options?: CancelOptions): Promise<void>;
34
+ /** Resolves for 404. A 409 is an ImageInUseError: a container uses the image, or, by ID, several names refer to it. */
35
+ remove(reference: string, options?: CancelOptions & {
36
+ force?: boolean;
37
+ noprune?: boolean;
38
+ }): Promise<void>;
39
+ }
40
+ //# sourceMappingURL=images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAM7E,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA+B3D,4FAA4F;AAC5F,qBAAa,MAAM;;gBAGL,MAAM,EAAE,YAAY;IAIhC,yBAAyB;IACnB,OAAO,CACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,SAAS,CAAC,YAAY,GAAG,SAAS,CAAC;IAS9C,uEAAuE;IACjE,IAAI,CACR,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAa,GAAG;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC;KACxB,GACL,OAAO,CAAC,IAAI,CAAC;IAkChB,IAAI,CACF,OAAO,GAAE,aAAa,GAAG;QAAE,GAAG,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,GACjE,OAAO,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IAOpC,gKAAgK;IAC1J,GAAG,CACP,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC;IAkBhB;;;;;OAKG;IACG,IAAI,CACR,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,aAAa,GAAG;QAAE,IAAI,EAAE,SAAS,CAAC,UAAU,CAAA;KAAE,GACtD,OAAO,CAAC,IAAI,CAAC;IAgChB,+DAA+D;IACzD,IAAI,CACR,UAAU,EAAE,MAAM,EAAE,EACpB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAQtC,yFAAyF;IACnF,IAAI,CACR,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU,EAChD,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC;IAUhB,uHAAuH;IACjH,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAa,GAAG;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,GACnE,OAAO,CAAC,IAAI,CAAC;CAgBjB"}
package/dist/images.js ADDED
@@ -0,0 +1,173 @@
1
+ import { Readable } from 'node:stream';
2
+ import { isSuccess, parseBody } from "./engine-client.js";
3
+ import { DockerEngineError, ImageInUseError, ImageNotFoundError, } from "./errors.js";
4
+ import { readProgress } from "./progress.js";
5
+ /**
6
+ * The repository and the tag of a reference. A reference with a digest has no
7
+ * tag, and its repository is the whole reference.
8
+ */
9
+ function splitReference(reference) {
10
+ const colon = reference.lastIndexOf(':');
11
+ if (reference.includes('@') || colon <= reference.lastIndexOf('/')) {
12
+ return { repository: reference, tag: undefined };
13
+ }
14
+ return {
15
+ repository: reference.slice(0, colon),
16
+ tag: reference.slice(colon + 1),
17
+ };
18
+ }
19
+ /**
20
+ * A reference with no tag and no digest pulls each tag of the repository, so
21
+ * the pull names the tag 'latest', as the Docker CLI does.
22
+ */
23
+ function pullQuery(reference, platform) {
24
+ const bare = !reference.includes('@') && splitReference(reference).tag === undefined;
25
+ return { fromImage: reference, tag: bare ? 'latest' : undefined, platform };
26
+ }
27
+ /** The images of one engine. Images have no owner, so no handle removes one on disposal. */
28
+ export class Images {
29
+ #client;
30
+ constructor(client) {
31
+ this.#client = client;
32
+ }
33
+ /** undefined for 404. */
34
+ async inspect(reference, options = {}) {
35
+ const method = 'GET';
36
+ const path = `/images/${encodeURIComponent(reference)}/json`;
37
+ const response = await this.#client.exchange(method, path, options);
38
+ if (response.status === 404)
39
+ return undefined;
40
+ if (!isSuccess(response))
41
+ throw this.#client.error(response, method, path);
42
+ return parseBody(response);
43
+ }
44
+ /** Pulls the image and reads the progress of the engine to its end. */
45
+ async pull(reference, options = {}) {
46
+ const { platform, auth, signal } = options;
47
+ const method = 'POST';
48
+ const path = '/images/create';
49
+ const progress = await this.#client
50
+ .stream(method, path, {
51
+ query: pullQuery(reference, platform),
52
+ // The same X-Registry-Auth encoding is in push(): mirror a fix in both.
53
+ // Moby decodes it with the padded URLEncoding of Go, so the '=' stays.
54
+ headers: auth === undefined
55
+ ? undefined
56
+ : {
57
+ 'X-Registry-Auth': Buffer.from(JSON.stringify(auth))
58
+ .toString('base64')
59
+ .replaceAll('+', '-')
60
+ .replaceAll('/', '_'),
61
+ },
62
+ signal,
63
+ })
64
+ .catch((error) => {
65
+ if (error instanceof DockerEngineError && error.status === 404) {
66
+ throw new ImageNotFoundError(error.message, { status: 404, request: { method, path } }, reference, { cause: error });
67
+ }
68
+ throw error;
69
+ });
70
+ await readProgress(progress, { method, path });
71
+ }
72
+ list(options = {}) {
73
+ return this.#client.json('GET', '/images/json', {
74
+ query: { all: options.all, filters: options.filters },
75
+ signal: options.signal,
76
+ });
77
+ }
78
+ /** Gives the image a second name, such as a registry name before a push. target: 'repository:tag'; with no tag, the tag is 'latest', as the Docker CLI does. */
79
+ async tag(reference, target, options = {}) {
80
+ const method = 'POST';
81
+ const path = `/images/${encodeURIComponent(reference)}/tag`;
82
+ const { repository, tag = 'latest' } = splitReference(target);
83
+ const response = await this.#client.exchange(method, path, {
84
+ query: { repo: repository, tag },
85
+ signal: options.signal,
86
+ });
87
+ if (isSuccess(response))
88
+ return;
89
+ const error = this.#client.error(response, method, path);
90
+ if (response.status === 404) {
91
+ throw new ImageNotFoundError(error.message, error, reference, {
92
+ cause: error,
93
+ });
94
+ }
95
+ throw error;
96
+ }
97
+ /**
98
+ * Pushes the image and reads the progress of the engine to its end. The
99
+ * engine answers a push of an image that it does not have with 200, and
100
+ * then reports the error in the progress: an inspect of the reference tells
101
+ * a missing image from another error.
102
+ */
103
+ async push(reference, options) {
104
+ const { auth, signal } = options;
105
+ const { repository, tag = 'latest' } = splitReference(reference);
106
+ const method = 'POST';
107
+ const path = `/images/${encodeURIComponent(repository)}/push`;
108
+ try {
109
+ const progress = await this.#client.stream(method, path, {
110
+ query: { tag },
111
+ // The same X-Registry-Auth encoding is in pull(): mirror a fix in both.
112
+ // Moby decodes it with the padded URLEncoding of Go, so the '=' stays.
113
+ headers: {
114
+ 'X-Registry-Auth': Buffer.from(JSON.stringify(auth))
115
+ .toString('base64')
116
+ .replaceAll('+', '-')
117
+ .replaceAll('/', '_'),
118
+ },
119
+ signal,
120
+ });
121
+ await readProgress(progress, { method, path });
122
+ }
123
+ catch (error) {
124
+ if (!(error instanceof DockerEngineError))
125
+ throw error;
126
+ const missing = error.status === 404 ||
127
+ (error.status === undefined &&
128
+ (await this.inspect(reference, options)) === undefined);
129
+ if (!missing)
130
+ throw error;
131
+ throw new ImageNotFoundError(error.message, error, reference, {
132
+ cause: error,
133
+ });
134
+ }
135
+ }
136
+ /** A tar archive of the images, as `docker save` writes it. */
137
+ async save(references, options = {}) {
138
+ const response = await this.#client.stream('GET', '/images/get', {
139
+ query: { names: references },
140
+ signal: options.signal,
141
+ });
142
+ return Readable.toWeb(response);
143
+ }
144
+ /** Loads the images of a tar archive and reads the progress of the engine to its end. */
145
+ async load(archive, options = {}) {
146
+ const method = 'POST';
147
+ const path = '/images/load';
148
+ const progress = await this.#client.stream(method, path, {
149
+ content: { type: 'application/x-tar', data: archive },
150
+ signal: options.signal,
151
+ });
152
+ await readProgress(progress, { method, path });
153
+ }
154
+ /** Resolves for 404. A 409 is an ImageInUseError: a container uses the image, or, by ID, several names refer to it. */
155
+ async remove(reference, options = {}) {
156
+ const method = 'DELETE';
157
+ const path = `/images/${encodeURIComponent(reference)}`;
158
+ const response = await this.#client.exchange(method, path, {
159
+ query: { force: options.force, noprune: options.noprune },
160
+ signal: options.signal,
161
+ });
162
+ if (isSuccess(response) || response.status === 404)
163
+ return;
164
+ const error = this.#client.error(response, method, path);
165
+ if (response.status === 409) {
166
+ throw new ImageInUseError(error.message, error, reference, {
167
+ cause: error,
168
+ });
169
+ }
170
+ throw error;
171
+ }
172
+ }
173
+ //# sourceMappingURL=images.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images.js","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAqB,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;GAGG;AACH,SAAS,cAAc,CAAC,SAAiB;IAIvC,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACnE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IACnD,CAAC;IACD,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;QACrC,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,C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Ae,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE;gBACzD,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export type { ContainerProcess } from './container-process.ts';
2
+ export { Container, type ContainerFile, type Containers, type Created, type LogQuery, OwnedContainer, } from './containers.ts';
3
+ export type { DockerContext, Environment } from './context-store.ts';
4
+ export { type ConnectOptions, Docker } from './docker.ts';
5
+ export { BindSourceNotFoundError, ConnectionFailedError, ContainerNotFoundError, ContainerNotRunningError, ContainerRunningError, ContextNotFoundError, DockerEngineError, DockerError, ImageInUseError, ImageNotFoundError, NameConflictError, NetworkInUseError, NetworkNotFoundError, NotAFileError, PathNotFoundError, ReadOnlyPathError, UnsupportedEngineError, UnsupportedHostError, VolumeInUseError, VolumeNotFoundError, } from './errors.ts';
6
+ export type { Images } from './images.ts';
7
+ export { Network, type Networks, OwnedNetwork } from './networks.ts';
8
+ export type { OutputChunk } from './multiplexed-stream.ts';
9
+ export type { CancelOptions, Filters } from './options.ts';
10
+ export type { ExecResult, Output } from './output.ts';
11
+ export { OwnedVolume, Volume, type Volumes } from './volumes.ts';
12
+ /** The bodies and answers of the Engine API, with the names of its reference. Types only. */
13
+ export type * as EngineApi from './engine-api.ts';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,SAAS,EACT,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACrE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjE,6FAA6F;AAC7F,YAAY,KAAK,SAAS,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { Container, OwnedContainer, } from "./containers.js";
2
+ export { Docker } from "./docker.js";
3
+ export { BindSourceNotFoundError, ConnectionFailedError, ContainerNotFoundError, ContainerNotRunningError, ContainerRunningError, ContextNotFoundError, DockerEngineError, DockerError, ImageInUseError, ImageNotFoundError, NameConflictError, NetworkInUseError, NetworkNotFoundError, NotAFileError, PathNotFoundError, ReadOnlyPathError, UnsupportedEngineError, UnsupportedHostError, VolumeInUseError, VolumeNotFoundError, } from "./errors.js";
4
+ export { Network, OwnedNetwork } from "./networks.js";
5
+ export { OwnedVolume, Volume } from "./volumes.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EAKT,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAuB,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,OAAO,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AAIrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAgB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** One piece of output of a container process: its stream and its bytes. */
2
+ export interface OutputChunk {
3
+ stream: 'stdout' | 'stderr';
4
+ data: Uint8Array;
5
+ }
6
+ /**
7
+ * The output chunks of a multiplexed stream or of a raw stream, as the
8
+ * Content-Type of the answer names it.
9
+ */
10
+ export declare function outputChunks(bytes: AsyncIterable<Uint8Array>, contentType: string): AsyncGenerator<OutputChunk>;
11
+ //# sourceMappingURL=multiplexed-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexed-stream.d.ts","sourceRoot":"","sources":["../src/multiplexed-stream.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;CAClB;AA6ED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAChC,WAAW,EAAE,MAAM,GAClB,cAAc,CAAC,WAAW,CAAC,CAG7B"}
@@ -0,0 +1,81 @@
1
+ import { DockerError } from "./errors.js";
2
+ /** The media type of the output of a container that has no TTY. */
3
+ const MULTIPLEXED_STREAM = 'application/vnd.docker.multiplexed-stream';
4
+ /** The length of the header of a frame: the stream, three zero bytes, and the length, big-endian. */
5
+ const HEADER_LENGTH = 8;
6
+ /**
7
+ * The stream of a frame. The engine marks the input of a TTY as stdin (0),
8
+ * and stdcopy of Moby writes it to standard output; 3 is an error of the
9
+ * engine in the stream.
10
+ */
11
+ function streamOf(marker) {
12
+ if (marker === 0 || marker === 1)
13
+ return 'stdout';
14
+ if (marker === 2)
15
+ return 'stderr';
16
+ return 'error';
17
+ }
18
+ /**
19
+ * The frames of a multiplexed stream as output chunks. A frame can span chunk
20
+ * borders: the part of a frame that a chunk has comes as its own output chunk,
21
+ * so a large frame never waits in memory. The bytes are read at the pace of
22
+ * the caller.
23
+ */
24
+ async function* frames(bytes) {
25
+ let header = new Uint8Array(0);
26
+ let stream = 'stdout';
27
+ let remaining = 0;
28
+ let error = '';
29
+ const decoder = new TextDecoder();
30
+ for await (const chunk of bytes) {
31
+ let offset = 0;
32
+ while (offset < chunk.byteLength) {
33
+ if (remaining === 0) {
34
+ const needed = HEADER_LENGTH - header.byteLength;
35
+ const part = chunk.subarray(offset, offset + needed);
36
+ header = concat(header, part);
37
+ offset += part.byteLength;
38
+ if (header.byteLength < HEADER_LENGTH)
39
+ break;
40
+ const view = new DataView(header.buffer, header.byteOffset);
41
+ stream = streamOf(view.getUint8(0));
42
+ remaining = view.getUint32(4);
43
+ header = new Uint8Array(0);
44
+ continue;
45
+ }
46
+ const data = chunk.subarray(offset, offset + remaining);
47
+ offset += data.byteLength;
48
+ remaining -= data.byteLength;
49
+ if (stream === 'error') {
50
+ error += decoder.decode(data, { stream: remaining > 0 });
51
+ if (remaining === 0)
52
+ throw new DockerError(error);
53
+ }
54
+ else {
55
+ yield { stream, data };
56
+ }
57
+ }
58
+ }
59
+ }
60
+ function concat(left, right) {
61
+ const joined = new Uint8Array(left.byteLength + right.byteLength);
62
+ joined.set(left);
63
+ joined.set(right, left.byteLength);
64
+ return joined;
65
+ }
66
+ /** A raw stream has no frames: each chunk is standard output. */
67
+ async function* raw(bytes) {
68
+ for await (const data of bytes) {
69
+ if (data.byteLength > 0)
70
+ yield { stream: 'stdout', data };
71
+ }
72
+ }
73
+ /**
74
+ * The output chunks of a multiplexed stream or of a raw stream, as the
75
+ * Content-Type of the answer names it.
76
+ */
77
+ export function outputChunks(bytes, contentType) {
78
+ const mediaType = contentType.split(';')[0]?.trim();
79
+ return mediaType === MULTIPLEXED_STREAM ? frames(bytes) : raw(bytes);
80
+ }
81
+ //# sourceMappingURL=multiplexed-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexed-stream.js","sourceRoot":"","sources":["../src/multiplexed-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ1C,mEAAmE;AACnE,MAAM,kBAAkB,GAAG,2CAA2C,CAAC;AAEvE,qGAAqG;AACrG,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;;GAIG;AACH,SAAS,QAAQ,CAAC,MAAc;IAC9B,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAClD,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAClC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,KAAK,SAAS,CAAC,CAAC,MAAM,CACpB,KAAgC;IAEhC,IAAI,MAAM,GAAe,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAkC,QAAQ,CAAC;IACrD,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;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CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,IAAgB,EAAE,KAAiB;IACjD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAClE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iEAAiE;AACjE,KAAK,SAAS,CAAC,CAAC,GAAG,CACjB,KAAgC;IAEhC,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC;YAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAgC,EAChC,WAAmB;IAEnB,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IACpD,OAAO,SAAS,KAAK,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The values of a stream of newline-delimited JSON. A chunk can end inside a
3
+ * line, or inside a UTF-8 character: the line waits for the next chunk. An
4
+ * empty line has no value.
5
+ */
6
+ export declare function ndjson(chunks: AsyncIterable<Uint8Array>): AsyncGenerator<unknown>;
7
+ //# sourceMappingURL=ndjson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ndjson.d.ts","sourceRoot":"","sources":["../src/ndjson.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAuB,MAAM,CAC3B,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAChC,cAAc,CAAC,OAAO,CAAC,CAWzB"}
package/dist/ndjson.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The values of a stream of newline-delimited JSON. A chunk can end inside a
3
+ * line, or inside a UTF-8 character: the line waits for the next chunk. An
4
+ * empty line has no value.
5
+ */
6
+ export async function* ndjson(chunks) {
7
+ const decoder = new TextDecoder();
8
+ let rest = '';
9
+ for await (const chunk of chunks) {
10
+ rest += decoder.decode(chunk, { stream: true });
11
+ const lines = rest.split('\n');
12
+ rest = lines.pop() ?? '';
13
+ for (const line of lines)
14
+ if (line.trim())
15
+ yield JSON.parse(line);
16
+ }
17
+ rest += decoder.decode();
18
+ if (rest.trim())
19
+ yield JSON.parse(rest);
20
+ }
21
+ //# sourceMappingURL=ndjson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ndjson.js","sourceRoot":"","sources":["../src/ndjson.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,MAAM,CAC3B,MAAiC;IAEjC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,IAAI,IAAI,CAAC,IAAI,EAAE;gBAAE,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IACzB,IAAI,IAAI,CAAC,IAAI,EAAE;QAAE,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { Container, Created } from './containers.ts';
2
+ import type * as EngineApi from './engine-api.ts';
3
+ import { type EngineClient } from './engine-client.ts';
4
+ import type { CancelOptions, Filters } from './options.ts';
5
+ /** A network, by the ID that the engine gave it. It has no disposal. */
6
+ export declare class Network {
7
+ #private;
8
+ readonly id: string;
9
+ constructor(client: EngineClient, id: string);
10
+ inspect(options?: CancelOptions): Promise<EngineApi.NetworkInspect>;
11
+ connect(container: Container, endpoint?: EngineApi.NetworkConnectRequest['EndpointConfig'], options?: CancelOptions): Promise<void>;
12
+ disconnect(container: Container, options?: CancelOptions & {
13
+ force?: boolean;
14
+ }): Promise<void>;
15
+ /**
16
+ * Resolves for 404. A 403 is a pre-defined network or a network with
17
+ * connected containers: an inspect tells which. A pre-defined network can
18
+ * have connected containers too, so its name decides first. Only a running
19
+ * container has an endpoint, so only a running one keeps the network.
20
+ */
21
+ remove(options?: CancelOptions): Promise<void>;
22
+ }
23
+ /** A network that this handle created. Disposal removes it. */
24
+ export declare class OwnedNetwork extends Network implements AsyncDisposable {
25
+ /** remove() */
26
+ [Symbol.asyncDispose](): Promise<void>;
27
+ }
28
+ /** The networks of one engine. */
29
+ export declare class Networks {
30
+ #private;
31
+ constructor(client: EngineClient);
32
+ /** From API 1.44, the engine refuses a taken name with 409: it rejects with NameConflictError. */
33
+ create(body: EngineApi.NetworkCreateRequest, options?: CancelOptions): Promise<OwnedNetwork>;
34
+ /**
35
+ * Creates the network, or gives the one that has the name. The network that
36
+ * exists wins. When that network is removed between the 409 and the
37
+ * inspect, the create runs again.
38
+ */
39
+ createOrGet(body: EngineApi.NetworkCreateRequest, options?: CancelOptions): Promise<Created<'network', OwnedNetwork, Network>>;
40
+ /** One inspect: a handle with the ID of the engine, or undefined for 404. */
41
+ find(nameOrId: string, options?: CancelOptions): Promise<Network | undefined>;
42
+ list(options?: CancelOptions & {
43
+ filters?: Filters;
44
+ }): Promise<EngineApi.NetworkSummary[]>;
45
+ }
46
+ //# sourceMappingURL=networks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../src/networks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAO7E,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK3D,wEAAwE;AACxE,qBAAa,OAAO;;IAClB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;gBAGR,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;IAStC,OAAO,CACX,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC;IAc9B,OAAO,CACX,SAAS,EAAE,SAAS,EACpB,QAAQ,CAAC,EAAE,SAAS,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,EAC5D,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC;IAKV,UAAU,CACd,SAAS,EAAE,SAAS,EACpB,OAAO,GAAE,aAAa,GAAG;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAChD,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;OAKG;IACG,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAmDzD;AAED,+DAA+D;AAC/D,qBAAa,YAAa,SAAQ,OAAQ,YAAW,eAAe;IAClE,eA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